• R/O
  • SSH
  • HTTPS

freetrain-exav: Commit


Commit MetaInfo

Revisión112 (tree)
Tiempo2010-08-20 13:24:27
Autorriorio

Log Message

(empty log message)

Cambiar Resumen

Diferencia incremental

--- ALPHA3/trunk/core/world/accounting/HistoryViewDays.cs (nonexistent)
+++ ALPHA3/trunk/core/world/accounting/HistoryViewDays.cs (revision 112)
@@ -0,0 +1,377 @@
1+using System;
2+using System.Collections.Generic;
3+using System.ComponentModel;
4+using System.Data;
5+using System.Drawing;
6+using System.Text;
7+using System.Windows.Forms;
8+using System.Xml.Serialization;
9+using freetrain.framework;
10+using freetrain.framework.plugin;
11+using freetrain.util;
12+
13+namespace freetrain.world.accounting
14+{
15+ public class HistoryViewDays : Form
16+ {
17+
18+
19+ /// <summary>
20+ /// Persistent setting.
21+ /// </summary>
22+ private Options options = new Options().load();
23+ private FontDialog fontDialog1;
24+ private MenuItem FontSelectorMenuItem;
25+ private MenuItem SeparatorMenuItem;
26+ private MenuItem GenreSelectorMenuItem;
27+ private MenuItem CloseMenuItem;
28+
29+
30+ /// <summary>
31+ /// Persistent information of this dialog.
32+ /// </summary>
33+ public class Options : PersistentOptions
34+ {
35+ /// <summary> display font. </summary>
36+ public FontInfo font;
37+
38+ /// <summary>
39+ /// List of displayed genre ids.
40+ /// Public only for XmlSerializer.
41+ /// </summary>
42+ [XmlElement("genre")]
43+ public string[] _genre;
44+
45+ [XmlIgnore()]
46+ public AccountGenre[] genres {
47+ get {
48+ try {
49+ AccountGenre[] r = new AccountGenre[_genre.Length];
50+ for( int i=0; i<r.Length; i++ )
51+ r[i] = (AccountGenre)PluginManager.theInstance.getContribution(_genre[i]);
52+ return r;
53+ } catch( Exception e ) {
54+ // recover from missing plug-in error by returning a default list.
55+ return new AccountGenre[] {
56+ AccountGenre.RAIL_SERVICE,
57+ AccountGenre.ROAD_SERVICE,
58+ AccountGenre.SUBSIDIARIES
59+ };
60+ }
61+ }
62+ set {
63+ _genre = new string[value.Length];
64+ for( int i=0; i<value.Length; i++ )
65+ _genre[i] = value[i].id;
66+ save();
67+ }
68+ }
69+
70+ public new Options load() {
71+ return (Options)base.load();
72+ }
73+ }
74+
75+
76+
77+ protected override void OnLoad(System.EventArgs e) {
78+ // initialize the font
79+ if(options.font!=null) setFont(options.font.createFont());
80+ }
81+
82+ protected override void OnClosed(System.EventArgs e) {
83+ options.save();
84+ }
85+
86+ private void setFont( Font f ) {
87+ this.Font = f;
88+ listView1.Font = f;
89+ fontDialog1.Font = f;
90+ options.font = new FontInfo(f);
91+ options.save();
92+ }
93+
94+
95+
96+ /// <summary>
97+ /// 必要なデザイナ変数です。
98+ /// </summary>
99+ private System.ComponentModel.IContainer components = null;
100+
101+ /// <summary>
102+ /// 使用中のリソースをすべてクリーンアップします。
103+ /// </summary>
104+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
105+ protected override void Dispose(bool disposing)
106+ {
107+ if (disposing && (components != null))
108+ {
109+ components.Dispose();
110+ }
111+ base.Dispose(disposing);
112+ }
113+
114+ #region Windows フォーム デザイナで生成されたコード
115+
116+ /// <summary>
117+ /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
118+ /// コード エディタで変更しないでください。
119+ /// </summary>
120+ private void InitializeComponent()
121+ {
122+ this.selectSalesButton = new System.Windows.Forms.RadioButton();
123+ this.contextMenu = new System.Windows.Forms.ContextMenu();
124+ this.GenreSelectorMenuItem = new System.Windows.Forms.MenuItem();
125+ this.FontSelectorMenuItem = new System.Windows.Forms.MenuItem();
126+ this.SeparatorMenuItem = new System.Windows.Forms.MenuItem();
127+ this.CloseMenuItem = new System.Windows.Forms.MenuItem();
128+ this.selectExpendituresButton = new System.Windows.Forms.RadioButton();
129+ this.selectBalanceButton = new System.Windows.Forms.RadioButton();
130+ this.listView1 = new System.Windows.Forms.ListView();
131+ this.fontDialog1 = new System.Windows.Forms.FontDialog();
132+ this.SuspendLayout();
133+ //
134+ // selectSalesButton
135+ //
136+ this.selectSalesButton.AutoSize = true;
137+ this.selectSalesButton.Checked = true;
138+ this.selectSalesButton.ContextMenu = this.contextMenu;
139+ this.selectSalesButton.Location = new System.Drawing.Point(13, 13);
140+ this.selectSalesButton.Name = "selectSalesButton";
141+ this.selectSalesButton.Size = new System.Drawing.Size(47, 16);
142+ this.selectSalesButton.TabIndex = 2;
143+ this.selectSalesButton.TabStop = true;
144+ this.selectSalesButton.Text = "売上";
145+ this.selectSalesButton.UseVisualStyleBackColor = true;
146+ this.selectSalesButton.CheckedChanged += new System.EventHandler(this.selectSalesButton_CheckedChanged);
147+ //
148+ // contextMenu
149+ //
150+ this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
151+ this.GenreSelectorMenuItem,
152+ this.FontSelectorMenuItem,
153+ this.SeparatorMenuItem,
154+ this.CloseMenuItem});
155+ //
156+ // GenreSelectorMenuItem
157+ //
158+ this.GenreSelectorMenuItem.Index = 0;
159+ this.GenreSelectorMenuItem.Text = "表示項目の編集(&E)...";
160+ this.GenreSelectorMenuItem.Click += new System.EventHandler(this.GenreSelectorMenuItem_Click);
161+ //
162+ // FontSelectorMenuItem
163+ //
164+ this.FontSelectorMenuItem.Index = 1;
165+ this.FontSelectorMenuItem.Text = "フォント選択(&F)";
166+ this.FontSelectorMenuItem.Click += new System.EventHandler(this.FontSelectorMenuItem_Click);
167+ //
168+ // SeparatorMenuItem
169+ //
170+ this.SeparatorMenuItem.Index = 2;
171+ this.SeparatorMenuItem.Text = "-";
172+ //
173+ // CloseMenuItem
174+ //
175+ this.CloseMenuItem.Index = 3;
176+ this.CloseMenuItem.Text = "閉じる(&C)";
177+ //
178+ // selectExpendituresButton
179+ //
180+ this.selectExpendituresButton.AutoSize = true;
181+ this.selectExpendituresButton.ContextMenu = this.contextMenu;
182+ this.selectExpendituresButton.Location = new System.Drawing.Point(105, 13);
183+ this.selectExpendituresButton.Name = "selectExpendituresButton";
184+ this.selectExpendituresButton.Size = new System.Drawing.Size(47, 16);
185+ this.selectExpendituresButton.TabIndex = 3;
186+ this.selectExpendituresButton.TabStop = true;
187+ this.selectExpendituresButton.Text = "経費";
188+ this.selectExpendituresButton.UseVisualStyleBackColor = true;
189+ this.selectExpendituresButton.CheckedChanged += new System.EventHandler(this.selectExpendituresButton_CheckedChanged);
190+ //
191+ // selectBalanceButton
192+ //
193+ this.selectBalanceButton.AutoSize = true;
194+ this.selectBalanceButton.ContextMenu = this.contextMenu;
195+ this.selectBalanceButton.Location = new System.Drawing.Point(197, 12);
196+ this.selectBalanceButton.Name = "selectBalanceButton";
197+ this.selectBalanceButton.Size = new System.Drawing.Size(47, 16);
198+ this.selectBalanceButton.TabIndex = 4;
199+ this.selectBalanceButton.TabStop = true;
200+ this.selectBalanceButton.Text = "収支";
201+ this.selectBalanceButton.UseVisualStyleBackColor = true;
202+ this.selectBalanceButton.CheckedChanged += new System.EventHandler(this.selectBalanceButton_CheckedChanged);
203+ //
204+ // listView1
205+ //
206+ this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
207+ | System.Windows.Forms.AnchorStyles.Left)
208+ | System.Windows.Forms.AnchorStyles.Right)));
209+ this.listView1.ContextMenu = this.contextMenu;
210+ this.listView1.GridLines = true;
211+ this.listView1.Location = new System.Drawing.Point(12, 35);
212+ this.listView1.Name = "listView1";
213+ this.listView1.Size = new System.Drawing.Size(549, 105);
214+ this.listView1.TabIndex = 5;
215+ this.listView1.UseCompatibleStateImageBehavior = false;
216+ this.listView1.View = System.Windows.Forms.View.Details;
217+ //
218+ // HistoryViewMonths
219+ //
220+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
221+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
222+ this.ClientSize = new System.Drawing.Size(574, 152);
223+ this.Controls.Add(this.listView1);
224+ this.Controls.Add(this.selectBalanceButton);
225+ this.Controls.Add(this.selectExpendituresButton);
226+ this.Controls.Add(this.selectSalesButton);
227+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
228+ this.MaximizeBox = false;
229+ this.MinimizeBox = false;
230+ this.Name = "HistoryViewDays";
231+ this.ShowInTaskbar = false;
232+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
233+ this.Text = "月間売上履歴";
234+ this.ResumeLayout(false);
235+ this.PerformLayout();
236+
237+ }
238+
239+
240+ #endregion
241+
242+ private System.Windows.Forms.RadioButton selectSalesButton;
243+ private System.Windows.Forms.RadioButton selectExpendituresButton;
244+ private System.Windows.Forms.RadioButton selectBalanceButton;
245+ private System.Windows.Forms.ListView listView1;
246+ private System.Windows.Forms.ContextMenu contextMenu;
247+
248+ public enum selector : int {
249+ Sales=0,
250+ Expenditures=1,
251+ Balance=2
252+ }
253+
254+ public selector ButtonSelect = selector.Sales;
255+
256+ public HistoryViewDays()
257+ {
258+ InitializeComponent();
259+
260+ this.listView1.Columns.Add( "分類", 80, HorizontalAlignment.Center );
261+ for( int i=1; i<32; i++ ){
262+ string title = i.ToString() + "日前";
263+ this.listView1.Columns.Add( title, 80, HorizontalAlignment.Center );
264+ }
265+
266+ populateListView();
267+
268+ }
269+
270+
271+ /// <summary>
272+ /// Set up items in the list view according to <code>options.genres</code>.
273+ /// </summary>
274+ private void populateListView() {
275+ listView1.BeginUpdate();
276+ listView1.Items.Clear();
277+ foreach( AccountGenre g in options.genres ) {
278+ ListViewItem lvi = new GenreListItem(this, g, ButtonSelect);
279+ listView1.Items.Add(lvi);
280+ }
281+
282+ // updateItems(); // fill in the sub texts
283+ listView1.EndUpdate();
284+
285+ }
286+
287+ /// <summary>
288+ /// Update the displayed data of list view items.
289+ /// </summary>
290+ private AccountListener updateItems;
291+
292+ /// <summary>
293+ /// Manage ListViewItem and display information about an account genre.
294+ /// </summary>
295+ private class GenreListItem : ListViewItem, IDisposable {
296+ private readonly AccountGenre genre;
297+ private readonly HistoryViewDays parent;
298+ private selector ButtonSelect;
299+
300+ /// <summary> History object that whose value we are displaying. </summary>
301+ private TransactionHistory history { get { return genre.history; } }
302+
303+ internal GenreListItem( HistoryViewDays _parent, AccountGenre genre, selector _ButtonSelect ) {
304+ this.parent = _parent;
305+ this.genre = genre;
306+ this.Text = genre.name;
307+ this.ButtonSelect = _ButtonSelect;
308+
309+ for( int i=1; i<32; i++ )
310+ this.SubItems.Add("0");
311+
312+ onUpdateDays31();
313+
314+ genre.onUpdate += new AccountListener(onUpdateDays31);
315+ parent.updateItems += new AccountListener(onUpdateDays31);
316+ }
317+
318+ public void Dispose() {
319+ // disconnect
320+ genre.onUpdate -= new AccountListener(onUpdateDays31);
321+ parent.updateItems -= new AccountListener(onUpdateDays31);
322+ }
323+
324+ /// <summary> Update data on the screen. </summary>
325+ private void onUpdateDays31() {
326+ TransactionAgoSummary s = history.dayAgo;
327+ for( int i=0 ; i<31 ; i++ ){
328+ if( ButtonSelect==selector.Sales )
329+ this.SubItems[i+1].Text = CurrencyUtil.format(s.sales(i));
330+ if( ButtonSelect==selector.Expenditures )
331+ this.SubItems[i+1].Text = CurrencyUtil.format(s.expenditures(i));
332+ if( ButtonSelect==selector.Balance )
333+ this.SubItems[i+1].Text = CurrencyUtil.format(s.balance(i));
334+ }
335+ }
336+ }
337+
338+ private void selectSalesButton_CheckedChanged(object sender, EventArgs e)
339+ {
340+ ButtonSelect = selector.Sales;
341+ populateListView();
342+ }
343+
344+ private void selectExpendituresButton_CheckedChanged(object sender, EventArgs e)
345+ {
346+ ButtonSelect = selector.Expenditures;
347+ populateListView();
348+ }
349+
350+ private void selectBalanceButton_CheckedChanged(object sender, EventArgs e)
351+ {
352+ ButtonSelect = selector.Balance;
353+ populateListView();
354+ }
355+
356+ private void GenreSelectorMenuItem_Click(object sender, EventArgs e)
357+ {
358+
359+ using (GenreSelectorDialog dialog = new GenreSelectorDialog(options.genres))
360+ {
361+ if (dialog.ShowDialog(this) == DialogResult.OK)
362+ {
363+ // update this window
364+ options.genres = dialog.selected;
365+ populateListView();
366+ }
367+ }
368+ }
369+
370+ private void FontSelectorMenuItem_Click(object sender, EventArgs e)
371+ {
372+ if(fontDialog1.ShowDialog(this)==DialogResult.OK) {
373+ setFont(fontDialog1.Font);
374+ }
375+ }
376+ }
377+}
--- ALPHA3/trunk/core/world/accounting/HistoryViewMonths.cs (nonexistent)
+++ ALPHA3/trunk/core/world/accounting/HistoryViewMonths.cs (revision 112)
@@ -0,0 +1,250 @@
1+using System;
2+using System.Collections.Generic;
3+using System.ComponentModel;
4+using System.Data;
5+using System.Drawing;
6+using System.Text;
7+using System.Windows.Forms;
8+using System.Xml.Serialization;
9+using freetrain.framework;
10+using freetrain.framework.plugin;
11+using freetrain.util;
12+
13+namespace freetrain.world.accounting
14+{
15+ public class HistoryViewMonths : Form
16+ {
17+
18+
19+ /// <summary>
20+ /// Persistent setting.
21+ /// </summary>
22+ private Options options = new Options().load();
23+
24+
25+ /// <summary>
26+ /// Persistent information of this dialog.
27+ /// </summary>
28+ public class Options : PersistentOptions
29+ {
30+ /// <summary> display font. </summary>
31+ public FontInfo font;
32+
33+ /// <summary>
34+ /// List of displayed genre ids.
35+ /// Public only for XmlSerializer.
36+ /// </summary>
37+ [XmlElement("genre")]
38+ public string[] _genre;
39+
40+ [XmlIgnore()]
41+ public AccountGenre[] genres {
42+ get {
43+ try {
44+ AccountGenre[] r = new AccountGenre[_genre.Length];
45+ for( int i=0; i<r.Length; i++ )
46+ r[i] = (AccountGenre)PluginManager.theInstance.getContribution(_genre[i]);
47+ return r;
48+ } catch( Exception e ) {
49+ // recover from missing plug-in error by returning a default list.
50+ return new AccountGenre[] {
51+ AccountGenre.RAIL_SERVICE,
52+ AccountGenre.ROAD_SERVICE,
53+ AccountGenre.SUBSIDIARIES
54+ };
55+ }
56+ }
57+ set {
58+ _genre = new string[value.Length];
59+ for( int i=0; i<value.Length; i++ )
60+ _genre[i] = value[i].id;
61+ save();
62+ }
63+ }
64+
65+ public new Options load() {
66+ return (Options)base.load();
67+ }
68+ }
69+
70+
71+
72+
73+
74+ /// <summary>
75+ /// 必要なデザイナ変数です。
76+ /// </summary>
77+ private System.ComponentModel.IContainer components = null;
78+
79+ /// <summary>
80+ /// 使用中のリソースをすべてクリーンアップします。
81+ /// </summary>
82+ /// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
83+ protected override void Dispose(bool disposing)
84+ {
85+ if (disposing && (components != null))
86+ {
87+ components.Dispose();
88+ }
89+ base.Dispose(disposing);
90+ }
91+
92+ #region Windows フォーム デザイナで生成されたコード
93+
94+ /// <summary>
95+ /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
96+ /// コード エディタで変更しないでください。
97+ /// </summary>
98+ private void InitializeComponent()
99+ {
100+ this.selectSalesButton = new System.Windows.Forms.RadioButton();
101+ this.selectExpendituresButton = new System.Windows.Forms.RadioButton();
102+ this.selectBalanceButton = new System.Windows.Forms.RadioButton();
103+ this.listView1 = new System.Windows.Forms.ListView();
104+ this.SuspendLayout();
105+ //
106+ // selectSalesButton
107+ //
108+ this.selectSalesButton.AutoSize = true;
109+ this.selectSalesButton.Location = new System.Drawing.Point(13, 43);
110+ this.selectSalesButton.Name = "selectSalesButton";
111+ this.selectSalesButton.Size = new System.Drawing.Size(47, 16);
112+ this.selectSalesButton.TabIndex = 2;
113+ this.selectSalesButton.TabStop = true;
114+ this.selectSalesButton.Text = "売上";
115+ this.selectSalesButton.UseVisualStyleBackColor = true;
116+ //
117+ // selectExpendituresButton
118+ //
119+ this.selectExpendituresButton.AutoSize = true;
120+ this.selectExpendituresButton.Location = new System.Drawing.Point(105, 43);
121+ this.selectExpendituresButton.Name = "selectExpendituresButton";
122+ this.selectExpendituresButton.Size = new System.Drawing.Size(47, 16);
123+ this.selectExpendituresButton.TabIndex = 3;
124+ this.selectExpendituresButton.TabStop = true;
125+ this.selectExpendituresButton.Text = "経費";
126+ this.selectExpendituresButton.UseVisualStyleBackColor = true;
127+ //
128+ // selectBalanceButton
129+ //
130+ this.selectBalanceButton.AutoSize = true;
131+ this.selectBalanceButton.Location = new System.Drawing.Point(197, 42);
132+ this.selectBalanceButton.Name = "selectBalanceButton";
133+ this.selectBalanceButton.Size = new System.Drawing.Size(47, 16);
134+ this.selectBalanceButton.TabIndex = 4;
135+ this.selectBalanceButton.TabStop = true;
136+ this.selectBalanceButton.Checked = true;
137+ this.selectBalanceButton.Text = "収支";
138+ this.selectBalanceButton.UseVisualStyleBackColor = true;
139+ //
140+ // listView1
141+ //
142+ this.listView1.Location = new System.Drawing.Point(13, 65);
143+ this.listView1.Name = "listView1";
144+ this.listView1.Size = new System.Drawing.Size(549, 189);
145+ this.listView1.TabIndex = 5;
146+ this.listView1.UseCompatibleStateImageBehavior = false;
147+ this.listView1.Columns.Add("分類", 80);
148+ //
149+ // HistoryView
150+ //
151+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
152+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
153+ this.ClientSize = new System.Drawing.Size(574, 266);
154+ this.Controls.Add(this.listView1);
155+ this.Controls.Add(this.selectBalanceButton);
156+ this.Controls.Add(this.selectExpendituresButton);
157+ this.Controls.Add(this.selectSalesButton);
158+ this.Name = "HistoryView";
159+ this.Text = "売上履歴";
160+ this.ResumeLayout(false);
161+ this.PerformLayout();
162+
163+ for( int i=1; i<13; i++ ){
164+ string title = i.ToString() + "ヶ月前";
165+ this.listView1.Columns.Add( title, 80, HorizontalAlignment.Center );
166+ }
167+
168+ }
169+
170+ #endregion
171+
172+ private System.Windows.Forms.RadioButton selectSalesButton;
173+ private System.Windows.Forms.RadioButton selectExpendituresButton;
174+ private System.Windows.Forms.RadioButton selectBalanceButton;
175+ private System.Windows.Forms.ListView listView1;
176+
177+ public HistoryViewMonths()
178+ {
179+ InitializeComponent();
180+
181+ populateListView();
182+ }
183+
184+
185+ /// <summary>
186+ /// Set up items in the list view according to <code>options.genres</code>.
187+ /// </summary>
188+ private void populateListView() {
189+ listView1.BeginUpdate();
190+ listView1.Items.Clear();
191+ foreach( AccountGenre g in options.genres ) {
192+ ListViewItem lvi = new GenreListItem(this,g);
193+ listView1.Items.Add(lvi);
194+ }
195+ updateItems(); // fill in the sub texts
196+ listView1.EndUpdate();
197+ }
198+
199+ /// <summary>
200+ /// Update the displayed data of list view items.
201+ /// </summary>
202+ private AccountListener updateItems;
203+
204+ /// <summary>
205+ /// Manage ListViewItem and display information about an account genre.
206+ /// </summary>
207+ private class GenreListItem : ListViewItem, IDisposable {
208+ private readonly AccountGenre genre;
209+ private readonly HistoryViewMonths parent;
210+
211+ /// <summary> History object that whose value we are displaying. </summary>
212+ private TransactionHistory history { get { return genre.history; } }
213+
214+ internal GenreListItem( HistoryViewMonths _parent, AccountGenre genre ) {
215+ this.parent = _parent;
216+ this.genre = genre;
217+ this.Text = genre.name;
218+
219+ for( int i=1; i<13; i++ )
220+ this.SubItems.Add("0");
221+
222+ onUpdateMonths12();
223+
224+ genre.onUpdate += new AccountListener(onUpdateMonths12);
225+ parent.updateItems += new AccountListener(onUpdateMonths12);
226+ }
227+
228+ public void Dispose() {
229+ // disconnect
230+ genre.onUpdate -= new AccountListener(onUpdateMonths12);
231+ parent.updateItems -= new AccountListener(onUpdateMonths12);
232+ }
233+
234+ /// <summary> Update data on the screen. </summary>
235+ private void onUpdateMonths12() {
236+ TransactionAgoSummary s = history.monthAgo;
237+ for( int i=0 ; i<12 ; i++ ){
238+ // if( selectSalesButton.Checked )
239+ // this.SubItems[i+1].Text = CurrencyUtil.format(s.sales(i));
240+ // if( selectExpendituresButton.Checked )
241+ // this.SubItems[i+1].Text = CurrencyUtil.format(s.expenditures(i));
242+ // if( selectBalanceButton.Checked )
243+ this.SubItems[i+1].Text = CurrencyUtil.format(s.balance(i));
244+ }
245+ }
246+ }
247+
248+
249+ }
250+}
Show on old repository browser