示例#1
0
 public ImgDictionary(BaseConfig baseConfig, EImageBW8 img, int index)
 {
     _name  = baseConfig.ToolName + ".Img";
     _img   = img;
     Config = baseConfig;
     Index  = index;
 }
示例#2
0
        private void LoadDLL(string filepath)
        {
            try
            {
                do
                {
                    Assembly assemly    = Assembly.LoadFile(filepath);
                    Type     ParentType = System.Type.GetType("EasyAIO.BaseConfig");
                    Type[]   types      = assemly.GetExportedTypes();
                    foreach (var t in types)
                    {
                        if (t.IsClass && t.IsSubclassOf(ParentType))
                        {
                            BaseConfig obj = (BaseConfig)Activator.CreateInstance(t);

                            break;
                        }
                    }
                } while (false);
            }
            catch
            {
                Console.WriteLine("LoadDLL error!");
            }
        }
示例#3
0
        /// <summary>
        /// 加载指定路径
        /// </summary>
        /// <param name="path">路径</param>
        /// <returns>结果</returns>
        public bool LoadConfig(string path)
        {
            if (Path.GetExtension(path).ToLower() != ".zl")
            {
                MessageBox.Show("图像处理工具加载失败,文件类型不正确,请设置.zl文件路径", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            if (!File.Exists(path))
            {
                return(false);
            }
            stg = BinarySerializer.DeSerialize <SaveTaskGroup>(path);
            if (stg != null)
            {
                //移除现有处理
                foreach (TabPage item in tabctrl_task.TabPages)
                {
                    tabctrl_task.TabPages.Remove(item);
                    item.Dispose();
                }
                while (tasks.Count > 0)
                {
                    tasks[0] = null;
                    tasks.RemoveAt(0);
                }
                //添加新处理
                for (int i = 0; i < stg.ConfigGroup.Count; i++)
                {
                    string   name = stg.ConfigGroup[i].TaskName;
                    Task     t;
                    TreeView tree = CreatePage(name, out t);
                    t.configGroup = stg.ConfigGroup[i];
                    t.CreateEvents();
                    if (t.Events.Count != t.configGroup.CfgGroup.Count)
                    {
                        Console.WriteLine("加载工具个数不正确");
                    }
                    for (int j = 0; j < t.configGroup.CfgGroup.Count; j++)
                    {
                        BaseConfig cb = t.configGroup.CfgGroup[j];
                        TreeNode   tn = new TreeNode(cb.ToolName);
                        tn.Tag             = t.Events[j];
                        tn.StateImageIndex = 0;
                        tree.Nodes.Add(tn);
                    }
                }
                //RunTask();
            }
            else
            {
                //MessageBox.Show(String.Format("图像处理工具加载失败,请使用{0}版本库打开当前文件。", stg.DllVersion), "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                stg = new SaveTaskGroup();
            }

            return(true);
        }
示例#4
0
        internal BaseEvent CreateEvent(BaseConfig config)
        {
            BaseEvent       baseEvent = null;
            Assembly        ass       = null;
            AbstractFactory factory   = null;

            try
            {
                string assemblyName = config.FactoryTypeName.Substring(0, config.FactoryTypeName.IndexOf('.'));
                ass = Assembly.Load(assemblyName);

                if (ass != null)
                {
                    factory = (AbstractFactory)ass.CreateInstance(config.FactoryTypeName);
                    if (factory != null)
                    {
                        baseEvent = factory.CreateEvent(this);
                        if (baseEvent != null)
                        {
                            baseEvent.Config = config;
                            Events.Add(baseEvent);

                            if (baseEvent is ICamera)
                            {
                                ICamera cam = baseEvent as ICamera;
                                Cameras.Add(cam);
                            }
                        }
                        else
                        {
                            Console.WriteLine("加载" + config.ToolName + "出错!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("加载" + config.ToolName + "工厂出错!");
                    }
                }
                else
                {
                    Console.WriteLine("加载程序集出错!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("加载" + config.FactoryTypeName + "出错!\r\n" + e.Message);
            }
            return(baseEvent);
        }
示例#5
0
        /// <summary>
        /// 添加工具
        /// </summary>
        /// <param name="assemly">引用的工具类库</param>
        public static void AddTool(Assembly assemly)
        {
            Type ParentType = System.Type.GetType("EasyAIO.BaseConfig");

            Type[] types = assemly.GetExportedTypes();
            foreach (var t in types)
            {
                if (t.IsClass && t.IsSubclassOf(ParentType))
                {
                    BaseConfig obj = (BaseConfig)Activator.CreateInstance(t);
                    ToolList.Add(new ToolFactory(obj.ToolName, obj.FactoryTypeName));
                    break;
                }
            }
        }
示例#6
0
 /// <summary>
 /// 添加工具
 /// </summary>
 /// <param name="config"></param>
 public static void AddTool(BaseConfig config)
 {
     ToolList.Add(new ToolFactory(config.ToolName, config.FactoryTypeName));
 }