Пример #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);
        }
Пример #2
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);
        }
		void FindDisplayBinding (FilePath fileName, string mimeType, Project ownerProject)
		{
			findingDisplayBinding = true;

			try {
				string mappingKey = lazyFileViewer.GetMappingKey ();

				var fileViewer = OpenWithFileViewer.GetFileViewers (
					fileName,
					mimeType,
					ownerProject).FirstOrDefault (item => item.GetMappingKey () == mappingKey);

				if (fileViewer != null) {
					displayBinding = DisplayBindingFactory.CreateDisplayBinding (
						fileName,
						mimeType,
						fileViewer) as IExternalDisplayBinding;
				}
			} finally {
				findingDisplayBinding = false;
			}
		}