Esempio n. 1
0
        public void OnViewAction(Office.IRibbonControl control)
        {
            //Event handler for view contacts clicked
            try {
                IssueSelector     ie        = null;
                Outlook.Inspector inspector = (Outlook.Inspector)control.Context;
                if (Globals.ThisAddIn.InspectorWrappers.ContainsKey(inspector))
                {
                    InspectorWrapper     iw  = Globals.ThisAddIn.InspectorWrappers[inspector];
                    Tools.CustomTaskPane ctp = iw.CustomTaskPane;
                    if (ctp != null)
                    {
                        ie = (IssueSelector)ctp.Control;
                    }
                }
                switch (control.Id)
                {
                case "btnRef": if (ie != null)
                    {
                        ie.Refresh();
                    }
                    break;

                case "btnRefC": if (ie != null)
                    {
                        ie.RefreshCache();
                    }
                    break;
                }
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while handling View actions in the Issue Mgt ribbon extension.", ex), true, LogLevel.Error); }
            finally { this.mRibbonUI.Invalidate(); }
        }
Esempio n. 2
0
        //Interface
        public InspectorWrapper(Outlook.Inspector inspector)
        {
            //Constructor
            this.mInspector = inspector;
            ((Outlook.InspectorEvents_Event) this.mInspector).Close += new Outlook.InspectorEvents_CloseEventHandler(OnInspectorClose);

            IssueSelector issueSel = new IssueSelector();

            issueSel.IssueSelected        += new EventHandler(OnIssueCtlIssueSelected);
            issueSel.Error                += new ControlErrorEventHandler(OnIssueCtlError);
            this.mTaskPane                 = Globals.ThisAddIn.CustomTaskPanes.Add(issueSel, ThisAddIn.TASKPANE_TITLE, this.mInspector);
            this.mTaskPane.DockPosition    = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft;
            this.mTaskPane.Visible         = false;
            this.mTaskPane.VisibleChanged += new EventHandler(OnTaskPaneVisibleChanged);
        }
Esempio n. 3
0
 public void OnNavClicked(Office.IRibbonControl control, bool pressed)
 {
     //Event handler for nav toggle button action event
     try {
         Outlook.Inspector inspector = (Outlook.Inspector)control.Context;
         if (Globals.ThisAddIn.InspectorWrappers.ContainsKey(inspector))
         {
             InspectorWrapper     iw  = Globals.ThisAddIn.InspectorWrappers[inspector];
             Tools.CustomTaskPane ctp = iw.CustomTaskPane;
             if (ctp != null)
             {
                 ctp.Visible = pressed;
                 if (ctp.Visible)
                 {
                     IssueSelector s = (IssueSelector)ctp.Control;
                     s.Refresh();
                 }
             }
         }
     }
     catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while handling button click in the Issue Mgt ribbon extension.", ex), true, LogLevel.Error); }
     finally { this.mRibbonUI.Invalidate(); }
 }
Esempio n. 4
0
        public bool OnSetServices(Office.IRibbonControl control)
        {
            //Event handler for contacts enabled event
            bool enabled = false;

            try {
                Tools.CustomTaskPane ctp       = null;
                IssueSelector        ie        = null;
                Outlook.Inspector    inspector = (Outlook.Inspector)control.Context;
                if (Globals.ThisAddIn.InspectorWrappers.ContainsKey(inspector))
                {
                    InspectorWrapper iw = Globals.ThisAddIn.InspectorWrappers[inspector];
                    ctp = iw.CustomTaskPane;
                    if (ctp != null)
                    {
                        ie = (IssueSelector)ctp.Control;
                    }
                }
                switch (control.Id)
                {
                case "btnNav": enabled = true; break;

                case "btnNew": enabled = true; break;

                case "btnAdd": enabled = (ctp != null && ctp.Visible && ie != null && ie.SelectedID > 0); break;

                case "btnRef": enabled = (ctp != null && ctp.Visible); break;

                case "btnRefC": enabled = (ctp != null && ctp.Visible); break;

                case "btnCon": enabled = true; break;
                }
            }
            catch { }
            return(enabled);
        }
Esempio n. 5
0
        public void OnFileAction(Office.IRibbonControl control)
        {
            //Event handler for view contacts clicked
            Outlook.Inspector   insp        = null;
            Outlook.MailItem    m           = null;
            Outlook.Attachments attachments = null;
            Issue issue = null;

            try {
                Tools.CustomTaskPane ctp       = null;
                IssueSelector        ie        = null;
                Outlook.Inspector    inspector = (Outlook.Inspector)control.Context;
                if (Globals.ThisAddIn.InspectorWrappers.ContainsKey(inspector))
                {
                    InspectorWrapper iw = Globals.ThisAddIn.InspectorWrappers[inspector];
                    ctp = iw.CustomTaskPane;
                    if (ctp != null)
                    {
                        ie = (IssueSelector)ctp.Control;
                    }
                }
                switch (control.Id)
                {
                case "btnNew":
                    //Add the current outlook message as an issue action in a new issue
                    //Show explorer if not visible
                    ctp.Visible = true;

                    //Get the current email item and any associated attachments
                    insp        = Globals.ThisAddIn.Application.ActiveInspector();
                    m           = (Outlook.MailItem)insp.CurrentItem;
                    attachments = m.Attachments;

                    //Get a new issue; allow user interaction
                    issue         = CRGFactory.GetIssue(0);
                    issue.Subject = m.Subject;
                    issue.Actions.ActionTable[0].Comment = m.Body;
                    if (new dlgIssue(issue).ShowDialog() == DialogResult.OK)
                    {
                        //Save (create) the new issue
                        issue.Save();
                        if (ie != null)
                        {
                            ie.SelectedID = issue.ID;
                        }
                    }
                    break;

                case "btnAdd":
                    //Add the current outlook message as an issue action
                    issue = ie != null ? ie.SelectedIssue : null;
                    if (issue == null)
                    {
                        App.ReportError(new ApplicationException("Could not determine selected issue."), true, LogLevel.Error);
                    }
                    else
                    {
                        //Get the current email item and any associated attachments
                        insp        = Globals.ThisAddIn.Application.ActiveInspector();
                        m           = (Outlook.MailItem)insp.CurrentItem;
                        attachments = m.Attachments;

                        //Get a new action and add attachments
                        Issue.Action action = issue.Item(0);
                        action.Comment = m.Body;
                        foreach (Outlook.Attachment a in attachments)
                        {
                            Issue.Attachment attachment = action.Item(0);
                            attachment.Filename = CRGFactory.TempFolder + a.FileName;
                            action.Add(attachment);
                        }

                        //Allow user interaction
                        if (new dlgAction(action).ShowDialog() == DialogResult.OK)
                        {
                            //Save selected attachments to TEMP dir
                            foreach (Outlook.Attachment a in attachments)
                            {
                                try {
                                    if (action.Item(CRGFactory.TempFolder + a.FileName) != null)
                                    {
                                        a.SaveAsFile(CRGFactory.TempFolder + a.FileName);
                                    }
                                }
                                catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while saving mail attachments to temporary storage; continuing...", ex), true, LogLevel.Error); }
                            }

                            //Save the action
                            issue.Add(action);
                            ie.SelectedID = issue.ID;
                        }
                    }
                    break;
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while handling File actions in the Issue Mgt ribbon extension.", ex), true, LogLevel.Error); }
            finally { this.mRibbonUI.Invalidate(); }
        }