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.Collections.Generic;

using MessageManager;

namespace Desktop_Web_Stats
{
    public partial class Preferences : Form
    {
        private Properties.Settings settings = Properties.Settings.Default;
      
        private List<string> changePool; 
        
        public Preferences()
        {
            InitializeComponent();
        }

        private void ok_Btn_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            if (changePool.Contains("True"))
            {               
                settings.updateInterval = (short)updateInterval_UpDn.Value;
                settings.autoStart = autoStart_ckBox.Checked;
                settings.playDing = playDing_ckBox.Checked;

                Main.preferencesChanged = true;

                try
                {
                    settings.Save();
                    Main.preferencesChanged = true;                   
                    Dialog.Message("Success", "Your new preferences were saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    Dialog.Message("Error", "An error occurred\nTry again to change your preferences", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {                
                Main.preferencesChanged = false; 
                Dialog.Message("Cancelled", "No changes were made", MessageBoxButtons.OK, MessageBoxIcon.Information);                              
            }
        }

        private void Preferences_Load(object sender, EventArgs e)
        {
            changePool = new List<string>() { "False", "False", "False" };              

            updateInterval_UpDn.Value = settings.updateInterval;
            autoStart_ckBox.Checked = settings.autoStart;
            playDing_ckBox.Checked = settings.playDing;           
        }

        private void Preferences_FormClosed(object sender, FormClosedEventArgs e)
        {
            Dispose(true);
        }

        private void updateInterval_UpDn_Click(object sender, EventArgs e)
        {
           changePool[0] = (short)updateInterval_UpDn.Value != (short)settings["updateInterval"] ? "True" : "False";            
        }

        private void autoStart_ckBox_Click(object sender, EventArgs e)
        {
            changePool[1] = autoStart_ckBox.Checked != (bool)settings["autoStart"] ? "True" : "False";            
        }

        private void playDing_ckBox_Click(object sender, EventArgs e)
        {
            changePool[2] = playDing_ckBox.Checked != (bool)settings["playDing"] ? "True" : "False";           
        }       
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Michael J Hill - OH

United States United States
No Biography provided

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