public void TdiTabClosedEventForDialogInSliderTest() { GtkInit.AtOnceInitGtk(); bool notebookEventRised = false, tabEventRised = false; var tabJournal = new EmptyJournalTab(); tabJournal.UseSlider = true; var tab = new EmptyDlg(); tab.TabClosed += (sender, e) => tabEventRised = true; var notebook = new TdiNotebook(); notebook.TabClosed += (sender, e) => notebookEventRised = (e.Tab == tab); notebook.AddTab(tabJournal); tabJournal.TabParent.AddTab(tab, tabJournal); var slider = tabJournal.TabParent as TdiSliderTab; Assert.That(slider.ActiveDialog, Is.EqualTo(tab)); notebook.ForceCloseTab(tab, CloseSource.External); Assert.That(slider.ActiveDialog, Is.Null); Assert.That(tabEventRised, Is.True); Assert.That(notebookEventRised, Is.True); }
public static void HandleKeyPressEvent(object o, KeyPressEventArgs args) { TdiNotebook mainNotebook = MainClass.MainWin.TdiMain; if (mainNotebook == null) { throw new InvalidOperationException( "Вызвано событие TDIHandleKeyPressEvent, но для его корректной работы необходимо заполнить TDIMain.MainNotebook."); } int platform = (int)Environment.OSVersion.Platform; int version = Environment.OSVersion.Version.Major; Gdk.ModifierType modifier; //Kind of MacOSXCou if ((platform == 4 || platform == 6 || platform == 128) && version > 8) { modifier = Gdk.ModifierType.MetaMask | Gdk.ModifierType.Mod1Mask; } //Kind of Windows or Unix else { modifier = Gdk.ModifierType.ControlMask; } //CTRL+C if ((args.Event.Key == Gdk.Key.Cyrillic_es || args.Event.Key == Gdk.Key.Cyrillic_ES || args.Event.Key == Gdk.Key.c || args.Event.Key == Gdk.Key.C) && args.Event.State.HasFlag(modifier)) { Widget w = (o as Window).Focus; CopyToClipboard(w); } //CTRL+X else if ((args.Event.Key == Gdk.Key.Cyrillic_che || args.Event.Key == Gdk.Key.Cyrillic_CHE || args.Event.Key == Gdk.Key.x || args.Event.Key == Gdk.Key.X) && args.Event.State.HasFlag(modifier)) { Widget w = (o as Window).Focus; CutToClipboard(w); } //CTRL+V else if ((args.Event.Key == Gdk.Key.Cyrillic_em || args.Event.Key == Gdk.Key.Cyrillic_EM || args.Event.Key == Gdk.Key.v || args.Event.Key == Gdk.Key.V) && args.Event.State.HasFlag(modifier)) { Widget w = (o as Window).Focus; PasteFromClipboard(w); } //CTRL+A else if ((args.Event.Key == Gdk.Key.Cyrillic_ef || args.Event.Key == Gdk.Key.Cyrillic_EF || args.Event.Key == Gdk.Key.a || args.Event.Key == Gdk.Key.A) && args.Event.State.HasFlag(modifier)) { Widget w = (o as Window).Focus; SelectAllText(w); } }
public void TdiTabClosedEventTest() { var tab = Substitute.For <ITdiTab, Gtk.Widget>(); var notebook = new TdiNotebook(); notebook.AddTab(tab); Assert.That(notebook.Tabs.First().TdiTab, Is.EqualTo(tab)); notebook.ForceCloseTab(tab, CloseSource.External); tab.Received().OnTabClosed(); Assert.That(notebook.Tabs.Count, Is.EqualTo(0)); }
public void TdiTabClosedEventWithSliderTest() { var tab = Substitute.For <ITdiJournal, Gtk.Widget>(); tab.UseSlider.Returns(true); var notebook = new TdiNotebook(); notebook.AddTab(tab); Assert.That(notebook.Tabs.First().TdiTab, Is.InstanceOf <TdiSliderTab>()); notebook.ForceCloseTab(tab, CloseSource.External); tab.Received().OnTabClosed(); Assert.That(notebook.Tabs.Count, Is.EqualTo(0)); }
public TdiNavigationManager( TdiNotebook tdiNotebook, IViewModelsPageFactory viewModelsFactory, IInteractiveMessage interactive, IPageHashGenerator hashGenerator = null, ITdiPageFactory tdiPageFactory = null, AutofacViewModelsGtkPageFactory viewModelsGtkPageFactory = null, IGtkViewResolver viewResolver = null) : base(interactive, hashGenerator) { this.tdiNotebook = tdiNotebook ?? throw new ArgumentNullException(nameof(tdiNotebook)); this.tdiPageFactory = tdiPageFactory; this.viewModelsFactory = viewModelsFactory ?? throw new ArgumentNullException(nameof(viewModelsFactory)); this.viewModelsGtkWindowsFactory = viewModelsGtkPageFactory; this.viewResolver = viewResolver; tdiNotebook.TabClosed += TdiNotebook_TabClosed; }