Esempio n. 1
0
 void openFile(object dummy)
 {
     if (this.VM.ActiveEditor == null)
     {
         OpenFileDialog dlg = new OpenFileDialog();
         dlg.Filter          = "(*.bas)|*.bas|(*.vbs)|*.vbs|(*.txt)|*.txt|All files (*.*)|*.*";
         dlg.FilterIndex     = 0;
         dlg.CheckFileExists = true;
         if (dlg.ShowDialog() ?? false)
         {
             InstallBasTextEditor bas = this.AddEditor("");
             bas.VM.CurrentFileName = dlg.FileName;
             bas.textEditor.Load(bas.VM.CurrentFileName);
             bas.textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(bas.VM.CurrentFileName)).Name;
         }
     }
 }
Esempio n. 2
0
        InstallBasTextEditor AddEditor(string InstallBasAction)
        {
            ManagedContent mc = null;

            if (DockMan.ActiveContent == null)
            {
                mc = DockMan.DockableContents.First();
            }
            else
            {
                mc = DockMan.ActiveContent;
            }

            DockablePane cPane = mc.ContainerPane as DockablePane;

            string dc_Name = "editor_" + (VM.Editors.Count + 1).ToString();

            DockableContent dc_prev = null;

            foreach (var item in cPane.Items)
            {
                dc_prev = item as DockableContent;
                if (dc_prev.Name.Equals(dc_Name))
                {
                    break;
                }
                else
                {
                    dc_prev = null;
                }
            }
            if (dc_prev != null)
            {
                dc_Name += "_" + cPane.Items.Count.ToString();
            }


            DockableContent dc = new DockableContent();

            dc.Name  = dc_Name;
            dc.Title = dc_Name;
            cPane.Items.Add(dc);


            InstallBasTextEditor bas = new InstallBasTextEditor();

            bas.VM.SyntaxHighlighting = "VBNET";
            bas.VM.Font            = "Consolas";
            bas.VM.FontSize        = 12;
            bas.VM.CurrentFileName = dc_Name;
            if (!String.IsNullOrEmpty(InstallBasAction))
            {
                if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_INSTALL))
                {
                    bas.VM.InstallBas();
                }
                else if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_REMOVE))
                {
                    bas.VM.RemoveBas();
                }
            }

            dc.Content = bas;

            dc.Closing += delegate(object sender, CancelEventArgs e)
            {
                this.VM.ActiveEditor.IsActive = false;
                this.VM.Editors.Remove(bas.VM);
            };
            dc.Activate();

            this.VM.Editors.Add(bas.VM);
            bas.VM.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName.Equals("CurrentFileName"))
                {
                    dc.Title = Path.GetFileName(bas.VM.CurrentFileName);
                }
            };
            return(bas);
        }