示例#1
0
        void CountFileOpened(DocumentController controller)
        {
            string type;

            if (controller is FileDocumentController fileDocumentController)
            {
                type = System.IO.Path.GetExtension(fileDocumentController.FilePath);
                var mt = !string.IsNullOrEmpty(fileDocumentController.MimeType) ? fileDocumentController.MimeType : desktopService.GetMimeTypeForUri(fileDocumentController.FilePath);
                if (!string.IsNullOrEmpty(mt))
                {
                    type += " (" + mt + ")";
                }
            }
            else
            {
                type = "(not a file)";
            }

            var metadata = new Dictionary <string, object> ()
            {
                { "FileType", type },
                { "DisplayBinding", controller.GetType().FullName },
            };

            metadata ["DisplayBindingAndType"] = type + " | " + controller.GetType().FullName;

            Counters.DocumentOpened.Inc(metadata);
        }
 public bool CanHandle(DocumentController controller)
 {
     if (controller is FileDocumentController fileController)
     {
         return(CanHandle(fileController.FilePath, fileController.MimeType));
     }
     else if (ControllerType != null)
     {
         return(ControllerType.IsInstanceOfType(controller));
     }
     return(true);
 }
 async Task <DocumentView> InternalInitializeView()
 {
     if (viewItem == null)
     {
         try {
             viewItem = await OnInitializeView();
         } catch (Exception ex) {
             LoggingService.LogError("View container initialization failed", ex);
             viewItem = new DocumentViewContent(() => (Control)null);
         }
         // If the view already has a controller bound to it, link it to the new one, so that all
         // events from the view are propagated to the old controller besides the new one.
         if (viewItem.SourceController != null)
         {
             linkedController = viewItem.SourceController;
             linkedController.linkedControllerParent = this;
         }
         viewItem.SourceController = this;
     }
     return(viewItem);
 }
示例#4
0
        public async Task <Document> OpenDocument(DocumentController controller, bool bringToFront = true)
        {
            controller.ServiceProvider = ServiceProvider;

            var docOpenInfo = new DocumentOpenInformation {
                DocumentController = controller
            };

            if (!bringToFront)
            {
                docOpenInfo.Options &= ~OpenDocumentOptions.BringToFront;
            }

            var doc = await ShowView(docOpenInfo);

            if (bringToFront)
            {
                workbench.Present();
            }
            return(doc);
        }
 internal Task Init(DocumentController controller, Properties status)
 {
     Controller = controller;
     return(Initialize(status));
 }
 /// <summary>
 /// Called to check if this controller extension is supported for the provided controller.
 /// If the extension is supported, it will be attached to the controller. If it is not,
 /// it will be disposed and discarded.
 /// </summary>
 /// <returns>True if the extension is supported</returns>
 /// <param name="controller">Controller.</param>
 public virtual Task <bool> SupportsController(DocumentController controller)
 {
     return(Task.FromResult(SourceExtensionNode == null || SourceExtensionNode.Data.CanHandle(controller)));
 }
 public override Task <bool> SupportsController(DocumentController controller)
 {
     return(Task.FromResult(false));
 }
 public override Task <bool> SupportsController(DocumentController controller)
 {
     return(Task.FromResult(controller.Owner?.GetType() == typeof(MyWorkspaceObject)));
 }
 public override Task <bool> SupportsController(DocumentController controller)
 {
     return(Task.FromResult(controller.GetContent <IProducer> () != null));
 }