|
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Media;
using Compatibility;
using ContextMenuBuilder;
namespace Desktop_Web_Stats
{
public partial class Main : Form
{
private delegate void AppInitializeDelegate();
private AppInitializeDelegate performAppInitialize;
private Properties.Settings settings = Properties.Settings.Default;
private ContextMenu formContextMenu = new ContextMenu();
private Point nullRefPoint = new Point(-1, -1);
private Timer savePositionTimer = new Timer();
Form preferencesForm = new Desktop_Web_Stats.Preferences();
public static bool preferencesChanged = false;
public Main()
{
InitializeComponent();
// declare Form context menu;
string[] formMenuItemDescriptions = {"Preferences",
"Close the program"};
EventHandler[] formMenuItemEventHandlers = {Preferences_Item_Click,
Close_Item_Click};
this.ContextMenu = formContextMenu;
// append initialize methods to delegate;
performAppInitialize += RestoreLastPosition;
performAppInitialize += Manage.StartupFolderLnk;
performAppInitialize += (() => { Build.Menu(formMenuItemDescriptions, formMenuItemEventHandlers, formContextMenu); });
performAppInitialize += (() => { savePositionTimer.Tick += new EventHandler(savePositionTimer_Tick); });
performAppInitialize += CreateDataRequestCycle;
}
private void Main_Load(object sender, EventArgs e)
{
VouchSafe Verified = new VouchSafe();
if (!Verified.compatibility())
{
CloseAndDispose();
}
performAppInitialize();
}
private void RestoreLastPosition()
{
if (settings.preferredLocation != nullRefPoint)
{
this.Location = settings.preferredLocation;
}
}
private void savePositionTimer_Tick(object sender, EventArgs e)
{
savePositionTimer.Stop();
settings.preferredLocation = this.Location;
settings.Save();
}
private void CloseAndDispose()
{
Dispose(true);
Application.Exit();
}
private void Main_Move(object sender, EventArgs e)
{
// stop the timer if it is already running;
savePositionTimer.Stop();
// wait 8 seconds, then save the new position;
savePositionTimer.Interval = 8000;
savePositionTimer.Start();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.