public void ProcessCommand(string val, IYnote ynote) { //TODO:Performance var tb = (ynote.Panel.ActiveDocument as Editor).Tb; if (tb != null) { if (val == "Readable") { tb.Selection.ReadOnly = true; } else if (val == "Writeable") { tb.Selection.ReadOnly = false; } else if (val == "GoWordRight") { tb.Selection.GoWordRight(true); } else if (val == "GoWordLeft") { tb.Selection.GoWordLeft(true); } else if (val == "Expand") { tb.Selection.Expand(); } } }
public void ProcessCommand(string val, IYnote ynote) { var activeEditor = ynote.Panel.ActiveDocument as Editor; if (activeEditor == null) { return; } switch (val) { case "Back": activeEditor.Tb.NavigateBackward(); break; case "Forward": activeEditor.Tb.NavigateForward(); break; case "GoLeftBracket": activeEditor.Tb.GoLeftBracket(); break; case "GoRightBracket": activeEditor.Tb.GoRightBracket(); break; } }
public void ProcessCommand(string value, IYnote ynote) { if (ynote.Panel.ActiveDocument == null || !(ynote.Panel.ActiveDocument is Editor)) { return; } var edit = ynote.Panel.ActiveDocument as Editor; switch (value) { case "Increase": edit.Tb.IncreaseIndent(); break; case "Decrease": edit.Tb.DecreaseIndent(); break; case "Format": if (edit.Tb.Language == "Xml") { edit.Tb.Text = PrettyXml(edit.Tb.Text); } else { edit.Tb.DoAutoIndent(); } break; } }
public static void RunScript(IYnote ynote, string ysfile) { var assemblyFileName = ysfile + "c"; CSScript.GlobalSettings.TargetFramework = "v3.5"; //try //{ // var helper = // new AsmHelper(CSScript.LoadMethod(File.ReadAllText(ysfile), GetReferences())); // helper.Invoke("*.Run", ynote); var assembly = !File.Exists(assemblyFileName) ? CSScript.LoadMethod(File.ReadAllText(ysfile), assemblyFileName, false, GetReferences()) : Assembly.LoadFrom(assemblyFileName); using (var execManager = new AsmHelper(assembly)) { execManager.Invoke("*.Main", ynote); } //} //catch (Exception ex) //{ // MessageBox.Show("There was an Error running the script : \r\n" + ex.Message, "YnoteScript Host", // MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //} }
public void Main(IYnote ynote) { var m = new MenuItem(); int index = ((int)(YnoteMenu.ViewMenu)); m.Text = "Say Hello"; m.Click += (sender, args) => MessageBox.Show("Hello, World!"); ynote.Menu.MenuItems[index].MenuItems.Add(m); }
public void Main(IYnote ynote) { var m = new MenuItem(); int index = ((int)(YnoteMenu.ViewMenu)); m.Text = "Window Plugin"; m.Click += (sender, args) => new Window(ynote).Show(ynote.Panel,DockState.DockLeft); ynote.Menu.MenuItems[index].MenuItems.Add(m); m.Index = 7; }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; switch (val) { case "New": ynote.CreateNewDoc(); break; case "Open": using (var dlg = new OpenFileDialog()) { dlg.Filter = "All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) ynote.OpenFile(dlg.FileName); } break; case "Save": ynote.SaveEditor(ynote.Panel.ActiveDocument as Editor); break; case "SaveAll": foreach (Editor item in ynote.Panel.Documents.OfType<Editor>()) ynote.SaveEditor(item); break; case "Properties": if (edit.IsSaved) NativeMethods.ShowFileProperties(edit.Name); break; case "Revert": if (edit == null || !edit.IsSaved) return; edit.Tb.OpenFile(edit.Name); edit.Text = Path.GetFileName(edit.Name); break; case "Close": edit.Close(); break; case "CloseAll": foreach (Editor doc in ynote.Panel.Documents.OfType<Editor>()) doc.Close(); break; case "Delete": var filename = edit.Name; if (!edit.IsSaved) return; var result = MessageBox.Show("Are you sure you want to Delete " + edit.Text + " ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { File.Delete(filename); edit.Close(); } break; } }
public void ProcessCommand(string val, IYnote ynote) { var tb = (ynote.Panel.ActiveDocument as Editor).Tb; if (val == "FoldAll") tb.CollapseAllFoldingBlocks(); else if (val == "ExpandAll") tb.ExpandAllFoldingBlocks(); else if (val == "FoldSelection") tb.CollapseBlock(tb.SelectionStart, tb.Selection.End.iLine); }
public void ProcessCommand(string val, IYnote ynote) { foreach (var file in Directory.GetFiles(GlobalSettings.SettingsDir, "*.ys", SearchOption.AllDirectories)) { if (Path.GetFileName(file) == val + ".ys") { YnoteScript.RunScript(ynote, file); } } }
private static bool FileExists(IYnote ynote, string file) { try { return(ynote.Panel.Documents.Cast <Editor>().Any(doc => doc.Name == file)); } catch { } return(false); }
public void ProcessCommand(string val, IYnote ynote) { var ae = ynote.Panel.ActiveDocument as Editor; if (ae == null) { return; } ae.HighlightSyntax(val); ae.Tb.Language = val; }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; foreach (var snippet in Globals.Snippets) { if (Path.GetFileNameWithoutExtension(snippet.File) == val) { edit.InsertSnippet(snippet); } } }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; foreach (var file in Directory.GetFiles(GlobalSettings.SettingsDir, "*.ynotemacro", SearchOption.AllDirectories)) { if (Path.GetFileName(file) == val + ".ynotemacro") { edit.Tb.MacrosManager.ExecuteMacros(file); } } }
private static ICommand GetCommand(string script, IYnote ynote) { try { return(YnoteScript.Get <ICommand>(ynote, script, "*.GetCommand")); } catch (Exception ex) { MessageBox.Show("There was an Error running the script : \r\n" + ex.Message, "YnoteScript Host", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } }
private static ICommand GetCommand(string script, IYnote ynote) { try { return YnoteScript.Get<ICommand>(ynote, script, "*.GetCommand"); } catch (Exception ex) { MessageBox.Show("There was an Error running the script : \r\n" + ex.Message, "YnoteScript Host", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; } }
public static void RunCommand(IYnote ynote, string commandstr) { var command = YnoteCommand.FromString(commandstr); if (Globals.Commands == null) ReloadCommands(); foreach (var cmd in Globals.Commands) { if (cmd.Key == command.Key) { cmd.ProcessCommand(command.Value, ynote); break; } } }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; var item = RunScript.Get(GlobalSettings.SettingsDir + @"RunScripts\" + val + ".ynoterun"); if (item == null) { return; } if (edit != null) // item.ProcessConfiguration(edit.Name); { item.Run(); } }
public static void RunCommand(IYnote ynote, string commandstr) { var command = YnoteCommand.FromString(commandstr); if (Commands == null) { ReloadCommands(); } foreach (var cmd in Commands) { if (cmd.Key == command.Key) { cmd.ProcessCommand(command.Value, ynote); break; } } }
public void ProcessCommand(string val, IYnote ynote) { var tb = (ynote.Panel.ActiveDocument as Editor).Tb; if (val == "FoldAll") { tb.CollapseAllFoldingBlocks(); } else if (val == "ExpandAll") { tb.ExpandAllFoldingBlocks(); } else if (val == "FoldSelection") { tb.CollapseBlock(tb.SelectionStart, tb.Selection.End.iLine); } }
/// <summary> /// Exands an abbreviation /// </summary> /// <param name="abbr"></param> /// <param name="ynote"></param> /// <returns></returns> public static string ExpandAbbr(string abbr, IYnote ynote) { string expanded = abbr; var edit = ynote.Panel.ActiveDocument as Editor; if (abbr.Contains("$source")) { expanded = expanded.Replace("$source_dir", Path.GetDirectoryName(edit.Name)); expanded = expanded.Replace("$source_extension", Path.GetExtension(edit.Name)); expanded = expanded.Replace("$source_name", edit.Text.Substring(0, edit.Text.LastIndexOf('.'))); expanded = expanded.Replace("$source", edit.Name); } if (expanded.Contains("$project")) { if (ActiveProject != null) expanded = expanded.Replace("$project_dir", ActiveProject.Path) .Replace("$project_name", ActiveProject.Name); } return expanded; }
public void ProcessCommand(string val, IYnote ynote) { var activeEditor = ynote.Panel.ActiveDocument as Editor; switch (val) { case "MoveDown": activeEditor.Tb.MoveSelectedLinesDown(); break; case "MoveUp": activeEditor.Tb.MoveSelectedLinesUp(); break; case "Duplicate": activeEditor.Tb.DuplicateLine(activeEditor.Tb.Selection.Start.iLine); break; case "Join": var lns = activeEditor.Tb.SelectedText.Split(new[] { Environment.NewLine }, StringSplitOptions.None); activeEditor.Tb.SelectedText = string.Join(" ", lns); break; case "Sort": var fctb = activeEditor.Tb; string[] lines; if (string.IsNullOrEmpty(fctb.SelectedText)) { lines = fctb.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); } else { lines = fctb.SelectedText.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); } Array.Reverse(lines); var formedtext = lines.Aggregate <string, string>(null, (current, line) => current + (line + "\r\n")); fctb.SelectedText = formedtext; break; } }
/// <summary> /// Exands an abbreviation /// </summary> /// <param name="abbr"></param> /// <param name="ynote"></param> /// <returns></returns> public static string ExpandAbbr(string abbr, IYnote ynote) { string expanded = abbr; var edit = ynote.Panel.ActiveDocument as Editor; if (abbr.Contains("$source")) { expanded = expanded.Replace("$source_dir", Path.GetDirectoryName(edit.Name)); expanded = expanded.Replace("$source_extension", Path.GetExtension(edit.Name)); expanded = expanded.Replace("$source_name", edit.Text.Substring(0, edit.Text.LastIndexOf('.'))); expanded = expanded.Replace("$source", edit.Name); } if (expanded.Contains("$project")) { if (ActiveProject != null) { expanded = expanded.Replace("$project_dir", ActiveProject.Path) .Replace("$project_name", ActiveProject.Name); } } return(expanded); }
public SearchResults(IYnote ynote) { InitializeComponent(); _ynote = ynote; }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; switch (val) { case "New": ynote.CreateNewDoc(); break; case "Open": using (var dlg = new OpenFileDialog()) { dlg.Filter = "All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { ynote.OpenFile(dlg.FileName); } } break; case "Save": ynote.SaveEditor(ynote.Panel.ActiveDocument as Editor); break; case "SaveAll": foreach (Editor item in ynote.Panel.Documents.OfType <Editor>()) { ynote.SaveEditor(item); } break; case "Properties": if (edit.IsSaved) { NativeMethods.ShowFileProperties(edit.Name); } break; case "Revert": if (edit == null || !edit.IsSaved) { return; } edit.Tb.OpenFile(edit.Name); edit.Text = Path.GetFileName(edit.Name); break; case "Close": edit.Close(); break; case "CloseAll": foreach (Editor doc in ynote.Panel.Documents.OfType <Editor>()) { doc.Close(); } break; case "Delete": var filename = edit.Name; if (!edit.IsSaved) { return; } var result = MessageBox.Show("Are you sure you want to Delete " + edit.Text + " ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { File.Delete(filename); edit.Close(); } break; } }
public void ProcessCommand(string val, IYnote ynote) { Process.Start("http://en.wikipedia.org/w/index.php?search=" + val); }
public Window(IYnote ynote) { InitializeComponent(); this._ynote = ynote; }
private static bool FileExists(IYnote ynote, string file) { try { return ynote.Panel.Documents.Cast<Editor>().Any(doc => doc.Name == file); } catch { } return false; }
public void ProcessCommand(string val, IYnote ynote) { var activeEditor = ynote.Panel.ActiveDocument as Editor; switch (val) { case "MoveDown": activeEditor.Tb.MoveSelectedLinesDown(); break; case "MoveUp": activeEditor.Tb.MoveSelectedLinesUp(); break; case "Duplicate": activeEditor.Tb.DuplicateLine(activeEditor.Tb.Selection.Start.iLine); break; case "Join": var lns = activeEditor.Tb.SelectedText.Split(new[] {Environment.NewLine}, StringSplitOptions.None); activeEditor.Tb.SelectedText = string.Join(" ", lns); break; case "Sort": var fctb = activeEditor.Tb; string[] lines; if (string.IsNullOrEmpty(fctb.SelectedText)) lines = fctb.Text.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); else lines = fctb.SelectedText.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); Array.Reverse(lines); var formedtext = lines.Aggregate<string, string>(null, (current, line) => current + (line + "\r\n")); fctb.SelectedText = formedtext; break; } }
public void ProcessCommand(string val, IYnote ynote) { var ae = ynote.Panel.ActiveDocument as Editor; if (ae == null) return; ae.HighlightSyntax(val); ae.Tb.Language = val; }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; foreach (var snippet in Globals.Snippets) if (Path.GetFileNameWithoutExtension(snippet.File) == val) edit.InsertSnippet(snippet); }
public void ProcessCommand(string val, IYnote ynote) { //TODO:Performance var tb = (ynote.Panel.ActiveDocument as Editor).Tb; if (tb != null) { if (val == "Readable") tb.Selection.ReadOnly = true; else if (val == "Writeable") tb.Selection.ReadOnly = false; else if (val == "GoWordRight") tb.Selection.GoWordRight(true); else if (val == "GoWordLeft") tb.Selection.GoWordLeft(true); else if (val == "Expand") tb.Selection.Expand(); } }
public void ProcessCommand(string val, IYnote ynote) { foreach (var file in Directory.GetFiles(GlobalSettings.SettingsDir, "*.ys", SearchOption.AllDirectories)) if (Path.GetFileName(file) == val + ".ys") YnoteScript.RunScript(ynote, file); }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; var item = RunScript.Get(GlobalSettings.SettingsDir + @"RunScripts\" + val + ".ynoterun"); if (item == null) return; if (edit != null) // item.ProcessConfiguration(edit.Name); item.Run(); }
public void ProcessCommand(string val, IYnote ynote) { var edit = ynote.Panel.ActiveDocument as Editor; foreach (var file in Directory.GetFiles(GlobalSettings.SettingsDir, "*.ynotemacro", SearchOption.AllDirectories) ) if (Path.GetFileName(file) == val + ".ynotemacro") edit.Tb.MacrosManager.ExecuteMacros(file); }
public void ProcessCommand(string val, IYnote ynote) { var activeEditor = ynote.Panel.ActiveDocument as Editor; if (activeEditor == null) return; switch (val) { case "Back": activeEditor.Tb.NavigateBackward(); break; case "Forward": activeEditor.Tb.NavigateForward(); break; case "GoLeftBracket": activeEditor.Tb.GoLeftBracket(); break; case "GoRightBracket": activeEditor.Tb.GoRightBracket(); break; } }
public void ProcessCommand(string value, IYnote ynote) { if (ynote.Panel.ActiveDocument == null || !(ynote.Panel.ActiveDocument is Editor)) return; var edit = ynote.Panel.ActiveDocument as Editor; switch (value) { case "Increase": edit.Tb.IncreaseIndent(); break; case "Decrease": edit.Tb.DecreaseIndent(); break; case "Format": if (edit.Tb.Language == "Xml") edit.Tb.Text = PrettyXml(edit.Tb.Text); else edit.Tb.DoAutoIndent(); break; } }
public void ProcessCommand(string val, IYnote ynote) { Process.Start("http://google.com/search?q=" + val); }