private bool InitializeImages(string path, bool fLoadDefaultOnFail)
        {
            Bitmap bitmap;
            Bitmap bitmap2;

            if (imageStripLarge == null)
            {
                imageStripLarge = new ImageStrip(new Size(0x18, 0x18));
                imageStripSmall = new ImageStrip(new Size(0x10, 0x10));
            }
            if (!string.IsNullOrEmpty(path) && QTButtonBar.LoadExternalImage(path, out bitmap, out bitmap2))
            {
                imageStripLarge.AddStrip(bitmap);
                imageStripSmall.AddStrip(bitmap2);
                bitmap.Dispose();
                bitmap2.Dispose();
                textBoxImgPath.Text = strImageStripPath = path;
                return(true);
            }
            if (fLoadDefaultOnFail)
            {
                bitmap  = Resources_Image.ButtonStrip24;
                bitmap2 = Resources_Image.ButtonStrip16;
                imageStripLarge.AddStrip(bitmap);
                imageStripSmall.AddStrip(bitmap2);
                bitmap.Dispose();
                bitmap2.Dispose();
                textBoxImgPath.Text = strImageStripPath = string.Empty;
            }
            return(false);
        }
 protected override void Dispose(bool disposing)
 {
     if (imageStripLarge != null)
     {
         imageStripLarge.Dispose();
         imageStripLarge = null;
     }
     if (imageStripSmall != null)
     {
         imageStripSmall.Dispose();
         imageStripSmall = null;
     }
     pluginManager = null;
     base.Dispose(disposing);
 }
        public override void CommitConfig()
        {
            List <string> activeIDs = new List <string>();

            WorkingConfig.bbar.ButtonIndexes = CurrentButtons.Select(entry => {
                int p = 0;
                if (entry.PluginInfo != null)
                {
                    p = activeIDs.IndexOf(entry.PluginInfo.PluginID) + 1;
                    if (p == 0)
                    {
                        activeIDs.Add(entry.PluginInfo.PluginID);
                        p = activeIDs.Count;
                    }
                    p <<= 16;
                }
                return(p + entry.Index);
            }).ToArray();
            WorkingConfig.bbar.ActivePluginIDs = activeIDs.ToArray();
            // TODO: Validate image strip

            // MessageBox.Show("image:" + WorkingConfig.bbar.ImageStripPath);

            if (null != WorkingConfig.bbar.ImageStripPath && WorkingConfig.bbar.ImageStripPath.Trim().Length > 0)
            {
                imageStripLarge = new ImageStrip(new Size(24, 24));
                imageStripSmall = new ImageStrip(new Size(16, 16));

                Bitmap bitmap;
                Bitmap bitmap2;
                if (LoadExternalImage(WorkingConfig.bbar.ImageStripPath, out bitmap, out bitmap2))
                {
                    imageStripLarge.AddStrip(bitmap);
                    imageStripSmall.AddStrip(bitmap2);
                    bitmap.Dispose();
                    bitmap2.Dispose();
                    if (Path.GetExtension(WorkingConfig.bbar.ImageStripPath).PathEquals(".bmp"))
                    {
                        imageStripLarge.TransparentColor = imageStripSmall.TransparentColor = Color.Magenta;
                    }
                    else
                    {
                        imageStripLarge.TransparentColor = imageStripSmall.TransparentColor = Color.Empty;
                    }
                }
            }
        }
Beispiel #4
0
 private static void InitializeStaticFields() {
     fInitialized = true;
     if(!QTUtility.IsXP) {
         DefaultButtonIndices = new int[] { 3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 9, 20 };
     }
     else {
         DefaultButtonIndices = new int[] { 
   1, 2, 0, 3, 4, 5, 0, 6, 7, 0, 11, 13, 12, 14, 15, 0, 
   9, 20
  };
     }
     selectiveLablesIndices = new int[] { 1, 3, 6, 7, 9, 0x12 };
     RefreshTexts();
     imageStrip_Large = new ImageStrip(new Size(0x18, 0x18));
     imageStrip_Small = new ImageStrip(new Size(0x10, 0x10));
     ReadSetting();
 }
        public override void InitializeConfig()
        {
            // Initialize the button bar tab.
            imageStripLarge = new ImageStrip(new Size(24, 24));
            imageStripSmall = new ImageStrip(new Size(16, 16));
            if (null != WorkingConfig.bbar.ImageStripPath && WorkingConfig.bbar.ImageStripPath.Length > 0)
            {
                Bitmap bitmap;
                Bitmap bitmap2;
                if (LoadExternalImage(WorkingConfig.bbar.ImageStripPath, out bitmap, out bitmap2))
                {
                    imageStripLarge.AddStrip(bitmap);
                    imageStripSmall.AddStrip(bitmap2);
                    bitmap.Dispose();
                    bitmap2.Dispose();
                    if (Path.GetExtension(WorkingConfig.bbar.ImageStripPath).PathEquals(".bmp"))
                    {
                        imageStripLarge.TransparentColor = imageStripSmall.TransparentColor = Color.Magenta;
                    }
                    else
                    {
                        imageStripLarge.TransparentColor = imageStripSmall.TransparentColor = Color.Empty;
                    }
                }
            }
            else
            {
                using (Bitmap b = Resources_Image.ButtonStrip24)
                {
                    imageStripLarge.AddStrip(b);
                }
                imageStripSmall = new ImageStrip(new Size(16, 16));
                using (Bitmap b = Resources_Image.ButtonStrip16)
                {
                    imageStripSmall.AddStrip(b);
                }
            }

            ButtonPool     = new ObservableCollection <ButtonEntry>();
            CurrentButtons = new ObservableCollection <ButtonEntry>();

            // Create a list of all the plugin buttons.
            int order            = QTButtonBar.INTERNAL_BUTTON_COUNT;
            var lstPluginIDs     = new List <string>();
            var dicPluginButtons = new Dictionary <string, ButtonEntry[]>();

            foreach (PluginInformation pi in PluginManager.PluginInformations.Where(pi => pi.Enabled).OrderBy(pi => pi.Name))
            {
                if (pi.PluginType == PluginType.Interactive)
                {
                    lstPluginIDs.Add(pi.PluginID);
                    dicPluginButtons[pi.PluginID] = new ButtonEntry[] { new ButtonEntry(this, order++, 0, pi) };
                }
                else if (pi.PluginType == PluginType.BackgroundMultiple)
                {
                    Plugin plugin;
                    if (PluginManager.TryGetStaticPluginInstance(pi.PluginID, out plugin))
                    {
                        IBarMultipleCustomItems bmci = plugin.Instance as IBarMultipleCustomItems;
                        try {
                            if (bmci != null && bmci.Count > 0)
                            {
                                lstPluginIDs.Add(pi.PluginID);
                                dicPluginButtons[pi.PluginID] =
                                    bmci.Count.RangeSelect(i => new ButtonEntry(this, order++, i, pi)).ToArray();
                            }
                        }
                        catch { }
                    }
                }
            }

            // Add the current buttons (right pane)
            foreach (int i in WorkingConfig.bbar.ButtonIndexes)
            {
                int pluginIndex = i.HiWord() - 1;
                if (pluginIndex >= 0)
                {
                    string        id = WorkingConfig.bbar.ActivePluginIDs[pluginIndex];
                    ButtonEntry[] buttons;
                    if (dicPluginButtons.TryGetValue(id, out buttons) && i.LoWord() < buttons.Length)
                    {
                        CurrentButtons.Add(buttons[i.LoWord()]);
                    }
                }
                else
                {
                    CurrentButtons.Add(new ButtonEntry(this, i, i));
                }
            }

            // Add the rest of the buttons to the button pool (left pane)
            ButtonPool.Add(new ButtonEntry(this, 0, QTButtonBar.BII_SEPARATOR));
            for (int i = 1; i < QTButtonBar.INTERNAL_BUTTON_COUNT; i++)
            {
                if (!WorkingConfig.bbar.ButtonIndexes.Contains(i))
                {
                    ButtonPool.Add(new ButtonEntry(this, i, i));
                }
            }

            foreach (ButtonEntry entry in lstPluginIDs.SelectMany(pid => dicPluginButtons[pid]).Except(CurrentButtons))
            {
                ButtonPool.Add(entry);
            }
            lstButtonBarPool.ItemsSource    = ButtonPool;
            lstButtonBarCurrent.ItemsSource = CurrentButtons;
        }
 private bool InitializeImages(string path, bool fLoadDefaultOnFail) {
     Bitmap bitmap;
     Bitmap bitmap2;
     if(this.imageStripLarge == null) {
         this.imageStripLarge = new ImageStrip(new Size(0x18, 0x18));
         this.imageStripSmall = new ImageStrip(new Size(0x10, 0x10));
     }
     if(!string.IsNullOrEmpty(path) && QTButtonBar.LoadExternalImage(path, out bitmap, out bitmap2)) {
         this.imageStripLarge.AddStrip(bitmap);
         this.imageStripSmall.AddStrip(bitmap2);
         bitmap.Dispose();
         bitmap2.Dispose();
         this.textBoxImgPath.Text = this.strImageStripPath = path;
         return true;
     }
     if(fLoadDefaultOnFail) {
         bitmap = Resources_Image.ButtonStrip24;
         bitmap2 = Resources_Image.ButtonStrip16;
         this.imageStripLarge.AddStrip(bitmap);
         this.imageStripSmall.AddStrip(bitmap2);
         bitmap.Dispose();
         bitmap2.Dispose();
         this.textBoxImgPath.Text = this.strImageStripPath = string.Empty;
     }
     return false;
 }
 protected override void Dispose(bool disposing) {
     if(this.imageStripLarge != null) {
         this.imageStripLarge.Dispose();
         this.imageStripLarge = null;
     }
     if(this.imageStripSmall != null) {
         this.imageStripSmall.Dispose();
         this.imageStripSmall = null;
     }
     this.pluginManager = null;
     base.Dispose(disposing);
 }
        public override void InitializeConfig() {
            // Initialize the button bar tab.
            imageStripLarge = new ImageStrip(new Size(24, 24));
            using(Bitmap b = Resources_Image.ButtonStrip24) {
                imageStripLarge.AddStrip(b);
            }
            imageStripSmall = new ImageStrip(new Size(16, 16));
            using(Bitmap b = Resources_Image.ButtonStrip16) {
                imageStripSmall.AddStrip(b);
            }
            ButtonPool = new ObservableCollection<ButtonEntry>();
            CurrentButtons = new ObservableCollection<ButtonEntry>();

            // Create a list of all the plugin buttons.
            int order = QTButtonBar.INTERNAL_BUTTON_COUNT;
            var lstPluginIDs = new List<string>();
            var dicPluginButtons = new Dictionary<string, ButtonEntry[]>();
            foreach(PluginInformation pi in PluginManager.PluginInformations.Where(pi => pi.Enabled).OrderBy(pi => pi.Name)) {
                if(pi.PluginType == PluginType.Interactive) {
                    lstPluginIDs.Add(pi.PluginID);
                    dicPluginButtons[pi.PluginID] = new ButtonEntry[] { new ButtonEntry(this, order++, 0, pi) };
                }
                else if(pi.PluginType == PluginType.BackgroundMultiple) {
                    Plugin plugin;
                    if(PluginManager.TryGetStaticPluginInstance(pi.PluginID, out plugin)) {
                        IBarMultipleCustomItems bmci = plugin.Instance as IBarMultipleCustomItems;
                        try {
                            if(bmci != null && bmci.Count > 0) {
                                lstPluginIDs.Add(pi.PluginID);
                                dicPluginButtons[pi.PluginID] = 
                                    bmci.Count.RangeSelect(i => new ButtonEntry(this, order++, i, pi)).ToArray();
                            }
                        }
                        catch { }
                    }
                }
            }

            // Add the current buttons (right pane)
            foreach(int i in WorkingConfig.bbar.ButtonIndexes) {
                int pluginIndex = i.HiWord() - 1;
                if(pluginIndex >= 0) {
                    string id = WorkingConfig.bbar.ActivePluginIDs[pluginIndex];
                    ButtonEntry[] buttons;
                    if(dicPluginButtons.TryGetValue(id, out buttons) && i.LoWord() < buttons.Length) {
                        CurrentButtons.Add(buttons[i.LoWord()]);
                    }
                }
                else {
                    CurrentButtons.Add(new ButtonEntry(this, i, i));
                }
            }

            // Add the rest of the buttons to the button pool (left pane)
            ButtonPool.Add(new ButtonEntry(this, 0, QTButtonBar.BII_SEPARATOR));
            for(int i = 1; i < QTButtonBar.INTERNAL_BUTTON_COUNT; i++) {
                if(!WorkingConfig.bbar.ButtonIndexes.Contains(i)) {
                    ButtonPool.Add(new ButtonEntry(this, i, i));
                }
            }

            foreach(ButtonEntry entry in lstPluginIDs.SelectMany(pid => dicPluginButtons[pid]).Except(CurrentButtons)) {
                ButtonPool.Add(entry);
            }
            lstButtonBarPool.ItemsSource = ButtonPool;
            lstButtonBarCurrent.ItemsSource = CurrentButtons;
        }