Changed to use Authenticate asp.net event instead of Authorize
[castle.git] / Samples / ActiveRecord / BlogSample / UI / BlogForm.cs
blobe352718bd259491552ee7d788e90965f94590128
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace BlogSample.UI
17 using System.Windows.Forms;
19 public class BlogForm : Form
21 private GroupBox groupBox1;
22 private Label label2;
23 private Label label1;
24 private TextBox authorText;
25 private TextBox nameText;
26 private Button closeButton;
27 private Button saveButton;
28 private System.ComponentModel.Container components = null;
30 private readonly Blog currentBlog;
32 public BlogForm()
34 InitializeComponent();
36 currentBlog = new Blog();
39 public BlogForm(Blog blog) : this()
41 currentBlog = blog;
43 nameText.Text = currentBlog.Name;
44 authorText.Text = currentBlog.Author;
47 /// <summary>
48 /// Clean up any resources being used.
49 /// </summary>
50 protected override void Dispose( bool disposing )
52 if( disposing )
54 if(components != null)
56 components.Dispose();
59 base.Dispose( disposing );
62 #region Windows Form Designer generated code
63 /// <summary>
64 /// Required method for Designer support - do not modify
65 /// the contents of this method with the code editor.
66 /// </summary>
67 private void InitializeComponent()
69 this.groupBox1 = new System.Windows.Forms.GroupBox();
70 this.authorText = new System.Windows.Forms.TextBox();
71 this.label2 = new System.Windows.Forms.Label();
72 this.nameText = new System.Windows.Forms.TextBox();
73 this.label1 = new System.Windows.Forms.Label();
74 this.closeButton = new System.Windows.Forms.Button();
75 this.saveButton = new System.Windows.Forms.Button();
76 this.groupBox1.SuspendLayout();
77 this.SuspendLayout();
78 //
79 // groupBox1
80 //
81 this.groupBox1.Controls.Add(this.authorText);
82 this.groupBox1.Controls.Add(this.label2);
83 this.groupBox1.Controls.Add(this.nameText);
84 this.groupBox1.Controls.Add(this.label1);
85 this.groupBox1.Location = new System.Drawing.Point(8, 8);
86 this.groupBox1.Name = "groupBox1";
87 this.groupBox1.Size = new System.Drawing.Size(456, 128);
88 this.groupBox1.TabIndex = 1;
89 this.groupBox1.TabStop = false;
90 this.groupBox1.Text = "Blog:";
91 //
92 // authorText
93 //
94 this.authorText.Location = new System.Drawing.Point(160, 72);
95 this.authorText.Name = "authorText";
96 this.authorText.Size = new System.Drawing.Size(232, 21);
97 this.authorText.TabIndex = 3;
98 this.authorText.Text = "";
99 //
100 // label2
102 this.label2.Location = new System.Drawing.Point(40, 72);
103 this.label2.Name = "label2";
104 this.label2.TabIndex = 2;
105 this.label2.Text = "Author:";
107 // nameText
109 this.nameText.Location = new System.Drawing.Point(160, 40);
110 this.nameText.Name = "nameText";
111 this.nameText.Size = new System.Drawing.Size(232, 21);
112 this.nameText.TabIndex = 1;
113 this.nameText.Text = "";
115 // label1
117 this.label1.Location = new System.Drawing.Point(40, 40);
118 this.label1.Name = "label1";
119 this.label1.TabIndex = 0;
120 this.label1.Text = "Blog Name:";
122 // closeButton
124 this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
125 this.closeButton.Location = new System.Drawing.Point(242, 152);
126 this.closeButton.Name = "closeButton";
127 this.closeButton.Size = new System.Drawing.Size(104, 23);
128 this.closeButton.TabIndex = 6;
129 this.closeButton.Text = "Close";
130 this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
132 // saveButton
134 this.saveButton.Location = new System.Drawing.Point(126, 152);
135 this.saveButton.Name = "saveButton";
136 this.saveButton.Size = new System.Drawing.Size(104, 23);
137 this.saveButton.TabIndex = 7;
138 this.saveButton.Text = "Save";
139 this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
141 // BlogForm
143 this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
144 this.CancelButton = this.closeButton;
145 this.ClientSize = new System.Drawing.Size(472, 190);
146 this.Controls.Add(this.saveButton);
147 this.Controls.Add(this.closeButton);
148 this.Controls.Add(this.groupBox1);
149 this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
150 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
151 this.MaximizeBox = false;
152 this.MinimizeBox = false;
153 this.Name = "BlogForm";
154 this.Text = "BlogForm";
155 this.groupBox1.ResumeLayout(false);
156 this.ResumeLayout(false);
159 #endregion
161 private void closeButton_Click(object sender, System.EventArgs e)
163 DialogResult = DialogResult.Cancel;
165 Hide();
168 private void saveButton_Click(object sender, System.EventArgs e)
170 currentBlog.Name = nameText.Text;
171 currentBlog.Author = authorText.Text;
172 currentBlog.Save();
174 DialogResult = DialogResult.OK;
176 Hide();