Пример #1
0
        public void ExecuteCustomAction([NotNull] IActionDefinition action)
        {
            var schemaManager = new AnnotationsPropertySchemaManager(_model);

            _right.SuspendLayout();

            switch (action.Name)
            {
            case "AddReviewNote":
                if (_selected != null)
                {
                    var review = new ReviewNote();
                    schemaManager.AddAnnotation(_selected, review);
                    AddButton(review);
                }
                break;

            case "RemoveReviewNote":
                if (_selected != null && _annotation.Annotation is ReviewNote reviewNote &&
                    MessageBox.Show("You are about to remove the currently selected Review Note. Are you sure?",
                                    "Remove Review Note", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    schemaManager.RemoveAnnotation(_selected, reviewNote);
                    _annotation.Annotation = null;
                    RemoveButton(reviewNote);
                }
                break;

            case "Export":
                var saveFileDialog = new SaveFileDialog()
                {
                    AddExtension       = true,
                    AutoUpgradeEnabled = true,
                    CheckFileExists    = false,
                    CheckPathExists    = true,
                    RestoreDirectory   = true,
                    DefaultExt         = "csv",
                    Filter             = "CSV file (*.csv)|*.csv",
                    Title         = "Create CSV file",
                    ValidateNames = true
                };
                if (saveFileDialog.ShowDialog(Form.ActiveForm) == DialogResult.OK)
                {
                    ExportCsv(saveFileDialog.FileName);
                }
                break;

            case "Refresh":
                LoadModel();
                break;
            }

            _right.ResumeLayout();
        }
Пример #2
0
        public bool Execute()
        {
            var result = false;

            if (_annotation is TopicToBeClarified topicToBeClarified)
            {
                var dialog = new AnnotationDialog(_model, _container, topicToBeClarified, true);
                if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.Abort)
                {
                    var schemaManager = new AnnotationsPropertySchemaManager(_model);
                    schemaManager.RemoveAnnotation(_container, topicToBeClarified);
                }

                result = true;
            }
            else if (_annotation is Highlight highlight)
            {
                var dialog = new AnnotationDialog(_model, _container, highlight, true);
                if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.Abort)
                {
                    var schemaManager = new AnnotationsPropertySchemaManager(_model);
                    schemaManager.RemoveAnnotation(_container, highlight);
                }

                result = true;
            }
            else if (_annotation is ReviewNote reviewNote)
            {
                var dialog = new AnnotationDialog(_model, _container, reviewNote, true);
                if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.Abort)
                {
                    var schemaManager = new AnnotationsPropertySchemaManager(_model);
                    schemaManager.RemoveAnnotation(_container, reviewNote);
                }

                result = true;
            }

            return(result);
        }
Пример #3
0
        public void ExecuteCustomAction([NotNull] IActionDefinition action)
        {
            var schemaManager = new AnnotationsPropertySchemaManager(_model);

            _right.SuspendLayout();

            switch (action.Name)
            {
            case "AddNotes":
                if (_selected != null)
                {
                    var notes = new Annotation();
                    schemaManager.AddAnnotation(_selected, notes);
                    AddButton(notes);
                }
                break;

            case "AddTopic":
                if (_selected != null)
                {
                    var topic = new TopicToBeClarified();
                    schemaManager.AddAnnotation(_selected, topic);
                    AddButton(topic);
                }
                break;

            case "AddHighlight":
                if (_selected != null)
                {
                    var high = new Highlight();
                    schemaManager.AddAnnotation(_selected, high);
                    AddButton(high);
                }
                break;

            case "RemoveNotes":
                if (_selected != null && _annotation.Annotation is Annotation annotation &&
                    MessageBox.Show("You are about to remove the currently selected Note. Are you sure?",
                                    "Remove Notes", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    schemaManager.RemoveAnnotation(_selected, annotation);
                    _annotation.Annotation = null;
                    RemoveButton(annotation);
                }
                break;

            case "RemoveTopic":
                if (_selected != null && _annotation.Annotation is TopicToBeClarified toBeClarified &&
                    MessageBox.Show("You are about to remove the currently selected Topic. Are you sure?",
                                    "Remove Topic", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    schemaManager.RemoveAnnotation(_selected, toBeClarified);
                    _annotation.Annotation = null;
                    RemoveButton(toBeClarified);
                }
                break;

            case "RemoveHighlight":
                if (_selected != null && _annotation.Annotation is Highlight highlight &&
                    MessageBox.Show("You are about to remove the currently selected Highlight. Are you sure?",
                                    "Remove Highlight", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    schemaManager.RemoveAnnotation(_selected, highlight);
                    _annotation.Annotation = null;
                    RemoveButton(highlight);
                }
                break;

            case "ShowOpenTopics":
                _show = WhatToShow.OpenTopicsOnly;
                LoadModel();
                ChangeCustomActionStatus?.Invoke("ShowOpenTopics", false);
                ChangeCustomActionStatus?.Invoke("ShowHighlights", true);
                ChangeCustomActionStatus?.Invoke("ShowReviewNotes", true);
                ChangeCustomActionStatus?.Invoke("ShowAll", true);
                break;

            case "ShowHighlights":
                _show = WhatToShow.HighlightsOnly;
                LoadModel();
                ChangeCustomActionStatus?.Invoke("ShowOpenTopics", true);
                ChangeCustomActionStatus?.Invoke("ShowHighlights", false);
                ChangeCustomActionStatus?.Invoke("ShowReviewNotes", true);
                ChangeCustomActionStatus?.Invoke("ShowAll", true);
                break;

            case "ShowAll":
                _show = WhatToShow.All;
                LoadModel();
                ChangeCustomActionStatus?.Invoke("ShowOpenTopics", true);
                ChangeCustomActionStatus?.Invoke("ShowHighlights", true);
                ChangeCustomActionStatus?.Invoke("ShowReviewNotes", true);
                ChangeCustomActionStatus?.Invoke("ShowAll", false);
                break;

            case "ExportOpen":
                var saveFileDialog = new SaveFileDialog()
                {
                    AddExtension       = true,
                    AutoUpgradeEnabled = true,
                    CheckFileExists    = false,
                    CheckPathExists    = true,
                    RestoreDirectory   = true,
                    DefaultExt         = "csv",
                    Filter             = "CSV file (*.csv)|*.csv|Excel file (*.xlsx)|*.xlsx",
                    Title         = "Create a file with open Topics",
                    ValidateNames = true
                };
                if (saveFileDialog.ShowDialog(Form.ActiveForm) == DialogResult.OK)
                {
                    ExportCsv(saveFileDialog.FileName, true);
                }
                break;

            case "ExportAll":
                var saveFileDialog2 = new SaveFileDialog()
                {
                    AddExtension       = true,
                    AutoUpgradeEnabled = true,
                    CheckFileExists    = false,
                    CheckPathExists    = true,
                    RestoreDirectory   = true,
                    DefaultExt         = "csv",
                    Filter             = "CSV file (*.csv)|*.csv|Excel file (*.xlsx)|*.xlsx",
                    Title         = "Create a file with all Topics",
                    ValidateNames = true
                };
                if (saveFileDialog2.ShowDialog(Form.ActiveForm) == DialogResult.OK)
                {
                    ExportCsv(saveFileDialog2.FileName, false);
                }
                break;

            case "Refresh":
                LoadModel();
                break;
            }

            _right.ResumeLayout();
        }