/[RomCheater]/trunk/RomCheater.PluginFramework/Core/ScratchPad.cs
ViewVC logotype

Diff of /trunk/RomCheater.PluginFramework/Core/ScratchPad.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.PluginFramework/Core/ScratchPad.cs	2013/06/17 05:41:23	674
+++ trunk/RomCheater.PluginFramework/Core/ScratchPad.cs	2013/06/17 06:03:28	676
@@ -7,6 +7,7 @@
 using System.Text;
 using System.Windows.Forms;
 using WeifenLuo.WinFormsUI.Docking;
+using System.IO;
 
 namespace RomCheater.PluginFramework.Core
 {
@@ -15,6 +16,79 @@
         public ScratchPad()
         {
             InitializeComponent();
+            InitScratchPadText();
+        }
+
+
+        private void InitScratchPadText()
+        {
+            txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Italic);
+            txtScratchPad.ForeColor = SystemColors.GrayText;
+            StringBuilder builder = new StringBuilder();
+            txtScratchPad.Clear();
+
+            builder.AppendLine();
+            builder.AppendFormat("\tThis is a scratchpad");
+            builder.AppendLine();
+            builder.AppendFormat("\tYou can type anything in here, and save it for later or load an existing file.");
+
+            txtScratchPad.AppendText(builder.ToString());
+        }
+
+        private void mnuItemSave_Click(object sender, EventArgs e)
+        {
+            DialogResult result = ScracthPadSaver.ShowDialog();
+            if (result != DialogResult.OK) { return; }
+            using (FileStream fs = new FileStream(ScracthPadLoader.FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read))
+            {
+                using (StreamWriter sw = new StreamWriter(fs))
+                {
+                    sw.Write(txtScratchPad.Text);
+                    sw.Flush();
+                    sw.Close();
+                }
+            }
+        }
+
+        private void mnuItemOpen_Click(object sender, EventArgs e)
+        {
+            DialogResult result = ScracthPadLoader.ShowDialog();
+            if (result != DialogResult.OK) { return; }
+            txtScratchPad.Clear();
+
+            using (FileStream fs = new FileStream(ScracthPadLoader.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
+            {
+                using (StreamReader sr = new StreamReader(fs))
+                {
+                    txtScratchPad.AppendText(sr.ReadToEnd());
+                }
+            }
+        }
+
+
+
+        private bool InitDone = false;
+        
+        private void txtScratchPad_MouseDown(object sender, MouseEventArgs e)
+        {
+            if (!InitDone)
+            {
+                txtScratchPad.Clear();
+                txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Regular);
+                txtScratchPad.ForeColor = Color.Black;
+                InitDone = true;
+            }   
+        }
+
+        private void txtScratchPad_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (!InitDone)
+            {
+                txtScratchPad.Clear();
+                txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Regular);
+                txtScratchPad.ForeColor = Color.Black;
+                InitDone = true;
+            }  
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22