コード例 #1
0
        public override Main.Common.DTO.CMState ProcessMessage(Main.Common.Wrappers.Wrapper wrapper)
        {
            try
            {
                CMState state = SingletonHandler.ProcessMessage(wrapper);

                if (state.Success)
                {
                    DoLog(string.Format("@{0}:Publishing Wrapper for action {1}: {2} ", SingletonModuleConfiguration.Name, wrapper.GetAction(),
                                        wrapper.ToString()), Main.Common.Util.Constants.MessageType.Debug);
                }
                else
                {
                    DoLog(string.Format("@{0}:Error Publishing Wrapper. Error={1} ",
                                        state.Exception != null ? state.Exception.Message : "",
                                        SingletonModuleConfiguration.Name),
                          Main.Common.Util.Constants.MessageType.Error);
                }

                return(state);
            }
            catch (Exception ex)
            {
                DoLog(string.Format("@{0}:Error Publishing Wrapper. Error={1} ",
                                    ex != null ? ex.Message : "",
                                    SingletonModuleConfiguration.Name),
                      Main.Common.Util.Constants.MessageType.Error);
                throw;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zhaohengheng123/Heng
        private void btnSure_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "请选择..")
            {
                return;
            }
            for (int i = 0; i < Singleton.GetInstance().dicWindows.Count; i++)
            {
                if (i + 1 == WindowNum)
                {
                    continue;
                }
                else if (Singleton.GetInstance().dicWindows[i + 1].WindowName == comboBox1.Text)
                {
                    MessageBox.Show("该窗口已经被监控,请勿重复监控");
                    return;
                }
            }
            Point point = GetWindowPosition(comboBox1.Text);

            SingletonHandler.AddDicWindows(WindowNum, new Window()
            {
                WindowName = comboBox1.Text, IsActive = false, Point = point
            });
            setTitleHandler();
        }
コード例 #3
0
        public override bool Initialize(OnMessageReceived pOnMessageRcv, OnLogMessage pOnLogMsg, string configFile)
        {
            try
            {
                this.OnMessageRcv += pOnMessageRcv;
                this.OnLogMsg     += pOnLogMsg;

                if (LoadConfig(configFile))
                {
                    var singletonHandlerClass = Type.GetType(SingletonModuleConfiguration.SingletonAssembly);
                    if (singletonHandlerClass != null)
                    {
                        SingletonHandler = (ISingletonModule)singletonHandlerClass.GetMethod("GetInstance").Invoke(null, new object[] { pOnLogMsg, SingletonModuleConfiguration.SingletonConfigFile });

                        if (SingletonModuleConfiguration.ModuleDirection == ModuleDirection.Incoming)
                        {
                            SingletonHandler.SetIncomingEvent(pOnMessageRcv);
                        }
                        else if (SingletonModuleConfiguration.ModuleDirection == ModuleDirection.Outgoing)
                        {
                            SingletonHandler.SetOutgoingEvent(pOnMessageRcv);
                        }
                        else
                        {
                            throw new Exception(string.Format("Unkown module direction for {0}", SingletonModuleConfiguration.ModuleDirection));
                        }
                    }
                    else
                    {
                        DoLog("assembly not found: " + SingletonModuleConfiguration.SingletonAssembly, Main.Common.Util.Constants.MessageType.Error);
                        return(false);
                    }

                    return(true);
                }
                else
                {
                    DoLog("Error initializing config file " + configFile, Main.Common.Util.Constants.MessageType.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                DoLog("Critic error initializing " + configFile + ":" + ex.Message, Main.Common.Util.Constants.MessageType.Error);
                return(false);
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: zhaohengheng123/Heng
 private void btnStart_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "请选择..")
     {
         MessageBox.Show("还没有监控窗口!");
         return;
     }
     if (comboBox1.Text.Contains("梦幻西游"))
     {
         MessageBox.Show("先进游戏再监控窗口吧!");
         return;
     }
     //设置启动
     SingletonHandler.EditWindowActive(WindowNum);
     refreshBtn();
     setTitleHandler();
 }