예제 #1
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     //string docName = PluginBase.MainForm.CurrentDocument.ToString();
     //if (!isASDocument.IsMatch(docName)) saveHTML.Enabled = false;
     //else saveHTML.Enabled = true;
     //TabbedDocument document = (TabbedDocument)PluginBase.MainForm.CurrentDocument;
     //if (PluginBase.MainForm.EditorMenu == null) return;
     //if (this.copyHTMLItem == null)
     //{
     //    this.copyHTMLItem = new ToolStripMenuItem("Copy as HTML",
     //                               null,
     //                               new EventHandler(this.CopyAsHTML),
     //                               this.settingObject.CopyHTMLShortcut);
     //    PluginBase.MainForm.EditorMenu.Items.Add(this.copyHTMLItem);
     //    PluginBase.MainForm.IgnoredKeys.Add(this.settingObject.CopyHTMLShortcut);
     //}
     //switch (e.Type)
     //{
     //    case EventType.FileClose:
     //        break;
     //    case EventType.FileNew:
     //        break;
     //    case EventType.FileOpen:
     //        break;
     //    case EventType.FileSwitch:
     //        break;
     //}
 }
예제 #2
0
        /**
         * Handles the incoming events
         * Receives only events in EventMask
         */
        public void HandleEvent(object sender, NotifyEvent e)
        {
            switch (e.Type)
            {
            case EventType.ProcessStart:
                this.pluginUI.ClearOutput();
                break;

            case EventType.ProcessEnd:
                if (this.pluginUI.ShowOnProcessEnd && !this.pluginUI.ShowOnOutput)
                {
                    this.pluginUI.DisplayOutput();
                    if (this.MainForm.CurSciControl != null)
                    {
                        this.MainForm.CurSciControl.Focus();
                    }
                }
                break;

            case EventType.LogEntry:
                this.pluginUI.AddLogEntries();
                break;

            case EventType.SettingUpdate:
                this.pluginUI.UpdateSettings();
                break;
            }
        }
예제 #3
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     if (e.Type == EventType.UIStarted)
     {
         String initScript = Path.Combine(PathHelper.BaseDir, "InitScript.cs");
         String autoImport = Path.Combine(PathHelper.BaseDir, "InitMacros.fdm");
         if (File.Exists(initScript))
         {
             String command = "Internal;" + initScript;
             PluginBase.MainForm.CallCommand("ExecuteScript", command);
         }
         if (File.Exists(autoImport))
         {
             List <Macro> macros       = new List <Macro>();
             Object       macrosObject = ObjectSerializer.Deserialize(autoImport, macros, false);
             macros = (List <Macro>)macrosObject;
             this.settingObject.UserMacros.AddRange(macros);
             try { File.Delete(autoImport); }
             catch (Exception ex)
             {
                 ErrorManager.ShowError("Could not delete import file: " + autoImport, ex);
             }
             this.RefreshMacroMenuItems();
         }
         this.RunAutoRunMacros();
     }
 }
예제 #4
0
 /// <summary>
 /// Dispatches an event to the registered event handlers
 /// </summary>
 public static void DispatchEvent(Object sender, NotifyEvent e)
 {
     try
     {
         List <EventObject>[] objectList = GetObjectListCollection();
         for (Int32 i = 0; i < objectList.Length; i++)
         {
             List <EventObject> subObjects = objectList[i];
             for (Int32 j = 0; j < subObjects.Count; j++)
             {
                 EventObject obj = subObjects[j];
                 if ((obj.Mask & e.Type) > 0)
                 {
                     obj.Handler.HandleEvent(sender, e, obj.Priority);
                     if (e.Handled)
                     {
                         return;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
예제 #5
0
 public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         RefreshColors();
     }
 }
예제 #6
0
    //清空关卡
    public void ClearMissions()
    {
        NotifyEvent nEvent = new NotifyEvent(NotifyType.InitializeMission, this.gameObject);

        Debug.Log("I");
        NotificationCenter.getInstance().postNotification(nEvent);
    }
예제 #7
0
        /// <summary>
        /// RGV连接
        /// </summary>
        /// <param name="strServer"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public bool RGVConnect(string strServer, string port)
        {
            try
            {
                rg_Brun = false;
                if (string.IsNullOrEmpty(strServer) || port == "0")
                {
                    return(false);
                }

                IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(strServer), int.Parse(port));
                RgvCliSocket = TimeOutSocket.Connect(ipe, timeOut);

                if (RgvCliSocket != null && RgvCliSocket.Connected)
                {
                    NotifyEvent?.Invoke("RGVConnect", "连接成功");

                    rg_Brun = true;
                    Task.Run(RGVRcv);
                    return(true);
                }
                else
                {
                    NotifyEvent?.Invoke("Break", "连接失败!");
                    return(false);
                }
            }
            catch (SocketException ex)
            {
                NotifyEvent?.Invoke("Break", $"连接失败,异常:{ex.Message}");
                return(false);
            }
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        private void OnSessionEnd(DebugEvent e)
        {
            Cleanup();

            UpdateMenuState(DebuggerState.Stopped);

            NotifyEvent ne = new NotifyEvent(EventType.ProcessEnd);

            EventManager.DispatchEvent(this, ne);

            if (PluginMain.settingObject.SwitchToLayout != null)
            {
                RestoreOldLayout();
            }
            else if (!PluginMain.settingObject.DisablePanelsAutoshow)
            {
                PanelsHelper.watchPanel.Hide();
                PanelsHelper.pluginPanel.Hide();
                PanelsHelper.virtualMachinesPanel.Hide();
                PanelsHelper.breakPointPanel.Hide();
                PanelsHelper.stackframePanel.Hide();
            }

            PanelsHelper.pluginUI.TreeControl.Nodes.Clear();
            PanelsHelper.stackframeUI.ClearItem();
            PanelsHelper.watchUI.Clear();
            PanelsHelper.virtualMachinesUI.ClearItem();
            PluginMain.breakPointManager.ResetAll();
            PluginBase.MainForm.ProgressBar.Visible   = false;
            PluginBase.MainForm.ProgressLabel.Visible = false;
        }
예제 #9
0
 /// <summary>
 /// 发送报文信息
 /// </summary>
 /// <param name="btyData"></param>
 /// <returns></returns>
 private bool RGVSend(byte[] btyData)
 {
     try
     {
         lock (qLock)
         {
             if (RgvCliSocket != null)
             {
                 if (RgvCliSocket.Client.Connected)
                 {
                     RgvCliSocket.Client.Send(btyData);
                     return(true);
                 }
                 else
                 {
                     NotifyEvent?.Invoke("Break", "RGV SendData Fail!");
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (SocketException ex)
     {
         if (RgvCliSocket != null && !RgvCliSocket.Connected)
         {
             Close(RgvCliSocket, rg_Brun);
         }
         NotifyEvent?.Invoke("Break", $"给RGV发送异常,关闭连接,异常状态为{ex.Message}");
         return(false);
     }
 }
예제 #10
0
 /// <summary>
 /// Handles the incoming theming change event and updates.
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         this.ApplyTheming();
     }
 }
예제 #11
0
        private void DebugStarted()
        {
            UpdateMenuState(DebuggerState.Running);

            NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);

            EventManager.DispatchEvent(this, ne);

            PluginBase.MainForm.ProgressBar.Visible   = false;
            PluginBase.MainForm.ProgressLabel.Visible = false;

            if (PluginMain.settingObject.SwitchToLayout != null)
            {
                // save current state
                String oldLayoutFile = Path.Combine(Path.Combine(PathHelper.DataDir, "LuaDebugger"), "oldlayout.ldl");
                PluginBase.MainForm.DockPanel.SaveAsXml(oldLayoutFile);
                PluginBase.MainForm.CallCommand("RestoreLayout", PluginMain.settingObject.SwitchToLayout);
            }
            else if (!PluginMain.settingObject.DisablePanelsAutoshow)
            {
                PanelsHelper.watchPanel.Show();
                PanelsHelper.pluginPanel.Show();
                PanelsHelper.virtualMachinesPanel.Show();
                PanelsHelper.breakPointPanel.Show();
                PanelsHelper.stackframePanel.Show();
            }
        }
예제 #12
0
        /// <summary>
        /// 消息同步
        /// </summary>
        public void WebwxSync()
        {
            var url = string.Format(ApiUrls.WebwxSync, _session.BaseUrl, _session.Sid, _session.Skey, _session.PassTicket);
            var obj = new
            {
                _session.BaseRequest,
                _session.SyncKey,
                rr = ~_timestamp // 注意是按位取反
            };
            var referrer = "https://wx.qq.com/?&lang=zh_CN";
            var response = _httpClient.PostJsonAsync(url, obj.ToJson(), referrer).Result;
            var json     = response.RawText().ToJToken();

            if (json["BaseResponse"]["Ret"].ToString() == "0")
            {
                _session.SyncKey = json["SyncCheckKey"];
                var list    = json["AddMsgList"].ToObject <List <Message> >();
                var newMsgs = list.Where(m => m.MsgType != MessageType.WxInit).ToList();
                newMsgs.ForEach(m =>
                {
                    m.FromUser = _store.ContactMemberDic.GetOrDefault(m.FromUserName);
                    _context.FireNotifyAsync(NotifyEvent.CreateEvent(NotifyEventType.Message, m));
                });
            }
        }
예제 #13
0
        /// <summary>
        /// 开启状态通知
        /// </summary>
        /// <returns></returns>
        public bool StatusNotify()
        {
            var url = string.Format(ApiUrls.StatusNotify, _session.BaseUrl, _session.PassTicket);
            var obj = new
            {
                _session.BaseRequest,
                Code         = 3,
                FromUserName = _session.UserToken["UserName"],
                ToUserName   = _session.UserToken["UserName"],
                ClientMsgId  = _timestamp
            };
            var response = _httpClient.PostJsonAsync(url, obj.ToJson()).Result;
            var str      = response.RawText();

            if (!str.IsNullOrEmpty())
            {
                var json = JObject.Parse(str);
                if (json["BaseResponse"]["Ret"].ToString() == "0")
                {
                    return(true);
                }
                else
                {
                    var error = json["BaseResponse"]["ErrMsg"].ToString();
                    _context.FireNotifyAsync(NotifyEvent.CreateEvent(NotifyEventType.Error, "开启状态通知失败"));
                }
            }
            return(false);
        }
예제 #14
0
        void updater_Tick(object sender, EventArgs e)
        {
            updater.Stop();
            string          src     = File.Exists(logFile) ? File.ReadAllText(logFile) : "";
            MatchCollection matches = reError.Matches(src);

            TextEvent te;

            if (matches.Count == 0)
            {
                te = new TextEvent(EventType.ProcessEnd, "Done(0)");
                EventManager.DispatchEvent(this, te);
                if (!te.Handled)
                {
                    PlaySWF();
                }
                return;
            }

            NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);

            EventManager.DispatchEvent(this, ne);
            foreach (Match m in matches)
            {
                string file = m.Groups["file"].Value;
                string line = m.Groups["line"].Value;
                string desc = m.Groups["desc"].Value.Trim();
                TraceManager.Add(String.Format("{0}:{1}: {2}", file, line, desc), -3);
            }
            te = new TextEvent(EventType.ProcessEnd, "Done(" + matches.Count + ")");
            EventManager.DispatchEvent(this, te);

            (PluginBase.MainForm as Form).Activate();
            (PluginBase.MainForm as Form).Focus();
        }
예제 #15
0
 /// <summary>
 /// 获取报文信息
 /// </summary>
 private void RGVRcv()
 {
     byte[] btyBuffer = new byte[byteLength];
     while (rg_Brun)
     {
         try
         {
             if (RgvCliSocket != null)
             {
                 if (RgvCliSocket.Client.Connected)
                 {
                     for (int i = 0; i < byteLength; i++)
                     {
                         btyBuffer[i] = 0;
                     }
                     //读取接收到的报文赋值给btyBuffer
                     int nLen = RgvCliSocket.Client.Receive(btyBuffer);
                     if (nLen > 0)
                     {
                         NotifyEvent?.Invoke("RecvData", btyBuffer);
                     }
                 }
             }
         }
         catch (SocketException ex)
         {
             if (RgvCliSocket != null)
             {
                 Close(RgvCliSocket, rg_Brun);
             }
             NotifyEvent?.Invoke("Break", $"RGV连接中断!{ex.Message}");
         }
     }
 }
예제 #16
0
 public void Notify(NotifyStatus status)
 {
     if (NotifyEvent != null)
     {
         NotifyEvent.Invoke(this, new NotifyEventArgs(status));
     }
 }
예제 #17
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            if (e.Type == EventType.FileSwitch)
            {
                if (controlClickManager != null)
                {
                    controlClickManager.SciControl = PluginBase.MainForm.CurrentDocument.SciControl;
                }
            }
            else if (e.Type == EventType.ApplySettings)
            {
                if (!PluginBase.MainForm.IgnoredKeys.Contains(settingObject.OpenResourceShortcut))
                {
                    PluginBase.MainForm.IgnoredKeys.Add(settingObject.OpenResourceShortcut);
                }

                if (!PluginBase.MainForm.IgnoredKeys.Contains(settingObject.QuickOutlineShortcut))
                {
                    PluginBase.MainForm.IgnoredKeys.Add(settingObject.QuickOutlineShortcut);
                }

                findFilesMenuItem.ShortcutKeys    = settingObject.OpenResourceShortcut;
                quickOutlineMenuItem.ShortcutKeys = settingObject.QuickOutlineShortcut;
            }
        }
예제 #18
0
        // Receives only eventMask events
        public void HandleEvent(object sender, NotifyEvent e)
        {
            if (e.Type == EventType.FileOpen)
            {
                string path      = MainForm.CurFile;
                string extension = Path.GetExtension(path);

                if (extension.ToLower() == ".swf")
                {
                    DisplaySwf(MainForm.CurFile);
                }
            }
            else if (e.Type == EventType.Command)
            {
                TextEvent te = e as TextEvent;
                if (te.Text.StartsWith(COMMAND_POPUPSWF))
                {
                    string[] split  = te.Text.Split(';');
                    string   path   = split[2];
                    int      width  = int.Parse(split[3]);
                    int      height = int.Parse(split[4]);
                    PopupSwf(path, width, height);
                }
            }
        }
예제 #19
0
 public Form1()
 {
     InitializeComponent();
     // This is 'registering' the ButtonClickedOnForm2 method to the delegate.
     // So, when the delegate is invoked (called), this method gets executed.
     notifyDelegate += new NotifyEvent(ButtonClickedOnForm2);
 }
예제 #20
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.FileSwitch:
            case EventType.SyntaxChange:
                XMLComplete.CurrentFile = PluginBase.MainForm.CurrentDocument.FileName;
                break;

            case EventType.Completion:
                if (XMLComplete.Active)
                {
                    e.Handled = true;
                }
                return;

            case EventType.Keys:
                e.Handled = XMLComplete.OnShortCut(((KeyEvent)e).Value);
                break;

            case EventType.Command:
                DataEvent de = (DataEvent)e;
                if (XMLComplete.Active && !settingObject.DisableZenCoding &&
                    de.Action == "SnippetManager.Expand")
                {
                    Hashtable data = (Hashtable)de.Data;
                    if (ZenCoding.expandSnippet(data))
                    {
                        de.Handled = true;
                    }
                }
                break;
            }
        }
예제 #21
0
파일: PluginMain.cs 프로젝트: sgml/vizzy
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     try
     {
         String[] args = PluginBase.MainForm.StartArguments;
         for (int i = 0; i < args.Length; i++)
         {
             String arg = args[i];
             if (arg == "-line")
             {
                 if (args.Length >= i + 1)
                 {
                     Int32 line = Int32.Parse(args[i + 1]) - 1;
                     if (PluginBase.MainForm.CurrentDocument != null)
                     {
                         ScintillaNet.ScintillaControl Sci = PluginBase.MainForm.CurrentDocument.SciControl;
                         int pos = Sci.PositionFromLine(line);
                         int end = Sci.LineEndPosition(line);
                         Sci.BeginInvoke((MethodInvoker) delegate
                         {
                             Sci.SetSel(pos, end);
                             Sci.ScrollCaret();
                         });
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
예제 #22
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            StartType startType = this.settingObject.TrackingStartType;

            switch (e.Type)
            {
            case EventType.UIStarted:
            {
                if (startType == StartType.OnProgramStart)
                {
                    this.pluginUI.EnableTracking(true);
                }
                break;
            }

            case EventType.Command:
            {
                DataEvent de = (DataEvent)e;
                if (startType == StartType.OnBuildComplete && de.Action == "ProjectManager.BuildComplete")
                {
                    this.pluginUI.EnableTracking(true);
                }
                break;
            }
            }
        }
예제 #23
0
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.Keys:
                e.Handled = HandleKeys(((KeyEvent)e).Value);
                return;

            case EventType.FileSave:
                MessageBar.HideWarning();
                return;

            case EventType.Command:
                string cmd = (e as DataEvent).Action;
                if (cmd.IndexOfOrdinal("ProjectManager") > 0 ||
                    cmd.IndexOfOrdinal("Changed") > 0 ||
                    cmd.IndexOfOrdinal("Context") > 0 ||
                    cmd.IndexOfOrdinal("ClassPath") > 0 ||
                    cmd.IndexOfOrdinal("Watcher") > 0 ||
                    cmd.IndexOfOrdinal("Get") > 0 ||
                    cmd.IndexOfOrdinal("Set") > 0 ||
                    cmd.IndexOfOrdinal("SDK") > 0)
                {
                    return;     // ignore notifications
                }
                break;
            }
            // most of the time, an event should hide the list
            OnUIRefresh(null);
        }
 protected virtual void NotifyEventHandler(NotifyEvent handler, NotifyEventArgs args)
 {
     if (handler != null)
     {
         handler(this, args);
     }
 }
예제 #25
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.FileOpen:
                TextEvent fo = e as TextEvent;
                if (fo != null)
                {
                    this.pluginUI.CreateDocument(fo.Value);
                }
                break;

            case EventType.FileClose:
                TextEvent fc = e as TextEvent;
                if (fc != null)
                {
                    this.pluginUI.CloseDocument(fc.Value);
                }
                break;

            case EventType.ApplySettings:
                this.pluginUI.UpdateSettings();
                break;

            case EventType.FileEmpty:
                this.pluginUI.CloseAll();
                break;
            }
        }
예제 #26
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            switch (e.Type)
            {
            case EventType.FileSwitch:
                this.UpdateMenuItems();
                break;

            case EventType.Command:
                DataEvent de = (DataEvent)e;
                if (de.Action == "CodeRefactor.Menu")
                {
                    ToolStripMenuItem mainMenu = (ToolStripMenuItem)de.Data;
                    this.AttachMainMenuItem(mainMenu);
                    this.UpdateMenuItems();
                }
                else if (de.Action == "CodeRefactor.ContextMenu")
                {
                    ToolStripMenuItem contextMenu = (ToolStripMenuItem)de.Data;
                    this.AttachContextMenuItem(contextMenu);
                    this.UpdateMenuItems();
                }
                break;
            }
        }
예제 #27
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.UIStarted:
                DirectoryNode.OnDirectoryNodeRefresh += OnDirectoryNodeRefresh;
                break;

            case EventType.Command:
                var da = (DataEvent)e;
                switch (da.Action)
                {
                case ProjectManagerEvents.Project:
                    if (PluginBase.CurrentProject != null)
                    {
                        ReadBuildFiles();
                    }
                    pluginUI.RefreshData();
                    break;

                case ProjectManagerEvents.TreeSelectionChanged:
                    OnTreeSelectionChanged();
                    break;
                }
                break;
            }
        }
예제 #28
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     switch (e.Type)
     {
     /*
      * // Catches FileSwitch event and displays the filename it in the PluginUI.
      * case EventType.FileSwitch:
      *  string fileName = PluginBase.MainForm.CurrentDocument.FileName;
      *  pluginUI.Output.Text += fileName + "\r\n";
      *  TraceManager.Add("Switched to " + fileName); // tracing to output panel
      *  break;
      *
      * // Catches Project change event and display the active project path
      * case EventType.Command:
      *  string cmd = (e as DataEvent).Action;
      *  if (cmd == "ProjectManager.Project")
      *  {
      *      IProject project = PluginBase.CurrentProject;
      *      if (project == null)
      *          pluginUI.Output.Text += "Project closed.\r\n";
      *      else
      *          pluginUI.Output.Text += "Project open: " + project.ProjectPath + "\r\n";
      *  }
      *  break;
      */
     case EventType.FileSave:
         FileSavedHandler();
         break;
     }
 }
예제 #29
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            switch (e.Type)
            {
            case EventType.Command:
                DataEvent de = (DataEvent)e;
                switch (de.Action)
                {
                case ProjectManager.ProjectManagerEvents.Project:
                    // Close pluginPanel if the user has the setting checked and a project is opened
                    if (de.Data != null & this.startPage != null)
                    {
                        if (this.settingObject.CloseOnProjectOpen)
                        {
                            this.startPage.Close();
                        }
                        if (this.startPage != null)
                        {
                            // The project manager does not update recent projects until after
                            // it broadcasts this event so we'll wait a little bit before refreshing
                            Timer timer = new Timer();
                            timer.Interval = 100;
                            timer.Tick    += delegate { timer.Stop(); if (!this.startPageWebBrowser.IsDisposed)
                                                        {
                                                            this.startPageWebBrowser.SendProjectInfo();
                                                        }
                            };
                            timer.Start();
                        }
                    }
                    break;
                }
                break;

            case EventType.FileEmpty:
                if ((this.justOpened & (this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.Always || this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.NotRestoringSession)) || this.settingObject.ShowStartPageInsteadOfUntitled)
                {
                    this.ShowStartPage();
                    this.justOpened = false;
                    e.Handled       = true;
                }
                break;

            case EventType.RestoreSession:
                ISession session = ((DataEvent)e).Data as ISession;
                if (session.Type != SessionType.Startup)
                {
                    return;                                          // handle only startup sessions
                }
                if (this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.Always)
                {
                    e.Handled = true;
                }
                else if (session.Files.Count > 0)
                {
                    this.justOpened = false;
                }
                break;
            }
        }
예제 #30
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.FileEmpty:
                if ((this.justOpened & (this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.Always || this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.NotRestoringSession)) || this.settingObject.ShowStartPageInsteadOfUntitled)
                {
                    this.ShowStartPage();
                    this.justOpened = false;
                    e.Handled       = true;
                }
                break;

            case EventType.RestoreSession:
                ISession session = ((DataEvent)e).Data as ISession;
                if (session.Type != SessionType.Startup)
                {
                    return;                                          // handle only startup sessions
                }
                if (this.settingObject.ShowStartPageOnStartup == ShowStartPageOnStartupEnum.Always)
                {
                    e.Handled = true;
                }
                else if (session.Files.Count > 0)
                {
                    this.justOpened = false;
                }
                break;
            }
        }
예제 #31
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.ProcessStart:
                this.pluginUI.ClearOutput(null, null);
                break;

            case EventType.ProcessEnd:
                if (this.settingObject.ShowOnProcessEnd && !this.settingObject.ShowOnOutput)
                {
                    this.pluginUI.DisplayOutput();
                }
                break;

            case EventType.Trace:
                this.pluginUI.AddTraces();
                if (this.settingObject.ShowOnOutput)
                {
                    this.pluginUI.DisplayOutput();
                }
                break;

            case EventType.Keys:
                Keys keys = (e as KeyEvent).Value;
                e.Handled = this.pluginUI.OnShortcut(keys);
                break;

            case EventType.ApplySettings:
                this.pluginUI.ApplyWrapText();
                break;
            }
        }
예제 #32
0
 /// <summary>
 /// Processes the trace queue
 /// </summary>
 private static void ProcessQueue()
 {
     lock (asyncQueue)
     {
         if (PluginBase.MainForm.ClosingEntirely) return;
         traceLog.AddRange(asyncQueue);
         asyncQueue.Clear();
         synchronizing = false;
     }
     NotifyEvent ne = new NotifyEvent(EventType.Trace);
     EventManager.DispatchEvent(null, ne);
 }
예제 #33
0
 /// <summary>
 /// Dispatches an event to the registered event handlers
 /// </summary>
 public static void DispatchEvent(Object sender, NotifyEvent e)
 {
     try 
     {
         List<EventObject>[] objectList = GetObjectListCollection();
         for (Int32 i = 0; i < objectList.Length; i++)
         {
             List<EventObject> subObjects = objectList[i];
             for (Int32 j = 0; j < subObjects.Count; j++)
             {
                 EventObject obj = subObjects[j];
                 if ((obj.Mask & e.Type) > 0)
                 {
                     obj.Handler.HandleEvent(sender, e, obj.Priority);
                     if (e.Handled) return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
예제 #34
0
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
                case EventType.Keys:
                    e.Handled = HandleKeys(((KeyEvent)e).Value);
                    return;

                case EventType.FileSave:
                    MessageBar.HideWarning();
                    return;

                case EventType.Command:
                    string cmd = (e as DataEvent).Action;
                    if (cmd.IndexOfOrdinal("ProjectManager") > 0
                        || cmd.IndexOfOrdinal("Changed") > 0
                        || cmd.IndexOfOrdinal("Context") > 0
                        || cmd.IndexOfOrdinal("ClassPath") > 0
                        || cmd.IndexOfOrdinal("Watcher") > 0
                        || cmd.IndexOfOrdinal("Get") > 0
                        || cmd.IndexOfOrdinal("Set") > 0
                        || cmd.IndexOfOrdinal("SDK") > 0)
                        return; // ignore notifications
                    break;
            }
            // most of the time, an event should hide the list
            OnUIRefresh(null);
        }
예제 #35
0
            /// <summary>Read events from the inotify handle into the supplied array.</summary>
            /// <param name="events">The array into which events should be read.</param>
            /// <returns>The number of events read and stored into the array.</returns>
            private bool TryReadEvent(out NotifyEvent notifyEvent)
            {
                Debug.Assert(_buffer != null);
                Debug.Assert(_bufferAvailable >= 0 && _bufferAvailable <= _buffer.Length);
                Debug.Assert(_bufferPos >= 0 && _bufferPos <= _bufferAvailable);

                // Read more data into our buffer if we need it
                if (_bufferAvailable == 0 || _bufferPos == _bufferAvailable)
                {
                    // Read from the handle.  This will block until either data is available
                    // or all watches have been removed, in which case zero bytes are read.
                    unsafe
                    {
                        try
                        {
                            _bufferAvailable = (int)SysCall(fd => {
                                long result;
                                fixed (byte* buf = _buffer)
                                {
                                    result = (long)Interop.libc.read(fd, buf, (IntPtr)_buffer.Length);
                                }
                                Debug.Assert(result <= _buffer.Length);
                                return result;
                            });
                        }
                        catch (ArgumentException)
                        {
                            _bufferAvailable = 0;
                            Debug.Fail("Buffer provided to read was too small");
                        }
                        Debug.Assert(_bufferAvailable >= 0);
                    }
                    if (_bufferAvailable == 0)
                    {
                        notifyEvent = default(NotifyEvent);
                        return false;
                    }
                    Debug.Assert(_bufferAvailable >= c_INotifyEventSize);
                    _bufferPos = 0;
                }

                // Parse each event:
                //     struct inotify_event {
                //         int      wd;
                //         uint32_t mask;
                //         uint32_t cookie;
                //         uint32_t len;
                //         char     name[]; // length determined by len; at least 1 for required null termination
                //     };
                Debug.Assert(_bufferPos + c_INotifyEventSize <= _bufferAvailable);
                NotifyEvent readEvent;
                readEvent.wd = BitConverter.ToInt32(_buffer, _bufferPos);
                readEvent.mask = BitConverter.ToUInt32(_buffer, _bufferPos + 4);       // +4  to get past wd
                readEvent.cookie = BitConverter.ToUInt32(_buffer, _bufferPos + 8);     // +8  to get past wd, mask
                int nameLength = (int)BitConverter.ToUInt32(_buffer, _bufferPos + 12); // +12 to get past wd, mask, cookie
                readEvent.name = ReadName(_bufferPos + c_INotifyEventSize, nameLength);  // +16 to get past wd, mask, cookie, len
                _bufferPos += c_INotifyEventSize + nameLength;
                
                notifyEvent = readEvent;
                return true;
            }
예제 #36
0
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         Color fore = PluginBase.MainForm.GetThemeColor("RichToolTip.ForeColor");
         Color back = PluginBase.MainForm.GetThemeColor("RichToolTip.BackColor");
         toolTip.BackColor = back == Color.Empty ? SystemColors.Info : back;
         toolTip.ForeColor = fore == Color.Empty ? SystemColors.InfoText : fore;
         toolTipRTB.ForeColor = fore == Color.Empty ? SystemColors.InfoText : fore;
         toolTipRTB.BackColor = back == Color.Empty ? SystemColors.Info : back;
     }
 }
예제 #37
0
        private void button1_Click(object sender, EventArgs e)
        {
            vk start = new vk();
            if (checkBox1.Checked) // если флажон для статуса
            {
                SetStatus setStatus = new SetStatus(start.setStatus);
                IAsyncResult res1 = setStatus.BeginInvoke(richTextBox1.Text, null, null);
                res1.AsyncWaitHandle.WaitOne(2000);
                if (setStatus.EndInvoke(res1).IndexOf("error") != -1)
                {
                    NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                    this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                }
                //start.setStatus(richTextBox1.Text);
            }
            else // если для записи на стене
            {
                string name = "";

                if (checkBox2.Checked) // если нужно изображение, загружаем
                {
                    OpenFileDialog open = new OpenFileDialog();
                    open.FileName = "";
                    open.Filter = "Изображения|*.jpg;*.gif;*.png";

                    if (open.ShowDialog() == DialogResult.OK)
                    {
                        UploadFile upload = new UploadFile(start.UploadFile);
                        IAsyncResult res11 = upload.BeginInvoke(ID, open.FileName, null, null);

                        int iter = 0;

                        while (!res11.IsCompleted)
                        {
                            iter++;
                            if (iter == 500)
                            {
                                iter = 0;
                                Application.DoEvents();
                            }
                        }

                        res11.AsyncWaitHandle.WaitOne();

                        name = upload.EndInvoke(res11);
                    }

                    if (name == "")
                    {
                        NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                        this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                    }
                }

                if (ID != 0) // не себе
                {
                    if (name != "")
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, name, ID);
                    }
                    else
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, "", ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, "", ID);
                    }
                }
                else // себе
                {
                    if (name != "")
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, name, ID);
                    }
                    else
                    {
                        SetStatus setWallStatus = new SetStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text);
                    }
                }
            }
            this.Close();
        }
예제 #38
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            text = textbox[(uint)(myTabControl1.SelectedTab.Tag)].Text;
            textbox[(uint)(myTabControl1.SelectedTab.Tag)].Text = "";

            if (!string.IsNullOrEmpty(text.Trim())) // Если textBox не пустой, то печатаем сообщение в richTextBox, а затем отправляем
            {
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionStart = richtbox[Convert.ToUInt32(myTabControl1.SelectedTab.Tag)].Text.Length;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionLength = 0;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionFont = new Font(FontFamily.GenericSerif, 8, FontStyle.Bold);
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionColor = Color.FromArgb(0, 0, 255);

                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectedText = "Я (" + DateTime.Now.ToShortTimeString() + " " + DateTime.Now.ToShortDateString() + ")";
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionStart = richtbox[(uint)(myTabControl1.SelectedTab.Tag)].Text.Length;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionLength = 0;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionFont = new Font(FontFamily.GenericSerif, 9, FontStyle.Regular);
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionColor = Color.Black;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectedText = "\r\n" + text + "\r\n";
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionStart = richtbox[(uint)(myTabControl1.SelectedTab.Tag)].Text.Length;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionLength = 0;
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectionFont = new Font(FontFamily.GenericSerif, 4, FontStyle.Regular);
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].SelectedText = "\r\n";
                richtbox[(uint)(myTabControl1.SelectedTab.Tag)].ScrollToCaret();

                if (vars.VARS.Out_message_on && vars.VARS.Sound)
                    GeneralMethods.NotifySound("OutMessage");
            }

            vk start = new vk();

            SendMessage SendMsg = new SendMessage(start.sendMsg);
            IAsyncResult res1 = SendMsg.BeginInvoke(text, (uint)myTabControl1.SelectedTab.Tag, null, null);

            res1.AsyncWaitHandle.WaitOne();

            bool success = SendMsg.EndInvoke(res1);

            if (!success)
            {
                NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                this.Invoke(ShowNotify, "Ошибка!", "Ошибка при отправке!\nПовторите ещё раз!", (uint)0);
            }
        }
예제 #39
0
 void serv_NewStatus(ChangeStatusArgs info)
 {
     if (vars.VARS.Visual_notify && vars.VARS.Notify_online && info.flag == 1) // если визуальные оповещения включены и пользователь онлайн
     {
         NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
         this.Invoke(ShowNotify, vars.VARS.Contact[info.id].UserName, "В сети", info.id); // инвочим для того, чтобы она всплывала
     }
     if (vars.VARS.Visual_notify && vars.VARS.Notify_offline && info.flag == 0) // если визуальные оповещения включены и пользователь оффлайн
     {
         NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
         this.Invoke(ShowNotify, vars.VARS.Contact[info.id].UserName, "Не в сети", info.id);
     }
 }
예제 #40
0
 private void UpdateCounters(object state)
 {
     Hashtable couter = start.getStat();
     if (couter != null)
     {
         if (couter.ContainsKey("friends"))
         {
             if (Convert.ToUInt32(couter["friends"]) > 0)
             {
                 NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                 this.Invoke(ShowNotify, "Новое событие!", "Новый друг", (uint)0);
                 getEvent ShowButton = new getEvent(this.ShowButton);
                 this.button5.Invoke(ShowButton);
             }
         }
         if (couter.ContainsKey("photos"))
         {
             if (Convert.ToUInt32(couter["photos"]) > 0)
             {
                 NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                 this.Invoke(ShowNotify, "Новое событие!", "Новая фотография", (uint)0);
                 getEvent ShowButton = new getEvent(this.ShowButton);
                 this.button5.Invoke(ShowButton);
             }
         }
         if (couter.ContainsKey("videos"))
         {
             if (Convert.ToUInt32(couter["videos"]) > 0)
             {
                 NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                 this.Invoke(ShowNotify, "Новое событие!", "Новое видео", (uint)0);
                 getEvent ShowButton = new getEvent(this.ShowButton);
                 this.button5.Invoke(ShowButton);
             }
         }
         if (couter.ContainsKey("events"))
         {
             if (Convert.ToUInt32(couter["events"]) > 0)
             {
                 NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                 this.Invoke(ShowNotify, "Новое событие!", "Новая встреча", (uint)0);
                 getEvent ShowButton = new getEvent(this.ShowButton);
                 this.button5.Invoke(ShowButton);
             }
         }
     }
     else
     {
         getEvent HideButton = new getEvent(this.HideButton);
         this.button5.Invoke(HideButton);
     }
 }
예제 #41
0
 /// <summary>
 /// Handle the incoming theme events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         Boolean enabled = PluginBase.MainForm.GetThemeFlag("ScrollBar.UseGlobally", false);
         if (enabled && !richTextBox.Parent.Controls.Contains(vScrollBar))
         {
             AddScrollBars();
             UpdateScrollBarTheme();
         }
         else if (!enabled && richTextBox.Parent.Controls.Contains(vScrollBar))
         {
             RemoveScrollBars();
         }
     }
 }
예제 #42
0
        void serv_NewMessage(IncomingMessageArgs info)
        {
            if ((info.flag & 32) == 32 && (info.flag & 2) != 2)
            {
                if (vars.VARS.Visual_notify && vars.VARS.Notify_income)
                {
                    string txt; // текст, который будет отображаться в окошке
                    if (info.text.Length > 20)
                    {
                        txt = info.text.Substring(0, 20);
                        txt += "...";
                    }
                    else
                        txt = info.text;

                    NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                    this.Invoke(ShowNotify, vars.VARS.Contact[info.outID].UserName, txt, info.outID); // инвочим для того, чтобы окно оповещения всплывало
                }
            }
        }
예제 #43
0
 /// <summary>Create <see cref="NotifyCollectionEventArgs"/>.</summary>
 /// <param name="startIndex">Index of first item in modified range.</param>
 /// <param name="endIndex">Index of last item in modified range.</param>
 /// <param name="evt">Change type.</param>
 public NotifyCollectionEventArgs(int startIndex, int endIndex, NotifyEvent evt)
 {
     _startIndex = startIndex;
     _endIndex = endIndex;
     _event = evt;
 }
예제 #44
0
 private void OnNotifyEvent(Agent agent, NotifyEvent ne, string msg)
 {
     this.SafeInvoke(() =>
     {
         if (NotifyEvent.Connected == ne)
         {
             string logger = agent.ToString() + " 已连接";
             this.statusStrip1.Items[1].Text = logger;
             Log.GetLogFile(Program.System).Log(logger);
         }
         else if (NotifyEvent.ConnectError == ne)
         {
             this.statusStrip1.Items[1].Text = msg;
             Log.GetLogFile(Program.System).Log(msg);
         }
         else if (NotifyEvent.ConnectToCountryCenter == ne)
         {
             // this.StartConnectCountryCenter();
             this.listBox1.Items.Add(msg);
             Log.GetLogFile(Program.System).Log(msg);
         }
         else if (NotifyEvent.DisconnectToCountryCenter == ne)
         {
             // this.StopConnectCountryCenter();
             this.listBox1.Items.Add(msg);
             Log.GetLogFile(Program.System).Log(msg);
         }
     });
 }