Beispiel #1
0
        protected CollectorsForm2(Graph graph, bool hint)
            : base()
        {
            InitializeComponent();

            var items = MainMenuStrip.Items;
            ((ToolStripMenuItem)items["FileMenu"]).DropDownItems.Add(distractFromCurrentToolStripMenuItem);

            this.graph = graph;

            preciseSpectrumDisplayed = hint;
            setTitles();
            string prefix = (graph.DisplayingMode == Graph.Displaying.Diff) ? DIFF_TITLE : "";

            {
                int count = graph.Collectors.Count;
                graphs = new ZedGraphControlPlus[count];
                minX = new ushort[count];
                maxX = new ushort[count];
                setXScaleLimits();
            }

            SuspendLayout();
            tabControl.SuspendLayout();
            for (int i = 0; i < graph.Collectors.Count; ++i) {
                var collector = graph.Collectors[i];
                if (DisableTabPage(collector)) {
                    graphs[i] = null;
                    continue;
                }
                var tabPage = new TabPage(prefix + i + modeText) { UseVisualStyleBackColor = true };
                tabPage.SuspendLayout();
                tabControl.Controls.Add(tabPage);
                {
                    var zgc = new ZedGraphControlPlus() { ScrollMaxX = maxX[i], ScrollMinX = minX[i], Tag = (byte)(i + 1) };
                    zgc.PointValueEvent += ZedGraphControlPlus_PointValueEvent;
                    zgc.ContextMenuBuilder += ZedGraphControlPlus_ContextMenuBuilder;
                    tabPage.Controls.Add(zgc);
                    graphs[i] = zgc;
                }
                tabPage.ResumeLayout(false);
            }
            tabControl.ResumeLayout(false);
            ResumeLayout(false);
            PerformLayout();

            graph.GraphDataModified += InvokeRefreshGraph;
            graph.AxisModeChanged += InvokeAxisModeChange;
            graph.DisplayModeChanged += InvokeGraphModified;
        }
Beispiel #2
0
        void ZedGraphControlPlus_ContextMenuBuilder(object sender, ZedGraphControlPlus.ContextMenuBuilderEventArgs args)
        {
            var items = args.MenuStrip.Items;
            items.Add(new ToolStripSeparator());

            {
                var ppl = args.Row;
                int index = args.Index;
                if (ppl != null && index > 0 && index < ppl.Count && ppl.PLSreference != null) {
                    byte collectorNumber = (byte)((ZedGraphControlPlus)sender).Tag;

                    ushort step = (ushort)ppl.PLSreference.Step[index].X;

                    items.Add(new ToolStripMenuItem("Добавить точку в редактор", null,
                        (s, e) => {
                            var form = new AddPointForm(step, collectorNumber);
                            if (form.ShowDialog() == DialogResult.OK) {
                                Graph.PointToAdd = form.PointToAdd;
                            }
                        }));

                    items.Add(new ToolStripMenuItem("Коэффициент коллектора " + collectorNumber, null,
                        (s, e) => Modified |= new SetScalingCoeffForm(step, collectorNumber, graph != Graph.MeasureGraph.Instance, graph.setScalingCoeff).ShowDialog() == DialogResult.Yes));
                    {
                        var ped = ppl.PEDreference;
                        items.Add(new ToolStripMenuItem("Вычесть из текущего с перенормировкой на точку", null,
                            (s, e) => GraphForm_OnDiffOnPoint(step, collectorNumber, ped)));
                        if (ped != null) {
                            items.Add(new ToolStripMenuItem("Вычесть из текущего с перенормировкой на интеграл пика", null,
                                (s, e) => GraphForm_OnDiffOnPoint(ushort.MaxValue, null, ped)));
                        }
                    }
                    items.Add(new ToolStripSeparator());
                }
            }

            var stepViewItem = new ToolStripMenuItem("Ступени", null, (s, e) => graph.AxisDisplayMode = ScalableDataList.DisplayValue.Step);
            var voltageViewItem = new ToolStripMenuItem("Напряжение", null, (s, e) => graph.AxisDisplayMode = ScalableDataList.DisplayValue.Voltage);
            var massViewItem = new ToolStripMenuItem("Масса", null, (s, e) => graph.AxisDisplayMode = ScalableDataList.DisplayValue.Mass);

            switch (graph.AxisDisplayMode) {
                case ScalableDataList.DisplayValue.Step:
                    stepViewItem.Checked = true;
                    break;
                case ScalableDataList.DisplayValue.Voltage:
                    voltageViewItem.Checked = true;
                    break;
                case ScalableDataList.DisplayValue.Mass:
                    massViewItem.Checked = true;
                    break;
            }

            items.Add(new ToolStripMenuItem("Выбрать шкалу", null, stepViewItem, voltageViewItem, massViewItem));
        }