Пример #1
0
        bool MSGraphControl_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                return(false);
            }

            Point pos = MousePosition;

            pos = PointToClient(pos);
            MSGraphPane pane = MasterPane.FindChartRect(new PointF(pos.X, pos.Y)) as MSGraphPane;

            if (pane == null)
            {
                pos = PointToClient(new Point(ContextMenuStrip.Left, ContextMenuStrip.Top));
            }
            pane = MasterPane.FindChartRect(new PointF(pos.X, pos.Y)) as MSGraphPane;
            if (pane == null)
            {
                return(false);
            }

            if ((IsEnableHPan) &&
                ((e.Button == PanButtons && ModifierKeys == PanModifierKeys) ||
                 (e.Button == PanButtons2 && ModifierKeys == PanModifierKeys2)))
            {
                Graphics g = CreateGraphics();
                pane.SetScale(g);
            }
            return(false);
        }
Пример #2
0
        protected void ZedGraphWeb1_RenderGraph(ZedGraphWeb webObject,
                                                Graphics g, MasterPane pane)
        {
                                                                                     //GraphPane class came from the ZedGraph DLL
                        GraphPane myPane        = pane[0];                           //create an empty Graph Pane object
                        myPane.Title.Text       = "Approximate Site Traffic (2017)"; //Title text property of pane object
                        myPane.XAxis.Title.Text = "Month";                           //Title X axis label text property
                        myPane.YAxis.Title.Text = "Visits (thousands)";              //Title Y axis label text property
                                                                                     //PointPairList class came from the ZedGraph DLL
                        PointPairList list1 = new PointPairList();                   //New Point Pair List object
                                                                                     //Create some plotting line to display
                        for (int i = 0; i < 18; i++)
            {
                double x = Convert.ToDouble(i);
                double y = .75 * x * x * x;
                list1.Add(x, y);
            }
                        //Use a LineItem type chart came from the ZedGraph DLL
                        string textForLegend = "Site Visits";

            myPane.CurveList.Clear();
            LineItem myCurve = myPane.AddCurve(textForLegend,
                                               list1, Color.Red, SymbolType.Diamond);

            myCurve.Symbol.IsVisible = true;
        }
Пример #3
0
        private void CreateGraph()
        {
            ZedGraphControl zg1    = new ZedGraphControl();
            MasterPane      master = zg1.MasterPane;

            master.Rect = new RectangleF(0, 0, 1200, 800);
            master.PaneList.Clear();
            master.Title.IsVisible     = true;
            master.Title.FontSpec.Size = 16;
            master.Title.Text          = this.title;
            master.IsFontsScaled       = false;
            master.Margin.All          = 10;
            master.Legend.IsVisible    = false;
            addPaneToMaster(master, intervisscores, intervisactualScore, "site intervisibility");

            addPaneToMaster(master, terrainvisscores, terrainvisactualScore, "terrain visibility");
            // Refigure the axis ranges for the GraphPanes
            zg1.AxisChange();

            // Layout the GraphPanes using a default Pane Layout
            Bitmap b = new Bitmap(1200, 800);

            using (Graphics g = Graphics.FromImage(b))
            {
                master.SetLayout(g, PaneLayout.SingleColumn);
            }
            master.GetImage().Save(this.resultsfolder + "results.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }
Пример #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (AutoScaleAxis)
            {
                MasterPane.AxisChange(e.Graphics);
            }
            if (paneLayout.HasValue)
            {
                MasterPane.SetLayout(e.Graphics, paneLayout.Value);
                paneLayout = null;
            }
            else if (paneLayoutSize.HasValue)
            {
                var layoutSize = paneLayoutSize.Value;
                MasterPane.SetLayout(e.Graphics, layoutSize.Height, layoutSize.Width);
                paneLayoutSize = null;
            }
            base.OnPaint(e);

            if (rubberBand.Width > 0 && rubberBand.Height > 0)
            {
                e.Graphics.FillRectangle(RubberBandBrush, rubberBand);
                e.Graphics.DrawRectangle(RubberBandPen, rubberBand);
            }
        }
Пример #5
0
        public Form1()
        {
            InitializeComponent();
            master = zgc.MasterPane;
            master.PaneList.Clear();
            master.Title.IsVisible = true;
            master.Margin.All      = 10;
            master.Fill            = new Fill(SystemColors.Control);
            master.Border.Color    = SystemColors.Control;
            master.PaneList.Clear();
            for (int i = 0; i < 2; i++)
            {
                GraphPane pane = new GraphPane();
                master.Add(pane);
                if (i == 0)
                {
                    master.PaneList[0].Title.Text = "MS";
                }
                if (i == 1)
                {
                    master.PaneList[1].Title.Text = "MS";
                }
            }
            zgc.AxisChange();
            using (Graphics g = this.CreateGraphics())
            {
                // Refigure the axis ranges for the GraphPanes
                master.AxisChange(g);

                // Layout the GraphPanes using a default Pane Layout
                master.SetLayout(g, PaneLayout.SingleColumn);
            }
            zgc.IsSynchronizeXAxes = true;
        }
Пример #6
0
        public MasterPaneLayout()
            : base("A Demo of the MasterPane with a complex layout",
                   "MasterPane Layout", DemoType.General, DemoType.Special)
        {
            MasterPane master = base.MasterPane;

            master.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            master.Title.Text      = "My MasterPane Title";

            master.Margin.All = 10;
            //master.InnerPaneGap = 10;
            //master.Legend.IsVisible = true;
            //master.Legend.Position = LegendPos.TopCenter;

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for (int j = 0; j < 6; j++)
            {
                master.Add(AddGraph(j, rotator));
            }

            using (Graphics g = base.ZedGraphControl.CreateGraphics())
            {
                //master.PaneLayoutMgr.SetLayout( PaneLayout.ExplicitRow32 );
                //master.PaneLayoutMgr.SetLayout( 2, 4 );
                master.SetLayout(g, false, new int[] { 1, 3, 2 }, new float[] { 2, 1, 3 });
                master.IsCommonScaleFactor = true;
                base.ZedGraphControl.AxisChange();

                //g.Dispose();
            }
        }
Пример #7
0
        //Revision: JCarpenter 10/06
        /// <summary>
        /// Find the object currently under the mouse cursor, and return its state.
        /// </summary>
        private ContextMenuObjectState GetObjectState()
        {
            ContextMenuObjectState objState = ContextMenuObjectState.Background;

            // Determine object state
            Point     mousePt = PointToClient(MousePosition);
            int       iPt;
            GraphPane pane;
            object    nearestObj;

            using (Graphics g = CreateGraphics())
            {
                if (MasterPane.FindNearestPaneObject(mousePt, g, out pane,
                                                     out nearestObj, out iPt))
                {
                    CurveItem item = nearestObj as CurveItem;

                    if (item != null && iPt >= 0)
                    {
                        if (item.IsSelected)
                        {
                            objState = ContextMenuObjectState.ActiveSelection;
                        }
                        else
                        {
                            objState = ContextMenuObjectState.InactiveSelection;
                        }
                    }
                }
            }

            return(objState);
        }
        private void OnRenderGraph(ZedGraphWeb webObject, Graphics g, MasterPane pane)
        {
            DataSet   ds     = (DataSet)Cache["CurseCache"];
            GraphPane myPane = pane[0];

            myPane.Title.Text       = "Nr total de statii in functie de statia de pornire";
            myPane.XAxis.Title.Text = "Statie pornire";
            myPane.YAxis.Title.Text = "Nr. statii";
            Color[] colors =
            {
                Color.Red,    Color.Yellow, Color.Green, Color.Blue,
                Color.Purple, Color.Pink,   Color.Plum,  Color.Silver, Color.Salmon
            };
            if (ds != null)
            {
                List <string> listaX = new List <string>();
                PointPairList list   = new PointPairList();
                int           i      = 0;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    listaX.Add(r[2].ToString()); //rezultat

                    list.Add(0, (int)r[3], i++); // k
                }
                i = 0;

                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    PieItem segment1 = myPane.AddPieSlice((
                                                              int)r[3], colors[(i++) % colors.Length],
                                                          Color.White, 45f, (i % 2 == 0) ? 0.2 : 0,
                                                          r[2].ToString());
                }
            }
        }
Пример #9
0
        private void OnRenderGraph(ZedGraphWeb webObject, Graphics g, MasterPane pane)
        {
            DataSet   ds     = (DataSet)Cache["CurseCache"];
            GraphPane myPane = pane[0];

            myPane.Title.Text       = "Nr total de statii in functie de statia de pornire";
            myPane.XAxis.Title.Text = "Statie pornire";
            myPane.YAxis.Title.Text = "Nr. statii";
            Color[] colors =
            {
                Color.Red,    Color.Yellow, Color.Green, Color.Blue,
                Color.Purple, Color.Pink,   Color.Plum,  Color.Silver, Color.Salmon
            };
            if (ds != null)
            {
                List <string> listaX = new List <string>();
                PointPairList list   = new PointPairList();
                int           i      = 0;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    listaX.Add(r[2].ToString()); //rezultat

                    list.Add(0, (int)r[3], i++); // k
                }


                BarItem myCurve = myPane.AddBar("Curve 2", list, Color.Blue);
                myCurve.Bar.Fill              = new Fill(colors);
                myCurve.Bar.Fill.Type         = FillType.GradientByZ;
                myCurve.Bar.Fill.RangeMin     = 0;
                myCurve.Bar.Fill.RangeMax     = list.Count;
                myPane.XAxis.Type             = AxisType.Text;
                myPane.XAxis.Scale.TextLabels = listaX.ToArray();
            }
        }
Пример #10
0
        void MSGraphControl_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState, PointF mousePosition)
        {
            MSGraphPane pane = MasterPane.FindChartRect(mousePosition) as MSGraphPane;

            if (pane == null)
            {
                mousePosition = PointToClient(new Point(ContextMenuStrip.Left, ContextMenuStrip.Top));
            }
            pane = MasterPane.FindChartRect(mousePosition) as MSGraphPane;
            if (pane == null)
            {
                return;
            }

            Graphics g = CreateGraphics();

            pane.SetScale(g);

            if (IsSynchronizeXAxes)
            {
                foreach (MSGraphPane syncPane in MasterPane.PaneList)
                {
                    if (syncPane == pane)
                    {
                        continue;
                    }

                    syncPane.SetScale(g);
                }
            }

            Refresh();
        }
Пример #11
0
        private void degreeDistributionGraph()
        {
            ZedGraphControl zg     = new ZedGraphControl();
            MasterPane      master = setupPlotMaster(zg, "degree distribution graphs");

            var sorted = nodes.OrderBy(x => x.inWeight);
            var d      = sorted.Select(x => Convert.ToDouble(x.inWeight)).ToList();
            var lbls   = sorted.Select(x => x.name).ToList();

            addPaneToMaster(master, d, lbls, "in-coming sight lines");

            sorted = nodes.OrderBy(x => x.outWeight);
            d      = sorted.Select(x => Convert.ToDouble(x.outWeight)).ToList();
            lbls   = sorted.Select(x => x.name).ToList();
            addPaneToMaster(master, d, lbls, "out-going sight lines");

            sorted = nodes.OrderBy(x => x.totalWeight);
            d      = sorted.Select(x => Convert.ToDouble(x.totalWeight)).ToList();
            lbls   = sorted.Select(x => x.name).ToList();
            addPaneToMaster(master, d, lbls, "total sight lines");
            // Refigure the axis ranges for the GraphPanes
            zg.AxisChange();

            savePlot(master, @"C:\Users\Admin\Documents\projects\LostCity\viewNet\inDegreeDist.jpeg");
        }
Пример #12
0
        public ZedGraphChart()
        {
            MasterPane mp = MasterPane;

            mp.Border.IsVisible = true;
            mp.Border.Color     = Color.Yellow;

            ZedGraph.GraphPane pane = GraphPane;
            pane.Title.Text = "/";
            pane.Title.FontSpec.FontColor = Color.Gray;
            pane.IsFontsScaled            = false;
            pane.XAxis.Title.Text         = "t ";
            pane.YAxis.Title.Text         = "Δ";

            deltas       = new PointPairList();
            deltaSMA     = new PointPairList();
            deltaWMA     = new PointPairList();
            deltaCurrent = new PointPairList();

            deltasCurve       = GraphPane.AddCurve("Δ", deltas, Color.FromArgb(0, 204, 0), SymbolType.None);
            deltaSMACurve     = GraphPane.AddCurve("sma", deltaSMA, Color.FromArgb(255, 0, 0), SymbolType.None);
            deltaWMACurve     = GraphPane.AddCurve("wma", deltaWMA, Color.Yellow, SymbolType.None);
            deltaCurrentCurve = GraphPane.AddCurve("now", deltaCurrent, Color.Gray, SymbolType.None);

            SetTheme();
        }
Пример #13
0
        private void PlotAllFunctions()
        {
            // First, clear out any old GraphPane's from the MasterPane collection
            MasterPane master = zed.MasterPane;

            master.PaneList.Clear();

            // Display the MasterPane Title, and set the outer margin to 10 points
            master.Title.IsVisible = true;
            master.Margin.All      = 10;

            // Plot multiple functions arranged on a master pane.
            PlotOnMasterPane(Functions.LogisticApproximantSteep, "Logistic Steep (Approximant)");
            PlotOnMasterPane(Functions.LogisticFunctionSteep, "Logistic Steep (Function)");
            PlotOnMasterPane(Functions.SoftSign, "Soft Sign");
            PlotOnMasterPane(Functions.PolynomialApproximant, "Polynomial Approximant");
            PlotOnMasterPane(Functions.QuadraticSigmoid, "Quadratic Sigmoid");
            PlotOnMasterPane(Functions.ReLU, "ReLU");
            PlotOnMasterPane(Functions.LeakyReLU, "Leaky ReLU");
            PlotOnMasterPane(Functions.LeakyReLUShifted, "Leaky ReLU (Shifted)");
            PlotOnMasterPane(Functions.SReLU, "S-Shaped ReLU");
            PlotOnMasterPane(Functions.SReLUShifted, "S-Shaped ReLU (Shifted)");
            PlotOnMasterPane(Functions.ArcTan, "ArcTan");
            PlotOnMasterPane(Functions.TanH, "TanH");
            PlotOnMasterPane(Functions.ArcSinH, "ArcSinH");
            PlotOnMasterPane(Functions.ScaledELU, "Scaled Exponential Linear Unit");

            // Refigure the axis ranges for the GraphPanes.
            zed.AxisChange();

            // Layout the GraphPanes using a default Pane Layout.
            using (Graphics g = this.CreateGraphics()) {
                master.SetLayout(g, PaneLayout.SquareColPreferred);
            }
        }
Пример #14
0
        private void GraphicControl_Load(object sender, EventArgs e)
        {
            MasterPane.FitDrawingSpaceToScreen(false, true);
            //MainPane.AdditionalDrawingSpaceAreaMarginLeft = 24;

            masterPane.SetAppearanceScheme(masterPane.AppearanceScheme);

            toolStripDropDownButtonSelectionMode.DropDownItems.Clear();
            foreach (string name in Enum.GetNames(typeof(ChartPane.SelectionModeEnum)))
            {
                toolStripDropDownButtonSelectionMode.DropDownItems.Add(GeneralHelper.SeparateCapitalLetters(name));
            }

            // Appearance menu
            toolStripMenuItemAppearanceColorScheme.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownButtonAppearanceScheme_DropDownItemClicked);
            foreach (string name in Enum.GetNames(typeof(ChartPane.AppearanceSchemeEnum)))
            {
                toolStripMenuItemAppearanceColorScheme.DropDownItems.Add(GeneralHelper.SeparateCapitalLetters(name));
            }

            toolStripMenuItemAppearanceYAxisLabelPosition.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripMenuItemAppearanceYAxisLabelPosition_DropDownItemClicked);
            foreach (string name in Enum.GetNames(typeof(ChartPane.YAxisLabelPosition)))
            {
                toolStripMenuItemAppearanceYAxisLabelPosition.DropDownItems.Add(GeneralHelper.SeparateCapitalLetters(name));
            }

            //
            toolStripDropDownButtonScrollMode.DropDownItems.Clear();
            foreach (string name in Enum.GetNames(typeof(ChartPane.ScrollModeEnum)))
            {
                toolStripDropDownButtonScrollMode.DropDownItems.Add(GeneralHelper.SeparateCapitalLetters(name));
            }

            UpdateMasterPaneToolbar();
        }
Пример #15
0
        /// <summary>
        /// Создать два графика с помощью MasterPane
        /// </summary>
        private void DrawAllGraph()
        {
            MasterPane masterPane = zedGraph.MasterPane;

            masterPane.PaneList.Clear();

            int count = 2;

            for (int i = 0; i < count; i++)
            {
                // Создаем экземпляр класса GraphPane, представляющий собой один график
                GraphPane pane = new GraphPane();

                // Нарисуем график на панели
                DrawSingleGraph(pane);

                // Добавим график в MasterPane
                masterPane.Add(pane);
            }

            // Будем размещать добавленные графики в MasterPane
            using (Graphics g = CreateGraphics())
            {
                // Графики будут размещены в две строки,
                masterPane.SetLayout(g, PaneLayout.SingleColumn);
            }

            // Обновим оси и перерисуем график
            zedGraph.AxisChange();
            zedGraph.Invalidate();
        }
Пример #16
0
        private void AddChartToMaster(MasterPane master, PointPairList list, string title, string yaxistitle, VariableMeta meta, bool addStats)
        {
            GraphPane pane = new GraphPane();

            // Set the titles
            pane.Title.Text            = title;
            pane.XAxis.Title.Text      = "hour";
            pane.YAxis.Title.Text      = yaxistitle;
            pane.Border.IsVisible      = false;
            pane.XAxis.Scale.Max       = 23;
            pane.XAxis.Scale.Min       = 0;
            pane.XAxis.Scale.MajorStep = 4.0;
            pane.XAxis.Scale.MinorStep = 1.0;
            pane.YAxis.Scale.Min       = meta.min;
            pane.YAxis.Scale.Max       = meta.max;
            // Add the curve
            LineItem myCurve = pane.AddCurve(yaxistitle, list, Color.Black, SymbolType.XCross);

            // Don't display the line (This makes a scatter plot)
            myCurve.Line.IsVisible = false;
            // Hide the symbol outline
            myCurve.Symbol.Border.IsVisible = true;
            // Fill the symbol interior with color
            myCurve.Symbol.Size = 2f;
            if (addStats)
            {
                addStatsToPane(list, pane);
            }
            pane.AxisChange();
            master.Add(pane);
        }
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        public void RestoreState(SerializationInfoEx info)
        {
            Clear();

            lock (this)
            {
                foreach (ChartPane pane in GeneralHelper.EnumerableToList <ChartPane>(_panes))
                {
                    if (pane is SlaveChartPane)
                    {
                        this.RemoveSlavePane((SlaveChartPane)pane);
                    }
                }

                this.Name = info.GetString("Name");

                this.hScrollBar.Visible = info.GetBoolean("hScrollBar.Visible");
                this.vScrollBar.Visible = info.GetBoolean("vScrollBar.Visible");
                toolStripButtonShowScrollbars.Checked = this.hScrollBar.Visible;

                List <SerializationInfoEx> infos = info.GetValue <List <SerializationInfoEx> >("panesStates");
                for (int i = 0; i < infos.Count; i++)
                {
                    if (i == 0)
                    {
                        MasterPane.RestoreState(infos[0], true);
                    }
                    else
                    {
                        SlaveChartPane pane = CreateSlavePane("", SlaveChartPane.MasterPaneSynchronizationModeEnum.XAxis, 100);
                        pane.RestoreState(infos[i], true);
                    }
                }
            }
        }
Пример #18
0
        //DONE
        private void SetGraphPanels()
        {
            MasterPane myMaster = zedGraphControl1.MasterPane;

            _firstDate = DateTime.Now;

            //JPN: Initialize the date of last point to be shown in the dataview to the beginning of the Wockets Era.
            //Let's say 01-01-2007. If a dataset predates 2007, you will have to zoom manually to the region of interest
            //This value will later be changed to the last timestamp observed in the dataset
            _lastDate = new DateTime(2007, 01, 01, 00, 00, 00);

            myMaster.PaneList.Clear();

            // Set the master pane title
            myMaster.Title.IsVisible = false;

            // Fill the pane background with a color gradient
            myMaster.Fill = new Fill(Color.White, Color.MediumSlateBlue, 45.0F);

            // Set the margins and the space between panes to 10 points
            myMaster.Margin.All   = 0;
            myMaster.InnerPaneGap = 0;

            // Enable the master pane legend
            myMaster.Legend.IsVisible = false;
            //myMaster.Legend.Position = LegendPos.TopCenter;

            // Vertical pan and zoom not allowed
            zedGraphControl1.IsEnableVPan       = false;
            zedGraphControl1.IsEnableVZoom      = false;
            zedGraphControl1.IsShowPointValues  = _isUsingLabels;
            zedGraphControl1.IsSynchronizeXAxes = true;
        }
Пример #19
0
        private void LipidQuantificationProcessorUI_Load(object sender, EventArgs e)
        {
            MasterPane myMaster = zgcCurve.MasterPane;

            myMaster.PaneList.Clear();

            myMaster.Margin.All   = 10;
            myMaster.InnerPaneGap = 10;

            // Set the master pane title
            myMaster.Title.Text       = "Experimental Envelopes";
            myMaster.Title.IsVisible  = true;
            myMaster.Legend.IsVisible = false;

            GraphPane curve = new GraphPane();

            curve.XAxis.Title.Text = "Scan";
            curve.YAxis.Title.Text = "Intensity";
            myMaster.Add(curve);

            GraphPane ppm = new GraphPane();

            ppm.XAxis.Title.Text = "Scan";
            ppm.YAxis.Title.Text = "Monoisotopic PPM";
            myMaster.Add(ppm);

            myMaster.SetLayout(CreateGraphics(), PaneLayout.SingleColumn);
            zgcCurve.AxisChange();
        }
Пример #20
0
        private void refreshGraphs()
        {
            zc1.IsShowPointValues = true;
            MasterPane masterPane = zc1.MasterPane;

            masterPane.PaneList.Clear();

            // first pane (primary)
            GraphPane pane1 = new GraphPane();
            int       cc    = 0;

            foreach (String name in listBox1.SelectedItems)
            {
                pane1.Title.Text = this.Text;
                pane1.AddCurve(name, Datas[name], colors[cc], SymbolType.None);
                cc++;
                if (cc >= colors.Length)
                {
                    cc = 0;
                }
            }
            masterPane.Add(pane1);

            // second pane
            if (checkBox_showFourierAnalysis.Checked)
            {
                GraphPane pane2 = new GraphPane();

                int c = 0;
                foreach (String name in listBox1.SelectedItems)
                {
                    pane2.Title.Text = "Fourier analysis";
                    pane2.AddBar(String.Format("{0} (THD={1:F2}%)", name, calcTHD(name)), getFourierAnalysis(name), colors[c]);
                    pane2.XAxis.Scale.Max = 30;
                    pane2.XAxis.Scale.Min = 0;
                    c++;
                    if (cc >= colors.Length)
                    {
                        cc = 0;
                    }
                }

                masterPane.Add(pane2);
            }

            // layout them
            using (Graphics g = CreateGraphics())
            {
                masterPane.SetLayout(g, PaneLayout.SingleColumn);
            }

            zc1.AxisChange();
            zc1.Invalidate();

            tb_minX.Text = pane1.XAxis.Scale.Min.ToString();
            tb_maxX.Text = pane1.XAxis.Scale.Max.ToString();
            tb_minY.Text = pane1.YAxis.Scale.Min.ToString();
            tb_maxY.Text = pane1.YAxis.Scale.Max.ToString();
        }
Пример #21
0
        /// <summary>
        /// Place a list of <see cref="CurveItem" />'s in the selection list, removing all other
        /// items.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ciList">The list of <see cref="CurveItem" /> to be added to the list.</param>
        public void Select(MasterPane master, CurveList ciList)
        {
            //Clear the selection, but don't send the event,
            //the event will be sent in "AddToSelection" by calling "UpdateSelection"
            ClearSelection(master, false);

            AddToSelection(master, ciList);
        }
        public ZedGraphO18Experimental_ScanPPM(ZedGraphControl zgcGraph, Graphics g)
        {
            MasterPane myMaster = ZedGraphicExtension.InitMasterPanel(zgcGraph, g, 2, "Experimental Envelopes");

            updates.Updates.Add(new ZedGraphO18ExperimentalScan(zgcGraph, myMaster.PaneList[0], ""));

            updates.Updates.Add(new ZedGraphO18ExperimentalPPM(zgcGraph, myMaster.PaneList[1], ""));
        }
Пример #23
0
        private void Form_Load(object sender, EventArgs e)
        {
            MasterPane myPaneMaster = zedG.MasterPane;

            myPaneMaster.Title.Text = "NetWorth";
            myPaneMaster.Title.FontSpec.FontColor = Color.Black;

            GraphPane myPane = zedG.GraphPane;

            myPaneMaster.PaneList[0] = (myPane);

            //    //画一张的小图
            //    GraphPane paneStats = new GraphPane(new Rectangle(10, 10, 10, 10), "Mes", " t ( h )", "Rate");
            //    myPaneMaster.PaneList.Add(paneStats);

            LineItem[] myCurve = new LineItem[lineChart.Count];

            //建立indexD变量,索引myCurve变量
            int indexD = 0;
            //建立Random变量用于控制颜色变化
            Random aa = new Random();

            foreach (var variety in lineChart)
            {
                myCurve[indexD] = myPane.AddCurve(variety.Key, null, lineChart[variety.Key],
                                                  Color.FromArgb(aa.Next(1, 255), aa.Next(1, 255), aa.Next(1, 255)), SymbolType.None);
                myCurve[indexD].Symbol.Size = 8.0F;
                myCurve[indexD].Symbol.Fill = new Fill(Color.White);
                myCurve[indexD].Line.Width  = 2.0F;
                ++indexD;
            }

            // Draw the X tics between the labels instead of at the labels
            //myPane.XAxis.IsTicsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = date;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            //设置X轴和Y轴的名称
            myPane.XAxis.Title.Text = "时间"; //X轴
            myPane.YAxis.Title.Text = "净值"; //Y轴

            //设置图的title
            myPane.Title.Text = "净值曲线";

            // Fill the axis area with a gradient
            //myPane.AxisFill = new Fill(Color.White,
            //Color.FromArgb(255, 255, 166), 90F);
            // Fill the pane area with a solid color
            //myPane.PaneFill = new Fill(Color.FromArgb(250, 250, 255));

            //绩效指标图统计

            zedG.AxisChange();
            imageZed = zedG.GetImage();
        }
Пример #24
0
        void toolStripMenuItemAppearanceYAxisLabelPosition_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)e.ClickedItem;

            ChartPane.YAxisLabelPosition positionMode = (ChartPane.YAxisLabelPosition)Enum.Parse(typeof(ChartPane.YAxisLabelPosition), item.Text.Replace(" ", string.Empty));

            MasterPane.YAxisLabelsPosition = positionMode;
            MasterPane.Invalidate();
        }
Пример #25
0
        private void toolStripDropDownButtonAppearanceScheme_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)e.ClickedItem;

            ChartPane.AppearanceSchemeEnum scheme = (ChartPane.AppearanceSchemeEnum)Enum.Parse(typeof(ChartPane.AppearanceSchemeEnum), item.Text.Replace(" ", string.Empty));

            MasterPane.SetAppearanceScheme(scheme);
            MasterPane.Invalidate();
        }
Пример #26
0
        void MSGraphControl_MouseClick(object sender, MouseEventArgs e)
        {
            MSGraphPane pane = MasterPane.FindChartRect(e.Location) as MSGraphPane;

            if (pane != null && (IsEnableHZoom || IsEnableVZoom))
            {
                if ((_unzoomButtons.MatchesEvent(e) && ModifierKeys == _unzoomModifierKeys) ||
                    (_unzoomButtons2.MatchesEvent(e) && ModifierKeys == _unzoomModifierKeys2))
                {
                    if (IsSynchronizeXAxes)
                    {
                        foreach (MSGraphPane syncPane in MasterPane.PaneList)
                        {
                            syncPane.ZoomStack.Pop(syncPane);
                        }
                    }
                    else
                    {
                        pane.ZoomStack.Pop(pane);
                    }
                }
                else if (_unzoomAllButtons.MatchesEvent(e) ||
                         _unzoomAllButtons2.MatchesEvent(e))
                {
                    if (IsSynchronizeXAxes)
                    {
                        foreach (MSGraphPane syncPane in MasterPane.PaneList)
                        {
                            syncPane.ZoomStack.PopAll(syncPane);
                        }
                    }
                    else
                    {
                        pane.ZoomStack.PopAll(pane);
                    }
                }
                else
                {
                    return;
                }

                Graphics g = CreateGraphics();
                if (IsSynchronizeXAxes)
                {
                    foreach (MSGraphPane syncPane in MasterPane.PaneList)
                    {
                        syncPane.SetScale(g);
                    }
                }
                else
                {
                    pane.SetScale(g);
                }

                Refresh();
            }
        }
Пример #27
0
        /// <summary>
        /// Remove the specified <see cref="CurveItem" /> from the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ci">The <see cref="CurveItem" /> to be removed from the list.</param>
        public void RemoveFromSelection(MasterPane master, CurveItem ci)
        {
            if (this.Contains(ci))
            {
                this.Remove(ci);
            }

            UpdateSelection(master);
        }
Пример #28
0
 //初始化图表
 private void SetGraph()
 {
     //add 6-20
     master = zedGraphControl1.MasterPane;
     master.Title.IsVisible = false;
     //master.Title.Text = "原始数据";
     master.Margin.All = 0;
     //master.Fill = new Fill(Color.WhiteSmoke, Color.FromArgb(220, 220, 255), 45.0f);
 }
Пример #29
0
        /// <summary>
        /// Add a <see cref="CurveItem" /> to the selection list.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that is the "owner"
        /// of the <see cref="CurveItem" />'s.</param>
        /// <param name="ci">The <see cref="CurveItem" /> to be added to the list.</param>
        public void AddToSelection(MasterPane master, CurveItem ci)
        {
            if (this.Contains(ci) == false)
            {
                Add(ci);
            }

            UpdateSelection(master);
        }
Пример #30
0
        /// <summary>
        /// Constructor for graph form. Sets form up to be used for graphing, including
        /// adding two graphs to the main graph control and setting all properties to
        /// be used.
        /// </summary>
        public fGraph()
        {
            InitializeComponent();
            zg     = zedGraphMain;              //get graph component
            master = zedGraphMain.MasterPane;   //pull master from component

            master.PaneList.Clear();            //clear existing graph data

            price_pane = new GraphPane();       //create two graphs, one for score/time and one for price/time
            score_pane = new GraphPane();

            price_pane.XAxis.Type = AxisType.Date;              //set both graphs x-axis to type of date
            score_pane.XAxis.Type = AxisType.Date;

            //set panels y-axis spacing so the graphs appear congruent
            price_pane.YAxis.MinSpace  = 80;
            score_pane.YAxis.MinSpace  = 80;
            price_pane.Y2Axis.MinSpace = 20;
            score_pane.Y2Axis.MinSpace = 20;

            //set y-axis labels so user knows what they are
            price_pane.YAxis.Title.Text = "Cost in USD";
            score_pane.YAxis.Title.Text = "Arbitrary Score Units";

            price_pane.YAxis.Title.FontSpec.Size = 5.0f * (this.Size.Width / 100);
            score_pane.YAxis.Title.FontSpec.Size = 4.0f * (this.Size.Width / 100);

            //add both graphs to master pane
            master.Add(price_pane);
            master.Add(score_pane);

            //set scale factor to common so they zoom together and the x-axis moves together
            master.IsCommonScaleFactor = true;

            //set master graph options
            master.Title.IsVisible = true;
            master.Title.Text      = "Stock Data Over Time";
            master.Margin.All      = 10;
            master.InnerPaneGap    = 5;


            //set graphs to be on top of one-another
            using (Graphics g = this.CreateGraphics())
            {
                master.SetLayout(g, PaneLayout.SingleColumn);
                master.AxisChange(g);
            }

            //set x-axis to be syncrhonized
            zedGraphMain.IsSynchronizeXAxes = true;

            //set graph scrolling properties
            zedGraphMain.IsShowHScrollBar  = true;
            zedGraphMain.IsShowVScrollBar  = true;
            zedGraphMain.IsAutoScrollRange = true;
        }
Пример #31
0
        /// <summary>
        /// Generate an ImageMap as Html tags
        /// </summary>
        /// <param name="masterPane">The source <see cref="MasterPane" /> to be
        /// image mapped.</param>
        /// <param name="output">An <see cref="HtmlTextWriter" /> instance in which
        /// the html tags will be written for the image map.</param>
        public void MakeImageMap(MasterPane masterPane, HtmlTextWriter output)
        {
            string shape;
            string coords;
            var image = new Bitmap(1, 1);
            using (Graphics g = Graphics.FromImage(image))
            {
                float masterScale = masterPane.CalcScaleFactor();
                // Frontmost objects are MasterPane objects with A_InFront
                foreach (GraphObj obj in masterPane.GraphObjList)
                {
                    if (obj.Link.IsActive && obj.ZOrder == ZOrder.A_InFront)
                    {
                        obj.GetCoords(masterPane, g, masterScale, out shape, out coords);
                        MakeAreaTag(shape, coords, obj.Link.Url, obj.Link.Target,
                                    obj.Link.Title, obj.Link.Tag, output);
                    }
                }

                // Now loop over each GraphPane
                foreach (GraphPane pane in masterPane.PaneList)
                {
                    float scaleFactor = pane.CalcScaleFactor();

                    // Next comes GraphPane GraphObjs in front of data points
                    foreach (GraphObj obj in pane.GraphObjList)
                    {
                        if (obj.Link.IsActive && obj.IsInFrontOfData)
                        {
                            obj.GetCoords(pane, g, scaleFactor, out shape, out coords);
                            MakeAreaTag(shape, coords, obj.Link.Url, obj.Link.Target,
                                        obj.Link.Title, obj.Link.Tag, output);
                        }
                    }

                    // Then come the data points (CurveItems)
                    foreach (CurveItem curve in pane.CurveList)
                    {
                        if (curve.Link.IsActive && curve.IsVisible)
                        {
                            for (int i = 0; i < (curve is PieItem ? 1 : curve.Points.Count); i++)
                            {
                                //if ( curve.GetCoords( pane, i, pane.Rect.Left, pane.Rect.Top, out coords ) )
                                if (curve.GetCoords(pane, i, out coords))
                                {
                                    if (curve is PieItem)
                                    {
                                        MakeAreaTag("poly", coords, curve.Link.Url,
                                                    curve.Link.Target, curve.Link.Title, curve.Link.Tag, output);
                                        // only one point for PieItems
                                        break;
                                    }
                                    // Add an "?index=4" type tag to the url to indicate which
                                    // point was selected
                                    string url;
                                    if (curve.Link.Url != string.Empty)
                                    {
                                        url = curve.Link.MakeCurveItemUrl(pane, curve, i);
                                    }
                                    else
                                    {
                                        url = "";
                                    }

                                    string title = curve.Link.Title;
                                    if (curve.Points[i].Tag is string)
                                    {
                                        title = curve.Points[i].Tag as string;
                                    }
                                    MakeAreaTag("rect", coords, url,
                                                curve.Link.Target, title, curve.Points[i].Tag, output);
                                }
                            }
                        }
                    }

                    // Then comes the GraphObjs behind the data points
                    foreach (GraphObj obj in pane.GraphObjList)
                    {
                        if (obj.Link.IsActive && !obj.IsInFrontOfData)
                        {
                            obj.GetCoords(pane, g, scaleFactor, out shape, out coords);
                            MakeAreaTag(shape, coords, obj.Link.Url, obj.Link.Target,
                                        obj.Link.Title, obj.Link.Tag, output);
                        }
                    }
                }

                // Hindmost objects are MasterPane objects with !A_InFront
                foreach (GraphObj obj in masterPane.GraphObjList)
                {
                    if (obj.Link.IsActive && obj.ZOrder != ZOrder.A_InFront)
                    {
                        obj.GetCoords(masterPane, g, masterScale, out shape, out coords);
                        MakeAreaTag(shape, coords, obj.Link.Url, obj.Link.Target,
                                    obj.Link.Title, obj.Link.Tag, output);
                    }
                }
            }
        }
Пример #32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="outputStream"></param>
        /// <param name="format"></param>
        /// <param name="bShowTransparency">if true, draw squares instead of leaving the
        /// background transparent</param>
        /// <remarks>
        /// bShowTransparency is set to true in design mode, to false otherwise.
        /// </remarks>
        protected MasterPane CreateGraph(Stream outputStream, ImageFormat format,
                    bool bShowTransparency)
        {
            var rect = new RectangleF(0, 0, Width, Height);
            var mp = new MasterPane(string.Empty, rect);
            mp.Margin.All = 0;
            mp.Fill.IsVisible = false;
            mp.Border.IsVisible = false;

            // create all required panes
            //for ( int i = 0; i < this.PaneCount; i++ )
            //{
            mp.Add(new GraphPane(rect, Title, string.Empty, string.Empty));
            //}

            // create output bitmap container
            var image = new Bitmap(Width, Height);
            IGraphics g = new GdiGraphics(Graphics.FromImage(image));

            // Apply layout plan
            //mp.SetLayout( this.PaneLayout );
            mp.ReSize(g, rect);

            // Use callback to gather more settings and data values
            OnDrawPane(g, mp);

            // Allow designer control of axischange
            if (AxisChanged)
            {
                mp.AxisChange(g);
            }

            // Render the graph to a bitmap
            if (bShowTransparency && mp.Fill.Color.A != 255)
            {
                //Show the transparency as white/gray filled squares
                // We need to add the resource namespace to its name
                //string resourceName = string.Format( "{0}.transparency.png", GetType().Namespace );
                string resourceName = "ZedGraph.ZedGraph.transparency.png";
                Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

                if (stream == null)
                {
                    throw new Exception("Does the Build Action of the resource " + resourceName + " is set to Embedded Resource ?");
                }

                using (Image brushImage = new Bitmap(stream))
                {
                    using (var brush = new TextureBrush(brushImage, WrapMode.Tile))
                    {
                        g.FillRectangle(brush, 0, 0, Width, Height);
                    }
                }
                stream.Close();
            }
            mp.Draw(g);

            // Stream the graph out
            var ms = new MemoryStream();
            image.Save(ms, format);

            //TODO: provide caching options
            ms.WriteTo(outputStream);

            return mp;
        }
Пример #33
0
        /// <summary>
        /// stub method that passes control for the render event to the the registered
        /// event handler.
        /// </summary>
        protected virtual void OnDrawPane(IGraphics g, MasterPane mp)
        {
            ZedGraphWebControlEventHandler handler;
            handler = (ZedGraphWebControlEventHandler) Events[EventRender];

            MasterPaneFill.CopyTo(mp.Fill);
            MasterPaneBorder.CopyTo(mp.Border);

            if ((handler == null) && (CurveList.Count == 0) && (GraphObjList.Count == 0))
            {
                // default with the sample graph if no callback provided
                foreach (GraphPane p in mp.PaneList)
                {
                    RenderDemo(g, p);
                }
            }
            else
            {
                foreach (GraphPane p in mp.PaneList)
                {
                    // Add visual designer influences here - first!!
                    SetWebProperties(g, p);

                    // Add DataSource values if available before the callback
                    PopulateByDataSource(g, p);

                    //Add Graph Items
                    AddWebGraphItems(g, p);
                }

                //TODO: verify callback regression test
                // Add custom callback tweeking next
                if (handler != null)
                {
                    handler(this, g, mp);
                }

                // Set the layout according to user preferences
                mp.ReSize(g);
            }
        }
Пример #34
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZeeGraphControl()
        {
            _dragPane = null;
            InitializeComponent();

            // Use double-buffering for flicker-free updating:
            SetStyle(ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.ResizeRedraw, true);

            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            _resourceManager = new ResourceManager("ZeeGraph.ZeeGraphLocale",
                                                   Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle(0, 0, Size.Width, Size.Height);
            _masterPane = new MasterPane("", rect);
            _masterPane.Margin.All = 0;
            _masterPane.Title.IsVisible = false;

            string titleStr = _resourceManager.GetString("title_def");
            string xStr = _resourceManager.GetString("x_title_def");
            string yStr = _resourceManager.GetString("y_title_def");

            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);
            using (Graphics g = CreateGraphics())
            {
                graphPane.AxisChange(g);
                //g.Dispose();
            }
            _masterPane.Add(graphPane);

            hScrollBar1.Minimum = 0;
            hScrollBar1.Maximum = 100;
            hScrollBar1.Value = 0;

            vScrollBar1.Minimum = 0;
            vScrollBar1.Maximum = 100;
            vScrollBar1.Value = 0;

            _xScrollRange = new ScrollRange(true);
            _yScrollRangeList = new ScrollRangeList();
            _y2ScrollRangeList = new ScrollRangeList();

            _yScrollRangeList.Add(new ScrollRange(true));
            _y2ScrollRangeList.Add(new ScrollRange(false));

            _zoomState = null;
            _zoomStateStack = new ZoomStateStack();
        }
Пример #35
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if the components should be
        /// disposed, false otherwise</param>
        protected override void Dispose(bool disposing)
        {
            lock (_syncRoot)
            {
                if (disposing)
                {
                    if (components != null)
                        components.Dispose();
                }
                base.Dispose(disposing);

                _masterPane = null;
            }
        }