Example #1
0
		public MainWindow()
		{
			try
			{
				InitializeComponent();

				if (User.Default.MinimiseToSystemTray)
				{
					//add tray icon
					_tray = new TrayMainWindows(this);

					//add global key
					_hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
				}

                //add view on change file
                _changefile = new ObserverChangeFile();
                _changefile.OnFileTaskListChange += () => Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { this.Refresh(); }));

                //CheckUpdate new version
                _checkupdate = new CheckUpdate();
                _checkupdate.OnCheckedUpdateVersion += (string version) => Dispatcher.BeginInvoke(new CheckUpdate.CheckUpdateVersion(this.ShowUpdateMenu), version);
                _checkupdate.Check();

				webBrowser1.Navigate("about:blank");

				// migrate the user settings from the previous version, if necessary
				if (User.Default.FirstRun)
				{
					User.Default.Upgrade();
					User.Default.FirstRun = false;
					User.Default.Save();
				}

				Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

				this.Height = User.Default.WindowHeight;
				this.Width = User.Default.WindowWidth;
				this.Left = User.Default.WindowLeft;
				this.Top = User.Default.WindowTop;

				if (!string.IsNullOrEmpty(User.Default.FilePath))
					LoadTasks(User.Default.FilePath);

				FilterAndSort((SortType)User.Default.CurrentSort);

				lbTasks.Focus();

				string startupFile = ((App)App.Current).StartupFile;
				if (!string.IsNullOrEmpty(startupFile))
					LoadTasks(startupFile);
			}
			catch (Exception ex)
			{
				var msg = "An error occurred while intialising the application";
				Log.Error(msg, ex);
				MessageBox.Show(ex.Message, msg, MessageBoxButton.OK);
			}
			
		}
Example #2
0
 private void SetupTrayIcon()
 {
     if (User.Default.MinimiseToSystemTray)
     {
         _tray   = new TrayMainWindows(this);
         _hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
     }
 }
Example #3
0
		private void SetupTrayIcon()
		{
			if (User.Default.MinimiseToSystemTray)
			{
				_tray = new TrayMainWindows(this);
				_hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
			}
		}
Example #4
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                if (User.Default.MinimiseToSystemTray)
                {
                    //add tray icon
                    _tray = new TrayMainWindows(this);

                    //add global key
                    _hotkey = new HotKeyMainWindows(this, ModifierKeys.Windows | ModifierKeys.Alt, System.Windows.Forms.Keys.T);
                }

                //add view on change file
                _changefile = new ObserverChangeFile();
                _changefile.OnFileTaskListChange += () => Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { this.Refresh(); }));

                //CheckUpdate new version
                _checkupdate = new CheckUpdate();
                _checkupdate.OnCheckedUpdateVersion += (string version) => Dispatcher.BeginInvoke(new CheckUpdate.CheckUpdateVersion(this.ShowUpdateMenu), version);
                _checkupdate.Check();

                webBrowser1.Navigate("about:blank");

                // migrate the user settings from the previous version, if necessary
                if (User.Default.FirstRun)
                {
                    User.Default.Upgrade();
                    User.Default.FirstRun = false;
                    User.Default.Save();
                }

                Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

                this.Height = User.Default.WindowHeight;
                this.Width  = User.Default.WindowWidth;
                this.Left   = User.Default.WindowLeft;
                this.Top    = User.Default.WindowTop;

                if (!string.IsNullOrEmpty(User.Default.FilePath))
                {
                    LoadTasks(User.Default.FilePath);
                }

                FilterAndSort((SortType)User.Default.CurrentSort);

                lbTasks.Focus();
            }
            catch (Exception ex)
            {
                var msg = "An error occurred while intialising the application";
                Log.Error(msg, ex);
                MessageBox.Show(ex.Message, msg, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_tray != null)
                    {
                        _tray.Dispose();
                        _tray = null;
                    }

                    if (_hotkey != null)
                    {
                        _hotkey.Dispose();
                        _hotkey = null;
                    }

                    if (_changefile != null)
                    {
                        _changefile.Dispose();
                        _changefile = null;
                    }
                }

                _disposed = true;
            }
        }