public override void FinishedInitialization() { base.FinishedInitialization(); IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); dockingService.DocumentClosing += (sndr, args) => OnDocumentClosing(sndr); }
protected void SelectFirstDocument() { IDockingFormService dockService = ServiceManager.Get <IDockingFormService>(); List <IDockDocument> docs = dockService.Documents; if (docs.Count > 0) { dockService.SetActiveDocument(docs[0]); } }
public Form CreateDockingForm(Icon icon) { dockingService = ServiceManager.Get <IDockingFormService>(); dockingService.ContentLoaded += OnContentLoaded; dockingService.ActiveDocumentChanged += (sndr, args) => OnActiveDocumentChanged(sndr); form = dockingService.CreateMainForm(); form.Text = "FlowSharp"; form.Icon = icon; form.Size = new Size(1200, 800); form.Shown += OnShown; form.FormClosing += OnFormClosing; ((IBaseForm)form).ProcessCmdKeyEvent += OnProcessCmdKeyEvent; return(form); }
protected void CreateEditor(string language) { Control docEditor = null; IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); Control d = FindDocument(dockingService, FlowSharpCodeServiceInterfaces.Constants.META_CSHARP_EDITOR); if (d == null) { d = FindDocument(dockingService, FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR); if (d == null) { d = FindDocument(dockingService, FlowSharpServiceInterfaces.Constants.META_CANVAS); if (d == null) { docEditor = dockingService.CreateDocument(DockState.Document, language + " Editor", FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR); } else { docEditor = dockingService.CreateDocument(d, DockAlignment.Bottom, language + " Editor", FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR, 0.50); } } else { docEditor = dockingService.CreateDocument(d, DockState.Document, language + " Editor", FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR); } } else { docEditor = dockingService.CreateDocument(d, DockState.Document, language + " Editor", FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR); } // Panel dock = dockingService.DockPanel; // Interestingly, this uses the current document page, which, I guess because the C# editor was created first, means its using that pane. //Control pyDocEditor = dockingService.CreateDocument(DockState.Document, "Python Editor", FlowSharpCodeServiceInterfaces.Constants.META_PYTHON_EDITOR); Control pnlCodeEditor = new Panel() { Dock = DockStyle.Fill, Tag = language }; docEditor.Controls.Add(pnlCodeEditor); ((IDockDocument)docEditor).Metadata += "," + language; // Add language to metadata so we know what editor to create. IFlowSharpScintillaEditorService scintillaEditorService = ServiceManager.Get <IFlowSharpScintillaEditorService>(); scintillaEditorService.CreateEditor(pnlCodeEditor, language); }
protected void OnFlowSharpInitialized(object sender, EventArgs args) { IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); Panel dock = dockingService.DockPanel; Control docCanvas = FindDocument(dockingService, FlowSharpServiceInterfaces.Constants.META_CANVAS); Control csDocEditor = dockingService.CreateDocument(docCanvas, DockAlignment.Bottom, "C# Editor", FlowSharpCodeServiceInterfaces.Constants.META_EDITOR, 0.50); Control pnlCsCodeEditor = new Panel() { Dock = DockStyle.Fill }; csDocEditor.Controls.Add(pnlCsCodeEditor); csCodeEditorService = ServiceManager.Get <IFlowSharpCodeEditorService>(); csCodeEditorService.CreateEditor(pnlCsCodeEditor); csCodeEditorService.AddAssembly("Clifton.Core.dll"); }
protected IDockDocument CreateCSharpEditor() { IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); // Panel dock = dockingService.DockPanel; Control d = FindDocument(dockingService, FlowSharpCodeServiceInterfaces.Constants.META_SCINTILLA_EDITOR); if (d == null) { Control docCanvas = FindDocument(dockingService, FlowSharpServiceInterfaces.Constants.META_CANVAS); if (docCanvas == null) { csDocEditor = dockingService.CreateDocument(DockState.Document, "C# Editor", FlowSharpCodeServiceInterfaces.Constants.META_CSHARP_EDITOR); } else { csDocEditor = dockingService.CreateDocument(docCanvas, DockAlignment.Bottom, "C# Editor", FlowSharpCodeServiceInterfaces.Constants.META_CSHARP_EDITOR, 0.50); } } else { csDocEditor = dockingService.CreateDocument(d, DockState.Document, "C# Editor", FlowSharpCodeServiceInterfaces.Constants.META_CSHARP_EDITOR); } Control pnlCsCodeEditor = new Panel() { Dock = DockStyle.Fill }; csDocEditor.Controls.Add(pnlCsCodeEditor); IFlowSharpCodeEditorService csCodeEditorService = ServiceManager.Get <IFlowSharpCodeEditorService>(); csCodeEditorService.CreateEditor(pnlCsCodeEditor); csCodeEditorService.AddAssembly("Clifton.Core.dll"); return((IDockDocument)csDocEditor); }
public void CreateOutputWindow() { Control outputContainer = null; IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); // Panel dock = dockingService.DockPanel; // If an editor is open, create the output window to the right of the editor. // If no editor is open, create the output window below the canvas. // If no canvas is even open, create the output window as the primary document. // We need to implement this as a basic pattern of rules for how to position new windows. Control ctrl = FindDocument(dockingService, Constants.META_CSHARP_EDITOR); // create output window relative to the editor window. if (ctrl == null) { ctrl = FindDocument(dockingService, FlowSharpServiceInterfaces.Constants.META_CANVAS); if (ctrl == null) { outputContainer = dockingService.CreateDocument(DockState.Document, "Output", Constants.META_OUTPUT); } else { outputContainer = dockingService.CreateDocument(ctrl, DockAlignment.Bottom, "Output", Constants.META_OUTPUT, 0.50); } } else { outputContainer = dockingService.CreateDocument(ctrl, DockAlignment.Right, "Output", Constants.META_OUTPUT, 0.50); } Control pnlOutputWindow = new Panel() { Dock = DockStyle.Fill }; outputContainer.Controls.Add(pnlOutputWindow); CreateOutputWindow(pnlOutputWindow); }
/// <summary> /// Return the document (or null) that implements IDockDocument with the specified Metadata tag. /// </summary> protected Control FindDocument(IDockingFormService dockingService, string tag) { return((Control)dockingService.Documents.FirstOrDefault(d => d.Metadata.LeftOf(",") == tag)); }
/// <summary> /// Return the document (or null) that implements IDockDocument with the specified Metadata tag. /// </summary> protected Control FindDocument(IDockingFormService dockingService, string tag) { return((Control)dockingService.Documents.SingleOrDefault(d => d.Metadata == tag)); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Bootstrap(); IDockingFormService dockingService = ServiceManager.Get <IDockingFormService>(); form = dockingService.CreateMainForm(); form.Text = "FlowSharpCode"; form.Size = new Size(1200, 800); form.Shown += OnShown; form.SuspendLayout(); docCanvas = dockingService.CreateDocument(DockState.Document, "Canvas"); Panel pnlFlowSharp = new Panel() { Dock = DockStyle.Fill }; docCanvas.Controls.Add(pnlFlowSharp); canvasController = ServiceManager.Get <IFlowSharpCanvasService>().CreateCanvas(pnlFlowSharp); csDocEditor = dockingService.CreateDocument(docCanvas, DockAlignment.Bottom, "C# Editor", 0.50); pnlCsCodeEditor = new Panel() { Dock = DockStyle.Fill }; csDocEditor.Controls.Add(pnlCsCodeEditor); pythonDocEditor = dockingService.CreateDocument(csDocEditor, DockAlignment.Right, "Editor", 0.50); pnlPythonCodeEditor = new Panel() { Dock = DockStyle.Fill }; pythonDocEditor.Controls.Add(pnlPythonCodeEditor); docToolbar = dockingService.CreateDocument(DockState.DockLeft, "Toolbar"); Panel pnlToolbox = new Panel() { Dock = DockStyle.Fill }; docToolbar.Controls.Add(pnlToolbox); ServiceManager.Get <IFlowSharpToolboxService>().CreateToolbox(pnlToolbox, canvasController); propGridToolbar = dockingService.CreateDocument(docToolbar, DockAlignment.Bottom, "Properties", 0.50); propGrid = new PropertyGrid() { Dock = DockStyle.Fill }; propGridToolbar.Controls.Add(propGrid); canvasController.ElementSelected += ElementSelected; canvasController.UpdateSelectedElement += UpdateSelectedElement; propGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OnPropertyValueChanged); ProcessCmdKeyHandler keyHandler = new ProcessCmdKeyHandler(canvasController); ((IBaseForm)form).ProcessCmdKeyEvent += keyHandler.ProcessCmdKey; Menu menu = new Menu(); menu.Initialize(); form.Controls.Add(menu.menuStrip1); operations = new Operations(canvasController); MenuController menuController = new MenuController(form, menu, canvasController, operations); //keyActions[Keys.Control | Keys.C] = operations.Copy; //keyActions[Keys.Control | Keys.V] = operations.Paste; // keyActions[Keys.Delete] = operations.Delete; //keyActions[Keys.Up] = () => canvasController.DragSelectedElements(new Point(0, -1)); //keyActions[Keys.Down] = () => canvasController.DragSelectedElements(new Point(0, 1)); //keyActions[Keys.Left] = () => canvasController.DragSelectedElements(new Point(-1, 0)); //keyActions[Keys.Right] = () => canvasController.DragSelectedElements(new Point(1, 0)); // codeEditor.AddAssembly(typeof(XDocument)); form.ResumeLayout(); MouseController mouseController = ServiceManager.Get <IFlowSharpCanvasService>().MouseController; mouseController.MouseClick += OnMouseClick; Application.Run(form); }