コード例 #1
0
        public MainForm()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.StartPosition   = FormStartPosition.CenterScreen;
            //this.StartPosition = FormStartPosition.Manual;
            //this.Location = new Point(150, GlobalFunc.h / 2 - 330);
            this.ControlBox   = false;
            this.FormClosing += Form1_Closing;

            versionLabel.Text = Application.ProductVersion;

            myBGWorker.DoWork               += myBGWorker_DoWork;
            myBGWorker.ProgressChanged      += myBGWorker_ProgressChanged;
            myBGWorker.RunWorkerCompleted   += myBGWorker_RunWorkerCompleted;
            myBGWorker.WorkerReportsProgress = true;

            skipBGWorker.DoWork             += skipBGWorker_DoWork;
            skipBGWorker.RunWorkerCompleted += skipBGWorker_RunWorkerCompleted;

            GlobalFunc.mainFormHeight = GlobalFunc.h / 2 - 330;
            scsBtn.Enabled            = false;
            //quitBtn.Enabled = false;
            GlobalFunc.LoadProfile();
            GlobalFunc.LoadProfileDetail();
            SetProfile();
        }
コード例 #2
0
 private void addBtn_Click(object sender, EventArgs e)
 {
     SaveCurrent();
     GlobalFunc.LoadProfile();
     GlobalFunc.mainForm.SetProfile();
     profileCB.SelectedIndex = profileCB.FindString(profileCB.Text);
 }
コード例 #3
0
        private void removeBtn_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Confirm Delete?", "Delete Sequence", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (!string.IsNullOrEmpty(profileCB.Text) && profileCB.Text != "")
                {
                    string operationName = profileCB.Text;
                    try
                    {
                        if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"ProfileDetail\" + operationName + ".json"))
                        {
                            File.Delete(AppDomain.CurrentDomain.BaseDirectory + @"CountingSequence\" + operationName + ".json");
                        }
                    }
                    catch (Exception ex)
                    { }

                    try
                    {
                        for (int i = 0; i < GlobalFunc.profile.operationName.Count; i++)
                        {
                            if (operationName == GlobalFunc.profile.operationName[i])
                            {
                                GlobalFunc.profile.operationName.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    { }

                    string json = js.Serialize(GlobalFunc.profile);
                    File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "profile.json", json);

                    ShowMessage("Remove Profile successful");
                    profileCB.Text           = "";
                    GlobalFunc.toggleProfile = "";
                    GlobalFunc.LoadProfile();
                    SetProfile();

                    GlobalFunc.mainForm.SetProfile();
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                //do something else
            }
        }
コード例 #4
0
        private void SaveProfile()
        {
            bool existed = false;

            for (int i = 0; i < GlobalFunc.profile.operationName.Count; i++)
            {
                if (profileCB.Text == GlobalFunc.profile.operationName[i])
                {
                    existed = true;
                    break;
                }
            }

            if (!existed)
            {
                GlobalFunc.profile.operationName.Add(profileCB.Text);
                string json = js.Serialize(GlobalFunc.profile);
                File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "profile.json", json);
                ShowMessage("Add operation successful");
                GlobalFunc.toggleProfile       = "";
                GlobalFunc.toggleProfileDetail = null;

                GlobalFunc.LoadProfile();         //reload profile.json
                GlobalFunc.mainForm.SetProfile(); //set the profile list to main combo
                this.SetProfile();                //set the profile list to measurement combo
            }
            else
            {
                if (GlobalFunc.toggleProfile != profileCB.Text)
                {
                    ShowMessage("The opertaion name existed");
                }
            }


            //reload
        }