Example #1
0
        internal void AddModuleButton(AssistantModule module)
        {
            var descriptor = AssistantModuleDescriptors.GetDescriptor(module.GetType());

            if (ModuleButtons.ContainsKey(descriptor.ModuleType))
                throw new InvalidOperationException("button already exists in the layout");

            Button btn = new Button();
            btn.Size = new Size(80, 80);
            if (descriptor.IconPath != null)
            {
                try
                {
                    btn.BackgroundImageLayout = ImageLayout.Stretch;
                    btn.BackgroundImage = Image.FromFile(descriptor.IconPath);
                }
                catch (Exception _e)
                {
                    Logger.LogError("problem loading module icon", this, _e);
                }
            }
            btn.Click += module.OpenUI;
            toolTip1.SetToolTip(btn, descriptor.Name);
            flowLayoutPanelModules.Controls.Add(btn);

            ModuleButtons.Add(descriptor.ModuleType, btn);

            _contextMenuManager.Rebuild();
        }
Example #2
0
 internal static void AddButton(AssistantModule module)
 {
     AssistantForm.AddModuleButton(module);
 }