public async void LoadCmdlets(Object helpPath, Boolean importCBH) { ClosableTabItem previousTab = _mwvm.SelectedTab; UIElement previousElement = ((Grid)previousTab.Content).Children[0]; String cmd = Utils.GetCommandTypes(); if (String.IsNullOrEmpty(cmd)) { Utils.MsgBox("Error", Strings.E_EmptyCmds, MessageBoxButton.OK, MessageBoxImage.Error); return; } UIManager.ShowBusy(previousTab, Strings.InfoCmdletsLoading); try { IEnumerable <CmdletObject> data = await PowerShellProcessor.EnumCmdlets(_mwvm.SelectedModule, cmd, importCBH); _mwvm.SelectedModule.Cmdlets.Clear(); foreach (CmdletObject item in data) { _mwvm.SelectedModule.Cmdlets.Add(item); } if (helpPath != null) { _mwvm.SelectedModule.ImportedFromHelp = true; XmlProcessor.ImportFromXml((String)helpPath, _mwvm.SelectedModule); } previousTab.Module = _mwvm.SelectedModule; _mwvm.SelectedModule = null; UIManager.ShowEditor(previousTab); } catch (Exception e) { Utils.MsgBox("Error while loading cmdlets", e.Message, MessageBoxButton.OK, MessageBoxImage.Error); _mwvm.SelectedTab.ErrorInfo = e.Message; UIManager.RestoreControl(previousTab, previousElement); } }
async void LoadCmdletsForProject(ClosableTabItem tab) { String cmd = Utils.GetCommandTypes(); if (String.IsNullOrEmpty(cmd)) { Utils.MsgBox("Error", Strings.E_EmptyCmds, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (FileProcessor.FindModule(tab.Module.Name)) { tab.Module.ModulePath = null; } tab.ErrorInfo = null; tab.EditorContext.CurrentCmdlet = null; List <CmdletObject> nativeCmdlets = new List <CmdletObject>(); try { IEnumerable <CmdletObject> data = await PowerShellProcessor.EnumCmdlets(tab.Module, cmd, false); nativeCmdlets.AddRange(data); PowerShellProcessor.CompareCmdlets(tab.Module, nativeCmdlets); } catch (Exception e) { String message = e.Message + "\n\nYou still can use the module project in offline mode"; message += "\nHowever certain functionality may not be available."; Utils.MsgBox("Error while loading cmdlets", message, MessageBoxButton.OK, MessageBoxImage.Error); tab.ErrorInfo = e.Message; foreach (CmdletObject cmdlet in tab.Module.Cmdlets) { cmdlet.GeneralHelp.Status = ItemStatus.Missing; } } finally { UIManager.ShowEditor(tab); } }
public void OpenStoryboardPage(DXProject project) { // DeXign Project var page = new StoryboardPage(); var tabItem = new ClosableTabItem() { Header = project.Manifest.ProjectName, IsSelected = true, Content = new Frame() { Content = page }, Tag = page.Model }; tabItem.Closed += TabItem_Closed; // Add project on managed collection Model.Projects.SafeAdd(project); // Set Storyboard Project page.Model.Project = project; // Add TabPage tabControl.Items.Add(tabItem); // Update Recent UpdateRecentMenu(); }
private void MI_CreateNew_Project_Click(object sender, RoutedEventArgs e) { try { ClosableTabItem addWorkarea = new ClosableTabItem(); addWorkarea.Header = "新增專案"; var vm = new ProjectManagerView() { Margin = new Thickness(0) }; vm.DataContext = new ProjectsViewModel(App.Resolve <ProjectsController>()); ((ProjectsViewModel)vm.DataContext).Initialized(); vm.Mode = DocumentLifeCircle.Update; //SetValue(DockBar.DocumentModeProperty, DocumentLifeCircle.Create); Binding bindinglogineduser = new Binding(); bindinglogineduser.Source = ((MainViewModel)DataContext).LoginedUser; vm.SetBinding(ProjectManagerView.LoginedUserProperty, bindinglogineduser); addWorkarea.Content = vm; addWorkarea.Margin = new Thickness(0); Workspaces.Items.Add(addWorkarea); Workspaces.SelectedItem = addWorkarea; } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
void AddTab(Object obj) { ClosableTabItem tab = UIManager.GenerateTab(); _mwvm.Tabs.Add(tab); tab.Focus(); }
private void createNewDiagram(Canvas canvas, string tabName) { if (canvas == null) { canvas = new ScrollableCanvas(); } ClosableTabItem theTabItem = new ClosableTabItem(); ScrollViewer scrollViewer = new ScrollViewer(); canvas.Background = Brushes.Transparent; canvas.MouseDown += OnMouseDown; canvas.MouseLeftButtonDown += Canvas_MouseLeftButtonDown; canvas.MouseRightButtonDown += Canvas_MouseRightButtonDown; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; scrollViewer.Content = canvas; theTabItem.IsSelected = true; theTabItem.Content = scrollViewer; theTabItem.Title = tabName; tabs.Items.Add(theTabItem); tabs.SelectionChanged += TabControl_SelectionChanged; attachContextMenu(canvas); currentCanvas = canvas; }
/// <summary> /// 票期管理功能表項目 /// </summary> private void MI_Finance_TicketManagement_Click(object sender, RoutedEventArgs e) { try { ClosableTabItem addWorkarea = new ClosableTabItem(); addWorkarea.Header = "票期管理"; bool isExisted = true; foreach (TabItem item in Workspaces.Items) { if (item.Header.Equals(addWorkarea.Header)) { isExisted = true; addWorkarea = (ClosableTabItem)item; break; } } if (!isExisted) { } } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void SaveProjectFile(ClosableTabItem tab, String path) { FileStream fs = new FileStream(path, FileMode.Create); tab.Module.ProjectPath = path; Double oldVersion = tab.Module.FormatVersion; if (!tab.Module.IsOffline) { foreach (CmdletObject cmdlet in tab.Module.Cmdlets.ToArray().Where(cmdlet => cmdlet.GeneralHelp.Status == ItemStatus.Missing)) { tab.Module.Cmdlets.Remove(cmdlet); } } tab.Module.FormatVersion = Utils.CurrentFormatVersion; XmlSerializer serializer = new XmlSerializer(typeof(ModuleObject)); try { serializer.Serialize(fs, tab.Module); tab.Module.ProjectPath = path; tab.IsSaved = true; } catch { tab.Module.FormatVersion = oldVersion; throw; } finally { fs.Close(); } }
private void changeTabName(ClosableTabItem ti, string newName) { if (ti != null) { ti.Title = newName; } }
public EditorVM(ClosableTabItem parent) { ParamContext = new ParamVM(); RelatedLinkContext = new RelatedLinkVM(this); ExampleContext = new ExampleVM(this); OutputContext = new OutputVM(parent); }
public void OpenProject(Object obj) { String fileName; if (obj == null) { OpenFileDialog dlg = new OpenFileDialog { DefaultExt = ".pshproj", Filter = "PowerShell Help Project file (.pshproj)|*.pshproj" }; Boolean?result = dlg.ShowDialog(); if (result != true) { return; } fileName = dlg.FileName; } else { fileName = (String)obj; } AddTab(null); ClosableTabItem tab = _mwvm.SelectedTab; UIManager.ShowBusy(tab, Strings.InfoCmdletsLoading); try { ModuleObject module = FileProcessor.ReadProjectFile(fileName); Debug.Assert(tab != null, "tab != null"); tab.Module = module; LoadCmdletsForProject(tab); } catch (Exception e) { Utils.MsgBox("Read error", e.Message, MessageBoxButton.OK, MessageBoxImage.Error); } }
async void LoadModuleFromFile(Object obj) { // method call from ICommand is allowed only when module selector is active // so skip checks. ClosableTabItem previousTab = _mwvm.SelectedTab; OpenFileDialog dlg = new OpenFileDialog { DefaultExt = ".psm1", Filter = "PowerShell module files (*.psm1, *.psd1)|*.psm1;*.psd1" }; Boolean?result = dlg.ShowDialog(); if (result != true) { return; } UIManager.ShowBusy(previousTab, Strings.InfoModuleLoading); try { ModuleObject module = await PowerShellProcessor.GetModuleFromFile(dlg.FileName); if (module != null && !_mwvm.Modules.Contains(module)) { _mwvm.Modules.Add(module); module.ModulePath = dlg.FileName; } } catch (Exception e) { Utils.MsgBox("Import error", e.Message, MessageBoxButton.OK, MessageBoxImage.Error); previousTab.ErrorInfo = e.Message; } UIManager.ShowModuleList(previousTab); }
public EditorControl(ClosableTabItem tab) { if (tab != null) { DataContext = tab; } InitializeComponent(); }
public OutputVM(ClosableTabItem parent) { BusyControlVisible = Visibility.Collapsed; RtbVisible = Visibility.Collapsed; WebBrowserVisible = Visibility.Collapsed; Tab = parent; GenerateOutputCommand = new RelayCommand(GenerateOutput, CanGenerateView); }
public static void ShowEditor(ClosableTabItem tab) { MainWindowVM mwvm = (MainWindowVM)Application.Current.MainWindow.DataContext; mwvm.SelectedModule = null; ((Grid)tab.Content).Children.Clear(); ((Grid)tab.Content).Children.Add(new EditorControl(tab)); }
public void ModelChanged() { ClosableTabItem ti = tabs.SelectedItem as ClosableTabItem; if (!ti.Title.Contains(modelChangedPostfix)) { changeTabName(modelChangedPostfix + ti.Title); } }
private void OnAddTabItem(object sender, RoutedEventArgs e) { var item = new ClosableTabItem() { Header = "Added item" }; closableTabControl.Items.Add(item); }
private void ClientListView_SelectedClientChanged(object sender, RoutedEventArgs e) { try { ClosableTabItem addWorkarea = new ClosableTabItem(); ClientViewModel model = (ClientViewModel)e.OriginalSource; if (model != null) { addWorkarea.Header = string.Format("客戶-{0}[{1}]", model.ShortName, model.Code); } else { return; } bool isExisted = false; foreach (ClosableTabItem item in Workspaces.Items.OfType <ClosableTabItem>()) { if (item.Header.Equals(addWorkarea.Header)) { isExisted = true; addWorkarea = item; break; } } if (!isExisted) { var vm = new ClientManageView() { Margin = new Thickness(0) }; vm.DataContext = model; vm.Mode = DocumentLifeCircle.Read; vm.LoginedUser = ((MainViewModel)DataContext).LoginedUser; addWorkarea.Content = vm; addWorkarea.Margin = new Thickness(0); Workspaces.Items.Add(addWorkarea); } Workspaces.SelectedItem = addWorkarea; } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Storyboard_Loaded(object sender, RoutedEventArgs e) { this.Loaded -= Storyboard_Loaded; var frame = VisualTreeHelperEx.FindVisualParents <Frame>(this).FirstOrDefault(); if (frame != null) { mangedTabItem = frame.Parent as ClosableTabItem; mangedTabItem.Closed += MangedTabItem_Closed; } }
private void MI_CreateNew_Customers_Click(object sender, RoutedEventArgs e) { try { string Header = "新增客戶"; ClosableTabItem addWorkarea = new ClosableTabItem(); bool isExisted = false; foreach (TabItem item in Workspaces.Items) { if (item.Header.Equals(Header)) { isExisted = true; addWorkarea = (ClosableTabItem)item; break; } } if (!isExisted) { using (ClientController cc = new ClientController()) { addWorkarea.Header = Header; var vm = new ClientManageView() { Margin = new Thickness(0) }; ClientViewModel model = new ClientViewModel(); model.Id = Guid.NewGuid(); vm.DataContext = model; vm.Mode = DocumentLifeCircle.Create; vm.LoginedUser = ((MainViewModel)DataContext).LoginedUser; addWorkarea.Content = vm; addWorkarea.Margin = new Thickness(0); Workspaces.Items.Add(addWorkarea); Workspaces.SelectedItem = addWorkarea; } } else { Workspaces.SelectedItem = addWorkarea; } } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MI_Main_Client_Click(object sender, RoutedEventArgs e) { try { ClosableTabItem addWorkarea = new ClosableTabItem(); ClientViewModelCollection model = ((MainViewModel)DataContext).Clients; if (model != null) { addWorkarea.Header = "客戶列表"; } else { return; } bool isExisted = false; foreach (ClosableTabItem item in Workspaces.Items.OfType <ClosableTabItem>()) { if (item.Header.Equals(addWorkarea.Header)) { isExisted = true; addWorkarea = item; break; } } if (!isExisted) { var vm = new ClientListView() { Margin = new Thickness(0) }; vm.DataContext = model; vm.SelectedClientChanged += ClientListView_SelectedClientChanged; addWorkarea.Content = vm; Workspaces.Items.Add(addWorkarea); } Workspaces.SelectedItem = addWorkarea; } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void findAndOpenRelatedTab(ProjectItem pi) { ClosableTabItem cti = findTabItem(pi); if (cti == null) { createNewDiagram(fs.open(pi.FullPath), pi.Name); } else { cti.IsSelected = true; } }
public static ClosableTabItem GenerateTab() { ClosableTabItem cti = new ClosableTabItem { Header = "untitled", IsSaved = true, IsClosable = true, }; Panel content = new Grid(); content.Children.Add(new StartUserControl()); cti.Content = content; cti.EditorContext = new EditorVM(cti); return(cti); }
private void MI_Projects_Order_3_Click(object sender, RoutedEventArgs e) { //RecvMaterialView try { e.Handled = true; ClosableTabItem addWorkarea = null; string Header = "鋁擠型收料單"; addWorkarea = new ClosableTabItem() { Header = Header }; bool isExisted = false; //foreach (ClosableTabItem item in InnerWorkspaces.Items.OfType<ClosableTabItem>()) //{ // if (item.Header.Equals(addWorkarea.Header)) // { // isExisted = true; // addWorkarea = item; // break; // } //} //if (!isExisted) //{ // var vm = new RecvMaterialView() { Margin = new Thickness(0) }; // addWorkarea.Content = vm; // addWorkarea.Margin = new Thickness(0); // //Binding LoginedUserBinding = new Binding(); // //LoginedUserBinding.Source = LoginedUser; // //vm.SetBinding(AluminumExtrusionOrderSheetView.LoginedUserProperty, LoginedUserBinding); // InnerWorkspaces.Items.Add(addWorkarea); // InnerWorkspaces.SelectedItem = addWorkarea; //} } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void RunSimulation_MenuClick(object sender, RoutedEventArgs e) { ProjectTreeViewItem item = projectStructure.SelectedItem as ProjectTreeViewItem; ClosableTabItem cti = findTabItem(item.ProjectItem); if (cti == null) { createNewDiagram(item.ProjectItem.Canvas, item.ProjectItem.Name); } else { cti.IsSelected = true; } SimulateLocalButton_Click(null, null); }
private void MI_Projects_BOMImports_Click(object sender, RoutedEventArgs e) { try { e.Handled = true; ClosableTabItem addWorkarea = null; string Header = "用料需求資料匯入"; addWorkarea = new ClosableTabItem() { Header = Header }; bool isExisted = false; //foreach (ClosableTabItem item in InnerWorkspaces.Items.OfType<ClosableTabItem>()) //{ // if (item.Header.Equals(addWorkarea.Header)) // { // isExisted = true; // addWorkarea = item; // break; // } //} //if (!isExisted) //{ // var vm = new BOMDataImportsView() { Margin = new Thickness(0) }; // addWorkarea.Content = vm; // addWorkarea.Margin = new Thickness(0); // Binding LoginedUserBinding = new Binding(); // LoginedUserBinding.Source = LoginedUser; // vm.SetBinding(BOMDataImportsView.LoginedUserProperty, LoginedUserBinding); // vm.CurrentProject = (ProjectsViewModel)DataContext; // InnerWorkspaces.Items.Add(addWorkarea); // InnerWorkspaces.SelectedItem = addWorkarea; //} } catch (Exception ex) { MessageBox.Show(ex.Message, "錯誤", MessageBoxButton.OK, MessageBoxImage.Error); } }
void Initialize() { Panel content = new Grid(); ClosableTabItem cti = new ClosableTabItem { Header = "untitled", IsSaved = true, IsClosable = true, Content = content }; content.Children.Add(new StartUserControl()); cti.Content = content; cti.EditorContext = new EditorVM(cti); Tabs.Add(cti); SelectedTab = cti; }
// toolbar/menu commands void NewProject(Object obj) { if (!testSaved(_mwvm.SelectedTab)) { return; } if (_mwvm.SelectedTab == null) { AddTab(null); } ClosableTabItem tab = _mwvm.SelectedTab; Debug.Assert(tab != null, "tab != null"); tab.Module = null; LoadModules(true); tab.Header = "untitled"; }
private ClosableTabItem GetTabItem() { var itemSearchUserControl = new ItemSearchUserControl(); var grid = new Grid(); grid.Children.Add(itemSearchUserControl); var tabItem = new ClosableTabItem { Header = "Relics", Content = grid }; itemSearchUserControl.TabItem = tabItem; return(tabItem); }
// utility Boolean testSaved(ClosableTabItem tab) { if (tab == null || tab.IsSaved || tab.Module == null) { return(true); } tab.Focus(); MessageBoxResult mbxResult = Utils.MsgBox("PS Cmdlet Help Editor", Strings.InfoSaveRequired, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); switch (mbxResult) { case MessageBoxResult.Yes: SaveProjectFile(null); return(true); case MessageBoxResult.No: return(true); case MessageBoxResult.Cancel: return(false); } return(true); }
/// <summary> /// method to show the video format specific necessary information /// </summary> private void presentHandlerView(Video vid) { var tabItem = new ClosableTabItem(); tabItem.Header = System.IO.Path.GetFileName(vid.vidPath); tabItem.Content = vid.handler.propertyView; vidHandlerViews.Add(tabItem, vid); this.vidHandlersPanel.Items.Add(tabItem); }
/// <summary> /// Open a new or existing tab item /// </summary> /// <param name="header">Tab item header text</param> /// <param name="content">Content of tab. (Screen to be displayed)</param> private void OpenClosableTabItem(string header, FrameworkElement content) { //Look if it is open already var pair = tab.TabItemsListIdentifiers.Where(x => x.Value == header); if (pair.Count() == 0) { var model = content.DataContext as CertificateViewModel; var tabItem = new ClosableTabItem { Header = header, IsSelected = true }; if (model != null) model.OnDeleteCompleted += delegate { tabItem_CloseClicked(tabItem, null); }; tabItem.Content = content; tabItem.CloseClicked += tabItem_CloseClicked; tab.Items.Add(tabItem); } else //Activate when it is created { tab.MoveToTabItem(pair.First().Key); } }