OSDN Git Service

0.01pra release
[kuineator11/Kuineator.git] / Kuineator0.01pra / Kuineator0.01pra_src / kuineator / Components / Window / EditWindow.cs
1 using WeifenLuo.WinFormsUI.Docking;\r
2 using System;\r
3 using System.IO;\r
4 \r
5 namespace Kuineator.Components.Window\r
6 {\r
7     class EditWindow:DockContent\r
8     {\r
9         private string swp;\r
10         private bool loaded = true;\r
11         private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;\r
12         private System.Windows.Forms.ToolStripMenuItem ConMenuItem01;\r
13         private System.Windows.Forms.ToolStripMenuItem ConMenuItem02;\r
14         private System.Windows.Forms.ToolStripMenuItem ConMenuItem03;\r
15         private System.Windows.Forms.ToolStripSeparator ConSeparator01;\r
16         private System.Windows.Forms.ToolStripMenuItem ConMenuItem04;\r
17         private System.Windows.Forms.ToolStripMenuItem ConMenuItem05;\r
18         private System.Windows.Forms.ToolStripSeparator ConSeparator02;\r
19         private System.Windows.Forms.ToolStripMenuItem ConMenuItem06;\r
20         private System.Windows.Forms.ToolStripMenuItem ConMenuItem07;\r
21         public string path = "";\r
22         public EditWindow(){\r
23             InitializeComponent();\r
24             EditInitialize();\r
25         }\r
26 \r
27         public EditWindow(string path)\r
28         {\r
29             InitializeComponent();\r
30             EditInitialize();\r
31             FileInfo f = new FileInfo(path);\r
32             this.Text = f.Name;\r
33             this.codeEditorControl1.Open(path);\r
34             this.path = path;\r
35         }\r
36 \r
37         public EditWindow(string tabname, int mode)\r
38         {\r
39             InitializeComponent();\r
40             EditInitialize();\r
41             this.Text = tabname;\r
42         }\r
43 \r
44         public EditWindow(string tabname, string str)\r
45         {\r
46             InitializeComponent();\r
47             EditInitialize();\r
48             this.Text = tabname;\r
49             swp = str;\r
50             loaded = false;\r
51             this.Load +=new EventHandler(codeEditorControl1_Load);\r
52         }\r
53 \r
54         private void codeEditorControl1_Load(object sender, EventArgs e){\r
55             this.syntaxDocument1.InsertText(swp, 0, 0);\r
56             this.loaded = true;\r
57         }\r
58 \r
59         private void InitializeComponent()\r
60         {\r
61             this.components = new System.ComponentModel.Container();\r
62             Fireball.Windows.Forms.LineMarginRender lineMarginRender2 = new Fireball.Windows.Forms.LineMarginRender();\r
63             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\r
64             this.codeEditorControl1 = new Fireball.Windows.Forms.CodeEditorControl();\r
65             this.syntaxDocument1 = new Fireball.Syntax.SyntaxDocument(this.components);\r
66             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);\r
67             this.ConMenuItem01 = new System.Windows.Forms.ToolStripMenuItem();\r
68             this.ConMenuItem02 = new System.Windows.Forms.ToolStripMenuItem();\r
69             this.ConMenuItem03 = new System.Windows.Forms.ToolStripMenuItem();\r
70             this.ConSeparator01 = new System.Windows.Forms.ToolStripSeparator();\r
71             this.ConMenuItem04 = new System.Windows.Forms.ToolStripMenuItem();\r
72             this.ConMenuItem05 = new System.Windows.Forms.ToolStripMenuItem();\r
73             this.ConSeparator02 = new System.Windows.Forms.ToolStripSeparator();\r
74             this.ConMenuItem06 = new System.Windows.Forms.ToolStripMenuItem();\r
75             this.ConMenuItem07 = new System.Windows.Forms.ToolStripMenuItem();\r
76             this.tableLayoutPanel1.SuspendLayout();\r
77             this.contextMenuStrip1.SuspendLayout();\r
78             this.SuspendLayout();\r
79             // \r
80             // tableLayoutPanel1\r
81             // \r
82             this.tableLayoutPanel1.ColumnCount = 1;\r
83             this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));\r
84             this.tableLayoutPanel1.Controls.Add(this.codeEditorControl1, 0, 1);\r
85             this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
86             this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);\r
87             this.tableLayoutPanel1.Name = "tableLayoutPanel1";\r
88             this.tableLayoutPanel1.RowCount = 2;\r
89             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.198473F));\r
90             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 95.80153F));\r
91             this.tableLayoutPanel1.Size = new System.Drawing.Size(284, 262);\r
92             this.tableLayoutPanel1.TabIndex = 0;\r
93             // \r
94             // codeEditorControl1\r
95             // \r
96             this.codeEditorControl1.ActiveView = Fireball.Windows.Forms.CodeEditor.ActiveView.BottomRight;\r
97             this.codeEditorControl1.AllowDrop = true;\r
98             this.codeEditorControl1.AutoListPosition = null;\r
99             this.codeEditorControl1.AutoListSelectedText = "a123";\r
100             this.codeEditorControl1.AutoListVisible = false;\r
101             this.codeEditorControl1.CopyAsRTF = false;\r
102             this.codeEditorControl1.Dock = System.Windows.Forms.DockStyle.Fill;\r
103             this.codeEditorControl1.Document = this.syntaxDocument1;\r
104             this.codeEditorControl1.Indent = Fireball.Windows.Forms.CodeEditor.IndentStyle.None;\r
105             this.codeEditorControl1.InfoTipCount = 1;\r
106             this.codeEditorControl1.InfoTipPosition = null;\r
107             this.codeEditorControl1.InfoTipSelectedIndex = 1;\r
108             this.codeEditorControl1.InfoTipVisible = false;\r
109             lineMarginRender2.Bounds = new System.Drawing.Rectangle(19, 0, 19, 16);\r
110             this.codeEditorControl1.LineMarginRender = lineMarginRender2;\r
111             this.codeEditorControl1.Location = new System.Drawing.Point(3, 13);\r
112             this.codeEditorControl1.LockCursorUpdate = false;\r
113             this.codeEditorControl1.Name = "codeEditorControl1";\r
114             this.codeEditorControl1.Saved = false;\r
115             this.codeEditorControl1.ScopeIndicatorColor = System.Drawing.Color.White;\r
116             this.codeEditorControl1.ShowScopeIndicator = false;\r
117             this.codeEditorControl1.Size = new System.Drawing.Size(278, 246);\r
118             this.codeEditorControl1.SmoothScroll = true;\r
119             this.codeEditorControl1.SplitviewH = -4;\r
120             this.codeEditorControl1.SplitviewV = -4;\r
121             this.codeEditorControl1.TabGuideColor = System.Drawing.Color.FromArgb(((int)(((byte)(233)))), ((int)(((byte)(233)))), ((int)(((byte)(233)))));\r
122             this.codeEditorControl1.TabIndex = 0;\r
123             this.codeEditorControl1.Text = "codeEditorControl1";\r
124             this.codeEditorControl1.WhitespaceColor = System.Drawing.SystemColors.ControlDark;\r
125             // \r
126             // syntaxDocument1\r
127             // \r
128             this.syntaxDocument1.Lines = new string[] {\r
129         ""};\r
130             this.syntaxDocument1.MaxUndoBufferSize = 1000;\r
131             this.syntaxDocument1.Modified = false;\r
132             this.syntaxDocument1.UndoStep = 0;\r
133             // \r
134             // contextMenuStrip1\r
135             // \r
136             this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
137             this.ConMenuItem01,\r
138             this.ConMenuItem02,\r
139             this.ConMenuItem03,\r
140             this.ConSeparator01,\r
141             this.ConMenuItem04,\r
142             this.ConMenuItem05,\r
143             this.ConSeparator02,\r
144             this.ConMenuItem06,\r
145             this.ConMenuItem07});\r
146             this.contextMenuStrip1.Name = "contextMenuStrip1";\r
147             this.contextMenuStrip1.Size = new System.Drawing.Size(153, 192);\r
148             // \r
149             // ConMenuItem01\r
150             // \r
151             this.ConMenuItem01.Name = "ConMenuItem01";\r
152             this.ConMenuItem01.Size = new System.Drawing.Size(152, 22);\r
153             this.ConMenuItem01.Text = "閉じる";\r
154             this.ConMenuItem01.Click += new System.EventHandler(this.ConMenuItem01_Click);\r
155             // \r
156             // ConMenuItem02\r
157             // \r
158             this.ConMenuItem02.Name = "ConMenuItem02";\r
159             this.ConMenuItem02.Size = new System.Drawing.Size(152, 22);\r
160             this.ConMenuItem02.Text = "他を閉じる";\r
161             this.ConMenuItem02.Click += new System.EventHandler(this.ConMenuItem02_Click);\r
162             // \r
163             // ConMenuItem03\r
164             // \r
165             this.ConMenuItem03.Name = "ConMenuItem03";\r
166             this.ConMenuItem03.Size = new System.Drawing.Size(152, 22);\r
167             this.ConMenuItem03.Text = "すべて閉じる";\r
168             this.ConMenuItem03.Click += new System.EventHandler(this.ConMenuItem03_Click);\r
169             // \r
170             // ConSeparator01\r
171             // \r
172             this.ConSeparator01.Name = "ConSeparator01";\r
173             this.ConSeparator01.Size = new System.Drawing.Size(149, 6);\r
174             // \r
175             // ConMenuItem04\r
176             // \r
177             this.ConMenuItem04.Name = "ConMenuItem04";\r
178             this.ConMenuItem04.Size = new System.Drawing.Size(152, 22);\r
179             this.ConMenuItem04.Text = "再読み込み";\r
180             this.ConMenuItem04.Click += new System.EventHandler(this.ConMenuItem04_Click);\r
181             // \r
182             // ConMenuItem05\r
183             // \r
184             this.ConMenuItem05.Name = "ConMenuItem05";\r
185             this.ConMenuItem05.Size = new System.Drawing.Size(152, 22);\r
186             this.ConMenuItem05.Text = "複製";\r
187             this.ConMenuItem05.Click += new System.EventHandler(this.ConMenuItem05_Click);\r
188             // \r
189             // ConSeparator02\r
190             // \r
191             this.ConSeparator02.Name = "ConSeparator02";\r
192             this.ConSeparator02.Size = new System.Drawing.Size(149, 6);\r
193             // \r
194             // ConMenuItem06\r
195             // \r
196             this.ConMenuItem06.Name = "ConMenuItem06";\r
197             this.ConMenuItem06.Size = new System.Drawing.Size(152, 22);\r
198             this.ConMenuItem06.Text = "保存";\r
199             this.ConMenuItem06.Click += new System.EventHandler(this.ConMenuItem06_Click);\r
200             // \r
201             // ConMenuItem07\r
202             // \r
203             this.ConMenuItem07.Name = "ConMenuItem07";\r
204             this.ConMenuItem07.Size = new System.Drawing.Size(152, 22);\r
205             this.ConMenuItem07.Text = "上書き保存";\r
206             this.ConMenuItem07.Click += new System.EventHandler(this.ConMenuItem07_Click);\r
207             // \r
208             // EditWindow\r
209             // \r
210             this.ClientSize = new System.Drawing.Size(284, 262);\r
211             this.Controls.Add(this.tableLayoutPanel1);\r
212             this.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));\r
213             this.Name = "EditWindow";\r
214             this.TabPageContextMenuStrip = this.contextMenuStrip1;\r
215             this.tableLayoutPanel1.ResumeLayout(false);\r
216             this.contextMenuStrip1.ResumeLayout(false);\r
217             this.ResumeLayout(false);\r
218 \r
219         }\r
220 \r
221         private void EditInitialize()\r
222         {\r
223             this.lexer = new PwrLexer(this.syntaxDocument1, this.codeEditorControl1);\r
224             //\r
225             //tablist1\r
226             //\r
227             this.tablist1 = new Fireball.Windows.Forms.CodeEditor.AutoListForm(this.codeEditorControl1);\r
228             this.tablist1.AutoSize = true;\r
229             this.tablist1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\r
230             this.tablist1.ClientSize = new System.Drawing.Size(167, 164);\r
231             this.tablist1.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;\r
232             this.tablist1.Location = new System.Drawing.Point(0, 0);\r
233             this.tablist1.Name = "tablist1";\r
234             this.tablist1.ShowInTaskbar = false;\r
235             this.tablist1.StartPosition = System.Windows.Forms.FormStartPosition.Manual;\r
236             this.tablist1.Visible = false;\r
237             this.codeEditorControl1.TextChanged += new System.EventHandler(this.codeEditorControl1_TextChanged);\r
238         }\r
239 \r
240         public Fireball.Windows.Forms.CodeEditorControl getEditor()\r
241         {\r
242             return this.codeEditorControl1;\r
243         }\r
244 \r
245         private void codeEditorControl1_TextChanged(object sender, EventArgs e)\r
246         {\r
247             this.lexer.TextChanged();\r
248             if (this.Text[this.Text.Length - 1] != '*' && loaded) this.Text += "*";\r
249         }\r
250 \r
251         public void EditWindow_Deactivate(object sender, EventArgs e)\r
252         {\r
253             this.codeEditorControl1.AutoListVisible = false;\r
254         }\r
255 \r
256         public void WindowSave()\r
257         {\r
258             if (this.Text[this.Text.Length - 1] == '*')\r
259             {\r
260                 if (this.path == "")\r
261                 {\r
262                     if (System.Windows.Forms.MessageBox.Show("新規ファイルを保存しますか?",\r
263                         "質問",\r
264                         System.Windows.Forms.MessageBoxButtons.YesNo,\r
265                         System.Windows.Forms.MessageBoxIcon.Exclamation,\r
266                         System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)\r
267                     {\r
268                         FileStream f = Settings.FileControl.getSaveFile();\r
269                         if (f != null)\r
270                         {\r
271                             StreamWriter fw = new StreamWriter(f, System.Text.Encoding.GetEncoding(Settings.FileControl.CharacterCode));\r
272                             fw.Write(this.syntaxDocument1.Text);\r
273                             fw.Close();\r
274                             f.Close();\r
275                         }\r
276                     }\r
277                 }\r
278                 else\r
279                 {\r
280                     FileStream f = new FileStream(this.path, FileMode.Create);\r
281                     StreamWriter fw = new StreamWriter(f, System.Text.Encoding.GetEncoding(Settings.FileControl.CharacterCode));\r
282                     fw.Write(this.syntaxDocument1.Text);\r
283                     fw.Close();\r
284                     f.Close();\r
285                 }\r
286             }\r
287         }\r
288 \r
289         public void WindowSaveAs()\r
290         {\r
291 \r
292             FileStream f = Settings.FileControl.getSaveFile();\r
293             if (f != null)\r
294             {\r
295                 this.path = f.Name;\r
296                 StreamWriter fw = new StreamWriter(f, System.Text.Encoding.GetEncoding(Settings.FileControl.CharacterCode));\r
297                 fw.Write(this.syntaxDocument1.Text);\r
298                 fw.Close();\r
299                 f.Close();\r
300             }\r
301         }\r
302 \r
303         private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\r
304         private Fireball.Windows.Forms.CodeEditorControl codeEditorControl1;\r
305         public Fireball.Syntax.SyntaxDocument syntaxDocument1;\r
306         private Fireball.Windows.Forms.CodeEditor.AutoListForm tablist1;\r
307         private System.ComponentModel.IContainer components;\r
308         private PwrLexer lexer;\r
309 \r
310         private void ConMenuItem01_Click(object sender, EventArgs e)\r
311         {\r
312             this.WindowSave();\r
313             this.Dispose();\r
314         }\r
315 \r
316         private void ConMenuItem02_Click(object sender, EventArgs e)\r
317         {\r
318             Tools.PropertyManager.editmag.OtherRemoveWindow(this);\r
319         }\r
320 \r
321         private void ConMenuItem03_Click(object sender, EventArgs e)\r
322         {\r
323 \r
324         }\r
325 \r
326         private void ConMenuItem04_Click(object sender, EventArgs e)\r
327         {\r
328 \r
329         }\r
330 \r
331         private void ConMenuItem05_Click(object sender, EventArgs e)\r
332         {\r
333 \r
334         }\r
335 \r
336         private void ConMenuItem06_Click(object sender, EventArgs e)\r
337         {\r
338 \r
339         }\r
340 \r
341         private void ConMenuItem07_Click(object sender, EventArgs e)\r
342         {\r
343 \r
344         }\r
345 \r
346     }\r
347 }\r