Пример #1
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // If user has unsaved data ask them to confirm if they want to save first before closing.
            if (HasTxtChanged == true)
            {
                //Convert the Dialog so it is reusable for this instance
                AreYouSureDialog areYouSureDialog = new AreYouSureDialog();
                areYouSureDialog.Main_Label.Text            = "Would you like to save before closing?";
                areYouSureDialog.Warning_Label.Text         = "";
                areYouSureDialog.AYSD_Cancel_Button.Content = "Dont Save";
                areYouSureDialog.AYSD_Delete_Button.Content = "Save";
                areYouSureDialog.IsThisToDelete             = false;

                //Position window correctly

                areYouSureDialog.Owner = this;
                areYouSureDialog.WindowStartupLocation = WindowStartupLocation.Manual;
                areYouSureDialog.Top  = Owner.Top + 300;
                areYouSureDialog.Left = Owner.Left + 450;

                areYouSureDialog.ShowDialog();

                if (areYouSureDialog.DoesUserWantToSave == true)
                {
                    Recipe_JsonHandler.WriteToJsonFile_Tips(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Recipe Rack\\Tips\\TipsDocument.json", new TextRange(Tips_Rich_TextBox.Document.ContentStart, Tips_Rich_TextBox.Document.ContentEnd).Text.ToString());
                    HasTxtChanged = false;
                }
            }
        }
Пример #2
0
 private void Delete_Button_Click(object sender, RoutedEventArgs e)
 {
     // Give the user a dialog box to confirm they want to delete a recipe.
     if (!(SelectRecipes_ListBox.SelectedItem == null))
     {
         AreYouSureDialog areYouSureDialog = new AreYouSureDialog();
         areYouSureDialog.Owner = this;
         areYouSureDialog.WindowStartupLocation = WindowStartupLocation.Manual;
         areYouSureDialog.Top  = this.Top + 150;
         areYouSureDialog.Left = this.Left + 300;
         areYouSureDialog.ShowDialog();
         SelectRecipes_ListBox.Items.Clear();
         Show_UIControls(false);
     }
 }