public void NoteMapGlue_AssignNote_EditorUpdated() { bool result = true; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var noteEditor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(noteEditor); form.Shown += (sender, args) => { var tree = persistence.NewTree(); var sut = new NoteMapGlue(noteEditor, persistence); tree.Tree.RootNode.NoteText = "ABC"; result = noteEditor.HTML != null && noteEditor.HTML.Contains("ABC"); form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result); }
public void ImageLocalProvider_GetUrlDataCalled() { var p = new PersistenceManager(); var tree = p.OpenTree(@"Resources\New Format with Images.mm"); ImageLocalProvider sut = null; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); sut = A.Fake <ImageLocalProvider>(x => x.WithArgumentsForConstructor(() => new ImageLocalProvider(p))); form.Shown += (sender, args) => { editor.HTML = tree.RootNode.FirstChild.NoteText; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); string contentType; A.CallTo(() => sut.GetUrlData("mm://33046437-1659-4d39-91dd-5a420e7c4852.png/", out contentType)).MustHaveHappened(); }
protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { Process p = new Process(); p.StartInfo.FileName = "evolution"; p.StartInfo.Arguments = EmailUri; p.StartInfo.UseShellExecute = false; try { p.Start(); } catch (Exception e) { string message = String.Format("Error running Evolution: {0}", e.Message); Logger.Error(message); HIGMessageDialog dialog = new HIGMessageDialog(editor.Toplevel as Gtk.Window, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, Catalog.GetString("Cannot open email"), message); dialog.Run(); dialog.Destroy(); } return(true); }
public void NoteMapGlue_AssignNoteYahoo() { bool result = true; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var noteEditor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(noteEditor); form.Shown += (sender, args) => { var tree = persistence.OpenTree(@"Resources\Websites.mm"); var sut = new NoteMapGlue(noteEditor, persistence); tree.Tree.RootNode.LastChild.Selected = true; result = noteEditor.HTML != null && noteEditor.HTML.Contains("Yahoo"); form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result); }
public void HtmlImageCreator() { var result = ""; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Shown += (sender, args) => { editor.HTML = null; var sut = new HtmlImageCreator(editor); sut.InsertImage("testimage.png", ""); form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); result = editor.HTML; }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result.ToLower().Contains("<img")); }
protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { string persona = start.GetText(end); PersonLink plink = (PersonLink)galago.Trie.Lookup(persona); try { plink.SendMessage(); } catch (Exception e) { string title = Catalog.GetString("Cannot contact '{0}'"); title = String.Format(title, persona); string message = Catalog.GetString("Error running gaim-remote: {0}"); message = String.Format(message, e.Message); Logger.Log(message); HIGMessageDialog dialog = new HIGMessageDialog(editor.Toplevel as Gtk.Window, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, title, message); dialog.Run(); dialog.Destroy(); } return(true); }
public void NoteMapGlue_AssignNoteBBC_NavigatingEventFires() { int count = 0; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var noteEditor = new NoteEditor(); noteEditor.Navigating += (o, e) => count++; var form = CreateForm(); form.Controls.Add(noteEditor); form.Shown += (sender, args) => { var tree = persistence.OpenTree(@"Resources\Websites.mm"); var sut = new NoteMapGlue(noteEditor, persistence); tree.Tree.RootNode.FirstChild.Selected = true; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(count > 7); }
public void TableInsert() { var result = ""; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Shown += (sender, args) => { editor.HTML = null; var sut = new HtmlTableHelper(editor); sut.TableInsert(new HtmlTableProperty(true)); form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); result = editor.HTML; }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result.ToLower().Contains("</table>")); }
public void PasteFromClipboard_WithEmptyClipboard() { string result = null; System.Threading.Thread t = new System.Threading.Thread(() => { var pManager = new PersistenceManager(); var tree = pManager.NewTree(); var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); var sut = new ClipboardImagePaster(editor, pManager); form.Shown += (sender, args) => { Clipboard.Clear(); ClipboardImagePaster.PasteFromClipboard(editor, tree); result = editor.HTML; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsNull(result); }
public void GetSelectedTable_NoSelection() { bool result = false; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); var sut = new HtmlTableHelper(editor); form.Shown += (sender, args) => { editor.HTML = "Some Text"; var body = editor.Document.Body.DomElement as IHTMLBodyElement; IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange; r.findText("Text"); r.select(); sut.TableInsert(new HtmlTableProperty(true)); result = sut.GetSelectedTable() == null; form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result); }
public void SetNoteEditorBackColor() { bool result = true; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var noteEditor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(noteEditor); form.Shown += (sender, args) => { var ptree1 = persistence.NewTree(); var c1 = new MapNode(ptree1.Tree.RootNode, "c1"); c1.Selected = true; var sut = new NoteEditorCtrl(noteEditor, persistence); sut.SetNoteEditorBackColor(Color.Azure); result = noteEditor.BackColor.Equals(Color.Azure); form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result); }
public void ProcessImages_BBC_CheckImgTags() { var p = new PersistenceManager(); var tree = p.OpenTree(@"Resources\Websites.mm"); string html = null; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); form.Shown += (sender, args) => { editor.HTML = tree.RootNode.FirstChild.NoteText; ImageLocalSaver.ProcessImages(editor.Document, p.CurrentTree); html = editor.HTML; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(html.Contains("srcOrig")); int imgUpdated = Regex.Matches(html, "srcOrig", RegexOptions.IgnoreCase).Count; Assert.AreEqual(79, imgUpdated); int imgCount = Regex.Matches(html, "<img", RegexOptions.IgnoreCase).Count; Assert.IsTrue(imgCount > imgUpdated); }
public void ClipboardImagePaster_FileDropListWithMixedFiles() { string result = null; System.Threading.Thread t = new System.Threading.Thread(() => { var pManager = new PersistenceManager(); pManager.NewTree(); var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); var sut = new ClipboardImagePaster(editor, pManager); form.Shown += (sender, args) => { var fileList = new StringCollection(); fileList.Add(Path.GetFullPath(@"Resources\Sample Map.mm")); fileList.Add(Path.GetFullPath(@"Resources\MapCtrl1.png")); Clipboard.SetFileDropList(fileList); editor.Paste(); result = editor.HTML; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result.ToLower().Contains("img")); Assert.AreEqual(1, result.ToLower().Where(a => a == '.').Count()); }
public NoteEditorCtrl(NoteEditor editor, PersistenceManager pManager) { this.noteGlue = new NoteMapGlue(editor, pManager); new ImageLocalSaver(editor, pManager); new ImageLocalProvider(pManager); new ClipboardImagePaster(editor, pManager); }
public SideTabControl() { Dock = DockStyle.Fill; //SideBarTabs.Alignment = TabAlignment.Bottom; ImageList imageList = new ImageList(); imageList.Images.Add(MindMate.Properties.Resources.sticky_note_pin); ImageList = imageList; //create Note Editor tab in sidebar NoteTab = new TabPage(NoteTabTitle) { ImageIndex = 0 }; NoteEditor = new NoteEditor { Dock = DockStyle.Fill }; NoteTab.Controls.Add(NoteEditor); TabPages.Add(NoteTab); //create Search Tab in sidebar var searchTab = new TabPage(SearchTabTitle); var searchControl = new Search.SearchControl() { Dock = DockStyle.Fill }; searchTab.Controls.Add(searchControl); TabPages.Add(searchTab); }
public void ClipboardImagePaster_FileDropListWithNoImages() { string result = null; System.Threading.Thread t = new System.Threading.Thread(() => { var pManager = new PersistenceManager(); pManager.NewTree(); var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); var sut = new ImagePaster(editor, pManager); form.Shown += (sender, args) => { var fileList = new StringCollection(); fileList.Add(Path.GetFullPath(@"Resources\Sample Map.mm")); Clipboard.SetFileDropList(fileList); editor.Paste(); result = editor.HTML; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsNull(result); }
public void PasteFromClipboard() { string result = null; System.Threading.Thread t = new System.Threading.Thread(() => { var pManager = new PersistenceManager(); var tree = pManager.NewTree(); var editor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(editor); var sut = new ClipboardImagePaster(editor, pManager); form.Shown += (sender, args) => { Clipboard.SetImage(Bitmap.FromFile(@"Resources\MapCtrl1.png")); ClipboardImagePaster.PasteFromClipboard(editor, tree); result = editor.HTML; form.Close(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result.ToLower().Contains("img")); }
private void TextBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (NoteEditor.Visibility == Visibility.Visible) { NoteEditor.BackgroundFocus(); NoteEditor.BackgroundSelectAll(); } }
public NoteEditorCtrl(NoteEditor editor, PersistenceManager pManager, DialogManager dialogs) { this.noteGlue = new NoteMapGlue(editor, pManager); new ImageLocalSaver(editor, pManager); new ImageLocalProvider(pManager); new ImagePaster(editor, pManager); this.dialogs = dialogs; }
/// <summary> /// Method used when user clicks on tag. Synchronusly starts DecryptPassAsync(). /// </summary> /// <param name="tag"> NoteTag which was clicked. </param> /// <param name="editor"> NoteEditor in which NoteTag was clicked. </param> /// <param name="start"> TextIter pointiong to beginning of tag. </param> /// <param name="end"> TextIter pointiong to end of tag. </param> /// <returns> Returns true if password contained in tag is not empty string. </returns> protected bool PassEncryptTag_Activated(NoteTag tag, NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { string encPass = (tag as PassEncryptTag).Attributes[AtrName]; if (string.IsNullOrWhiteSpace(encPass)) { return(false); } DecryptPassAsync(encPass); return(true); }
public void NoteEditorContextMenu() { System.Threading.Thread t = new System.Threading.Thread(() => { NoteEditor editor = new NoteEditor(); new NoteEditorContextMenu(editor); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); }
protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { if (BugUrl != string.Empty) { Logger.Debug("Opening url '{0}'...", BugUrl); try { Services.NativeApplication.OpenUrl(BugUrl, editor.Screen); } catch (Exception e) { GuiUtils.ShowOpeningLocationError(null, BugUrl, e.Message); } } return(true); }
public void ShowHtmlSourceDialog() { string result = null; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var noteEditor = new NoteEditor(); var form = CreateForm(); form.Controls.Add(noteEditor); form.Shown += (sender, args) => { var ptree1 = persistence.NewTree(); var c1 = new MapNode(ptree1.Tree.RootNode, "c1"); c1.NoteText = "This is a note."; c1.Selected = true; var sut = new NoteEditorCtrl(noteEditor, persistence); Debugging.FormDebugHooks.Instance.ProvideShownEventHook((o, e) => { var f = (HtmlSourceDialog)o; foreach (Control c in f.Controls) { if (c.Name == "txtSource") { c.Text = "updated"; break; } } f.DialogResult = DialogResult.OK; }); sut.ShowHtmlSourceDialog(); result = noteEditor.HTML; form.Close(); Debugging.FormDebugHooks.Instance.ClearHook(); }; form.ShowDialog(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.AreEqual("updated", result); }
private void SearchNoteResultsHandler(object sender, EventArgs e) { if (CurrentNote != null) { NoteEditor noteEditor = CurrentNote.Document.Parent as NoteEditor; noteEditor.SearchTerm = String.Empty; // clear the property first so we can trigger DependencyPropertyChangedEvent on dependency property if (_searchService.IsSearchInProgress() == true) { noteEditor.SearchTerm = _searchService.SearchTerm; } } _searchNoteResultsTimer.Stop(); // search complete }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); var couchClient = new DreamSeat.CouchClient("localhost", 5984); couchClient.GetDatabase ("explosions", new Result<CouchDatabase>()).WhenDone((database) => { Console.Out.WriteLine("SUCCESS!"); }, e => { Console.Out.WriteLine ("Failure! :( " + e.Message); }); var editor = new NoteEditor(); this.notebook1.Add(editor); editor.Show(); }
public void DeleteColumn() { var rowCount = 0; var colCount = 0; var tabCols = 0; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Shown += (sender, args) => { //insert table editor.HTML = "Some Text There"; var body = editor.Document.Body.DomElement as IHTMLBodyElement; IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange; r.findText("Text"); r.select(); var sut = new HtmlTableHelper(editor); sut.TableInsert(new HtmlTableProperty(true)); //move inside table IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange; r2.findText("Text"); r2.select(); //modify table sut.DeleteColumn(); form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); rowCount = GetTable(editor).rows.length; colCount = (GetTable(editor).rows.item(0) as IHTMLTableRow).cells.length; tabCols = GetTable(editor).cols; }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.AreEqual(3, rowCount); Assert.AreEqual(2, colCount); Assert.AreEqual(2, tabCols); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); var couchClient = new DreamSeat.CouchClient("localhost", 5984); couchClient.GetDatabase("explosions", new Result <CouchDatabase>()).WhenDone((database) => { Console.Out.WriteLine("SUCCESS!"); }, e => { Console.Out.WriteLine("Failure! :( " + e.Message); }); var editor = new NoteEditor(); this.notebook1.Add(editor); editor.Show(); }
public void NoteMapGlue() { NoteMapGlue sut = null; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var persistence = new PersistenceManager(); var nodeEditor = new NoteEditor(); sut = new NoteMapGlue(nodeEditor, persistence); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsNotNull(sut); }
public void TableModify_ContainingTable() { var result = ""; var tableCount = 0; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Shown += (sender, args) => { //insert table editor.HTML = "Some Text There"; var body = editor.Document.Body.DomElement as IHTMLBodyElement; IHTMLTxtRange r = body.createTextRange() as IHTMLTxtRange; r.findText("Text"); r.select(); var sut = new HtmlTableHelper(editor); sut.TableInsert(new HtmlTableProperty(true)); //move inside table IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange; r2.findText("Text"); r2.select(); //modify table var prop = new HtmlTableProperty(true); prop.CaptionText = "Table modified"; sut.TableModify(prop); form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); result = editor.HTML; tableCount = editor.Document.GetElementsByTagName("table").Count; }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(result.Contains("Table modified")); Assert.AreEqual(1, tableCount); }
public void ColumnMoveLeft() { string cellValue = "empty"; string cellValue2 = "empty"; System.Threading.Thread t = new System.Threading.Thread(() => { var editor = new NoteEditor(); var form = CreateForm(); form.Shown += (sender, args) => { //insert table var sut = new HtmlTableHelper(editor); sut.TableInsert(new HtmlTableProperty(true)); //fill table FillTable((editor.Document.GetElementsByTagName("table")[0].DomElement) as IHTMLTable); //move inside table var body = editor.Document.Body.DomElement as IHTMLBodyElement; IHTMLTxtRange r2 = body.createTextRange() as IHTMLTxtRange; r2.findText("r0c1"); r2.select(); //modify table sut.ColumnMoveLeft(); form.Close(); }; form.Controls.Add(editor); form.ShowDialog(); cellValue = GetCellValue(GetTable(editor), 1, 0); cellValue2 = GetCellValue(GetTable(editor), 1, 1); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.AreEqual("r1c1", cellValue); Assert.AreEqual("r1c0", cellValue2); }
public SideTabControl() { Dock = DockStyle.Fill; //SideBarTabs.Alignment = TabAlignment.Bottom; ImageList imageList = new ImageList(); imageList.Images.Add(MindMate.Properties.Resources.sticky_note_pin); ImageList = imageList; NoteTab = new TabPage(NoteTabTitle) { ImageIndex = 0 }; NoteEditor = new NoteEditor { Dock = DockStyle.Fill }; NoteTab.Controls.Add(NoteEditor); TabPages.Add(NoteTab); }
/// <summary> /// Handles the click on the datetag: /// Opens up a calendar dialog /// </summary> /// <param name="editor"> /// A <see cref="NoteEditor"/> /// </param> /// <param name="start"> /// A <see cref="Gtk.TextIter"/> /// </param> /// <param name="end"> /// A <see cref="Gtk.TextIter"/> /// </param> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { calendar = new Calendar (); range = new TextRange (start, end); this.editor = editor; Dialog dialog = new Dialog (); dialog.Modal = true; dialog.VBox.Add (calendar); dialog.VBox.ShowAll (); dialog.AddButton ("OK", ResponseType.Ok); dialog.AddButton ("Cancel", ResponseType.Cancel); dialog.Response += new ResponseHandler (OnDialogResponse); dialog.Run (); dialog.Destroy (); return true; }