GME
13
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.ComponentModel; 00004 using System.Data; 00005 using System.Drawing; 00006 using System.Text; 00007 using System.Windows.Forms; 00008 using System.Runtime.InteropServices; 00009 00010 namespace CSGUI 00011 { 00012 00013 [ComVisible(false)] 00014 public partial class WelcomeScreen : Form 00015 { 00016 00017 public string SelectedProject; 00018 public WelcomeScreen() 00019 { 00020 InitializeComponent(); 00021 this.FormBorderStyle = FormBorderStyle.FixedSingle; 00022 } 00023 protected override bool ProcessMnemonic(char charCode) 00024 { 00025 if (charCode >= '1' && charCode < '1' + recents.Count) 00026 { 00027 this.SelectedProject = recents[charCode - '1']; 00028 Close(); 00029 return true; 00030 } 00031 if (charCode == 'o') 00032 { 00033 this.btnOpen.PerformClick(); 00034 return true; 00035 } 00036 if (charCode == 'n') 00037 { 00038 this.btnNew.PerformClick(); 00039 return true; 00040 } 00041 return false; 00042 } 00043 00044 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 00045 { 00046 if (keyData == Keys.Escape) 00047 this.Close(); 00048 return base.ProcessCmdKey(ref msg, keyData); 00049 } 00050 00051 List<string> recents; 00052 internal void ShowDialog(IWin32Window windowWrapper, List<string> recents) 00053 { 00054 this.recents = recents; 00055 int y = 20; 00056 using (Graphics g = this.CreateGraphics()) 00057 { 00058 00059 foreach (string recent_ in recents) 00060 { 00061 string recent = recent_; 00062 LinkLabel recentLink = new System.Windows.Forms.LinkLabel(); 00063 recentLink.Text = recent; 00064 recentLink.Location = new Point(7, y); 00065 recentLink.AutoSize = false; 00066 recentLink.AutoEllipsis = true; 00067 recentLink.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 00068 recentLink.Size = new Size(grpRecents.Size.Width - 14, 00069 (int)Math.Ceiling(20 * g.DpiY / 96)); 00070 recentLink.LinkClicked += delegate(object sender, LinkLabelLinkClickedEventArgs args) 00071 { 00072 this.SelectedProject = recent; 00073 this.Close(); 00074 }; 00075 grpRecents.Controls.Add(recentLink); 00076 y += 4 + recentLink.Size.Height; 00077 } 00078 } 00079 00080 this.btnOpen.Click += new EventHandler(delegate(object o, EventArgs args) 00081 { 00082 OpenFileDialog openFileDialog1 = new OpenFileDialog(); 00083 //openFileDialog1.InitialDirectory = 00084 openFileDialog1.Filter = "GME project files (*.mga,*.xme,*.mgx)|*.mga; *.xme; *.mgx|MGA files|*.mga|GME XML files|*.xme; *.xml|All files (*.*)|*.*"; 00085 openFileDialog1.RestoreDirectory = true; 00086 openFileDialog1.CheckFileExists = true; 00087 00088 if (openFileDialog1.ShowDialog(this) == DialogResult.OK) 00089 { 00090 this.SelectedProject = openFileDialog1.FileName; 00091 this.Close(); 00092 } 00093 }); 00094 this.btnNew.Click += new EventHandler(delegate(object o, EventArgs args) 00095 { 00096 this.SelectedProject = WelcomeScreenExp.sCREATE_SENTINEL; 00097 this.Close(); 00098 }); 00099 this.StartPosition = FormStartPosition.CenterParent; 00100 this.ShowInTaskbar = false; 00101 this.DragDrop += new DragEventHandler(delegate(object o, DragEventArgs de) 00102 { 00103 if (de.Data.GetDataPresent(DataFormats.FileDrop)) 00104 { 00105 SelectedProject = (de.Data.GetData(DataFormats.FileDrop) as string[])[0]; 00106 this.Close(); 00107 } 00108 }); 00109 this.DragEnter += new DragEventHandler(delegate(object o, DragEventArgs e) 00110 { 00111 if (e.Data.GetDataPresent(DataFormats.FileDrop)) 00112 { 00113 string filename = (e.Data.GetData(DataFormats.FileDrop) as string[])[0]; 00114 if (filename.EndsWith(".mga") || filename.EndsWith(".xme")) 00115 { 00116 e.Effect = DragDropEffects.Copy; 00117 return; 00118 } 00119 } 00120 e.Effect = DragDropEffects.None; 00121 00122 }); 00123 ShowDialog(windowWrapper); 00124 } 00125 } 00126 }