Пример #1
0
        public GameAreaViewModel(MainWindowViewModel parent)
        {
            _parent          = parent;
            GlobalCommands   = new ThreadSaveObservableCollection <DelegateCommand>();
            _commandService  = IoC.Resolve <CommandService>();
            _subSpaceManager = IoC.Resolve <SubSpaceManager>();
            _commandService.CommandsChanged += (sender, args) => CommandService_CommandsChanged();
            OpenSubSpaces    = new ThreadSaveObservableCollection <SubSpaceBase>();
            LocalCommands    = new ThreadSaveObservableCollection <NamedDelegateCommand>();
            Orientaion       = new RotateTransform();
            GameTablePostion = new Rect(0, 0, 300, 400);
            LocalCommands.Add(new NamedDelegateCommand(CommandService.COMMAND_GROUP_GENERAL + ".Open Notes", f => OpenSubSpace("Notes"), f => CanOpenSubSpace("Notes")));
            LocalCommands.Add(new NamedDelegateCommand(CommandService.COMMAND_GROUP_GENERAL + ".Open Browser", f => OpenSubSpace("Browser"), f => CanOpenSubSpace("Browser")));
            LocalCommands.Add(new NamedDelegateCommand(CommandService.COMMAND_GROUP_GENERAL + ".Open Chat", f => OpenSubSpace("Chat"), f => CanOpenSubSpace("Chat")));
            LocalCommands.Add(new NamedDelegateCommand(CommandService.COMMAND_GROUP_GENERAL + ".Close", f => _parent.CloseArea(this),
                                                       f => AppUserModel?.RoleModel != Roles.Admin));

            var loginViewModel = new SelectionDialogViewModel(f => f is AppUserModel, (d) =>
            {
                Load(d as AppUserModel).ContinueWith(OnTaskDone);
            });

            loginViewModel.AddRange(IoC.Resolve <DbEntities>().DbAccess.GetUsers().Select(e => new AppUserModel
            {
                Name      = e.Name,
                RoleModel = Roles.Yield().First(f => f.Id == e.IdRole),
                Id        = e.AppUserId
            }));

            IoC.Resolve <DialogService>().ShowDialog(new Dialog(this, "Login", loginViewModel));
        }
Пример #2
0
        public async Task <T> ShowSelectionDialogAsync <T>(string title, string header, IEnumerable <T> options)
        {
            var viewModel = new SelectionDialogViewModel <T>(header, options);
            var view      = ViewLocator.LocateForModel(viewModel, null, null);

            ViewModelBinder.Bind(viewModel, view, null);

            var dialog = new ContentDialog
            {
                Content = view,
                IsPrimaryButtonEnabled   = true,
                PrimaryButtonText        = "Ok",
                IsSecondaryButtonEnabled = true,
                SecondaryButtonText      = "Cancel",
                Title = title
            };

            var result = await dialog.ShowAsync();

            return(result == ContentDialogResult.Primary ? viewModel.SelectedOption : default(T));
        }