コード例 #1
0
        private void SettingWindowCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            // Force update of script interface
            SettingWindowButton.Focus();

            SettingViewModel svModel = new SettingViewModel(Global.Setting, Global.Projects);
            SettingWindow    dialog  = new SettingWindow(svModel)
            {
                Owner = this
            };

            if (dialog.ShowDialog() == true)
            {
                // Refresh Projects
                if (svModel.NeedProjectRefresh)
                {
                    Model.StartLoadingProjects(true, false);
                }
                else
                {
                    // Scale Factor
                    if (svModel.NeedScriptRedraw && Model.CurMainTree?.Script != null)
                    {
                        Model.DisplayScript(Model.CurMainTree.Script);
                    }

                    // Script
                    if (svModel.NeedScriptCaching)
                    {
                        Model.StartScriptCaching();
                    }
                }
            }
        }
コード例 #2
0
        private async void CodeBoxRunButton_Click(object sender, RoutedEventArgs e)
        {
            Encoding encoding = Encoding.UTF8;

            if (File.Exists(m.CodeFile))
            {
                encoding = FileHelper.DetectTextEncoding(m.CodeFile);
            }

            using (StreamWriter writer = new StreamWriter(m.CodeFile, false, encoding))
            {
                writer.Write(m.CodeBox_Input);
                writer.Close();
            }

            if (Engine.WorkingLock == 0)  // Start Build
            {
                Interlocked.Increment(ref Engine.WorkingLock);

                Project project = m.CodeBox_CurrentProject;
                Script  p       = project.LoadScriptMonkeyPatch(m.CodeFile);

                Logger           logger    = null;
                SettingViewModel setting   = null;
                MainViewModel    mainModel = null;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    MainWindow w = (Application.Current.MainWindow as MainWindow);
                    logger       = w.Logger;
                    setting      = w.Setting;
                    mainModel    = w.Model;
                });

                mainModel.SwitchNormalBuildInterface = false;
                mainModel.WorkInProgress             = true;

                EngineState s = new EngineState(p.Project, logger, mainModel, EngineMode.RunMainAndOne, p);
                s.SetOption(setting);

                Engine.WorkingEngine = new Engine(s);

                await Engine.WorkingEngine.Run($"CodeBox - {project.ProjectName}");

                mainModel.WorkInProgress             = false;
                mainModel.SwitchNormalBuildInterface = true;

                Application.Current.Dispatcher.Invoke(() =>
                {
                    MainWindow w = Application.Current.MainWindow as MainWindow;

                    w.DrawScript(w.CurMainTree.Script);

                    if (w.Setting.General_ShowLogAfterBuild && LogWindow.Count == 0)
                    { // Open BuildLogWindow
                        w.LogDialog = new LogWindow(1);
                        w.LogDialog.Show();
                    }
                });

                Engine.WorkingEngine = null;
                Interlocked.Decrement(ref Engine.WorkingLock);
            }
            else
            {
                MessageBox.Show("Engine is already running", "Build Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #3
0
ファイル: SettingWindow.xaml.cs プロジェクト: KYHI/PEBakery
 public SettingWindow(SettingViewModel model)
 {
     this.Model       = model;
     this.DataContext = Model;
     InitializeComponent();
 }
コード例 #4
0
ファイル: UIRenderer.cs プロジェクト: pianomanx/PEBakery
        private static async void RunOneSection(SectionAddress addr, string logMsg, bool hideProgress)
        {
            if (Engine.WorkingLock == 0)
            {
                Interlocked.Increment(ref Engine.WorkingLock);

                Logger           logger    = null;
                SettingViewModel setting   = null;
                MainViewModel    mainModel = null;

                Application.Current.Dispatcher.Invoke(() =>
                {
                    MainWindow w = Application.Current.MainWindow as MainWindow;

                    logger    = w.Logger;
                    mainModel = w.Model;
                    setting   = w.Setting;

                    // Populate BuildTree
                    if (!hideProgress)
                    {
                        w.Model.BuildTree.Children.Clear();
                        w.PopulateOneTreeView(addr.Plugin, w.Model.BuildTree, w.Model.BuildTree);
                        w.CurBuildTree = null;
                    }
                });

                mainModel.WorkInProgress = true;

                EngineState s = new EngineState(addr.Plugin.Project, logger, mainModel, addr.Plugin, addr.Section.SectionName);
                s.SetOption(setting);
                s.DisableLogger = setting.Log_DisableInInterface;

                Engine.WorkingEngine = new Engine(s);

                // Build Start, Switch to Build View
                if (!hideProgress)
                {
                    mainModel.SwitchNormalBuildInterface = false;
                }

                // Run
                long buildId = await Engine.WorkingEngine.Run(logMsg);

                // Build Ended, Switch to Normal View
                if (!hideProgress)
                {
                    mainModel.SwitchNormalBuildInterface = true;
                }

                // Turn off ProgressRing
                mainModel.WorkInProgress = false;

                Engine.WorkingEngine = null;
                Interlocked.Decrement(ref Engine.WorkingLock);

                if (!hideProgress)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        MainWindow w = Application.Current.MainWindow as MainWindow;
                        w.DrawPlugin(w.CurMainTree.Plugin);
                    });
                }
            }
        }