public LiveClipboardFormatHandler(LiveClipboardContentSourceAttribute lcAttribute, ContentSourceInfo contentSource) { ResourceManager resMan = new ResourceManager(contentSource.GetType()); string resourceNamePrefix = "LiveClipboardContentSource." + lcAttribute.Name + "."; _format = new LiveClipboardFormat(lcAttribute.ContentType, lcAttribute.Type); _formatName = LoadResourcedString(resMan, resourceNamePrefix + "Name", lcAttribute.Name); _formatDescription = LoadResourcedString(resMan, resourceNamePrefix + "Description", lcAttribute.Description); _formatImagePath = lcAttribute.ImagePath; _contentSource = contentSource; }
public LiveClipboardChangeHandlerForm(LiveClipboardFormatHandler existingHandler) { // // Required for Windows Form Designer support // InitializeComponent(); this.columnHeaderHandler.Text = Res.Get(StringId.ChangeLiveClipboardHandlerComponent); this.buttonOK.Text = Res.Get(StringId.OKButtonText); this.buttonCancel.Text = Res.Get(StringId.CancelButton); this.labelCaption.Text = Res.Get(StringId.ChangeLiveClipboardHandlerCaption); this.Text = Res.Get(StringId.ChangeLiveClipboardHandlerTitle); // save and populate format info _targetFormat = existingHandler.Format; pictureBoxFormatIcon.Image = existingHandler.ContentSource.Image; labelFormatName.Text = existingHandler.FormatName; labelContentType.Text = existingHandler.FriendlyContentType; labelCaption.Text = String.Format(CultureInfo.CurrentCulture, labelCaption.Text, existingHandler.FormatName); // populate the list with content sources that support this format ContentSourceInfo[] contentSources = LiveClipboardManager.GetContentSourcesForFormat(existingHandler.Format); Array.Sort(contentSources, new ContentSourceInfo.NameComparer()); foreach (ContentSourceInfo contentSource in contentSources) { LiveClipboardComponentDisplay componentDisplay = new LiveClipboardComponentDisplay(contentSource); imageListComponents.Images.Add(componentDisplay.Icon); ListViewItem listViewItem = new ListViewItem(); listViewItem.Tag = contentSource; listViewItem.ImageIndex = imageListComponents.Images.Count - 1; listViewItem.Text = " " + componentDisplay.Name; listViewComponents.Items.Add(listViewItem); if (contentSource.Equals(existingHandler.ContentSource)) listViewItem.Selected = true; } }
public override bool Equals(object obj) { LiveClipboardFormat lcFormat = obj as LiveClipboardFormat; return(Id.Equals(lcFormat.Id)); }
private static string GetContentSourceIdForFormat(LiveClipboardFormat format) { using (SettingsPersisterHelper formatSettings = _formatHandlerSettings.GetSubSettings(format.Id)) return formatSettings.GetString(CONTENT_SOURCE_ID, null); }
public static void SetContentSourceForFormat(LiveClipboardFormat format, string contentSourceId) { using (SettingsPersisterHelper formatSettings = _formatHandlerSettings.GetSubSettings(format.Id)) formatSettings.SetString(CONTENT_SOURCE_ID, contentSourceId); }
public static ContentSourceInfo[] GetContentSourcesForFormat(LiveClipboardFormat format) { ArrayList contentSources = new ArrayList(); foreach (ContentSourceInfo contentSourceInfo in ContentSourceManager.ActiveContentSources) { foreach (LiveClipboardFormatHandler supportedFormatHandler in contentSourceInfo.LiveClipboardFormatHandlers) if (supportedFormatHandler.Format.Equals(format)) contentSources.Add(contentSourceInfo); } return contentSources.ToArray(typeof(ContentSourceInfo)) as ContentSourceInfo[]; }
public static ContentSourceInfo FindContentSourceForLiveClipboardFormat(LiveClipboardFormat format) { // see if the preferred content source is noted in the registry string contentSourceId = GetContentSourceIdForFormat(format); if (contentSourceId != null) { // if the content-source is still installed and active then return it ContentSourceInfo contentSourceInfo = ContentSourceManager.FindContentSource(contentSourceId); if (contentSourceInfo != null) return contentSourceInfo; } // didn't find a valid preconfigured entry, scan all sources to see if we've got one foreach (ContentSourceInfo contentSourceInfo in ContentSourceManager.ActiveContentSources) { foreach (LiveClipboardFormatHandler csFormatHandler in contentSourceInfo.LiveClipboardFormatHandlers) { if (csFormatHandler.Format.Equals(format)) { // note that this is now our default SetContentSourceForFormat(format, contentSourceInfo.Id); // return the source return contentSourceInfo; } } } // no match found return null; }
public static ContentSourceInfo FindContentSourceForLiveClipboard(LiveClipboardFormat[] formats) { // formats are supposed to be arranged in order of richness/desirability, // iterate through the formats in this order searching for a content-source // that can handle them foreach (LiveClipboardFormat format in formats) { ContentSourceInfo contentSource = FindContentSourceForLiveClipboardFormat(format); if (contentSource != null) return contentSource; } // didn't find a match return null; }