public static void OpenStackLocation(string sourceLocation) { string file = sourceLocation.Split('|').First(); OnNextFileOpenComplete = () => ProcessOpenStackLocation(sourceLocation); Npp.OpenFile(file); //needs to by asynchronous }
static public void SaveAllButNew() { //Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SAVEALLFILES, 0, 0); var files = Npp.GetOpenFiles(); var current = Npp.GetCurrentFile(); foreach (var item in files) { if (Path.IsPathRooted(item)) //the "new" file is not saved so it has no root { Npp.OpenFile(item); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SAVECURRENTFILE, 0, 0); } } Npp.OpenFile(current); }
public ProjectPanel() { InitializeComponent(); this.VisibleChanged += ProjectPanel_VisibleChanged; UpdateButtonsTooltips(); Debugger.OnDebuggerStateChanged += RefreshControls; //tabControl1.Bac tabControl1.AddTab("Code Map", mapPanel = new CodeMapPanel()); tabControl1.AddTab("Favorites", favPanel = new FavoritesPanel()); favPanel.OnOpenScriptRequest = file => { if (file.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)) { LoadScript(file); } else { Npp.OpenFile(file); } }; RefreshControls(); ReloadScriptHistory(); LoadReleaseNotes(); treeView1.AttachMouseControlledZooming(); toolStripPersistance = new ToolStripPersistance(toolStrip1, settingsFile); toolStripPersistance.Load(); //buttons = toolStrip1.Items.Cast<ToolStripItem>().ToArray(); //ButtonsDefaultLayout = buttons.Select(x => x.Name.StartsWith("toolStripSeparator") ? "---" : x.Name).ToArray(); //OrrangeToolstripButtons(); //watcher = new FileSystemWatcher(Plugin.ConfigDir, "toolbar_buttons.txt"); //watcher.NotifyFilter = NotifyFilters.LastWrite; //watcher.Changed += watcher_Changed; //watcher.EnableRaisingEvents = true; }
static public void SaveDocuments(string[] files) { var filesToSave = files.Select(x => Path.GetFullPath(x)); var openFiles = Npp.GetOpenFiles(); var current = Npp.GetCurrentFile(); foreach (var item in files) { if (Path.IsPathRooted(item)) //the "new" file is not saved so it has no root { var path = Path.GetFullPath(item); if (filesToSave.Contains(path)) { Npp.OpenFile(item); Win32.SendMessage(Npp.NppHandle, NppMsg.NPPM_SAVECURRENTFILE, 0, 0); } } } Npp.OpenFile(current); }
static public void NavigateToFileLocation(string sourceLocation) { var location = FileLocation.Parse(sourceLocation); location.Start = Npp.CharOffsetToPosition(location.Start, location.File); location.End = Npp.CharOffsetToPosition(location.End, location.File); TranslateCompiledLocation(location); if (File.Exists(location.File)) { if (Npp.GetCurrentFile().IsSameAs(location.File, true)) { ShowBreakpointSourceLocation(location); } else { OnNextFileOpenComplete = () => ShowBreakpointSourceLocation(location); Npp.OpenFile(location.File); //needs to by asynchronous } } }
public void LoadScript(string scriptFile) { if (!string.IsNullOrWhiteSpace(scriptFile) && File.Exists(scriptFile)) { if (!scriptFile.IsScriptFile()) { MessageBox.Show("The file type '" + Path.GetExtension(scriptFile) + "' is not supported.", "CS-Script"); } else { try { Npp.OpenFile(scriptFile); Project project = CSScriptHelper.GenerateProjectFor(scriptFile); /* * root * references * assembly_1 * assembly_2 * assembly_n * script_1 * script_2 * script_N */ treeView1.BeginUpdate(); treeView1.Nodes.Clear(); TreeNode root = treeView1.Nodes.Add("Script '" + Path.GetFileNameWithoutExtension(scriptFile) + "'"); TreeNode references = root.Nodes.Add("References"); root.SelectedImageIndex = root.ImageIndex = scriptFile.IsVbFile() ? scriptVbImage : scriptImage; references.SelectedImageIndex = references.ImageIndex = assemblyImage; references.ContextMenuStrip = itemContextMenu; root.ContextMenuStrip = solutionContextMenu; root.ToolTipText = "Script: " + scriptFile; Action <TreeNode, string[]> populateNode = (node, files) => { foreach (var file in files) { int imageIndex = includeImage; var info = new ProjectItem(file) { IsPrimary = (file == project.PrimaryScript) }; if (info.IsPrimary) { imageIndex = file.IsVbFile() ? scriptVbImage : scriptImage; } if (info.IsAssembly) { imageIndex = assemblyImage; } node.Nodes.Add(new TreeNode(info.Name) { ImageIndex = imageIndex, SelectedImageIndex = imageIndex, Tag = info, ToolTipText = file, ContextMenuStrip = itemContextMenu }); } ; }; populateNode(references, project.Assemblies); populateNode(root, project.SourceFiles); root.Expand(); treeView1.EndUpdate(); currentScript = scriptFile; CSScriptIntellisense.Plugin.EnsureCurrentFileParsed(); var history = Config.Instance.ScriptHistory.Split('|').ToList(); history.Remove(scriptFile); history.Insert(0, scriptFile); Config.Instance.ScriptHistory = string.Join("|", history.Take(Config.Instance.SciptHistoryMaxCount).ToArray()); Config.Instance.Save(); ReloadScriptHistory(); } catch (Exception e) { //it is not a major use-case so doesn't matter why we failed MessageBox.Show("Cannot load script.\nError: " + e.Message, "CS-Script"); e.LogAsError(); } } } else { MessageBox.Show("Script '" + scriptFile + "' does not exist.", "CS-Script"); } RefreshControls(); }
void EditItem(string scriptFile) { Npp.OpenFile(scriptFile); }