-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWin.cs
2558 lines (2130 loc) · 104 KB
/
MainWin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Runtime.InteropServices;
using System.Linq;
using SkiaSharp;
using Play.Interfaces.Embedding;
using Play.Rectangles;
using Play.Edit;
using Play.Parse.Impl;
namespace Mjolnir {
/// <summary>
/// The form where all the other window's live for the Retro (normal) desktop case.
/// </summary>
public partial class MainWin :
Form,
IPgParent,
IPgLoad<XmlElement>,
IPgSave<XmlDocumentFragment>,
IEnumerable<SmartHerderBase>
{
public Font DecorFont { get; } = new Font( "Segoe UI Symbol", 12 ) ?? throw new InvalidOperationException("Main Window could not load Decor font.");
public SolidBrush ToolsBrushActive { get; } = new SolidBrush( Color.FromArgb( 255, 112, 165, 234 ) ) ?? throw new InvalidOperationException("Main Window could not create tools color brush.");
public Font ToolsFont => Document.FontStandard;
readonly SmartGrab _rcFrame = new SmartGrab( new SmartRect( LOCUS.UPPERLEFT, 50, 50, 300, 300 ), 5, true, SCALAR.ALL );
readonly SmartRect _rcMargin = new SmartRect(5); // BUG: This is probably obsolete.
readonly SmartRect _rcSide = new SmartRect(5); // This defines the distance from each edge of the app win to the inside rect.
readonly SmartRect _rcSideSave = new SmartRect(); // Save whatever the side settings where when visible.
readonly SmartRect _rcSideInit = new SmartRect( 250, 34, 250, 100 ); // If a side was closed, this will be it's new side size.
readonly List<SideRect> _rgSideBox = new List<SideRect>(4); // This are the visual slots for our tool windows.
readonly SmartRect _rctDragBounds = new SmartRect( LOCUS.CENTER, 0, 0, 0, 0 ); // Might want to subclass a smartrect with ISmartDrag methods...
ISmartDrag _oDrag = null; // This is our standard drag drop object.
MenuStrip _oTopMenu = null;
ToolStripMenuItem _miRecentsMenu = null;
ToolStripMenuItem _miViewListMenu = null;
ToolStripMenuItem _miDecorMenu = null;
ToolStripMenuItem _miToolsMenu = null;
ToolStripMenuItem _miViewCreate = null;
ContextMenuStrip _oContextMenu = new ContextMenuStrip();
Point _pntContextLocation = new Point(); // context menu object has no activation position! Go figure!
readonly MainWinDecorEnum _oDecorEnum;
readonly Dictionary<string, SmartHerderBase> _rgShepards = new Dictionary<string, SmartHerderBase>();
readonly Dictionary<string, EDGE> _rgSideNames = new Dictionary<string, EDGE>();
readonly ParentRect _oLayout2;
readonly ParentRect _oLayout1;
ViewSlot _oSelectedWinSite = null;
IDocSlot _oSelectedDocSite = null;
protected ViewsEditor _oDoc_ViewSelector;
protected bool _fIsClosing = false;
internal TOPLAYOUT _eLayout = TOPLAYOUT.Solo; // Once layout 1&2 are normalized I won't need this.
protected SCRIPT_FONTPROPERTIES _sDefFontProps = new SCRIPT_FONTPROPERTIES();
protected IntPtr _hScriptCache = IntPtr.Zero;
protected bool _fTextInvalid = true;
public enum TOPLAYOUT {
Solo,
Multi
}
/// <exception cref="ArgumentNullException" />
public MainWin( Program oDocument ) {
Document = oDocument ?? throw new ArgumentNullException( "Main window document is null." );
LayoutStackVertical oStackVirt = new LayoutStackVertical( 5, 10, 100 );
oStackVirt.Add( new LayoutRect( LayoutRect.CSS.Pixels, 0, 10 ) { Hidden = true } ); // Folder tabs.
oStackVirt.Add( new LayoutSelectedView( this ) );
oStackVirt.Add( new LayoutRect( LayoutRect.CSS.Pixels, 0, 10 ) { Hidden = true } ); // Footer.
_oLayout1 = oStackVirt;
_oLayout2 = new LayoutFlowSquare_MainWin( this, 5 );
_oDecorEnum = new MainWinDecorEnum( this );
}
public IPgParent Parentage => Document;
public IPgParent Services => Parentage.Services; // BUG: UUUhhh I think I should return =this=
public Program Document { get; }
public SmartRect Frame { get { return _rcFrame; } }
/// <summary date="4/7/2020" >
/// Honestly this could live right on the main window. But I'm sure the names would
/// collide with the existing view management code on the main window. So I'll put all this
/// here for now.
/// </summary>
public class ControllerForMainWindow : IPgController2, IEnumerable<IPgViewType>
{
MainWin _oMainWin;
public ControllerForMainWindow( MainWin oMainWin ) {
_oMainWin = oMainWin ?? throw new ArgumentNullException();
}
public string PrimaryExtension => string.Empty;
public IDisposable CreateDocument(IPgBaseSite oSite, string strExtension) {
try {
if( string.Compare( strExtension, ".views" ) == 0 )
return new ViewsEditor( oSite );
} catch( Exception oEx ) {
Type[] rgErrors = { typeof( InvalidCastException ),
typeof( ArgumentException ),
typeof( NullReferenceException ),
typeof( ArgumentNullException ) };
_oMainWin.LogError( oSite, "hosting", "Guest does not support required interfaces.");
if( rgErrors.IsUnhandled( oEx ) )
throw;
}
return null;
}
/// <summary>
/// This is a new use for a controller. So it's a bit confusing. The main window is
/// basically the controller. The Document parameter is the document within the MainWindow
/// we are managing. In some regard we don't know where the document came from! Currently
/// the view embedding interfaces don't give us access to the document site.
/// </summary>
/// <remarks>You know, I should make the view site able to return a document or document site.</remarks>
public IDisposable CreateView(IPgViewSite oViewSite, object oDocument, Guid guidViewType) {
try {
if( guidViewType == Program.ViewSelector ) {
EditWindow2 oEditWin = new EditWindow2(oViewSite, (BaseEditor)oDocument, fReadOnly:true, fSingleLine:false);
oEditWin.HyperLinks.Add( "ViewSwitch", OnHyperViewSwitch );
oEditWin.ToolSelect = 1;
oEditWin.Wrap = false;
return oEditWin;
}
} catch( Exception oEx ) {
Type[] rgErrors = { typeof( NullReferenceException ),
typeof( InvalidCastException ),
typeof( ArgumentNullException ) };
if( rgErrors.IsUnhandled( oEx ) )
throw new InvalidProgramException( "Unexpected error creating editor view.", oEx );
_oMainWin.Document.LogError( "Main Window children", "Could not create a child window for the main window" );
}
throw new ArgumentOutOfRangeException( "Don't recognize top level window requested!" );
}
/// <summary>
/// It's a little hacky to add the call back here, but let's go for it.
/// </summary>
private void OnHyperViewSwitch( Line oLine, IPgWordRange oRange ) {
try {
if( oLine is ViewsLine oViewLine ) {
_oMainWin.ViewSelect( oViewLine.ViewSite, fFocus:true );
}
} catch( NullReferenceException ) {
}
}
public IEnumerator<IPgViewType> GetEnumerator() {
yield return new ViewType( "View Select", Program.ViewSelector );
}
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
public PgDocumentDescriptor Suitability(string strExtension) {
throw new NotImplementedException();
}
}
/// <summary>
/// The Main window didn't have it's own document embedding slot. This is different than a view
/// slot or a program document slot. I used to want the views selection to live on the program
/// but I'm changing my mind and I'm slowly migrating it to the MainWindow. I'm hardcoding this
/// instance to the ViewSelector and can sort it all out later. The main complexity is that
/// decor views want access to an IDocSlot on the document. That sux and we need to work on that.
/// </summary>
protected class MainWinDocSlot : IPgBaseSite, IDocSlot {
MainWin _oHost;
ControllerForMainWindow _oController;
IDisposable _oGuest;
IPgLoad _oGuestLoad;
public MainWinDocSlot( MainWin oMainWin ) {
_oHost = oMainWin ?? throw new ArgumentNullException( "Main window reference must not be null" );
_oController = new ControllerForMainWindow( _oHost );
}
public IPgParent Host => _oHost;
public int ID => 0;
public IDisposable Document => _oGuest;
public bool IsDirty => false;
public string Title => "View Selector";
public string FileName => string.Empty;
public IPgController2 Controller => _oController;
public IEnumerable<IPgViewType> ViewTypes => _oController;
public int Reference { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string LastPath => throw new NotImplementedException();
public void Dispose() {
_oGuest.Dispose();
}
public void LogError(string strMessage, string strDetails, bool fShow = true) {
_oHost.LogError( this, strMessage, strDetails, fShow );
}
public bool InitNew() {
try {
_oGuest = Controller.CreateDocument( this, ".views" ) ?? throw new ApplicationException("Couldn't assign document");
_oGuestLoad = (IPgLoad)_oGuest;
} catch( Exception oEx ) {
Type[] rgErrors = { typeof( ApplicationException ),
typeof( InvalidCastException ) };
if( rgErrors.IsUnhandled( oEx ) )
throw;
return false;
}
return _oGuestLoad.InitNew();
}
public bool Load(string strFileName) {
throw new NotImplementedException();
}
public void Notify(ShellNotify eEvent) {
}
public bool Save(bool fNewLocation) {
throw new NotImplementedException();
}
}
/// <summary>
/// Load our global configuration. This is different than per instance session state
/// which is loaded via a standard InitNew/Load API.
/// </summary>
/// <remarks>
/// 12/3/2018 : It would be nice if the window was at least minimally functional if any of this
/// fails, but we're not quite there yet.
///</remarks>
///<exception cref="ArgumentNullException" />
///<seealso cref="Program.InitNew"
///<seealso cref="Program.Load(TextReader)"/>
public void Initialize( XmlDocument xmlConfig ) {
if( xmlConfig == null )
throw new ArgumentNullException();
InitializeMenu ( xmlConfig );
InitializeEdges ( xmlConfig );
// It's super dangerous to be calling InitializeLocation which moves the window
// BEFORE WE'VE InitNew/Loaded the Program.
InitializeLocation( xmlConfig );
InitializeShepards( xmlConfig );
// Looking this over, all of this stuff below should probably be in InitNew()/Load()...
MainWinDocSlot oViewSitesSlot = new MainWinDocSlot(this);
oViewSitesSlot.InitNew();
_oDoc_ViewSelector = (ViewsEditor)oViewSitesSlot.Document;
DecorMenuReload();
}
//protected override void Dispose(bool disposing) {
// if (disposing) {
// Document.EventUpdateTitles -= UpdateAllTitlesFor;
// }
// if( _hScriptCache != IntPtr.Zero ) {
// PgUniscribe.ScriptFreeCache( ref _hScriptCache );
// _hScriptCache = IntPtr.Zero;
// }
// base.Dispose(disposing);
//}
public Program.LangSlot GetMappedGrammerSite( string strLang ) {
return( Document.GetMappedGrammerSite( strLang ));
}
// This old style drag drop was an attempt to support the feature but it's
// recommended that OLE drag drop is used. http://msdn2.microsoft.com/en-us/library/bb776904(VS.85).aspx
// See also System.Runtime.InteropServices Marshal::GetComInterfaceForObject()
private const int WS_EX_ACCEPTFILES = 0x00000010;
private const int WM_DROPFILES = 0x0233;
private const uint DQ_FILECOUNT = 0xFFFFFFFF;
/*
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | WS_EX_ACCEPTFILES;
return cp;
}
}
*/
//[DllImport("shell32.dll", CharSet = CharSet.Auto)]
//public static extern int DragQueryFile(IntPtr hDrop, int iFile, StringBuilder lpszFile, int cch);
//[DllImport("shell32.dll")]
//static extern void DragFinish(IntPtr hDrop);
//[DllImport("shell32.dll")]
//static extern void DragAcceptFiles( IntPtr hWnd, bool fAccept );
//[DllImport( "ole32.DLL", EntryPoint= "RegisterDragDrop", SetLastError= true)]
//public static extern UInt32 RegisterDragDrop( IntPtr hWin, IntPtr iDragDrop );
/*
protected override void WndProc(ref Message m) {
if (m.Msg == WM_DROPFILES) {
int iNumChars = DragQueryFile(m.WParam, 0, null, 0);
StringBuilder sbDropFilePath = new StringBuilder(iNumChars + 1);
DragQueryFile(m.WParam, 0, sbDropFilePath, iNumChars + 1);
DragFinish(m.WParam);
string strItem = sbDropFilePath.ToString();
//MainWin oHost = (MainWin)_oSite.Host;
this.CreateTextEditor( strItem );
}
base.WndProc(ref m);
}
*/
protected override void OnHandleCreated(EventArgs e) {
base.OnHandleCreated(e);
// TODO: We do a lot in our constructor. But not all the children windows (like FindWindow) are constructed when
// we load our state, as such they won't know the selected view. I'm going to try this here for now. I thinking
// what we really need is a multi-step construction. First we wire up our window and wait until we have our handle and can display
// messages. Then load up children, then send this event.
if (_oSelectedWinSite != null && ViewChanged != null)
ViewChanged(_oSelectedWinSite.Guest as IPgParent ); // BUG, guest really needs to be a IPgParent.
if( _hScriptCache == IntPtr.Zero ) {
using( Graphics oG = this.CreateGraphics() ) {
using( GraphicsContext oDC = new GraphicsContext( oG ) ) {
using( new ItemContext( oDC.Handle, ToolsFont.ToHfont() ) ) {
_sDefFontProps.Load( oDC.Handle, ref _hScriptCache );
}
}
}
}
//RegisterDragDrop( this.Handle, Marshal.GetComInterfaceForObject( this, typeof( Microsoft.VisualStudio.OLE.Interop.IDropTarget ) ) );
}
protected override void OnDragEnter(DragEventArgs drgevent) {
base.OnDragEnter(drgevent);
}
internal IEnumerator<ColorMap> SharedGrammarColors {
get {
return Document.GetSharedGrammarColors();
}
}
public Bitmap BitmapCreateFromChar( string strText ) {
Size oSize = new Size( 16, 16 );
Bitmap oBmp = new Bitmap( oSize.Width, oSize.Height );
using( Graphics g = Graphics.FromImage(oBmp) ) {
using( Font oFont = new Font( "Segoe MDL2 Assets", 10f, FontStyle.Regular ) ) {
float fPixels = oFont.SizeInPoints * oFont.FontFamily.GetCellDescent( FontStyle.Regular ) / oFont.FontFamily.GetEmHeight(FontStyle.Regular);
PointF oPointF = new PointF( 0, fPixels );
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.DrawString( strText, oFont, Brushes.Black, oPointF );
}
}
return( oBmp );
}
/// <summary>
/// Initialize the paths to the grammars on first load. This is when we are copying our
/// config file to the user's appdata area.
/// </summary>
/// <param name="strInstallDir">Path where the executable lives</param>
/// <param name="xmlDocument">A parsed config file.</param>
protected void InitializePathsToGrammer( string strInstallDir, XmlDocument xmlDocument ) {
XmlNodeList lstTypes = xmlDocument.SelectNodes("config/languages/grammars/grammar");
foreach( XmlElement xeType in lstTypes ) {
string strFile = Path.GetFileName( xeType.GetAttribute( "file" ) );
xeType.SetAttribute( "file", strInstallDir + "\\" + strFile );
}
}
/// <summary>
/// Find the values we persisted for our border margins.
/// </summary>
/// <param name="xmlDocument">Pointer to the xml document with our settings.</param>
protected void InitializeEdges( XmlDocument xmlDocument ) {
XmlElement xmlElem = xmlDocument.SelectSingleNode( "config/mainwindow/margin" ) as XmlElement;
_rgSideBox.Add( new SideRect( TRACK.VERT, 5 ) );
_rgSideBox.Add( new SideRect( TRACK.VERT, 5 ) );
_rgSideBox.Add( new SideRect( TRACK.VERT, 5 ) );
_rgSideBox.Add( new SideRect( TRACK.HORIZ, 5 ) );
// 8/15/2016 TODO : Need to get organized about edges and margins w/r to menu docked at top.
// PreferedSize returns utter nonsense for the Width/Height of the TopMenu!!
_rcMargin .SetScalar( SET.STRETCH, SCALAR.TOP, Document.FontStandard.Height + 14 ); // NOTE: Need "Invertable" rect rule b/c margin rect's aren't normal rect usage.
_rcSideSave.SetScalar( SET.STRETCH, SCALAR.TOP, _rcMargin[ SCALAR.TOP ]);
// Read in all the edge values.
try {
_rgSideNames.Add("left", EDGE.LEFT);
_rgSideNames.Add("top", EDGE.TOP );
_rgSideNames.Add("right", EDGE.RIGHT );
_rgSideNames.Add("bottom", EDGE.BOTTOM );
if( xmlElem != null ) {
foreach( string strEdge in _rgSideNames.Keys ) {
int iEdge = (int)_rgSideNames[strEdge];
if( int.TryParse( xmlElem.GetAttribute( strEdge ), out int iValue ) ) {
_rcSide[iEdge] = iValue;
} else {
LogError( null, "initialization", "Couldn't read margins from config." );
}
}
}
} catch( Exception oE ) {
Type[] rgError = { typeof( ArgumentException ),
typeof( FormatException ) };
if(rgError.IsUnhandled( oE ) )
throw;
// Just set all margins to zero on error.
for( int i=0; i<4; ++i ) {
_rcSide[i] = 0;
}
}
_rcFrame.Hidden = false;
_rcFrame.Show = SHOWSTATE.Inactive;
_rcFrame.SizeEvent += new RectSize(this.OnInsideAdjusted);
//LayoutFrame(); Can't call now because center view is null on init.
}
/// <summary>
/// Make sure you call this after InitializeDocking()! The size window calls back on us.
/// Load
/// string initLocation = Properties.Settings.Default.InitialLocation; // saved string
/// // parse and load location/size
/// Save
/// location = RestoreBounds.Location;
/// size = RestoreBounds.Size;
/// string initLocation = string.Join(",", location.X, location.Y, size.Width, size.Height);
/// Properties.Settings.Default.InitialLocation = initLocation;
/// Properties.Settings.Default.Save();
/// </summary>
/// <param name="xmlDocument"></param>
protected void InitializeLocation( XmlDocument xmlDocument ) {
int [] rgMain = new int[4];
string[] rgDims = { "left", "top", "width", "height" };
try {
if (xmlDocument.SelectSingleNode("config/mainwindow/location") is XmlElement xmlElem) {
for (int i = 0; i < rgDims.Length; ++i) {
int.TryParse(xmlElem.GetAttribute(rgDims[i]), out rgMain[i]);
}
}
} catch( Exception oE ) {
Type[] rgError = { typeof( ArgumentException ),
typeof( FormatException ),
typeof( NullReferenceException ) };
if(rgError.IsUnhandled( oE ) )
throw;
rgMain[0] = 10;
rgMain[1] = 10;
rgMain[2] = 800;
rgMain[3] = 600;
}
SuspendLayout();
StartPosition = FormStartPosition.Manual;
Location = new Point( rgMain[0], rgMain[1] );
Size = new Size ( rgMain[2], rgMain[3] ); // ends up making LayoutFrame() call.
ResumeLayout();
}
/// <summary>
/// 12/5/2018 : We assume the main program has either called InitNew or Load by now. In the future,
/// I'll probably stick this code in the InitNew and Load sequence. We're not quite there yet.
/// </summary>
/// <param name="xmlConfig"></param>
protected void InitializeMenu( XmlDocument xmlConfig ) {
_oTopMenu = new MyMenuStrip() {
Font = Document.FontMenu,
AutoSize = false,
LayoutStyle = ToolStripLayoutStyle.Flow
};
// Save Menu shortcut.
//ToolStripMenuItem oSaveShortcut = new ToolStripMenuItem( string.Empty, oSaveBitmap, new EventHandler(this.OnDocSave));
_oTopMenu.Items.Add(new ToolStripMenuItem( MyExtensions.str3InchFloppy, null, new EventHandler(this.OnDocSave) ));
// File Menu.
ToolStripMenuItem oFileMenu = new ToolStripMenuItem("File");
_oTopMenu.Items.Add( oFileMenu );
List<ToolStripMenuItem> rgSubMenu = new List<ToolStripMenuItem>();
rgSubMenu.Add( new ToolStripMenuItem("Html", BitmapCreateFromChar( "\xE12b" ), new EventHandler(this.OnDocNewHtml )));
rgSubMenu.Add( new ToolStripMenuItem("Text", BitmapCreateFromChar( "\xE185" ), new EventHandler(this.OnDocNewText )));
rgSubMenu.Add( new ToolStripMenuItem("M3u", BitmapCreateFromChar( "\xE189" ), new EventHandler(this.OnDocNewM3u )));
rgSubMenu.Add( new ToolStripMenuItem("Scraps", BitmapCreateFromChar( "\xE0a5" ), new EventHandler(this.OnDocNewScraps)));
rgSubMenu.Add( new ToolStripMenuItem("Morse", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewMorse )));
rgSubMenu.Add( new ToolStripMenuItem("Net Log", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewNetLogger)));
rgSubMenu.Add( new ToolStripMenuItem("Std Log", BitmapCreateFromChar( "\xE113" ), new EventHandler(this.OnDocNewStdLogger)));
rgSubMenu.Add( new ToolStripMenuItem("SSTV", BitmapCreateFromChar( "\xE114" ), new EventHandler(this.OnDocNewSSTV )));
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("New", BitmapCreateFromChar( "\xE295" ), rgSubMenu.ToArray() ) );
oFileMenu.DropDownItems.Add(new ToolStripMenuItem( "Open...", BitmapCreateFromChar( "\xE132" ), new EventHandler(this.OnDocOpen), Keys.Control | Keys.O ));
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Paste", BitmapCreateFromChar( "\xE16C" ), new EventHandler(this.OnDocPaste)));
List<ToolStripMenuItem> rgSubMenu4 = new List<ToolStripMenuItem>();
oFileMenu.DropDownItems.Add( _miRecentsMenu = new ToolStripMenuItem("Recent", BitmapCreateFromChar( "\xE1a5" ) ) );
foreach( Line oLine in Document.DocRecents ) {
ToolStripMenuItem oMenuItem = new MenuItemWithLine( oLine, new EventHandler(OnDocFavorites) );
_miRecentsMenu.DropDownItems.Add( oMenuItem );
}
oFileMenu.DropDownItems.Add(new ToolStripSeparator() );
_miViewCreate = new ToolStripMenuItem("View", BitmapCreateFromChar( "\xE187" ), rgSubMenu4.ToArray() );
oFileMenu.DropDownItems.Add( _miViewCreate );
oFileMenu.DropDownItems.Add(new ToolStripSeparator() ); //---
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Save", BitmapCreateFromChar( "\xe105" ), new EventHandler(this.OnDocSave), Keys.Control | Keys.S ));
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Save As...", BitmapCreateFromChar( "\xe159" ), new EventHandler(this.OnDocSaveAs)));
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Save All", BitmapCreateFromChar( "\xe158" ), new EventHandler(this.OnDocSaveAll), Keys.Control | Keys.Shift | Keys.O ));
//oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Run", null, new EventHandler(this.OnRun)));
oFileMenu.DropDownItems.Add(new ToolStripSeparator() ); //---
ToolStripMenuItem[] rgSubMenu3 = new ToolStripMenuItem[3] {
new ToolStripMenuItem("Name", BitmapCreateFromChar( "\xE132" ), new EventHandler(this.OnFileCopyName)),
new ToolStripMenuItem("Directory", BitmapCreateFromChar( "\xE188" ), new EventHandler(this.OnFileCopyDirectory)),
new ToolStripMenuItem("Path", BitmapCreateFromChar( "\xE1DA" ), new EventHandler(this.OnFileCopyPath))
};
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Copy", BitmapCreateFromChar( "\xE16D" ), rgSubMenu3 ) );
List<ToolStripMenuItem> rgSubMenuPlay = new List<ToolStripMenuItem>();
rgSubMenuPlay.Add(new ToolStripMenuItem("Sequential", BitmapCreateFromChar("\xE149"), new EventHandler(this.OnDocPlaySeqential)));
rgSubMenuPlay.Add(new ToolStripMenuItem("Random", BitmapCreateFromChar("\xE14b"), new EventHandler(this.OnDocPlayRandom)));
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Play", BitmapCreateFromChar("\xE189"), rgSubMenuPlay.ToArray()));
oFileMenu.DropDownItems.Add(new ToolStripSeparator() ); //---
oFileMenu.DropDownItems.Add(new ToolStripMenuItem("Close", BitmapCreateFromChar( "\xe10a" ), new EventHandler(this.OnFileClose))); // s/b file close, close all views and file!
// Edit Menu.
ToolStripMenuItem oEditMenu = new ToolStripMenuItem("Edit");
_oTopMenu.Items.Add( oEditMenu );
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Cut", BitmapCreateFromChar( "\xE16B" ), new EventHandler(this.OnEditCut), Keys.Control | Keys.X));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Copy", BitmapCreateFromChar( "\xE16D" ), new EventHandler(this.OnEditCopy), Keys.Control | Keys.C));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Paste", BitmapCreateFromChar( "\xE16C" ), new EventHandler(this.OnEditPaste), Keys.Control | Keys.V));
ToolStripMenuItem[] rgSubMenu2 = new ToolStripMenuItem[3] {
new ToolStripMenuItem("Img", BitmapCreateFromChar( "\xE114" ), new EventHandler(this.OnEditPasteAsImg)),
new ToolStripMenuItem("Text", BitmapCreateFromChar( "\xE185" ), new EventHandler(this.OnEditPasteAsText)),
new ToolStripMenuItem("Base64", BitmapCreateFromChar( "\xE159" ), new EventHandler(this.OnEditPasteAsBase64 ))
};
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Paste as", BitmapCreateFromChar( "\xE16C" ), rgSubMenu2 ) );
oEditMenu.DropDownItems.Add(new ToolStripSeparator() ); //---
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Undo", BitmapCreateFromChar( "\xE10e" ), new EventHandler(this.OnEditUndo), Keys.Control | Keys.Z ));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Delete", BitmapCreateFromChar( "\xE107" ), new EventHandler(this.OnEditDelete ), Keys.Delete ) );
oEditMenu.DropDownItems.Add(new ToolStripSeparator()); //---
List<ToolStripMenuItem> rgSubMenuLock = new List<ToolStripMenuItem> {
new ToolStripMenuItem("Accept", BitmapCreateFromChar( "\xE1f7" ), new EventHandler(this.OnEditUnlock )),
new ToolStripMenuItem("Block", BitmapCreateFromChar( "\xE1f6" ), new EventHandler(this.OnEditLock ))
};
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Text", BitmapCreateFromChar("\xE144"), rgSubMenuLock.ToArray()));
oEditMenu.DropDownItems.Add(new ToolStripSeparator() ); //---
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Select All", BitmapCreateFromChar( "\xE14e" ), new EventHandler(this.OnEditSelectAll), Keys.Control | Keys.A));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Select Off", BitmapCreateFromChar( "\x0000" ), new EventHandler(this.OnEditSelectOff), Keys.Control | Keys.D));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Collect", BitmapCreateFromChar( "\xE0e7" ), new EventHandler(this.OnCollect), Keys.Control | Keys.L ));
oEditMenu.DropDownItems.Add(new ToolStripMenuItem("Find", BitmapCreateFromChar( "\xE1a3" ), new EventHandler(this.OnEditFind), Keys.Control | Keys.F));
_miToolsMenu = new ToolStripMenuItem( "Mode" );
_oTopMenu.Items.Add( _miToolsMenu );
_miDecorMenu = new ToolStripMenuItem( "Dock" );
_oTopMenu.Items.Add(_miDecorMenu);
_miViewListMenu = new ToolStripMenuItem("Views");
_miViewListMenu.DropDownItems.Add( new ToolStripMenuItem( "Show All", BitmapCreateFromChar( MyExtensions.strHome ), this.OnViewAll ) );
_oTopMenu.Items.Add(_miViewListMenu);
ToolStripMenuItem oSettingsMenu = new ToolStripMenuItem("Session");
_oTopMenu.Items.Add(oSettingsMenu);
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Settings!", BitmapCreateFromChar( "\xE12a" ), new EventHandler(this.OnConfigOpen )));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Open...", BitmapCreateFromChar( "\xE132" ), new EventHandler(this.OnSessionView )));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Save", BitmapCreateFromChar( "\xe105" ), new EventHandler(this.OnSessionSave )));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Save As...", BitmapCreateFromChar( "\xe159" ), new EventHandler(this.OnSessionSaveAs)));
oSettingsMenu.DropDownItems.Add(new ToolStripSeparator() );
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Alerts!", BitmapCreateFromChar( "\xE1de" ), new EventHandler(this.OnSessionOpenAlerts )));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Find Results!", BitmapCreateFromChar( "\xE179" ), new EventHandler(this.OnSessionOpenResults)));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Recent List!", BitmapCreateFromChar( "\xE1a5" ), new EventHandler(this.OnSessionOpenRecents)));
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("Scrap Book!", BitmapCreateFromChar( "\xE1d3" ), new EventHandler(this.OnSessionOpenScraps )));
oSettingsMenu.DropDownItems.Add(new ToolStripSeparator() );
oSettingsMenu.DropDownItems.Add(new ToolStripMenuItem("About!", BitmapCreateFromChar( "\xe0a5" ), new EventHandler( this.OnHelpAbout ))); // "\xE2c0" doesn't work. :-(
//oSettingsMenu.DropDown.MouseLeave += OnDropDown_MouseLeave;
if (_oContextMenu != null) {
_oContextMenu.Items.Add(new ToolStripMenuItem("Minimize")); // Just place holders for now.
_oContextMenu.Items.Add(new ToolStripMenuItem("Maximize"));
_oContextMenu.Items.Add(new ToolStripMenuItem("Close", null, new EventHandler(this.OnDecorCloseCommand)));
_oContextMenu.Items.Add(new ToolStripMenuItem("Menu", null, new EventHandler(this.OnDecorMenuOpenCommand)));
_oContextMenu.Opened += new EventHandler(OnContextMenuPopup);
this.ContextMenuStrip = _oContextMenu;
}
ToolStripMenuItem oParent = new ToolStripMenuItem(MyExtensions.strGoParent, null, new EventHandler(this.OnEditJumpParent ) ) {
ForeColor = Color.Goldenrod
};
_oTopMenu.Items.Add( oParent );
_oTopMenu.Items.Add(new ToolStripMenuItem(MyExtensions.strGoLeft, null, new EventHandler(this.OnEditJumpPrev) ) );
_oTopMenu.Items.Add(new ToolStripMenuItem(MyExtensions.strGoRight, null, new EventHandler(this.OnEditJumpNext) ) );
ToolStripMenuItem oPlay = new ToolStripMenuItem(MyExtensions.strPlay, null, new EventHandler(this.OnEditPlay)) {
ForeColor = Color.DarkGreen
};
_oTopMenu.Items.Add( oPlay );
_oTopMenu.Items.Add(new ToolStripMenuItem(MyExtensions.strPause, null, new EventHandler(this.OnEditPause ) ) );
ToolStripMenuItem oStop = new ToolStripMenuItem(MyExtensions.strStop, null, new EventHandler(this.OnEditStop ) ) {
ForeColor = Color.DarkRed
};
_oTopMenu.Items.Add( oStop );
ToolStripMenuItem oViewNextSibling = new ToolStripMenuItem(MyExtensions.strHome, null, new EventHandler(this.OnViewNextSibling ) ) {
ForeColor = Color.DarkBlue
};
_oTopMenu.Items.Add( oViewNextSibling );
ToolStripMenuItem oViewNextAll = new ToolStripMenuItem(MyExtensions.strNextView, null, new EventHandler(this.OnViewNextAll ) ) {
ForeColor = Color.DarkBlue
};
_oTopMenu.Items.Add( oViewNextAll );
MakeDropdownOnHover();
}
private void OnDocPlayRandom(object sender,EventArgs e) {
}
private void OnDocPlaySeqential(object sender,EventArgs e) {
}
/// <summary>
/// Switch the layout so we see all the views!
/// </summary>
/// <seealso cref="ViewSlot.OnMenuSelectView"/>
private void OnViewAll(object sender,EventArgs e) {
_eLayout = TOPLAYOUT.Multi;
LayoutViews();
}
private void OnDropDown_MouseLeave(object sender, EventArgs e) {
((ToolStripDropDown)sender).Hide();
}
/// <summary>
/// Override menu behavior so we get pop-up menus.
/// </summary>
/// <remarks>Unfortunately we can't dispatch the pop up as easily. I've commented out for now.</remarks>
private void MakeDropdownOnHover() {
/*
_oTopMenu.Items.OfType<ToolStripMenuItem>().ToList().ForEach(x =>
{
x.MouseEnter += (obj, arg) => {
if( ActiveForm != null ) {
((ToolStripDropDownItem)obj).ShowDropDown();
}
};
// CLose, but can't get the second level pop ups. Grrrr
//x.DropDown.MouseLeave += (obj, arg) => {
// ((ToolStripDropDown)x.DropDown).Hide();
//};
});
*/
}
IEnumerator<SmartHerderBase> IEnumerable<SmartHerderBase>.GetEnumerator() {
return( ShepardEnum() );
}
IEnumerator IEnumerable.GetEnumerator() {
return( ShepardEnum() );
}
void OnContextMenuPopup(object sender, EventArgs e) {
_pntContextLocation = this.PointToClient(Cursor.Position);
// First check if we're hovering over a herder to determine if we need to grey some stuff.
SmartHerderBase oHerderFound = null;
foreach (SmartHerderBase oHerder in this) {
if (oHerder.IsInside(_pntContextLocation.X, _pntContextLocation.Y)) {
oHerderFound = oHerder;
}
}
// Second check to see if the menu herder is showing.
SmartHerderBase oHerderMenu = Shepardfind("menu");
// Now set up our show/grey stuff in our menu.
string[] rgContexts = { "minimize", "maximize", "close" }; // BUG: hard coded values.
foreach (ToolStripMenuItem oMenuItem in _oContextMenu.Items) {
bool fFoundContext = false;
foreach (string strContext in rgContexts) {
// There's a "name" value on the oMenuItem which is probably better since it won't be localized!!!
// need to set up the menu so that value get's set instead of depending on "text" property.
if (string.Compare(strContext, oMenuItem.Text, true) == 0) {
fFoundContext = true;
}
}
if (fFoundContext) {
oMenuItem.Enabled = oHerderFound != null;
}
if (string.Compare("menu", oMenuItem.Text, true) == 0 && oHerderMenu != null) { // BUG: hard coded values.
oMenuItem.Enabled = !oHerderMenu.Hidden;
}
}
}
private void OpenOrShowFirstView( IDocSlot oDocSite ) {
if( oDocSite == null )
return;
ViewSlot oViewSite = _oDoc_ViewSelector.FindFirstView( oDocSite );
if( oViewSite == null ) {
ViewCreate( oDocSite, Guid.Empty );
} else {
oViewSite.SetFocus();
}
}
private void OnSessionOpenAlerts( object s, EventArgs e )
{
OpenOrShowFirstView( Document.AlertSlot );
}
private void OnSessionOpenResults( object s, EventArgs e )
{
OpenOrShowFirstView( Document.ResultsSlot );
}
private void OnSessionOpenRecents(object sender, EventArgs e)
{
OpenOrShowFirstView( Document.RecentsSlot );
}
private void OnSessionOpenScraps(object sender, EventArgs e )
{
OpenOrShowFirstView( Document.ScrapBookSlot );
}
/// <summary>
/// Internal error clearing house. This'll be a way for me to track errors in the
/// system. Anyone can call this but I expect most errors to come the the sites.
/// </summary>
/// <remarks>If we get more than one error coming along then we'll get multiple pop
/// ups. What we should do is open the window with an Alert view in it and just reuse
/// the open window for the subsequent messages.</remarks>
/// <param name="oSite">Might be null!</param>
/// <param name="strCatagory"></param>
public void LogError( IPgBaseSite oSite, string strCatagory, string strDetails, bool fShow=true ) {
Document.LogError( oSite, strCatagory, strDetails, fShow );
}
/// <summary>
/// Warn not to close if there are open documents.
/// </summary>
/// <remarks>I need to see if there is a difference between the user requesting
/// a close and the system shutting down.</remarks>
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
_fIsClosing = true;
e.Cancel = Document.WarnOnOpenDocuments();
// I'd rather ask the user if they want to save first then close. But that needs a
// better dialog box than I have a the moment. So just auto save.
if( Document.SessionSlot.IsDirty ) {
Document.SessionSave( false );
//MessageBox.Show( "The session is unsaved.", "Session" );
//e.Cancel = true;
}
}
/// <summary>A disposed would be better but windows are a bit different then everyone else.</summary>
//protected override void OnClosed( EventArgs e ) {
// base.OnClosed(e);
//}
/// <summary>
/// Closing our main window.
/// </summary>
protected override void OnFormClosed( FormClosedEventArgs e ) {
base.OnFormClosed(e);
foreach( ViewsLine oLine in _oDoc_ViewSelector ) {
oLine.ViewSite.Dispose();
}
_oDoc_ViewSelector.Clear();
// BUG: These belong in Dispose() method.
DecorFont .Dispose();
ToolsBrushActive.Dispose();
}
public string VersionInfo {
get {
return( System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() );
}
}
/// <summary>
/// Open up a new .txt document and fill it with the Version Info of this program.
/// </summary>
/// <remarks>TODO: Set the path to the last used path. TODO: Create a new document and use the controller
/// to create the view!!</remarks>
public void OnHelpAbout( object sender, EventArgs e ) {
if (EditorInitNewShow("about.txt") is Editor oDocAbout) {
using (Editor.Manipulator oManip = oDocAbout.CreateManipulator()) {
using (TextReader oReader = new StringReader(VersionInfo)) {
for (string strLine = string.Empty; strLine != null; strLine = oReader.ReadLine()) {
// Unfortunately, right from the get go there's an empty line I don't want.
if (!string.IsNullOrEmpty(strLine))
oManip.LineInsert(oDocAbout.ElementCount, strLine);
}
}
}
}
}
/// <summary>
/// Just open the raw file for edit. They'll need to save and reload to update the file.
/// </summary>
/// <remarks>See also Application.UserAppDataPath()</remarks>
public void OnConfigOpen( object sender, EventArgs e ) {
StringBuilder sbConfig = new StringBuilder();
try {
sbConfig.Append( Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData) );
sbConfig.Append( "\\pg\\mjolnir\\" );
sbConfig.Append( "config.phree" );
DocumentShow( sbConfig.ToString() );
} catch( NullReferenceException ) {
LogError( null, "session", "Couldn't find template string, or something!" );
}
}
public void OnSessionSave( object sender, EventArgs e ) {
Document.SessionSave( fAtNew: false );
}
public void OnSessionSaveAs( object sender, EventArgs e ) {
Document.SessionSave( fAtNew: true );
}
/// <summary>
/// Attempt to open a view on the session document. This should be a read only document since
/// typing in it won't affect anything and it will get overwritten in the end. If we didn't
/// open the shell on a session then there is no session and the doc site is null.
/// Remember, the guest of the session site is the MAIN WINDOW!!! ^_^; It's not a editor and
/// we can't open a view on it.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void OnSessionView( object sender, EventArgs e ) {
Program.TextSlot oSessionSlot = Document.SessionSlot;
if( _oDoc_ViewSelector.FindFirstView( oSessionSlot ) == null ) {
if( string.IsNullOrEmpty( oSessionSlot.FileName ) )
LogError( oSessionSlot, "host", "The current session has not been persisted." );
else
DocumentShow( oSessionSlot.FileName );
}
}
public void OnDocNewText( object sender, EventArgs e ) {
EditorInitNewShow( ".txt" );
}
public void OnDocNewHtml( object sender, EventArgs e ) {
EditorInitNewShow( ".html" );
}
public void OnDocNewM3u( object sender, EventArgs e ) {
EditorInitNewShow( ".m3u" );
}
public void OnDocNewScraps( object sender, EventArgs e ) {
EditorInitNewShow( ".scraps" );
}
public void OnDocNewMorse( object sender, EventArgs e ) {
EditorInitNewShow( ".morse" );
}
public void OnDocNewNetLogger( object sender, EventArgs e ) {
EditorInitNewShow( ".netlog" );
}
public void OnDocNewStdLogger( object sender, EventArgs e ) {
EditorInitNewShow( ".stdlog" );
}
public void OnDocNewSSTV( object sender, EventArgs e ) {
EditorInitNewShow( ".mysstv" );
}
public void OnDocOpen( object sender, EventArgs e ) {
ViewSlot oViewSite = this.ViewSiteSelected;
string strLastPath = Document.UserDocs;
// Look at the currently active view and find the lastpath for that view.
if( oViewSite != null ) {
strLastPath = oViewSite.LastPath;
}
using( OpenFileDialog oDialog = new OpenFileDialog() ) {
oDialog.InitialDirectory = strLastPath;
if( oDialog.ShowDialog() == DialogResult.OK ) {
if( FileCheck( oDialog.FileName ) ) {
// Don't put this in the FileOk event because after that event
// the dialog returns focus to where it came from and we lose
// focus from our newly opened view.
DocumentShow( oDialog.FileName );
}
}
}
}
public void OnDocFavorites( object sender, EventArgs e )
{
if (sender is MenuItemWithLine oItem) {
Document.DocRecents.LineMove( 0, oItem.DocumentLine );
_miRecentsMenu.DropDownItems.Remove( oItem );
_miRecentsMenu.DropDownItems.Insert( 0, oItem );
this.DocumentShow(oItem.Text);
}
}
public void OnDocPaste( object sender, EventArgs e ) {
IDataObject pDataObject = Clipboard.GetDataObject();
if( pDataObject.GetDataPresent( DataFormats.FileDrop ) ) {
string[] rgItems = pDataObject.GetData(DataFormats.FileDrop) as string[];
ViewSlot oViewSite = null;
//TODO: If more than one file to open, I should warn the user and put up a select box.
foreach( string strFileName in rgItems ) {
oViewSite = this.DocumentShow( strFileName, EditorShowEnum.SILENT );
}
// Open select and focus the last one.