1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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 PostForm
: Form
21 private Button saveButton
;
22 private Button closeButton
;
23 private GroupBox groupBox1
;
28 private TextBox contentsText
;
29 private TextBox titleText
;
30 private TextBox categoryText
;
31 private DateTimePicker createdDtTime
;
32 private CheckBox publishedCheck
;
35 /// Required designer variable.
37 private System
.ComponentModel
.Container components
= null;
39 private readonly Post currentPost
;
40 private readonly Blog parentBlog
;
44 InitializeComponent();
47 public PostForm(Blog parentBlog
) : this()
49 this.parentBlog
= parentBlog
;
51 currentPost
= new Post();
54 public PostForm(Blog parentBlog
, Post post
) : this(parentBlog
)
58 titleText
.Text
= currentPost
.Title
;
59 contentsText
.Text
= currentPost
.Contents
;
60 categoryText
.Text
= currentPost
.Category
;
61 createdDtTime
.Value
= currentPost
.Created
;
62 publishedCheck
.Checked
= currentPost
.Published
;
66 /// Clean up any resources being used.
68 protected override void Dispose(bool disposing
)
72 if (components
!= null)
77 base.Dispose(disposing
);
80 #region Windows Form Designer generated code
83 /// Required method for Designer support - do not modify
84 /// the contents of this method with the code editor.
86 private void InitializeComponent()
88 this.saveButton
= new System
.Windows
.Forms
.Button();
89 this.closeButton
= new System
.Windows
.Forms
.Button();
90 this.groupBox1
= new System
.Windows
.Forms
.GroupBox();
91 this.publishedCheck
= new System
.Windows
.Forms
.CheckBox();
92 this.label4
= new System
.Windows
.Forms
.Label();
93 this.createdDtTime
= new System
.Windows
.Forms
.DateTimePicker();
94 this.categoryText
= new System
.Windows
.Forms
.TextBox();
95 this.label3
= new System
.Windows
.Forms
.Label();
96 this.contentsText
= new System
.Windows
.Forms
.TextBox();
97 this.label2
= new System
.Windows
.Forms
.Label();
98 this.titleText
= new System
.Windows
.Forms
.TextBox();
99 this.label1
= new System
.Windows
.Forms
.Label();
100 this.groupBox1
.SuspendLayout();
101 this.SuspendLayout();
105 this.saveButton
.Location
= new System
.Drawing
.Point(124, 296);
106 this.saveButton
.Name
= "saveButton";
107 this.saveButton
.Size
= new System
.Drawing
.Size(104, 23);
108 this.saveButton
.TabIndex
= 10;
109 this.saveButton
.Text
= "Save";
110 this.saveButton
.Click
+= new System
.EventHandler(this.saveButton_Click
);
114 this.closeButton
.Location
= new System
.Drawing
.Point(244, 296);
115 this.closeButton
.Name
= "closeButton";
116 this.closeButton
.Size
= new System
.Drawing
.Size(104, 23);
117 this.closeButton
.TabIndex
= 9;
118 this.closeButton
.Text
= "Close";
119 this.closeButton
.Click
+= new System
.EventHandler(this.closeButton_Click
);
123 this.groupBox1
.Controls
.Add(this.publishedCheck
);
124 this.groupBox1
.Controls
.Add(this.label4
);
125 this.groupBox1
.Controls
.Add(this.createdDtTime
);
126 this.groupBox1
.Controls
.Add(this.categoryText
);
127 this.groupBox1
.Controls
.Add(this.label3
);
128 this.groupBox1
.Controls
.Add(this.contentsText
);
129 this.groupBox1
.Controls
.Add(this.label2
);
130 this.groupBox1
.Controls
.Add(this.titleText
);
131 this.groupBox1
.Controls
.Add(this.label1
);
132 this.groupBox1
.Location
= new System
.Drawing
.Point(8, 8);
133 this.groupBox1
.Name
= "groupBox1";
134 this.groupBox1
.Size
= new System
.Drawing
.Size(456, 272);
135 this.groupBox1
.TabIndex
= 8;
136 this.groupBox1
.TabStop
= false;
137 this.groupBox1
.Text
= "Blog:";
141 this.publishedCheck
.CheckAlign
= System
.Drawing
.ContentAlignment
.MiddleRight
;
142 this.publishedCheck
.Location
= new System
.Drawing
.Point(40, 224);
143 this.publishedCheck
.Name
= "publishedCheck";
144 this.publishedCheck
.Size
= new System
.Drawing
.Size(136, 24);
145 this.publishedCheck
.TabIndex
= 8;
146 this.publishedCheck
.Text
= "Published:";
150 this.label4
.Location
= new System
.Drawing
.Point(40, 192);
151 this.label4
.Name
= "label4";
152 this.label4
.TabIndex
= 7;
153 this.label4
.Text
= "Created at:";
157 this.createdDtTime
.Location
= new System
.Drawing
.Point(160, 192);
158 this.createdDtTime
.Name
= "createdDtTime";
159 this.createdDtTime
.Size
= new System
.Drawing
.Size(232, 21);
160 this.createdDtTime
.TabIndex
= 6;
164 this.categoryText
.Location
= new System
.Drawing
.Point(160, 160);
165 this.categoryText
.Name
= "categoryText";
166 this.categoryText
.Size
= new System
.Drawing
.Size(232, 21);
167 this.categoryText
.TabIndex
= 5;
168 this.categoryText
.Text
= "";
172 this.label3
.Location
= new System
.Drawing
.Point(40, 160);
173 this.label3
.Name
= "label3";
174 this.label3
.TabIndex
= 4;
175 this.label3
.Text
= "Category:";
179 this.contentsText
.Location
= new System
.Drawing
.Point(160, 72);
180 this.contentsText
.Multiline
= true;
181 this.contentsText
.Name
= "contentsText";
182 this.contentsText
.Size
= new System
.Drawing
.Size(232, 80);
183 this.contentsText
.TabIndex
= 3;
184 this.contentsText
.Text
= "";
188 this.label2
.Location
= new System
.Drawing
.Point(40, 72);
189 this.label2
.Name
= "label2";
190 this.label2
.TabIndex
= 2;
191 this.label2
.Text
= "Contents:";
195 this.titleText
.Location
= new System
.Drawing
.Point(160, 40);
196 this.titleText
.Name
= "titleText";
197 this.titleText
.Size
= new System
.Drawing
.Size(232, 21);
198 this.titleText
.TabIndex
= 1;
199 this.titleText
.Text
= "";
203 this.label1
.Location
= new System
.Drawing
.Point(40, 40);
204 this.label1
.Name
= "label1";
205 this.label1
.TabIndex
= 0;
206 this.label1
.Text
= "Title:";
210 this.AutoScaleBaseSize
= new System
.Drawing
.Size(5, 14);
211 this.ClientSize
= new System
.Drawing
.Size(472, 334);
212 this.Controls
.Add(this.saveButton
);
213 this.Controls
.Add(this.closeButton
);
214 this.Controls
.Add(this.groupBox1
);
215 this.Font
= new System
.Drawing
.Font("Tahoma", 8.25F
, System
.Drawing
.FontStyle
.Regular
, System
.Drawing
.GraphicsUnit
.Point
, ((System
.Byte
)(0)));
216 this.FormBorderStyle
= System
.Windows
.Forms
.FormBorderStyle
.FixedDialog
;
217 this.MaximizeBox
= false;
218 this.MinimizeBox
= false;
219 this.Name
= "PostForm";
220 this.Text
= "PostForm";
221 this.groupBox1
.ResumeLayout(false);
222 this.ResumeLayout(false);
228 private void saveButton_Click(object sender
, System
.EventArgs e
)
230 currentPost
.Blog
= parentBlog
;
232 currentPost
.Title
= titleText
.Text
;
233 currentPost
.Contents
= contentsText
.Text
;
234 currentPost
.Category
= categoryText
.Text
;
235 currentPost
.Created
= createdDtTime
.Value
;
236 currentPost
.Published
= publishedCheck
.Checked
;
240 DialogResult
= DialogResult
.OK
;
245 private void closeButton_Click(object sender
, System
.EventArgs e
)
247 DialogResult
= DialogResult
.Cancel
;