/// <summary>
 /// Shows the edit group dialog, where user can change the name
 /// </summary>
 private void EditGroupButton_Click(object sender, RoutedEventArgs e)
 {
     var groupName = ((Button)sender).Tag.ToString();
     var input = new InputPrompt
     {
         Title = "Edit Group Name",
         Message = String.Format("\r\nChoose a new name for the group, \"{0}\"", groupName),
         MessageTextWrapping = TextWrapping.Wrap,
         IsAppBarVisible = true,
         IsCancelVisible = true,
         IsSubmitOnEnterKey = true,
         IsOverlayApplied = true
     };
     input.Completed += delegate(object sender1, PopUpEventArgs<string, PopUpResult> e1)
     {
         GroupViewModel groupViewModel;
         if (e1.PopUpResult == PopUpResult.Ok)
         {
             groupViewModel = new GroupViewModel(groupName);
             groupViewModel.Group.Name = e1.Result;
             groupViewModel.Save();
             App.ViewModel.LoadAllMedicinesByGroups(true);
         }
     };
     input.Show();
 }
 /// <summary>
 /// Deletes the group
 /// </summary>
 private void DeleteGroupButton_Click(object sender, RoutedEventArgs e)
 {
     var groupName = ((Button)sender).Tag.ToString();
     var result = MessageBox.Show(String.Format("Delete, \"{0}\"", groupName), "Are you sure?", MessageBoxButton.OKCancel);
     if (result == MessageBoxResult.OK)
     {
         GroupViewModel groupViewModel = new GroupViewModel(groupName);
         groupViewModel.Delete();
         App.ViewModel.LoadAllMedicinesByGroups(true);
         MessageBox.Show(String.Format("Deleted group, \"{0}\"", groupName));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Shows a dialog to create a new group
 /// </summary>
 /// <returns>Name of the new group if created else an empty string</returns>
 public static void CreateNewGroupDialog(GroupViewModel groupViewModel = null, bool showInfoMsg = false)
 {
     string groupName = String.Empty;
     var input = new InputPrompt
     {
         Title = "Add Group",
         Message = "\r\nChoose a name for the new group",
         MessageTextWrapping = TextWrapping.Wrap,
         IsAppBarVisible = true,
         IsCancelVisible = true,
         IsSubmitOnEnterKey = true,
         IsOverlayApplied = true
     };
     input.Completed += delegate(object sender, PopUpEventArgs<string, PopUpResult> e)
     {
         if (e.PopUpResult == PopUpResult.Ok)
         {
             groupName = e.Result;
             if (groupViewModel == null)
                 groupViewModel = new GroupViewModel();
             groupViewModel.Group.Name = groupName;
             if (groupViewModel.Create())
             {
                 groupViewModel.AllGroups.Add(groupViewModel.Group);
                 if (showInfoMsg)
                     MessageBox.Show("Group is created but won't be shown here!\r\nAdd some medicines to the group to see it here.");
             }
         }
     };
     input.Show();
 }