Skip to content
Browse files

Add WinForms sample project.

  • Loading branch information...
1 parent 169fd1d commit 3e718e82f315fda025e454f6775e357960e9e26f @jdhardy committed Apr 2, 2012
View
4 FlippingGame/FlippingGame.py
@@ -15,7 +15,7 @@ def check_wager(self, wager):
def flip(self, guess, wager):
assert 1 <= wager <= self.bankroll
- assert guess in "TF"
+ assert guess in "TH"
result = self._do_flip()
self.history.append((result, guess, wager))
@@ -27,4 +27,4 @@ def flip(self, guess, wager):
return False, result
def _do_flip(self):
- return "TF"[self.rand.Next(2)]
+ return "TH"[self.rand.Next(2)]
View
12 IronPythonSamples.sln
@@ -11,6 +11,8 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "FlippingGame", "FlippingGam
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSample", "ConsoleSample\ConsoleSample.csproj", "{40BC8BDE-81E0-48EC-9AC2-FB2A739E5144}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsSample", "WinFormsSample\WinFormsSample.csproj", "{1940BB9C-9F27-417B-A227-2E69C0A8C172}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -37,6 +39,16 @@ Global
{40BC8BDE-81E0-48EC-9AC2-FB2A739E5144}.Release|Mixed Platforms.Build.0 = Release|x86
{40BC8BDE-81E0-48EC-9AC2-FB2A739E5144}.Release|x86.ActiveCfg = Release|x86
{40BC8BDE-81E0-48EC-9AC2-FB2A739E5144}.Release|x86.Build.0 = Release|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Debug|x86.ActiveCfg = Debug|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Debug|x86.Build.0 = Debug|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Release|Any CPU.ActiveCfg = Release|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Release|Mixed Platforms.Build.0 = Release|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Release|x86.ActiveCfg = Release|x86
+ {1940BB9C-9F27-417B-A227-2E69C0A8C172}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
277 WinFormsSample/FlippingGame.Designer.cs
@@ -0,0 +1,277 @@
+namespace WinFormsSample {
+ partial class FlippingGame {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent() {
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.bankrollLabel = new System.Windows.Forms.Label();
+ this.wagerBox = new System.Windows.Forms.NumericUpDown();
+ this.guessHeadsRadio = new System.Windows.Forms.RadioButton();
+ this.guessTailsRadio = new System.Windows.Forms.RadioButton();
+ this.flipButton = new System.Windows.Forms.Button();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
+ this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
+ this.resultLabel = new System.Windows.Forms.Label();
+ this.flippingBox = new System.Windows.Forms.PictureBox();
+ this.resultLayout = new System.Windows.Forms.TableLayoutPanel();
+ ((System.ComponentModel.ISupportInitialize)(this.wagerBox)).BeginInit();
+ this.tableLayoutPanel1.SuspendLayout();
+ this.tableLayoutPanel2.SuspendLayout();
+ this.tableLayoutPanel3.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.flippingBox)).BeginInit();
+ this.resultLayout.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(3, 25);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(42, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Wager:";
+ //
+ // label2
+ //
+ this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left;
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(3, 50);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(40, 13);
+ this.label2.TabIndex = 0;
+ this.label2.Text = "Guess:";
+ //
+ // label4
+ //
+ this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left;
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(3, 3);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(48, 13);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Bankroll:";
+ //
+ // bankrollLabel
+ //
+ this.bankrollLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
+ this.bankrollLabel.AutoSize = true;
+ this.tableLayoutPanel3.SetColumnSpan(this.bankrollLabel, 2);
+ this.bankrollLabel.Location = new System.Drawing.Point(57, 3);
+ this.bankrollLabel.Margin = new System.Windows.Forms.Padding(3);
+ this.bankrollLabel.Name = "bankrollLabel";
+ this.bankrollLabel.Size = new System.Drawing.Size(13, 13);
+ this.bankrollLabel.TabIndex = 5;
+ this.bankrollLabel.Text = "?";
+ //
+ // wagerBox
+ //
+ this.wagerBox.Anchor = System.Windows.Forms.AnchorStyles.Left;
+ this.tableLayoutPanel3.SetColumnSpan(this.wagerBox, 2);
+ this.wagerBox.Location = new System.Drawing.Point(57, 22);
+ this.wagerBox.Minimum = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ this.wagerBox.Name = "wagerBox";
+ this.wagerBox.Size = new System.Drawing.Size(75, 20);
+ this.wagerBox.TabIndex = 6;
+ this.wagerBox.Value = new decimal(new int[] {
+ 1,
+ 0,
+ 0,
+ 0});
+ //
+ // guessHeadsRadio
+ //
+ this.guessHeadsRadio.AutoSize = true;
+ this.guessHeadsRadio.Checked = true;
+ this.guessHeadsRadio.Location = new System.Drawing.Point(57, 48);
+ this.guessHeadsRadio.Name = "guessHeadsRadio";
+ this.guessHeadsRadio.Size = new System.Drawing.Size(56, 17);
+ this.guessHeadsRadio.TabIndex = 7;
+ this.guessHeadsRadio.TabStop = true;
+ this.guessHeadsRadio.Text = "Heads";
+ this.guessHeadsRadio.UseVisualStyleBackColor = true;
+ //
+ // guessTailsRadio
+ //
+ this.guessTailsRadio.AutoSize = true;
+ this.guessTailsRadio.Location = new System.Drawing.Point(119, 48);
+ this.guessTailsRadio.Name = "guessTailsRadio";
+ this.guessTailsRadio.Size = new System.Drawing.Size(47, 17);
+ this.guessTailsRadio.TabIndex = 7;
+ this.guessTailsRadio.Text = "Tails";
+ this.guessTailsRadio.UseVisualStyleBackColor = true;
+ //
+ // flipButton
+ //
+ this.flipButton.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.flipButton.Location = new System.Drawing.Point(178, 25);
+ this.flipButton.Name = "flipButton";
+ this.flipButton.Size = new System.Drawing.Size(59, 23);
+ this.flipButton.TabIndex = 2;
+ this.flipButton.Text = "Flip!";
+ this.flipButton.UseVisualStyleBackColor = true;
+ this.flipButton.Click += new System.EventHandler(this.flipButton_Click);
+ //
+ // tableLayoutPanel1
+ //
+ this.tableLayoutPanel1.AutoSize = true;
+ this.tableLayoutPanel1.ColumnCount = 1;
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
+ this.tableLayoutPanel1.Controls.Add(this.resultLayout, 0, 1);
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(13, 13);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ this.tableLayoutPanel1.RowCount = 2;
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(246, 133);
+ this.tableLayoutPanel1.TabIndex = 8;
+ //
+ // tableLayoutPanel2
+ //
+ this.tableLayoutPanel2.AutoSize = true;
+ this.tableLayoutPanel2.ColumnCount = 2;
+ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel2.Controls.Add(this.flipButton, 1, 0);
+ this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel3, 0, 0);
+ this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
+ this.tableLayoutPanel2.Name = "tableLayoutPanel2";
+ this.tableLayoutPanel2.RowCount = 1;
+ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel2.Size = new System.Drawing.Size(240, 74);
+ this.tableLayoutPanel2.TabIndex = 0;
+ //
+ // tableLayoutPanel3
+ //
+ this.tableLayoutPanel3.AutoSize = true;
+ this.tableLayoutPanel3.ColumnCount = 3;
+ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.tableLayoutPanel3.Controls.Add(this.guessHeadsRadio, 1, 2);
+ this.tableLayoutPanel3.Controls.Add(this.label1, 0, 1);
+ this.tableLayoutPanel3.Controls.Add(this.label4, 0, 0);
+ this.tableLayoutPanel3.Controls.Add(this.guessTailsRadio, 2, 2);
+ this.tableLayoutPanel3.Controls.Add(this.bankrollLabel, 1, 0);
+ this.tableLayoutPanel3.Controls.Add(this.wagerBox, 1, 1);
+ this.tableLayoutPanel3.Controls.Add(this.label2, 0, 2);
+ this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3);
+ this.tableLayoutPanel3.Name = "tableLayoutPanel3";
+ this.tableLayoutPanel3.RowCount = 3;
+ this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ this.tableLayoutPanel3.Size = new System.Drawing.Size(169, 68);
+ this.tableLayoutPanel3.TabIndex = 3;
+ //
+ // resultLabel
+ //
+ this.resultLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.resultLabel.AutoSize = true;
+ this.resultLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.resultLabel.Location = new System.Drawing.Point(41, 5);
+ this.resultLabel.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
+ this.resultLabel.Name = "resultLabel";
+ this.resultLabel.Size = new System.Drawing.Size(35, 37);
+ this.resultLabel.TabIndex = 1;
+ this.resultLabel.Text = "?";
+ //
+ // flippingBox
+ //
+ this.flippingBox.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.flippingBox.Image = global::WinFormsSample.Properties.Resources.ajax_loader;
+ this.flippingBox.Location = new System.Drawing.Point(3, 7);
+ this.flippingBox.Name = "flippingBox";
+ this.flippingBox.Size = new System.Drawing.Size(32, 32);
+ this.flippingBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
+ this.flippingBox.TabIndex = 9;
+ this.flippingBox.TabStop = false;
+ //
+ // resultLayout
+ //
+ this.resultLayout.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.resultLayout.AutoSize = true;
+ this.resultLayout.ColumnCount = 2;
+ this.resultLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.resultLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
+ this.resultLayout.Controls.Add(this.flippingBox, 0, 0);
+ this.resultLayout.Controls.Add(this.resultLabel, 1, 0);
+ this.resultLayout.Location = new System.Drawing.Point(83, 83);
+ this.resultLayout.Name = "resultLayout";
+ this.resultLayout.RowCount = 1;
+ this.resultLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.resultLayout.Size = new System.Drawing.Size(79, 47);
+ this.resultLayout.TabIndex = 1;
+ //
+ // FlippingGame
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.ClientSize = new System.Drawing.Size(288, 156);
+ this.Controls.Add(this.tableLayoutPanel1);
+ this.Name = "FlippingGame";
+ this.Text = "Coin Flipping Game";
+ this.Load += new System.EventHandler(this.FlippingGame_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.wagerBox)).EndInit();
+ this.tableLayoutPanel1.ResumeLayout(false);
+ this.tableLayoutPanel1.PerformLayout();
+ this.tableLayoutPanel2.ResumeLayout(false);
+ this.tableLayoutPanel2.PerformLayout();
+ this.tableLayoutPanel3.ResumeLayout(false);
+ this.tableLayoutPanel3.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.flippingBox)).EndInit();
+ this.resultLayout.ResumeLayout(false);
+ this.resultLayout.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label bankrollLabel;
+ private System.Windows.Forms.NumericUpDown wagerBox;
+ private System.Windows.Forms.RadioButton guessHeadsRadio;
+ private System.Windows.Forms.RadioButton guessTailsRadio;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
+ private System.Windows.Forms.Button flipButton;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
+ private System.Windows.Forms.Label resultLabel;
+ private System.Windows.Forms.PictureBox flippingBox;
+ private System.Windows.Forms.TableLayoutPanel resultLayout;
+ }
+}
+
View
92 WinFormsSample/FlippingGame.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using IronPython.Hosting;
+using Microsoft.Scripting.Hosting;
+
+namespace WinFormsSample {
+ public partial class FlippingGame : Form {
+ ScriptEngine engine;
+ ScriptScope scope;
+ dynamic game;
+ Random rand = new Random();
+
+ public FlippingGame() {
+ InitializeComponent();
+
+ this.engine = Python.CreateEngine();
+ this.engine.SetSearchPaths(new[] { "FlippingGame" });
+ this.scope = this.engine.CreateScope();
+ }
+
+ private void FlippingGame_Load(object sender, EventArgs e) {
+ this.scope.ImportModule("FlippingGame");
+ this.engine.Execute("game = FlippingGame.FlippingGame()", this.scope);
+ this.game = this.scope.GetVariable("game");
+
+ ConstrainWager();
+ ShowBankroll();
+
+ ShowResult();
+ }
+
+ private void ShowBankroll() {
+ bankrollLabel.Text = game.bankroll.ToString();
+ }
+
+ private void flipButton_Click(object sender, EventArgs e) {
+ var wager = wagerBox.Value;
+ var guess = guessHeadsRadio.Checked ? "H" : "T";
+
+ var result = game.flip(guess, wager);
+ var won = result[0];
+ var toss = result[1];
+
+ ShowSpinner();
+
+ var timer = new Timer() {Interval = rand.Next(350, 1000)};
+ timer.Tick += (t_sender, t_e) => {
+ flippingBox.Visible = false;
+ SetToss(toss.ToString(), (bool)won);
+ ShowResult();
+
+ ConstrainWager();
+ ShowBankroll();
+
+ ((Timer)t_sender).Stop();
+ };
+
+ timer.Start();
+ }
+
+ private void ShowResult() {
+ resultLabel.Visible = true;
+ flippingBox.Visible = false;
+ }
+
+ private void ShowSpinner() {
+ resultLabel.Visible = false;
+ flippingBox.Visible = true;
+ }
+
+ private void SetToss(string toss, bool won) {
+ resultLabel.Visible = true;
+ resultLabel.Text = toss;
+ resultLabel.ForeColor = won ? Color.Green : Color.Red;
+ }
+
+ private void ConstrainWager() {
+ var bankroll = game.bankroll;
+
+ if (bankroll > 0) {
+ wagerBox.Maximum = bankroll;
+ } else {
+ wagerBox.Enabled = false;
+ flipButton.Enabled = false;
+ guessHeadsRadio.Enabled = guessTailsRadio.Enabled = false;
+ resultLabel.Text = "X";
+ ShowResult();
+ }
+ }
+ }
+}
View
120 WinFormsSample/FlippingGame.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
View
18 WinFormsSample/Program.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace WinFormsSample {
+ static class Program {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main() {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new FlippingGame());
+ }
+ }
+}
View
36 WinFormsSample/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("WinFormsSample")]
+[assembly: AssemblyDescription("IronPython WinForms Sample")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WinFormsSample")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1ff8ae58-12a7-49c1-a02d-7a6843193371")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
70 WinFormsSample/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.261
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WinFormsSample.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinFormsSample.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static System.Drawing.Bitmap ajax_loader {
+ get {
+ object obj = ResourceManager.GetObject("ajax_loader", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
View
124 WinFormsSample/Properties/Resources.resx
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <data name="ajax_loader" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\ajax-loader.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+</root>
View
26 WinFormsSample/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.261
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WinFormsSample.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
View
7 WinFormsSample/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
View
BIN WinFormsSample/Resources/ajax-loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
126 WinFormsSample/WinFormsSample.csproj
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{1940BB9C-9F27-417B-A227-2E69C0A8C172}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>WinFormsSample</RootNamespace>
+ <AssemblyName>WinFormsSample</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\IronPythonSamples\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="IronPython">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\IronPython.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.Modules">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\IronPython.Modules.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.SQLite">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\IronPython.SQLite.dll</HintPath>
+ </Reference>
+ <Reference Include="IronPython.Wpf">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\IronPython.Wpf.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Dynamic">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\Microsoft.Dynamic.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Scripting">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\Microsoft.Scripting.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Scripting.AspNet">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\Microsoft.Scripting.AspNet.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Scripting.Metadata">
+ <HintPath>..\packages\IronPython.2.7.2-final1\lib\Net40\Microsoft.Scripting.Metadata.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="FlippingGame.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="FlippingGame.Designer.cs">
+ <DependentUpon>FlippingGame.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="FlippingGame.resx">
+ <DependentUpon>FlippingGame.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ <None Include="..\FlippingGame\FlippingGame.py">
+ <Link>FlippingGame\FlippingGame.py</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="packages.config" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\Flipping.gif" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\ajax-loader.gif" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>

0 comments on commit 3e718e8

Please sign in to comment.
Something went wrong with that request. Please try again.