void UpdatesFormShown(object sender, EventArgs e) { // If already checked, do nothing if (already_checked) { return; } // Check for updates u = new UpdatesCheck(); u.Error += delegate { try { this.Invoke((MethodInvoker) delegate { ShowPanel(panError); }); } catch { Utils.Debug.Write("CEZ"); } }; u.Updated += delegate { try { this.Invoke((MethodInvoker) delegate { ShowPanel(panUpdated); }); } catch { Utils.Debug.Write("CEZ"); } }; u.NewVersionAvailable += delegate(string version, string url_setup, int size_setup, string url_portable, int size_portable) { try { this.Invoke((MethodInvoker) delegate { ShowAvailableUpdate(version, url_setup, size_setup, url_portable, size_portable); }); } catch { Utils.Debug.Write("CEZ"); } }; u.Check(); }
void UpdatesFormShown(object sender, EventArgs e) { // If already checked, do nothing if (already_checked) return; // Check for updates u = new UpdatesCheck(); u.Error += delegate { try { this.Invoke((MethodInvoker)delegate { ShowPanel(panError); }); } catch { Utils.Debug.Write("CEZ"); } }; u.Updated += delegate { try { this.Invoke((MethodInvoker)delegate { ShowPanel(panUpdated); }); } catch { Utils.Debug.Write("CEZ"); } }; u.NewVersionAvailable += delegate(string version, string url_setup, int size_setup, string url_portable, int size_portable) { try { this.Invoke((MethodInvoker)delegate { ShowAvailableUpdate(version, url_setup, size_setup, url_portable, size_portable); }); } catch { Utils.Debug.Write("CEZ"); } }; u.Check(); }
// Loading operations private void MainFormLoad(object sender, EventArgs e) { treeTasks.MultiSelect = true; // Hide move panel HideMovePanel(); // Set up application pahs DirectoryInfo appdir = new DirectoryInfo(Application.ExecutablePath); appdir = new DirectoryInfo(appdir.Parent.FullName); ApplicationDirectory = appdir.FullName.TrimEnd(new char[] {'\\'}) + "\\"; DatabasePath = ApplicationDirectory + "db.sqlite"; ConfigurationPath = ApplicationDirectory + "todomoo.conf"; BackupDirectory = ApplicationDirectory + "backups\\"; LanguageDirectory = ApplicationDirectory + "lang\\"; // Create the main engine from the database file try { Todomoo.OpenDatabase(DatabasePath); } catch (Exception ex) { ExitWithError("Unable to load main database (db.sqlite)!\n" + ex.Message); return; } // Create the default configuration, then load user settings Settings = new Utils.AppSettings(ConfigurationPath); ApplyDefaultSettings(); Settings.Load(); // Language inizialization Lang = new Languages.Language(LanguageDirectory); Lang.LoadLanguage(Settings.Get("lang").ToString()); ApplyLanguage(); // Form aspect WindowState = (Settings.Get("window_maximized").ToString() == "1") ? FormWindowState.Maximized : FormWindowState.Normal; if (Settings.Get("window_maximized").ToString() != "1") { Rectangle screen = Screen.PrimaryScreen.Bounds; int w = Math.Max(100, Math.Min(screen.Width - 50, (int)Settings.Get("window_width" ))); int h = Math.Max(100, Math.Min(screen.Height - 50, (int)Settings.Get("window_height"))); int x = Math.Max(0, Math.Min(screen.Width - w, (int)Settings.Get("window_xpos" ))); int y = Math.Max(0, Math.Min(screen.Height - h, (int)Settings.Get("window_ypos" ))); SetBounds(x, y, w, h); } UpdateFormAspect(); UpdateColumnsAspect(); treeTasks.Refresh(); // Icons initialization btnCategoryAll.Image = IconColoured.GetSquared(Color.Gray); // Setup task tree and load categories. // SelectedCategory set method automatically fill in the tree. SetupTaskTree(); LoadCategories(); int category_to_load_id = Utils.Conversion.ToInt(Settings.Get("selected_category").ToString()); foreach (Category category in Todomoo.Categories) if (category.Id == category_to_load_id) SelectedCategory = category; // Updates auto check if (Settings.Get("updates_auto").ToString() == "1") { // Wait 5secs and start to check for updates timerUpdates = new Timer(); timerUpdates.Interval = 5000; timerUpdates.Tick += delegate { timerUpdates.Stop(); u = new UpdatesCheck(); u.Error += delegate(string message) { try { Utils.Debug.Write("Updates check error: " + message); } catch { } }; u.NewVersionAvailable += delegate(string version, string url_setup, int size_setup, string url_portable, int size_portable) { try { this.Invoke((MethodInvoker)delegate { UpdatesForm.CreateWithNewVersion(Lang, Settings, version, url_setup, size_setup, url_portable, size_portable).ShowDialog(this); }); } catch { } }; u.Check(); }; timerUpdates.Start(); } }