Beispiel #1
0
        private void btnOption_Click(object sender, EventArgs e)
        {
            HashIni ini = Profile.ReadAll(IniFile);

            LoadOptionData(ini);
            option.ShowDialog();
        }
Beispiel #2
0
        bool ShowSettingDialog()
        {
            using (var form = new FormNewInput())
            {
                form.MinCpuUsage = _minCPUUsage ?? 0;
                form.MaxCpuUsage = _maxCPUUsage ?? 100;
                form.Duration    = _checkDuration ?? 0;
                form.IsAverage   = _isAverage;

                if (DialogResult.OK != form.ShowDialog())
                {
                    return(false);
                }

                _minCPUUsage   = form.MinCpuUsage;
                _maxCPUUsage   = form.MaxCpuUsage;
                _checkDuration = form.Duration;
                _isAverage     = form.IsAverage;

                HashIni ini = Profile.ReadAll(IniPath);
                Profile.WriteInt(SECTION_OPTION, KEY_CHECKDURATION, form.Duration, ini);
                Profile.WriteFloat(SECTION_OPTION, KEY_MIN_CPUUSAGE, form.MinCpuUsage, ini);
                Profile.WriteFloat(SECTION_OPTION, KEY_MAX_CPUUSAGE, form.MaxCpuUsage, ini);
                Profile.WriteBool(SECTION_OPTION, KEY_IS_AVERAGE, form.IsAverage, ini);

                if (!Profile.WriteAll(ini, IniPath))
                {
                    MessageBox.Show("failed to save ini");
                }
            }
            UpdateData();
            return(true);
        }
Beispiel #3
0
        public FormMain()
        {
            InitializeComponent();

            HashIni ini = Profile.ReadAll(IniFile);

            bool bval;

            Profile.GetBool(SECTION_OPTION, KEY_LOCATIONSAVED, false, out bval, ini);
            if (bval)
            {
                int x, y, width, height;
                Profile.GetInt(SECTION_OPTION, KEY_X, this.Location.X, out x, ini);
                Profile.GetInt(SECTION_OPTION, KEY_Y, this.Location.Y, out y, ini);

                Profile.GetInt(SECTION_OPTION, KEY_Width, this.Size.Width, out width, ini);
                Profile.GetInt(SECTION_OPTION, KEY_Height, this.Size.Height, out height, ini);

                LoadOptionData(ini);

                if (AmbLib.IsRectAppearInScreen(new Rectangle(x, y, width, height)))
                {
                    this.StartPosition = FormStartPosition.Manual;
                    this.Location      = new Point(x, y);
                    this.Size          = new Size(width, height);
                }
            }
        }
Beispiel #4
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            bool success = true;

            HashIni ini = Profile.ReadAll(IniPath);

            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_SINGLECLICK, chkShowSingleClick.Checked, ini);
            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_DOUBLECLICK, chkShowDoubleClick.Checked, ini);
            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_UP, chkShowUp.Checked, ini);
            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_DOWN, chkShowDown.Checked, ini);
            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_WHEEL, chkShowWheel.Checked, ini);
            success &= Profile.WriteBool(SECTION_OPTION, KEY_CHECK_MOVE, chkShowMove.Checked, ini);

            success &= AmbLib.SaveFormXYWH(this, SECTION_LOCATION, ini);

            success &= Profile.WriteInt(SECTION_OPTION, KEY_SPLITTER_DISTANCE, splitMain.SplitterDistance, ini);

            if (success)
            {
                try
                {
                    success &= Profile.WriteAll(ini, IniPath, true);
                }
                catch (Exception)
                {
                    success = false;
                }
            }

            if (!success)
            {
                CppUtils.Alert(Properties.Resources.SAVE_FAILED);
            }
        }
Beispiel #5
0
        void LoadOptionData(HashIni ini)
        {
            bool bval;

            Profile.GetBool(SECTION_OPTION, KEY_CLOSEAFTERRENAMING, false, out bval, ini);
            option.IsCloseAfterRenaming = bval;
            Profile.GetBool(SECTION_OPTION, KEY_SKIPWARNING, false, out bval, ini);
            option.IsSkipWarning = bval;
            option.ClearDirty();
        }
Beispiel #6
0
        public FormMain()
        {
            InitializeComponent();

            tlpInfo.Margin  = new Padding(0);
            tlpInfo.Padding = new Padding(0);

            HashIni ini = Profile.ReadAll(IniFile);
            int     x, y;

            Ambiesoft.Profile.GetInt(SECTION_SETTING, "X", 60, out x, ini);
            Ambiesoft.Profile.GetInt(SECTION_SETTING, "Y", 60, out y, ini);

            bool isin = false;

            foreach (Screen s in Screen.AllScreens)
            {
                Point pos = new Point(x, y);
                if (s.WorkingArea.Contains(pos))
                {
                    isin = true;
                    break;
                }
            }

            if (isin)
            {
                StartPosition = FormStartPosition.Manual;
                this.Location = new Point(x, y);

                int width, height;
                Profile.GetInt(SECTION_SETTING, "Width", -1, out width, ini);
                Profile.GetInt(SECTION_SETTING, "Height", -1, out height, ini);
                if (width > 0 && height > 0)
                {
                    this.Size = new Size(width, height);
                }
            }


            int  intval;
            bool boolval;

            if (Ambiesoft.Profile.GetInt(SECTION_SETTING, "AutoRun", 0, out intval, ini))
            {
                chkAutoRun.Checked = intval != 0;
            }

            Ambiesoft.Profile.GetBool(SECTION_SETTING, KEY_TOPMOST, false, out boolval, ini);
            this.TopMost = alwaysOnTopToolStripMenuItem.Checked = boolval;


            Profile.GetBool(SECTION_SETTING, KEY_SMARTDOUBLECLICKSELECTION, true, out boolval, ini);
            tsmiSmartDoubleClickSelection.Checked = boolval;
        }
Beispiel #7
0
        bool LoadAfterFinish()
        {
            HashIni ini = Profile.ReadAll(IniPath);

            if (!afterFinisiDlg_.LoadValues("AfterFinish", ini))
            {
                MessageBox.Show("error");
                return(false);
            }
            return(true);
        }
Beispiel #8
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            this.BeginInvoke(new EventHandler(OnAfterLoad));

            HashIni ini = Profile.ReadAll(IniPath);

            afterFinishDialog_.LoadValues("AfterFinish", ini);
            txtNotification.Text = afterFinishDialog_.ToDescription();
            FormMain_Resize(this, null);
            lblTopLeft.Visible     = false;
            lblBottomRight.Visible = false;
        }
Beispiel #9
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            string  iniPath = IniPath;
            HashIni ini     = Profile.ReadAll(iniPath);

            AmbLib.SaveFormXYWH(this, SECTION_LOCATION, ini);

            if (!Profile.WriteAll(ini, iniPath))
            {
                MessageBox.Show("ini save failed");
            }
        }
Beispiel #10
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            HashIni ini = Profile.ReadAll(IniPath);

            AmbLib.SaveFormXYWH(this, SECTION_LOCATION, ini);
            AmbLib.SaveListViewColumnWidth(listMain, SECTION_OPTION, KEY_COLUMN_WIDTH, ini);
            AmbLib.SaveComboBox(cmbApplication, SECTION_APP_COMBO, MAX_COMBO_SAVE, ini);
            AmbLib.SaveComboBox(cmbArguments, SECTION_ARG_COMBO, MAX_COMBO_SAVE, ini);
            if (!Profile.WriteAll(ini, IniPath))
            {
                CppUtils.Alert("Failed to save ini");
            }
        }
Beispiel #11
0
 void LaunchApp()
 {
     try
     {
         HashIni ini = Profile.ReadAll(IniPath);
         afterFinishDialog_.LoadValues("AfterFinish", ini);
         afterFinishDialog_.DoNotify();
     }
     catch (Exception ex)
     {
         FatalExit(ex.Message);
     }
 }
Beispiel #12
0
        public FormPrint()
        {
            InitializeComponent();

            HashIni ini = Profile.ReadAll(IniFile);
            int     intval;

            if (Profile.GetInt(SECTION_OPTION, KEY_WAIT_COUNT, -1, out intval, ini) && intval > 0)
            {
                udWait.Value = intval;
            }
            this.Size = new Size(this.Size.Width, (int)(this.Size.Height * 1.5));
            Program.commonwb(wbPrint);
            wbPrint.StatusTextChanged += new EventHandler(wbPrint_StatusTextChanged);
        }
Beispiel #13
0
        bool SaveAfterFinish()
        {
            HashIni ini = Profile.ReadAll(IniPath);

            if (!afterFinisiDlg_.SaveValues("AfterFinish", ini))
            {
                MessageBox.Show("error");
                return(false);
            }
            if (!Profile.WriteAll(ini, IniPath))
            {
                MessageBox.Show("error");
                return(false);
            }
            return(true);
        }
Beispiel #14
0
        private void btnEditNotification_Click(object sender, EventArgs e)
        {
            HashIni ini = Profile.ReadAll(IniPath);

            afterFinishDialog_.LoadValues("AfterFinish", ini);
            if (DialogResult.OK != afterFinishDialog_.ShowDialog())
            {
                return;
            }
            txtNotification.Text = afterFinishDialog_.ToDescription();
            afterFinishDialog_.SaveValues("AfterFinish", ini);
            if (!Profile.WriteAll(ini, IniPath))
            {
                CppUtils.Alert("Failed to save ini");
            }
        }
Beispiel #15
0
        public bool SaveValues(string section, HashIni ini)
        {
            bool ok = true;

            ok &= Profile.WriteBool(section, KEY_chkPlaySound, chkPlaySound.Checked, ini);
            ok &= Profile.WriteString(section, KEY_txtWav, txtWav.Text, ini);
            ok &= Profile.WriteInt(section, KEY_udRepeatCount, Decimal.ToInt32(udRepeatCount.Value), ini);

            ok &= Profile.WriteBool(section, KEY_chkOpenFolder, chkOpenFolder.Checked, ini);
            ok &= Profile.WriteBool(section, KEY_chkShutdown, chkShutdown.Checked, ini);

            ok &= Profile.WriteBool(section, KEY_chkLaunchApp, chkLaunchApp.Checked, ini);
            ok &= Profile.WriteString(section, KEY_txtApp, txtApp.Text, ini);
            ok &= Profile.WriteString(section, KEY_txtArg, txtArg.Text, ini);

            return(ok);
        }
Beispiel #16
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            HashIni ini = Profile.ReadAll(IniFile);

            Profile.WriteInt(SECTION_SETTING, "X", Location.X, ini);
            Profile.WriteInt(SECTION_SETTING, "Y", Location.Y, ini);
            Profile.WriteInt(SECTION_SETTING, "Width", Size.Width, ini);
            Profile.WriteInt(SECTION_SETTING, "Height", Size.Height, ini);

            Profile.WriteBool(SECTION_SETTING, KEY_SMARTDOUBLECLICKSELECTION,
                              tsmiSmartDoubleClickSelection.Checked, ini);

            if (!Profile.WriteAll(ini, IniFile))
            {
                CppUtils.Alert("failed saving ini.");
            }
        }
Beispiel #17
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            bool failed = false;

            HashIni ini = Profile.ReadAll(IniPath);

            failed |= !Ambiesoft.Profile.WriteString("option", "ffmpeg", ffmpeg_, ini);
            failed |= !AmbLib.SaveListViewColumnWidth(lvMain, SECTION_OPTION, KEY_COLUMN_WIDTH, ini);
            failed |= !AmbLib.SaveFormXYWH(this, SECTION_OPTION, ini);
            failed |= !Profile.WriteAll(ini, IniPath);
            if (failed)
            {
                CppUtils.CenteredMessageBox(this,
                                            Properties.Resources.S_INISAVE_FAILED,
                                            Application.ProductName,
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
            }
        }
Beispiel #18
0
        public bool LoadValues(string section, HashIni ini)
        {
            bool   b;
            int    i;
            string s;

            if (Profile.GetBool(section, KEY_chkPlaySound, false, out b, ini))
            {
                chkPlaySound.Checked = b;
            }
            if (Profile.GetString(section, KEY_txtWav, string.Empty, out s, ini))
            {
                txtWav.Text = s;
            }
            if (Profile.GetInt(section, KEY_udRepeatCount, 1, out i, ini))
            {
                udRepeatCount.Value = i;
            }

            if (Profile.GetBool(section, KEY_chkOpenFolder, false, out b, ini))
            {
                chkOpenFolder.Checked = b;
            }
            if (Profile.GetBool(section, KEY_chkShutdown, false, out b, ini))
            {
                chkShutdown.Checked = b;
            }
            if (Profile.GetBool(section, KEY_chkLaunchApp, false, out b, ini))
            {
                chkLaunchApp.Checked = b;
            }

            if (Profile.GetString(section, KEY_txtApp, string.Empty, out s, ini))
            {
                txtApp.Text = s;
            }
            if (Profile.GetString(section, KEY_txtArg, string.Empty, out s, ini))
            {
                txtArg.Text = s;
            }

            return(true);
        }
Beispiel #19
0
        public FormMain(List <string> inputVideos)
        {
            inputVideos_ = inputVideos;

            InitializeComponent();

            HashIni ini = Profile.ReadAll(IniPath);

            AmbLib.LoadFormXYWH(this, SECTION_OPTION, ini);

            ColumnHeader ch = null;

            ch       = new ColumnHeader();
            ch.Name  = COLUMN_FILE;
            ch.Text  = Properties.Resources.COLUMN_FILE;
            ch.Width = 100;
            lvMain.Columns.Add(ch);

            ch       = new ColumnHeader();
            ch.Name  = COLUMN_DATE;
            ch.Text  = Properties.Resources.COLUMN_DATE;
            ch.Width = 100;
            lvMain.Columns.Add(ch);

            ch       = new ColumnHeader();
            ch.Name  = COLUMN_EXTENTION;
            ch.Text  = Properties.Resources.COLUMN_EXTENTION;
            ch.Width = 100;
            lvMain.Columns.Add(ch);

            ch       = new ColumnHeader();
            ch.Name  = COLUMN_DURATION;
            ch.Text  = Properties.Resources.COLUMN_DURATION;
            ch.Width = 100;
            lvMain.Columns.Add(ch);



            Profile.GetString("option", "ffmpeg", "", out ffmpeg_, ini);
            AmbLib.LoadListViewColumnWidth(lvMain, SECTION_OPTION, KEY_COLUMN_WIDTH, ini);
        }
Beispiel #20
0
        private void FormPrint_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult.Yes != CppUtils.CenteredMessageBox(this,
                                                                Properties.Resources.AreYouSureToQuit,
                                                                Application.ProductName,
                                                                MessageBoxButtons.YesNo,
                                                                MessageBoxIcon.Question,
                                                                MessageBoxDefaultButton.Button2))
            {
                e.Cancel = true;
                return;
            }

            HashIni ini = Profile.ReadAll(IniFile);

            Profile.WriteInt(SECTION_OPTION, KEY_WAIT_COUNT, decimal.ToInt32(udWait.Value), ini);
            if (!Profile.WriteAll(ini, IniFile))
            {
                CppUtils.Alert(Properties.Resources.FAILED_TO_SAVE_INI);
            }
            Environment.Exit(0);
        }
Beispiel #21
0
        public FormMain()
        {
            InitializeComponent();

            this.panelClick.MouseWheel += panelClick_MouseWheel;
            // Load from ini file
            bool bval;

            try
            {
                ini_ = Profile.ReadAll(IniPath, true);

                Profile.GetBool(SECTION_OPTION, KEY_CHECK_SINGLECLICK, true, out bval, ini_);
                chkShowSingleClick.Checked = bval;
                Profile.GetBool(SECTION_OPTION, KEY_CHECK_DOUBLECLICK, false, out bval, ini_);
                chkShowDoubleClick.Checked = bval;
                Profile.GetBool(SECTION_OPTION, KEY_CHECK_UP, false, out bval, ini_);
                chkShowUp.Checked = bval;
                Profile.GetBool(SECTION_OPTION, KEY_CHECK_DOWN, true, out bval, ini_);
                chkShowDown.Checked = bval;
                Profile.GetBool(SECTION_OPTION, KEY_CHECK_WHEEL, true, out bval, ini_);
                chkShowWheel.Checked = bval;
                Profile.GetBool(SECTION_OPTION, KEY_CHECK_MOVE, true, out bval, ini_);
                chkShowMove.Checked = bval;

                AmbLib.LoadFormXYWH(this, SECTION_LOCATION, ini_);
            }
            catch (FileNotFoundException)
            {
            }
            catch (Exception ex)
            {
                CppUtils.Alert(ex);
                Environment.Exit(1);
            }

            // Set Title
            this.Text = Application.ProductName;
        }
Beispiel #22
0
        public FormMain(string[] args)
        {
            args_ = args;

            InitializeComponent();

            lblCombo1TopLeft.Visible     = false;
            lblCombo1BottomRight.Visible = false;
            lblCombo2TopLeft.Visible     = false;
            lblCombo2BottomRight.Visible = false;

            // LoadFromIni
            HashIni ini = Profile.ReadAll(IniPath);

            AmbLib.LoadFormXYWH(this, SECTION_LOCATION, ini);
            AmbLib.LoadListViewColumnWidth(listMain, SECTION_OPTION, KEY_COLUMN_WIDTH, ini);
            AmbLib.LoadComboBox(cmbApplication, SECTION_APP_COMBO, MAX_COMBO_SAVE, ini);
            AmbLib.LoadComboBox(cmbArguments, SECTION_ARG_COMBO, MAX_COMBO_SAVE, ini);


            OptionSet p = new OptionSet()
                          .Add("v|version", dummy => { ShowHelp(); Environment.Exit(0); })
                          .Add("?|h|help", dummy => { ShowHelp(); Environment.Exit(0); })
                          .Add("@=", reportFile => { ImportFromReport(reportFile); })
                          .Add("dir=", dir => { ImportDirectory(dir); })
            ;


            // Parse CommandLine
            List <string> defaultArgs = p.Parse(args);

            foreach (string file in defaultArgs)
            {
                AddToList(file);
            }

            UpdateTitle();
        }
Beispiel #23
0
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.WindowState == FormWindowState.Normal)
            {
                HashIni ini = Profile.ReadAll(IniFile);

                Profile.WriteInt(SECTION_OPTION, KEY_X, this.Location.X, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_Y, this.Location.Y, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_Width, this.Size.Width, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_Height, this.Size.Height, ini);
                Profile.WriteBool(SECTION_OPTION, KEY_LOCATIONSAVED, true, ini);

                if (option.Dirty)
                {
                    Profile.WriteBool(SECTION_OPTION, KEY_CLOSEAFTERRENAMING, option.IsCloseAfterRenaming, ini);
                    Profile.WriteBool(SECTION_OPTION, KEY_SKIPWARNING, option.IsSkipWarning, ini);
                }
                if (!Profile.WriteAll(ini, IniFile))
                {
                    Ambiesoft.CppUtils.Alert(this, Properties.Resources.FAILED_TO_SAVE_INIFILE);
                }
            }
        }
Beispiel #24
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            HashIni ini = Profile.ReadAll(Program.IniFile);

            if (WindowState == FormWindowState.Normal)
            {
                Profile.WriteInt(SECTION_OPTION, KEY_X, Location.X, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_Y, Location.Y, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_WIDTH, this.Size.Width, ini);
                Profile.WriteInt(SECTION_OPTION, KEY_HEIGHT, this.Size.Height, ini);
            }

            AmbLib.SaveListViewColumnWidth(lvMain, SECTION_OPTION, KEY_COLUMN, ini);


            Profile.WriteInt(SECTION_OPTION, KEY_LISTVIEWCOLOR1, option_.btnLVColor1.BackColor.ToArgb(), ini);
            Profile.WriteInt(SECTION_OPTION, KEY_LISTVIEWCOLOR2, option_.btnLVColor2.BackColor.ToArgb(), ini);

            if (!Profile.WriteAll(ini, Program.IniFile))
            {
                Alert(Properties.Resources.FAILED_TO_SAVE_SETTING);
            }
        }
Beispiel #25
0
        public FormMain()
        {
            InitializeComponent();

            HashIni ini = Profile.ReadAll(Program.IniFile);


            int x = 0, y = 0;
            int width = 0, height = 0;

            if (Profile.GetInt(SECTION_OPTION, KEY_X, 0, out x, ini) &&
                Profile.GetInt(SECTION_OPTION, KEY_Y, 0, out y, ini) &&
                Profile.GetInt(SECTION_OPTION, KEY_WIDTH, 0, out width, ini) &&
                Profile.GetInt(SECTION_OPTION, KEY_HEIGHT, 0, out height, ini))
            {
                Point pt   = new Point(x, y);
                Size  size = new Size(width, height);

                Rectangle r = new Rectangle(pt, size);
                if (AmbLib.IsRectInScreen(r))
                {
                    this.Location      = new Point(x, y);
                    this.Size          = new Size(width, height);
                    this.StartPosition = FormStartPosition.Manual;
                }
            }

            int intval = 0;

            if (Profile.GetInt(SECTION_OPTION, KEY_LISTVIEWCOLOR1, Color.White.ToArgb(), out intval, ini))
            {
                option_.btnLVColor1.BackColor = Color.FromArgb(intval);
            }
            if (Profile.GetInt(SECTION_OPTION, KEY_LISTVIEWCOLOR2, Color.White.ToArgb(), out intval, ini))
            {
                option_.btnLVColor2.BackColor = Color.FromArgb(intval);
            }

            Debug.Assert(lvMain.Columns.Count == 0);

            {
                ColumnHeader chName = new ColumnHeader();
                chName.Name  = COLUMN_NAME;
                chName.Text  = Properties.Resources.COLUMN_NAME;
                chName.Width = 50;
                chName.Tag   = new ColumnInfo(txtEditName);
                lvMain.Columns.Add(chName);
            }

            {
                ColumnHeader chPath = new ColumnHeader();
                chPath.Name  = COLUMN_PATH;
                chPath.Text  = Properties.Resources.COLUMN_PATH;
                chPath.Width = 50;
                chPath.Tag   = new ColumnInfo(cmbEditFile);
                lvMain.Columns.Add(chPath);
            }

            {
                ColumnHeader chArguments = new ColumnHeader();
                chArguments.Name  = COLUMN_ARGUMENTS;
                chArguments.Text  = Properties.Resources.COLUMN_ARGUMENTS;
                chArguments.Width = 50;
                chArguments.Tag   = new ColumnInfo(txtEditName);
                lvMain.Columns.Add(chArguments);
            }

            {
                ColumnHeader chWorkingDirectory = new ColumnHeader();
                chWorkingDirectory.Name  = COLUMN_WORKINGDIRECTORY;
                chWorkingDirectory.Text  = Properties.Resources.COLUMN_WORKINGDIRECTORY;
                chWorkingDirectory.Width = 50;
                chWorkingDirectory.Tag   = new ColumnInfo(cmbEditDirectory);
                lvMain.Columns.Add(chWorkingDirectory);
            }

            {
                ColumnHeader chIconPath = new ColumnHeader();
                chIconPath.Name  = COLUMN_ICONPATH;
                chIconPath.Text  = Properties.Resources.COLUMN_ICONPATH;
                chIconPath.Width = 50;
                chIconPath.Tag   = new ColumnInfo(cmbEditDirectory);
                lvMain.Columns.Add(chIconPath);
            }

            {
                ColumnHeader chIconIndex = new ColumnHeader();
                chIconIndex.Name  = COLUMN_ICONINDEX;
                chIconIndex.Text  = Properties.Resources.COLUMN_ICONINDEX;
                chIconIndex.Width = 50;
                chIconIndex.Tag   = new ColumnInfo(txtEditName);
                lvMain.Columns.Add(chIconIndex);
            }

            {
                ColumnHeader chRunAsAdmin = new ColumnHeader();
                chRunAsAdmin.Name  = COLUMN_RUNASADMIN;
                chRunAsAdmin.Text  = Properties.Resources.COLUMN_RUNASADMIN;
                chRunAsAdmin.Width = 10;
                chRunAsAdmin.Tag   = new ColumnInfo(cmbEditBool);
                lvMain.Columns.Add(chRunAsAdmin);
            }

            AmbLib.LoadListViewColumnWidth(lvMain, SECTION_OPTION, KEY_COLUMN, ini);

            // lvMain.SmallImageList = sysImageList_;

            lvMain.SubItemClicked    += lvMain_SubItemClicked;
            lvMain.SubItemEndEditing += lvMain_SubItemEndEditing;

            lvMain.DoubleClickActivation = true;

            lvMain.Font           = SystemFonts.IconTitleFont;
            txtEditName.Font      = SystemFonts.IconTitleFont;
            cmbEditDirectory.Font = SystemFonts.IconTitleFont;
        }
Beispiel #26
0
        public FormMain(string[] args)
        {
            InitializeComponent();

            this.Text = Application.ProductName;

            // read ini
            HashIni ini = Profile.ReadAll(IniPath);

            AmbLib.LoadFormXYWH(this, SECTION_LOCATION, ini);

            int intval;

            if (Profile.GetInt(SECTION_OPTION, KEY_CHECKDURATION, 0, out intval, ini))
            {
                _checkDuration = intval;
            }
            float fval;

            if (Profile.GetFloat(SECTION_OPTION, KEY_MIN_CPUUSAGE, 0, out fval, ini))
            {
                _minCPUUsage = fval;
            }
            if (Profile.GetFloat(SECTION_OPTION, KEY_MAX_CPUUSAGE, 0, out fval, ini))
            {
                _maxCPUUsage = fval;
            }

            bool bval;

            if (Profile.GetBool(SECTION_OPTION, KEY_IS_AVERAGE, false, out bval, ini))
            {
                _isAverage = bval;
            }

            try
            {
                bool start = false;
                var  p     = new OptionSet();
                p.Add("v|version", "Show Version", dummy =>
                {
                    MessageBox.Show("ver");
                    Environment.Exit(0);
                });
                p.Add("max=", "Max cpu usage", max =>
                {
                    _maxCPUUsage = float.Parse(max);
                });
                p.Add("min=", "Min cpu usage", max =>
                {
                    _minCPUUsage = float.Parse(max);
                });
                p.Add("d=|duration=", "Duration of checking", duration =>
                {
                    _checkDuration = int.Parse(duration);
                });
                p.Add("a|average", "Use average", dummy =>
                {
                    _isAverage = true;
                });
                p.Add("h|H|help|?", "Show Help", dummy =>
                {
                    var stream = new MemoryStream();
                    var to     = new StreamWriter(stream);
                    p.WriteOptionDescriptions(to);
                    to.Flush();
                    stream.Position = 0;
                    var reader      = new StreamReader(stream);
                    string message  = reader.ReadToEnd();

                    MessageBox.Show(message,
                                    Application.ProductName + " v" + AmbLib.getAssemblyVersion(Assembly.GetExecutingAssembly(), 3),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    Environment.Exit(0);
                });
                p.Add("start", "Start without showing the dialog", dummy =>
                {
                    start = true;
                });

                List <string> mainArgs = p.Parse(args);
                _start = start;
                if (mainArgs.Count != 0)
                {
                    FatalExit("Uknown Option:" + string.Join(" ", mainArgs.ToArray()));
                }
            }
            catch (Exception ex)
            {
                FatalExit(ex.Message);
            }
        }