Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / PestControl / Castle.Applications.PestControl.Web / views / project / new.aspx.cs
blob6beb5d9666c8313b19a087bf736ca7f08a1e6781
1 using System;
2 using System.Collections;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Web;
7 using System.Web.SessionState;
8 using System.Web.UI;
9 using System.Web.UI.WebControls;
10 using System.Web.UI.HtmlControls;
11 using Castle.Applications.PestControl.Model;
12 using Castle.Applications.PestControl.Services.BuildSystems;
13 using Castle.Applications.PestControl.Services.SourceControl;
14 using Castle.MonoRail.Framework;
16 namespace Castle.Applications.PestControl.Web.views.project
18 /// <summary>
19 /// Summary description for _new.
20 /// </summary>
21 public class New : System.Web.UI.Page, IControllerAware
23 protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
24 protected System.Web.UI.WebControls.TextBox name;
25 protected System.Web.UI.WebControls.Button Save;
26 protected System.Web.UI.WebControls.DropDownList sc;
27 protected System.Web.UI.WebControls.DropDownList bs;
28 protected System.Web.UI.WebControls.CheckBox isPublic;
30 private SourceControlManager _sourceControlManager;
31 protected System.Web.UI.WebControls.Repeater dynRep;
32 private BuildSystemManager _buildSystemManager;
33 private Controller _controller;
35 private void Page_Load(object sender, System.EventArgs e)
37 Save.Click += new EventHandler(OnSave);
39 ISourceControl[] sourceControls = SourceControlManager.AvailableSourceControl();
41 if (!IsPostBack)
43 SelectedSourceControl = -1;
45 sc.AutoPostBack = true;
46 sc.DataSource = sourceControls;
47 sc.DataTextField = "Name";
48 sc.DataValueField = "Key";
49 sc.DataBind();
51 bs.DataSource = BuildSystemManager.AvailableBuildSystems();
52 bs.DataTextField = "Name";
53 bs.DataValueField = "Key";
54 bs.DataBind();
57 if (sc.SelectedIndex != SelectedSourceControl )
59 // If the user changed the combo, we rebind the
60 // properties for the selected source control
62 ISourceControl control = sourceControls[ sc.SelectedIndex ];
64 SelectedSourceControl = sc.SelectedIndex;
66 dynRep.DataSource = control.ParametersDefinition;
67 dynRep.DataBind();
71 public int SelectedSourceControl
73 get { return (int) this.ViewState["SelectedSourceControl"]; }
74 set { this.ViewState["SelectedSourceControl"] = value; }
77 public SourceControlManager SourceControlManager
79 get { return _sourceControlManager; }
80 set { _sourceControlManager = value; }
83 public BuildSystemManager BuildSystemManager
85 get { return _buildSystemManager; }
86 set { _buildSystemManager = value; }
89 #region Web Form Designer generated code
90 override protected void OnInit(EventArgs e)
93 // CODEGEN: This call is required by the ASP.NET Web Form Designer.
95 InitializeComponent();
96 base.OnInit(e);
99 /// <summary>
100 /// Required method for Designer support - do not modify
101 /// the contents of this method with the code editor.
102 /// </summary>
103 private void InitializeComponent()
105 this.dynRep.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.dynRep_ItemCommand);
106 this.Load += new System.EventHandler(this.Page_Load);
109 #endregion
111 private void dynRep_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
116 private void OnSave(object sender, EventArgs e)
118 Hashtable properties = new Hashtable();
120 foreach(RepeaterItem item in dynRep.Items)
122 HtmlInputControl pKey = (HtmlInputControl) item.FindControl("propKey");
123 TextBox pValue = (TextBox) item.FindControl("propValue");
125 properties.Add(pKey.Value, pValue.Text);
128 _controller.PropertyBag.Add("properties", properties);
129 _controller.PropertyBag.Add("isPublic", isPublic.Checked);
130 _controller.PropertyBag.Add("ownerEmail", ((User) Context.User).Email );
132 _controller.Send("insert");
135 #region IControllerAware Members
137 public void SetController(Controller controller)
139 _controller = controller;
142 #endregion