예제 #1
0
        /// <summary>
        /// 作用:单击按钮时触发的事件
        /// 作者:汪建龙
        /// 编写时间:2016年12月20日14:02:05
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (objCommand == null)
                {
                    CreateCommand();
                }

                if ((objCommand as ICommand) != null)
                {
                    ICommand cmd = objCommand as ICommand;
                    cmd.OnClick();

                    ITool tool = cmd as ITool;
                    if (tool != null &&
                        WorkBench.AxToolbarControl != null &&
                        WorkBench.AxToolbarControl.IsDisposed == false)
                    {
                        WorkBench.AxToolbarControl.CurrentTool = tool;
                    }
                }
                else if ((objCommand as ITLWCommand) != null)
                {
                    ITLWCommand cmd = objCommand as ITLWCommand;
                    cmd.OnClick();
                }
            }catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
                // LogManager.Log.LogError(ex.ToString());
            }
        }
예제 #2
0
 /// <summary>
 /// 作用:根据程序集名称和类名
 /// </summary>
 private void CreateCommand()
 {
     try
     {
         if (objCommand == null)
         {
             lock (_objToLock)
             {
                 if (objCommand == null)
                 {
                     object obj = CreateInstance(AssemblyName, ClassName);
                     if (obj is ICommand)
                     {
                         ((ICommand)obj).OnCreate(WorkBench.AxMapControl.Object);
                         if (WorkBench.AxToolbarControl != null)
                         {
                             WorkBench.AxToolbarControl.AddItem(obj);
                         }
                         else if (obj is ITLWCommand)
                         {
                             try
                             {
                                 ITLWCommand cmd = obj as ITLWCommand;
                                 cmd.Init(_parameter);
                             }catch (Exception ex)
                             {
                                 System.Diagnostics.Trace.WriteLine(ex);
                                 //LogManager.Log.LogError(ex.ToString());
                             }
                         }
                         else
                         {
                             obj = null;
                         }
                         objCommand = obj;
                     }
                 }
             }
         }
     }catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex);
         //LogManager.Log.LogError(ex.ToString());
         objCommand = null;
     }
 }
예제 #3
0
        public void Start()
        {
            try
            {
                string configfile = XMLConfigFilePath;
                if (System.IO.File.Exists(configfile))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(configfile);

                    XmlNode xmlNode = xmlDoc.SelectSingleNode("/Workbench/AutoRunCommand");
                    if (xmlNode != null)
                    {
                        XmlNodeList nodes = xmlNode.SelectNodes("CommandClass");
                        foreach (XmlNode node in nodes)
                        {
                            try
                            {
                                string      assemblyName = node.Attributes["AssemblyName"].Value;
                                string      className    = node.Attributes["ClassName"].Value;
                                string      parameter    = node.Attributes["Parameter"].Value;
                                ITLWCommand cmd          = InstanceHelper.CreateInstance(assemblyName, className) as ITLWCommand;
                                if (cmd != null)
                                {
                                    cmd.Init(parameter);
                                    cmd.OnClick();
                                }

                                System.Windows.Forms.Application.DoEvents();
                            }catch (Exception ex)
                            {
                                System.Diagnostics.Trace.WriteLine(ex);
                                //LogManager.Log.LogError(ex.ToString());
                            }
                        }
                    }
                }
            }catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
                //LogManager.Log.LogError(ex.ToString());
            }
        }