Exemple #1
0
 public DocumentWindow(IServiceProvider serviceProvider, Microsoft.Matrix.Core.Documents.Document document)
     : base(serviceProvider)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     this._document = document;
     try
     {
         base.SuspendLayout();
         this.InitializeUserInterface();
         this._documentView = this.CreateDocumentView();
     }
     finally
     {
         base.ResumeLayout(true);
     }
     this._documentView.DocumentChanged += new EventHandler(this.OnDocumentViewDocumentChanged);
     this._viewCommandHandler = this._documentView as ICommandHandler;
     this._viewToolboxClient = this._documentView as IToolboxClient;
     this._viewSelectionContainer = this._documentView as ISelectionContainer;
     IDesigner designer = ((IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost))).GetDesigner(document);
     this._designerCommandHandler = designer as ICommandHandler;
     this._contextCommandHandler = this._document.ProjectItem.Project;
     this.UpdateCaption();
 }
Exemple #2
0
        public void BeforeEach()
        {
            var activeDocument = Mock.Create <IDocument>();

            this.activeView = Mock.Create <IDocumentView>();
            Mock.Arrange(() => this.activeView.Document).Returns(activeDocument);
        }
Exemple #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tipoDoc">El tipo de documento a procesar</param>
 /// <param name="view">La vista donde se va a presentar el documento</param>
 /// <param name="daof">DAOFactory</param>
 public GenericPresenter(TipoDocumento tipoDoc, IDocumentView view, DAOFactory daof)
 {
     TipoDocumento       = tipoDoc;
     TipoDocumentoHelper = new TipoDocumentoHelper(TipoDocumento);
     this.view           = view;
     DAOFactory          = daof;
 }
        public override void OnNodeStructureChanged(IDocumentView <TDocument> docView, IElementEdit edit)
        {
            base.OnNodeStructureChanged(docView, edit);

            for (var index = 0; index < edit.RemovedNodes.Length; index++)
            {
                var removedNode = edit.RemovedNodes[index];
                var view        = childViews[edit.Index];
                if (!ReferenceEquals(view.Node, removedNode))
                {
                    // pure paranoia ..
                    throw new InvalidOperationException();
                }
                Remove(edit.Index);
            }

            var insertIndex = edit.Index;

            for (var index = 0; index < edit.AddedNodes.Length; index++)
            {
                var addedNode = edit.AddedNodes[index];
                var view      = docView.ViewFactory.CreateFor(addedNode, Style);
                Insert(insertIndex, view);
                insertIndex += 1;
            }
        }
Exemple #5
0
        private void ActivateResult(IProjectItem projectItem, FindInFilesResult result)
        {
            if (projectItem == null)
            {
                return;
            }
            if (this.FindInFile(projectItem, new FindInFilesDialog.ProcessResult(this.UpdateResult), result))
            {
                result.Line   = -1;
                result.Column = -1;
                this.FindInFile(projectItem, new FindInFilesDialog.ProcessResult(this.UpdateToLastResult), result);
            }
            if (result.Line == -1 || result.Column == -1)
            {
                return;
            }
            IDocumentView documentView = projectItem.OpenView(true);

            if (documentView == null)
            {
                return;
            }
            ISetCaretPosition setCaretPosition = documentView as ISetCaretPosition;

            if (setCaretPosition == null)
            {
                return;
            }
            setCaretPosition.SetCaretPosition(result.Line, result.Column);
        }
Exemple #6
0
        public SwitchToDialog(IWindowService windowService, IViewService viewService)
        {
            FrameworkElement element = FileTable.GetElement("Resources\\UserInterface\\SwitchToDialog.xaml");

            element.DataContext         = (object)this;
            this.DialogContent          = (UIElement)element;
            this.Title                  = StringTable.SwitchToDialogTitle;
            this.SizeToContent          = SizeToContent.WidthAndHeight;
            this.WindowStyle            = WindowStyle.None;
            this.documentListBox        = element.FindName("DocumentList") as ListBox;
            this.windowService          = windowService;
            this.viewService            = viewService;
            this.documentViewReferences = new ObservableCollection <DocumentViewReference>();
            foreach (IView view in (IEnumerable <IView>) this.viewService.Views)
            {
                IDocumentView documentView = view as IDocumentView;
                if (documentView != null)
                {
                    this.documentViewReferences.Add(new DocumentViewReference(documentView));
                }
            }
            this.documentViewReferencesView = CollectionViewSource.GetDefaultView((object)this.documentViewReferences);
            this.documentViewReferencesView.MoveCurrentToFirst();
            this.MoveSelectionByOne(true);
        }
        public void ActivateDocument(IDocumentView view)
        {
            if (view == null)
            {
                return;
            }
            foreach (DocumentView d in documentViews)
            {
                if (d.GetType() == view.GetType())
                {
                    if (d.DocumentName == view.DocumentName)
                    {
                        d.Activate();
                        return;
                    }
                }
            }
            DocumentView doc = view as DocumentView;

            if (doc != null)
            {
                doc.FormClosing += new FormClosingEventHandler(OnDocumentWindowClosing);
                documentViews.Add(doc);
                doc.Show(dockPanel, DockState.Document);
                Refresh();
            }
        }
        public ActionsEditManipulator(IDocumentView view, FrameworkElement el)
            : base(view, el)
        {
            AddActionPanel.Orientation = Orientation.Vertical;
            Button b;

            foreach (Type actionType in ActionsCollection.ActionsTypes)
            {
                b         = new Button();
                b.Content = "Add" + actionType.Name;
                AddActionPanel.Children.Add(b);
                b.Tag    = actionType;
                b.Click += new RoutedEventHandler(AddEventClick);
            }
            b         = new Button();
            b.Content = "Delete Action";
            AddActionPanel.Children.Add(b);
            b.Click += new RoutedEventHandler(DeleteActionClicked);
            AddActionPanel.HorizontalAlignment = HorizontalAlignment.Left;
            AddActionPanel.VerticalAlignment   = VerticalAlignment.Top;
            ActionsPanel.HorizontalAlignment   = HorizontalAlignment.Right;
            ActionsPanel.VerticalAlignment     = VerticalAlignment.Top;

            visualChildren.Add(AddActionPanel);
            visualChildren.Add(ActionsPanel);
        }
 void CreateDocumentLoader()
 {
     document     = MockRepository.GenerateStub <IDocument>();
     documentView = MockRepository.GenerateStub <IDocumentView>();
     documentView.Stub(view => view.Document).Return(document);
     documentLoader = MockRepository.GenerateStub <IDocumentLoader>();
 }
Exemple #10
0
        public IDocumentView OpenView(bool makeActive)
        {
            if (!this.DocumentType.CanView)
            {
                return(null);
            }
            if (!this.IsOpen && !this.OpenDocument(false, false))
            {
                return(null);
            }
            IViewService  viewService  = this.Services.ViewService();
            IDocumentView documentView = viewService.Views.OfType <IDocumentView>().FirstOrDefault <IDocumentView>((IDocumentView v) => v.Document == this.Document);

            if (documentView == null)
            {
                documentView = this.Document.CreateDefaultView();
                if (documentView != null)
                {
                    viewService.OpenView(documentView);
                }
            }
            if (documentView != null && makeActive)
            {
                viewService.ActiveView = documentView;
            }
            return(documentView);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="element"></param>
        public DrawTool(IDocumentView view)
            : base(view)
        {
            objectPrview.Opacity = 0.5;
            visualChildren.Add(objectPrview);

            gridManager = ((Views.SchemaView)_view).GridManager;
        }
Exemple #12
0
        public override IDocumentView CreateDefaultView()
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.CreateCodeEditor);
            IDocumentView documentView = (IDocumentView) new LimitedDocumentView((IDocument)this, this.editingService);

            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.CreateCodeEditor);
            return(documentView);
        }
Exemple #13
0
        private void SetActiveView(IView view)
        {
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.SwitchView);
            IDocumentView documentView = view as IDocumentView;

            DocumentService.Item obj = documentView != null ? this.items[documentView.Document] : (DocumentService.Item)null;
            this.SetActiveDocumentAndView(view, obj);
        }
Exemple #14
0
 public PointerAdorner(IDocumentView Target, UIElement AdornedTarget, Drawing ExposedPointer, bool DecorateCloser)
     : base(AdornedTarget)
 {
     this.IsHitTestVisible = false;
     this.Target           = Target;
     this.ExposedPointer   = ExposedPointer;
     this.DecorateCloser   = DecorateCloser;
 }
Exemple #15
0
        private void ViewService_ActiveViewChanged(object sender, ViewChangedEventArgs e)
        {
            IDocumentView newView = e.NewView as IDocumentView;

            if (newView != null)
            {
                this.SelectItemForDocument(newView.Document);
            }
        }
Exemple #16
0
        public override IDocumentView CreateDefaultView()
        {
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.CreateCodeEditor);
            CodeProject.EnsureResolverCachePruned(this.codeProject.ProjectResolver);
            IDocumentView documentView = (IDocumentView) new CodeView((IDocument)this, this.codeProject, this.codeProjectService.MessageDisplayService, this.viewService, this.codeOptionsModel, this.windowService);

            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.CreateCodeEditor);
            return(documentView);
        }
Exemple #17
0
        private bool SaveProjectItems(bool promptBeforeSaving, bool saveActiveDocument)
        {
            Func <IProjectItem, Microsoft.Expression.Framework.Documents.DocumentReference> documentReference = null;
            Func <IProjectItem, bool> func = null;
            bool flag = true;

            ErrorHandling.HandleBasicExceptions(() => {
                IEnumerable <IProjectItem> dirtyProjectItems = SolutionBase.GetDirtyProjectItems(this.Projects);
                if (!saveActiveDocument)
                {
                    IDocumentView activeView = this.Services.ViewService().ActiveView as IDocumentView;
                    if (activeView != null)
                    {
                        IDocument document = activeView.Document;
                        dirtyProjectItems  =
                            from item in dirtyProjectItems
                            where item.Document != document
                            select item;
                    }
                }
                if (dirtyProjectItems.Any <IProjectItem>())
                {
                    if (promptBeforeSaving)
                    {
                        SaveFilesDialog saveFilesDialog = new SaveFilesDialog(this.Services, dirtyProjectItems);
                        saveFilesDialog.InitializeDialog();
                        saveFilesDialog.ShowDialog();
                        if (saveFilesDialog.Result == ProjectDialog.ProjectDialogResult.Cancel)
                        {
                            flag = false;
                            return;
                        }
                        if (saveFilesDialog.Result == ProjectDialog.ProjectDialogResult.Discard)
                        {
                            flag = true;
                            return;
                        }
                    }
                    if (this.IsSourceControlActive)
                    {
                        IEnumerable <IProjectItem> projectItems = dirtyProjectItems;
                        if (documentReference == null)
                        {
                            documentReference = (IProjectItem item) => item.DocumentReference;
                        }
                        SourceControlHelper.UpdateSourceControl(projectItems.Select <IProjectItem, Microsoft.Expression.Framework.Documents.DocumentReference>(documentReference), UpdateSourceControlActions.Checkout, this.Services);
                    }
                    IEnumerable <IProjectItem> projectItems1 = dirtyProjectItems;
                    if (func == null)
                    {
                        func = (IProjectItem item) => !item.SaveDocumentFile();
                    }
                    flag = !projectItems1.Any <IProjectItem>(func);
                }
            }, (Exception exception) => this.Services.ShowErrorMessage(StringTable.SaveAllFailedDialogMessage, exception));
            return(flag);
        }
Exemple #18
0
 public void Do(IDocumentView doc)
 {
     if (!(doc is Views.SchemaView))
     {
         throw new Exception("this is not schema");
     }
     schemaView = doc as Views.SchemaView;
     schemaView.MainPanel.Children.Add(addedObject);
 }
Exemple #19
0
 public ControlCreateTool(IDocumentView view)
     : base(view)
 {
     if (!typeof(T).IsSubclassOf(typeof(FrameworkElement)))
     {
         throw new Exception();
     }
     visualChildren.Add(boundce);
 }
        public SpellCheckProvider(ISpellingService spellingService, IDocumentView view)
        {
            this.spellingService = spellingService;
            spellCheckRenderer = new SpellCheckBackgroundRenderer();

            View = view;

            View.TextView.BackgroundRenderers.Add(spellCheckRenderer);
            View.TextView.VisualLinesChanged += TextViewVisualLinesChanged;
        }
Exemple #21
0
        public bool IsViewOfItem(IView view)
        {
            IDocumentView documentView = view as IDocumentView;

            if (documentView == null || documentView.Document == null)
            {
                return(false);
            }
            return(documentView.Document.DocumentReference == this.projectItem.DocumentReference);
        }
Exemple #22
0
 public void SetActiveDocumentView(IDocumentView view)
 {
     UIDispatcher.Execute(() =>
     {
         if (DocumentViews.Contains(view))
         {
             ActiveDocumentView = view;
         }
     });
 }
Exemple #23
0
 public void SetActiveDocumentView(string id)
 {
     UIDispatcher.Execute(() =>
     {
         if (_viewModels.ContainsKey(id))
         {
             ActiveDocumentView = (IDocumentView)_viewModels[id].View;
         }
     });
 }
        public void ConnectToDocumentView(IDocumentView view)
        {
            if (_providers.Any(p => p.View == view))
            {
                throw new ArgumentException("View already has a spell check provider connected", "view");
            }

            var provider = _spellCheckProviderFactory.GetProvider(_spellingService, view);
            _providers.Add(provider);
        }
Exemple #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        protected BaseTool(IDocumentView view)
            : base(view.MainPanel)
        {
            _view          = view;
            visualChildren = new VisualCollection(this);
            DrawingVisual drawingVisual = new DrawingVisual();

            drawingVisual.Opacity = 0;
            visualChildren.Add(drawingVisual);
        }
        /// <summary>
        /// Registers the <see cref="DocumentView" />.
        /// Now that it is known in the IContextualViewModelManager, the visibility of the context sensitive views can be managed.
        /// </summary>
        /// <param name="documentView">The document view.</param>
        public void RegisterOpenDocumentView(IDocumentView documentView)
        {
            Argument.IsNotNull(() => documentView);

            if (!_openDocumentViewsCollection.Contains(documentView))
            {
                _openDocumentViewsCollection.Add(documentView);
                ShowContextSensitiveViews(documentView);
            }
        }
 /// <summary>
 /// Shows the specified view as the current window.
 /// </summary>
 /// <param name="view">The view.</param>
 public void ShowView(IDocumentView view)
 {
     if (view is DockContent)
     {
         ((DockContent)view).Show(base.Workspace);
     }
     else
     {
         throw new InvalidCastException(string.Format("Provided view must inherit {0}", typeof(DockContent)));
     }
 }
        public void ConnectToDocumentView(IDocumentView view)
        {
            if (_providers.Any(p => p.View == view))
            {
                throw new ArgumentException("View already has a spell check provider connected", "view");
            }

            var provider = _spellCheckProviderFactory.GetProvider(_spellingService, view);

            _providers.Add(provider);
        }
        public void DisconnectFromDocumentView(IDocumentView view)
        {
            var provider = _providers.FirstOrDefault(p => p.View == view);

            if (provider == null)
            {
                return;
            }

            provider.Disconnect();
            _providers.Remove(provider);
        }
Exemple #30
0
            internal static void Initializer(IDocumentView documentView, QuickPadCommands commands)
            {
                documentView.ViewModel = ServiceProvider.GetService <DocumentViewModel>();

                commands.NewDocumentCommand.Executioner = NewDocument;
                commands.LoadCommand.Executioner        = LoadDocument;
                commands.SaveCommand.Executioner        = SaveDocument;
                commands.SaveAsCommand.Executioner      = SaveAsDocument;
                commands.ExitCommand.Executioner        = ExitApplication;

                documentView.ViewModel.Initialize = async viewModel => { await viewModel.InitNewDocument(); };
            }
        public void SetUp()
        {
            Count       = 0;
            styleSystem = LayoutTestStyle.CreateStyleSystem();
            var textStyle = LayoutTestStyle.CreateTextStyle(styleSystem);

            var documentView = Substitute.For <IDocumentView <ITextDocument> >();

            documentView.Document.Returns((ITextDocument)null);
            documentView.Style.Returns(textStyle);
            this.doc = documentView;
        }
Exemple #32
0
            public void Initialize(IView viewReference)
            {
                this.ViewReference             = viewReference;
                viewReference.PropertyChanged += new PropertyChangedEventHandler(this.ViewReference_PropertyChanged);
                IDocumentView documentView = this.ViewReference as IDocumentView;

                if (documentView == null)
                {
                    return;
                }
                documentView.Document.IsDirtyChanged += new EventHandler(this.Document_IsDirtyChanged);
                documentView.Document.Renamed        += new EventHandler(this.Document_Renamed);
            }
 public void NewActiveDocument(IDocumentView newDoc)
 {
     if (newDoc == null)
     {
         throw new ArgumentNullException();
     }
     if (ActiveDocuments.Contains(newDoc))
     {
         ActiveDocuments.Remove(newDoc);
     }
     ActiveDocuments.Push(newDoc);
     this.TitlePre = ActiveDocument.GetVM().TitleName;
 }
 void CreateDocumentLoader()
 {
     document = MockRepository.GenerateStub<IDocument>();
     documentView = MockRepository.GenerateStub<IDocumentView>();
     documentView.Stub(view => view.Document).Return(document);
     documentLoader = MockRepository.GenerateStub<IDocumentLoader>();
 }
 public ISpellCheckProvider GetProviderForView(IDocumentView view)
 {
     return _providers.FirstOrDefault(provider => provider.View == view);
 }
        public void DisconnectFromDocumentView(IDocumentView view)
        {
            var provider = _providers.FirstOrDefault(p => p.View == view);
            if (provider == null) return;

            provider.Disconnect();
            _providers.Remove(provider);
        }
 void IMultiViewDocumentWindow.ActivateView(IDocumentView documentView)
 {
     this._viewHost.SwitchToView(documentView);
 }
 public void NewActiveDocument(IDocumentView newDoc)
 {
     if (newDoc == null) throw new ArgumentNullException();
     if (ActiveDocuments.Contains(newDoc)) ActiveDocuments.Remove(newDoc);
     ActiveDocuments.Push(newDoc);
     this.TitlePre = ActiveDocument.GetVM().TitleName;
 }
Exemple #39
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this._viewCommandHandler = null;
         this._documentView.DocumentChanged -= new EventHandler(this.OnDocumentViewDocumentChanged);
         this.DisposeDocumentView();
         this._documentView = null;
         this._designerCommandHandler = null;
         this._contextCommandHandler = null;
         this._document = null;
     }
     base.Dispose(disposing);
 }
Exemple #40
0
 /// <summary>
 /// Constructeur
 /// </summary>
 /// <param name="sender">
 /// Vue qui a créé le message
 /// </param>
 /// <param name="type">
 /// Type de changement demandé
 /// </param>
 /// <param name="arguments">
 /// Arguments du message
 /// </param>
 public Message(IDocumentView sender, ChangeType type, String[] arguments)  
 { 
     this.Sender = sender; 
     this.Type = type;
     this.Arguments = arguments; 
 } 
 /// <summary>
 /// Ajout d'une vue gérée par ce contrôleur
 /// </summary>
 /// <param name="view"></param>
 public void AddView(IDocumentView view)
 {
     totalViews++;
 }
 public ISpellCheckProvider GetProvider(ISpellingService spellingService, IDocumentView view)
 {
     return new SpellCheckProvider(spellingService, view);
 }
 /// <summary>
 /// Shows the specified view as the current window.
 /// </summary>
 /// <param name="view">The view.</param>
 public void ShowView(IDocumentView view)
 {
     if (view is DockContent)
         ((DockContent)view).Show(base.Workspace);
     else throw new InvalidCastException(string.Format("Provided view must inherit {0}", typeof(DockContent)));
 }
Exemple #44
0
 void OpenDocument()
 {
     documentView = documentLoader.LoadDocumentView(fileName);
     document = documentView.Document;
 }
 private void CloseView(IDocumentView view)
 {
     if (view == null) throw new ArgumentNullException("view");
     This.Logger.Verbose("Closing View.");
     view.Close();
     if (view is IDisposable)
     {
         var document = view.Document;
         var viewInfo = document == null ? view.GetType() : document.GetType();
         This.Logger.Verbose(string.Format("Disposing view {0}", viewInfo));
         ((IDisposable)view).Dispose();
     }
 }
 public void SwitchToView(IDocumentView documentView)
 {
     if (documentView == null)
     {
         throw new ArgumentNullException("Can't switch to a null IDocumentView");
     }
     for (int i = 0; i < this._views.Count; i++)
     {
         MultiViewDocumentWindow.ViewInfo info = this._views[i] as MultiViewDocumentWindow.ViewInfo;
         if (info.view == documentView)
         {
             this.SwitchToView(i);
             return;
         }
     }
 }