Example #1
0
        public LexPresetView()
        {
            RegisterDefinition("Lex.xshd");

            this.InitializeComponent();

            this.SegmentCodeEditor.TextArea.TextEntered +=
                (sender, args) =>
                this.ShowCompletionWindow(
                    args,
                    this.ViewModel.SegmentCodeCompletion,
                    this.SegmentCodeEditor);

            this.RecordCodeEditor.TextArea.TextEntered +=
                (sender, args) =>
                this.ShowCompletionWindow(
                    args,
                    this.ViewModel.RecordCodeCompletion,
                    this.RecordCodeEditor);

            this.SegmentCodeEditor.TextArea.TextEntering += this.OnTextAreaOnTextEntering;
            this.RecordCodeEditor.TextArea.TextEntering  += this.OnTextAreaOnTextEntering;

            this.ViewModel.EditCompleted = () => {
                DialogResult = true;
                this.Close();
            };

            this.Closing += (sender, args) => {
                if (this.DialogResult == true)
                {
                    return;
                }

                if (this.ViewModel.IsChanged)
                {
                    var result = CustomModernDialog.ShowMessage(
                        "Do you want to close the editor and discard all the changes?",
                        "Lex Preset",
                        this,
                        new ButtonDef("nosave", "dicard changes"),
                        new ButtonDef("cancel", "cancel", isCancel: true));

                    if (result == "cancel")
                    {
                        args.Cancel = true;
                    }
                }
            };
        }
Example #2
0
        public LexPresetsView()
        {
            this.InitializeComponent();

            this.ViewModel.SelectionCompleted = () => {
                this.DialogResult = true;
                this.Close();
            };

            this.ViewModel.SelectFileForImport = () => {
                var dialog = new OpenFileDialog {
                    Filter          = "LogWatch Lex Presets|*.lwlex|All Files|*.*",
                    CheckFileExists = true
                };

                if (dialog.ShowDialog() == true)
                {
                    return(dialog.FileName);
                }

                return(null);
            };

            this.ViewModel.SelectFileForExport = () => {
                var dialog = new SaveFileDialog {
                    Filter          = "LogWatch Lex Presets|*.lwlex|All Files|*.*",
                    OverwritePrompt = true
                };

                if (dialog.ShowDialog() == true)
                {
                    return(dialog.FileName);
                }

                return(null);
            };

            this.ViewModel.ConfirmDelete = preset => {
                var result = CustomModernDialog.ShowMessage(
                    string.Format("Are you sure you want to delete preset \"{0}\"?", preset.Name),
                    "Lex Presets",
                    this,
                    new ButtonDef("delete", "delete preset"),
                    ButtonDef.Cancel);

                return(result == "delete");
            };
        }