public static void RegisterMasterTab <T>(this IRegionManager regionManager, string subTabRegionName, string contentRegionName, string tabRegion, IWhitelistedServiceLocator whitelistedServiceLocator) where T : class, ITabViewModel, IWhitelisted { regionManager.RegisterViewWithRegion(tabRegion, () => { ITabViewModel viewModel = whitelistedServiceLocator.GetInstance <T>(); var tab = new TabItem(); var masterIconTabHeader = new MasterIconTabHeader(subTabRegionName); var contentContainer = new Grid(); var tabContent = new ContentControl(); tabContent.Padding = ContentPadding; tabContent.IsTabStop = false; tab.Header = masterIconTabHeader; tabContent.SetValue(RegionManager.RegionNameProperty, contentRegionName); tabContent.DataContext = viewModel; masterIconTabHeader.DataContext = viewModel; contentContainer.Children.Add(tabContent); AddGpoBehavior(tab, contentContainer, viewModel); tab.Content = contentContainer; return(tab); }); }
public void CloseItem(ITabViewModel anItem) { if (!(anItem is HomeViewModel)) { DeactivateItem(anItem, true); } }
public void RenameTabItem(string fileName) { // rename tab ITabViewModel <T> tabItem = TabItems[SelectedIndex]; if (this is FilterViewModel) { Settings.RemoveFilterFile(tabItem.Tag); } else { Settings.RemoveLogFile(tabItem.Tag); } if (CurrentFile() != null) { tabItem.Tag = CurrentFile().Tag = fileName; CurrentFile().FileName = tabItem.Header = tabItem.Name = Path.GetFileName(fileName); } else { SetStatus("RenameTabItem:error: current file is null: " + fileName); } if (this is FilterViewModel) { Settings.AddFilterFile(fileName); } else { Settings.AddLogFile(fileName); } }
public void RemoveTabItem(ITabViewModel <T> tabItem) { if (tabItems.Any(x => String.Compare((string)x.Tag, (string)tabItem.Tag, true) == 0)) { tabItems.Remove(tabItem); SelectedIndex = tabItems.Count - 1; } }
private void OpenFolderExecuted() { if (IsValidTabIndex()) { ITabViewModel <T> tabItem = tabItems[_selectedIndex]; CreateProcess("explorer.exe", string.Format("\"{0}\"", Path.GetDirectoryName(tabItem.Tag))); } }
public async Task CloseTab(ITabViewModel tabViewModel) { await Dispatcher.UIThread.InvokeAsync(() => { Logger.Debug($"Close tab '{tabViewModel.Id}'."); factory.RemoveDockable(tabViewModel as IDockable, collapse: false); Session.RootViewModel.Tabs.Remove(tabViewModel); }); }
public async Task FocusTab(ITabViewModel tabViewModel) { await Dispatcher.UIThread.InvokeAsync(() => { Logger.Debug($"Focus tab '{tabViewModel.Id}'."); factory.SetActiveDockable(tabViewModel as IDockable); Session.RootViewModel.ActiveTab = tabViewModel; }); }
public void CopyFilePathExecuted(object sender) { if (IsValidTabIndex()) { ITabViewModel <T> tabItem = tabItems[_selectedIndex]; Clipboard.Clear(); Clipboard.SetText(tabItem.Tag); } }
public void ShowTab(ITabViewModel view_model) { if (Events != null) { Events.Publish(new ShowTabViewMessage { Item = view_model }); } }
public TabControlViewModel() { ObservableCollection <ITabViewModel> tabControlViewModels = new ObservableCollection <ITabViewModel>(); //tabControlViewModels.Add(new ViewModelA { Header = "Tab A" }); //tabControlViewModels.Add(new ViewModelB { Header = "Tab B" }); //tabControlViewModels.Add(new ViewModelC { Header = "Tab C" }); SelectedTabViewModel = tabControlViewModels[0]; }
public bool CanHandle(Tab tab, out ITabViewModel tabViewModel) { tabViewModel = null; if (tab.TypeId == TypeId) { tabViewModel = new FooTabViewModel(tab); return(true); } return(false); }
public bool CanHandle(Tab tab, out ITabViewModel tabViewModel) { tabViewModel = null; if (tab.TypeId == Default.TypeId) { tabViewModel = _factory(tab); return(true); } return(false); }
private void OpenFiles(bool isMult = false) { var filter = imgExts.Aggregate("Image Files|", (c, el) => c + ("*" + el + ";")); filter = textExts.Aggregate(filter + "|Text Files|", (c, el) => c + ("*" + el + ";")); filter += "|All Files|*.*"; FileDialog fd = new OpenFileDialog { Multiselect = isMult, Filter = filter, FilterIndex = 3 }; if (fd.ShowDialog() == null) { return; } var fms = fd.FileNames; ITabViewModel lastTab = null; for (int i = 0, count = fms.Length; i < count; i++) { ITabViewModel tab = null; switch (GetFileTypeByPath(fms[i])) { case FileTypes.Image: tab = new TabImageViewModel(); break; case FileTypes.Text: tab = new TabTextViewModel(); break; } if (tab != null) { tab.Path = fms[i]; tab.IsSync = App.Setting.IsSync; TabControl.Tabs.Add(tab); lastTab = tab; } } foreach (var tab in TabControl.Tabs.Where(tab => !tab.IsRun)) { tab.Start(); if (tab.Equals(lastTab)) { TabControl.SelectedItem = lastTab; } } }
public async Task <ITabViewModel> CreateEditorTab(IAssetEditor editor) { var tab = await AvaloniaUIThread.InvokeAsync(() => new EditorTabViewModel(editor)); Logger.Debug($"Create new editor tab '{tab.Id}'."); editorTabs.Add(tab); selectedEditorTab = tab; Session.RootViewModel.Tabs.Add(tab, editor); Session.RootViewModel.ActiveTab = tab; return(tab); }
public async Task <ITabViewModel> CreateToolTab(object viewModel) { var tab = await AvaloniaUIThread.InvokeAsync(() => new ToolTabViewModel(viewModel)); Logger.Debug($"Create new tool tab '{tab.Id}'."); toolTabs.Add(tab); selectedToolTab = tab; Session.RootViewModel.Tabs.Add(tab, viewModel); Session.RootViewModel.ActiveTab = tab; return(tab); }
private static void AddGpoBehavior(TabItem tab, Grid content, ITabViewModel viewModel) { if (viewModel.BlockedByGPO) { var contentControl = new GPOLockLayer(); contentControl.IsLockedByGpo = viewModel.BlockedByGPO; contentControl.DataContext = viewModel; content.Children.Add(contentControl); } if (viewModel.HiddenByGPO) { tab.Visibility = Visibility.Collapsed; } }
internal bool SwitchIfExist(ITabViewModel tabViewModel) { if (tabViewModel == null) { return(false); } var existedTab = allTabs.FirstOrDefault(x => x.HashName == tabViewModel.TabHashName); if (existedTab == null) { return(false); } SwitchTo(existedTab); return(true); }
public void CloseFileExecuted(object sender) { if (IsValidTabIndex()) { DeleteIfTempFile(CurrentFile()); ITabViewModel <T> tabItem = tabItems[_selectedIndex]; if (!ViewManager.CloseFile(tabItem.Tag)) { return; } RemoveTabItem(tabItem); } }
public async Task FocusTab(ITabViewModel tabViewModel) { Logger.Debug($"Focus tab '{tabViewModel.Id}'."); if (tabViewModel is EditorTabViewModel) { selectedEditorTab = tabViewModel; } else { selectedToolTab = tabViewModel; } Session.RootViewModel.ActiveTab = tabViewModel; }
public static void RegisterMasterTab <T>(this IRegionManager regionManager, string subTabRegionName, string contentRegionName, string tabRegion, IWhitelistedServiceLocator whitelistedServiceLocator, IEventAggregator eventAggregator) where T : class, ITabViewModel, IWhitelisted { regionManager.RegisterViewWithRegion(tabRegion, () => { ITabViewModel viewModel = whitelistedServiceLocator.GetInstance <T>(); var tab = new TabItem(); var masterIconTabHeader = new MasterIconTabHeader(subTabRegionName); var contentContainer = new Grid(); var tabContent = new ContentControl { IsTabStop = false }; tabContent.SetResourceReference(FrameworkElement.StyleProperty, "TabUserControl"); tab.Header = masterIconTabHeader; tabContent.SetValue(RegionManager.RegionNameProperty, contentRegionName); tabContent.DataContext = viewModel; tabContent.Loaded += (sender, args) => { var helpTopic = HelpTopic.ProfileSettings; var dependencyObjects = (args.OriginalSource as ContentControl).GetChildObjects(); if (dependencyObjects.First() is DependencyObject view) { helpTopic = (HelpTopic)view.GetValue(HelpProvider.HelpTopicProperty); } eventAggregator.GetEvent <SetProfileTabHelpTopicEvent>().Publish(helpTopic); }; masterIconTabHeader.DataContext = viewModel; contentContainer.Background = new SolidColorBrush(Colors.White); contentContainer.Children.Add(tabContent); AddGpoBehavior(tab, contentContainer, viewModel); tab.Content = contentContainer; TransposerHelper.Register(masterIconTabHeader, viewModel); TransposerHelper.Register(tabContent, viewModel); return(tab); }); }
internal bool TryCreateTab(ITabViewModel tabViewModel, out Tab tab) { tab = null; if (tabViewModel == null) { return(false); } var existedTab = allTabs.FirstOrDefault(x => x.HashName == tabViewModel.TabHashName); if (existedTab != null) { return(false); } tab = new Tab(tabViewModel, this); return(true); }
public void tab_view_modles_populated_when_created() { // ARRANGE var tabViewModels = new ITabViewModel[] { new FooTabViewModel(new Tab(Guid.Empty, "Foo")), new BarTabViewModel(new Tab(Guid.Empty, "Bar")) }; _tabService.Setup(x => x.GetTabs()).Returns(tabViewModels); // ACT var viewModel = new MainViewModel(_diagnosticsViewModel.Object, _tabService.Object); // ASSERT Assert.That(viewModel.Tabs, Is.EquivalentTo(tabViewModels)); }
public void RenameFileExecuted(object sender) { SetStatus("RenameFile:enter"); if (IsValidTabIndex()) { ITabViewModel <T> tabItem = tabItems[_selectedIndex]; RenameDialog dialog = new RenameDialog(); string result = dialog.WaitForResult(); if (!string.IsNullOrEmpty(result)) { tabItem.Modified = true; RenameTabItem(result); } SetStatus("RenameFile:exit"); } }
public override void RenameTabItem(string logName) { // rename tab ITabViewModel <LogFileItem> tabItem = TabItems[SelectedIndex]; Settings.RemoveLogFile(tabItem.Tag); if (CurrentFile() != null) { tabItem.Tag = CurrentFile().Tag = logName; CurrentFile().FileName = tabItem.Header = tabItem.Name = Path.GetFileName(logName); } else { SetStatus("RenameTabItem:error: current file is null: " + logName); } Settings.AddLogFile(logName); }
public void strategies_can_handle_created_type_id() { // ARRANGE // ACT var result = _strategies.All(x => { ITabViewModel vm1 = x.Create(); ITabViewModel vm2; var canHandle = x.CanHandle(vm1.Tab, out vm2); return(canHandle && vm1.Tab.Equals(vm2.Tab)); }); // ASSERT Assert.That(result, Is.True); }
private void Initialize() { localization = MainModel.Localization.CurrentLanguage.MainWindow; AppSettings appSettings = MainModel.AppSettings; MainWindowSettings mainWindowSettings = appSettings.MainWindow; WindowWidth = mainWindowSettings.Width; WindowHeight = mainWindowSettings.Height; WindowLeft = mainWindowSettings.Left; WindowTop = mainWindowSettings.Top; IsWindowMaximized = mainWindowSettings.Maximized; DefaultSearchTabViewModel.ImportRequested += DefaultSearchTabViewModel_ImportRequested; DefaultSearchTabViewModel.NonFictionSearchComplete += SearchTabNonFictionSearchComplete; DefaultSearchTabViewModel.FictionSearchComplete += SearchTabFictionSearchComplete; DefaultSearchTabViewModel.SciMagSearchComplete += SearchTabSciMagSearchComplete; selectedTabViewModel = null; isDownloadManagerButtonHighlighted = false; isCompletedDownloadCounterVisible = false; completedDownloadCount = 0; isApplicationUpdateAvailable = false; bookmarks = new BookmarkViewModelList(MainModel); }
public void ReloadFileExecuted(object sender) { IFile <T> file = default(IFile <T>); SetStatus("ReloadFile:enter"); if (IsValidTabIndex()) { ITabViewModel <T> tabItem = tabItems[_selectedIndex]; if (!File.Exists(tabItem.Tag)) { SetStatus("ReloadFile:returning: file does not exist: " + tabItem.Tag); return; } // force reset of menus for shared filters Settings.Refresh(); ViewManager.CloseFile(tabItem.Tag); RemoveTabItem(tabItem); file = ViewManager.OpenFile(tabItem.Tag); AddTabItem(file); SetStatus("ReloadFile:exit"); } }
public async Task CloseTab(ITabViewModel tabViewModel) { Logger.Debug($"Close tab '{tabViewModel.Id}'."); var toolIdx = toolTabs.IndexOf(tabViewModel); var editorIdx = editorTabs.IndexOf(tabViewModel); if (toolIdx >= 0) { toolTabs.Remove(tabViewModel); if (selectedToolTab == tabViewModel) { if (toolTabs.Count > 0) { toolIdx = toolIdx < toolTabs.Count ? toolIdx : toolTabs.Count - 1; selectedToolTab = toolTabs[toolIdx]; } } await FocusTab(selectedToolTab); } else { editorTabs.Remove(tabViewModel); if (selectedEditorTab == tabViewModel) { if (editorTabs.Count > 0) { editorIdx = editorIdx < editorTabs.Count ? editorIdx : editorTabs.Count - 1; selectedEditorTab = editorTabs[editorIdx]; } } await FocusTab(selectedEditorTab); } Session.RootViewModel.Tabs.Remove(tabViewModel); }
public void CreateTab(ITabViewModel viewModel) { _TabsCollection.Add(viewModel); }
public bool CloseTab(ITabViewModel tabViewModel) { return(_tabs.Remove(tabViewModel)); }