Exemple #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();
        }
Exemple #2
0
 private void Generate([NotNull] Question question, [NotNull] IPropertiesContainer container,
                       [NotNull] AnnotationsPropertySchemaManager schemaManager)
 {
     if (question.Rule?.Evaluate(container) ?? false)
     {
         schemaManager.AddAnnotation(container, new TopicToBeClarified()
         {
             Text = question.Text
         });
     }
 }
Exemple #3
0
        public bool Execute()
        {
            bool result = false;

            var dialog = new AnnotationDialog(_model, _container, new ReviewNote());

            if (dialog.ShowDialog(Form.ActiveForm) == DialogResult.OK)
            {
                var schemaManager = new AnnotationsPropertySchemaManager(_model);
                schemaManager.AddAnnotation(_container, dialog.Annotation);
                result = true;
            }

            return(result);
        }
Exemple #4
0
        private void Generate([NotNull] Question question,
                              IEnumerable <IPropertiesContainer> containers, AnnotationsPropertySchemaManager schemaManager)
        {
            var items = containers?.ToArray();

            if (items?.Any() ?? false)
            {
                foreach (var item in items)
                {
                    if (question.Rule?.Evaluate(item) ?? false)
                    {
                        schemaManager.AddAnnotation(item, new TopicToBeClarified()
                        {
                            Text = question.Text
                        });
                    }
                }
            }
        }
Exemple #5
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();
        }