2359
|
1 |
using System;
|
|
2 |
using Outlook = Microsoft.Office.Interop.Outlook;
|
|
3 |
|
|
4 |
namespace pEp
|
|
5 |
{
|
|
6 |
/// <summary>
|
|
7 |
/// Stores an Outlook Explorer with connected events.
|
|
8 |
/// </summary>
|
|
9 |
public class WatchedInspector : WatchedWindow
|
|
10 |
{
|
|
11 |
private Outlook.Inspector _Inspector = null;
|
|
12 |
|
|
13 |
/**************************************************************
|
|
14 |
*
|
|
15 |
* Constructors/Destructors
|
|
16 |
*
|
|
17 |
*************************************************************/
|
|
18 |
|
|
19 |
/// <summary>
|
|
20 |
/// Primary constructor.
|
|
21 |
/// </summary>
|
|
22 |
/// <param name="inspector">The inspector to watch.</param>
|
|
23 |
public WatchedInspector(Outlook.Inspector inspector)
|
|
24 |
{
|
|
25 |
this._Inspector = inspector;
|
|
26 |
|
|
27 |
if (this._Inspector != null)
|
|
28 |
{
|
|
29 |
this.ConnectWatchedInspectorEvents();
|
|
30 |
|
|
31 |
// Set mail item
|
|
32 |
this.CurrentMailItem = this._Inspector.CurrentItem as Outlook.MailItem;
|
|
33 |
|
|
34 |
if (this.CurrentMailItem != null)
|
|
35 |
{
|
|
36 |
this.InitializeMailItem();
|
|
37 |
}
|
|
38 |
else
|
|
39 |
{
|
|
40 |
Log.Error("WatchedInspector: Error getting current mail item.");
|
|
41 |
}
|
|
42 |
}
|
|
43 |
}
|
|
44 |
|
|
45 |
#region Properties
|
|
46 |
/// <summary>
|
|
47 |
/// Gets the Inspector that is wrapped by this WatchedInspector
|
|
48 |
/// </summary>
|
|
49 |
public Outlook.Inspector Inspector
|
|
50 |
{
|
|
51 |
get { return this._Inspector; }
|
|
52 |
}
|
|
53 |
|
|
54 |
/// <summary>
|
|
55 |
/// Gets the Explorer that is wrapped by this WatchedExplorer.
|
|
56 |
/// </summary>
|
|
57 |
public override dynamic Window
|
|
58 |
{
|
|
59 |
get { return this.Inspector; }
|
|
60 |
}
|
|
61 |
#endregion
|
|
62 |
|
|
63 |
#region Methods
|
|
64 |
/**************************************************************
|
|
65 |
*
|
|
66 |
* Methods
|
|
67 |
*
|
|
68 |
*************************************************************/
|
|
69 |
|
|
70 |
/// <summary>
|
|
71 |
/// Clean up any resources being used.
|
|
72 |
/// </summary>
|
|
73 |
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
74 |
protected override void Dispose(bool disposing)
|
|
75 |
{
|
|
76 |
if (disposing &&
|
|
77 |
this._Inspector != null)
|
|
78 |
{
|
|
79 |
// Disconnect all events
|
|
80 |
this.DisconnectWatchedInspectorEvents();
|
|
81 |
|
|
82 |
// Set Outlook objects to null
|
|
83 |
this._Inspector = null;
|
|
84 |
|
|
85 |
// Dispose base class
|
|
86 |
base.Dispose();
|
|
87 |
}
|
|
88 |
}
|
|
89 |
|
|
90 |
/// <summary>
|
|
91 |
/// Connects the events for this watched explorer
|
|
92 |
/// </summary>
|
|
93 |
private void ConnectWatchedInspectorEvents()
|
|
94 |
{
|
|
95 |
if (this._Inspector != null)
|
|
96 |
{
|
|
97 |
((Outlook.InspectorEvents_10_Event)this._Inspector).Close += WatchedInspector_Close;
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
/// <summary>
|
|
102 |
/// Disconnects the events from this watched explorer
|
|
103 |
/// </summary>
|
|
104 |
private void DisconnectWatchedInspectorEvents()
|
|
105 |
{
|
|
106 |
if (this._Inspector != null)
|
|
107 |
{
|
|
108 |
((Outlook.InspectorEvents_10_Event)this._Inspector).Close -= WatchedInspector_Close;
|
|
109 |
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
#endregion
|
|
114 |
|
|
115 |
#region Event Handling
|
|
116 |
/**************************************************************
|
|
117 |
*
|
|
118 |
* Event Handling
|
|
119 |
*
|
|
120 |
*************************************************************/
|
|
121 |
|
|
122 |
/// <summary>
|
|
123 |
/// Event handler for when a watched inspector is being closed.
|
|
124 |
/// </summary>
|
|
125 |
private void WatchedInspector_Close()
|
|
126 |
{
|
|
127 |
Globals.ThisAddIn.RemoveFromWatchedInspectors(this);
|
|
128 |
|
|
129 |
this.Dispose();
|
|
130 |
}
|
|
131 |
|
|
132 |
/// <summary>
|
|
133 |
/// Event handler for when the processing of an item in the WatchedInspector has finished.
|
|
134 |
/// </summary>
|
|
135 |
private void Inspector_ProcessingCompleted(object sender, MsgProcessor.ProcessingCompletedEventArgs e)
|
|
136 |
{
|
|
137 |
throw new NotImplementedException();
|
|
138 |
}
|
|
139 |
|
|
140 |
#endregion
|
|
141 |
}
|
|
142 |
}
|