Exemplo n.º 1
0
        void Clear_list_zed()
        {
            ZedGraph.MasterPane masterPane = zedGraph1.MasterPane;

            masterPane.PaneList.Clear();
            GraphPane pane = new GraphPane();

            pane.CurveList.Clear();

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

            // Установим масштаб по умолчанию для оси X
            pane.XAxis.Scale.MinAuto = true;
            pane.XAxis.Scale.MaxAuto = true;
            // Установим масштаб по умолчанию для оси Y
            pane.YAxis.Scale.MinAuto = true;
            pane.YAxis.Scale.MaxAuto = true;

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

            zedGraph1.AxisChange();
            zedGraph1.Invalidate();
        }//Очистить график - функция
Exemplo n.º 2
0
        //Revision: JCarpenter 10/06
        /// <summary>
        /// Find the object currently under the mouse cursor, and return its state.
        /// </summary>
        ContextMenuObjectState GetObjectState()
        {
            var objState = ContextMenuObjectState.Background;

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

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

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

            return(objState);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

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

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height);

            masterPane              = new MasterPane("", rect);
            masterPane.MarginLeft   = 0;
            masterPane.MarginRight  = 0;
            masterPane.MarginTop    = 0;
            masterPane.MarginBottom = 0;

            GraphPane graphPane = new GraphPane(rect, "Title", "X-Axis", "Y-Axis");
            Graphics  g         = this.CreateGraphics();

            graphPane.AxisChange(g);
            g.Dispose();
            masterPane.Add(graphPane);

            this.isShowPointValues = false;
            this.isShowContextMenu = true;
            this.pointValueFormat  = PointPair.DefaultFormat;
            this.pointDateFormat   = XDate.DefaultFormatStr;
        }
Exemplo n.º 4
0
    void UseSkillStatistic(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        GraphPane graphPane = masterPane[0];

        graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

        graphPane.Legend.Fill.IsVisible          = false;
        graphPane.Legend.Border.IsVisible        = false;
        graphPane.Legend.FontSpec.Fill.IsVisible = false;

        graphPane.XAxis.Title.Text          = StringDef.Date;
        graphPane.XAxis.MajorGrid.Color     = WebConfig.GraphXAxisGridColor;
        graphPane.XAxis.Type                = AxisType.DateAsOrdinal;
        graphPane.XAxis.MinorTic.Size       = 0;
        graphPane.XAxis.Scale.MajorStep     = 1;
        graphPane.XAxis.Scale.FontSpec.Size = 12;
        switch (_viewType)
        {
        case ViewType.ByMonth:
            graphPane.XAxis.Scale.MajorUnit = DateUnit.Month;
            break;

        case ViewType.ByDay:
            graphPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            break;
        }

        graphPane.YAxis.MajorGrid.IsVisible = true;
        graphPane.YAxis.MajorGrid.DashOff   = 0;
        graphPane.YAxis.MajorGrid.Color     = Color.Gray;
        graphPane.YAxis.MinorGrid.IsVisible = true;
        graphPane.YAxis.MinorGrid.Color     = Color.LightGray;
        graphPane.YAxis.MinorGrid.DashOff   = 0;

        graphPane.Title.Text       = String.Format("{0} - {1}", StringDef.UseSkill, _statisticDesc);
        graphPane.YAxis.Title.Text = StringDef.UseSkill;

        AnalyseResult result = null;

        if (_useCache)
        {
            result = Session["AdvancedStatistic_UseSkillStatistic"] as AnalyseResult;
        }
        if (result == null)
        {
            result = _analyseResultList[0];
            Session["AdvancedStatistic_UseSkillStatistic"] = result;
            Session["AdvancedStatistic_CanUseCache"]       = true;
        }
        if (_chartType == ChartType.Bar)
        {
            BarItem barItem = graphPane.AddBar("使用技能", result.Times, result.Counts, Color.Blue);
            barItem.Bar.Fill = new Fill(Color.Blue);
        }
        else if (_chartType == ChartType.Line)
        {
            LineItem lineItem = graphPane.AddCurve("使用技能", result.Times, result.Counts, Color.Blue);
        }
    }
Exemplo n.º 5
0
		//public static Color SelectedSymbolColor = Color.Gray;

	#endregion

	#region Methods

		/// <summary>
		/// Place a <see cref="CurveItem" /> 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="ci">The <see cref="CurveItem" /> to be added to the list.</param>
		public void Select( MasterPane master, CurveItem ci )
		{
			//Clear the selection, but don't send the event,
			//the event will be sent in "AddToSelection" by calling "UpdateSelection"
			ClearSelection( master, false );

			AddToSelection( master, ci );
		}
Exemplo n.º 6
0
        /// <summary>
        /// Construct a <see cref="ZoomStateGroup"/> object from the scale ranges settings contained
        /// in each <see cref="GraphPane" /> for the specified <see cref="MasterPane"/>.
        /// </summary>
        /// <param name="masterPane">The <see cref="MasterPane"/> from which to obtain the scale
        /// range values.
        /// </param>
        /// <param name="type">A <see cref="ZoomState.StateType"/> enumeration that indicates whether
        /// this saved state is from a pan, zoom, or scroll.</param>
        public ZoomStateGroup( MasterPane masterPane, StateType type )
            : base(type)
        {
            _stack = new ZoomStateStack();

            foreach ( GraphPane pane in masterPane._paneList )
                _stack.Add( new ZoomState( pane, type ) );
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        private void Form2_Load(object sender, EventArgs e)
        {
            ZedGraph.MasterPane masterPane = ZDC_ColorMap.MasterPane;
            ZDC_ColorMap.IsSynchronizeXAxes = true;
            ZDC_ColorMap.IsSynchronizeYAxes = false;


            //masterPane.PaneList.Clear();
            masterPane.Add(ZDC_OpticalPlot.GraphPane);

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

            int   topMargin    = 0;
            int   leftMargin   = 25;
            int   bottomMargin = 25;
            int   rightMargin  = 25;
            int   spacingY     = 1;
            float labelGapY    = 1;
            float labelGapX    = 1;


            //masterPane[0].Chart.Rect = new RectangleF(leftMargin, topMargin, ZDC_ColorMap.Width - leftMargin - rightMargin, ZDC_ColorMap.Height / 2 - topMargin - spacingY);
            //masterPane[1].Chart.Rect = new RectangleF(leftMargin, ZDC_ColorMap.Height / 2 + spacingY, ZDC_ColorMap.Width - leftMargin - rightMargin, ZDC_ColorMap.Height / 2 - spacingY - bottomMargin);

            masterPane[0].Margin.Top    = 0.0f;
            masterPane[0].Margin.Left   = 0.0f;
            masterPane[0].Margin.Right  = 20.0f; //20
            masterPane[0].Margin.Bottom = 0.0f;

            masterPane[1].Margin.Top    = 10.0f; //10
            masterPane[1].Margin.Left   = 0.0f;
            masterPane[1].Margin.Right  = 0.0f;
            masterPane[1].Margin.Bottom = 0.0f;

            masterPane[0].XAxis.Title.IsVisible = false;
            masterPane[0].YAxis.Title.IsVisible = false;
            masterPane[0].Title.IsVisible       = false;
            masterPane[0].XAxis.Scale.IsVisible = false;
            masterPane[0].XAxis.Scale.LabelGap  = labelGapY;
            masterPane.InnerPaneGap             = 0.0f;
            masterPane[1].XAxis.Title.IsVisible = false;
            masterPane[1].YAxis.Title.IsVisible = false;
            masterPane[1].Title.IsVisible       = false;
            masterPane[1].XAxis.Scale.LabelGap  = labelGapX;
            masterPane[1].YAxis.Scale.LabelGap  = labelGapY;
            ZDC_ColorMap.AxisChange();
            ZDC_ColorMap.Invalidate();

            //masterPane.Margin.Bottom = 5;
            int        rr   = (int)masterPane[0].Chart.Rect.Width;
            RectangleF rect = masterPane.Rect;

            ZDC_OpticalPlot.GraphPane.AxisChangeEvent += GraphPane_AxisChangeEvent;
        }
Exemplo n.º 9
0
        public ZedGraphControl()
        {
            InitializeComponent();

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = MouseDown == null || MouseUp == null || MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseDown);
            base.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseUp);
            base.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ZedGraphControl_MouseMove);

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

            _resourceManager = new ResourceManager("ZedGraph.ZedGraph.ZedGraphLocale",
                                                   Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle(0, 0, this.Size.Width, this.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, "Title", "X Axis", "Y Axis" );
            GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr);

            using (Graphics g = this.CreateGraphics())
            {
                graphPane.AxisChange(g);
            }
            _masterPane.Add(graphPane);

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

            this.vScrollBar1.Minimum = 0;
            this.vScrollBar1.Maximum = 100;
            this.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();
        }
        /// <summary>
        /// Rendering method used by the print context menu items
        /// </summary>
        /// <param name="sender">The applicable <see cref="PrintDocument" />.</param>
        /// <param name="e">A <see cref="PrintPageEventArgs" /> instance providing
        /// page bounds, margins, and a Graphics instance for this printed output.
        /// </param>
        private void Graph_PrintPage(object sender, PrintPageEventArgs e)
        {
            PrintDocument pd = sender as PrintDocument;

            MasterPane mPane = this.MasterPane;

            bool[] isPenSave  = new bool[mPane.PaneList.Count + 1];
            bool[] isFontSave = new bool[mPane.PaneList.Count + 1];
            isPenSave[0]  = mPane.IsPenWidthScaled;
            isFontSave[0] = mPane.IsFontsScaled;
            for (int i = 0; i < mPane.PaneList.Count; i++)
            {
                isPenSave[i + 1]  = mPane[i].IsPenWidthScaled;
                isFontSave[i + 1] = mPane[i].IsFontsScaled;
                if (_isPrintScaleAll)
                {
                    mPane[i].IsPenWidthScaled = true;
                    mPane[i].IsFontsScaled    = true;
                }
            }

            RectangleF saveRect = mPane.Rect;
            SizeF      newSize  = mPane.Rect.Size;

            if (_isPrintFillPage && _isPrintKeepAspectRatio)
            {
                float xRatio = (float)e.MarginBounds.Width / (float)newSize.Width;
                float yRatio = (float)e.MarginBounds.Height / (float)newSize.Height;
                float ratio  = Math.Min(xRatio, yRatio);

                newSize.Width  *= ratio;
                newSize.Height *= ratio;
            }
            else if (_isPrintFillPage)
            {
                newSize = e.MarginBounds.Size;
            }

            mPane.ReSize(e.Graphics, new RectangleF(e.MarginBounds.Left,
                                                    e.MarginBounds.Top, newSize.Width, newSize.Height));
            mPane.Draw(e.Graphics);

            using (Graphics g = this.CreateGraphics())
            {
                mPane.ReSize(g, saveRect);

                //g.Dispose();
            }

            mPane.IsPenWidthScaled = isPenSave[0];
            mPane.IsFontsScaled    = isFontSave[0];
            for (int i = 0; i < mPane.PaneList.Count; i++)
            {
                mPane[i].IsPenWidthScaled = isPenSave[i + 1];
                mPane[i].IsFontsScaled    = isFontSave[i + 1];
            }
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Construct a <see cref="ZoomStateGroup"/> object from the scale ranges settings contained
        /// in each <see cref="GraphPane" /> for the specified <see cref="MasterPane"/>.
        /// </summary>
        /// <param name="masterPane">The <see cref="MasterPane"/> from which to obtain the scale
        /// range values.
        /// </param>
        /// <param name="type">A <see cref="ZoomState.StateType"/> enumeration that indicates whether
        /// this saved state is from a pan, zoom, or scroll.</param>
        public ZoomStateGroup(MasterPane masterPane, StateType type) : base(type)
        {
            _stack = new ZoomStateStack();

            foreach (GraphPane pane in masterPane._paneList)
            {
                _stack.Add(new ZoomState(pane, type));
            }
        }
Exemplo n.º 14
0
 public MainWindow()
 {
     //hp8753 = new HP8753DotNet();
     isConnected = false;
     InitializeComponent();
     connect_button.Content = "Local -> Remote";
     // Link to the XAML plot graph
     plotGraphPane = dataGraph.MasterPane;
 }
Exemplo n.º 15
0
 private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
 {
     ErrorMsg.Text = "";
     CY.GFive.DALProviders.SqlServerProvider.ScoreProvider sp = new CY.GFive.DALProviders.SqlServerProvider.ScoreProvider();
     string coursecode = Request.Form.Get("ddlCourse");
     string term = Request.Form.Get("ddlTerm");
     if (coursecode == null || coursecode == "请选择" || term == null || term == "请选择")
     {
         ErrorMsg.Text = "有参数不正确";
         ZedGraphWeb1.Visible = false;
         return;
     }
     if (string.IsNullOrEmpty(ddlYearNum.SelectedValue) || ddlYearNum.SelectedValue == "请选择")
     {
         ErrorMsg.Text = "有参数不正确";
         ZedGraphWeb1.Visible = false;
         return;
     }
     string year = ddlYearNum.SelectedItem.ToString();//year term course class teacher
     GraphPane myPane = masterPane[0];
     myPane.Title.Text = "同课程分数段统计";       //设计图表的标题
     myPane.XAxis.Title.Text = "分数段";    //X轴标题
     myPane.YAxis.Title.Text = "人数";          //Y轴标题
     string[] labels = new string[6];
     labels[0] = "60以下";
     labels[1] = "60-69";
     labels[2] = "70-79";
     labels[3] = "80-89";
     labels[4] = "90-99";
     labels[5] = "100";
     List<string> dic = sp.PrapareTeacherAndClassByCourse(year, Convert.ToInt32(term), coursecode);
     foreach (string s in dic)
     {
         string[] value = s.Split(','); //teachercode,classcode
         Random rand = new Random();
         int r = rand.Next(8);
         int gg = rand.Next(10);
         int b = rand.Next(5);
         Color temp = Color.FromArgb(r * 30, gg * 25, b * 50);
         DataSet ds = sp.GetScoreUnionByParam(year, Convert.ToInt32(term), value[1], coursecode);
         PointPairList list = new PointPairList();
         for (int i = 0; i < 6; i++)
             list.Add(0, Convert.ToInt32(ds.Tables[0].Rows[i]["人数"]));
         CY.GFive.Core.Business.StaffInfo si = CY.GFive.Core.Business.StaffInfo.GetInstance(value[0]);
         CY.GFive.Core.Business.ClassInfo ci = CY.GFive.Core.Business.ClassInfo.GetByCode(value[1]);
         BarItem myCurve = myPane.AddBar(si.Name + "-" + ci.ClassName, list, temp);
         myCurve.Bar.Fill = new Fill(temp, Color.White, temp);
     }
     myPane.XAxis.MajorTic.IsBetweenLabels = false; //柱状显示位置,true为在两个下标题值的中间,flase为两边
     myPane.XAxis.Scale.TextLabels = labels;//下标题的内容
     myPane.XAxis.Type = AxisType.Text;
     myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 90.0f);//图表外层背景填充色,由color1到color2渐变,参数3为方向
     myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 270.0f);//图表内层背景填充色,由color1到color2渐变,参数3为方向
     ZedGraphWeb1.Visible = true;
     masterPane.AxisChange(g);
 }
Exemplo n.º 16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="webObject"></param>
 /// <param name="g"></param>
 /// <param name="pane"></param>
 void _zedGraphWeb_RenderGraph(
     ZedGraph.Web.ZedGraphWeb webObject,
     System.Drawing.Graphics g,
     ZedGraph.MasterPane pane)
 {
     // TODO:
     //
     //pane[
     this.Draw(pane[0], this.DataSource);
 }
Exemplo n.º 17
0
        /// <summary></summary>
        /// <param name="mp"></param>
        /// <param name="parent"></param>
        public ExportForPublicationDialog(Form parent, MasterPane mp)
        {
            InitializeComponent();

            Owner                = parent;
            m_Mp                 = mp;
            m_DpiUpDown.Value    = 96;
            m_WidthUpDown.Value  = (decimal)(GetWidth() / 96.0f);
            m_HeightUpDown.Value = (decimal)(GetHeight() / 96.0f);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Copy the properties from this <see cref="ZoomStateGroup"/> out to the specified
 /// <see cref="MasterPane"/>.
 /// </summary>
 /// <param name="masterPane">The <see cref="MasterPane"/> to which the scale range
 /// properties should be copied.
 /// </param>
 public void ApplyState(MasterPane masterPane)
 {
     for (int i = 0; i < _stack.Count; i++)
     {
         if (masterPane._paneList.Count > i)
         {
             _stack[i].ApplyState(masterPane._paneList[i]);
         }
     }
 }
Exemplo n.º 19
0
    /// <summary>
    /// This method is where you generate your graph.
    /// </summary>
    /// <param name="masterPane">You are provided with a MasterPane instance that
    /// contains one GraphPane by default (accessible via masterPane[0]).</param>
    /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
    /// <param name="z">And a ZedGraphWeb instance because the event handler requires it</param>
    /// <param name="row">Selected row n gridview.</param>
    private static void OnRenderGraphVillagePie(ZedGraphWeb z,
        Graphics g,
        MasterPane masterPane,
        TableRow row)
    {
        // Get the GraphPane so we can work with it
        GraphPane myPane = masterPane[0];

        // Fill the pane background with a color gradient
        myPane.Fill = new Fill(Color.White, Color.White, 45.0f);
        // No fill for the chart background
        myPane.Chart.Fill.Type = FillType.None;

        myPane.Legend.IsVisible = false;
        myPane.Legend.IsShowLegendSymbols = true;
        myPane.Legend.IsHStack = false;

        // Add some pie slices
        const string srcTable = "Goods";
        DataBase dataBase = new DataBase();
        DataSet dataSet = dataBase.GetGoods(srcTable, Misc.String2Number(row.Cells[0].Text.Trim()));
        DataRow dataRow = dataSet.Tables[srcTable].Rows[0];
        int wood = Misc.String2Number(dataRow.ItemArray[0].ToString());
        int clay = Misc.String2Number(dataRow.ItemArray[1].ToString());
        int iron = Misc.String2Number(dataRow.ItemArray[2].ToString());
        int crop = Misc.String2Number(dataRow.ItemArray[3].ToString());

        PieItem segmentWood = myPane.AddPieSlice(wood, Color.Green, Color.Green, 45f, 0, wood.ToString());
        PieItem segmentClay = myPane.AddPieSlice(clay, Color.OrangeRed, Color.OrangeRed, 45f, .0, clay.ToString());
        PieItem segmentIron = myPane.AddPieSlice(iron, Color.Blue, Color.Blue, 45f, 0, iron.ToString());
        PieItem segmentCrop = myPane.AddPieSlice(crop, Color.Yellow, Color.Yellow, 45f, 0.2, crop.ToString());

        segmentWood.LabelDetail.FontSpec.Size = 20f;
        segmentClay.LabelDetail.FontSpec.Size = 20f;
        segmentIron.LabelDetail.FontSpec.Size = 20f;
        segmentCrop.LabelDetail.FontSpec.Size = 20f;

        // Sum up the pie values
        CurveList curves = myPane.CurveList;
        double total = 0;
        for (int x = 0; x < curves.Count; x++)
        {
            total += ((PieItem) curves[x]).Value;
        }

        // Set the GraphPane title
        //myPane.Title.Text = String.Format("Total Goods : {0}\nWood : {1}\nClay : {2}\nIron : {3}\nCrop : {4}", total,
        //                                  wood, clay, iron, crop);
        myPane.Title.Text = String.Format("Total Goods : {0}", total);
        myPane.Title.FontSpec.IsItalic = true;
        myPane.Title.FontSpec.Size = 24f;
        myPane.Title.FontSpec.Family = "Times New Roman";

        masterPane.AxisChange(g);
    }
Exemplo n.º 20
0
    void ExpStatistic(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        bool      showSymbol = true;
        GraphPane graphPane  = masterPane[0];

        graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

        graphPane.Legend.Fill.IsVisible          = false;
        graphPane.Legend.Border.IsVisible        = false;
        graphPane.Legend.FontSpec.Fill.IsVisible = false;

        graphPane.XAxis.Title.Text          = StringDef.Date;
        graphPane.XAxis.MajorGrid.Color     = WebConfig.GraphXAxisGridColor;
        graphPane.XAxis.Type                = AxisType.DateAsOrdinal;
        graphPane.XAxis.MinorTic.Size       = 0;
        graphPane.XAxis.Scale.MajorStep     = 1;
        graphPane.XAxis.Scale.FontSpec.Size = 12;
        switch (_viewType)
        {
        case ViewType.ByMonth:
            graphPane.XAxis.Scale.MajorUnit = DateUnit.Month;
            break;

        case ViewType.ByDay:
            graphPane.XAxis.Scale.MajorUnit = DateUnit.Day;
            break;
        }

        graphPane.YAxis.MajorGrid.IsVisible = true;
        graphPane.YAxis.MajorGrid.DashOff   = 0;
        graphPane.YAxis.MajorGrid.Color     = Color.Gray;
        graphPane.YAxis.MinorGrid.IsVisible = true;
        graphPane.YAxis.MinorGrid.Color     = Color.LightGray;
        graphPane.YAxis.MinorGrid.DashOff   = 0;

        graphPane.Title.Text       = String.Format("{0} - {1}", StringDef.ExpStatistic, _statisticDesc);
        graphPane.YAxis.Title.Text = StringDef.Exp;

        if (_analyseResultList != null && _analyseResultList.Count != 0)
        {
            double[] timeArray = _analyseResultList[0].Times;
            double[] expArray  = _analyseResultList[0].Values;

            if (_chartType == ChartType.Bar)
            {
                BarItem barItemMoney = graphPane.AddBar(StringDef.AddExp, timeArray, expArray, Color.Black);
                barItemMoney.Bar.Fill = new Fill(Color.Blue);
            }
            else if (_chartType == ChartType.Line)
            {
                graphPane.AddCurve(StringDef.AddExp, timeArray, expArray, Color.Red, (showSymbol ? WebConfig.GraphSymbols[0] : SymbolType.None));
            }
        }
    }
Exemplo n.º 21
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The <see cref="MasterPane"/> object from which to copy</param>
        public MasterPane(MasterPane rhs) : base(rhs)
        {
            this.paneLayout              = rhs.paneLayout;
            this.innerPaneGap            = rhs.innerPaneGap;
            this.rows                    = rhs.rows;
            this.columns                 = rhs.rows;
            this.isColumnSpecified       = rhs.isColumnSpecified;
            this.countList               = rhs.countList;
            this.hasUniformLegendEntries = rhs.hasUniformLegendEntries;

            this.paneList = (PaneList)rhs.paneList.Clone();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Add a list of <see cref="CurveItem" />'s 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="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
        public void AddToSelection(MasterPane master, CurveList ciList)
        {
            foreach (CurveItem ci in ciList)
            {
                if (this.Contains(ci) == false)
                {
                    this.Add(ci);
                }
            }

            UpdateSelection(master);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Determine if the state contained in this <see cref="ZoomStateGroup"/> object is different from
        /// the state of the specified <see cref="MasterPane"/>.
        /// </summary>
        /// <param name="masterPane">The <see cref="MasterPane"/> object with which to compare states.</param>
        /// <returns>true if the states are different, false otherwise</returns>
        public bool IsChanged(MasterPane masterPane)
        {
            for (int i = 0; i < _stack.Count; i++)
            {
                if (masterPane._paneList.Count > i && _stack[i].IsChanged(masterPane._paneList[i]))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Add a list of <see cref="CurveItem" />'s 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="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
        public void AddToSelection(MasterPane master, CurveList ciList)
        {
            foreach (var ci in ciList)
            {
                if (Contains(ci) == false)
                {
                    Add(ci);
                }
            }

            UpdateSelection(master);
        }
Exemplo n.º 25
0
        /// <summary>
        /// This method is where you generate your graph.
        /// </summary>
        /// <param name="masterPane">You are provided with a MasterPane instance that
        /// contains one GraphPane by default (accessible via masterPane[0]).</param>
        /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
        private void OnRenderGraph1(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            // Set the title and axis labels
            myPane.Title.Text       = "Cat Stats";
            myPane.YAxis.Title.Text = "Big Cats";
            myPane.XAxis.Title.Text = "Population";

            // Make up some data points
            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard" };
            double[] x      = { 100, 115, 75, 22, 98, 40 };
            double[] x2     = { 120, 175, 95, 57, 113, 110 };
            double[] x3     = { 204, 192, 119, 80, 134, 156 };

            // Generate a red bar with "Curve 1" in the legend
            BarItem myCurve = myPane.AddBar("Here", x, null, Color.Red);

            // Fill the bar with a red-white-red color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red, 90f);

            // Generate a blue bar with "Curve 2" in the legend
            myCurve = myPane.AddBar("There", x2, null, Color.Blue);
            // Fill the bar with a Blue-white-Blue color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue, 90f);

            // Generate a green bar with "Curve 3" in the legend
            myCurve = myPane.AddBar("Elsewhere", x3, null, Color.Green);
            // Fill the bar with a Green-white-Green color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Green, Color.White, Color.Green, 90f);

            // Draw the Y tics between the labels instead of at the labels
            myPane.YAxis.MajorTic.IsBetweenLabels = true;

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

            // Set the bar type to stack, which stacks the bars by automatically accumulating the values
            myPane.BarSettings.Type = BarType.Stack;

            // Make the bars horizontal by setting the BarBase to "Y"
            myPane.BarSettings.Base = BarBase.Y;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 166), 45.0F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 26
0
        private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            ErrorMsg.Text = "";
            CY.GFive.DALProviders.SqlServerProvider.ScoreProvider sp = new CY.GFive.DALProviders.SqlServerProvider.ScoreProvider();
            if (string.IsNullOrEmpty(Request.Form.Get("Term")) || string.IsNullOrEmpty(Request.Form.Get("Course")))
            {
                ErrorMsg.Text = "参数错误";
                ZedGraphWeb1.Visible = false;
                return;
            }
            int term = Convert.ToInt32(Request.Form.Get("Term"));
            string course = Request.Form.Get("Course");
            string year = ddlYearNum.SelectedItem.ToString();
            string teacher = ddlTeacher.SelectedValue;
            List<string> classlist = sp.GetClassList(year, term, teacher, course);
            if (classlist.Count < 1)
                return;
            GraphPane myPane = masterPane[0];

            myPane.Title.Text = "分数段统计";       //设计图表的标题
            myPane.XAxis.Title.Text = "分数段";    //X轴标题
            myPane.YAxis.Title.Text = "人数";          //Y轴标题
            string[] labels = new string[6];
            labels[0] = "60以下";
            labels[1] = "60-69";
            labels[2] = "70-79";
            labels[3] = "80-89";
            labels[4] = "90-99";
            labels[5] = "100";

            foreach (string classcode in classlist)
            {
                Random rand = new Random();
                int n = rand.Next(4);
                Color temp = Color.FromArgb(n * 10, n * 60, n * 50);
                DataSet ds = sp.GetScoreUnionByParam(year, term, classcode, course);
                CY.GFive.Core.Business.ClassInfo citemp = CY.GFive.Core.Business.ClassInfo.GetByCode(classcode);
                PointPairList list = new PointPairList();
                for (int i = 0; i < 6; i++)
                    list.Add(0, Convert.ToInt32(ds.Tables[0].Rows[i]["人数"]));
                BarItem myCurve = myPane.AddBar(citemp.ClassName, list, temp);
                myCurve.Bar.Fill = new Fill(temp, Color.White, temp);
            }

            myPane.XAxis.MajorTic.IsBetweenLabels = false; //柱状显示位置,true为在两个下标题值的中间,flase为两边
            myPane.XAxis.Scale.TextLabels = labels;//下标题的内容
            myPane.XAxis.Type = AxisType.Text;
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 90.0f);//图表外层背景填充色,由color1到color2渐变,参数3为方向
            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 270.0f);//图表内层背景填充色,由color1到color2渐变,参数3为方向
            ZedGraphWeb1.Visible = true;
            masterPane.AxisChange(g);
        }
Exemplo n.º 27
0
 public static GraphData GetGraphData(MasterPane masterPane)
 {
     var paneDatas = new List<GraphPaneData>();
     foreach (var graphPane in masterPane.PaneList)
     {
         var graphPaneData = GraphPaneData.GetGraphPaneData(graphPane);
         if (graphPaneData != null)
         {
             paneDatas.Add(graphPaneData);
         }
     }
     return new GraphData(null, paneDatas);
 }
Exemplo n.º 28
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 (this)
            {
                if (disposing)
                {
                    components?.Dispose();
                }
                base.Dispose(disposing);

                _masterPane = null;
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Here is a completely independent second graph.  In InitializeComponent() above,
        /// ZedGraphWeb1 calls OnRenderGraph1, and ZedGraphWeb2 calls OnRenderGraph2.
        /// </summary>
        private void OnRenderGraph2(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            // Set the titles and axis labels
            myPane.Title.Text       = "My Test Date Graph";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points from the Sine function
            PointPairList list  = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                double x  = new XDate(1995, i + 1, 1);
                double y  = Math.Sin((double)i * Math.PI / 15.0);
                double y2 = 2 * y;

                list.Add(x, y);
                list2.Add(x, y2);
            }

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve2 = myPane.AddCurve("My Curve 2", list, Color.Blue,
                                                SymbolType.Circle);

            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Red, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Generate a red curve with diamond symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve("My Curve",
                                               list2, Color.MediumVioletRed, SymbolType.Diamond);

            // Fill the area under the curve with a white-green gradient
            myCurve.Line.Fill = new Fill(Color.White, Color.Green);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            myPane.XAxis.Type      = AxisType.Date;
            myPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Mark the <see cref="CurveItem" />'s that are included in the selection list
        /// by setting the <see cref="CurveItem.IsSelected" /> property to true.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that "owns" the selection list.</param>
        public void UpdateSelection(MasterPane master)
        {
            if (Count <= 0)
            {
                ClearSelection(master);
                return;
            }

            foreach (GraphPane pane in master.PaneList)
            {
                foreach (CurveItem ci in pane.CurveList)
                {
                    //Make it Inactive
                    ci.IsSelected = false;
                }
            }
            foreach (CurveItem ci in  this)
            {
                //Make Active
                ci.IsSelected = true;

                //If it is a line / scatterplot, the selected Curve may be occluded by an unselected Curve
                //So, move it to the top of the ZOrder by removing it, and re-adding it.

                //Why only do this for Lines? ...Bar and Pie Curves are less likely to overlap,
                //and adding and removing Pie elements changes thier display order
                if (ci.IsLine)
                {
                    //I don't know how to get a Pane, from a CurveItem, so I can only do it
                    //if there is one and only one Pane, based on the assumption that the
                    //Curve's Pane is MasterPane[0]

                    //If there is only one Pane
                    if (master.PaneList.Count == 1)
                    {
                        GraphPane pane = master.PaneList[0];
                        pane.CurveList.Remove(ci);
                        pane.CurveList.Insert(0, ci);
                    }
                }
            }

            //Send Selection Changed Event
            if (SelectionChangedEvent != null)
            {
                SelectionChangedEvent(this, new EventArgs());
            }
        }
Exemplo n.º 31
0
    protected void ZedGraphWeb1_RenderGraph(System.Drawing.Graphics g, ZedGraph.MasterPane mPane)
    {
        int           nDays = 0;
        int           nRows = 0;
        GraphPane     pane  = mPane[0];
        PointPairList pt    = new PointPairList();
        double        nx;
        double        ny;

        string days   = (string)Page.Request.Params["days"];
        string ticker = (string)Page.Request.Params["ticker"];

        if (ticker != null)
        {
            ticker = ticker.Trim();
            DataTier theDataTier = new DataTier();
            if (days == null)
            {
                nDays = 0;
            }
            else
            {
                nDays = Convert.ToInt32(days);
            }

            DataTable dtTable = theDataTier.GetFullPriceHistory(ticker, nDays);
            nRows = dtTable.Rows.Count;


            for (int i = 1; i < nRows; i++)
            {
                ny = Convert.ToDouble(dtTable.Rows[i].ItemArray[1]);
                XDate tmpDate = new XDate(Convert.ToDateTime(dtTable.Rows[i].ItemArray[0]));
                nx = (double)tmpDate;
                pt.Add(nx, ny);
            }
            pane.XAxis.Type        = AxisType.Date;
            pane.XAxis.GridDashOff = 0;
            LineItem priceCurve = pane.AddCurve("Closing Price", pt, Color.SlateBlue, SymbolType.None);
            priceCurve.Line.Width = 2.0F;
            pane.AxisFill         = new Fill(Color.White, Color.AntiqueWhite);
            pane.XAxis.MinGrace   = 0;
            pane.XAxis.MaxGrace   = 0;
            pane.YAxis.MinGrace   = 0;
            pane.YAxis.MaxGrace   = 0;
            pane.AxisChange(g);
        }
    }
Exemplo n.º 32
0
        /// <summary>
        /// The Copy Constructor - Make a deep-copy clone of this class instance.
        /// </summary>
        /// <param name="rhs">The <see cref="MasterPane"/> object from which to copy</param>
        public MasterPane(MasterPane rhs) : base(rhs)
        {
            // copy all the value types
            //_paneLayoutMgr = rhs._paneLayoutMgr.Clone();
            _innerPaneGap           = rhs._innerPaneGap;
            _isUniformLegendEntries = rhs._isUniformLegendEntries;
            _isCommonScaleFactor    = rhs._isCommonScaleFactor;

            // Then, fill in all the reference types with deep copies
            _paneList = rhs._paneList.Clone();

            _paneLayout        = rhs._paneLayout;
            _countList         = rhs._countList;
            _isColumnSpecified = rhs._isColumnSpecified;
            _prop = rhs._prop;
        }
Exemplo n.º 33
0
        /// <summary>
        /// Clear the selection list and optionally trigger a <see cref="SelectionChangedEvent" />.
        /// </summary>
        /// <param name="master">The <see cref="MasterPane" /> that "owns" the selection list.</param>
        /// <param name="sendEvent">true to trigger a <see cref="SelectionChangedEvent" />,
        /// false otherwise.</param>
        public void ClearSelection(MasterPane master, bool sendEvent)
        {
            this.Clear();

            foreach (var pane in master.PaneList.Where(p => p is GraphPane).Cast <GraphPane>())
            {
                foreach (CurveItem ci in pane.CurveList)
                {
                    ci.IsSelected = false;
                }
            }

            if (sendEvent)
            {
                SelectionChangedEvent?.Invoke(this, new EventArgs());
            }
        }
Exemplo n.º 34
0
        private void DrawGraph()
        {
            // —оздаем экземпл¤р класса MasterPane, который представл¤ет собой область,
            // на которйо "лежат" все графики (экземпл¤ры класса GraphPane)
            ZedGraph.MasterPane masterPane = zedGraph.MasterPane;

            // ѕо умолчанию в MasterPane содержитс¤ один экземпл¤р класса GraphPane
            // (который можно получить из свойства zedGraph.GraphPane)
            // ќчистим этот список, так как потом мы будем создавать графики вручную
            masterPane.PaneList.Clear();

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

                // «аполнение графика данными не изменилось,
                // поэтому вынесем заполнение точек в отдельный метод DrawSingleGraph()
                DrawSingleGraph(pane);

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

            // Ѕудем размещать добавленные графики в MasterPane
            using (Graphics g = CreateGraphics())
            {
                // «акомментарены разные варианты (не все) размещени¤ графиков.

                // √рафики будут размещены в один столбец друг под другом
                //masterPane.SetLayout (g, PaneLayout.SingleColumn);

                //√рафики будут размещены в одну строку друг за другом
                //masterPane.SetLayout (g, PaneLayout.SingleRow);

                // √рафики будут размещены в две строки,
                // в первой будет один столбец, а во второй - две
                masterPane.SetLayout(g, PaneLayout.ExplicitCol12);
            }

            // ќбновим оси и перерисуем график
            zedGraph.AxisChange();
            zedGraph.Invalidate();
        }
Exemplo n.º 35
0
        //Отображение нескольких графиков
        public void displayGraph(Dictionary <PointPairList, String> listOfLists)
        {
            ZedGraph.MasterPane masterPane = zedGraph.MasterPane;
            masterPane.PaneList.Clear();

            foreach (KeyValuePair <PointPairList, String> points in listOfLists)
            {
                GraphPane pane = createPane(points.Key, points.Value);
                masterPane.Add(pane);
            }

            using (Graphics g = CreateGraphics())
            {
                masterPane.SetLayout(g, PaneLayout.ForceSquare);
            }

            zedGraph.AxisChange();
            zedGraph.Invalidate();
        }
Exemplo n.º 36
0
        /// <summary>
        /// This method is where you generate your graph.
        /// </summary>
        /// <param name="masterPane">You are provided with a MasterPane instance that
        /// contains one GraphPane by default (accessible via masterPane[0]).</param>
        /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
        private void OnRenderGraph(System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            myPane.Title.Text       = "Sales By Region";
            myPane.XAxis.Title.Text = "Region";
            myPane.YAxis.Title.Text = "Gross Sales, $Thousands";

            PointPairList list  = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();
            Random        rand  = new Random();

            for (double x = 0; x < 5; x += 1.0)
            {
                double y  = rand.NextDouble() * 1000;
                double y2 = rand.NextDouble() * 1000;
                double y3 = rand.NextDouble() * 1000;
                list.Add(x, y);
                list2.Add(x, y2);
                list3.Add(x, y3);
            }

            BarItem myCurve = myPane.AddBar("Blue Team", list, Color.Blue);

            myCurve.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue);
            BarItem myCurve2 = myPane.AddBar("Red Team", list2, Color.Red);

            myCurve2.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);
            BarItem myCurve3 = myPane.AddBar("Green Team", list3, Color.Green);

            myCurve3.Bar.Fill = new Fill(Color.Green, Color.White, Color.Green);

            myPane.XAxis.MajorTic.IsBetweenLabels = true;
            string[] labels = { "Africa", "Americas", "Asia", "Europe", "Australia" };
            myPane.XAxis.Scale.TextLabels = labels;
            myPane.XAxis.Type             = AxisType.Text;
            myPane.Fill       = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);

            masterPane.AxisChange(g);
        }
Exemplo n.º 37
0
        private void DrawGraph()
        {
            // Создаем экземпляр класса MasterPane, который представляет собой область,
            // на которйо "лежат" все графики (экземпляры класса GraphPane)
            ZedGraph.MasterPane masterPane = zedGraph.MasterPane;

            // По умолчанию в MasterPane содержится один экземпляр класса GraphPane
            // (который можно получить из свойства zedGraph.GraphPane)
            // Очистим этот список, так как потом мы будем создавать графики вручную
            masterPane.PaneList.Clear();

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

                // Заполнение графика данными не изменилось,
                // поэтому вынесем заполнение точек в отдельный метод DrawSingleGraph()
                DrawSingleGraph(pane);

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

            // Будем размещать добавленные графики в MasterPane
            using (Graphics g = CreateGraphics())
            {
                // Графики будут размещены в три строки.
                // В первой будет 4 столбца,
                // Во второй - 2
                // В третей - 3
                // Если бы второй аргумент был равен false, то массив из третьего аргумента
                // задавал бы не количество столбцов в каждой строке,
                // а количество строк в каждом столбце
                masterPane.SetLayout(g, true, new int[] { 4, 2, 3 });
            }

            // Обновим оси и перерисуем график
            zedGraph.AxisChange();
            zedGraph.Invalidate();
        }
Exemplo n.º 38
0
        public ZedGraphProxy(ZedGraphControl chart)
        {
            Chart = chart;

            master = chart.MasterPane;
            master.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);
            master.PaneList.Clear();

            master.Title.IsVisible = true;
            //master.Title.Text = "";

            master.Margin.All = 10;
            master.InnerPaneGap = 0;

            myPane = new GraphPane(new Rectangle(25, 25, chart.Width - 50, chart.Height - 50), "", "", "");

               // myPane.Title.Text = "";
            myPane.XAxis.Title.Text = "Time, s";
            myPane.Y2Axis.IsVisible = true;
            myPane.Fill.IsVisible = false;
            myPane.Chart.Fill = new Fill(Color.White, Color.LightYellow, 45.0F);
            myPane.Margin.All = 0;
            myPane.Margin.Top = 20;

            master.Add(myPane);

            y1List = new PointPairList();
            y2List = new PointPairList();

            var myCurve = myPane.AddCurve("", y1List, Color.Red, SymbolType.Circle);
            myCurve.IsVisible = false;
            myCurve = myPane.AddCurve("", y2List, Color.Green, SymbolType.Circle);
            myCurve.IsVisible = false;
            myCurve.IsY2Axis = true;
            chart.IsSynchronizeYAxes = true;
            chart.Invalidate();
        }
Exemplo n.º 39
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 ( this )
            {
                if ( disposing )
                {
                    if ( components != null )
                        components.Dispose();
                }
                base.Dispose( disposing );

                _masterPane = null;
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public ZedGraphControl()
        {
            InitializeComponent();

            // These commands do nothing, but they get rid of the compiler warnings for
            // unused events
            bool b = MouseDown == null || MouseUp == null || MouseMove == null;

            // Link in these events from the base class, since we disable them from this class.
            base.MouseDown += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseDown );
            base.MouseUp += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseUp );
            base.MouseMove += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseMove );

            //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel );

            // Use double-buffering for flicker-free updating:
            SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint
                | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true );
            //isTransparentBackground = false;
            //SetStyle( ControlStyles.Opaque, false );
            SetStyle( ControlStyles.SupportsTransparentBackColor, true );
            //this.BackColor = Color.Transparent;

            _resourceManager = new ResourceManager( "VixenModules.App.Curves.ZedGraph.ZedGraphLocale",
                Assembly.GetExecutingAssembly());

            Rectangle rect = new Rectangle( 0, 0, this.Size.Width, this.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, "Title", "X Axis", "Y Axis" );
            GraphPane graphPane = new GraphPane( rect, titleStr, xStr, yStr );
            using ( Graphics g = this.CreateGraphics() )
            {
                graphPane.AxisChange( g );
                //g.Dispose();
            }
            _masterPane.Add( graphPane );

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

            this.vScrollBar1.Minimum = 0;
            this.vScrollBar1.Maximum = 100;
            this.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();
        }
Exemplo n.º 41
0
	protected void ZedGraphWebExpStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
	{
		switch (ListBoxViewContent.SelectedIndex)
		{
			case 0:
				ExpByPlayTime(g, masterPane);				
				break;
			case 1:
				ExpByDate(g, masterPane);
				break;
		}
	}
Exemplo n.º 42
0
		/// <summary>
		/// Mark the <see cref="CurveItem" />'s that are included in the selection list
		/// by setting the <see cref="CurveItem.IsSelected" /> property to true.
		/// </summary>
		/// <param name="master">The <see cref="MasterPane" /> that "owns" the selection list.</param>
		public void UpdateSelection( MasterPane master )
		{
			if ( Count <= 0 )
			{
				ClearSelection( master );
				return;
			}

			foreach ( GraphPane pane in master.PaneList )
			{
				foreach ( CurveItem ci in pane.CurveList )
				{
					//Make it Inactive
					ci.IsSelected = false;
				}

			}
			foreach ( CurveItem ci in  this )
			{
				//Make Active
				ci.IsSelected = true;

				//If it is a line / scatterplot, the selected Curve may be occluded by an unselected Curve
				//So, move it to the top of the ZOrder by removing it, and re-adding it.

				//Why only do this for Lines? ...Bar and Pie Curves are less likely to overlap, 
				//and adding and removing Pie elements changes thier display order
				if ( ci.IsLine )
				{
					//I don't know how to get a Pane, from a CurveItem, so I can only do it 
					//if there is one and only one Pane, based on the assumption that the 
					//Curve's Pane is MasterPane[0]

					//If there is only one Pane
					if ( master.PaneList.Count == 1 )
					{
						GraphPane pane = master.PaneList[0];
						pane.CurveList.Remove( ci );
						pane.CurveList.Insert( 0, ci );
					}

				}
			}

			//Send Selection Changed Event
			if ( SelectionChangedEvent != null )
				SelectionChangedEvent( this, new EventArgs() );

		}
Exemplo n.º 43
0
    protected void ZedGraphWebExpStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
    {
        Color statColor = Color.Blue;
        string statTitle = string.Empty;
        string statXAxisTitle = string.Empty;
        switch (ListBoxViewContent.SelectedValue)
        {
            case "NpcBeKilled":
                statColor = Color.Orange;
                statTitle = StringDef.NpcBeKilledStatistic;
                statXAxisTitle = StringDef.NpcBeKilledCount;
                break;
            case "NpcKill":
                statColor = Color.Red;
                statTitle = StringDef.NpcKillPlayerStatistic;
                statXAxisTitle = StringDef.NpcKillPlayerCount;
                break;
        }

        GraphPane graphPane = masterPane[0];
        graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);
        graphPane.Title.Text = statTitle;
        graphPane.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.Title.FontSpec.Size = 10;
        graphPane.Legend.IsVisible = false;
        graphPane.BarSettings.Base = BarBase.Y;

        graphPane.XAxis.Title.Text = statXAxisTitle;
        graphPane.XAxis.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.XAxis.Title.FontSpec.Size = 6.2f;
        graphPane.XAxis.MajorGrid.IsVisible = true;
        graphPane.XAxis.MajorGrid.DashOff = 0;
        graphPane.XAxis.MajorGrid.Color = Color.Gray;
        graphPane.XAxis.MinorGrid.IsVisible = true;
        graphPane.XAxis.MinorGrid.Color = Color.LightGray;
        graphPane.XAxis.MinorGrid.DashOff = 0;
        graphPane.XAxis.Scale.FontSpec.Size = 5.6f;
        graphPane.XAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;

        //graphPane.YAxis.Title.Text = StringDef.NpcTemplate;
        graphPane.YAxis.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.YAxis.MajorTic.IsBetweenLabels = true;
        graphPane.YAxis.Scale.IsPreventLabelOverlap = false;
        graphPane.YAxis.Scale.AlignH = AlignH.Center;
        graphPane.YAxis.Scale.FontSpec.Size = 5.6f;
        graphPane.YAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.YAxis.Scale.IsReverse = true;
        graphPane.YAxis.Type = AxisType.Text;

        double[] countList = new double[_recordList.Count];
        string[] templateList = new string[_recordList.Count];
        for (int i = 0; i < _recordList.Count; i++)
        {
            NpcStatisticInfo info = _recordList[i];
            countList[i] = info.Count;
            FS2NpcData npcData = FS2GameDataManager.TheInstance.GetNpcData(int.Parse(info.TemaplteId));
            if (npcData != null)
            {
                templateList[i] = npcData.ToString();
            }
            else
            {
                templateList[i] = info.TemaplteId;
            }
        }
        BarItem barItem = graphPane.AddBar(StringDef.NpcBeKilledCount, countList, null, Color.Blue);
        barItem.Bar.Fill = new Fill(statColor);
        graphPane.YAxis.Scale.TextLabels = templateList;
        masterPane.AxisChange();
        BarItem.CreateBarLabels(graphPane, false, string.Empty, StringDef.DefaultFontFamily, 5.6f, TextObj.Default.FontColor, false, false, false);
    }
Exemplo n.º 44
0
		/// <summary>
		/// Add a list of <see cref="CurveItem" />'s 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="ciList">The list of <see cref="CurveItem" />'s to be added to the list.</param>
		public void AddToSelection( MasterPane master, CurveList ciList )
		{
			foreach ( CurveItem ci in ciList )
			{
				if ( this.Contains( ci ) == false )
					this.Add( ci );
			}

			UpdateSelection( master );
		}
Exemplo n.º 45
0
        /// <summary>
        /// stub method that passes control for the render event to the the registered
        /// event handler.
        /// </summary>
        protected virtual void OnDrawPane( Graphics 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 )
                {
                    ZedGraphWeb.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 );
            }
        }
Exemplo n.º 46
0
 /// <summary>
 /// Copy the properties from this <see cref="ZoomStateGroup"/> out to the specified
 /// <see cref="MasterPane"/>.
 /// </summary>
 /// <param name="masterPane">The <see cref="MasterPane"/> to which the scale range
 /// properties should be copied.
 /// </param>
 public void ApplyState( MasterPane masterPane )
 {
     for ( int i = 0; i < _stack.Count; i++ )
     {
         if ( masterPane._paneList.Count > i )
             _stack[i].ApplyState( masterPane._paneList[i] );
     }
 }
Exemplo n.º 47
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 );
		}
Exemplo n.º 48
0
        /// <summary>
        /// Determine if the state contained in this <see cref="ZoomStateGroup"/> object is different from
        /// the state of the specified <see cref="MasterPane"/>.
        /// </summary>
        /// <param name="masterPane">The <see cref="MasterPane"/> object with which to compare states.</param>
        /// <returns>true if the states are different, false otherwise</returns>
        public bool IsChanged( MasterPane masterPane )
        {
            for ( int i = 0; i < _stack.Count; i++ )
            {
                if ( masterPane._paneList.Count > i && _stack[i].IsChanged( masterPane._paneList[i] ) )
                    return true;
            }

            return false;
        }
Exemplo n.º 49
0
        private void OnRenderUserChart(ZedGraphWeb z, Graphics g, MasterPane masterPane)
        {
            GraphPane graphPane = masterPane[0];
            graphPane.Title.Text = Resource.SalesByMonthChartLabel;
            graphPane.XAxis.Title.Text = Resource.SalesByMonthChartMonthLabel;
            graphPane.YAxis.Title.Text = Resource.SalesByMonthChartSalesLabel;

            PointPairList pointList = new PointPairList();

            if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthBySite(siteSettings.SiteGuid); }

            foreach (DataRow row in salesByMonthData.Rows)
            {
                double x = new XDate(Convert.ToInt32(row["Y"]), Convert.ToInt32(row["M"]), 1);
                double y = Convert.ToDouble(row["Sales"]);
                pointList.Add(x, y);
            }

            LineItem myCurve2 = graphPane.AddCurve(Resource.SalesByMonthChartLabel, pointList, Color.Blue, SymbolType.Circle);
            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Green, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            graphPane.XAxis.Type = AxisType.Date;
            graphPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 50
0
        /// <summary>
        /// Modify the <see cref="GraphPane" /> <see cref="PaneBase.Rect" /> sizes of each
        /// <see cref="GraphPane" /> such that they fit within the <see cref="MasterPane" />
        /// in a pre-configured layout.
        /// </summary>
        /// <remarks>The <see cref="SetLayout(PaneLayout)" /> method (and overloads) is
        /// used for setting the layout configuration.</remarks>
        /// <param name="g">A <see cref="Graphics" /> instance to be used for font sizing,
        /// etc. in determining the layout configuration.</param>
        /// <param name="master">The <see cref="MasterPane" /> instance which is to
        /// be resized.</param>
        /// <seealso cref="SetLayout(PaneLayout)" />
        /// <seealso cref="SetLayout(int,int)" />
        /// <seealso cref="SetLayout(bool,int[])" />
        /// <seealso cref="SetLayout(bool,int[],float[])" />
        public void DoLayout( Graphics g, MasterPane master )
        {
            if ( this._countList != null )
                DoLayout( g, master, this._isColumnSpecified, this._countList, this._prop );
            else
            {
                int count = master.PaneList.Count;
                if ( count == 0 )
                    return;

                int rows,
                        cols,
                        root = (int)( Math.Sqrt( (double)count ) + 0.9999999 );

                //float[] widthList = new float[5];

                switch ( _paneLayout )
                {
                    case PaneLayout.ForceSquare:
                        rows = root;
                        cols = root;
                        DoLayout( g, master, rows, cols );
                        break;
                    case PaneLayout.SingleColumn:
                        rows = count;
                        cols = 1;
                        DoLayout( g, master, rows, cols );
                        break;
                    case PaneLayout.SingleRow:
                        rows = 1;
                        cols = count;
                        DoLayout( g, master, rows, cols );
                        break;
                    default:
                    case PaneLayout.SquareColPreferred:
                        rows = root;
                        cols = root;
                        if ( count <= root * ( root - 1 ) )
                            rows--;
                        DoLayout( g, master, rows, cols );
                        break;
                    case PaneLayout.SquareRowPreferred:
                        rows = root;
                        cols = root;
                        if ( count <= root * ( root - 1 ) )
                            cols--;
                        DoLayout( g, master, rows, cols );
                        break;
                    case PaneLayout.ExplicitCol12:
                        DoLayout( g, master, true, new int[2] { 1, 2 }, null );
                        break;
                    case PaneLayout.ExplicitCol21:
                        DoLayout( g, master, true, new int[2] { 2, 1 }, null );
                        break;
                    case PaneLayout.ExplicitCol23:
                        DoLayout( g, master, true, new int[2] { 2, 3 }, null );
                        break;
                    case PaneLayout.ExplicitCol32:
                        DoLayout( g, master, true, new int[2] { 3, 2 }, null );
                        break;
                    case PaneLayout.ExplicitRow12:
                        DoLayout( g, master, false, new int[2] { 1, 2 }, null );
                        break;
                    case PaneLayout.ExplicitRow21:
                        DoLayout( g, master, false, new int[2] { 2, 1 }, null );
                        break;
                    case PaneLayout.ExplicitRow23:
                        DoLayout( g, master, false, new int[2] { 2, 3 }, null );
                        break;
                    case PaneLayout.ExplicitRow32:
                        DoLayout( g, master, false, new int[2] { 3, 2 }, null );
                        break;
                }
            }
        }
Exemplo n.º 51
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;
            Bitmap 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;
                                    }
                                    else
                                    {
                                        // 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 );
                    }
                }

            }
        }
Exemplo n.º 52
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 );

		}
Exemplo n.º 53
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( System.IO.Stream OutputStream, ImageFormat Format,
				bool bShowTransparency )
        {
            RectangleF rect = new RectangleF( 0, 0, this.Width, this.Height );
            MasterPane 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
            Bitmap image = new Bitmap( this.Width, this.Height );
            using ( Graphics g = 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 ( this.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 = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( resourceName );

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

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

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

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

            return mp;
        }
Exemplo n.º 54
0
		/// <summary>
		/// Clear the selection list and trigger a <see cref="SelectionChangedEvent" />.
		/// </summary>
		/// <param name="master">The <see cref="MasterPane" /> that "owns" the selection list.</param>
		public void ClearSelection( MasterPane master )
		{
			ClearSelection( master, true );
		}
Exemplo n.º 55
0
		public void MasterPaneInit()
		{
			masterPane = graph.MasterPane;
			masterPane.PaneList.Clear();
			masterPane.Title.Text = "Spectrum Analyser";
			masterPane.Title.IsVisible = false;
			masterPane.Title.FontSpec.Size = 14f;
			masterPane.Title.FontSpec.FontColor = Color.Gray;
			masterPane.Title.FontSpec.IsBold = true;
			masterPane.Fill = new Fill(Color.Black);
			masterPane.Margin.All = 0f;
			masterPane.InnerPaneGap = 0f;
			masterPane.Legend.IsVisible = false;
			masterPane.Legend.Position = LegendPos.TopCenter;
			masterPane.Legend.Fill = new Fill(Color.Black);
			masterPane.Legend.FontSpec.FontColor = Color.Gray;
			masterPane.Legend.FontSpec.Size = 12f;
			masterPane.Legend.Border.Color = Color.Gray;
			masterPane.BaseDimension = 10f;
		}
Exemplo n.º 56
0
		/// <summary>
		/// Clear the selection list and optionally trigger a <see cref="SelectionChangedEvent" />.
		/// </summary>
		/// <param name="master">The <see cref="MasterPane" /> that "owns" the selection list.</param>
		/// <param name="sendEvent">true to trigger a <see cref="SelectionChangedEvent" />,
		/// false otherwise.</param>
		public void ClearSelection( MasterPane master, bool sendEvent )
		{
			this.Clear();

			foreach ( GraphPane pane in master.PaneList )
			{
				foreach ( CurveItem ci in pane.CurveList )
				{
					ci.IsSelected = false;
				}
			}

			if ( sendEvent )
			{
				if ( SelectionChangedEvent != null )
					SelectionChangedEvent( this, new EventArgs() );
			}
		}
Exemplo n.º 57
0
        /// <summary>
        /// Internal method that applies a previously set layout with a specific
        /// row and column count.  This method is only called by
        /// <see cref="DoLayout(Graphics,MasterPane)" />.
        /// </summary>
        internal void DoLayout( Graphics g, MasterPane master, int rows, int columns )
        {
            if ( rows < 1 )
                rows = 1;
            if ( columns < 1 )
                columns = 1;

            int[] countList = new int[rows];

            for (int i=0; i<rows; i++ )
                countList[i] = columns;

            DoLayout( g, master, true, countList, null );
        }
Exemplo n.º 58
0
	//private bool CreateStatisticTable(StatisticInfo[] infos, int statisticTypeIndex, object[] statistic)
	//{
	//    string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };

	//    TableHeaderRow headerRow = new TableHeaderRow();
	//    TableHeaderCell headerCell = new TableHeaderCell();
	//    headerCell.Text = StatisticTypeNames[statisticTypeIndex];
	//    headerRow.Cells.Add(headerCell);

	//    headerCell = new TableHeaderCell();
	//    headerCell.Text = StringDef.Count;
	//    headerRow.Cells.Add(headerCell);

	//    TableStatistic.Rows.Add(headerRow);

	//    for (int i = 0; i < infos.Length; i++)
	//    {
	//        StatisticInfo info = infos[i];
	//        TableRow row = new TableRow();

	//        TableCell cell = new TableCell();
	//        for (int j = 0; j < statistic.Length; j++)
	//        {
	//            if (statistic[j].Id == info.Type)
	//            {
	//                cell.Text = statistic[j].Name;
	//                row.Cells.Add(cell);
	//                break;
	//            }
	//        }

	//        cell = new TableCell();
	//        cell.Text = info.Count.ToString();
	//        row.Cells.Add(cell);

	//        TableStatistic.Rows.Add(row);
	//    }

	//    return true;
	//}

	protected void ZedGraphWebStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
	{
		if (_server != null)
		{
			GraphPane graphPane = masterPane[0];

			string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };
			string staticType = StatisticTypes[_statisticType];
			string staticTypeName = StatisticTypeNames[_statisticType];
			SqlCommand cmd = new SqlCommand("SELECT " + staticType + ",COUNT(*) FROM rolesfirst " + _whereStatement + " GROUP BY " + staticType);
            if (!_server.IsConnected)
            {
                //LabelMessage.Visible = true;
                //LabelMessage.Text = StringDef.NoConnectionAlert;
                return;
            }
			SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id,_server, cmd);

			if (result != null && result.Success)
			{
				//整理数据
				SqlDataType[] dataTypes = new SqlDataType[] { SqlDataType.Int32, SqlDataType.Int32 };
				result.SetFieldType(dataTypes);

				object[] statistic = null;
				switch (_statisticType)
				{
					case 0:
						{
							statistic = new object[FS2GameDataManager.MaxLevel];
							for (int level = 1; level <= FS2GameDataManager.MaxLevel; level++)
							{
								statistic[level - 1] = level;
							}
						}
						break;
					case 1:
						{
							statistic = new object[FS2GameDataManager.RoleClasses.Length];
							for (int i = 0; i < FS2GameDataManager.RoleClasses.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleClasses[i];
							}
						}
						break;
					case 2:
						{
							statistic = new object[FS2GameDataManager.RoleSexes.Length];
							for (int i = 0; i < FS2GameDataManager.RoleSexes.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleSexes[i];
							}
						}
						break;
					case 3:
						statistic = new object[] { 0, 1, 2, 3, 4 };
						break;
				}
				
				StatisticInfo[] infos = new StatisticInfo[statistic.Length];
				for (int i = 0; i < infos.Length; i++)
				{
					infos[i] = new StatisticInfo(int.Parse(statistic[i].ToString()), 0);
				}

				object[] record = null;
				while ((record = result.ReadRecord()) != null)
				{
					int type = (int)record[0];
					int count = (int)record[1];

					for (int i = 0; i < infos.Length; i++)
					{
						if (infos[i].Type == type)
						{
							infos[i].Count = count;
						}
					}
				}

				////构造数据表格
				//bool success = CreateStatisticTable(infos, _statisticType, statistic);
				//if (success)
				//{
				//    TableStatistic.Visible = true;
				//}

				graphPane.Title.Text = staticTypeName;
				graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

				graphPane.Legend.IsVisible = false;

				string[] textLabels = new string[statistic.Length];
				for (int i = 0; i < statistic.Length; i++)
				{
					textLabels[i] = statistic[i].ToString();
				}

				graphPane.XAxis.Title.Text = staticTypeName;
				graphPane.XAxis.MajorGrid.Color = WebConfig.GraphXAxisGridColor;

				if (_statisticType > 0)
				{
					graphPane.XAxis.MajorTic.IsBetweenLabels = true;
					graphPane.XAxis.Type = AxisType.Text;
					graphPane.XAxis.Scale.TextLabels = textLabels;
				}

				graphPane.YAxis.Title.Text = StringDef.Count;
				graphPane.YAxis.Scale.Min = 0;
				graphPane.YAxis.MajorGrid.IsVisible = true;
				graphPane.YAxis.MajorGrid.DashOff = 0;
				graphPane.YAxis.MajorGrid.Color = Color.Gray;
				graphPane.YAxis.MinorGrid.IsVisible = true;
				graphPane.YAxis.MinorGrid.Color = Color.LightGray;
				graphPane.YAxis.MinorGrid.DashOff = 0;

				if (_chartType == ChartType.Bar)
				{
					graphPane.BarSettings.Type = BarType.Stack;

					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制柱子
					BarItem barItem = graphPane.AddBar(StringDef.Count, types, counts, WebConfig.GraphColors[0]);
					barItem.Bar.Fill = new Fill(WebConfig.GraphColors[0]);
				}
				else if (_chartType == ChartType.Line)
				{
					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制线条
					LineItem lineItem = graphPane.AddCurve("xxx", types, counts, WebConfig.GraphColors[1], SymbolType.None);
				}

				graphPane.AxisChange(g);
			}
		}
	}
        /// <summary>
        /// The Copy Constructor - Make a deep-copy clone of this class instance.
        /// </summary>
        /// <param name="rhs">The <see cref="MasterPane"/> object from which to copy</param>
        public MasterPane( MasterPane rhs )
            : base(rhs)
        {
            // copy all the value types
            //_paneLayoutMgr = rhs._paneLayoutMgr.Clone();
            _innerPaneGap = rhs._innerPaneGap;
            _isUniformLegendEntries = rhs._isUniformLegendEntries;
            _isCommonScaleFactor = rhs._isCommonScaleFactor;

            // Then, fill in all the reference types with deep copies
            _paneList = rhs._paneList.Clone();

            _paneLayout = rhs._paneLayout;
            _countList = rhs._countList;
            _isColumnSpecified = rhs._isColumnSpecified;
            _prop = rhs._prop;
        }
Exemplo n.º 60
0
        /// <summary>
        /// Internal method that applies a previously set layout with a rows per column or
        /// columns per row configuration.  This method is only called by
        /// <see cref="DoLayout(Graphics,MasterPane)" />.
        /// </summary>
        internal void DoLayout( Graphics g, MasterPane master, bool isColumnSpecified, int[] countList,
            float[] proportion)
        {
            // calculate scaleFactor on "normal" pane size (BaseDimension)
            float scaleFactor = master.CalcScaleFactor();

            // innerRect is the area for the GraphPane's
            RectangleF innerRect = master.CalcClientRect( g, scaleFactor );
            master.Legend.CalcRect( g, master, scaleFactor, ref innerRect );

            // scaled InnerGap is the area between the GraphPane.Rect's
            float scaledInnerGap = (float)( master._innerPaneGap * scaleFactor );

            int iPane = 0;

            if ( isColumnSpecified )
            {
                int rows = countList.Length;

                float y = 0.0f;

                for ( int rowNum = 0; rowNum < rows; rowNum++ )
                {
                    float propFactor = _prop == null ? 1.0f / rows : _prop[rowNum];

                    float height = ( innerRect.Height - (float)( rows - 1 ) * scaledInnerGap ) *
                                    propFactor;

                    int columns = countList[rowNum];
                    if ( columns <= 0 )
                        columns = 1;
                    float width = ( innerRect.Width - (float)( columns - 1 ) * scaledInnerGap ) /
                                    (float)columns;

                    if ( iPane >= master._paneList.Count )
                        return;

                    for ( int colNum = 0; colNum < columns; colNum++ )
                    {
                        master[iPane].Rect = new RectangleF(
                                            innerRect.X + colNum * ( width + scaledInnerGap ),
                                            innerRect.Y + y,
                                            width,
                                            height );
                        iPane++;
                    }

                    y += height + scaledInnerGap;
                }
            }
            else
            {
                int columns = countList.Length;

                float x = 0.0f;

                for ( int colNum = 0; colNum < columns; colNum++ )
                {
                    float propFactor = _prop == null ? 1.0f / columns : _prop[colNum];

                    float width = ( innerRect.Width - (float)( columns - 1 ) * scaledInnerGap ) *
                                    propFactor;

                    int rows = countList[colNum];
                    if ( rows <= 0 )
                        rows = 1;
                    float height = ( innerRect.Height - (float)( rows - 1 ) * scaledInnerGap ) / (float)rows;

                    for ( int rowNum = 0; rowNum < rows; rowNum++ )
                    {
                        if ( iPane >= master._paneList.Count )
                            return;

                        master[iPane].Rect = new RectangleF(
                                            innerRect.X + x,
                                            innerRect.Y + rowNum * ( height + scaledInnerGap ),
                                            width,
                                            height );
                        iPane++;
                    }

                    x += width + scaledInnerGap;
                }
            }
        }