Exemplo n.º 1
0
        public void SetAsDefault(FilePath fileName, string mimeType, OpenWithFileViewer fileViewer)
        {
            ClearDefault(fileName, mimeType);

            if (fileViewer == null)
            {
                return;
            }

            var key = GetKey(fileName, mimeType);

            var userDefinedFileViewer = fileViewer as UserDefinedOpenWithFileViewer;

            if (userDefinedFileViewer != null)
            {
                defaultDisplayBindings [key] = userDefinedFileViewer.DisplayBinding;
                userDefinedFileViewer.SetAsDefault();
                return;
            }

            key.IsApplication    = fileViewer.IsApplication;
            key.IsDisplayBinding = fileViewer.IsDisplayBinding;

            mappings [key] = fileViewer.GetMappingKey();

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

            defaultDisplayBindings [key] = displayBinding;
            DisplayBindingService.RegisterRuntimeDisplayBinding(displayBinding);
        }
Exemplo n.º 2
0
        public bool IsCustomDefault(FilePath fileName, string mimeType, OpenWithFileViewer fileViewer)
        {
            var userDefinedFileViewer = fileViewer as UserDefinedOpenWithFileViewer;

            if (userDefinedFileViewer != null)
            {
                return(userDefinedFileViewer.IsDefault);
            }

            string mapping = null;
            var    key     = GetKey(fileName, mimeType);

            if (!mappings.TryGetValue(key, out mapping))
            {
                return(false);
            }

            return(mapping == fileViewer.GetMappingKey());
        }