/// <summary>
        /// Removes the specified document from the managed ones.
        /// </summary>
        /// <param name="TargetDocument">Document to be removed.</param>
        public void RemoveDocument(ISphereModel TargetDocument)
        {
            General.ContractRequiresNotNull(TargetDocument);

            if (!this.Documents.Contains(TargetDocument))
            {
                return;
            }
            //- throw new UsageAnomaly("Document intended to be removed is not registered in the Workspace.", TargetDocument);

            int ActiveDocIndex = (this.ActiveDocument == null ? -1 : this.Documents.IndexOf(this.ActiveDocument));

            this.Documents.Remove(TargetDocument);

            var Handler = PostDocumentRemoval;

            if (Handler != null)
            {
                Handler(this, TargetDocument);
            }

            if (ActiveDocIndex >= 0)
            {
                this.ActiveDocument = (ActiveDocIndex < this.Documents.Count ? this.Documents[ActiveDocIndex] : (this.Documents.Count > 0 ? this.Documents[ActiveDocIndex - 1] : null));
            }
            else
            {
                this.ActiveDocument = null;
            }
        }
        public IEnumerable <IDocumentView> GetAllViews(ISphereModel ParentDocument = null)
        {
            if (ParentDocument == null)
            {
                return(this.RegisteredViews);
            }

            return(this.RegisteredViews.Where(view => view.ParentDocument == ParentDocument));
        }
        // DO NOT MESS WITH THIS METHOD SIGNATURE (TO AVOID DESERIALIZATION CRASH)
        public void SetSource(ISphereModel Source)
        {
            this.Source = Source;
            Refresh();

            if (this.SourceChanged != null)
            {
                this.SourceChanged(Source);
            }
        }
        /// <summary>
        /// Adds and activates a new document to the managed ones.
        /// </summary>
        /// <param name="NewDocument">Document being added.</param>
        public void LoadDocument(ISphereModel NewDocument)
        {
            General.ContractRequiresNotNull(NewDocument);

            if (this.Documents.Contains(NewDocument))
            {
                throw new UsageAnomaly("Cannot add an already registered document to the Workspace", NewDocument);
            }

            this.Documents.Add(NewDocument);
            this.ActiveDocument = NewDocument;
        }
        public void DiscardAllViews(ISphereModel ParentDocument = null)
        {
            var Targets = RegisteredViews.OrderBy(v => !(v == this.ActiveView)).ToList();

            foreach (var Item in Targets)
            {
                if (ParentDocument == null || Item.ParentDocument == ParentDocument)
                {
                    DiscardView(Item.GlobalId, false);
                }
            }

            // All tabs are cleared together to avoid reassign the Active-View
            this.ViewsTab.Items.Clear();
        }
示例#6
0
        public static void OnDocumentChange(WorkspaceManager workspace, ISphereModel document)
        {
            var SelectedDocument = workspace.ShellProvider.MainSelector.SelectedItem as ISphereModel;

            if (SelectedDocument.GlobalId == document.GlobalId)
            {
                ShellHost.RefreshSelection(document);
            }

            EntitleApplication(SelectedDocument.ToStringAlways());

            StatusBarControl.SldScaleLevel.ValueChanged += new RoutedPropertyChangedEventHandler <double>(StatusScale_ValueChanged);

            CompositionDirector.Visualizer.PostViewActivation =
                (docview =>
            {
                if (docview == null)
                {
                    return;
                }

                var DocEngine = docview.ParentDocument.DocumentEditEngine;
                if (DocEngine != null)
                {
                    ContentTreeControl.SetItemsSource(((Composition)DocEngine.TargetDocument).NavigableElements);
                    UpdatePalettes(DocEngine);
                    UpdateMenuToolbar();
                    DocEngine.ReactToViewChanged(docview);
                }

                docview.PostChangeOfPageDisplalyScale =
                    (PageDisplayScale =>
                {
                    StatusBarControl.SldScaleLevel.Value = PageDisplayScale;
                    //POSTPONED: NavigatorMapControl.Magnification = PageDisplayScale / 100;
                });

                //POSTPONED: ProductDirector.NavigatorMapControl.MapSource = docview.HostingScrollViewer;

                docview.PostChangeOfPageDisplalyScale(docview.PageDisplayScale);
            });
        }
示例#7
0
 public static void OnDocumentDiscard(WorkspaceManager workspace, ISphereModel document)
 {
     ContentTreeControl.SetItemsSource(null);
 }
 /// <summary>
 /// Activates the supplied document.
 /// </summary>
 public void ActivateDocument(ISphereModel Document)
 {
     this.ActiveDocument = Document;
 }