problem in getting tree heirarachy structure in a form.

Discussion about the open-source Phalanger [?] project.

problem in getting tree heirarachy structure in a form.

Postby phalanger@codeplex » October 6th, 2006, 1:19 pm

Hai,
I'm trying to get tree heirarchy structure in a form( like windows explorer ). Following are the 2 files, that i'm not able to get the output(form).I'm getting 0 error. can u find out the problem in the code?

1) File---- Demo.php

<?
import namespace System;
import namespace system:::Windows:::Forms;
import namespace System:::Collections:::Generic;

import namespace Phalanger;

namespace Phalanger
{
class Demo
{
// The entry point of the application
public static function Main()
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
$form = new TreeForm ;
Application::Run($form);
}
}
}
?>



2)File --- TreeForm.php
<?php
import namespace System;
import namespace System:::Drawing;
import namespace System:::Collections;
import namespace System:::ComponentModel;
import namespace System:::ServiceProcess;
import namespace System:::Management;
import namespace System:::Diagnostics;
import namespace System:::Windows:::Forms;
import namespace System:::Windows:::Forms:::TreeNode;
import namespace System:::Threading ;
import namespace Phalanger ;

namespace Phalanger
{
class TreeForm extends Form
{

public function __construct()
{
$this->InitializeComponent();
}

private function InitializeComponent()
{
$treeNode1 = new TreeNode();
$treeNode2 = new TreeNode();
$treeNode3 = new TreeNode();
$treeNode4 = new TreeNode();
$treeNode5 = new TreeNode();
$treeNode6 = new TreeNode( $this->add(array( $treeNode2,$treeNode3,$treeNode4, $treeNode5 ) ) );
$treeNode7 = new TreeNode();
$treeNode8 = new TreeNode( $this->add( array( $treeNode7) )) ;

/*** $treeNode1 = new TreeNode("root");
$treeNode2 = new TreeNode("bin");
$treeNode3 = new TreeNode("etc");
$treeNode4 = new TreeNode("dev");
$treeNode5 = new TreeNode("local");
$treeNode6 = new TreeNode("usr", array( $treeNode2,$treeNode3,$treeNode4, $treeNode5 ) );
$treeNode7 = new TreeNode("usr");
$treeNode8 = new TreeNode("lost", array( $this->treeNode7) ); *****/

$this->treeView = new TreeView();
$this->SuspendLayout();
//
// treeView
//
$this->treeView->AllowDrop = true;
$this->treeView->Cursor = $this->Cursors->Hand;
$this->treeView->Font = new Font("Times New Roman", 8.25, $this->FontStyle->Regular, $this->GraphicsUnit->Point, 0 );
$this->treeView->FullRowSelect = true;
$this->treeView->HideSelection = false;
$this->treeView->ImeMode = $this->ImeMode->AlphaFull;
$this->treeView->LineColor = Color::FromArgb( 64,0, 64);
$this->treeView->Location = new Point(0, -2);
$this->treeView->Margin = new Padding(4);
$this->treeView->Name = "treeView";
$treeNode1->BackColor = $this->SystemColors->ActiveCaptionText;
$treeNode1->Checked = true;
$treeNode1->ForeColor = Color::FromArgb(0,192,0);
$treeNode1->Name = "Node0";
$treeNode1->NodeFont = new Font("Verdana", 8.25, $this->FontStyle->Regular, $this->GraphicsUnit->Point,0);
$treeNode1->Text = "root";
$treeNode1->ToolTipText = "Admin";
$treeNode2->ForeColor = Color::FromArgb( 128 , 64 ,0);
$treeNode2->Name = "bin";
$treeNode2->NodeFont = new Font("Arial", 8.25, $this->FontStyle->Regular, $this->GraphicsUnit->Point, 0 );
$treeNode2->Text = "bin";
$treeNode2->ToolTipText = "Click to show bin";
$treeNode3->ForeColor = Color::FromArgb( 128, 64,0);
$treeNode3->Name = "etc";
$treeNode3->Text = "etc";
$treeNode3->ToolTipText = "Click to show etc";
$treeNode4->ForeColor = Color::FromArgb( 128 , 64, 0 );
$treeNode4->Name = "dev";
$treeNode4->NodeFont = new Font("Arial", 8.25, $this->FontStyle->Regular, $this->GraphicsUnit->Point, 0);
$treeNode4->Text = "dev";
$treeNode4->ToolTipText = "Click to show dev";
$treeNode5->ForeColor = Color::FromArgb( 128,64 ,0 );
$treeNode5->Name = "usr";
$treeNode5->NodeFont = new Font("Arial", 8.25, $this->FontStyle->Regular, $this->GraphicsUnit->Point,0);
$treeNode5->Text = "usr";
$treeNode5->ToolTipText = "Click to show usr";
$treeNode6->ForeColor = Color::FromArgb(0,192,0);
$treeNode6->Name = "Functions";
$treeNode6->NodeFont = new Font("Georgia", 8.25, $this->fontStyle->Regular, $this->GraphicsUnit->Point,0);
$treeNode6->Text = "lost";
$treeNode6->ToolTipText = "Click to show Functions";
$treeNode7->Name = "lost";
$treeNode7->Text = "lost";
$treeNode7->ToolTipText = "Click to show lost";
$treeNode8->ForeColor = Color::FromArgb( 0, 192, 0);
$treeNode8->Name = "Mssql ";
$treeNode8->NodeFont = new Font("Georgia", 8.25,$this->FontStyle->Regular, $this->GraphicsUnit->Point, 0);
$treeNode8->Text = "Mssql Databases";
$treeNode8->ToolTipText = "Click to show Mssql Databases";
$this->treeView->Nodes->AddRange( array( $treeNode1,$treeNode6,$treeNode8 ) );
$this->treeView->PathSeparator = "";
$this->treeView->RightToLeft = $this->RightToLeft->No;
$this->treeView->RightToLeftLayout = true;
$this->treeView->ShowNodeToolTips = true;
$this->treeView->Size = new Size(163, 293);
$this->treeView->TabIndex = 0;
$this->treeView->ClientSizeChanged->add(array ( $this,"treeView_ClientSizeChanged") );
$this->treeView->AfterSelect->add( array ($this, "treeView1_AfterSelect")) ;
//
// Form1
//
$this->AutoScaleDimensions = new Size(6, 13);
$this->AutoScaleMode = AutoScaleMode::Font;
$this->ClientSize = new Size(423, 291);
$this->Controls->Add($this->treeView);
$this->KeyPreview = true;
$this->Name = "Form1";
$this->Text = "Form1";
$this->ResumeLayout(false);

}
}
}
Thank you.



phalanger@codeplex
 
Posts: 8
Joined: January 7th, 2012, 8:57 pm

RE: problem in getting tree heirarachy structure in a form.

Postby tomasp » October 10th, 2006, 10:25 pm

Hi,
the "ugly" compiler error message is caused by the "$this->GraphicsUnit->Point" expression. This is not correct, because GraphicsUnit is not a member of Form. It is a .NET enumeration, so you should use "FontStyle::Regular" instead.

Hope this helps!
Tomas
tomasp
 
Posts: 46
Joined: January 7th, 2012, 8:37 pm

RE: problem in getting tree heirarachy structure in a form.

Postby phalanger@codeplex » October 11th, 2006, 1:17 pm

thanks for ur reply.

can you change below code to phalanger.

System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Mssql Databases", new System.Windows.Forms.TreeNode[] {treeNode1, treeNode2 });


this.treeView.ClientSizeChanged += new System.EventHandler(this.treeView_ClientSizeChanged);
this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);

phalanger@codeplex
 
Posts: 8
Joined: January 7th, 2012, 8:57 pm

RE: problem in getting tree heirarachy structure in a form.

Postby tomasp » October 22nd, 2006, 2:04 am

Hi,
you can get more examples in the "Deployment\Samples" directory of our latest source code. The "WinForms" example contains examples that might be very interesting for you :-).

To answer your questions -
// C#
new System.Windows.Forms.TreeNode("Mssql Databases", new System.Windows.Forms.TreeNode[] {treeNode1, treeNode2 });
// Phalanger
new System:::Windows:::Forms:::TreeNode("Mssql Databases", array(treeNode1, treeNode2));

// C#
this.treeView.ClientSizeChanged += new System.EventHandler(this.treeView_ClientSizeChanged);
// Phalanger
$this->treeView->ClientSizeChanged.Add(new System.EventHandler(array($this, "treeView_ClientSizeChanged")));

(but we're planning to include "+=" in the future too)
tomasp
 
Posts: 46
Joined: January 7th, 2012, 8:37 pm

RE: problem in getting tree heirarachy structure in a form.

Postby phalanger@codeplex » November 3rd, 2006, 9:38 am

hai,
Now I have got all the tree nodes. Then I used
$this->treeView->AfterSelect( new EventHandler ( array ( $this, "treeView1_AfterSelect )) ) ;

function treeView1_AfterSelect()
{
.........
//printing some text message on the right of the form .
.. ........
}
-----or -----

$this->treeView->MouseClick( new EventHandler ( array ( $this, "treeView1_AfterSelect )) ) ;

function treeView1_AfterSelect()
{
.........
//printing some text message on the right of the form .
.. ........
}
This code works fine only at first time( when the programs runs ). If I will select any other nodes afterwords, text message is not changing.In .net this is not the case coz there is eventhandler. I need to check "nodeselection" everytime, can u give some idea for this...
Thanks for your reply...
Regards,
sharath.
phalanger@codeplex
 
Posts: 8
Joined: January 7th, 2012, 8:57 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 7 guests

cron

User Control Panel

Login

Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 5 minutes)
Most users ever online was 511 on April 27th, 2024, 10:11 pm

Users browsing this forum: No registered users and 7 guests