0:   //  TipOfTheDay.cs
1:   //  Copyright (C) 2000 Mike Krueger
2:   //
3:   //  This program is free software; you can redistribute it and/or modify
4:   //  it under the terms of the GNU General Public License as published by
5:   //  the Free Software Foundation; either version 2 of the License, or
6:   //  (at your option) any later version.
7:   //
8:   //  This program is distributed in the hope that it will be useful,
9:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11:   //  GNU General Public License for more details.
12:   //
13:   //  You should have received a copy of the GNU General Public License
14:   //  along with this program; if not, write to the Free Software
15:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16:  
17:   using System;
18:   using System.Drawing;
19:   using System.ComponentModel;
20:   using System.Resources;
21:   using System.Windows.Forms;
22:   using System.Xml;
23:   using System.IO;
24:  
25:   using SharpDevelop.Gui;
26:   using SharpDevelop.Tool.Data;
27:   using SharpDevelop.Tool.Text;
28:  
29:   namespace SharpDevelop.Gui.Dialogs {
30:       
31:       public class TipOfTheDayView : UserControl
32:       {
33:           readonly int ICON_DISTANCE 16;
34:           Bitmap     icon      null;
35:           Font     titlefont new Font("Times new Roman"15FontStyle.Bold);
36:           Font     textfont  new Font("Times new Roman"12);
37:           string[] tips;
38:           int      curtip 0;
39:           
40:           string didyouknowtext;
41:           
42:           public TipOfTheDayView(XmlElement el)
43:           {
44:               this.didyouknowtext Resource.GetString("Dialog.TipOfTheDay.DidYouKnowText");
45:               
46:               icon   Resource.GetBitmap("Icons.TipOfTheDayIcon");
47:               
48:               
49:   //            XmlNodeList nodes = el.GetElementsByTagName("TIP");
50:               XmlNodeList nodes el.ChildNodes;
51:               
52:               tips new string[nodes.Count];
53:               for (int 0< nodes.Count; ++i) {
54:                   tips[i] = StringParser.Parse(nodes[i].InnerText);
55:               }
56:               
57:               curtip = (new Random().Next()) % nodes.Count;
58:               
59:           }
60:           
61:           protected override void OnPaintBackground(PaintEventArgs pe)
62:           {}
63:           
64:           protected override void OnPaint(PaintEventArgs pe)
65:           {
66:               Graphics g pe.Graphics;
67:               
68:               g.FillRectangle(new SolidBrush(Color.Gray), 0,
69:                                                           0,
70:                                                           icon.Width ICON_DISTANCE,
71:                                                           Height);
72:               g.FillRectangle(new SolidBrush(Color.White), icon.Width ICON_DISTANCE,
73:                                                                      0,
74:                                                                      Width icon.Width ICON_DISTANCE,
75:                                                                      Height);
76:               g.DrawImage(iconICON_DISTANCE 24);
77:               
78:               g.DrawString(didyouknowtexttitlefontnew SolidBrush(Color.Black), icon.Width ICON_DISTANCE 48);
79:               
80:               g.DrawLine(new Pen(Color.Black), new Point(icon.Width ICON_DISTANCEtitlefont.Height 2),
81:                                                new Point(Widthtitlefont.Height 2));
82:               drawrect new Rectangle(icon.Width ICON_DISTANCEtitlefont.Height 6,
83:                                        Width icon.Width ICON_DISTANCEHeight - (titlefont.Height 6));
84:               
85:               g.DrawString(tips[curtip], textfontnew SolidBrush(Color.Black), drawrect);
86:           }
87:           Rectangle drawrect;
88:           
89:           public void NextTip()
90:           {
91:               curtip = (curtip 1) % tips.Length;
92:               Invalidate(drawrect);
93:               Update();
94:           }
95:       }
96:       
97:       public class TipOfTheDayDialog : Form 
98:       {
99:       
100:           private System.ComponentModel.Container components;
101:           private CheckBox checkBox1;
102:           private Button button2;
103:           private Button button1;
104:           
105:           Panel panel new Panel();
106:           TipOfTheDayView tipview;
107:           
108:           void NextTip(object senderEventArgs e)
109:           {
110:               tipview.NextTip();
111:           }
112:           
113:           void CheckChange(object senderEventArgs e)
114:           {
115:               Options.SetProperty("SharpDevelop.Gui.Dialog.TipOfTheDayView.ShowTipsAtStartup"checkBox1.Checked);
116:           }
117:           
118:           public TipOfTheDayDialog()
119:           {
120:               
121:               InitializeComponent();
122:               StartPosition FormStartPosition.CenterParent;
123:               
124:               Icon null;
125:               
126:               XmlDocument doc new XmlDocument();
127:               doc.Load(Application.StartupPath "\\..\\data\\options\\TipsOfTheDay.xml" );
128:                   
129:               tipview new TipOfTheDayView(doc.DocumentElement);
130:               panel.Controls.Add(tipview);
131:   //            panel.FormBorderStyle = FormBorderStyle.Fixed3D;
132:               Controls.Add(panel);
133:               
134:               panel.Width  tipview.Width  Width 24;
135:               panel.Height tipview.Height button1.Top 15;
136:               panel.Location new Point(85);
137:               button1.Click += new EventHandler(NextTip);
138:               
139:               checkBox1.CheckedChanged += new EventHandler(CheckChange);
140:               checkBox1.Checked Boolean.Parse(Options.GetProperty("SharpDevelop.Gui.Dialog.TipOfTheDayView.ShowTipsAtStartup"true).ToString());
141:               
142:               MaximizeBox  MinimizeBox false;
143:               ShowInTaskbar false;
144:               
145:           }
146:           
147:           /// <summary>
148:           /// Clean up any resources being used.
149:           /// </summary>
150:           protected override void Dispose(bool disposing)
151:           {
152:               if (disposing) {
153:                   if (components != null){
154:                       components.Dispose();
155:                   }
156:               }
157:               base.Dispose(disposing);
158:           }
159:           
160:           private void InitializeComponent()
161:           {
162:               this.components new System.ComponentModel.Container();
163:               this.button2 new Button();
164:               this.checkBox1 new CheckBox();
165:               this.button1 new Button();
166:               
167:               button2.Location new System.Drawing.Point(328232);
168:               button2.DialogResult DialogResult.Cancel;
169:               button2.Size new System.Drawing.Size(8024);
170:               button2.TabIndex 1;
171:               button2.Text Resource.GetString("Global.CloseButtonText");
172:               
173:               checkBox1.Location new System.Drawing.Point(8232);
174:               checkBox1.Text Resource.GetString("Dialog.TipOfTheDay.checkBox1Text");
175:               checkBox1.Size new System.Drawing.Size(21024);
176:   //            checkBox1.AccessibleRole = AccessibleRoles.CheckButton;
177:               checkBox1.TabIndex 2;
178:               checkBox1.TextAlign System.Drawing.ContentAlignment.MiddleLeft;
179:               
180:               this.AutoScaleBaseSize new System.Drawing.Size(513);
181:               this.Text Resource.GetString("Dialog.TipOfTheDay.DialogName");
182:               //@design this.TrayLargeIcon = true;
183:               this.FormBorderStyle FormBorderStyle.FixedDialog;
184:               //@design this.TrayHeight = 0;
185:               this.ClientSize new System.Drawing.Size(418263);
186:               
187:               button1.Location new System.Drawing.Point(240 16232);
188:               button1.Size new System.Drawing.Size(9624);
189:               button1.TabIndex 0;
190:               button1.Text Resource.GetString("Dialog.TipOfTheDay.button1Text");
191:               
192:               this.Controls.Add(checkBox1);
193:               this.Controls.Add(button2);
194:               this.Controls.Add(button1);
195:           }
196:       }
197:   }

This page was automatically generated by SharpDevelop.