Пример #1
0
        internal static void Clear()
        {
            IronPythonConsole console = IronPythonConsole.currentConsole;

            if (console != null)
            {
                console.Dispatcher.Invoke(() => console.console.Clear());
            }
        }
Пример #2
0
 protected override void OnClosed(EventArgs e)
 {
     base.OnClosed(e);
     IronPythonConsole.currentConsole = null;
     this.stdout.Close();
     this.writer.Close();
     this.stdin.Close();
     this.reader.Close();
 }
Пример #3
0
        internal static void Run(Window parent, string script)
        {
            IronPythonConsole.Run(parent);
            IronPythonConsole console = IronPythonConsole.currentConsole;

            if (console != null)
            {
                console.writer.WriteLine(script);
                console.Execute(script);
            }
        }
Пример #4
0
 internal static void Run(Window parent)
 {
     if (IronPythonConsole.currentConsole == null)
     {
         IronPythonConsole console = new IronPythonConsole();
         console.Owner = parent;
         IronPythonConsole.currentConsole = console;
         console.Show();
     }
     else
     {
         IronPythonConsole.currentConsole.Focus();
     }
 }
 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     base.OnClosing(e);
     try {
         if (!this.EnsureSaved())
         {
             e.Cancel = true;
         }
         else
         {
             IronPythonConsole.Stop();
             Settings.User.Save();
             this.autoSaveTimer?.Dispose();
             this.autoSaveTimer = null;
         }
     } catch (Exception exception) {
         Tracer.Report("Mainframe.OnClosing", exception);
         this.ReportException(exception);
     }
 }
Пример #6
0
 public static void ClearConsole()
 {
     IronPythonConsole.Clear();
 }
        public Mainframe()
        {
            App.Mainframe     = this;
            this.ProjectWidth = new SettingsGridLengthCache(Settings.User, "Mainframe.ProjectWidth", "0.25*");
            this.DiagramWidth = new SettingsGridLengthCache(Settings.User, "Mainframe.DiagramWidth", "0.75*");

            // Create this command here as it used multiple times not like all other commands only onces when menu is created.
            this.CommandOpenRecent = new LambdaUICommand(Properties.Resources.CommandFileOpenRecent, file => this.OpenRecent(file as string));

            this.DataContext = this;
            this.InitializeComponent();

            this.autoSaveTimer = new Timer(o => this.Editor?.AutoSave(), null, Timeout.Infinite, Timeout.Infinite);

            Thread thread = new Thread(new ThreadStart(() => {
                try {
                    string file = App.CurrentApp.FileToOpen;
                    if (string.IsNullOrEmpty(file) || !File.Exists(file))
                    {
                        if (Settings.User.LoadLastFileOnStartup)
                        {
                            file = Settings.User.RecentFile();
                        }
                    }
                    if (!string.IsNullOrEmpty(file) && File.Exists(file))
                    {
                        this.Edit(file);
                    }
                    else
                    {
                        this.Edit(null);
                    }
                    if (!string.IsNullOrEmpty(App.CurrentApp.CommandLineErrors))
                    {
                        this.ShowErrorMessage(App.CurrentApp.CommandLineErrors, null);
                    }
                    else if (!string.IsNullOrEmpty(App.CurrentApp.ScriptToRun))
                    {
                        this.Dispatcher.BeginInvoke(new Action(() => IronPythonConsole.Run(this, App.CurrentApp.ScriptToRun)));
                    }
                    else
                    {
                        // Reuse this thread to check if there are any translations requests are pending
                        DialogAbout.CheckTranslationRequests(this.Dispatcher);
                    }
                } catch (Exception exception) {
                    Tracer.Report("Mainframe.PostLoaded", exception);
                    this.ReportException(exception);
                    this.Edit(null);
                }
            }));

            //TextNote validator will instantiate FlowDocument that in some cases required to happened only on STA.
            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;
            thread.Name         = "ProjectLoader";
            thread.Priority     = ThreadPriority.AboveNormal;
            thread.Start();

            // Check for new available version
            Thread versionThread = new Thread(new ThreadStart(() => DialogAbout.CheckVersion(this.Dispatcher)))
            {
                IsBackground = true,
                Name         = "CheckVersion",
                Priority     = ThreadPriority.BelowNormal
            };

            versionThread.Start();

                        #if DEBUG && false
            this.Loaded += (object sender, RoutedEventArgs e) => {
                Menu   menu = (Menu)((Grid)this.Content).Children[0];
                string text = "Test";
                menu.Items.Add(new MenuItem()
                {
                    Header = text, Command = new LambdaUICommand(text, o => {
                        DialogMessage.Show(this,
                                           "hello",
                                           "world <Hyperlink NavigateUri=\"http://www.rbc.ru\">link 1</Hyperlink> or <Hyperlink NavigateUri=\"http://www.lenta.ru\">link 2</Hyperlink> hello <Hyperlink NavigateUri=\"http://www.cnn.com\">and link 3</Hyperlink> end",
                                           "details",
                                           MessageBoxImage.Error,
                                           MessageBoxButton.OKCancel
                                           );
                    })
                });
            };
                        #endif
        }