public static void Execute() { if (Globals.SciControl == null) { return; } ScintillaControl sci = Globals.SciControl; string selectStr = sci.SelText; if (selectStr.Length < 1) { MessageBox.Show("クラスにするコマンドを選択してください", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Project project = (Project)PluginBase.CurrentProject; if (project == null) { return; } MainForm mainForm = (MainForm)Globals.MainForm; FlashDevelopActions flashDevelopActions = new FlashDevelopActions(mainForm); FileActions fileActions = new FileActions(mainForm, flashDevelopActions); if (!File.Exists(TEMP_PATH)) { StreamWriter tmpWriter = new StreamWriter(TEMP_PATH, false, System.Text.Encoding.UTF8, 512); tmpWriter.Write(TMP_FILE); tmpWriter.Close(); } ITabbedDocument currentDocument = (ITabbedDocument)mainForm.CurrentDocument; String parentPath = System.IO.Path.GetDirectoryName(currentDocument.FileName); fileActions.AddFileFromTemplate(project, parentPath, TEMP_PATH); String fileName = fileActions.ProcessArgs(project, "$(FileName)"); String newFilePath = parentPath + "\\" + fileName + ".as"; if (!File.Exists(newFilePath)) { TraceManager.Add("キャンセルされました"); return; } StreamReader reader = new StreamReader(newFilePath); String value = reader.ReadToEnd(); reader.Close(); StreamWriter writer = new StreamWriter(newFilePath, false, System.Text.Encoding.UTF8, 512); writer.Write(fileActions.ProcessArgs(project, value)); writer.Close(); string insText = "new " + fileName + "()"; sci.BeginUndoAction(); sci.Clear(); sci.InsertText(sci.CurrentPos, insText); sci.SelectionStart = sci.CurrentPos; sci.SelectionEnd = sci.CurrentPos + insText.Length; sci.EndUndoAction(); TraceManager.Add(fileName + " が作成されました"); }