示例#1
0
        private void EditLabelsHost_Load(object sender, EventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            try
            {
                MinimumSize = new Size(900, 600);

                Left = (int)TopLeft.X;
                Top  = (int)TopLeft.Y;

                // Fix bottom panel
                int margin = Buttons.Height - Save.Bottom;
                splitContainer1.SplitterDistance = splitContainer1.Height - Save.Height - margin * 2;
                splitContainer1.FixedPanel       = FixedPanel.Panel2;
                splitContainer1.IsSplitterFixed  = true;

                var editor = new LabelsEditor(_options);
                editor.InitializeComponent();
                elementHost1.Child = editor;

                editor.TopLeft = TopLeft;
                editor.Used1D  = Used1D;
                editor.PopulateTreeView(Cml);

                Warning.Text = Message;
            }
            catch (Exception ex)
            {
                using (var form = new ReportError(Globals.Chem4WordV3.Telemetry, TopLeft, module, ex))
                {
                    form.ShowDialog();
                }
            }
        }
        void Button_Click(object sender, RoutedEventArgs e)
        {
            var labels = LabelsEditor.GetVisualLabels();

            // Add selected labels to all messages that don't have one yet
            foreach (var message in _messages)
            {
                foreach (var label in labels)
                {
                    LabelsContainer label1 = label;

                    if (!message.LabelsList.Any(l => l.Labelname.ToLower() == label1.Labelname.ToLower()))
                    {
                        message.AddLabel(new Label(label1.Labelname));
                    }
                }
            }

            // Add selected labels to all documents that don't have one yet
            //foreach (var document in _documents)
            //{
            //    foreach (var label in labels)
            //    {
            //        LabelsContainer label1 = label;

            //        if (!document.LabelsList.Any(l => l.Labelname.ToLower() == label1.Labelname.ToLower()))
            //            document.AddLabel(label1.Labelname);
            //    }
            //}

            Close();
        }
示例#3
0
        public EditorHost(string cml, string type)
        {
            InitializeComponent();
            _editorType = type;

            AcmeOptions acmeOptions = new AcmeOptions(null);

            var used1D = SimulateGetUsed1DLabels(cml);

            MessageFromWpf.Text = "";

            SystemHelper helper    = new SystemHelper();
            var          telemetry = new TelemetryWriter(true, helper);

            switch (_editorType)
            {
            case "ACME":
                Editor acmeEditor = new Editor();
                acmeEditor.EditorOptions = acmeOptions;
                acmeEditor.InitializeComponent();
                elementHost1.Child = acmeEditor;

                // Configure Control
                acmeEditor.ShowFeedback = false;
                acmeEditor.TopLeft      = new Point(Left, Top);
                acmeEditor.Telemetry    = telemetry;
                acmeEditor.SetProperties(cml, used1D, acmeOptions);

                acmeEditor.OnFeedbackChange += AcmeEditorOnFeedbackChange;

                break;

            case "LABELS":
                LabelsEditor labelsEditor = new LabelsEditor(acmeOptions);
                labelsEditor.InitializeComponent();
                elementHost1.Child = labelsEditor;

                // Configure Control
                labelsEditor.TopLeft = new Point(Left, Top);
                labelsEditor.Used1D  = used1D;
                labelsEditor.PopulateTreeView(cml);

                break;

            default:
                CmlEditor cmlEditor = new CmlEditor();
                cmlEditor.InitializeComponent();
                elementHost1.Child = cmlEditor;

                // Configure Control
                cmlEditor.Cml = cml;

                break;
            }
        }
示例#4
0
        public EditorHost(string cml, string type)
        {
            InitializeComponent();
            _editorType = type;

            var appdata      = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var settingsPath = Path.Combine(appdata, "Chem4Word.V3");

            var used1D = SimulateGetUsed1DLabels(cml);

            MessageFromWpf.Text = "";

            switch (_editorType)
            {
            case "ACME":
                Options options = new Options();
                options.SettingsFile = Path.Combine(settingsPath, "Chem4Word.Editor.ACME.json");

                Editor acmeEditor = new Editor();
                acmeEditor.InitializeComponent();
                elementHost1.Child = acmeEditor;

                // Configure Control
                acmeEditor.ShowFeedback = false;
                SystemHelper helper = new SystemHelper();
                acmeEditor.Telemetry = new TelemetryWriter(true, helper);
                acmeEditor.SetProperties(cml, used1D, options);
                acmeEditor.OnFeedbackChange += AcmeEditorOnFeedbackChange;

                break;

            case "LABELS":
                LabelsEditor labelsEditor = new LabelsEditor();
                labelsEditor.InitializeComponent();
                elementHost1.Child = labelsEditor;

                // Configure Control
                labelsEditor.Used1D = used1D;
                labelsEditor.PopulateTreeView(cml);

                break;

            default:
                CmlEditor cmlEditor = new CmlEditor();
                cmlEditor.InitializeComponent();
                elementHost1.Child = cmlEditor;

                // Configure Control
                cmlEditor.Cml = cml;

                break;
            }
        }