////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region INajmHandlersManager implementation ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // attach handler to HDUs public int OpenSession(Guid guidID, IHDU[] hduList) { int sessionID = -1; if (_loadedAssemblies != null && _loadedAssemblies.ContainsKey(guidID)) { INajmHandler hduHandler = _loadedAssemblies[guidID].Handler; if (hduHandler != null) { if (hduHandler.CanHandle(hduList)) { if (!_form.TabControl.TabPages.ContainsKey(guidID.ToString())) { // create tab page for this handler _form.TabControl.TabPages.Add(guidID.ToString(), hduHandler.Name); TabPage handlerTabPage = _form.TabControl.TabPages[guidID.ToString()]; //set image to be used handlerTabPage.ImageKey = hduHandler.ID.ToString(); // initialize is called ONCE when the handler is attached an HDU for first time. // paenl is passed at this time and will be used for all sessions. hduHandler.Initialize(this, handlerTabPage); } sessionID = hduHandler.OpenSession(hduList); } else { throw new NajmException(string.Format("{0} can't handle these HDUs", hduHandler.Name)); } } } return(sessionID); }
private void UnHookEvents(INajmHandler nh) { // connect events nh.SessionOpened -= new SessionOpenedDelegate(hduHandler_OnSessionOpened); nh.SessionActivated -= new SessionActivatedDelegate(hduHandler_OnSessionActivated); nh.SessionClosed -= new SessionClosedDelegate(hduHandler_OnSessionClosed); nh.NoSessions -= new NoSessionsDelegate(hduHandler_OnNoSessions); nh.SessionDeactivated -= new SessionDeactivatedDelegate(hduHandler_OnSessionDeactivated); }
public void ActivateSession(Guid guid, int session) { if (_loadedAssemblies != null && _loadedAssemblies.ContainsKey(guid)) { INajmHandler hduHandler = _loadedAssemblies[guid].Handler; if (hduHandler != null) { hduHandler.ActivateSession(session); } } }
public void CloseSession(Guid guidID, int sid) { if (_loadedAssemblies != null && _loadedAssemblies.ContainsKey(guidID)) { INajmHandler hduHandler = _loadedAssemblies[guidID].Handler; if (hduHandler != null) { hduHandler.CloseSession(sid); } } }
internal void HandlerButton_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Guid hid = (Guid)((ToolStripButton)sender).Tag; INajmHandler nh = _handlersManager[hid]; if (MessageBox.Show(string.Format("Reload \'{0}\' ?", nh.Name), "Najm", MessageBoxButtons.YesNo) == DialogResult.Yes) { _handlersManager.ReloadHandler(hid); } } }
private INajmHandler LoadAssembly(string assemblyName, string loadParam) { Assembly a = System.Reflection.Assembly.LoadFrom(assemblyName); INajmHandler hduHandler = null; Type[] expTypes = a.GetExportedTypes(); foreach (Type t in expTypes) { if (t != null && t.IsClass && t.GetInterface("Najm.Handlers.Integration.INajmHandler") != null) { hduHandler = (INajmHandler)a.CreateInstance(t.FullName); // add toolstrip button only if its not our default handler if (hduHandler != null) { // call Load on the handler hduHandler.Load(loadParam); if (!hduHandler.ID.Equals(new Guid(DEFAULT_HANDLER_ID))) { // get toolstrip image if handler provide one if (!String.IsNullOrEmpty(hduHandler.ToolstripImageName)) { LoadToolstripImage(a, hduHandler.ToolstripImageName); } // get tooltip _tooltip = hduHandler.Tooltip; } else { _default = true; } break; } } } return(hduHandler); }