void ClearAndAddFreshItems() { // reset everything and start fresh with new layout firstTime = true; itemRotate = 0; IGoogleDesktopDisplayPluginHelper helper = (IGoogleDesktopDisplayPluginHelper)this; // we are not going to show any details if we are in the NoWrap layout, instead // we use the 'pinning' feature where user can pin items to stay on top of the // content list GoogleDesktopDisplayContentFlags contentFlags = GoogleDesktopDisplayContentFlags.GDD_CONTENT_FLAG_HAVE_DETAILS; if (contentLayout == GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_NOWRAP_ITEMS) { contentFlags = GoogleDesktopDisplayContentFlags.GDD_CONTENT_FLAG_PINNABLE; } helper.SetFlags(GoogleDesktopDisplayPluginFlags.GDD_PLUGIN_FLAG_NONE, contentFlags); // since we are going to show items with a new layout, remove all old ones helper.RemoveAllContentItems(); ChangeItems(false); }
void Initialize() { // initialize variables totalItemsCreatedCount = 0; contentLayout = GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_EMAIL; totalItemsCreatedCount = 0; showImages = true; isDirty = false; // Load our icons contentIcon1 = ImageConverter.ImageToIpicture(new Icon( Assembly.GetExecutingAssembly().GetManifestResourceStream( "GoogleDesktopDisplayCSharpSample.ico1.ico")).ToBitmap()); contentIcon2 = ImageConverter.ImageToIpicture(new Icon( Assembly.GetExecutingAssembly().GetManifestResourceStream( "GoogleDesktopDisplayCSharpSample.ico2.ico")).ToBitmap()); Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( "GoogleDesktopDisplayCSharpSample.plugin.ico"); Bitmap smallImage = new Icon(stream, 16, 16).ToBitmap(); stream.Seek(0, System.IO.SeekOrigin.Begin); Bitmap largeImage = new Icon(stream, 32, 32).ToBitmap(); // Set plugin information IGoogleDesktopDisplayPluginHelper helper = (IGoogleDesktopDisplayPluginHelper)this; helper.about_text = aboutStr; helper.SetIcons(ImageConverter.ImageToIpicture(smallImage), ImageConverter.ImageToIpicture(largeImage)); UpdateTitle(); }
/// <summary> /// Create content items and add to the display /// </summary> /// <param name="refreshOnly">true if the item counter should not be /// incremented, false if it should be incremented /// </param> void ChangeItems(bool refreshOnly) { // add content to display. int maxItems = (firstTime) ? 1 : 1; firstTime = false; IGoogleDesktopDisplayPluginHelper pluginHelper = (IGoogleDesktopDisplayPluginHelper)this; // Here we show absolute time for items in email layout GoogleDesktopDisplayContentItemFlags itemFlags = GoogleDesktopDisplayContentItemFlags.GDD_CONTENT_ITEM_FLAG_NONE; if (contentLayout == GoogleDesktopDisplayContentItemLayout.GDD_CONTENT_ITEM_LAYOUT_EMAIL) { itemFlags = GoogleDesktopDisplayContentItemFlags.GDD_CONTENT_ITEM_FLAG_TIME_ABSOLUTE; } for (int j = 0, i = itemStart + itemRotate; j < maxItems; ++j, ++i) { // create a new item SamplePluginContentItem curItem = new SamplePluginContentItem(); IGoogleDesktopDisplayContentItemHelper itemHelper = (IGoogleDesktopDisplayContentItemHelper)curItem; // the strings to display, different format for odd and even numbered items String heading = "Line " + i + " line " + i + " line " + i; String source = "Google"; String snippet = "Google doodles with the idea to create noodles to sell on Froogle."; stdole.IPicture image = null; if (showImages) { // use different images for odd and even numbered items bool oddNumberedItem = ((i % 2) == 1); image = (oddNumberedItem) ? contentIcon1 : contentIcon2; } DateTime timeCreated = DateTime.UtcNow; // Show the item in the sidebar and optionally in the notifier window // if the sidebar was auto-hidden. GoogleDesktopContentItemDisplayOptions options = GoogleDesktopContentItemDisplayOptions.GDD_ITEM_DISPLAY_IN_SIDEBAR | GoogleDesktopContentItemDisplayOptions.GDD_ITEM_DISPLAY_AS_NOTIFICATION_IF_SIDEBAR_HIDDEN; pluginHelper.AddContentItem(curItem, options); // do the actual setting of properties itemHelper.heading = heading; itemHelper.tooltip = heading; itemHelper.source = source; itemHelper.time_created = timeCreated; itemHelper.snippet = snippet; itemHelper.flags = itemFlags; itemHelper.image = image; itemHelper.layout = contentLayout; } if (!refreshOnly) { // increment item counter since we are asked to add new content itemRotate = (itemRotate + maxItems) % itemRotateMax; totalItemsCreatedCount += maxItems; } // if we are in minimized mode, update the title with latest info. // displaySite will be null until plugin is fully initialized. if (displaySite != null && displaySite.display_state == GoogleDesktopDisplayTileDisplayState.GDD_TILE_DISPLAY_STATE_MINIMIZED) { UpdateTitle(); } }