Exemplo n.º 1
0
 void ChkPerHourCheckedChanged(object sender, EventArgs e)
 {
     lblCurrency.Text   = Settings.Get("currency").ToString();
     task.PricingByHour = chkPerHour.Checked;
     if (task.PricingByHour)
     {
         lblCurrency.Text += "/h";
         try { numPrice.Value = (Decimal)task.PriceByHour; } catch { numPrice.Value = 0; }
     }
     else
     {
         try { numPrice.Value = (Decimal)task.Price; } catch { numPrice.Value = 0; }
     }
 }
Exemplo n.º 2
0
        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); };
        }
Exemplo n.º 3
0
        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); };
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get a string from current language file.
        /// </summary>
        /// <param name="key">Key of the string</param>
        /// <returns></returns>
        public string Get(string key)
        {
            string val = definitions.Get(key).ToString();

            if (val == "System.Object")
            {
                return("!ERR.LANG!");
            }
            return(val);
        }
Exemplo n.º 5
0
        // 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";
            }
        }
Exemplo n.º 6
0
        // 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();

            }
        }
Exemplo n.º 7
0
        // 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";
            }
        }
Exemplo n.º 8
0
        /// <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();
        }