private void EventSetter_OnHandler(object sender, MouseEventArgs e) { var xdt = sender as CellValuePresenter; var cpr = xdt.TryFindParent <DataRecordPresenter>(); var ep = cpr.DataRecord.DataItem as NeighborhoodWatch; if (ep != null && ep.DetectedById > 0) { var leftModel = PageNavigatorHelper.GetLeftElementViewModel(); var rightEle = PageNavigatorHelper._MainWindow.RightTreeElement; if (leftModel != null) { if (!rightEle.Model.DirectoryPushed) { rightEle.OnDirectoryClick(); } leftModel.ChangeEndpointNavigationState(); var enp = ApplicationContext.EndPointListAll.Find(r => r.EndpointId == ep.DetectedById); var dir = ApplicationContext.FolderListAll.Find(r => r.FolderId == enp.FolderId); var listNodes = new List <int>(); GetParentListId(listNodes, dir); PageNavigatorHelper.GetRightElementViewModel().SelectTreeNode(ep.DetectedById, listNodes, TreeViewSelectMode.Endpoint); } } }
private void UpdateLabel(string name) { if (name.Length > 200) { var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; messageDialog.ShowMessageDialog("Label name cannot more than 200 letters", "Message"); return; } var viewModel = DataContext as LabelCriteriaViewModel; var label = new POC.Common.Model.Endpoint.Label { LabelId = viewModel.LabelId, LabelName = name }; var labelsPage = PageNavigatorHelper.GetMainContent <LabelsPage>(); if (labelsPage != null) { var labelViewModel = labelsPage.DataContext as LabelViewModel; if (labelViewModel != null) { labelViewModel.EditLabel(label); } _headerExpanderOrg = name; var rightViewModel = PageNavigatorHelper.GetRightElementViewModel(); ApplicationContext.IsRebuildTree = true; rightViewModel.LoadLabelView(); } }
public void OnActiveChanged() { var policyVm = PageNavigatorHelper.GetMainContentViewModel <POCAgentViewModel>(); if (policyVm != null) { policyVm.Id = Id; policyVm.Name = Name; policyVm.PolicyColor = ExpanderBackgroundColor; var pocAgent = ApplicationContext.POCAgentList.Find(r => r.Id == Id); if (pocAgent != null) { policyVm.POCServer = pocAgent.POCServer; policyVm.Key = pocAgent.Key; policyVm.Port = pocAgent.Port; policyVm.NeighborhoodWatch = pocAgent.NeighborhoodWatch; policyVm.TransferInterval = pocAgent.TransferInterval; policyVm.SynchronizationInterval = pocAgent.SyncInterval; policyVm.ActiveTransfer = pocAgent.ActiveTransfer; policyVm.UpdateSource = pocAgent.UpdateSource; policyVm.pocServerOrigin = pocAgent.POCServer; policyVm.keyOrigin = pocAgent.Key; policyVm.portOrigin = pocAgent.Port; } } }
private void DragSource_Drop(object sender, Infragistics.DragDrop.DropEventArgs e) { var data = e.Data as NeighborhoodWatch; var drca = e.DropTarget as XamDataTreeNodeControl; if (drca != null) { var node = drca.Node; if (node != null) { if (ApplicationContext.EndPointListAll.Select(r => r.MACAddress).Contains(data.MAC)) { var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; messageDialog.ShowMessageDialog( "Cannot move, this Endpoint is existed", "Message"); return; } var ndata = node.Data as DirectoryNode; ApplicationContext.AllNeighborhoodWatch.Find(r => r.Id == data.Id).Managed = true; Model.OnTabSelected(); var mainVM = PageNavigatorHelper.GetMainModel(); mainVM.AddComputer(ndata, data.Computer, data.MAC); } } }
public void LoadData(List <BackgroundWorker> workers) { //Load data var loadDataBg = new BackgroundWorker(); loadDataBg.DoWork += LoadDataBg_DoWork; workers.Add(loadDataBg); loadDataBg.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { IsLoading = false; ReCountComputer(); BackgroundWorker wk = (BackgroundWorker)s; workers.Remove(wk); if (workers.Count == 0) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); //Handle error when switch page, backgroundworker does not auto stop if (ApplicationContext.LDAPActived != null && ldapViewModel != null) { ldapViewModel.BuildLDAPTree(ApplicationContext.LDAPActived); } } }; loadDataBg.RunWorkerAsync(); }
private void FilterBk_DoWork(object sender, DoWorkEventArgs e) { _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { if (IsActived) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { var ldap = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders }; ReCountComputer(); ldapViewModel.BuildLDAPTree(ldap); } } })); }
public void GetBelowNode(DirectoryNode currentNode) { var belowNode = new DirectoryNode(); var parentNode = GetParentNode(currentNode); if (parentNode == null) { var rightViewModel = PageNavigatorHelper.GetRightElementViewModel(); if (rightViewModel != null) { ApplicationContext.BelowNode = rightViewModel.TreeDataSource.FirstOrDefault(); } else { ApplicationContext.BelowNode = belowNode; } return; } var sameLvlNodes = GetSameLvlNodes(parentNode, currentNode); if (sameLvlNodes.Count == 0) { belowNode = parentNode; } else { belowNode = sameLvlNodes[0]; } ApplicationContext.BelowNode = belowNode; }
/// <summary> /// Initializes a new instance of the <see cref="ColorCodeViewModel"/> class. /// </summary> /// <param name="view">The view.</param> /// <param name="colorModel">The color model.</param> public ColorCodeViewModel(ColorCodeControl view, ColorModel colorModel) { _view = view; UpdateModel(colorModel); _view.Model = this; _mainViewModel = PageNavigatorHelper.GetMainModel(); }
public void OnDirectoryClick() { Model.SetInitState(); BackButton.Visibility = Visibility.Collapsed; //btnDirectorySetFocus(); btnLabel.BorderThickness = new Thickness(0); Model.DirectoryPushed = true; btnDirectory.BorderThickness = new Thickness(0, 0, 0, 2); btnDirectory.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#1dabed")); btnDirectory.Foreground = Brushes.White; var bc = new BrushConverter(); btnLabel.Foreground = (Brush)bc.ConvertFrom("#8e8f98"); btnLabel.Style = FindResource("PushedTabPageButton") as Style; btnDirectory.Style = FindResource("PushedTabPageButton") as Style; LabelScrollViewer.Visibility = Visibility.Collapsed; DirectoryScrollViewer.Visibility = Visibility.Visible; //reload tree when click on the directory var mainViewModel = PageNavigatorHelper.GetMainModel(); if (Model.SearchCommand.CanExecute(null)) { Model.SearchText = ""; ApplicationContext.SearchText = ""; Model.DirectoryLabelClicked(true); mainViewModel.AddDeleteButtonVisible = true; } ApplicationContext.DirSearched = false; }
private void OnMoveCommand(object args) { if (_selectedData.Any(neighborhood => ApplicationContext.EndPointListAll.Find(r => r.MACAddress == neighborhood.MAC) != null)) { _view.HideWindow(); var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; messageDialog.ShowMessageDialog( "Cannot move, have some Endpoints are existed", "Message"); return; } var moveDiscoveryBk = new BackgroundWorker(); moveDiscoveryBk.DoWork += MoveDiscoveryBk_DoWork; moveDiscoveryBk.RunWorkerCompleted += MoveDiscoveryBk_RunWorkerCompleted; moveDiscoveryBk.RunWorkerAsync(); foreach (var neighborhood in _selectedData) { ApplicationContext.AllNeighborhoodWatch.Find(r => r.Id == neighborhood.Id).Managed = true; } var neighborhoodVm = PageNavigatorHelper.GetMainContentViewModel <NeighborhoodWatchViewModel>(); if (neighborhoodVm != null) { neighborhoodVm.OnTabSelected(); } _view.HideWindow(); }
private void Background_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //Reload LabelFilterViewModel var rvm = PageNavigatorHelper.GetRightElementViewModel(); rvm.LoadLabelView(true); }
/// <summary> /// Indicate that whether we can refresh screen or not /// </summary> /// <returns></returns> protected bool CanRefresh() { ApplicationContext.CanRefreshEndpoint = false; ApplicationContext.CanRefreshDiscovery = false; ApplicationContext.CanRefreshLDAP = false; ApplicationContext.CanRefreshSoftware = false; ApplicationContext.CanRefreshUpdateSource = false; var lastRefreshUpdate = ServiceManager.GetLastUpdateData(); var canrefresh = false; foreach (var lastupd in lastRefreshUpdate) { foreach (var inLastUpd in LastRefresh) { if (inLastUpd.Name == lastupd.Name && inLastUpd.LastSync < lastupd.LastSync) { if (lastupd.Name == "DirectoryEndpoint") { ApplicationContext.CanRefreshEndpoint = true; } if (lastupd.Name == "Discovery") { ApplicationContext.CanRefreshDiscovery = true; } if (lastupd.Name == "LDAPDirectoryEndpoint") { ApplicationContext.CanRefreshLDAP = true; } if (lastupd.Name == "Software") { ApplicationContext.CanRefreshSoftware = true; } if (lastupd.Name == "UpdateSource") { ApplicationContext.CanRefreshUpdateSource = true; } if (lastupd.Name == "Task") { ApplicationContext.CanRefreshTask = true; } canrefresh = true; } } } if (canrefresh) { var mainVm = PageNavigatorHelper.GetMainModel(); if (mainVm != null) { ApplicationContext.IsReload = true; ApplicationContext.IsReloadForRefresh = true; mainVm.ReloadData(); LastRefresh = lastRefreshUpdate; } } return(canrefresh); }
/// <summary> /// Select current tree node to refresh data for groupview screen /// </summary> public void SelectCurrentTreeNode(DirectoryNode curnode) { var rightViewModel = PageNavigatorHelper.GetRightElementViewModel(); rightViewModel.EndEditingTree(); rightViewModel.RefreshTreeData(curnode); // ResortTreeNode(curnode); }
public ShowLDAPDirectoryViewModel(ShowLdapDirectoryDialog view, LDAPAssignmentViewModel ldapAssignmentViewModel) { _view = view; _ldapAssignmentViewModel = ldapAssignmentViewModel; _mainWindowViewModel = PageNavigatorHelper.GetMainModel(); SelectLdapCommand = new RelayCommand(OnMoveCommand, CanExecuteCommand); _view.Loaded += _view_Loaded; }
private void TxtModelCriteria_LostFocus(object sender, RoutedEventArgs e) { if (currentText != TxtModelCriteria.Text) { PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); currentText = TxtModelCriteria.Text; } }
private void TxtIPv4Criteria2_LostFocus(object sender, RoutedEventArgs e) { if (currentText2 != TxtIPv4Criteria2.Text) { Model.TxtIPv4Criteria2 = TxtIPv4Criteria2.Text; PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); currentText2 = TxtIPv4Criteria2.Text; } }
private void UploadSoftware() { var mainVm = PageNavigatorHelper.GetMainModel(); mainVm.ShowMessage("Uploading..."); var uploadBg = new BackgroundWorkerHelper(); uploadBg.AddDoWork(SaveBackgroundWorker_DoWork).AddRunWorkerCompleted(OnSaveData_RunWorkerCompleted).DoWork(); }
private void SaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { _view.Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { var listPolicyAssign = e.Argument as List <PolicyAssign>; var pocAgentVm = PageNavigatorHelper.GetMainContentViewModel <POCAgentViewModel>(); pocAgentVm.AssignPolicy(listPolicyAssign); })); }
private void OnLDAPNavExecute() { var mainViewModel = PageNavigatorHelper.GetMainModel(); if (mainViewModel != null) { mainViewModel.NavigationIndex = (int)NavigationIndexes.LDAP; } PageNavigatorHelper.Switch(new LDAPPage()); }
private void OnExecuteDeleteRule(object obj) { var directoryAssignment = PageNavigatorHelper.GetMainContentViewModel <AssignmentViewModel>(); if (directoryAssignment != null) { directoryAssignment.DeleteRuleCommand.Execute(null); } //_view.AssignmentCtxMenu.IsOpen = false; }
private void OncolorNavExecute() { var mainViewModel = PageNavigatorHelper.GetMainModel(); if (mainViewModel != null) { mainViewModel.NavigationIndex = (int)NavigationIndexes.Colors; } PageNavigatorHelper.Switch(new ColorCodePage()); }
private void OnAssignmentNavExecute() { var mainViewModel = PageNavigatorHelper.GetMainModel(); if (mainViewModel != null) { mainViewModel.NavigationIndex = (int)NavigationIndexes.Assignment; } PageNavigatorHelper.Switch(new DirectoryAssignmentPage()); }
private void OnDownloadNavExecute() { var mainViewModel = PageNavigatorHelper.GetMainModel(); if (mainViewModel != null) { mainViewModel.NavigationIndex = (int)NavigationIndexes.Download; } // PageNavigatorHelper.Switch(new NeighborhoodWatchPage()); }
private void OnQuarantineNavExecute() { var mainViewModel = PageNavigatorHelper.GetMainModel(); if (mainViewModel != null) { mainViewModel.NavigationIndex = (int)NavigationIndexes.Transfer; } PageNavigatorHelper.Switch(new POCQuarantinePage()); }
/// <summary> /// Initializes a new instance of the <see cref="ImportFilePageViewModel"/> class. /// </summary> /// <param name="view">The view.</param> /// <param name="folderId">The folder identifier.</param> public ImportFilePageViewModel(ImportFilePage view, int folderId) { _mainViewModel = PageNavigatorHelper.GetMainModel(); ImportCommand = new RelayCommand(ExecuteImport, CanImport); CancelCommand = new RelayCommand(ExecuteCancel); BrowseFileCommand = new RelayCommand(ExecuteBrowseFile, CanBrowseFile); _view = view; ReloadData(folderId); VisibleSimulate = Visibility.Collapsed; MenuImportButtonStyle = _view.FindResource("MenuButton") as Style; }
/// <summary> /// Make tree data /// </summary> /// <returns></returns> public void MakeTree(int nodeSelected, bool isSearch = false, string searchKey = "", bool isExpandAll = false, bool isReload = false) { if (isSearch) { GetSearchedData(searchKey); } else if (isReload) { ApplicationContext.FolderListAll = GetAllFolders(); ApplicationContext.EndPointListAll = GetDirectoryEndpoints(1); ApplicationContext.FolderListTree = ApplicationContext.FolderListAll; ApplicationContext.EndPointListTree = ApplicationContext.EndPointListAll; } var rootId = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderId : ApplicationContext.FolderListTree.Min(r => r.FolderId); var rootName = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderName : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).FolderName; var guid = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).Guid : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).Guid; var mainVm = PageNavigatorHelper.GetMainModel(); var isPocAgent = mainVm.NavigationIndex == (int)NavigationIndexes.POCAgent; var rootPolicy = isPocAgent ? ApplicationContext.FolderPolicyList.Find(r => r.ObjectId == rootId) : null; // create root, build subtree and return it var node = new DirectoryNode { NodeId = rootId, Title = rootName, IsFolder = true, Guid = guid, NodeWidth = ApplicationContext.GridRightOriginalWidth, NodeHoverWidth = isPocAgent ? 0 : ApplicationContext.GridRightOriginalWidth, NodeSelectedWidth = isPocAgent ? ApplicationContext.GridRightOriginalWidth : 0, NodePolicyColor = isPocAgent ? (rootPolicy != null ? rootPolicy.Color : UIConstant.PolicyDefaultColor) : "", ChildrenPolicyColor = isPocAgent ? GetChildPolicyAssign(new Directory { FolderId = rootId }) : null, NodeColor = "#FFF" }; MakeSubTree(node, isPocAgent); var listNode = new ObservableCollection <DirectoryNode>(); listNode.Add(node); var rightViewModel = PageNavigatorHelper.GetRightElementViewModel(); if (rightViewModel != null) { rightViewModel.EndEditingTree(); rightViewModel.TreeDataSource = listNode; if (isExpandAll) { ApplicationContext.ExpandedIds = new List <int>(); ApplicationContext.ExpandedIds.Add(ApplicationContext.FolderListAll.Select(c => c.FolderId).ToList().Min()); } rightViewModel.RefreshTreeData(nodeSelected); } }
private void OnExecuteAddTask(object obj) { //Execute TaskListViewModel.AddTaskCommand var taskListViewModel = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (taskListViewModel != null) { taskListViewModel.AddTaskCommand.Execute(null); } _view.TaskCtxMenu.IsOpen = false; }
private bool CheckEndpointNavigationClicked() { var mainVm = PageNavigatorHelper.GetMainModel(); if (mainVm != null && (mainVm.NavigationIndex == (int)NavigationIndexes.Endpoint || mainVm.NavigationIndex == (int)NavigationIndexes.Label)) { return(true); } return(false); }
private void Thumb_OnDragCompleted(object sender, DragCompletedEventArgs e) { if (PageNavigatorHelper._MainWindow != null) { var rvm = PageNavigatorHelper.GetRightElementViewModel(); if (rvm != null) { rvm.SetNodeWidth(RightTreeElement.DataTree.Nodes, GrdRightElement.ActualWidth); } ApplicationContext.GridRightOriginalWidth = GrdRightElement.ActualWidth; } }
private void OnShowLDAPCommand(object arg) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { ApplicationContext.LDAPActived = new LDAP { Id = Id, Domain = DomainName, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, HideEmptyFolders = IsHideEmptyFolders, HideManagedEndpoints = IsHideManagedEndPoints }; ldapViewModel.BuildLDAPTree(ApplicationContext.LDAPActived); } }