Esempio n. 1
0
        public bool Options(ref Config cnfg)
        {
            if (string.IsNullOrEmpty(cnfg.Program))
            {
                FileInfo git = new FileInfo(ProgramFilesx86() + @"\Git\cmd\git.exe");
                tProgram.Text = git.Exists ? git.FullName : "";
            }
            else tProgram.Text = cnfg.Program;
            tArguments.Text = string.IsNullOrEmpty(cnfg.Arguments) ? "diff" : cnfg.Arguments;
            numSecs.Value = cnfg.Update > 0 ? cnfg.Update : 2;
            tFont.Text = string.IsNullOrEmpty(cnfg.Font) ? "70% serif" : cnfg.Font;
            tWorkDir.Text = string.IsNullOrEmpty(cnfg.WorkDir) ? "" : cnfg.WorkDir;

            if (base.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                cnfg.Program = tProgram.Text.Trim();
                cnfg.Arguments = tArguments.Text.Trim();
                cnfg.Update = (uint)numSecs.Value;
                cnfg.Font = tFont.Text.Trim();
                cnfg.WorkDir = tWorkDir.Text.Trim();

                if (!File.Exists(cnfg.Program))
                {
                    MessageBox.Show(Resources.FormOptions_Options_Program_not_exists, Resources.Error);
                    return Options(ref cnfg);
                }

                if (string.IsNullOrEmpty(cnfg.WorkDir) && Directory.Exists(cnfg.WorkDir))
                {
                    MessageBox.Show(Resources.FormOptions_Options_WorkDir_not_exists, Resources.Error);
                    return Options(ref cnfg);
                }
                return true;
            }
            return false;
        }
Esempio n. 2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            try
            {
                using (Stream stfile = File.OpenRead(CnfgName))
                {
                    XmlSerializer xmlconfig = new XmlSerializer(typeof(Config));
                    Cnfg = (Config)xmlconfig.Deserialize(stfile);

                    int posX = Cnfg.posX;
                    int posY = Cnfg.posY;
                    int sHeight = Cnfg.Height;
                    int sWidth = Cnfg.Width;

                    if (sHeight < 200) sHeight = this.MinimumSize.Height;
                    if (sWidth < 200) sWidth = this.MinimumSize.Width;

                    this.Location = new Point(posX, posY);
                    this.Size = new Size(sWidth, sHeight);
                }
            }
            catch
            {
                bOptions_Click(null, null);
            }

            bwDiff.RunWorkerAsync(Cnfg);
        }