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