public UpdatesForm(Languages.Language language, Utils.AppSettings settings) { // Windows Forms designer support. InitializeComponent(); // Show first panel ShowPanel(panChecking); // Setup settings reference Settings = settings; // Setup language for the form Lang = language; Text = Lang.Get("updates"); btnClose.Text = Lang.Get("close"); // Language setup lblChecking.Text = Lang.Get("updates_checking") + "..."; lblUpdated.Text = Lang.Get("updates_updated"); lblError.Text = Lang.Get("updates_error"); chkAuto.Text = Lang.Get("updates_auto"); // Auto check chkAuto.Checked = (Settings.Get("updates_auto").ToString() == "1"); chkAuto.CheckedChanged += delegate { Settings.Set("updates_auto", chkAuto.Checked ? 1 : 0); }; }
public static UpdatesForm CreateWithNewVersion( Languages.Language language, Utils.AppSettings settings, string version, string url_setup, int size_setup, string url_portable, int size_portable ) { // Create the form UpdatesForm u = new UpdatesForm(language, settings); u.already_checked = true; u.ShowAvailableUpdate(version, url_setup, size_setup, url_portable, size_portable); return(u); }
/// <summary> /// Edit a Category object. /// </summary> /// <param name="category">Category to edit</param> public CategoryForm(Languages.Language language, Category category) { // Windows Forms designer support. InitializeComponent(); // Setup task this.category = category; // Create form icon this.Icon = IconColoured.GetSquaredIcon(category.Colour); // Setup language Lang = language; Text = Lang.Get((category.Id == 0) ? "category_add" : "category_edit"); btnOk.Text = " " + Lang.Get((category.Id == 0) ? "add" : "edit"); btnCancel.Text = Lang.Get("cancel"); btnChooseColour.Text = " " + Lang.Get("colour_choose"); lblName.Text = Lang.Get("name") + ":"; lblColour.Text = Lang.Get("colour") + ":"; // Populate colours combo int index = 0; cmbColour.ImageList.ColorDepth = ColorDepth.Depth32Bit; foreach (Category cat in Todomoo.Categories) { cmbColour.ImageList.Images.Add(IconColoured.GetSquared(cat.Colour)); ImageComboItem item = new ImageComboItem(Lang.Get("colour_as") + " " + cat.Name, index); item.Tag = cat.Colour; cmbColour.Items.Add(item); index++; } if (cmbColour.Items.Count == 0) { cmbColour.ImageList.Images.Add(IconColoured.GetSquared(Color.Gray)); ImageComboItem item = new ImageComboItem(Lang.Get("default"), index); item.Tag = Color.Gray; cmbColour.Items.Add(item); } cmbColour.SelectedIndex = 0; // Fill in GUI fields txtName.Text = category.Name; foreach (ImageComboItem item in cmbColour.Items) { if (item.Text == Lang.Get("colour_as") + " " + category.Name) { cmbColour.SelectedItem = item; } } }
public AboutForm(Languages.Language language) { // Windows Forms designer support. InitializeComponent(); // Version no Version v = new Version(Application.ProductVersion); lblBuild.Text = v.Major + "." + v.Minor; // Language btnClose.Text = language.Get("close"); Text = language.Get("help_about"); // Credits string htmlCredits = @" <!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd""> <html lang=""en""> <head> <style type=""text/css""> body { font-size: 11px; font-family: Tahoma, sans-serif; margin: 0; padding: 10px 10px; background-color: #f6f6f6; color: #000000; } p { padding: 0; margin: 0 0 10px; } </style> </head> <body> <p> Best beta tester ever: <b>Davide "Gege" De Gennaro</b><br> Cutest beta tester ever: <b>Serena Mantovani</b> </p> <p> French translation: <b>MML67</b><br> Portuguese translation: <b>Edson Braga Zampieri</b><br> Spanish translation: <b>Ian</b><br> Chinese translation: <b>Chunhui Zhao</b><br> Dutch translation: <b>Rick Spaan</b><br> Thai translation: <b>Prakrit Dungsutha</b><br> Polish translation: <b>Eugeniusz Wieczorek</b><br> Greek translation: <b>geogeo.gr</b><br> Romanian translation: <b>Oprea Nicolae</b><br> German translation: <b>Wolfgang Gaida</b><br> Russian translation: <b>Василий Павлов</b> </p> <p> <a href=""http://www.famfamfam.com/lab/icons/silk/"">Silk icons</a> by FamFamFam.<br> <a href=""http://www.codeproject.com/KB/list/ObjectListView.aspx"">Object list view</a> by Phillip Piper (GNU GPL). </p> </body> </html> " ; webCredits.DocumentText = htmlCredits.Trim(new char[] { '\n', '\r', '\t', ' ' }).Trim(); webCredits.Navigating += delegate(object sender, WebBrowserNavigatingEventArgs e) { System.Diagnostics.Process.Start(e.Url.ToString()); e.Cancel = true; }; }
// Constructor public OptionsForm(Languages.Language language, Utils.AppSettings settings) { // Windows Forms designer support. InitializeComponent(); // Setup settings reference Settings = settings; // Setup language for the form Lang = language; Text = Lang.Get("options"); btnOk.Text = Lang.Get("ok"); btnCancel.Text = Lang.Get("cancel"); // Setup language for GUI tabGui.Text = Lang.Get("options_gui"); boxAppearance.Text = Lang.Get("options_appearance"); lblMenuStyle.Text = Lang.Get("options_menu") + ":"; lblToolbarStyle.Text = Lang.Get("options_toolbar") + ":"; lblCategoriesStyle.Text = Lang.Get("options_categories_bar") + ":"; cmbMenuStyle.Items[0] = Lang.Get("options_style_standard"); cmbMenuStyle.Items[1] = Lang.Get("options_style_flat"); cmbToolbarStyle.Items[0] = Lang.Get("options_style_standard"); cmbToolbarStyle.Items[1] = Lang.Get("options_style_flat"); cmbCategoriesStyle.Items[0] = Lang.Get("options_style_standard"); cmbCategoriesStyle.Items[1] = Lang.Get("options_style_flat"); boxLanguage.Text = Lang.Get("options_language"); lblCurrency.Text = Lang.Get("options_currency") + ":"; // Setup language for backup tabBackup.Text = Lang.Get("options_backups"); cmdBackupDirectory.Text = Lang.Get("options_backup_dir"); lblBackupTip.Text = Lang.Get("options_backup_tip"); boxAutomaticBackup.Text = Lang.Get("options_automatic_backup"); chkAutomaticBackup.Text = Lang.Get("options_automatic_backup_text"); // Setup language for minimize to tray boxBehaviour.Text = Lang.Get("options_behaviour"); lblClosing.Text = Lang.Get("options_closing") + ":"; optClosingMinimize.Text = Lang.Get("minimize_to_tray"); optClosingClose.Text = Lang.Get("close_program"); // Fill in fields for the GUI cmbMenuStyle.SelectedIndex = (Settings.Get("style_menu").ToString() == "0" ? 0 : 1); cmbToolbarStyle.SelectedIndex = (Settings.Get("style_toolbar").ToString() == "0" ? 0 : 1); cmbCategoriesStyle.SelectedIndex = (Settings.Get("style_categories").ToString() == "0" ? 0 : 1); cmbCurrency.SelectedIndex = 0; if (Settings.Get("currency").ToString() == "€") { cmbCurrency.SelectedIndex = 0; } if (Settings.Get("currency").ToString() == "$") { cmbCurrency.SelectedIndex = 1; } if (Settings.Get("currency").ToString() == "£") { cmbCurrency.SelectedIndex = 2; } if (Settings.Get("currency").ToString() == "¥") { cmbCurrency.SelectedIndex = 3; } if (Settings.Get("currency").ToString() == "R$") { cmbCurrency.SelectedIndex = 4; } if (Settings.Get("currency").ToString() == "฿") { cmbCurrency.SelectedIndex = 5; } // Fill in languages combo cmbLanguage.Items.Clear(); foreach (Languages.AvailableLanguage l in Languages.AvailableLanguage.GetAll()) { cmbLanguage.Items.Add(l); if (Settings.Get("lang").ToString() == l.Code) { cmbLanguage.SelectedItem = l; } } // Fill in minimize radio if (Settings.Get("window_minimize_when_closing").ToString() == "0") { optClosingClose.Checked = true; } else { optClosingMinimize.Checked = true; } // Fill in fields for the backup chkAutomaticBackup.Checked = (Settings.Get("backup_automatic").ToString() == "1"); try { long sum = 0; DirectoryInfo backup_dir = new DirectoryInfo(MainForm.BackupDirectory); if (!backup_dir.Exists) { backup_dir.Create(); } FileInfo[] files = backup_dir.GetFiles("*.sqlite"); foreach (FileInfo file in files) { sum += file.Length; } lblBackupSize.Text = ((float)sum / (1024F * 1024F)).ToString("0.00").Replace(',', '.') + " MB"; } catch { lblBackupSize.Text = "? MB"; } }
// 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(); } }
// Constructor public OptionsForm(Languages.Language language, Utils.AppSettings settings) { // Windows Forms designer support. InitializeComponent(); // Setup settings reference Settings = settings; // Setup language for the form Lang = language; Text = Lang.Get("options"); btnOk.Text = Lang.Get("ok"); btnCancel.Text = Lang.Get("cancel"); // Setup language for GUI tabGui.Text = Lang.Get("options_gui"); boxAppearance.Text = Lang.Get("options_appearance"); lblMenuStyle.Text = Lang.Get("options_menu") + ":"; lblToolbarStyle.Text = Lang.Get("options_toolbar") + ":"; lblCategoriesStyle.Text = Lang.Get("options_categories_bar") + ":"; cmbMenuStyle.Items[0] = Lang.Get("options_style_standard"); cmbMenuStyle.Items[1] = Lang.Get("options_style_flat"); cmbToolbarStyle.Items[0] = Lang.Get("options_style_standard"); cmbToolbarStyle.Items[1] = Lang.Get("options_style_flat"); cmbCategoriesStyle.Items[0] = Lang.Get("options_style_standard"); cmbCategoriesStyle.Items[1] = Lang.Get("options_style_flat"); boxLanguage.Text = Lang.Get("options_language"); lblCurrency.Text = Lang.Get("options_currency") + ":"; // Setup language for backup tabBackup.Text = Lang.Get("options_backups"); cmdBackupDirectory.Text = Lang.Get("options_backup_dir"); lblBackupTip.Text = Lang.Get("options_backup_tip"); boxAutomaticBackup.Text = Lang.Get("options_automatic_backup"); chkAutomaticBackup.Text = Lang.Get("options_automatic_backup_text"); // Setup language for minimize to tray boxBehaviour.Text = Lang.Get("options_behaviour"); lblClosing.Text = Lang.Get("options_closing") + ":"; optClosingMinimize.Text = Lang.Get("minimize_to_tray"); optClosingClose.Text = Lang.Get("close_program"); // Fill in fields for the GUI cmbMenuStyle.SelectedIndex = (Settings.Get("style_menu").ToString() == "0" ? 0 : 1); cmbToolbarStyle.SelectedIndex = (Settings.Get("style_toolbar").ToString() == "0" ? 0 : 1); cmbCategoriesStyle.SelectedIndex = (Settings.Get("style_categories").ToString() == "0" ? 0 : 1); cmbCurrency.SelectedIndex = 0; if (Settings.Get("currency").ToString() == "€" ) cmbCurrency.SelectedIndex = 0; if (Settings.Get("currency").ToString() == "$" ) cmbCurrency.SelectedIndex = 1; if (Settings.Get("currency").ToString() == "£" ) cmbCurrency.SelectedIndex = 2; if (Settings.Get("currency").ToString() == "¥" ) cmbCurrency.SelectedIndex = 3; if (Settings.Get("currency").ToString() == "R$") cmbCurrency.SelectedIndex = 4; if (Settings.Get("currency").ToString() == "฿" ) cmbCurrency.SelectedIndex = 5; // Fill in languages combo cmbLanguage.Items.Clear(); foreach (Languages.AvailableLanguage l in Languages.AvailableLanguage.GetAll()) { cmbLanguage.Items.Add(l); if (Settings.Get("lang").ToString() == l.Code) cmbLanguage.SelectedItem = l; } // Fill in minimize radio if (Settings.Get("window_minimize_when_closing").ToString() == "0") optClosingClose.Checked = true; else optClosingMinimize.Checked = true; // Fill in fields for the backup chkAutomaticBackup.Checked = (Settings.Get("backup_automatic").ToString() == "1"); try { long sum = 0; DirectoryInfo backup_dir = new DirectoryInfo(MainForm.BackupDirectory); if (!backup_dir.Exists) backup_dir.Create(); FileInfo[] files = backup_dir.GetFiles("*.sqlite"); foreach (FileInfo file in files) sum += file.Length; lblBackupSize.Text = ((float)sum / (1024F * 1024F)).ToString("0.00").Replace(',', '.') + " MB"; } catch { lblBackupSize.Text = "? MB"; } }
/// <summary> /// Edit a Task object showing a specific section. /// </summary> /// <param name="task">Task to edit</param> /// <param name="start_tab">The forst section to show</param> public TaskForm(Languages.Language language, Utils.AppSettings settings, Task task, StartingTab start_tab) { // Windows Forms designer support. InitializeComponent(); // Setup task this.task = task; // Form icon System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TaskForm)); Icon = (task.Id == 0) ? ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))) : ((System.Drawing.Icon)(resources.GetObject("$this.Icon2"))); // Language Lang = language; Text = Lang.Get((task.Id == 0) ? "task_add" : "task_edit"); btnOk.Text = " " + Lang.Get((task.Id == 0) ? "add" : "edit"); btnCancel.Text = Lang.Get("cancel"); ApplyLanguage(); // Settings Settings = settings; lblCurrency.Text = Settings.Get("currency").ToString(); // Starting tab switch (start_tab) { case StartingTab.DatesTime: tabs.SelectedTab = tabDatesTime; break; case StartingTab.Payment: tabs.SelectedTab = tabPayment; break; case StartingTab.Notes: tabs.SelectedTab = tabNotes; break; } // Populate combos PopulateColourCombo(); PopulatePriorityCombo(); PopulatePaymentCombo(); if (task.IsRoot()) { PopulateCategoryCombo(task.CategoryId); // Category combo also for root tasks } // Fill in GUI fields (general) txtName.Text = task.Name; try { txtDescription.Text = task.Description; } catch { txtDescription.Text = ""; } foreach (ImageComboItem item in cmbColour.Items) { if (item.Text == Lang.Get("colour_as") + " " + task.Name) { cmbColour.SelectedItem = item; } } cmbPriority.SelectedIndex = task.Priority % 3; // Fill in GUI fields (dates and time) dtCreationDate.Value = task.CreationDate; try { dtDueDate.Value = task.DueDate; chkDueDateNot.Checked = false; } catch { chkDueDateNot.Checked = true; } try { dtCompleted.Value = task.Completed; chkCompletedNot.Checked = false; } catch { chkCompletedNot.Checked = true; } try { int t = task.Timer; chkUseTimer.Checked = true; } catch { chkUseTimer.Checked = false; } try { numTimerS.Value = task.Timer % 60; numTimerM.Value = ((task.Timer - numTimerS.Value) / 60) % 60; numTimerH.Value = (task.Timer - numTimerS.Value - numTimerM.Value * 60) / (60 * 60); } catch { } // If the timer is running, disable timer fields. if (task.IsTimerRunning()) { chkUseTimer.Enabled = false; lblTimer.Visible = btnTimerReset.Visible = btnSumTimers.Visible = false; numTimerS.Visible = numTimerM.Visible = numTimerH.Visible = false; lblTimerS.Visible = lblTimerM.Visible = lblTimerH.Visible = false; panCannotEditTimer.Visible = true; lblCannotEditTimer.Text = Lang.Get("task_timer_is_running"); } // Fill in GUI fields (payment) try { chkPerHour.Checked = task.PricingByHour; if (task.PricingByHour) { numPrice.Value = (Decimal)task.PriceByHour; } else { numPrice.Value = (Decimal)task.Price; } chkPriceNot.Checked = false; } catch { chkPriceNot.Checked = true; } try { dtPaid.Value = task.Paid; chkPaidNot.Checked = false; } catch { chkPaidNot.Checked = true; } try { cmbPaymentType.Text = task.Payment; } catch { } try { txtPaymentNote.Text = task.PaymentNote; } catch { txtPaymentNote.Text = ""; } chkPerHour.Enabled = !chkPriceNot.Checked; // Show/hide task parent if (task.ParentId != 0) { cmbCategory.Hide(); } lblCategory.Visible = btnAddCategory.Visible = (task.ParentId == 0); btnAddCategory.Enabled = (task.ParentId == 0); lblSubTaskOf.Visible = panParent.Visible = (task.ParentId != 0); // Setup task parent if (!task.IsRoot()) { try { Task parent = new Task(task.ParentId); lblParentName.Text = parent.Name; boxParentIcon.Image = IconColoured.GetSquared(parent.Colour); task.CategoryId = parent.CategoryId; // Same category of the parent! if (task.Id == 0) { foreach (ImageComboItem item in cmbColour.Items) { if (item.Text == Lang.Get("colour_as") + " " + parent.Name) { cmbColour.SelectedItem = item; } } } } catch { lblParentName.Text = Lang.Get("task_loading_error"); boxParentIcon.Image = IconColoured.GetSquared(Color.Gray); } } // Notes settings (this is not so good, calling MainForm in this way...) try { notes_monospace_font = new FontFamily("Consolas"); } catch { } chkMonospace.Checked = (Todomoo.mainForm.Settings.Get("note_monospace").ToString() == "1"); chkWordWrap.Checked = (Todomoo.mainForm.Settings.Get("note_word_wrap").ToString() == "1"); // Draw note accordion DrawNotesAccordion(); // Form size and "sizeability" TabsSelectedIndexChanged(); TaskFormResize(); }
/// <summary> /// Edit a Task object. /// </summary> /// <param name="task">Task to edit</param> public TaskForm(Languages.Language language, Utils.AppSettings settings, Task task) : this(language, settings, task, StartingTab.General) { }