個人檔案The Martin Schray Way相片部落格清單更多 ![]() | 說明 |
|
11月16日 PHP.NET Simple FormV7Building on my first, second, third, fourth, fifth and sixth PHP.NET posts I worked up a seventh PHP .NET Win Forms example. This example takes the Label, TextBox, Button and adds places them in a FlowLayoutPanel. I then add a PictureBox control. I place the FlowlayoutPanel and PitureBox control in a TableLayoutPanel. The benefit of doing this I don't have deal with positioning, placement and everything moves and resizes appropriatley. As the form is resized the controls will moved so they visible and layed out optimally. When the button is clicked it grabs the text from the TextBox and uses MapPoint web services to find the location and render a map in the PictureBox. Wait did I say MapPoint? We use MapPoint web serivices to find a location and render a map! I wrote a class in C# that I call the MapPointWebServiceHelper. Yeah I know a really long name, but it lets us do a lot of with MapPoint really easily. I post about about what the class does later. Here are a few comments about the code:
Need PHP.NET? I went over to CodePlex and grabbed Phalanger. It's a PHP implementation that can interoperate with .NET. I then grabbed my (yes I wrote them ~ imagine that) IronPython Winforms examples and began porting them to PHP. This is the seventh example I have ported. Here is the code: <? import namespace System; import namespace System:::Drawing; import namespace System:::Drawing:::Imaging; import namespace System:::Windows:::Forms; import namespace System:::ComponentModel; import namespace MapPointWebServiceProject; import namespace MapPointWebServiceProject:::net:::mappoint:::staging; import namespace Phalanger; // The main form with cool background image and a tricky button class FormV7 extends Form { // The entry point of the application public static function Main() { $form = new FormV7; Application::Run($form); } public function __construct() { // setup TableLayoutPanel and FlowLayoutPanel $this->_tableLayoutPanel1 = new TableLayoutPanel(); $this->_tableLayoutPanel1->ColumnCount = 1; $this->_tableLayoutPanel1->RowCount = 2; $this->_tableLayoutPanel1->Dock = DockStyle::Fill; $this->_flowLayoutPanel1 = new FlowLayoutPanel(); $this->_flowLayoutPanel1->Dock = DockStyle::Fill; // Create Controls $this->_pictureBox1 = new PictureBox(); $this->_pictureBox1->Dock = DockStyle::Fill; $this->_label1 = new Label(); $this->_label1->Text ="Enter Location:"; $this->_label1->AutoSize =True; $this->_txtLocation = new TextBox(); $this->_button1 = new Button(); $this->_button1->Text = "Get map"; $this->_botton1->AutoSize=True; // Setup TableLayoutPanel rows and columns and add controls $this->_tableLayoutPanel1->ColumnStyles->Add(new ColumnStyle(SizeType::Percent, 100.0)); $this->_tableLayoutPanel1->RowStyles->Add(new RowStyle(SizeType::Absolute, 45.0)); $this->_tableLayoutPanel1->RowStyles->Add(new RowStyle(SizeType::Percent, 100.0)); $this->_tableLayoutPanel1->Controls->Add($this->_flowLayoutPanel1, 0, 0); $this->_tableLayoutPanel1->Controls->Add($this->_pictureBox1, 0, 1); // Add controls to FlowLayoutPanel $this->_flowLayoutPanel1->Controls->Add($this->_label1); $this->_flowLayoutPanel1->Controls->Add($this->_txtLocation); $this->_flowLayoutPanel1->Controls->Add($this->_button1); $this->AcceptButton = $this->_button1; $this->_button1->Click->Add(new EventHandler(array($this, "Button_OnClick"))); $this->Controls->Add($this->_tableLayoutPanel1); } protected function Button_OnClick($eventArgs) { try { $mapHelper = MapPointWebServiceHelper::GetInstance("5200", "ned68Fe"); $loc = $mapHelper->FindLocation($this->_txtLocation->Text); if ($loc) $this->_pictureBox1->Image = $mapHelper->GetMap($loc, $this->_pictureBox1->Width, $this->_pictureBox1->Height,4.0); else MessageBox::Show("Address or location is not valid","Invalid Location"); } catch (System:::Exception $e) { MessageBox::Show($e->Message(),"MapPoint Exception"); } } } ?> I had to get it compiled into an .exe to run. From the Samples\Winform directory I run the following command line: ..\..\bin\phpc /pure /target:winexe /r:bin\MapPointWebServiceProject.dll FormV7.php Then I run the app with the following command line: bin\FormV7.exe 11月3日 PHP.NET Simple FormV6Building on my first, second, third, fourth and fifth PHP.NET posts I worked up a sixth PHP .NET Win Forms example. This example takes the Label, TextBox, Button and adds places them in a FlowLayoutPanel. I then add a WebBrowser control. I place the FlowlayoutPanel and WebBrowser control in a TableLayoutPanel. The benefit of doing this I don't have deal with positioning, placement and everything moves and resizes appropriatley. As the form is resized the controls will moved so they visible and layed out optimally. When the button is clicked it grabs the text from the TextBox and uses it as the URL to be displayed in the WebBrowser. Here are a few comments about the code:
Need PHP.NET? I went over to CodePlex and grabbed Phalanger. It's a PHP implementation that can interoperate with .NET. I then grabbed my (yes I wrote them ~ imagine that) IronPython Winforms examples and began porting them to PHP. This is the second example I have ported. Here is the code: <? import namespace System; import namespace System:::Drawing; import namespace System:::Drawing:::Imaging; import namespace System:::Windows:::Forms; import namespace System:::ComponentModel; // The main form with cool background image and a tricky button class FormV6 extends Form { // The entry point of the application public static function Main() { $form = new FormV6; Application::Run($form); } public function __construct() { // setup TableLayoutPanel and FlowLayoutPanel $this->_tableLayoutPanel1 = new TableLayoutPanel(); $this->_tableLayoutPanel1->ColumnCount = 1; $this->_tableLayoutPanel1->RowCount = 2; $this->_tableLayoutPanel1->Dock = DockStyle::Fill; $this->_flowLayoutPanel1 = new FlowLayoutPanel(); $this->_flowLayoutPanel1->Dock = DockStyle::Fill; $this->_webBrowser = new WebBrowser(); $this->_webBrowser->Dock = DockStyle::Fill; $this->_label1 = new Label(); $this->_label1->Text ="Enter Message"; $this->_txtMessage = new TextBox(); $this->_txtMessage->TabIndex = 0; $this->_txtMessage->Size = new Size(200,20); $this->_button1 = new Button(); $this->_button1->Text = "Message"; // Setup ToolStrip and ToolStripLabel $this->_StatusStrip1 = new StatusStrip(); $this->_ToolStripStatusLabel1 = new ToolStripStatusLabel(); $this->_StatusStrip1->Items->Add($this->_ToolStripStatusLabel1); $this->Controls->Add($this->_StatusStrip1); $this->AcceptButton = $this->_button1; // when the enter key is pressed $this._button1 will be clicked $this->_button1->Click->Add(new EventHandler(array($this, "Button_OnClick"))); // Set TableLayoutPanel column and row styles and add FlowLayoutPanel and Web Browser $this->_tableLayoutPanel1->ColumnStyles->Add(new ColumnStyle(SizeType::Percent, 100.0)); $this->_tableLayoutPanel1->RowStyles->Add(new RowStyle(SizeType::Absolute, 80.0)); $this->_tableLayoutPanel1->RowStyles->Add(new RowStyle(SizeType::Percent, 100.0)); $this->_tableLayoutPanel1->Controls->Add($this->_flowLayoutPanel1, 0, 0); $this->_tableLayoutPanel1->Controls->Add($this->_webBrowser, 0, 1); // add controls that will be contained in FlowLayoutPanel $this->_flowLayoutPanel1->Controls->Add($this->_label1); $this->_flowLayoutPanel1->Controls->Add($this->_txtMessage); $this->_flowLayoutPanel1->Controls->Add($this->_button1); $this->Controls->Add($this->_tableLayoutPanel1); } protected function Button_OnClick($eventArgs) { $this->_webBrowser->Navigate($this->_txtMessage->Text); $this->_ToolStripStatusLabel1->Text = $this->_txtMessage->Text; $this->_txtMessage->Text = ""; } } ?> I had to get it compiled into an .exe to run. From the Samples\Winform directory I run the following command line: ..\..\bin\phpc /pure /target:winexe FormV6.php Then I run the app with the following command line: bin\FormV6.exe IronPython for ASP.NET PreviewIronPython ASP.NET CTP – download it here
This package provides IronPython integration with ASP.NET and Visual Studio (including Visual Web Developer Express Edition). This allows you to write ASP.NET pages (both inline code and code-behind files) as well as common classes using IronPython. (The infrastructure is extensible to allow other dynamic languages to plug in as well.) The framework also includes design-time support for creating IronPython projects and pages in Visual Studio, with syntax coloring and debugging support.
Wow! this is very cool Windows Media 11 for XP releasedI installed Windows Media Player 11 for XP yesterday. It is very cool. One awesome feature is the the search over large media libraries is super quick and shows a filtered list in real time. Very cool.
Windows Media Player 11 for Windows XP Windows Media Player 11 offers great new ways to store and enjoy all the music, video, pictures, and recorded TV on your computer.11月2日 PHP.NET Simple FormV4Building on my first, second and third PHP.NET posts I worked up a fourth PHP .NET Win Forms example. This example adds Label, TextBox and button. When the button is clicked it grabs the text from the TextBox and displays it a MessageBox. Here are a few comments about the code:
Need PHP.NET? I went over to CodePlex and grabbed Phalanger. It's a PHP implementation that can interoperate with .NET. I then grabbed my (yes I wrote them ~ imagine that) IronPython Winforms examples and began porting them to PHP. This is the second example I have ported. Here is the code: <? import namespace System; import namespace System:::Drawing; import namespace System:::Drawing:::Imaging; import namespace System:::Windows:::Forms; import namespace System:::ComponentModel; // The main form with cool background image and a tricky button class FormV4 extends Form { // The entry point of the application public static function Main() { $form = new FormV4; Application::Run($form); } public function __construct() { // Set the forms title $this->Text = "Hello World"; // Create and position a label $this->label = new Label(); $this->label->Text = "Enter message"; $this->Controls->Add($this->label); // Create and position a Textbox $this->textbox = new TextBox(); $this->textbox->Size = new Size(100,25); $this->textbox->Left = 100; $this->Controls->Add($this->textbox); // Create and position a button $this->button = new Button(); $this->button->Location = new Point(1, 30); $this->button->Name = "Button"; $this->button->Text = "Message"; $this->button->Click->Add(new EventHandler(array($this, "Button_OnClick"))); $this->Controls->Add($this->button); // Create Component Container $this->_components = new System:::ComponentModel:::Container(); // // Add component - ContextMenu // $this->_contextMenuStrip1 = new ContextMenuStrip($this->_components); $this->_exitToolStripMenuItem = new ToolStripMenuItem(); $this->_exitToolStripMenuItem->Text = "Exit"; $this->_contextMenuStrip1->Items->Add($this->_exitToolStripMenuItem); $this->_exitToolStripMenuItem->Click->Add(new EventHandler(array($this, "ContextMenu_OnClick"))); // // Add Component - NotifyIcon // $this->_notifyIcon1 = new NotifyIcon($this->_components); $this->_notifyIcon1->Visible=True; $this->_notifyIcon1->Text='Test'; $this->_notifyIcon1->Icon = new Icon("app.ico"); $this->_notifyIcon1->ContextMenuStrip = $this->_contextMenuStrip1; } protected function Button_OnClick($eventArgs) { MessageBox::Show($this->textbox->Text,"Message"); } protected function ContextMenu_OnClick($eventArgs) { $this->Close(); } } ?> I had to get it compiled into an .exe to run. From the Samples\Winform directory I run the following command line: ..\..\bin\phpc /pure /target:winexe FormV4.php Then I run the app with the following command line: bin\FormV4.exe 11月1日 PHP.NET Simple FormV3Building on my first and second PHP.NET posts I worked up a third PHP .NET Win Forms example. This example adds Label, TextBox and button. When the button is clicked it grabs the text from the TextBox and displays it a MessageBox. Here are a few comments about the code:
Need PHP.NET? I went over to CodePlex and grabbed Phalanger. It's a PHP implementation that can interoperate with .NET. I then grabbed my (yes I wrote them ~ imagine that) IronPython Winforms examples and began porting them to PHP. This is the second example I have ported. Here is the code: <? import namespace System; import namespace System:::Drawing; import namespace System:::Drawing:::Imaging; import namespace System:::Windows:::Forms; // The main form with cool background image and a tricky button class FormV3 extends Form { // The entry point of the application public static function Main() { $form = new FormV3; Application::Run($form); } public function __construct() { // Set the forms title $this->Text = "Hello World"; // Create and position a label $this->label = new Label(); $this->label->Text = "Enter message"; $this->Controls->Add($this->label); // Create and position a Textbox $this->textbox = new TextBox(); $this->textbox->Size = new Size(100,25); $this->textbox->Left = 100; $this->Controls->Add($this->textbox); // Create and position a button $this->button = new Button(); $this->button->Location = new Point(1, 30); $this->button->Name = "Button"; $this->button->Text = "Message"; $this->button->Click->Add(new EventHandler(array($this, "Button_OnClick"))); $this->Controls->Add($this->button); } protected function Button_OnClick($eventArgs) { MessageBox::Show($this->textbox->Text,"Message"); } } ?> I had to get it compiled into an .exe to run. From the Samples\Winform directory I run the following command line: ..\..\bin\phpc /pure /target:winexe FormV3.php Then I run the app with the following command line: bin\FormV3.exe |
|
|