Beispiel #1
0
        private void Devices_CmdDelete_Executed(object sender, ExecutedRoutedEventArgs evt)
        {
            int    count   = Devices.Count(predicate: IsSelectedDevice);
            string message = count == 1 ? JCstring.MessageTextDeleteOneDevice : string.Format(JCstring.MessageTextDeleteMultipleDevices, count);

            MessageBoxExResult result = MessageBoxEx.Show(
                new MessageBoxExParams {
                CaptionText = JCstring.MessageCaptionDelete,
                MessageText = message,
                Image       = MessageBoxExImage.Question,
                Button      = MessageBoxExButton.YesNo,
                Owner       = this
            }
                );

            if (result == MessageBoxExResult.Yes)
            {
                List <Device> deleteDevices = Devices.Where(predicate: IsSelectedDevice).ToList();
                foreach (Device device in deleteDevices)
                {
                    Devices.Remove(device);
                }
            }

            Devices_SetDataGridFocus();
        }
 /// <summary>
 /// Create a new standard button with an image.
 /// </summary>
 /// <param name="caption">The button text</param>
 /// <param name="result">The button result</param>
 /// <param name="image">The button image</param>
 /// <param name="isDefault">Is the default button</param>
 public MessageBoxExButton(string caption, MessageBoxExResult result, Bitmap image, bool isDefault = false)
 {
     Message   = caption;
     Result    = result;
     IsDefault = isDefault;
     Image     = image;
 }
 /// <summary>
 /// Create a new standard button.
 /// </summary>
 /// <param name="caption">The button text</param>
 /// <param name="result">The button result</param>
 /// <param name="isDefault">Is the default button</param>
 ///
 public MessageBoxExButton(string caption, MessageBoxExResult result, bool isDefault = false)
 {
     Message      = caption;
     Result       = result;
     IsDefault    = isDefault;
     CustomResult = null;
 }
Beispiel #4
0
        private bool Save(bool forceSaveAs)
        {
            if ((this._filename != "" && this._filename != null) || forceSaveAs == true)
            {
                if (this._filename.StartsWith("<") == true || forceSaveAs == true)
                {
                    if (this.saveFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        this._filename = this.saveFileDialog.FileName;
                    }
                    else
                    {
                        return(false);
                    }
                }

                this.CheckPath(this._filename);

                try
                {
                    this._cs.Save(this._clips, this._filename);
                    this._clips.Modified = false;
                }
                catch (Exception e)
                {
                    //TODO: Check for read-only files
                    // file:///P:/Tools/Vista%20UX%20Guide/Windows/DialogBoxes/DialogBoxesPatterns.htm#QuestionDialogsLinks
                    MessageBoxExResult res = MessageBoxEx.Show(
                        this,
                        this.Text,
                        "An error occured while saving.",
                        e.Message,
                        "Save as...",
                        "Retry",
                        MessageBoxIcon.Error);
                    if (res == MessageBoxExResult.Commit1)
                    {
                        this.Save(true);
                    }
                    else if (res == MessageBoxExResult.Commit2)
                    {
                        this.Save(false);
                    }
                    return(res != MessageBoxExResult.Cancel);
                }
            }
            return(true);
        }
Beispiel #5
0
        private void Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.Control btn = sender as System.Windows.Controls.Control;

            if (null != btn)
            {
                if ("btn_Yes" == btn.Name)
                {
                    messageBoxExResult = MessageBoxExResult.Yes;
                }
                else if ("btn_No" == btn.Name)
                {
                    messageBoxExResult = MessageBoxExResult.No;
                }
            }

            this.Close();
        }
        private bool SaveUnsavedData()
        {
            if (!Devices.IsModified)
            {
                return(true);
            }

            while (true)
            {
                MessageBoxExResult result = MessageBoxEx.Show(
                    new MessageBoxExParams {
                    CaptionText = JCstring.MessageCaptionUnsavedData,
                    MessageText = JCstring.MessageTextUnsavedData.Unescape(),
                    Image       = MessageBoxExImage.Warning,
                    Button      = MessageBoxExButton.YesNoCancel,
                    Owner       = this
                }
                    );

                switch (result)
                {
                case MessageBoxExResult.Yes:
                    if (SaveDeviceCollection())
                    {
                        return(true);
                    }
                    break;

                case MessageBoxExResult.No:
                    return(true);

                case MessageBoxExResult.Cancel:
                    return(false);
                }
            }
        }