#region Using directives >using System; >using System.Collections; >using System.ComponentModel; >using System.Data; >using System.Drawing; >using System.Windows.Forms; > >#endregion > >namespace JTB.TimeRecorder >{ > partial class StartupForm : Form > { > #region public variables > DateTime zeroTime = DateTime.Parse("00:00"); // Don't think this is the best way of setting a time to midnight > TaskType myTaskType = new TaskType(); > DataConnector dc1 = new DataConnector(); > #endregion > > public StartupForm() > { > InitializeComponent(); > } > > private void StartupForm_Load(object sender, EventArgs e) > { > StartTime.Value = zeroTime; > EndTime.Value = zeroTime; > > // playing > string myTest = myTaskType.GetOneType(3); // get an item directly from the class > myTaskType.AddOneType("Adding item 1"); // Add a new item directly > cboTaskType.DataSource = dc1; > dc1.DataSource = myTaskType.Types; // set the class to be a DataConnector for some reason, VS2005 way of doing things > dc1.Position = dc1.Add("Adding item 2"); // Add a new item via the DataConnector and set the current position to be that new item > } > > #region re-size management > /// <summary> > /// Form is being resized, allow anything but minimize > /// If the user minimized the form then send it to the system tray > /// </summary> > /// <param name="sender"></param> > /// <param name="e"></param> > private void StartupForm_Resize(object sender, EventArgs e) > { > if (WindowState == FormWindowState.Minimized) > { > ShowInTaskbar = false; > NotifySysTray.Visible = true; > } > else > { > this.ShowInTaskbar = true; > NotifySysTray.Visible = false; > } > } >/// <summary> >/// Close the form from the sys tray icon >/// </summary> >/// <param name="sender"></param> >/// <param name="e"></param> > private void MenuSysTray_Close_Click(object sender, EventArgs e) > { > this.Close(); > } >/// <summary> >/// Restore the Time record to previous state >/// </summary> >/// <param name="sender"></param> >/// <param name="e"></param> > private void MenuSysTray_Restore_Click(object sender, EventArgs e) > { > WindowState = FormWindowState.Normal; > StartupForm_Resize(sender, e); > } > #endregion > > #region Button control > private void btnClose_Click(object sender, EventArgs e) > { > this.Close(); > } > #endregion > } > > #region tasktype class - Lists all the task that I currently undertake and may be added to, hence serializable > [Serializable] // Still got to learn how to do this, and what its really about - Think its some kind of XML write to file > public class TaskType > { > private ArrayList _types = new ArrayList(); > private int _myVar; > private string _myString = "John"; > > public TaskType() > { > _types.Add("Dev MRP v1.2"); > _types.Add("Dev MRP v1.1 (retro fix)"); > _types.Add("Dev MRP v1.0 (retro fix)"); > _types.Add("Dev (retro fix) pre MRP<v8.2"); > _types.Add("QA v1.2"); > _types.Add("(Support) Previous version(s)"); > _types.Add("(BUG) New version issue "); > _types.Add("General Admin"); > _types.Add("Holiday (When I'm lucky)"); > } > > public int MyVar > { > get { return _myVar; } > set { _myVar = value; } > } > > public ArrayList Types > { > get { return _types; } > } > > public string GetOneType(int recordno) > { > if (recordno < Types.Count) > return (string)_types[recordno]; > else > return ""; > } > > public int AddOneType(string value) > { > > return _types.Add(value); ; > } > > public string MyString > { > get { return _myString; } > set { _myString = value; } > } > > } > #endregion >}>