00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 using System;
00013 using System.Windows.Forms;
00014 using Mcs.Epm.MicrosoftProject.mpFx.Client.Plugins.QueueManagerPlugin.Controls;
00015 using Mcs.Epm.MicrosoftProject.mpFx.Client.Plugins.QueueManagerPlugin.Forms;
00016 using Mcs.Epm.MicrosoftProject.mpFx.Client.Plugins.QueueManagerPlugin.Properties;
00017 using Mcs.Epm.MicrosoftProject.mpFx.Client.Shared;
00018
00019 namespace Mcs.Epm.MicrosoftProject.mpFx.Client.Plugins.QueueManagerPlugin
00020 {
00021 public class QueueManagerPlugin : IMpFxClientPlugin
00022 {
00023 #region Instance Data
00024
00025 private bool _Disposed;
00026 private bool _IsLoaded;
00027 private bool _ToolsDropDownCreated;
00028
00029 private ToolStrip _ToolStrip;
00030 private Form _Parent;
00031 private QueueManagerForm _QueueManagerForm;
00032 private ToolStripDropDownButton _ToolsToolStripDropDownButton;
00033 private ToolStripMenuItem _OpenQueueManagerToolStripMenuItem;
00034 private ToolStripSeparator _FirstSeparator;
00035
00036 #endregion
00037
00038 #region Public Properties
00039
00040 public ProjectServer ProjectServer { get; private set; }
00041
00042 public bool IsMarkedForDeletion {get;set;}
00043
00044 public Guid Guid
00045 {
00046 get
00047 {
00048 return new Guid("{911B6484-C8A0-4df2-80A3-6BBEC0A4470F}");
00049 }
00050 }
00051
00052 public Version Version
00053 {
00054 get
00055 {
00056 return new Version("1.0.0.0");
00057 }
00058 }
00059
00060 public string Implementation {get;set;}
00061
00062 public string Name
00063 {
00064 get
00065 {
00066 return Resources.PluginName;
00067 }
00068 }
00069
00070 public string Description
00071 {
00072 get
00073 {
00074 return Resources.PluginDescription;
00075 }
00076 }
00077
00078 public string Author
00079 {
00080 get
00081 {
00082 return Resources.PluginAuthor;
00083 }
00084 }
00085
00086 public string Tag
00087 {
00088 get
00089 {
00090 return Resources.PluginTag;
00091 }
00092 }
00093
00094 public Uri Preview
00095 {
00096 get
00097 {
00098 return new Uri(Resources.PluginPreview);
00099 }
00100 }
00101
00102 public bool IsLoaded
00103 {
00104 get
00105 {
00106 return _IsLoaded;
00107 }
00108 }
00109
00110 public Form MainForm
00111 {
00112 get
00113 {
00114 return null;
00115 }
00116 }
00117
00118 public UserControl OptionsControl
00119 {
00120 get
00121 {
00122 return new OptionsControl();
00123 }
00124 }
00125
00126 #endregion
00127
00128 #region Public Events
00129
00130 public event OnStatusChangedEventHandler OnStatusChanged;
00131
00132 #endregion
00133
00134 #region Public Methods
00135
00136 public void OnLoad(ProjectServer projectServer, Form parent, ToolStrip toolStrip)
00137 {
00138 Tools.ValidateOnLoadParams(projectServer, parent, toolStrip);
00139
00140 ProjectServer = projectServer;
00141
00142 _Parent = parent;
00143 _ToolStrip = toolStrip;
00144
00145 LoadUserInterface();
00146
00147 _IsLoaded = true;
00148 }
00149
00150 public void OnUnload()
00151 {
00152 UnloadUserInterface();
00153
00154 ProjectServer = null;
00155 _Parent = null;
00156 _ToolStrip = null;
00157
00158 _IsLoaded = false;
00159 }
00160
00161 #endregion
00162
00163 #region Private Methods
00164
00165 private void LoadUserInterface()
00166 {
00167 DoOnStatusChanged(new OnStatusChangedArgs("Creating menu items... "));
00168
00169 UnloadUserInterface();
00170
00171 _ToolsToolStripDropDownButton = Tools.FindToolStripDropDownButtonByText(_ToolStrip, "Tools");
00172
00173 if (_ToolsToolStripDropDownButton == null)
00174 {
00175 _ToolsToolStripDropDownButton = new ToolStripDropDownButton("&Tools");
00176 _ToolsDropDownCreated = true;
00177 }
00178 else
00179 {
00180 _ToolsDropDownCreated = false;
00181 }
00182
00183 _ToolsToolStripDropDownButton.Click += projectsToolStripDropDownButton_Click;
00184
00185 if (_ToolsDropDownCreated)
00186 {
00187 _ToolStrip.Items.Insert(2, _ToolsToolStripDropDownButton);
00188 }
00189
00190 _FirstSeparator = new ToolStripSeparator();
00191
00192 _ToolsToolStripDropDownButton.DropDownItems.Add(_FirstSeparator);
00193
00194 _OpenQueueManagerToolStripMenuItem = new ToolStripMenuItem("&Open Queue Manager...");
00195
00196 _OpenQueueManagerToolStripMenuItem.Click +=_OpenQueueManagerToolStripMenuItem_Click;
00197
00198 _ToolsToolStripDropDownButton.DropDownItems.Add(_OpenQueueManagerToolStripMenuItem);
00199
00200 DoOnStatusChanged(new OnStatusChangedArgs(string.Empty));
00201 }
00202
00203 private void UnloadUserInterface()
00204 {
00205 Tools.DisposeForm(_QueueManagerForm);
00206
00207 if (_ToolsToolStripDropDownButton == null)
00208 {
00209 return;
00210 }
00211 Tools.CleanupToolStripItem(_ToolsToolStripDropDownButton.DropDownItems, _FirstSeparator);
00212 _FirstSeparator = null;
00213
00214 Tools.CleanupToolStripItem(_ToolsToolStripDropDownButton.DropDownItems, _OpenQueueManagerToolStripMenuItem);
00215 _OpenQueueManagerToolStripMenuItem = null;
00216
00217 if (_ToolsDropDownCreated)
00218 {
00219 Tools.CleanupToolStripItem(_ToolsToolStripDropDownButton.DropDownItems, _ToolsToolStripDropDownButton);
00220 _ToolsToolStripDropDownButton = null;
00221 }
00222
00223 _ToolsToolStripDropDownButton = null;
00224 }
00225
00226 #endregion
00227
00228 #region Event Handlers
00229
00230 void _OpenQueueManagerToolStripMenuItem_Click(object sender, EventArgs e)
00231 {
00232 if (_QueueManagerForm == null || _QueueManagerForm.IsDisposed)
00233 {
00234 _QueueManagerForm = new QueueManagerForm(this);
00235 _QueueManagerForm.MdiParent = _Parent;
00236
00237 }
00238 _QueueManagerForm.Show();
00239 }
00240
00241 internal void DoOnStatusChanged(OnStatusChangedArgs args)
00242 {
00243 if (OnStatusChanged != null)
00244 {
00245 OnStatusChanged(this, args);
00246 }
00247 }
00248
00249 void projectsToolStripDropDownButton_Click(object sender, EventArgs e)
00250 {
00251
00252 }
00253
00254 #endregion
00255
00256 #region IDisposable members
00257
00258 ~QueueManagerPlugin()
00259 {
00260 Dispose(false);
00261 }
00262
00263 public void Dispose()
00264 {
00265 Dispose(true);
00266 GC.SuppressFinalize(this);
00267 }
00268
00269 private void Dispose(bool disposing)
00270 {
00271 if (_Disposed)
00272 {
00273 if (disposing)
00274 {
00275 try
00276 {
00277 OnUnload();
00278 }
00279 catch (Exception)
00280 {}
00281 }
00282
00283 _Disposed = true;
00284 }
00285 }
00286
00287 #endregion
00288 }
00289 }