using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using System.IO; namespace RomCheater.PluginFramework.Core { public partial class ScratchPad : DockContent { 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; } } } }