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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 676 - (hide annotations) (download)
Mon Jun 17 06:03:28 2013 UTC (7 years, 10 months ago) by william
File size: 3136 byte(s)

1 william 674 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Linq;
7     using System.Text;
8     using System.Windows.Forms;
9     using WeifenLuo.WinFormsUI.Docking;
10 william 676 using System.IO;
11 william 674
12     namespace RomCheater.PluginFramework.Core
13     {
14     public partial class ScratchPad : DockContent
15     {
16     public ScratchPad()
17     {
18     InitializeComponent();
19 william 676 InitScratchPadText();
20 william 674 }
21 william 676
22    
23     private void InitScratchPadText()
24     {
25     txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Italic);
26     txtScratchPad.ForeColor = SystemColors.GrayText;
27     StringBuilder builder = new StringBuilder();
28     txtScratchPad.Clear();
29    
30     builder.AppendLine();
31     builder.AppendFormat("\tThis is a scratchpad");
32     builder.AppendLine();
33     builder.AppendFormat("\tYou can type anything in here, and save it for later or load an existing file.");
34    
35     txtScratchPad.AppendText(builder.ToString());
36     }
37    
38     private void mnuItemSave_Click(object sender, EventArgs e)
39     {
40     DialogResult result = ScracthPadSaver.ShowDialog();
41     if (result != DialogResult.OK) { return; }
42     using (FileStream fs = new FileStream(ScracthPadLoader.FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read))
43     {
44     using (StreamWriter sw = new StreamWriter(fs))
45     {
46     sw.Write(txtScratchPad.Text);
47     sw.Flush();
48     sw.Close();
49     }
50     }
51     }
52    
53     private void mnuItemOpen_Click(object sender, EventArgs e)
54     {
55     DialogResult result = ScracthPadLoader.ShowDialog();
56     if (result != DialogResult.OK) { return; }
57     txtScratchPad.Clear();
58    
59     using (FileStream fs = new FileStream(ScracthPadLoader.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
60     {
61     using (StreamReader sr = new StreamReader(fs))
62     {
63     txtScratchPad.AppendText(sr.ReadToEnd());
64     }
65     }
66     }
67    
68    
69    
70     private bool InitDone = false;
71    
72     private void txtScratchPad_MouseDown(object sender, MouseEventArgs e)
73     {
74     if (!InitDone)
75     {
76     txtScratchPad.Clear();
77     txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Regular);
78     txtScratchPad.ForeColor = Color.Black;
79     InitDone = true;
80     }
81     }
82    
83     private void txtScratchPad_KeyDown(object sender, KeyEventArgs e)
84     {
85     if (!InitDone)
86     {
87     txtScratchPad.Clear();
88     txtScratchPad.Font = new System.Drawing.Font(txtScratchPad.Font, FontStyle.Regular);
89     txtScratchPad.ForeColor = Color.Black;
90     InitDone = true;
91     }
92     }
93 william 674 }
94     }

  ViewVC Help
Powered by ViewVC 1.1.22