private CTHotKeys.MemoryUnit mu_PluginOrProtocol(string name)
        {
            CTHotKeys.MemoryUnit mu = null;

            foreach (var val in CTInterface.DeveloperToolStripMenuItem.DropDownItems)
            {
                if (val is ToolStripMenuItem && ((ToolStripMenuItem)val).Text == name)
                {
                    mu = new CTHotKeys.MemoryUnit(name);
                    mu.SetAssociatedControl = val;
                    return(mu);
                }
            }

            for (int i = 1; i < CTInterface.IA.Segmentation.AutoSetUp.LibTB.Items.Count; i++)
            {
                string str = CTInterface.IA.Segmentation.AutoSetUp.LibTB.Items[i].ToString();
                if (str != name)
                {
                    continue;
                }
                //create memory unit
                mu = new CTHotKeys.MemoryUnit(str);
                //set associated control
                {
                    Button btn = new Button();
                    btn.Tag    = str;
                    btn.Click += CTInterface.HotKays.AutoSetUpBtn_Click;
                    mu.SetAssociatedControl = btn;
                }
                return(mu);
            }

            return(mu);
        }
        public void LoadAccSettings()
        {
            CTHotKeys.MemoryUnit mu;
            dialog.RefreshValues();

            for (int i = 0; i < dialog.SmartButtonsList.Items.Count; i++)
            {
                mu = mu_PluginOrProtocol((string)dialog.SmartButtonsList.Items[i]);

                if (mu == null)
                {
                    mu = new CTHotKeys.MemoryUnit((string)dialog.SmartButtonsList.Items[i]);
                    CTInterface.HotKays.SetAssociatedControl(mu);
                }

                if (mu.GetAssociatedControl == null)
                {
                    continue;
                }

                if (SmartButtonsList.Count <= i)
                {
                    ToolStripButton btn = new ToolStripButton();
                    btn.Click += SmartButton_Click;
                    SmartButtonsList.Add(btn);

                    btn.DisplayStyle = ToolStripItemDisplayStyle.Text;
                    btn.Margin       = new System.Windows.Forms.Padding(3, 1, 3, 2);
                    btn.BackColor    = CTInterface.FileBrowser.TaskBtnColor1;
                    btn.ForeColor    = System.Drawing.Color.Black;
                    btn.Image        = Properties.Resources.Save;
                    CTInterface.taskTS.Items.Add(btn);
                }

                SmartButtonsList[i].Text = mu.GetName;
                SmartButtonsList[i].Tag  = mu;
            }

            for (int i = SmartButtonsList.Count - 1;
                 i > dialog.SmartButtonsList.Items.Count - 1; i--)
            {
                SmartButtonsList[i].Dispose();
                SmartButtonsList.RemoveAt(i);
            }
        }
 private void SmartButton_Click(object sender, EventArgs e)
 {
     CTHotKeys.MemoryUnit mu = (CTHotKeys.MemoryUnit)((ToolStripButton)sender).Tag;
     mu.ActivateAssociatedControl();
 }