Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Easy Desktop Web Stats

, 23 Oct 2012 CPOL
Create a Windows desktop app to display daily web stats from your personal site
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()

            // declare Form context menu;
            string[] formMenuItemDescriptions = {"Preferences",
                                                 "Close the program"};

            EventHandler[] formMenuItemEventHandlers = {Preferences_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())

        private void RestoreLastPosition()
            if (settings.preferredLocation != nullRefPoint)
                this.Location = settings.preferredLocation;
        private void savePositionTimer_Tick(object sender, EventArgs e)
            settings.preferredLocation = this.Location;

        private void CloseAndDispose()

        private void Main_Move(object sender, EventArgs e)
            // stop the timer if it is already running;
            // wait 8 seconds, then save the new position;
            savePositionTimer.Interval = 8000;

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 article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Michael J Hill - OH

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 23 Oct 2012
Article Copyright 2012 by Michael J Hill - OH
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid