Example #1
0
        public void AddNewApplication(string application, string arguments, string friendlyName)
        {
            var app        = DesktopApplicationFactory.CreateApplication(application, arguments, friendlyName);
            var fileViewer = new UserDefinedOpenWithFileViewer(app);

            fileViewer.IsNew = true;

            fileViewers.Add(fileViewer);
        }
 public static OpenWithDesktopApplicationDisplayBinding CreateDisplayBinding(
     FilePath fileName,
     string mimeType,
     UserDefinedOpenWithFileViewer fileViewer)
 {
     return(new OpenWithDesktopApplicationDisplayBinding(
                fileName,
                mimeType,
                fileViewer.GetApplication(),
                canUseAsDefault: false));
 }
        UserDefinedOpenWithFileViewer CreateUserDefinedFileViewer(
            DisplayBindingMappingKey key,
            string application,
            string displayName,
            string arguments,
            bool isDefault)
        {
            var app        = DesktopApplicationFactory.CreateApplication(application, arguments, displayName);
            var fileViewer = new UserDefinedOpenWithFileViewer(app);

            if (isDefault)
            {
                fileViewer.SetAsDefault();
            }

            return(fileViewer);
        }
        void WriteUserDefinedFileViewer(XmlTextWriter writer, UserDefinedOpenWithFileViewer fileViewer)
        {
            writer.WriteStartElement("UserDefinedFileViewer");

            var app = fileViewer.GetApplication();

            writer.WriteElementString("Application", app.Id);
            writer.WriteElementString("DisplayName", app.DisplayName);

            var externalApp = app as ExternalProcessDesktopApplication;

            writer.WriteElementString("Arguments", externalApp?.Arguments ?? string.Empty);

            writer.WriteElementString("IsDefault", fileViewer.IsDefault.ToString());

            writer.WriteEndElement();
        }
Example #5
0
        public void RemoveUserDefinedViewer(
            FilePath fileName,
            string mimeType,
            UserDefinedOpenWithFileViewer fileViewer)
        {
            List <UserDefinedOpenWithFileViewer> existingFileViewers =
                GetUserDefinedFileViewers(fileName, mimeType);

            var key = GetKey(fileName, mimeType);

            existingFileViewers.Remove(fileViewer);

            if (!existingFileViewers.Any())
            {
                userDefinedFileViewers.Remove(key);
            }

            DisplayBindingService.DeregisterRuntimeDisplayBinding(fileViewer.DisplayBinding);
        }
Example #6
0
        public void AddUserDefinedViewer(
            FilePath fileName,
            string mimeType,
            UserDefinedOpenWithFileViewer fileViewer)
        {
            List <UserDefinedOpenWithFileViewer> existingFileViewers =
                GetUserDefinedFileViewers(fileName, mimeType);

            var key = GetKey(fileName, mimeType);

            fileViewer.IsNew = false;
            existingFileViewers.Add(fileViewer);
            userDefinedFileViewers [key] = existingFileViewers;

            var displayBinding = DisplayBindingFactory.CreateDisplayBinding(fileName, mimeType, fileViewer);

            fileViewer.DisplayBinding = displayBinding;
            DisplayBindingService.RegisterRuntimeDisplayBinding(displayBinding);
        }