private void AddBlockFromFile(string path) { Commands.DelegateCommand removeRemoveBlockClickEvent = new Commands.DelegateCommand(new Action <object>((_) => { // 使用Lambda表达式传递一个完整的Action。 // 删除图像块的Action // 在这里调用Origin的图片块扫描 foreach (var block in ImageBlocks) { if (block.BlockPath == path) { var deleteBlockPath = block.BlockPath; ImageBlocks.Remove(block); GC.Collect(); System.IO.File.Delete(deleteBlockPath); ScanNumberOfImageBlocksClickEvent.Execute(null); break; } } })); var imageBlock = new Models.ImageBlock(path, removeRemoveBlockClickEvent); ImageBlocks.Add(imageBlock); ScanNumberOfImageBlocksClickEvent.Execute(null); App.Log.Info($"ImageBlock {path} has been added to {Name}"); }
public LoadingViewModel(Events.NowLoading model) { this.model = model; SelectedIndex = 0; SelectedServerIndex = 0; BrowseMessage = ""; Browse = new Commands.DelegateCommand((param) => { BrowseMessage = ""; this.RaisePropertyChanged("BrowseMessage"); this.RaisePropertyChanged("ExistBrowseMessage"); try { model.Client.BrowseSecurityList(model.ServerList[SelectedServerIndex]); } catch (Exception e) { model.ServerList[SelectedServerIndex].Endpoints = null; BrowseMessage = string.Format("{0}", e.Message); } finally { this.RaisePropertyChanged("SecurityList"); this.RaisePropertyChanged("SecurityListIsNotZero"); this.RaisePropertyChanged("BrowseMessage"); this.RaisePropertyChanged("ExistBrowseMessage"); } }, (param) => true); }
public MainWindowVM() { Products = new ObservableCollection <Product>(); Products.CollectionChanged += (sender, args) => RecalcTotalPrice(); AddProductCommand = new Commands.DelegateCommand(AddProduct); RemoveProductCommand = new Commands.DelegateCommand(RemoveProduct); }
public AccessTableVM() { //SetRightCommand = new Commands.DelegateCommand(SetRight); BackCommand = new Commands.DelegateCommand(o => NavigationService.Navigate(NavigationService.ExplorerPage)); AddRoleCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.AddRole(RoleName); RoleName = string.Empty; OnPropertyChanged("Roles"); }); RemoveRoleCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.RemoveRole(SelectedRole); OnPropertyChanged("Roles"); OnPropertyChanged("UsersRoles"); }); AddRoleToUserCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.AddRoleToUser(SelectedUser, SelectedUserRole); OnPropertyChanged("UsersRoles"); }); RemoveRoleFromUserCommand = new Commands.DelegateCommand(o => { OsService.GetOS().RMon.RemoveRoleFromUser(SelectedUser, SelectedUserRole); OnPropertyChanged("UsersRoles"); }); }
public OneTimeAccessModel( Interfaces.IConnection connector, Interfaces.IOneTimeAccessOperator otaOperator ) { this._itemsToRead = new ObservableCollection <VariableInfo>(); this.otaOperator = otaOperator; BindingOperations.EnableCollectionSynchronization(_itemsToRead, new object()); DeleteOneTimeAccessItemsCommand = new Commands.DelegateCommand( (param) => { DeleteOneTimeAccessItems(); }, (param) => { return(OneTimeAccessItems.Count > 0); }); ReadCommand = new Commands.DelegateCommand( (param) => { OneTimeRead(); }, (param) => { return(connector.Connected && OneTimeAccessItems.Count > 0); }); WriteCommand = new Commands.DelegateCommand( (param) => { GroupWrite(this._itemsToRead); }, (param) => { return(connector.Connected && OneTimeAccessItems.Count > 0); }); connector.ObserveProperty(x => x.Connected).Subscribe(c => { if (!c) { Close(); } }); }
public AnalyseWindow() { InitializeComponent(); DataContext = App.AnalyseWindowViewModel; CloseWindowClick = new Commands.DelegateCommand(new System.Action <object>(CloseWindow)); //触发初始化函数 App.AnalyseWindowViewModel.Init(CloseWindowClick); App.Log.Info("App.AnalyseWindowViewModel.Init triggered !"); }
public ExplorerVM() { os = OsService.GetOS(); OpenFileCommand = new Commands.DelegateCommand(OpenFile); CreateFileCommand = new Commands.DelegateCommand(CreateFile); RenameFileCommand = new Commands.DelegateCommand(RenameFile); RemoveFileCommand = new Commands.DelegateCommand(RemoveFile); NavigateCommand = new Commands.DelegateCommand(Navigate); }
public Player(INavigatorService navigatorService, TVRemote tvRemote) { InitializeComponent(); DataContext = this; navigator = navigatorService; Channel = navigator.CurrentPageData as Models.TVChannel; BackCommand = new Commands.DelegateCommand(GoBack); TVRemoteCommandsInit(tvRemote); }
public AnalyseWindow() { WindowTitle = "HAAR 分析窗口"; SelectedImagesNotification = ""; MinSize = 20; MaxSize = 100; NDetection = 2; // 推荐的默认分类参数 Classifiers = new ObservableCollection <Models.HaarClassifier>(); StartButtonClickEvent = new Commands.DelegateCommand(new Action <object>(StartAnalyse)); _selectedCount = 0; }
public TVChannels(INavigatorService navigatorService, TVRemote tvRemote) { InitializeComponent(); DataContext = this; navigator = navigatorService; FocusUpCommand = new Commands.DelegateCommand(FocusUp); FocusDownCommand = new Commands.DelegateCommand(FocusDown); PlayCommand = new Commands.DelegateCommand(Play); BackCommand = new Commands.DelegateCommand(GoBack); lbChannels.SelectedIndex = 0; TVRemoteCommandsInit(tvRemote); }
public Login(INavigatorService navigatorService, TVRemote tvRemote) { navigator = navigatorService; InitializeComponent(); FocusUpCommand = new Commands.DelegateCommand(FocusUp); FocusDownCommand = new Commands.DelegateCommand(FocusDown); InputCommand = new Commands.DelegateCommand(Input); LoginCommand = new Commands.DelegateCommand(DoLogin); controls = new[] { tbName, tbPassword, (Control)btnLogin }; controls[iFocusedControl].Focus(); TVRemoteCommandsInit(tvRemote); }
/// <summary> /// 类的构造函数 /// </summary> /// <param name="folderPath">图像分类路径</param> /// <param name="name">图像分类名称</param> /// <param name="removeCategoryClickEvent">删除图像分类的委托事件</param> /// <param name="scanNumberOfImageBlocksClickEvent">扫描图片块的委托事件</param> public ImageCategory(string folderPath, string name, Commands.DelegateCommand removeCategoryClickEvent, Commands.DelegateCommand scanNumberOfImageBlocksClickEvent) { ImageBlocks = new ObservableCollection <ImageBlock>(); Name = name; if (!System.IO.Directory.Exists(folderPath)) { System.IO.Directory.CreateDirectory(folderPath); } FolderPath = folderPath; RemoveCategoryClickEvent = removeCategoryClickEvent; ScanNumberOfImageBlocksClickEvent = scanNumberOfImageBlocksClickEvent; AddBlockClickEvent = new Commands.DelegateCommand(new Action <object>(AddBlock)); _snapCount = 0; }
// 与UI同步的图像分类 /// <summary> /// 类的构造函数 /// </summary> /// <param name="path">图像路径</param> /// <param name="checkBoxClickEvent">点击左侧CheckBox的事件</param> /// <param name="removeImageClickEvent">删除图片的事件</param> public OriginImage(string path, Commands.DelegateCommand checkBoxClickEvent, Commands.DelegateCommand removeImageClickEvent) { Path = System.IO.Path.GetFullPath(path); Name = System.IO.Path.GetFileName(path); ThumbImagePath = System.IO.Path.Combine(App.AprheuaThumbImagesFolder, $"thumb-{Utility.GetTimeStamp()}-{Name}"); OverlayImagePath = System.IO.Path.Combine(App.AprheuaOverlayImagesFolder, $"overlay-{Utility.GetTimeStamp()}-{Name}"); NumberOfImageBlocks = 0; IsSelected = false; ImageCategories = new ObservableCollection <ImageCategory>(); GetReducedImageAsync(); // 异步获取文件的缩略图,减小内存占用 CheckBoxClickEvent = checkBoxClickEvent; RemoveImageClickEvent = removeImageClickEvent; // 构造器接受DelegateCommand OpenInExplorerClickEvent = new Commands.DelegateCommand(new Action <object>(OpenInExplorerClick)); ScanNumberOfImageBlocksClickEvent = new Commands.DelegateCommand(new Action <object>(ScanNumberOfImageBlocks)); }
public SelectRoleVM() { SelectRoleCommand = new Commands.DelegateCommand(o => { var os = OsService.GetOS(); os.SelectRole(SelectedUserRole); if (os.Sessions.HasSession(os.SessionId)) { var res = MessageBox.Show("Продолжить существующую сессию?", "Сессия", MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { NavigationService.Navigate(NavigationService.ExplorerPage); return; } } os.Sessions.StartSession(os.SessionId); NavigationService.Navigate(NavigationService.ExplorerPage); }); }
// 初始化。扫描分类器,处理关闭事件 public void Init(Commands.DelegateCommand closeWindowClick) { _selectedCount = 0; foreach (var img in MainWindow.SourceImages) { if (img.IsSelected) { _selectedCount++; } } // 检查哪些SourceImage被选中了 App.Log.Info($"selectedCount : {_selectedCount}"); App.Log.Info($"Scanning classifiers under {App.AprheuaClassifiersFolder}"); Classifiers = ScanHaarClassifierFolder(App.AprheuaClassifiersFolder); // 扫描分类器 CloseWindowClick = closeWindowClick; // 与前台代码的通信,关闭窗口的通信 SelectedImagesNotification = $"对已选的 {_selectedCount} 个图像应用 HAAR 分析 :"; }
public NodeTreeModel( Interfaces.IConnection connector, Interfaces.IReference references, Interfaces.ISubscriptionModel subscriptionM, Interfaces.IOneTimeAccessModel oneTimeAccessM) { this.connector = connector; this.references = references; ReloadCommand = new Commands.DelegateCommand( (param) => { ForceUpdate(); }, (param) => connector.Connected); MouseDoubleClickedCommand = new DelegateCommand <IList>((items) => { subscriptionM.AddToSubscription(items); ChangeSelectedIndexForTabContorol(0); }, (param) => true); AddToReadWriteCommand = new Commands.DelegateCommand( (param) => { oneTimeAccessM.AddToReadWrite((IList)param); ChangeSelectedIndexForTabContorol(1); }, (param) => connector.Connected); NodeSelectedCommand = new Commands.DelegateCommand( (param) => { }, //nodeInfoDataGrid.Update((VariableNode)param); }, (param) => true); UpdateVariableNodeListCommand = new Commands.DelegateCommand( (param) => { UpdateVariableNodes((Interfaces.IReference)param); }, (param) => true); this.connector.ObserveProperty(x => x.Connected).Subscribe(c => Update(c)); Initialize(); }
/// <summary> /// 创建图像分类 /// </summary> /// <param name="folderPath">图像分类的文件夹位置</param> /// <param name="name">图像分类的名称</param> /// <returns>int 返回当前图像分类在图像分类中的位置(index)</returns> public int AddCategory(string folderPath, string name) { Commands.DelegateCommand removeCategoryClickEvent = new Commands.DelegateCommand(new Action <object>((_) => { // 使用Lambda表达式直接传递Action foreach (var imageCategory in ImageCategories) { if (imageCategory.Name == name) { var deleteFolderPath = imageCategory.FolderPath; ImageCategories.Remove(imageCategory); GC.Collect(); Utility.DeleteFolder(deleteFolderPath); break; } } })); var category = new ImageCategory(folderPath, name, removeCategoryClickEvent, ScanNumberOfImageBlocksClickEvent); category.ScanImages(); ImageCategories.Add(category); return(ImageCategories.IndexOf(category)); }
public MainVM() { LoadFileCommand = new Commands.DelegateCommand(LoadFileUsingDialog); RegressionCalculateYCommand = new Commands.DelegateCommand(CalcY); ExcludeParametersCommand = new Commands.DelegateCommand(ExcludeParameters); }
/// <summary> /// 类的构造函数 /// </summary> /// <param name="blockPath">图像块路径</param> /// <param name="removeBlockClickEvent">删除图像块的委托事件</param> public ImageBlock(string blockPath, Commands.DelegateCommand removeBlockClickEvent) { OpenBlockInViewClickEvent = new Commands.DelegateCommand(new System.Action <object>(OpenBlockInViewClick)); RemoveBlockClickEvent = removeBlockClickEvent; BlockPath = blockPath; }
public LoginVM() { LoginCommand = new Commands.DelegateCommand(login); RegistrateCommand = new Commands.DelegateCommand(registrate); //Name = "гость"; Password = "******"; }