コード例 #1
0
        private void UpdatePluginList()
        {
            // clear existing list
            listViewInstalledPlugins.Items.Clear();
            imageListPlugins.Images.Clear();

            // re-initialize list
            int imageIndex = 0;

            ContentSourceInfo[] pluginContentSources = ContentSourceManager.PluginContentSources;
            foreach (ContentSourceInfo pluginContentSource in pluginContentSources)
            {
                imageListPlugins.Images.Add(BidiHelper.Mirror(pluginContentSource.Image));
                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag        = pluginContentSource;
                listViewItem.ImageIndex = imageIndex++;
                RefreshListViewItem(listViewItem);
                listViewInstalledPlugins.Items.Add(listViewItem);
            }
            // select first item if possible
            if (listViewInstalledPlugins.Items.Count > 0)
            {
                listViewInstalledPlugins.Items[0].Selected = true;
            }

            // update the details pane
            UpdateDetailsPane();
        }
コード例 #2
0
 private void UpdateListViewItem(ListViewItem listViewItem, LiveClipboardFormatHandler formatHandler)
 {
     imageListFormats.Images.Add(BidiHelper.Mirror((Bitmap)formatHandler.FormatImage));
     listViewItem.Tag        = formatHandler;
     listViewItem.ImageIndex = imageListFormats.Images.Count - 1;
     listViewItem.SubItems.Clear();
     listViewItem.Text = " " + formatHandler.FormatName;
     listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, formatHandler.FormatDescription));
 }
コード例 #3
0
        /// <summary>
        /// Loads a Bitmap from an Assembly's resource stream.
        /// </summary>
        /// <param name="assembly">The Assembly to load the Bitmap from.</param>
        /// <param name="path">The explicit path to the Bitmap, null to use the default.</param>
        /// <param name="resource">The name of the Bitmap to load (i.e. "Image.png").</param>
        public static Bitmap LoadAssemblyResourceBitmap(Assembly assembly, string path, string resource, bool mirror)
        {
            //	If a path was not specified, default to using the name of the assembly.
            if (path == null)
            {
                path = assembly.GetName().Name;
            }

            //	Format the schema resource name that we will load from the assembly.
            string resourceName = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", path, resource);
            string key          = String.Format(CultureInfo.InvariantCulture, "{0},{1}", resourceName, mirror);
            //	Get the bitmap.
            Bitmap bitmap;

            lock (typeof(ResourceHelper))
            {
                //	Initialize the bitmap cache if necessary
                if (bitmapCache == null)
                {
                    bitmapCache = new Dictionary <string, Bitmap>();
                }

                //	Locate the resource name in the bitmap cache.  If found, return it.
                if (!bitmapCache.TryGetValue(key, out bitmap))
                {
                    //	Get a stream on the resource.  If this fails, null will be returned.  This means
                    //	that we could not find the resource in the assembly.
                    using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                    {
                        if (stream != null)
                        {
                            //	Load the bitmap.
                            // Bitmaps require their underlying streams to remain open
                            // for as long as their bitmaps are in use.  We don't want to hold open the
                            // resource stream though, so copy it to a memory stream.
                            bitmap = new Bitmap(StreamHelper.CopyToMemoryStream(stream));

                            if (BidiHelper.IsRightToLeft && mirror)
                            {
                                Bitmap temp = BidiHelper.Mirror(bitmap);
                                bitmap.Dispose();
                                bitmap = temp;
                            }
                        }

                        //	Cache the bitmap.
                        bitmapCache.Add(key, bitmap);
                    }
                }

                //	Done!
                return(bitmap);
            }
        }
コード例 #4
0
        private void UpdateImages()
        {
            if (_normalImage == null)
            {
                return;
            }

            if (RightToLeft == RightToLeft.Yes ^ mirrored)
            {
                _normalImage = BidiHelper.Mirror(_normalImage);
                if (_disabledImage != null)
                {
                    _disabledImage = BidiHelper.Mirror(_disabledImage);
                }
                mirrored = !mirrored;
            }
            Image = Enabled ? _normalImage : (_disabledImage ?? _normalImage);
        }
コード例 #5
0
        private void UpdatePluginList()
        {
            BlogPublishingPluginSettings settings = TemporaryBlogSettings.PublishingPluginSettings;

            List <ContentSourceInfo> plugins = new List <ContentSourceInfo>(
                Join(ContentSourceManager.EnabledPublishNotificationPlugins, ContentSourceManager.EnabledHeaderFooterPlugins));

            plugins.Sort(ContentSourceManager.CreateComparison(settings));

            listViewPlugins.BeginUpdate();
            try
            {
                listViewPlugins.Items.Clear();
                imgListPlugins.Images.Clear();

                foreach (ContentSourceInfo csi in plugins)
                {
                    imgListPlugins.Images.Add(BidiHelper.Mirror(csi.Image));
                    ListViewItem item = new ListViewItem();
                    item.Tag        = csi;
                    item.Text       = " " + csi.Name;
                    item.ImageIndex = imgListPlugins.Images.Count - 1;
                    item.Checked    = settings.IsEnabled(csi.Id) ?? false;
                    listViewPlugins.Items.Add(item);
                }

                if (listViewPlugins.Items.Count > 0)
                {
                    listViewPlugins.Items[0].Selected = true;
                }
            }
            finally
            {
                listViewPlugins.EndUpdate();
            }

            ManageMoveButtons();
        }