Inheritance: WindowViewModel
Esempio n. 1
0
        private void ShowEditor(ICrit crit)
        {
            if (CurrentEditor != null && (CurrentEditor as ICritKeeper).Crit == crit)
            {
                return; // уже открыт
            }
            naviagationExpected = crit != null;
            CloseEditor();
            naviagationExpected = false;

            if (crit is Estimator)
            {
                CurrentEditor = new EstimatorEditorViewModel(crit as Estimator);
            }
            else if (crit is CriteriaGroup)
            {
                CurrentEditor = new CriteriaGroupEditorViewModel(crit as CriteriaGroup);
            }
            else if (crit is Criterion)
            {
                CurrentEditor = new CriterionEditorViewModel(crit as Criterion);
            }

            if (CurrentEditor != null)
            {
                CurrentEditor.OnDialogResult((r) => CloseEditor());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Проверить номер джампера на корректность
        /// </summary>
        /// <param name="number">Номер джампера</param>
        /// <returns></returns>
        public (bool status, string reason) CheckJumperNumber(int?number)
        {
            if (number == null)
            {
                return(false, "недопустимый номер");
            }

            if (Jumpers.Any(j => j.Number == number))
            {
                var dvm = new DialogViewModel("Номер уже существует, хотите ли вы поменять их местами?", DialogType.Question);

                WinMan.ShowDialog(dvm);

                switch (dvm.DialogResult)
                {
                case DialogResult.YesAction:
                    var jumper = Jumpers.First(j => j.Number == number);
                    jumper.Number = SelectedJumper.Number;
                    DbMethods.UpdateDbCollection(jumper);
                    return(true, "Операция успешно завершена");

                case DialogResult.NoAction:
                    return(false, "Данный номер уже существует");

                default:
                    return(false, "Операция отменена");
                }
            }

            return(number > Jumpers.Count
                                ? (false, "Все номера должны быть по порядку без пропусков")
                                : (true, "Операция успешно завершена"));
        }
 public CustomActionSheet(DialogViewModel viewModel)
 {
     InitializeComponent();
     this.BindingContext              = viewModel;
     this.lvActions.ItemTapped       += LvActions_ItemTapped;
     PopupNavigation.Instance.Popped += Instance_Popped;
 }
    /// <summary>
    /// Show the required dialog.
    /// </summary>
    /// <typeparam name="TResult">The type of result to return.</typeparam>
    /// <param name="viewModel">The view model ascociated with the view.</param>
    public async Task <TResult> ShowDialog <TResult>(DialogViewModel <TResult> viewModel)
    {
        // Locate the ascociated view.
        var viewType = ViewLocator.LocateTypeForModelType(viewModel.GetType(), null, null);
        var dialog   = (BaseMetroDialog)Activator.CreateInstance(viewType);

        if (dialog == null)
        {
            throw new InvalidOperationException(
                      String.Format("The view {0} belonging to view model {1} " +
                                    "does not inherit from {2}",
                                    viewType,
                                    viewModel.GetType(),
                                    typeof(BaseMetroDialog)));
        }
        dialog.DataContext = viewModel;
        // Show the metro window.
        MetroWindow firstMetroWindow = Application.Current.Windows.OfType <MetroWindow>().First();
        await firstMetroWindow.ShowMetroDialogAsync(dialog);

        TResult result = await viewModel.Task;
        await firstMetroWindow.HideMetroDialogAsync(dialog);

        return(result);
    }
Esempio n. 5
0
        public async Task <DialogViewModel> GetDialogAsync(int interlocutorId)
        {
            DialogViewModel model = null;
            User            user  = await context.Users.FirstOrDefaultAsync(u => u.Id == userId);

            if (user != null)
            {
                int[] ids = { userId, interlocutorId };
                Array.Sort(ids);
                Dialog dialog = await GetOrCreateDialogAsync(interlocutorId);

                User targetUser = await context.Users.FirstOrDefaultAsync(u => u.Id == interlocutorId);

                if (targetUser != null)
                {
                    DialogMessage message = await context.DialogMessages.LastOrDefaultAsync(m => m.DialogId == dialog.Id);

                    model = new DialogViewModel()
                    {
                        Id              = dialog.Id,
                        Image           = targetUser.Image,
                        LastMessageDate = message?.DateOfSending,
                        LastMessageText = message?.Text,
                        InterlocutorId  = interlocutorId,
                        Title           = targetUser.Nickname
                    };
                }
            }
            return(model);
        }
 public DialogHost(Window parent, DialogViewModel viewModel)
 {
     Owner = parent;
     InitializeComponent();
     DataContext = viewModel;
     viewModel.CloseRequestEvent += Close;
 }
        public async void OnOpenAddPostilView()
        {
            var privilege = await Mg.Get <IMgContext>().GetPrivilegeAsync(ModuleKeys.OpenAddPostilView);

            if (!privilege)
            {
                Mg.Get <IMgLog>().Error("您没有添加批注的权限!");
                Mg.Get <IMgDialog>().ShowDesktopAlert("提示", "您没有添加批注的权限!");
                return;
            }
            var addPostil = new AddPostilViewModel();
            var vm        = new DialogViewModel(addPostil)
            {
                Title  = "添加批注",
                Width  = 1400,
                Height = 800,
                CancelButtonVisibility = Visibility.Visible,
                OkButtonVisibility     = Visibility.Visible,
                Icon       = this.GetAppImageSource("Assets/添加批注.png"),
                ResizeMode = ResizeMode.CanResize
            };
            var result = Mg.Get <IMgDialog>().ShowDialog(vm);

            if (result != CloseResult.Ok)
            {
                return;
            }
            addPostil.OnAddPostil();
        }
Esempio n. 8
0
        public LancamentoAlternativaViewModel()
        {
            Model = new LancamentoAlternativaModel();

            Dialog = new DialogViewModel("AlternativaDialog");
            Dialog.OnCreateEvent += AdicionarAlternativa;
        }
 public DialogWindow(Window owner, DialogViewModel viewModel)
 {
     this.Owner = owner;
     _viewModel = viewModel;
     InitializeComponent();
     DataContext = _viewModel;
 }
Esempio n. 10
0
        public void ShowMessageDialog(string title, string message, string okBtn, PlatformDialogServiceArguments platformArguments)
        {
            UIViewController  presentViewController = null;
            UIAlertController dialogViewController  = null;

            if (platformArguments.Context != null && platformArguments.Context is UIViewController viewController)
            {
                presentViewController = viewController;
            }
            else
            {
                AttempToLookForPresentViewController(out presentViewController, out dialogViewController);
            }

            DialogViewModel viewModel = new DialogViewModel()
            {
                Title    = title,
                Body     = message,
                OkBtnTxt = okBtn
            };

            if (dialogViewController != null)
            {
                dialogViewController.DismissViewController(false, () =>
                {
                    DialogHelper.ShowDialog(presentViewController, viewModel, null);
                });
            }
            else
            {
                DialogHelper.ShowDialog(presentViewController, viewModel, null);
            }
        }
Esempio n. 11
0
        public static async Task <bool> DisplayDialogAsync(Activity current, DialogViewModel viewModel, Action actionOk = null, Action actionNotOk = null)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

            if (current == null || current.IsFinishing)
            {
                tcs.TrySetResult(false);
                return(await tcs.Task);
            }

            bool result = await DisplayDialogAsync(
                current,
                viewModel.Title,
                viewModel.Body,
                viewModel.OkBtnTxt,
                viewModel.CancelbtnTxt);

            if (result)
            {
                actionOk?.Invoke();
                tcs.TrySetResult(true);
            }
            else
            {
                actionNotOk?.Invoke();
                tcs.TrySetResult(false);
            }
            return(await tcs.Task);
        }
Esempio n. 12
0
        public bool ShowViewModel(DialogViewModel viewModel, Func <AuthenticationDialogWindow> windowCreator)
        {
            if (!TryGetNext(out CapturedGuiOperation operation))
            {
                throw new ReplayNotFoundException($"Failed to find next `{nameof(CapturedGuiOperation)}`.");
            }
            if (!Ordinal.Equals(viewModel?.GetType().FullName, operation.DialogType))
            {
                throw new ReplayInputTypeException($"Expected `{viewModel?.GetType().FullName}` vs. Actual `{operation.DialogType}`.");
            }

            _context.Trace.WriteLine($"replay {nameof(ShowViewModel)}.");

            viewModel.IsValid = operation.Output.IsValid;
            viewModel.Result  = (AuthenticationDialogResult)operation.Output.Result;

            switch (viewModel)
            {
            case CredentialsViewModel cvm:
            {
                cvm.Login    = operation.Output.Login;
                cvm.Password = operation.Output.Password;
            }
            break;

            case TwoFactorViewModel tfvm:
            {
                tfvm.AuthenticationCode = operation.Output.AuthenticationCode;
            }
            break;
            }

            return(operation.Output.Success);
        }
Esempio n. 13
0
        /// <summary>
        /// Отмена измененных данных
        /// </summary>
        public void CancelChanges()
        {
            if (CanCancelChanges is false)
            {
                return;
            }

            var dvm = new DialogViewModel(null, DialogType.CANCEL_CHANGES);

            WinMan.ShowDialog(dvm);

            if (dvm.DialogResult == DialogResult.NO_ACTION)
            {
                return;
            }

            EditableEpisode       = JsonConvert.DeserializeObject <CartoonEpisode>(TempEpisodeSnapshot);
            SelectedEpisodeOption = JsonConvert.DeserializeObject <EpisodeOption>(TempEpisodeOptionSnapshot);
            var tempId = SelectedJumper.JumperId;

            Jumpers             = new BindableCollection <Jumper>(SelectedEpisodeOption.Jumpers);
            SelectedJumper      = Jumpers.First(j => j.JumperId == tempId);
            EditableEpisodeTime = ConvertToEpisodeTime(SelectedEpisodeOption, SelectedJumper);
            NotifyEditingProperties();
            NotifyOfPropertyChange(() => Jumpers);
            NotifyOfPropertyChange(() => SelectedJumper);
        }
        public static void SubmitEntryForm(DialogViewModel dialog)
        {
            var entryViewModel = GetEntryForm(dialog);

            Assert.IsTrue(entryViewModel.Validate(), entryViewModel.GetValidationSummary());
            entryViewModel.OnSave();
        }
Esempio n. 15
0
        /// <summary>
        /// Установить все значения по умолчанию
        /// </summary>
        public void SetDefaultValues()
        {
            if (CanSetDefaultValues is false)
            {
                NotifyOfPropertyChange(() => CanSetDefaultValues);
                return;
            }

            var dvm = new DialogViewModel("Данная операция безвозвратна. Вы действительно хотите установить настройки по умолчанию?",
                                          DialogType.Question);

            WinMan.ShowDialog(dvm);

            if (dvm.DialogResult == DialogResult.NoAction)
            {
                return;
            }

            WatchingSettings = new WatchingSettings {
                Id = WatchingSettings.Id
            };
            UpdateDbCollection(entity: WatchingSettings);
            //SaveChanges();
            LoadWS();
            NotifyButtons();

            WinMan.ShowDialog(new DialogViewModel("Данные успешно сброшены по умоланию", DialogType.Info));
        }
Esempio n. 16
0
        public IHttpActionResult GetUser(DialogViewModel user)
        {
            string username    = Utilities.GetUserNameFromRequest(Request);
            User   currentUser = userService.GetUsers().FirstOrDefault(u => u.UserName.Equals(username));

            if (user == null)
            {
                return(BadRequest("Access Denied"));
            }
            try
            {
                var userResult = userService.GetUsers().Where(u => u.Id == user.UserId).FirstOrDefault();
                var userVM     = new DialogViewModel()
                {
                    NickName    = userResult.LastName,
                    UserAvartar = userResult.ImageUrl,
                    UserId      = userResult.Id,
                    Username    = userResult.UserName
                };
                return(Ok(userVM));
            }
            catch
            {
                return(BadRequest());
            }
        }
Esempio n. 17
0
        public async Task <IEnumerable <DialogViewModel> > GetAllUserDialogs(string userId)
        {
            var user = await userManager.FindByIdAsync(userId);

            var dialoglist = user.UserDialogs.Union(user.ContactDialogs);
            var allDialogs = new List <DialogViewModel>();

            foreach (var dialog in dialoglist)
            {
                if (dialog.Messages.Count != 0)
                {
                    var  model  = new DialogViewModel(dialog, user);
                    bool online = IsOnline(model.ContactId);
                    if (online)
                    {
                        model.IsOnline = true;
                    }
                    else
                    {
                        model.IsOnline = false;
                    }
                    allDialogs.Add(model);
                }
            }
            return(allDialogs);
        }
        public static bool?ShowDialog(Window owner, IDialogModel model)
        {
            var headerViewModel = new DialogHeaderMessageViewModel(model.Message);
            IDialogFooterViewModel footerViewModel;

            if (model.Buttons == DialogButtons.YesNo)
            {
                footerViewModel = new DialogFooterYesNoViewModel(model.Buttons);
            }
            else if (model.Buttons == DialogButtons.Ok)
            {
                footerViewModel = new DialogFooterOkViewModel(model.Buttons);
            }
            else
            {
                throw new NotImplementedException("This type of buttons is not implemented yet");
            }

            var dialogViewModel = new DialogViewModel(model.Caption,
                                                      headerViewModel,
                                                      footerViewModel);

            var dialog = new DialogWindow()
            {
                DataContext = dialogViewModel,
                Owner       = owner
            };

            return(dialog.ShowDialog());
        }
        public ViewModelLocator()
        {
            Navigation = new NavigationService();

            MainViewModel            = new MainViewModel();
            DialogViewModel          = new DialogViewModel();
            LogScreenWindowViewModel = new LogScreenWindowViewModel();


            FirstScreenViewModel  = new FirstScreenViewModel(Navigation);
            AddHostViewModel      = new AddHostViewModel(Navigation);
            AddCategoryViewModel  = new AddCategoryViewModel(Navigation);
            EditCategoryViewModel = new EditCategoryViewModel(Navigation);
            SettingsViewModel     = new SettingsViewModel(Navigation);
            LogScreenViewModel    = new LogScreenViewModel(Navigation);


            Navigation.RegisterPage("FirstScreen", FirstScreenViewModel);
            Navigation.RegisterPage("AddHost", AddHostViewModel);
            Navigation.RegisterPage("AddCategory", AddCategoryViewModel);
            Navigation.RegisterPage("EditCategory", EditCategoryViewModel);
            Navigation.RegisterPage("Settings", SettingsViewModel);
            Navigation.RegisterPage("LogScreen", LogScreenViewModel);
            Navigation.GoTo("FirstScreen");
        }
Esempio n. 20
0
 public MyDialogService()
 {
     ReturnedModel       = new DialogModel();
     dialogVM            = new DialogViewModel(ReturnedModel);
     dialogVM.OnPressOK += DialogVM_OnPressOK;
     view = new DialogView();
 }
Esempio n. 21
0
        /// <summary>
        /// Изменение значения свойства с учетом отмены выбора
        /// </summary>
        /// <param name="element">Исходное значение объекта</param>
        /// <param name="value">Конечное значение объекта</param>
        private void ChangePropertyValue(ref object element, object value)
        {
            var(identifier, oldValue, hasChanges) = SetStartingValues(element, value);

            if (hasChanges is false)
            {
                return;
            }

            if (((ISettingsViewModel)ActiveItem)?.HasChanges ?? false)
            {
                var vm = new DialogViewModel(null, DialogType.SAVE_CHANGES);
                _ = WinMan.ShowDialog(vm);

                switch (vm.DialogResult)
                {
                case DialogResult.YES_ACTION:
                    ((ISettingsViewModel)ActiveItem).SaveChanges();
                    break;

                case DialogResult.NO_ACTION:
                    break;

                case DialogResult.CANCEL_ACTION:
                    Application.Current.Dispatcher.BeginInvoke(
                        new Action(() => SetOldValue(identifier, oldValue)),
                        DispatcherPriority.ContextIdle, null);
                    return;
                }
            }

            NotifyChangedProperties(identifier, value);
        }
Esempio n. 22
0
        protected override DialogViewModel CreateRedirectDialog(DialogViewModel dialog, XrmRecordService xrmRecordService)
        {
            var visualStudioService = dialog.ApplicationController.ResolveType <IVisualStudioService>();
            var xrmPackageSettings  = dialog.ApplicationController.ResolveType <XrmPackageSettings>();

            return(new XrmPackageSettingsDialog(dialog, xrmPackageSettings, visualStudioService, xrmRecordService));
        }
Esempio n. 23
0
        public ModeloRegistroViewModel()
        {
            Model = new ModeloRegistroModel();

            Dialog = new DialogViewModel("CriterioDialog");
            Dialog.OnCreateEvent += AdicionarCriterio;
        }
Esempio n. 24
0
        public DragThumb()
        {
            var vm = Application.Current.MainWindow?.DataContext as MainWindowViewModel;

            _dialogVm = vm?.DialogViewModel;

            DragDelta += MoveThumb_DragDelta;
        }
        public void SettingDialog_LastResponseIsCancel()
        {
            var sut = new DialogViewModel<string>();

            sut.Dialog = _userDialog;

            Assert.IsTrue(sut.Responses[sut.Responses.Count-1].IsCancel);
        }
        /// <summary>
        /// this one internal so the navigation resolver doesnt use it
        /// </summary>
        internal XrmPackageSettingsDialog(DialogViewModel parentDialog, XrmPackageSettings objectToEnter, IVisualStudioService visualStudioService, XrmRecordService xrmRecordService)
            : base(parentDialog, xrmRecordService, objectToEnter)
        {
            XrmRecordService    = xrmRecordService;
            VisualStudioService = visualStudioService;

            AddRedirectToConnectionEntryIfNotConnected(visualStudioService);
        }
 // Continuation callback. Will be invoked once the dialog closed.
 // The parameter is the previously created FileExistsDialogViewmodel containing data set from the dialog.
 private async Task HandleFileExistsDialogResponseAsync(DialogViewModel dialogViewModel, string filePath, string settingsData)
 {
     if (dialogViewModel.DialogResult == DialogResult.Accepted)
     {
         // Example method
         await SaveFileAsync(filePath, settingsData);
     }
 }
        public void SettingDialog_FirstResponseIsDefault()
        {
            var sut = new DialogViewModel<string>();

            sut.Dialog = _userDialog;

            Assert.IsTrue(sut.Responses[0].IsDefault);
        }
Esempio n. 29
0
        public void SettingDialog_LastResponseIsCancel()
        {
            var sut = new DialogViewModel <string>();

            sut.Dialog = _userDialog;

            Assert.IsTrue(sut.Responses[sut.Responses.Count - 1].IsCancel);
        }
Esempio n. 30
0
 public override void ShowCompletionScreen(DialogViewModel dialog)
 {
     base.ShowCompletionScreen(dialog);
     if (dialog.FatalException != null)
     {
         throw dialog.FatalException;
     }
 }
Esempio n. 31
0
 private void OnSourceInitialized(object sender, EventArgs e)
 {
     if (DataContext is DialogViewModel dialogViewModel)
     {
         _dialogViewModel = dialogViewModel;
         _dialogViewModel.PropertyChanged += OnDialogViewModelPropertyChanged;
     }
 }
        public AppXrmConnectionEntryDialog(IDialogController applicationController)
            :       base(applicationController)
        {
            ObjectToEnter = new SavedXrmRecordConfiguration();
            var configEntryDialog = new ObjectEntryDialog(ObjectToEnter, this, ApplicationController, saveButtonLabel: "Next");

            SubDialogs = new DialogViewModel[] { configEntryDialog };
        }
        public void SettingDialog_CreatesBindableResponses()
        {
            var sut = new DialogViewModel<string>();

            sut.Dialog = _userDialog;

            Assert.AreEqual(3, sut.Responses.Count);
            for (int i = 0; i < _responses.Length; i++)
            {
                Assert.AreEqual(_responses[i], sut.Responses[i].Response);
            }
        }
        public void ClosingBeforeResponding_SetsResponseToCancelResponse()
        {
            var sut = new DialogViewModel<string>();
            (sut as IActivate).Activate();
            sut.Dialog = _userDialog;
            foreach (var bindableResponse in sut.Responses)
            {
                bindableResponse.IsCancel = false;
            }
            var cancelResponse = sut.Responses[1];
            cancelResponse.IsCancel = true;

            (sut as IDeactivate).Deactivate(true);

            Assert.AreEqual(cancelResponse.Response, sut.Dialog.GivenResponse);
        }
Esempio n. 35
0
		public DialogHeaderViewModel(DialogViewModel content)
		{
			Content = content;
			ShowIconAndTitle = true;
		}
Esempio n. 36
0
 public DialogHeaderViewModel(DialogViewModel content)
 {
     Content = content;
 }
        public void Respond_SetsTheResponseOnTheDialog()
        {
            var sut = new DialogViewModel<string>();
            sut.Dialog = _userDialog;

            sut.Respond(sut.Responses[0]);

            Assert.AreEqual(_responses[0], sut.Dialog.GivenResponse);
        }
        public void ClosingBeforeResponding_SetsResponseToFirstResponse_WhenNoCancelResponseExists_AndNoDefautlResponseExists()
        {
            var sut = new DialogViewModel<string>();
            (sut as IActivate).Activate();
            sut.Dialog = _userDialog;
            foreach (var bindableResponse in sut.Responses)
            {
                bindableResponse.IsCancel = false;
                bindableResponse.IsDefault = false;
            }
            var firstResponse = sut.Responses.First();

            (sut as IDeactivate).Deactivate(true);

            Assert.AreEqual(firstResponse.Response, sut.Dialog.GivenResponse);
        }