Esempio n. 1
0
        private async void ButtonAddProfile_Click(object sender, RoutedEventArgs e)
        {
            var dialog       = new ProfileDialog();
            var dialogResult = await dialog.ShowAsync();

            if (dialogResult == ContentDialogResult.Primary)
            {
                var profile = dialog.Result;
                if (profile != null)
                {
                    var existingElement = ProfileExists(profile);
                    if (existingElement != null)
                    {
                        var yesNoDialog = new YesNoDialog("Profil bereits vorhanden",
                                                          string.Format("Das Profil mit der Profilnummer '{0:s}', einer Länge von '{1:s}' und der Farbe '{2:s}' ist bereits vorhanden. " +
                                                                        "Soll das vorhandene Profil geändert werden?", profile.ProfileNumber, profile.Length, profile.Surface));
                        await yesNoDialog.ShowAsync();

                        if (yesNoDialog.Result == YesNoDialogType.Yes)
                        {
                            existingElement.Count  += profile.Count;
                            existingElement.Amount += profile.Amount;
                            await UpdateProfile(existingElement);
                        }

                        return;
                    }

                    if (PlantOrder != null)
                    {
                        profile.PlantOrderId = PlantOrder.Id;
                    }

                    if (FileEntry != null)
                    {
                        profile.Filename = FileEntry.Name;
                    }

                    var profileId = await Proxy.CreateProfile(profile);

                    if (profileId > 0)
                    {
                        profile.ProfileId = profileId;
                        var element = AutoMapperConfiguration.Map(profile);
                        ElementCollection.Add(element);
                    }
                    else
                    {
                        var errorDialog = new InfoDialog("Beim Anlegen des Profil's ist ein Fehler aufgetreten!", "Information", InfoDialogType.Error);
                        await errorDialog.ShowAsync();
                    }
                }
            }
        }
Esempio n. 2
0
        private void AddProfile(object sender, RoutedEventArgs e)
        {
            var w = new ProfileDialog(context, null);

            w.ShowDialog();
            if (!w.DialogResult.HasValue || !w.DialogResult.Value)
            {
                return;
            }

            ReloadProfileTree();
        }
Esempio n. 3
0
 protected override void Run()
 {
     try
     {
         var profileDialog     = new ProfileDialog();
         var profileController = new ProfileController(profileDialog);
         profileDialog.Run(Xwt.MessageDialog.RootWindow);
     }
     catch (Exception ex)
     {
         MessageService.ShowError(ex.Message);
     }
 }
Esempio n. 4
0
 private void ProfileDialog_KeyDown(object sender, KeyEventArgs e)
 {
     if (ProfileDialog.IsOpen)
     {
         if (e.Key == Key.Enter)
         {
             ProfileDialog.FullNameTB.Focus();
             ProfileDialog.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
             ProfileDialog_OnSave(null, null);
         }
         else if (e.Key == Key.Escape)
         {
             ProfileDialog_OnCancel(null, null);
         }
     }
 }
Esempio n. 5
0
        private void AddChildProfile(object sender, RoutedEventArgs e)
        {
            ProfileItem pi;

            if (!GetSelectedItem(out pi))
            {
                return;
            }
            var w = new ProfileDialog(context, pi.profile);

            w.ShowDialog();
            if (!w.DialogResult.HasValue || !w.DialogResult.Value)
            {
                return;
            }

            ReloadProfileTree();
        }
Esempio n. 6
0
        private async void ShowEditProfile(object sender, RoutedEventArgs e)
        {
            PrepareProfileDialog();
            var answer = await ProfileDialog.ShowAsync();

            if (answer != ContentDialogResult.Primary)
            {
                return;
            }
            using (var scope = IoC.Container.BeginLifetimeScope())
            {
                SplitView.Visibility    = Visibility.Collapsed;
                ProgressRing.Visibility = Visibility.Visible;
                var userService = scope.Resolve <IUserService>();
                var user        = await userService.Update(TextBoxLogin.Text, Constant.Key, TextBoxPassword.Password, Constant.User);

                SplitView.Visibility    = Visibility.Visible;
                ProgressRing.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 7
0
        private async Task UpdateProfile(ElementModel element)
        {
            var dialog       = new ProfileDialog(element);
            var dialogResult = await dialog.ShowAsync();

            if (dialogResult == ContentDialogResult.Primary && dialog.Mode == ProfileDialogMode.Edit)
            {
                var profile = dialog.Result;
                var result  = await Proxy.UpdateProfileAsync(profile);

                if (result)
                {
                    UpdateElement(element, profile);
                }
                else
                {
                    var infoDialog = new InfoDialog("Das Profil konnte nicht geändert werden!");
                    await infoDialog.ShowAsync();
                }
            }
        }
Esempio n. 8
0
        private void ProfileAdd_Activated(object sender, EventArgs args)
        {
            ((ToggleButton)sender).SetStateFlags(StateFlags.Normal, true);

            if (_inputDevice.ActiveId == "disabled")
            {
                return;
            }

            InputConfig   inputConfig   = GetValues();
            ProfileDialog profileDialog = new ProfileDialog();

            if (inputConfig == null)
            {
                return;
            }

            if (profileDialog.Run() == (int)ResponseType.Ok)
            {
                string path = System.IO.Path.Combine(GetProfileBasePath(), profileDialog.FileName);
                string jsonString;

                if (inputConfig is KeyboardConfig keyboardConfig)
                {
                    jsonString = JsonHelper.Serialize(keyboardConfig, true);
                }
                else
                {
                    jsonString = JsonHelper.Serialize(inputConfig as ControllerConfig, true);
                }

                File.WriteAllText(path, jsonString);
            }

            profileDialog.Dispose();

            SetProfiles();
        }
Esempio n. 9
0
        // ProfileDialog

        public static Person personThisIsOf(this ProfileDialog dialog)
        {
            return((Person)typeof(ProfileDialog).GetField("personThisIsOf", InstanceNonPub).GetValue(dialog));
        }