Пример #1
0
 public void CreatePad()
 {
     if (Altaxo.Current.Dispatcher.InvokeRequired)
     {
         throw new InvalidOperationException("This action could trigger pad creation and is only valid on the main thread!");
     }
     if (!padContentCreated)
     {
         padContentCreated = true;
         try
         {
             if (addIn != null)
             {
                 Current.Log.Debug("Creating pad " + Class + "...");
                 padContent = (IPadContent)addIn.CreateObject(Class);
                 padContent.PadDescriptor = this;
             }
             else
             {
                 padContent = (IPadContent)Activator.CreateInstance(padType);
                 padContent.PadDescriptor = this;
             }
             if (padContent is IMVCController mvcPadContent && padContent.ViewObject == null)
             {
                 Current.Gui.FindAndAttachControlTo(mvcPadContent);
             }
         }
         catch (Exception ex)
         {
             MessageService.ShowException(ex, "Error creating pad instance");
         }
     }
 }
Пример #2
0
        public void CreatePad()
        {
#if DEBUG
            if (WorkbenchSingleton.InvokeRequired)
            {
                throw new InvalidOperationException("This action could trigger pad creation and is only valid on the main thread!");
            }
#endif
            if (!padContentCreated)
            {
                padContentCreated = true;
                try
                {
                    if (addIn != null)
                    {
                        LoggingService.Debug("Creating pad " + Class + "...");
                        padContent = (IPadContent)addIn.CreateObject(Class);
                    }
                    else
                    {
                        padContent = (IPadContent)Activator.CreateInstance(padType);
                    }
                }
                catch (Exception ex)
                {
                    MessageService.ShowError(ex, "Error creating pad instance");
                }
            }
        }
Пример #3
0
 public ICountingAlgorithm GetAlgorithm()
 {
     if (cachedAlgorithm == null)
     {
         cachedAlgorithm = (ICountingAlgorithm)addIn.CreateObject(className);
     }
     return(cachedAlgorithm);
 }
Пример #4
0
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            Debug.Assert(Class != null && Class.Length > 0);
            IPadContent pad = AddIn.CreateObject(Class) as IPadContent;

            pad.Shortcut = shortcut;

            return(pad);
        }
Пример #5
0
        /// <summary>
        /// Creates an item with the specified sub items. And the current
        /// Condition status for this item.
        /// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            Debug.Assert(Class != null && Class.Length > 0);
            IAlgorithm algorithm = (IAlgorithm)AddIn.CreateObject(Class);

            algorithm.CodeFiles = codeFiles;
            AssignValues();
            algorithm.LastLines = lastLines1;
            return(algorithm);
        }
Пример #6
0
        /// <summary>
        /// Creates an item with the specified sub items. And the current
        /// Condition status for this item.
        /// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            MenuCommand newItem = null;

            object o = null;

            if (Class != null)
            {
                o = AddIn.CreateObject(Class);
            }
            if (o != null)
            {
                if (o is IMenuCommand)
                {
                    IMenuCommand menuCommand = (IMenuCommand)o;
                    menuCommand.Owner = owner;

                    newItem = new SdMenuCommand(conditions, owner, Label, menuCommand);
                }
            }

            if (newItem == null)
            {
                MenuCommand menuCommand = new SdMenuCommand(conditions, owner, Label);
                if (subItems != null && subItems.Count > 0)
                {
                    foreach (object item in subItems)
                    {
                        if (item != null && item is MenuCommand)
                        {
                            menuCommand.MenuCommands.Add((MenuCommand)item);
                        }
                    }
                }
                newItem = menuCommand;
            }


            if (Shortcut != null && newItem is SdMenuCommand)
            {
                try
                {
                    foreach (string key in this.shortcut)
                    {
                        ((SdMenuCommand)newItem).Shortcut |= (System.Windows.Forms.Shortcut)Enum.Parse(typeof(System.Windows.Forms.Shortcut), key);
                    }
                }
                catch (Exception)
                {
                    ((SdMenuCommand)newItem).Shortcut = System.Windows.Forms.Shortcut.None;
                }
            }
            newItem.Enabled = true;             //action != ConditionFailedAction.Disable;
            return(newItem);
        }
Пример #7
0
 public void CreatePad()
 {
                 #if DEBUG
     if (WorkbenchSingleton.InvokeRequired)
     {
         throw new InvalidOperationException("This action could trigger pad creation and is only valid on the main thread!");
     }
                 #endif
     if (!padContentCreated)
     {
         padContentCreated = true;
         if (addIn != null)
         {
             padContent = (IPadContent)addIn.CreateObject(Class);
         }
         else
         {
             padContent = (IPadContent)Activator.CreateInstance(padType);
         }
     }
 }
Пример #8
0
 public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
 {
     return(AddIn.CreateObject(Class));
 }
Пример #9
0
 public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
 {
     Debug.Assert(Class != null && Class.Length > 0);
     return(AddIn.CreateObject(Class));
 }
 public ITestFramework Create(string className)
 {
     return(addin.CreateObject(className) as ITestFramework);
 }
Пример #11
0
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            SdMenuCommand       newItem             = null;
            StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));

            object o = null;

            if (Class != null)
            {
                o = AddIn.CreateObject(Class);                //说明当前菜单项是没有子菜单项�?即它有自己的功能,其功能由Class类具体实�?这种菜单项也是最常见�?
            }
            if (o != null)
            {
                if (o is ISubmenuBuilder)
                {
                    return(((ISubmenuBuilder)o).BuildSubmenu(owner));
                }

                if (o is IMenuCommand)
                {
                    newItem = new SdMenuCommand(stringParserService.Parse(Label), new EventHandler(new MenuEventHandler(owner, (IMenuCommand)o).Execute));
                    if (beginGroup == "true")
                    {
                        newItem.BeginGroup = true;
                    }
                }
            }

            if (newItem == null)
            {            //说明当前菜单项既不是Link类型�?也没有指出其Class属�?所以有可能是一个包含子菜单的菜单项.
                newItem = new SdMenuCommand(stringParserService.Parse(Label));
                if (subItems != null && subItems.Count > 0)
                {                //判断是否有子菜单�?
                    foreach (object item in subItems)
                    {
                        if (item is ButtonItem)
                        {                        //添加一个子菜单�?
                            newItem.SubItems.Add((ButtonItem)item);
                        }
                        else
                        {                        //添加一组子菜单�?
                            newItem.SubItems.AddRange((ButtonItem[])item);
                        }
                    }
                }
            }

            Debug.Assert(newItem != null);            //到这里为�?newItem即当前菜单项不应该为空了.

            if (Icon != null)
            {            //为菜单设置Icon.
                ResourceService ResourceService = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
                newItem.Image = ResourceService.GetBitmap(Icon);
            }
            newItem.Description = description;

            newItem.MouseEnter += new EventHandler(newItem_MouseEnter);
            newItem.MouseLeave += new EventHandler(newItem_MouseLeave);

            if (Shortcut != null)
            {            //为菜单设置Shortcut.
                try
                {
                    newItem.Shortcuts.Add((eShortcut)Enum.Parse(eShortcut.F1.GetType(), Shortcut));
                }
                catch (Exception)
                {
                }
            }

            return(newItem);           //最后返回当前菜单项.
        }
        /// <summary>
        /// Creates an item with the specified sub items. And the current
        /// Condition status for this item.
        /// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
            IDialogPanelDescriptor newItem             = null;
            StringParserService    stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));

            if (subItems == null || subItems.Count == 0)
            {
                if (Class != null)
                {
                    newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label), (IDialogPanel)AddIn.CreateObject(Class));
                }
                else
                {
                    newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label));
                }
            }
            else
            {
                newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label), subItems);
            }
            return(newItem);
        }