Ejemplo n.º 1
0
        public InspectorWrapper(Outlook.Inspector Inspector)
        {
            inspector = Inspector;
            ((Outlook.InspectorEvents_Event)inspector).Close +=
                new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);

            // Main Task Pane
            taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
                new MyUserControlTaskPane(), "Archive Email", inspector);

            taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);

            // Settings Task Pane
            taskPaneSettings = Globals.ThisAddIn.CustomTaskPanes.Add(
                new SettingsPane(), "Settings", inspector);

            taskPaneSettings.VisibleChanged += new EventHandler(TaskPaneSettings_VisibleChanged);

            // Add properties
            taskPane.Width = 320;
            taskPane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
            taskPane.DockPosition         = Office.MsoCTPDockPosition.msoCTPDockPositionRight;

            taskPaneSettings.Width = 320;
            taskPaneSettings.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
            taskPaneSettings.DockPosition         = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
        }
 void Inspectors_NewInspector(Outlook.Inspector Inspector)
 {
     if (Inspector.CurrentItem is Outlook.MailItem)
     {
         inspectorWrappersValue.Add(Inspector, new InspectorWrapper(Inspector));
     }
 }
Ejemplo n.º 3
0
 private void AddAttachmentsButton_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         Outlook.Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
         Outlook.MailItem  mail      = inspector.CurrentItem;
         try
         {
             if (attFileDialog.ShowDialog() == DialogResult.OK)
             {
                 mail.Attachments.Add(attFileDialog.FileNames[0]);
                 mail.Body = $"{mail.Body}{attFileDialog.FileNames[0]}\r\n";
             }
         }
         finally
         {
             if (inspector != null)
             {
                 Marshal.ReleaseComObject(mail);
                 mail = null;
             }
             if (inspector != null)
             {
                 Marshal.ReleaseComObject(inspector);
                 inspector = null;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Ejemplo n.º 4
0
        private Outlook.Inspector m_Window; // wrapped window object

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new instance of the tracking class for a particular 
        /// inspector and custom task pane.
        /// </summary>
        /// <param name="inspector">A new inspector window to track</param>
        ///<remarks></remarks>
        public OutlookInspector(Outlook.Inspector inspector)
        {
            m_Window = inspector;

            // Hookup the close event
            ((Outlook.InspectorEvents_Event)inspector).Close +=
                new Outlook.InspectorEvents_CloseEventHandler(
                OutlookInspectorWindow_Close);

            taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(
                new UserControl1(), "My task pane", m_Window);
            taskPane.Visible = true;
            //  taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);

            // Hookup item-level events as needed
            // For example, the following code hooks up PropertyChange
            // event for a ContactItem
            //OutlookItem olItem = new OutlookItem(inspector.CurrentItem);
            //if(olItem.Class==Outlook.OlObjectClass.olContact)
            //{
            //    m_Contact = olItem.InnerObject as Outlook.ContactItem;
            //    m_Contact.PropertyChange +=
            //        new Outlook.ItemEvents_10_PropertyChangeEventHandler(
            //        m_Contact_PropertyChange);
            //}
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="Inspector"></param>
 public InspectorWrapper(Outlook.Inspector Inspector)
 {
     inspector = Inspector;
     ((Outlook.InspectorEvents_Event)inspector).Close += new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);
     taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new EmailTreeControll(), "for Wylie", inspector);
     taskPane.VisibleChanged += new EventHandler(TaskPane_VisibleChanged);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Create a new instance of the tracking class for a particular
        /// inspector and custom task pane.
        /// </summary>
        /// <param name="inspector">A new inspector window to track</param>
        ///<remarks></remarks>
        public OutlookInspector(Outlook.Inspector inspector)
        {
            Window = inspector;

            // Hookup the close event
            ((Outlook.InspectorEvents_Event)inspector).Close += OutlookInspectorWindow_Close;
        }
        private AppointmentRibbonButton thisRibbon()
        {
            Outlook.Inspector       inspector        = (Outlook.Inspector) this.Context;
            AppointmentRibbonButton individualRibbon = Globals.Ribbons[inspector].AppointmentRibbonButton;

            return(individualRibbon);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 設定したメール情報を取得
        /// </summary>
        public void file_data()
        {
            Dictionary <int, string> dicFile = new Dictionary <int, string>();

            // Inspectorを取得、MailItemを取得、Attchmentを取得
            Outlook.Inspector   ins        = app.ActiveInspector();
            Outlook.MailItem    item       = ins.CurrentItem as Outlook.MailItem;
            Outlook.Attachments attchments = item.Attachments;

            if (attchments.Count == 0)
            {
                MessageBox.Show("添付ファイルなし", AddInsLibrary.Properties.Resources.msgError, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                foreach (Outlook.Attachment attach in attchments)
                {
                    string name         = attach.FileName;
                    string display_name = attach.DisplayName;
                    string path         = attach.GetTemporaryFilePath();
                    string path_name    = attach.PathName;
                    int    hash         = attach.GetHashCode();

                    MessageBox.Show(name + "\r\n" + display_name + "\r\n" + path, AddInsLibrary.Properties.Resources.msgError, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Ejemplo n.º 9
0
        private void newInspector(Outlook.Inspector inspector)
        {
            if (inspector.CurrentItem is Outlook.MailItem)
            {
                // Cast and create wrapper
                Outlook.MailItem mailItem   = inspector.CurrentItem;
                editorWrapper    newWrapper = new editorWrapper(mailItem);

                // Wrapper created, register Application level callbacks
                inspector.Application.ItemSend += (object item, ref bool cancel) =>
                {
                    inspector.CurrentItem.DeferredDeliveryTime = // Implement 30 second delay if enabled
                                                                 (newWrapper.toggleDelay) ? (DateTime.Now).Add(new TimeSpan(0, 0, 30)) : new DateTime(4501, 1, 1);
                };

                // Register Window level callbacks
                ((Outlook.InspectorEvents_10_Event)inspector).Activate += newWrapper.runTimer;
                inspector.Deactivate += newWrapper.pauseTimer;
                ((Outlook.InspectorEvents_10_Event)inspector).Close += () => { editorWrapperCollection.Remove(inspector.GetHashCode()); };

                // Register mail item callbacks
                mailItem.Open          += (ref bool s) => { newWrapper.addInVisible = newWrapper.getTaskPane.Visible = false; }; // Prevent ribbon options from blinking when changing drafts
                mailItem.AttachmentAdd += newWrapper.examineAttachment;
                mailItem.Unload        += newWrapper.deconstructWrapper;

                // That's a wrap
                editorWrapperCollection.Add(inspector.GetHashCode(), newWrapper);
            }
        }
Ejemplo n.º 10
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Application object
            Outlook.Application application = this.Application;
            // Get the Inspector object
            Outlook.Inspectors inspectors = application.Inspectors;
            // Get the active Inspector object
            Outlook.Inspector activeInspector = application.ActiveInspector();
            if (activeInspector != null)
            {
                // Get the title of the active item when the Outlook start.
                MessageBox.Show("Active inspector: " + activeInspector.Caption);
            }

            // ...
            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_AddTextToNewMail);


            // Get the Explorer objects
            Outlook.Explorers explorers = application.Explorers;
            // Get the active Explorer object
            Outlook.Explorer activeExplorer = application.ActiveExplorer();
            if (activeExplorer != null)
            {
                // Get the title of the active folder when the Outlook start.
                MessageBox.Show("Active explorer: " + activeExplorer.Caption);
            }
        }
Ejemplo n.º 11
0
 private void Inspectors_NewInspector(MSOutlook.Inspector Inspector)
 {
     if (Inspector.CurrentItem is MSOutlook.MailItem)
     {
         InspectorWrappers.Add(Inspector, new InspectorWrapper(Inspector, instantLookup));
     }
 }
        public FormRegionControls(Outlook.FormRegion region)
        {
            if (region != null)
            {
                try
                {
                    // Cache a reference to this region, this region's
                    // inspector, and the controls on this region.
                    _inspector  = region.Inspector;
                    _form       = region.Form as UserForm;
                    _ordersText = _form.Controls.Item(_ordersTextBoxName)
                                  as Microsoft.Vbe.Interop.Forms.TextBox;
                    _coffeeList = _form.Controls.Item(_formRegionListBoxName)
                                  as Outlook.OlkListBox;

                    // Fill the listbox with some arbitrary strings.
                    for (int i = 0; i < _listItems.Length; i++)
                    {
                        _coffeeList.AddItem(_listItems[i], i);
                    }
                    _coffeeList.Change += new
                                          Outlook.OlkListBoxEvents_ChangeEventHandler(
                        _coffeeList_Change);
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Ejemplo n.º 13
0
        private void Initialize(object sender, EventArgs e)
        {
            //Globals.ThisAddIn.IsInspectorOpen = true;

            //Debug.WriteLine("Initialize {0:T}", DateTime.Now);
            if (DataAPI.Ready())
            {
                _timerForm.timerApptRibbon.Stop();

                Outlook.Inspector insp = this.Context as Outlook.Inspector;
                if (insp.CurrentItem is Outlook.MailItem)
                {
                    _mail = insp.CurrentItem;
                    _mail.BeforeDelete += new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Item_BeforeDelete);
                    _itemType           = Outlook.OlItemType.olMailItem;
                }
                else if (insp.CurrentItem is Outlook.AppointmentItem)
                {
                    _appt = insp.CurrentItem;
                    _appt.BeforeDelete   += new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Item_BeforeDelete);
                    _appt.PropertyChange += _appt_PropertyChange;
                    _itemType             = Outlook.OlItemType.olAppointmentItem;
                }
                insp = null;
                RefreshTouch();
                SetUI();
            }
            else
            {
                _timerForm.timerApptRibbon.Interval = (_timerForm.timerApptRibbon.Interval * 2);
            }
        }
Ejemplo n.º 14
0
 private void Inspectors_NewInspector(Outlook.Inspector inspector)
 {
     if (inspector.CurrentItem is Outlook.MailItem)
     {
         _inspectorWrappersValue.Add(inspector, new InspectorWrapper(inspector));
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Connect inspector events, hookup the close event.
        /// </summary>
        private void ConnectEvents()
        {
            Outlook.Inspector inspector = _wrapped as Outlook.Inspector;

            // Hookup inspector events
            ((Outlook.InspectorEvents_Event)inspector).Close += new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);
        }
Ejemplo n.º 16
0
 // Only show MyTab when Inspector is in compose mode.
 public bool MyTabInspector_GetVisible(Office.IRibbonControl control)
 {
     if (control.Context is Outlook.Inspector)
     {
         Outlook.Inspector oInsp =
             control.Context as Outlook.Inspector;
         if (oInsp.CurrentItem is Outlook.MailItem)
         {
             Outlook.MailItem oMail =
                 oInsp.CurrentItem as Outlook.MailItem;
             if (oMail.Sent == false)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 17
0
        public FormRegionControls(Outlook.FormRegion region)
        {
            if (region != null)
            {
                try
                {
                    // 缓存对此区域及其
                    // 检查器以及此区域上的控件的引用。
                    _inspector = region.Inspector;
                    _form = region.Form as UserForm;
                    _ordersText = _form.Controls.Item(_ordersTextBoxName)
                        as Microsoft.Vbe.Interop.Forms.TextBox;
                    _coffeeList = _form.Controls.Item(_formRegionListBoxName)
                        as Outlook.OlkListBox;

                    // 使用任意字符串填充此列表框。
                    for (int i = 0; i < _listItems.Length; i++)
                    {
                        _coffeeList.AddItem(_listItems[i], i);
                    }
                    _coffeeList.Change += new
                        Outlook.OlkListBoxEvents_ChangeEventHandler(
                        _coffeeList_Change);
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Ejemplo n.º 18
0
        //
        #endregion

        #region Package Editing
        /// <summary>
        /// Add/Edit Package
        /// </summary>
        /// <param name="inspector"></param>
        internal void AddEditPackage(Outlook.Inspector inspector, string ShareLink)
        {
            MessageInspector objMessageInspector = FindMessageInspector(inspector);

            objMessageInspector.InsertLinksIntoMessageBody(ShareLink);
            //objMessageInspector.AddEditPackage();
        }
Ejemplo n.º 19
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Inspector object
            inspectors = this.Application.Inspectors;

            // Get the active Inspector object
            activeInspector = this.Application.ActiveInspector();
            if (activeInspector != null)
            {
                // Get the title of the active item when the Outlook start.
                Debug.WriteLine("Active inspector: {0}", activeInspector.Caption);
            }

            // Get the Explorer objects
            explorers = this.Application.Explorers;

            // Get the active Explorer object
            activeExplorer = this.Application.ActiveExplorer();
            if (activeExplorer != null)
            {
                // Get the title of the active folder when the Outlook start.
                Debug.WriteLine("Active explorer: {0}", activeExplorer.Caption);
            }

            config.PropertyChanged += Config_PropertyChanged;
            if (config.AddInEnabled)
            {
                addComposingEventHandler();
            }
        }
Ejemplo n.º 20
0
 private Outlook.MailItem ThisEmail()
 {
     Outlook.Application application = Globals.ThisAddIn.Application;
     Outlook.Inspector   inspector   = application.ActiveInspector();
     Outlook.MailItem    myMailItem  = (Outlook.MailItem)inspector.CurrentItem;
     return(myMailItem);
 }
        private void toggleButton_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.Inspector inspector        = (Outlook.Inspector)e.Control.Context;
            InspectorWrapper  inspectorWrapper = Globals.ThisAddIn.InspectorWrappers[inspector];
            CustomTaskPane    taskPane         = inspectorWrapper.CustomTaskPane;
            CustomTaskPane    taskPaneSettings = inspectorWrapper.CustomTaskPaneSettings;

            if (((RibbonToggleButton)sender).Name == "toggleButtonShowTaskPane")
            {
                if (taskPaneSettings != null)
                {
                    taskPaneSettings.Visible = false;
                }

                if (taskPane != null)
                {
                    taskPane.Visible = ((RibbonToggleButton)sender).Checked;
                }
            }
            else if (((RibbonToggleButton)sender).Name == "toggleButtonSettings")
            {
                if (taskPane != null)
                {
                    taskPane.Visible = false;
                }

                if (taskPaneSettings != null)
                {
                    taskPaneSettings.Visible = ((RibbonToggleButton)sender).Checked;
                }
            }
        }
Ejemplo n.º 22
0
        ///
        /// Eventhandler for the Inspector close event
        ///
        private void Inspector_Close()
        {
            // call the Close Method - the derived classes can implement cleanup code
            // by overriding the Close method
            Close();

            // unregister Inspector events
            ((Outlook.InspectorEvents_10_Event)Inspector).Close          -= new Outlook.InspectorEvents_10_CloseEventHandler(Inspector_Close);
            ((Outlook.InspectorEvents_10_Event)Inspector).Activate       -= new Outlook.InspectorEvents_10_ActivateEventHandler(Activate);
            ((Outlook.InspectorEvents_10_Event)Inspector).Deactivate     -= new Outlook.InspectorEvents_10_DeactivateEventHandler(Deactivate);
            ((Outlook.InspectorEvents_10_Event)Inspector).BeforeMaximize -= new Outlook.InspectorEvents_10_BeforeMaximizeEventHandler(BeforeMaximize);
            ((Outlook.InspectorEvents_10_Event)Inspector).BeforeMinimize -= new Outlook.InspectorEvents_10_BeforeMinimizeEventHandler(BeforeMinimize);
            ((Outlook.InspectorEvents_10_Event)Inspector).BeforeMove     -= new Outlook.InspectorEvents_10_BeforeMoveEventHandler(BeforeMove);
            ((Outlook.InspectorEvents_10_Event)Inspector).BeforeSize     -= new Outlook.InspectorEvents_10_BeforeSizeEventHandler(BeforeSize);
            ((Outlook.InspectorEvents_10_Event)Inspector).PageChange     -= new Outlook.InspectorEvents_10_PageChangeEventHandler(PageChange);

            // clean up resources and do a GC.Collect();
            Inspector = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
            // raise the Close event.
            if (Closed != null)
            {
                Closed(Id);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Disconnect inspector events, unhook close event.
        /// </summary>
        protected virtual void DisconnectEvents()
        {
            Outlook.Inspector inspector = _wrapped as Outlook.Inspector;

            // Unhook events from the inspector
            ((Outlook.InspectorEvents_Event)inspector).Close -= new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);
        }
Ejemplo n.º 24
0
        public void OnSendList(Office.Core.IRibbonControl control)
        {
            if (control != null)
            {
                try
                {
                    Outlook.Inspector inspector =
                        (Outlook.Inspector)control.Context;
                    String coffeeText = GetTextFromTaskPane(inspector);

                    // Create a new email from the input parameters, and send it.
                    Outlook._MailItem mi =
                        (Outlook._MailItem)
                        Globals.ThisAddIn.Application.CreateItem(
                            Outlook.OlItemType.olMailItem);
                    mi.Subject = _orderName;
                    mi.Body    = coffeeText;
                    mi.To      = _mailAddressee;
                    mi.Send();

                    // Update the count of orders in the form region.
                    UserInterfaceContainer uiContainer =
                        Globals.ThisAddIn._uiElements.GetUIContainerForInspector(
                            inspector);
                    CultureInfo cultureInfo = new CultureInfo("en-us");
                    uiContainer.FormRegionControls.SetControlText(
                        _ordersTextBoxName, (++_orderCount).ToString(cultureInfo));
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Ejemplo n.º 25
0
 private void ThisAddIn_NewInspector(Outlook.Inspector _inspector)
 {
     if (_inspector.CurrentItem is Outlook.MailItem mailItem)
     {
         new MailWrapper(mailItem, _inspector);
     }
 }
        private static void InsertPspfBodyHeader(Outlook.MeetingItem item, ProtectiveMarking marking)
        {
            Outlook.Inspector inspector  = null;
            dynamic           wordEditor = null;

            try
            {
                inspector  = item.GetInspector;
                wordEditor = inspector.WordEditor;

                AddMarkingHeaderToDocument(marking, wordEditor);

                // Other methods seen to force the edits to persist:
                //item.Display();
                //inspector.Activate(); causes the meeting to pop out a new window and stay open
            }
            finally
            {
                if (wordEditor != null)
                {
                    Marshal.ReleaseComObject(wordEditor);
                }

                if (inspector != null)
                {
                    Marshal.ReleaseComObject(inspector);
                }
            }
        }
Ejemplo n.º 27
0
        private void NewInspector(Outlook.Inspector inspector)
        {
            if (((Outlook.MailItem)inspector.CurrentItem).Sender != null)
            {
                return;
            }

            var thread = new System.Threading.Thread(() => {
                FormSearchAddress form;
                lock (formTable) {
                    if (formTable.ContainsKey(inspector))
                    {
                        return;
                    }
                    form = new FormSearchAddress(inspector);
                    formTable.Add(inspector, form);
                }
                ((Outlook.ItemEvents_10_Event)inspector.CurrentItem).Close += new Outlook.ItemEvents_10_CloseEventHandler(MailClose);
                inspector.BeforeMove += new Outlook.InspectorEvents_10_BeforeMoveEventHandler(InspectorBeforeChange);
                inspector.BeforeSize += new Outlook.InspectorEvents_10_BeforeSizeEventHandler(InspectorBeforeChange);
                form.ShowDialog();
            });

            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();
        }
Ejemplo n.º 28
0
 public void AddLink_OnAction(Office.IRibbonControl control)
 {
     try
     {
         System.Diagnostics.Trace.WriteLine(this.GetType().Name + ": UploadButton clicked");
         WindowWrapper objActiveWindow = new WindowWrapper(Globals.ThisAddIn.Application.ActiveWindow());
         //We would have preferred a consistent design through remoting, but
         //the about dialog is so simple that there is no reason to open it through remoting
         //considering we already have the two modes respectively for settings and options
         UI.SeafileForm frmSeafileForm = new UI.SeafileForm(this.LCID);
         frmSeafileForm.ShowDialog(objActiveWindow);
         if (frmSeafileForm.DialogResult == System.Windows.Forms.DialogResult.OK)
         {
             Outlook.Inspector objInspector = (Outlook.Inspector)control.Context;
             Globals.ThisAddIn.AddInController.AddEditPackage(objInspector, frmSeafileForm.ShareLink);
         }
     }
     catch (Exception Ex)
     {
         System.Diagnostics.Trace.WriteLine(Ex);
         System.Windows.Forms.MessageBox.Show(
             Ex.Message,
             Constants.EditorAppName,
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 29
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Get the Application object
            Outlook.Application application = this.Application;

            // Get the Inspectors objects
            Outlook.Inspectors inspectors = application.Inspectors;

            // Get the active Inspector
            Outlook.Inspector activeInspector = application.ActiveInspector();

            // Get the Explorers objects
            Outlook.Explorers explorers = application.Explorers;

            // Get the active Explorer object
            Outlook.Explorer activeExplorer = application.ActiveExplorer();

            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(
                    Inspectors_AddTextToNewMail);

            // Subscribe to the ItemSend event, that it's triggered when an email is sent
            application.ItemSend +=
                new Outlook.ApplicationEvents_11_ItemSendEventHandler(
                    ItemSend_BeforeSend);

            // Add a new Inspector to the application
            inspectors.NewInspector +=
                new Outlook.InspectorsEvents_NewInspectorEventHandler(
                    Inspectors_RegisterEventWordDocument);
        }
Ejemplo n.º 30
0
        // 我们让公共方法具有此行为,以便
        // 能够独立于 NewInspector 事件调用该行为。
        // 目的是为了允许争用条件,
        // 在此条件下可以在挂钩 NewInspector 事件之前进行
        // 功能区回调。
        public Office.Core.CustomTaskPane CreateTaskPane(
            Outlook.Inspector inspector)
        {
            Office.Core.CustomTaskPane taskpane = null;

            try
            {
                // 创建一个新的任务窗格,并将其宽度设置为与
                // SimpleControl 宽度匹配。
                taskpane = _taskPaneConnector.CreateTaskPane(
                    _controlProgId, _controlTitle, inspector);
                if (taskpane != null)
                {
                    taskpane.Width = 230;

                    // 将任务窗格映射到检查器,并将其缓存
                    // 在集合中。
                    _uiElements.Add(new UserInterfaceContainer(
                                        inspector, taskpane, _ribbonConnector));
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return(taskpane);
        }
        // We factor this behavior out to a public method, so that
        // it can be called independently of the NewInspector event.
        // This is to allow for the race condition where ribbon
        // callbacks can come in before the NewInspector event is
        // hooked up.
        public Office.Core.CustomTaskPane CreateTaskPane(
            Outlook.Inspector inspector)
        {
            Office.Core.CustomTaskPane taskpane = null;

            try
            {
                // Create a new task pane, and set its width to match our
                // SimpleControl width.
                taskpane = _taskPaneConnector.CreateTaskPane(
                    _controlProgId, _controlTitle, inspector);
                if (taskpane != null)
                {
                    taskpane.Width = 230;

                    // Map the task pane to the inspector and cache it
                    // in our collection.
                    _uiElements.Add(new UserInterfaceContainer(
                                        inspector, taskpane, _ribbonConnector));
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return(taskpane);
        }
Ejemplo n.º 32
0
        public static Boolean SendOutlookMail(string recipient, string subject, string body)
        {
            try
            {
                Outlook.Application outlookApp = new Outlook.Application();
                Outlook._MailItem   oMailItem  = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                Outlook.Inspector   oInspector = oMailItem.GetInspector;

                Outlook.Recipients oRecips = (Outlook.Recipients)oMailItem.Recipients;
                Outlook.Recipient  oRecip  = (Outlook.Recipient)oRecips.Add(recipient);
                oRecip.Resolve();

                if (subject != "")
                {
                    oMailItem.Subject = subject;
                }
                if (body != "")
                {
                    oMailItem.Body = body;
                }
                oMailItem.Display(true);
                return(true);
            }
            catch (Exception objEx)
            {
                MessageBox.Show(objEx.ToString());
                return(false);
            }
        }
Ejemplo n.º 33
0
        void inspectors_NewInspector(Outlook.Inspector Inspector)
        {
            try
            {
                // When a new Inspector opens, create a task pane and attach
                // it to this Inspector. Also add the task pane<-->Inspector
                // mapping to the collection.
                Office.CustomTaskPane taskPane = taskPaneFactory.CreateCTP(
                    "TestOutlook2007Addin.SimpleControl", taskPaneTitle,
                    Inspector);
                inspectorPanes.Add(taskPane, Inspector);

                // Sink the Close event on this Inspector to make sure the
                // task pane is also destroyed.
                itemEvents =
                    (Outlook.ItemEvents_10_Event)Inspector.CurrentItem;
                InspectorCloseHandler chc =
                    new InspectorCloseHandler(this, taskPane);
                itemEvents.Close +=
                    new Outlook.ItemEvents_10_CloseEventHandler(
                        chc.CloseEventHandler);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// 창을 닫을때 inspector를 초기화
        /// </summary>
        private void InspectorWrapper_Close()
        {
            if (taskPane != null)
            {
                Globals.ThisAddIn.CustomTaskPanes.Remove(taskPane);
            }

            taskPane = null;
            Globals.ThisAddIn.InspectorWrappers.Remove(inspector);
            ((Outlook.InspectorEvents_Event)inspector).Close -= new Outlook.InspectorEvents_CloseEventHandler(InspectorWrapper_Close);
            inspector = null;
        }
Ejemplo n.º 35
0
        public InspectorWrapper(MSOutlook.Inspector Inspector, InstantLookup<MSOutlook.Inspector> InstantLookup)
        {
            inspector = Inspector;
            ((MSOutlook.InspectorEvents_Event)inspector).Activate += InspectorWrapper_Activate;
            ((MSOutlook.InspectorEvents_Event)inspector).Deactivate += InspectorWrapper_Deactivate;
            ((MSOutlook.InspectorEvents_Event)inspector).Close += InspectorWrapper_Close;

            instantLookup = InstantLookup;
            instantLookup.OnLemmaFound += InstantLookup_OnLemmaFound;

            taskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new LookupPane(), "German Grammar", inspector);
            taskPane.Visible = Properties.Settings.Default.LookupPaneVisible;
            taskPane.Width = Properties.Settings.Default.LookupPaneWidth;
            taskPane.Control.Tag = taskPane;
            taskPane.Control.SizeChanged += Control_SizeChanged;
        }
Ejemplo n.º 36
0
        public UserInterfaceContainer(
            Outlook.Inspector inspector,
            Office.Core.CustomTaskPane taskPane,
            IRibbonConnector ribbonConnector)
        {
            if (inspector != null)
            {
                _inspector = inspector;
                _taskPane = taskPane;
                _ribbonConnector = ribbonConnector;

                // 接收 InspectorClose 事件以便我们能够进行清理。
                _inspectorEvents = (Outlook.InspectorEvents_10_Event)_inspector;
                _inspectorEvents.Close +=
                    new Outlook.InspectorEvents_10_CloseEventHandler(
                    _inspectorEvents_Close);
            }
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Create a new instance of the tracking class for a particular 
        /// inspector and custom task pane.
        /// </summary>
        /// <param name="inspector">A new inspector window to track</param>
        ///<remarks></remarks>
        public OutlookInspector(Outlook.Inspector inspector)
        {
            m_Window = inspector;

            // Hookup the close event
            ((Outlook.InspectorEvents_Event)inspector).Close +=
                new Outlook.InspectorEvents_CloseEventHandler(
                OutlookInspectorWindow_Close);

            // Hookup item-level events as needed
            // For example, the following code hooks up PropertyChange
            // event for a ContactItem
            //OutlookItem olItem = new OutlookItem(inspector.CurrentItem);
            //if(olItem.Class==Outlook.OlObjectClass.olContact)
            //{
            //    m_Contact = olItem.InnerObject as Outlook.ContactItem;
            //    m_Contact.PropertyChange +=
            //        new Outlook.ItemEvents_10_PropertyChangeEventHandler(
            //        m_Contact_PropertyChange);
            //}

        }
Ejemplo n.º 38
0
        void _inspectorEvents_Close()
        {
            // 将我们自身从 UI 对象集合中移除,
            // 解除挂钩关闭事件,然后清理所有引用。
            _inspectorEvents.Close -=
                new Outlook.InspectorEvents_10_CloseEventHandler(
                _inspectorEvents_Close);

            if (InspectorClose != null)
            {
                // 告诉所有侦听方我们正在关闭。
                InspectorClose(this, new EventArgs());
            }

            _inspector = null;
            _inspectorEvents = null;
            _taskPane = null;
            _formRegionControls = null;
            _ribbonConnector = null;
        }
Ejemplo n.º 39
0
 private void MailRibbon_Load(object sender, RibbonUIEventArgs e)
 {
     inspector = Globals.ThisAddIn.Application.ActiveInspector(); ;
 }
Ejemplo n.º 40
0
        void Inspectors_NewInspector(Inspector Inspector)
        {
            if (Inspector.CurrentItem is AppointmentItem)
            {
                AppointmentItem item = Inspector.CurrentItem;

                g_currentAppointItem = item;

                delRecuMeet = false;

                BackUpAppointment bak_app = copyAppointMentItem(item);

                if (!AppSubjectDic.ContainsKey(item))
                {
                    AppSubjectDic.Add(item, bak_app);
                    ThisAddIn.g_log.Debug("AppSubectDic add AppointMentItem");
                }
                else
                {
                    AppSubjectDic[item] = bak_app;
                    ThisAddIn.g_log.Debug("AppointMentItem exists,AppSubjectDic replace AppointMentItem");
                }

                item.PropertyChange += new ItemEvents_10_PropertyChangeEventHandler(Item_Property_Change);
                item.BeforeCheckNames += new ItemEvents_10_BeforeCheckNamesEventHandler(item_BeforeCheckNames);
                ThisAddIn.g_log.Info(item.Subject + " Inspectors_NewInspector Event End");
            }
        }
Ejemplo n.º 41
0
        void Inspectors_NewInspector(Inspector Inspector)
        {
            if (Inspector.CurrentItem is AppointmentItem)
            {
                AppointmentItem item = Inspector.CurrentItem;

                try
                {
                    loginRecipient = item.Recipients[1];
                }
                catch (System.Exception ex)
                {
                    ThisAddIn.g_log.Error(string.Format("loginRecipient is null. because {0}", ex.Message));
                    loginRecipient = null;
                }
                delRecuMeet = false;

                BackUpAppointment bak_app = copyAppointMentItem(item);

                if (!AppSubjectDic.ContainsKey(item))
                {
                    AppSubjectDic.Add(item, bak_app);
                }
                else
                {
                    AppSubjectDic[item] = bak_app;
                }

                item.PropertyChange += new ItemEvents_10_PropertyChangeEventHandler(ThisAddIn.Item_Property_Change);
                item.BeforeCheckNames += new ItemEvents_10_BeforeCheckNamesEventHandler(item_BeforeCheckNames);

            }
        }
Ejemplo n.º 42
0
        private void InspectorWrapper_Close()
        {
            taskPane.Control.SizeChanged -= Control_SizeChanged;
            Globals.ThisAddIn.CustomTaskPanes.Remove(taskPane);
            taskPane = null;

            instantLookup.Paused = true;
            instantLookup.OnLemmaFound -= InstantLookup_OnLemmaFound;
            instantLookup = null;

            Globals.ThisAddIn.InspectorWrappers.Remove(inspector);
            ((MSOutlook.InspectorEvents_Event)inspector).Close -= InspectorWrapper_Close;
            ((MSOutlook.InspectorEvents_Event)inspector).Deactivate -= InspectorWrapper_Deactivate;
            ((MSOutlook.InspectorEvents_Event)inspector).Activate -= InspectorWrapper_Activate;
            inspector = null;

            Properties.Settings.Default.Save(); //need to do this here, as I can't do it in the shutdown of the addon...
        }
Ejemplo n.º 43
0
 void Inspectors_NewInspector(Outlook.Inspector Inspector)
 {
     myInspector = Inspector;
     if (myInspector.CurrentItem is Outlook.MailItem)
     {
         countMail(myInspector.CurrentItem);
         //MessageBox.Show("Inspector!");
     }
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Event Handler for the inspector close event.
        /// </summary>
        private void OutlookInspectorWindow_Close()
        {
            // Unhook events from any item-level instance variables
            //m_Contact.PropertyChange -= 
            //    Outlook.ItemEvents_10_PropertyChangeEventHandler(
            //    m_Contact_PropertyChange);

            // Unhook events from the window
            ((Outlook.InspectorEvents_Event)m_Window).Close -=
                new Outlook.InspectorEvents_CloseEventHandler(
                OutlookInspectorWindow_Close);

            // Raise the OutlookInspector close event
            if (Close != null)
            {
                Close(this, EventArgs.Empty);
            }

            // Unhook any item-level instance variables
            //m_Contact = null;
            m_Window = null;
        }
Ejemplo n.º 45
-1
 void OutlookInspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
 {
     OutlookInspector = (Outlook.Inspector)Inspector;
     if (Inspector.CurrentItem is Outlook.MailItem)
     {
         OutlookMailItem = (Outlook.MailItem)Inspector.CurrentItem;
     }
 }