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 + " が作成されました"); }
public void Initialize() { MainFormRef = MainForm; // Mika: added Icons.Initialize(MainForm); Settings.Initialize(MainForm); PluginData.Load(); showProjectClasspaths = Settings.ShowProjectClasspaths; showGlobalClasspaths = Settings.ShowGlobalClasspaths; MainForm.IgnoredKeys.Add(Keys.F5); MainForm.IgnoredKeys.Add(Keys.F8); #region Actions and Event Listeners menus = new FDMenus(MainForm); menus.View.Click += new EventHandler(OpenPanel); menus.GlobalClasspaths.Click += new EventHandler(OpenGlobalClasspaths); menus.ProjectMenu.NewProject.Click += new EventHandler(NewProject); menus.ProjectMenu.OpenProject.Click += new EventHandler(OpenProject); menus.ProjectMenu.CloseProject.Click += new EventHandler(CloseProject); menus.ProjectMenu.TestMovie.Click += new EventHandler(TestMovie); menus.ProjectMenu.BuildProject.Click += new EventHandler(BuildProject); menus.ProjectMenu.Properties.Click += new EventHandler(OpenProjectProperties); menus.RecentComboBox.RequestProject += new ProjectRequestHandler(GetProject); menus.RecentComboBox.OpenProject += new ProjectOpenHandler(OpenProjectSilent); buildActions = new BuildActions(MainForm); buildActions.BuildComplete += new BuildCompleteHandler(BuildComplete); buildActions.ClasspathsChanged += new EventHandler(ProjectClasspathsChanged); flashDevelopActions = new FlashDevelopActions(MainForm); fileActions = new FileActions(pluginUI); fileActions.OpenFile += new FileNameHandler(OpenFile); fileActions.FileDeleted += new FileNameHandler(FileDeleted); fileActions.FileMoved += new FileMovedHandler(FileMoved); projectActions = new ProjectActions(pluginUI); // create our UI surface and a docking panel for it pluginUI = new PluginUI(this, menus, fileActions, projectActions); pluginUI.NewProject += new EventHandler(NewProject); pluginUI.OpenProject += new EventHandler(OpenProject); pluginUI.Rename += new RenameEventHandler(fileActions.Rename); pluginUI.Tree.MovePath += new DragPathEventHandler(fileActions.Move); pluginUI.Tree.CopyPath += new DragPathEventHandler(fileActions.Copy); pluginUI.Menu.Open.Click += new EventHandler(TreeOpenItems); pluginUI.Menu.Execute.Click += new EventHandler(TreeExecuteItems); pluginUI.Menu.Insert.Click += new EventHandler(TreeInsertItem); pluginUI.Menu.AddLibrary.Click += new EventHandler(TreeAddLibraryItems); pluginUI.Menu.AlwaysCompile.Click += new EventHandler(TreeAlwaysCompileItems); pluginUI.Menu.Cut.Click += new EventHandler(TreeCutItems); pluginUI.Menu.Copy.Click += new EventHandler(TreeCopyItems); pluginUI.Menu.Paste.Click += new EventHandler(TreePasteItems); pluginUI.Menu.Delete.Click += new EventHandler(TreeDeleteItems); pluginUI.Menu.LibraryOptions.Click += new EventHandler(TreeLibraryOptions); pluginUI.Menu.Hide.Click += new EventHandler(TreeHideItems); pluginUI.Menu.ShowHidden.Click += new EventHandler(ToggleShowHidden); pluginUI.Menu.AddNewClass.Click += new EventHandler(TreeAddNewClass); pluginUI.Menu.AddNewXml.Click += new EventHandler(TreeAddXml); pluginUI.Menu.AddNewFile.Click += new EventHandler(TreeAddFile); pluginUI.Menu.AddNewFolder.Click += new EventHandler(TreeAddFolder); pluginUI.Menu.AddLibraryAsset.Click += new EventHandler(TreeAddAsset); pluginUI.Menu.AddExistingFile.Click += new EventHandler(TreeAddExistingFile); pluginUI.TreeBar.Refresh.Click += new EventHandler(TreeRefreshNode); menus.RecentComboBox.Rebuild(); #endregion pluginPanel = MainForm.CreateDockingPanel(pluginUI, Guid, Icons.Project.Img, DockState.DockRight); // try to open the last opened project string lastProject = Settings.LastProject; if (Settings.LastProject != "" && File.Exists(Settings.LastProject)) { OpenProjectSilent(lastProject); // if we open the last project right away, we need to give ASCompletion // some time before we can trust that it received our classpaths ok startupTimer = new Timer(); startupTimer.Tick += new EventHandler(ProjectClasspathsChanged); startupTimer.Interval = 1000; startupTimer.Start(); } else { Project = null; } try { ProjectIcon.Associate(); // make sure .fdp points to this instance of FD } catch (UnauthorizedAccessException) { // silent } catch (Exception) { // silent? } }