public IDockDocument ShowDocument(string name, CreateDockDocumentDelegate createDockCallback) { IDockDocument doc = null; var avalonDoc = FindAvalonDocument(name); if (avalonDoc == null) { if (String.CompareOrdinal(name, "startPage") != 0 && StartPageDockDocument.GlobalAutoClose) { StartPageDockDocument.GlobalAutoClose = false; CloseDocument("startPage"); } avalonDoc = new DocumentContent() { Name = name }; doc = createDockCallback(avalonDoc, name); BindingExtensions.CreateBinding(doc, "DocumentTitle", avalonDoc, DocumentContent.TitleProperty, BindingMode.OneWay); avalonDoc.Content = doc; avalonDoc.Closing += AvalonDoc_Closing; avalonDoc.Closed += AvalonDoc_Closed; } avalonDoc.Show(dockingManager, false); Dispatcher.BeginInvoke(new NoArgsDelegate(() => { avalonDoc.Manager.ActiveDocument = avalonDoc; }), null); return(doc); }
public void CloseDocument(IDockDocument doc) { var avalonDock = FindAvalonDocument(doc); if (avalonDock != null) { avalonDock.Close(); } }
public bool IsSameFile(IDockDocument document, string path) { var docCtrl = document as ResDictDocControl; if (docCtrl != null) { return(String.Compare(docCtrl.Document.FileName, path, StringComparison.OrdinalIgnoreCase) == 0); } return(false); }
public string GetDocumentName(IDockDocument doc) { var avalonDock = doc.DocumentContext as DocumentContent; if (avalonDock == null) { throw new ArgumentException("doc is not a valid document"); } return(avalonDock.Name); }
public void CloseDocument(IDockDocument doc) { bool cancel = false; doc.DocumentClosing(ref cancel); if (!cancel) { Documents.Remove(doc); doc.DocumentClosed(); } }
private DocumentContent FindAvalonDocument(IDockDocument doc) { foreach (var avalonDoc in dockingManager.Documents) { if (Object.ReferenceEquals(avalonDoc.Content, doc)) { return(avalonDoc); } } return(null); }
public IDockDocument ShowDocument(string id, CreateDockDocumentDelegate createDockCallback) { IDockDocument doc = FindDocument(id); if (doc == null) { doc = createDockCallback(null, id); Documents.Add(doc); } ActiveDocument = doc; return(doc); }
protected void InformServicesOfNewCanvas(BaseController controller) { // Wire up menu for this canvas controller. IFlowSharpMenuService menuService = ServiceManager.Get <IFlowSharpMenuService>(); menuService.Initialize(controller); // Wire up mouse for this canvas controller. IFlowSharpMouseControllerService mouseService = ServiceManager.Get <IFlowSharpMouseControllerService>(); mouseService.Initialize(controller); // Debug window needs to know too. ServiceManager.Get <IFlowSharpDebugWindowService>().Initialize(controller); // PropertyGrid service needs to hook controller events. ServiceManager.Get <IFlowSharpPropertyGridService>().Initialize(controller); // Update document tab when canvas name changes. controller.CanvasNameChanged += (sndr, args) => { IDockDocument doc = ((IDockDocument)((BaseController)sndr).Canvas.Parent.Parent); doc.TabText = controller.CanvasName; // Update the metadata for the controller document so the layout contains this info on save. doc.Metadata = Constants.META_CANVAS + "," + controller.Filename + "," + doc.TabText; }; // Update the metadata for the controller document so the layout contains this info on save. controller.FilenameChanged += (sndr, args) => { IDockDocument doc = ((IDockDocument)((BaseController)sndr).Canvas.Parent.Parent); doc.Metadata = Constants.META_CANVAS + "," + controller.Filename + "," + doc.TabText; }; // Inform debug window, so it can select the shape in the shape list when a shape is selected on the canvas. controller.ElementSelected += (sndr, args) => { ServiceManager.Get <IFlowSharpDebugWindowService>().FindShape(args.Element); }; ServiceManager.Get <IFlowSharpEditService>().NewCanvas(controller); // Update any other services needing to know about the new canvas. These are additional services that are not // part of the core FlowSharp application (for example, the FlowSharpCode services.) NewCanvas.Fire(this, new NewCanvasEventArgs() { Controller = controller }); }
protected void InformServicesOfNewCanvas(BaseController controller) { // Wire up menu for this canvas controller. IFlowSharpMenuService menuService = ServiceManager.Get <IFlowSharpMenuService>(); menuService.Initialize(controller); // Wire up mouse for this canvas controller. IFlowSharpMouseControllerService mouseService = ServiceManager.Get <IFlowSharpMouseControllerService>(); mouseService.Initialize(controller); // Debug window needs to know too. ServiceManager.Get <IFlowSharpDebugWindowService>().Initialize(controller); // PropertyGrid service needs to hook controller events. ServiceManager.Get <IFlowSharpPropertyGridService>().Initialize(controller); // Update document tab when canvas name changes. controller.CanvasNameChanged += (sndr, args) => { IDockDocument doc = ((IDockDocument)((BaseController)sndr).Canvas.Parent.Parent); doc.TabText = controller.CanvasName; // Update the metadata for the controller document so the layout contains this info on save. doc.Metadata = Constants.META_CANVAS + "," + controller.Filename + "," + doc.TabText; }; // Update the metadata for the controller document so the layout contains this info on save. controller.FilenameChanged += (sndr, args) => { IDockDocument doc = ((IDockDocument)((BaseController)sndr).Canvas.Parent.Parent); doc.Metadata = Constants.META_CANVAS + "," + controller.Filename + "," + doc.TabText; }; // Update any other services needing to know about the new canvas. NewCanvas.Fire(this, new NewCanvasEventArgs() { Controller = controller }); }
public void SetActiveDocument(IDockDocument document) { ((DockContent)document).Activate(); }