private void btnNewScript_Click(object sender, RoutedEventArgs e)
        {
            Window parentWindow = Window.GetWindow(this);
            //
            NewScriptWindow window = new NewScriptWindow();

            window.Owner     = parentWindow;
            window.ScriptMgr = ScriptMgr;
            bool?r = window.ShowDialog();

            if (r.HasValue && r.Value)
            {
                string new_script = window.NewScript.Name;
                txtAI.Text = new_script;
                //src_npc.SetValue(NpcData.VAR_NPC_AI, setAI(new_script));
                //invokeScriptChanged(src_npc);
            }
        }
Exemple #2
0
        private void CommandBinding_New(object sender, ExecutedRoutedEventArgs e)
        {
            var window = new NewScriptWindow();

            window.ShowDialog();
        }
Exemple #3
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item     = sender as MenuItem;
            string   _iHeader = item.Header.ToString();

            switch (_iHeader)
            {
            //MenuItem_File
            case "New (Ctrl + N)": {
                var window = new NewScriptWindow();
                window.ShowDialog();
                break;
            }

            case "Open (Ctrl + O)": {
                var dlg = new OpenFileDialog();
                dlg.InitialDirectory = myGlobal.settingInfo.CasePath;
                dlg.Filter           = "Script test (*.csv)|*.csv";
                dlg.Title            = "Select script test case file";

                if (dlg.ShowDialog() == true)
                {
                    csvScriptTest.FromCsvFile(dlg.FileName, dlg.SafeFileName);

                    Properties.Settings.Default.ScriptPath = dlg.FileName;
                    Properties.Settings.Default.ScriptName = dlg.SafeFileName;
                    Properties.Settings.Default.Save();

                    MessageBox.Show("Success", "Open File", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                break;
            }

            case "Save (Ctrl + S)": {
                if (myGlobal.duts.Count == 0)
                {
                    return;
                }

                if (myGlobal.duts[0].Path == null)           //new test case
                {
                    var dlg = new SaveFileDialog();
                    dlg.InitialDirectory = myGlobal.settingInfo.CasePath;
                    dlg.FileName         = string.Format("Script_Test_{0}.csv", myGlobal.duts[0].Name);
                    dlg.Filter           = "*.csv|*.csv";
                    dlg.Title            = "Save script test to file";
                    if (dlg.ShowDialog() == true)
                    {
                        csvScriptTest.ToCsvFile(dlg.FileName);

                        Properties.Settings.Default.ScriptPath = dlg.FileName;
                        Properties.Settings.Default.ScriptName = dlg.SafeFileName;
                        Properties.Settings.Default.Save();

                        MessageBox.Show("Success", "Save File", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    csvScriptTest.ToCsvFile(myGlobal.duts[0].Path);
                    MessageBox.Show("Success", "Save File", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                break;
            }

            case "SaveAs": {
                MessageBox.Show(myParameter.dictRangeCapacitance.Count.ToString());
                break;
            }

            case "Exit (Ctrl + Shift + X)": {
                this.Close();
                break;
            }

            //MenuItem_View
            case "Reset Tree Icons": {
                ViewHelper.resetTreeIcon();
                break;
            }

            case "Clear Debug Windows": {
                ViewHelper.clearDebugWindow();
                break;
            }

            case "Clear Test Results": {
                ViewHelper.clearTestResult();
                break;
            }

            case "Clear Status Bar": {
                ViewHelper.clearStatusBar();
                break;
            }

            case "Show Status Bar": {
                break;
            }

            case "Reset All": {
                ViewHelper.clearAll();
                break;
            }

            //MenuItem_Tests
            case "Run Tree (F5)": {
                if (myGlobal.duts.Count == 0)
                {
                    break;
                }
                if (myGlobal.duts[0].Cases[0].Items.Count == 0)
                {
                    break;
                }

                Thread t = new Thread(new ThreadStart(() => {
                        Stopwatch st = new Stopwatch();
                        st.Start();

                        bool r = TestAllItems.getResult();

                        st.Stop();
                        string tt = (st.ElapsedMilliseconds / 1000).ToString();

                        MessageBox.Show("All item is tested. total time = " + tt + " sec", "Test Tree", MessageBoxButton.OK, MessageBoxImage.Information);
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }


            //MenuItem_Debug
            case "Multimeter device": {
                this.Opacity = 0.5;
                var window = new MultimeterWindow(myGlobal.multimeterInfo.DLLFile);
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            case "Switch card device": {
                this.Opacity = 0.5;
                var window = new SwitchCardWindow(myGlobal.switchcardInfo.DLLFile);
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            case "Power supply device": {
                this.Opacity = 0.5;
                var window = new PowerSupplyWindow(myGlobal.powersupplyInfo.DLLFile);
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            //MenuItem_Options
            case "Edit configurations": {
                this.Opacity = 0.5;
                var window = new EditConfigurationWindow();
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            //MenuItem_Windows

            //MenuItem_Help
            case "ICT Help": {
                this.Opacity = 0.5;
                var window = new HelpWindow();
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            case "ICT About": {
                this.Opacity = 0.5;
                var window = new AboutWindow();
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }

            case "ICT History": {
                this.Opacity = 0.5;
                var window = new HistoryWindow();
                window.ShowDialog();
                this.Opacity = 1;
                break;
            }
            }
        }