Example #1
0
 /// <summary>
 /// Method to render the arrow
 /// </summary>
 /// <param name="map">The map</param>
 /// <param name="graphics">The graphics object</param>
 /// <param name="arrow">The arrow</param>
 private void RenderArrow(SharpMap.Map map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow)
 {
     var pts = new System.Drawing.PointF[arrow.Coordinates.Length];
     for (var i = 0; i < pts.Length; i++)
         pts[i] = map.WorldToImage(arrow.GetCoordinateN(i));
     graphics.DrawLines(ArrowPen, pts);
 }
Example #2
0
        public void Draw(System.Drawing.Graphics graphics, System.Drawing.Brush brush)
        {
            foreach (Link link in net.Links)
            {
                var w = link.Wrap();

                if (!pencilBox.Keys.Contains(w.Height))
                {
                    pencilBox[w.Height] = new System.Drawing.Pen(brush, (float)w.Height);
                }

                graphics.DrawLines(pencilBox[w.Height], w.LineF);
            }
        }
 public override void DrawArrowForces(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods)
 {
     if (m_visibleThickPath != null)
     {
         GraphicsState o = gc.Save();
         gc.SetClip(m_visibleThickPath);
         if ((m_traceLines != null) && (m_traceLines.Length > 0) && (m_traceLines[0].Count > 1))
         {
             for (int k = 0; k < m_traceLines.Length; k++)
             {
                 gc.DrawLines(r.RegionGuides, m_traceLines[k].ToArray());
             }
         }
         gc.Restore(o);
     }
 }
Example #4
0
        protected override void OnPaintEtc(System.Drawing.Graphics g)
        {
            base.OnPaintEtc(g);
            if (mEntry != null && mEntry.Records.Count > 1)
            {
                int idx = 0;
                foreach (Record rec in mEntry.Records)
                {
                    mPoints[idx++] = FromLatLngToLocal(rec.Location);
                }
                g.DrawLines(mRedPen, mPoints);

                if (mShowRange.IsValid)
                {
                    idx = 0;
                    for (int i = mShowRange.Min; i < mShowRange.Max; ++i)
                    {
                        mSelectedPoints[idx++] = mPoints[i];
                    }
                    g.DrawLines(mSelectedPen, mSelectedPoints);
                }
            }
        }
Example #5
0
		/// <summary>
		/// Paints a border around the image. If Image drop shadow is enabled,
		/// a shodow is drawn too.
		/// </summary>
		/// <param name="g">The graphics object</param>
		/// <param name="ImageRect">the rectangle region of the image</param>
		private void paint_ImageBorder(System.Drawing.Graphics g, System.Drawing.Rectangle ImageRect)
		{
			System.Drawing.Rectangle rect = ImageRect;

			//
			// If ImageDropShadow = true, draw shadow
			//
			if(ImageDropShadow)
			{
				System.Drawing.Pen p0 = new System.Drawing.Pen(System.Drawing.Color.FromArgb(80,0,0,0));
				System.Drawing.Pen p1 = new System.Drawing.Pen(System.Drawing.Color.FromArgb(40,0,0,0));
				g.DrawLine(p0, new Point(rect.Right,rect.Bottom),new Point(rect.Right+1,rect.Bottom));
				g.DrawLine(p0, new Point(rect.Right+1,rect.Top+1),new Point(rect.Right+1,rect.Bottom+0));
				g.DrawLine(p1, new Point(rect.Right+2,rect.Top+2),new Point(rect.Right+2,rect.Bottom+1));
				g.DrawLine(p0, new Point(rect.Left+1,rect.Bottom+1),new Point(rect.Right+0,rect.Bottom+1));
				g.DrawLine(p1, new Point(rect.Left+1,rect.Bottom+2),new Point(rect.Right+1,rect.Bottom+2));
			}
			//
			// Draw Image Border
			//
			if(ImageBorderEnabled)
			{
				Color[] ColorArray    = null;
				float[] PositionArray = null;
				System.Drawing.Color color = this.ImageBorderColor;
				if(!this.Enabled)
					color = System.Drawing.Color.LightGray;
				//
				// initialize color and position array
				//
				ColorArray = new Color[]{
											Blend(color,System.Drawing.Color.White,40),
											Blend(color,System.Drawing.Color.White,20),
											Blend(color,System.Drawing.Color.White,30),
											Blend(color,System.Drawing.Color.White,00),
											Blend(color,System.Drawing.Color.Black,30),
											Blend(color,System.Drawing.Color.Black,70),
				};
				PositionArray = new float[]{0.0f,.20f,.50f,.60f,.90f,1.0f};
				//
				// create blend object
				//
				System.Drawing.Drawing2D.ColorBlend blend = new System.Drawing.Drawing2D.ColorBlend();
				blend.Colors    = ColorArray;
				blend.Positions = PositionArray;
				//
				// create brush and pens
				//
				using(var brush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, BackColor,
					Blend(BackColor, BackColor, 10), System.Drawing.Drawing2D.LinearGradientMode.Vertical))
				{
					brush.InterpolationColors = blend;
					using(var pen0 = new Pen(brush, 1))
					using(var pen1 = new Pen(Color.Black))
					{
						//
						// calculate points to draw line
						//
						rect.Inflate(1, 1);
						var pts = border_Get(rect.Left, rect.Top, rect.Width, rect.Height);
						border_Contract(1, ref pts);
						//
						// draw line 0
						//
						g.DrawLines(pen1, pts);
						//
						// draw line 1
						//
						border_Contract(1, ref pts);
						g.DrawLines(pen0, pts);
					}
				}
			}
		}
 public static void DrawCheckedFlag(
     System.Drawing.Graphics g, Rectangle rect, Color color)
 {
     PointF[] points = new PointF[3];
     points[0] = new PointF(
         rect.X + rect.Width / 4.5f,
         rect.Y + rect.Height / 2.5f);
     points[1] = new PointF(
         rect.X + rect.Width / 2.5f,
         rect.Bottom - rect.Height / 3f);
     points[2] = new PointF(
         rect.Right - rect.Width / 4.0f,
         rect.Y + rect.Height / 4.5f);
     using (Pen pen = new Pen(color, 2F))
     {
         g.DrawLines(pen, points);
     }
 }
Example #7
0
		/// <summary>
		/// Paints this base container
		/// </summary>
		public override void Paint(System.Drawing.Graphics g)
		{
			Font objFont=this.GetFont();
			if(m_Expanded && !this.DesignMode || m_Expanded && this.DesignMode && !m_MouseOver)
			{
				// Office 2000 Style
				if(m_Style==eDotNetBarStyle.Office)
				{
                    g.FillRectangle(SystemBrushes.Control,m_Rect);
					System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_Rect,System.Windows.Forms.Border3DStyle.SunkenOuter,System.Windows.Forms.Border3DSide.All);
				}
				else
				{
					// DotNet Style
					g.FillRectangle(SystemBrushes.Control,m_Rect);
					g.FillRectangle(new SolidBrush(ColorFunctions.ToolMenuFocusBackColor(g)),m_Rect.Left,m_Rect.Top,m_Rect.Width-2,m_Rect.Height);
					Point[] p=new Point[4];
					p[0].X=m_Rect.Left;
					p[0].Y=m_Rect.Top+m_Rect.Height-1;
					p[1].X=m_Rect.Left;
					p[1].Y=m_Rect.Top;
					p[2].X=m_Rect.Left+m_Rect.Width-3;
					p[2].Y=m_Rect.Top;
					p[3].X=m_Rect.Left+m_Rect.Width-3;
					p[3].Y=m_Rect.Top+m_Rect.Height-1;
					g.DrawLines(new Pen(ColorFunctions.MenuFocusBorderColor(g),1),p);
					// Draw the shadow
					g.FillRectangle(SystemBrushes.ControlDark,m_Rect.Left+m_Rect.Width-2,m_Rect.Top+2,2,m_Rect.Height-2);
				}
				
			}
			else if(m_MouseOver && (m_Enabled || this.DesignMode))
			{
				// Office 2000 Style
				if(!this.DesignMode && m_MouseOver)
				{
					if(m_Style==eDotNetBarStyle.Office)
					{
						g.FillRectangle(SystemBrushes.Control,m_Rect);
						System.Windows.Forms.ControlPaint.DrawBorder3D(g,m_Rect,System.Windows.Forms.Border3DStyle.RaisedInner,System.Windows.Forms.Border3DSide.All);
					}
					else
					{
						// DotNet Style
						g.FillRectangle(SystemBrushes.Control,m_Rect);
						g.FillRectangle(new SolidBrush(ColorFunctions.HoverBackColor(g)),m_Rect.Left,m_Rect.Top,m_Rect.Width-2,m_Rect.Height);
						// TODO: Beta 2 fix --> g.DrawRectangle(SystemPens.Highlight,m_Rect.Left,m_Rect.Top,m_Rect.Width-2,m_Rect.Height);
						NativeFunctions.DrawRectangle(g,SystemPens.Highlight,m_Rect.Left,m_Rect.Top,m_Rect.Width-2,m_Rect.Height);
					}
				}
			}
			else
				g.FillRectangle(SystemBrushes.Control,m_Rect);

			if(this.DesignMode && this.Focused)
			{
				Rectangle r=m_Rect;
				r.Inflate(-1,-1);
				g.DrawRectangle(new Pen(SystemColors.ControlText,2),r);
			}
			
			StringFormat sf=StringFormat.GenericDefault;
			sf.HotkeyPrefix=System.Drawing.Text.HotkeyPrefix.Show;
			sf.Alignment=System.Drawing.StringAlignment.Center;
			sf.LineAlignment=System.Drawing.StringAlignment.Center;
			if(m_Enabled || this.DesignMode)
			{
				g.DrawString(m_Text,objFont,SystemBrushes.ControlText,m_Rect,sf);
			}
			else
			{
				if(m_Style==eDotNetBarStyle.DotNet)
					g.DrawString(m_Text,objFont,SystemBrushes.ControlDark,m_Rect,sf);
				else
					System.Windows.Forms.ControlPaint.DrawStringDisabled(g,m_Text,objFont,SystemColors.Control,m_Rect,sf);
			}
		}
Example #8
0
        public void DrawLShapeLine(System.Drawing.Graphics g, int intMarginLeft, int intMarginTop, int intWidth, int intHeight)
        {
            Pen myPen = new Pen(Color.Black);
            myPen.Width = 2;
            // Create array of points that define lines to draw.
            int marginleft = intMarginLeft;
            int marginTop = intMarginTop;
            int width = intWidth;
            int height = intHeight;
            int arrowSize = 3;
            Point[] points =
             {
                new Point(marginleft, marginTop),
                new Point(marginleft, height + marginTop),
                new Point(marginleft + width, marginTop + height),
                // Arrow
                new Point(marginleft + width - arrowSize, marginTop + height - arrowSize),
                new Point(marginleft + width - arrowSize, marginTop + height + arrowSize),
                new Point(marginleft + width, marginTop + height)
             };

            g.DrawLines(myPen, points);
        }
 public override void Paint(System.Drawing.Graphics g)
 {
     g.DrawLines(pen,this.mPoints);
     //g.DrawBeziers(pen,mPoints);
 }
Example #10
0
        public override void RenderCustomChart(Character character, string chartName, System.Drawing.Graphics g, int width, int height)
        {
            Rectangle rectSubPoint;
            System.Drawing.Drawing2D.LinearGradientBrush brushSubPointFill;
            System.Drawing.Drawing2D.ColorBlend blendSubPoint;

            CalculationOptionsMage calculationOptions = character.CalculationOptions as CalculationOptionsMage;

            Font fontLegend = new Font("Verdana", 10f, GraphicsUnit.Pixel);
            int legendY;

            Brush[] brushSubPoints;
            Color[] colorSubPointsA;
            Color[] colorSubPointsB;

            float graphStart;
            float graphWidth;
            float graphTop;
            float graphBottom;
            float graphHeight;
            float maxScale;
            float graphEnd;
            float[] ticks;
            Pen black200 = new Pen(Color.FromArgb(200, 0, 0, 0));
            Pen black150 = new Pen(Color.FromArgb(150, 0, 0, 0));
            Pen black75 = new Pen(Color.FromArgb(75, 0, 0, 0));
            Pen black50 = new Pen(Color.FromArgb(50, 0, 0, 0));
            Pen black25 = new Pen(Color.FromArgb(25, 0, 0, 0));
            StringFormat formatTick = new StringFormat();
            formatTick.LineAlignment = StringAlignment.Far;
            formatTick.Alignment = StringAlignment.Center;
            Brush black200brush = new SolidBrush(Color.FromArgb(200, 0, 0, 0));
            Brush black150brush = new SolidBrush(Color.FromArgb(150, 0, 0, 0));
            Brush black75brush = new SolidBrush(Color.FromArgb(75, 0, 0, 0));
            Brush black50brush = new SolidBrush(Color.FromArgb(50, 0, 0, 0));
            Brush black25brush = new SolidBrush(Color.FromArgb(25, 0, 0, 0));

            string[] statNames = new string[] { "11.7 Spell Power", "4 Mana per 5 sec", "10 Crit Rating", "10 Haste Rating", "10 Hit Rating", "10 Intellect", "10 Spirit" };
            Color[] statColors = new Color[] { Color.FromArgb(255, 255, 0, 0), Color.DarkBlue, Color.FromArgb(255, 255, 165, 0), Color.Olive, Color.FromArgb(255, 154, 205, 50), Color.Aqua, Color.FromArgb(255, 0, 0, 255) };

            DisplayCalculations calculations = calculationOptions.Calculations;

            List<float> X = new List<float>();
            List<ComparisonCalculationBase[]> Y = new List<ComparisonCalculationBase[]>();

            height -= 2;

            Stats[] statsList = new Stats[] {
                        new Stats() { SpellPower = 1.17f },
                        new Stats() { Mp5 = 0.4f },
                        new Stats() { CritRating = 1 },
                        new Stats() { HasteRating = 1 },
                        new Stats() { HitRating = 1 },
                        new Stats() { Intellect = 1 },
                        new Stats() { Spirit = 1 },
                    };

            switch (chartName)
            {
                case "Stats Graph":
                    Base.Graph.RenderStatsGraph(g, width, height, character, statsList, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
                case "Proc Uptime":
                    List<SpecialEffect> effectList = new List<SpecialEffect>();
                    effectList.AddRange(calculations.SpellPowerEffects);
                    effectList.AddRange(calculations.HasteRatingEffects);

                    #region Legend
                    legendY = 2;

                    Color[] colors = new Color[] {
                        Color.FromArgb(255,202,180,96), 
                        Color.FromArgb(255,101,225,240),
                        Color.FromArgb(255,0,4,3), 
                        Color.FromArgb(255,238,238,30),
                        Color.FromArgb(255,45,112,63), 
                        Color.FromArgb(255,121,72,210), 
                        Color.FromArgb(255,217,100,54), 
                        Color.FromArgb(255,210,72,195), 
                        Color.FromArgb(255,206,189,191), 
                        Color.FromArgb(255,255,0,0), 
                        Color.FromArgb(255,0,255,0), 
                        Color.FromArgb(255,0,0,255), 
                    };

                    brushSubPoints = new Brush[effectList.Count];
                    colorSubPointsA = new Color[effectList.Count];
                    colorSubPointsB = new Color[effectList.Count];
                    for (int i = 0; i < effectList.Count; i++)
                    {
                        Color baseColor = colors[i];
                        brushSubPoints[i] = new SolidBrush(Color.FromArgb(baseColor.R / 2, baseColor.G / 2, baseColor.B / 2));
                        colorSubPointsA[i] = Color.FromArgb(baseColor.A / 2, baseColor.R / 2, baseColor.G / 2, baseColor.B / 2);
                        colorSubPointsB[i] = Color.FromArgb(baseColor.A / 2, baseColor);
                    }

                    for (int i = 0; i < effectList.Count; i++)
                    {
                        g.DrawLine(new Pen(colors[i]), new Point(20, legendY + 7), new Point(50, legendY + 7));
                        //g.DrawString(effectList[i].ToString(), fontLegend, Brushes.Black, new Point(60, legendY));

                        legendY += 16;
                    }

                    #endregion

                    #region Graph Ticks
                    graphStart = 30f;
                    graphWidth = width - 50f;
                    graphTop = legendY;
                    graphBottom = height - 4 - 4 * effectList.Count;
                    graphHeight = graphBottom - graphTop - 40;
                    maxScale = calculationOptions.FightDuration;
                    graphEnd = graphStart + graphWidth;
                    ticks = new float[] {(float)Math.Round(graphStart + graphWidth * 0.5f),
                            (float)Math.Round(graphStart + graphWidth * 0.75f),
                            (float)Math.Round(graphStart + graphWidth * 0.25f),
                            (float)Math.Round(graphStart + graphWidth * 0.125f),
                            (float)Math.Round(graphStart + graphWidth * 0.375f),
                            (float)Math.Round(graphStart + graphWidth * 0.625f),
                            (float)Math.Round(graphStart + graphWidth * 0.875f)};

                    for (int i = 0; i <= 10; i++)
                    {
                        float h = (float)Math.Round(graphBottom - graphHeight * i / 10.0);
                        g.DrawLine(black25, graphStart - 4, h, graphEnd, h);
                        //g.DrawLine(black200, graphStart - 4, h, graphStart, h);

                        g.DrawString((i / 10.0).ToString("F1"), fontLegend, black200brush, graphStart - 15, h + 6, formatTick);
                    }

                    g.DrawLine(black150, ticks[1], graphTop + 36, ticks[1], graphTop + 39);
                    g.DrawLine(black150, ticks[2], graphTop + 36, ticks[2], graphTop + 39);
                    g.DrawLine(black75, ticks[3], graphTop + 36, ticks[3], graphTop + 39);
                    g.DrawLine(black75, ticks[4], graphTop + 36, ticks[4], graphTop + 39);
                    g.DrawLine(black75, ticks[5], graphTop + 36, ticks[5], graphTop + 39);
                    g.DrawLine(black75, ticks[6], graphTop + 36, ticks[6], graphTop + 39);
                    g.DrawLine(black75, graphEnd, graphTop + 41, graphEnd, height - 4);
                    g.DrawLine(black75, ticks[0], graphTop + 41, ticks[0], height - 4);
                    g.DrawLine(black50, ticks[1], graphTop + 41, ticks[1], height - 4);
                    g.DrawLine(black50, ticks[2], graphTop + 41, ticks[2], height - 4);
                    g.DrawLine(black25, ticks[3], graphTop + 41, ticks[3], height - 4);
                    g.DrawLine(black25, ticks[4], graphTop + 41, ticks[4], height - 4);
                    g.DrawLine(black25, ticks[5], graphTop + 41, ticks[5], height - 4);
                    g.DrawLine(black25, ticks[6], graphTop + 41, ticks[6], height - 4);
                    g.DrawLine(black200, graphStart - 4, graphTop + 40, graphEnd + 4, graphTop + 40);
                    g.DrawLine(black200, graphStart, graphTop + 36, graphStart, height - 4);
                    g.DrawLine(black200, graphEnd, graphTop + 36, graphEnd, height - 4);
                    g.DrawLine(black200, graphStart - 4, graphBottom, graphEnd + 4, graphBottom);

                    g.DrawString(TimeFormat(0f), fontLegend, black200brush, graphStart, graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale), fontLegend, black200brush, graphEnd, graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.5f), fontLegend, black200brush, ticks[0], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.75f), fontLegend, black150brush, ticks[1], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.25f), fontLegend, black150brush, ticks[2], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.125f), fontLegend, black75brush, ticks[3], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.375f), fontLegend, black75brush, ticks[4], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.625f), fontLegend, black75brush, ticks[5], graphTop + 36, formatTick);
                    g.DrawString(TimeFormat(maxScale * 0.875f), fontLegend, black75brush, ticks[6], graphTop + 36, formatTick);
                    #endregion

                    for (int i = 0; i < effectList.Count; i++)
                    {
                        float procs = 0.0f;
                        float triggers = 0.0f;
                        for (int j = 0; j < calculations.SolutionVariable.Count; j++)
                        {
                            if (calculations.Solution[j] > 0)
                            {
                                Cycle c = calculations.SolutionVariable[j].Cycle;
                                if (c != null)
                                {
                                    switch (effectList[i].Trigger)
                                    {
                                        case Trigger.DamageSpellCrit:
                                        case Trigger.SpellCrit:
                                            triggers += (float)calculations.Solution[j] * c.Ticks / c.CastTime;
                                            procs += (float)calculations.Solution[j] * c.CritProcs / c.CastTime;
                                            break;
                                        case Trigger.DamageSpellHit:
                                        case Trigger.SpellHit:
                                            triggers += (float)calculations.Solution[j] * c.Ticks / c.CastTime;
                                            procs += (float)calculations.Solution[j] * c.HitProcs / c.CastTime;
                                            break;
                                        case Trigger.SpellMiss:
                                            triggers += (float)calculations.Solution[j] * c.Ticks / c.CastTime;
                                            procs += (float)calculations.Solution[j] * (1 - c.HitProcs) / c.CastTime;
                                            break;
                                        case Trigger.DamageSpellCast:
                                        case Trigger.SpellCast:
                                            if (effectList[i].Stats.ValkyrDamage > 0)
                                            {
                                                triggers += (float)calculations.Solution[j] * c.CastProcs2 / c.CastTime;
                                                procs += (float)calculations.Solution[j] * c.CastProcs2 / c.CastTime;
                                            }
                                            else
                                            {
                                                triggers += (float)calculations.Solution[j] * c.CastProcs / c.CastTime;
                                                procs += (float)calculations.Solution[j] * c.CastProcs / c.CastTime;
                                            }
                                            break;
                                        case Trigger.MageNukeCast:
                                            triggers += (float)calculations.Solution[j] * c.NukeProcs / c.CastTime;
                                            procs += (float)calculations.Solution[j] * c.NukeProcs / c.CastTime;
                                            break;
                                        case Trigger.DamageDone:
                                        case Trigger.DamageOrHealingDone:
                                            triggers += (float)calculations.Solution[j] * c.DamageProcs / c.CastTime;
                                            procs += (float)calculations.Solution[j] * c.DamageProcs / c.CastTime;
                                            break;
                                        case Trigger.DoTTick:
                                            triggers += (float)calculations.Solution[j] * c.DotProcs / c.CastTime;
                                            procs += (float)calculations.Solution[j] * c.DotProcs / c.CastTime;
                                            break;
                                    }
                                }
                            }
                        }
                        float triggerInterval = calculations.CalculationOptions.FightDuration / triggers;
                        float triggerChance = Math.Min(1.0f, procs / triggers);

                        int steps = 200;
                        PointF[] plot = new PointF[steps + 1];
                        for (int tick = 0; tick <= steps; tick++)
                        {
                            float time = tick / (float)steps * calculations.CalculationOptions.FightDuration;
                            plot[tick] = new PointF(graphStart + time / maxScale * graphWidth, graphBottom - graphHeight * effectList[i].GetUptimePlot(triggerInterval, triggerChance, 3.0f, time));
                        }

                        g.DrawLines(new Pen(colors[i]), plot);

                        g.DrawString(string.Format("{0} (average uptime {1:F}%)", effectList[i], effectList[i].GetAverageUptime(triggerInterval, triggerChance, 3.0f, calculations.CalculationOptions.FightDuration) * 100), fontLegend, Brushes.Black, new Point(60, 2 + i * 16));
                    }
                    break;
                case "Sequence Reconstruction":

                    if (calculationOptions.SequenceReconstruction == null)
                    {
                        g.DrawString("Sequence reconstruction data is not available.", fontLegend, Brushes.Black, 2, 2);
                    }
                    else
                    {
        #region Legend
                        legendY = 2;

                        List<EffectCooldown> cooldownList = calculationOptions.Calculations.CooldownList;

                        brushSubPoints = new Brush[cooldownList.Count];
                        colorSubPointsA = new Color[cooldownList.Count];
                        colorSubPointsB = new Color[cooldownList.Count];
                        for (int i = 0; i < cooldownList.Count; i++)
                        {
                            Color baseColor = cooldownList[i].Color;
                            brushSubPoints[i] = new SolidBrush(Color.FromArgb(baseColor.R / 2, baseColor.G / 2, baseColor.B / 2));
                            colorSubPointsA[i] = Color.FromArgb(baseColor.A / 2, baseColor.R / 2, baseColor.G / 2, baseColor.B / 2);
                            colorSubPointsB[i] = Color.FromArgb(baseColor.A / 2, baseColor);
                        }
                        StringFormat formatSubPoint = new StringFormat();
                        formatSubPoint.Alignment = StringAlignment.Center;
                        formatSubPoint.LineAlignment = StringAlignment.Center;

                        int maxWidth = 1;
                        for (int i = 0; i < cooldownList.Count; i++)
                        {
                            string subPointName = cooldownList[i].Name;
                            int widthSubPoint = (int)Math.Ceiling(g.MeasureString(subPointName, fontLegend).Width + 2f);
                            if (widthSubPoint > maxWidth) maxWidth = widthSubPoint;
                        }
                        for (int i = 0; i < cooldownList.Count; i++)
                        {
                            string cooldownName = cooldownList[i].Name;
                            rectSubPoint = new Rectangle(2, legendY, maxWidth, 16);
                            blendSubPoint = new System.Drawing.Drawing2D.ColorBlend(3);
                            blendSubPoint.Colors = new Color[] { colorSubPointsA[i], colorSubPointsB[i], colorSubPointsA[i] };
                            blendSubPoint.Positions = new float[] { 0f, 0.5f, 1f };
                            brushSubPointFill = new System.Drawing.Drawing2D.LinearGradientBrush(rectSubPoint, colorSubPointsA[i], colorSubPointsB[i], 67f);
                            brushSubPointFill.InterpolationColors = blendSubPoint;

                            g.FillRectangle(brushSubPointFill, rectSubPoint);
                            g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);
                            g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);
                            g.DrawRectangle(new Pen(brushSubPointFill), rectSubPoint);

                            g.DrawString(cooldownName, fontLegend, brushSubPoints[i], rectSubPoint, formatSubPoint);
                            legendY += 16;
                        }

                        if (calculationOptions.AdviseAdvancedSolver)
                        {
                            g.DrawString("Sequence Reconstruction was not fully successful, it is recommended that you enable more options in advanced solver (segment cooldowns, integral mana consumables, advanced constraints options)!", fontLegend, Brushes.Black, new RectangleF(5 + maxWidth, 40, width - maxWidth - 10, 100));
                        }

                        g.DrawLine(Pens.Aqua, new Point(maxWidth + 40, 10), new Point(maxWidth + 80, 10));
                        g.DrawString("Mana", fontLegend, Brushes.Black, new Point(maxWidth + 90, 2));
                        g.DrawLine(Pens.Red, new Point(maxWidth + 40, 26), new Point(maxWidth + 80, 26));
                        g.DrawString("Dps", fontLegend, Brushes.Black, new Point(maxWidth + 90, 18));
                        #endregion

        #region Graph Ticks
                        graphStart = 20f;
                        graphWidth = width - 40f;
                        graphTop = legendY;
                        graphBottom = height - 4 - 4 * cooldownList.Count;
                        graphHeight = graphBottom - graphTop - 40;
                        maxScale = calculationOptions.FightDuration;
                        graphEnd = graphStart + graphWidth;
                        ticks = new float[] {(float)Math.Round(graphStart + graphWidth * 0.5f),
                            (float)Math.Round(graphStart + graphWidth * 0.75f),
                            (float)Math.Round(graphStart + graphWidth * 0.25f),
                            (float)Math.Round(graphStart + graphWidth * 0.125f),
                            (float)Math.Round(graphStart + graphWidth * 0.375f),
                            (float)Math.Round(graphStart + graphWidth * 0.625f),
                            (float)Math.Round(graphStart + graphWidth * 0.875f)};

                        g.DrawLine(black150, ticks[1], graphTop + 36, ticks[1], graphTop + 39);
                        g.DrawLine(black150, ticks[2], graphTop + 36, ticks[2], graphTop + 39);
                        g.DrawLine(black75, ticks[3], graphTop + 36, ticks[3], graphTop + 39);
                        g.DrawLine(black75, ticks[4], graphTop + 36, ticks[4], graphTop + 39);
                        g.DrawLine(black75, ticks[5], graphTop + 36, ticks[5], graphTop + 39);
                        g.DrawLine(black75, ticks[6], graphTop + 36, ticks[6], graphTop + 39);
                        g.DrawLine(black75, graphEnd, graphTop + 41, graphEnd, height - 4);
                        g.DrawLine(black75, ticks[0], graphTop + 41, ticks[0], height - 4);
                        g.DrawLine(black50, ticks[1], graphTop + 41, ticks[1], height - 4);
                        g.DrawLine(black50, ticks[2], graphTop + 41, ticks[2], height - 4);
                        g.DrawLine(black25, ticks[3], graphTop + 41, ticks[3], height - 4);
                        g.DrawLine(black25, ticks[4], graphTop + 41, ticks[4], height - 4);
                        g.DrawLine(black25, ticks[5], graphTop + 41, ticks[5], height - 4);
                        g.DrawLine(black25, ticks[6], graphTop + 41, ticks[6], height - 4);
                        g.DrawLine(black200, graphStart - 4, graphTop + 40, graphEnd + 4, graphTop + 40);
                        g.DrawLine(black200, graphStart, graphTop + 36, graphStart, height - 4);
                        g.DrawLine(black200, graphEnd, graphTop + 36, graphEnd, height - 4);
                        g.DrawLine(black200, graphStart - 4, graphBottom, graphEnd + 4, graphBottom);

                        g.DrawString(TimeFormat(0f), fontLegend, black200brush, graphStart, graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale), fontLegend, black200brush, graphEnd, graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.5f), fontLegend, black200brush, ticks[0], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.75f), fontLegend, black150brush, ticks[1], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.25f), fontLegend, black150brush, ticks[2], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.125f), fontLegend, black75brush, ticks[3], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.375f), fontLegend, black75brush, ticks[4], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.625f), fontLegend, black75brush, ticks[5], graphTop + 36, formatTick);
                        g.DrawString(TimeFormat(maxScale * 0.875f), fontLegend, black75brush, ticks[6], graphTop + 36, formatTick);
                        #endregion

                        List<SequenceReconstruction.SequenceItem> sequence = calculationOptions.SequenceReconstruction.sequence;

                        float mana = calculations.StartingMana;
                        int gemCount = 0;
                        float time = 0;
                        Color manaFill = Color.FromArgb(50, Color.FromArgb(255, 0, 0, 255));
                        float lastMana = mana;
                        float maxMana = calculations.BaseStats.Mana;
                        float maxDps = 100;
                        for (int i = 0; i < sequence.Count; i++)
                        {
                            int index = sequence[i].Index;
                            VariableType type = sequence[i].VariableType;
                            float duration = (float)sequence[i].Duration;
                            Cycle cycle = sequence[i].Cycle;
                            if (cycle != null && cycle.DamagePerSecond > maxDps) maxDps = cycle.DamagePerSecond;
                            CastingState state = sequence[i].CastingState;
                            float mps = (float)sequence[i].Mps;
                            if (sequence[i].IsManaPotionOrGem)
                            {
                                duration = 0;
                                if (sequence[i].VariableType == VariableType.ManaGem)
                                {
                                    mana += (float)((1 + calculations.BaseStats.BonusManaGem) * calculations.ManaGemValue);
                                    gemCount++;
                                }
                                else if (sequence[i].VariableType == VariableType.ManaPotion)
                                {
                                    mana += (float)((1 + calculations.BaseStats.BonusManaPotion) * calculations.ManaPotionValue);
                                }
                                if (mana < 0) mana = 0;
                                if (mana > maxMana)
                                {
                                    mana = maxMana;
                                }
                                g.DrawLine(Pens.Aqua, graphStart + time / maxScale * graphWidth, graphBottom - graphHeight * lastMana / maxMana, graphStart + time / maxScale * graphWidth, height - 44 - graphHeight * mana / maxMana);
                            }
                            else
                            {
                                if (sequence[i].IsEvocation)
                                {
                                    switch (sequence[i].VariableType)
                                    {
                                        case VariableType.Evocation:
                                            mps = -(float)calculationOptions.Calculations.EvocationRegen;
                                            break;
                                        case VariableType.EvocationIV:
                                            mps = -(float)calculationOptions.Calculations.EvocationRegenIV;
                                            break;
                                        case VariableType.EvocationHero:
                                            mps = -(float)calculationOptions.Calculations.EvocationRegenHero;
                                            break;
                                        case VariableType.EvocationIVHero:
                                            mps = -(float)calculationOptions.Calculations.EvocationRegenIVHero;
                                            break;
                                    }
                                }
                                float partTime = duration;
                                if (mana - mps * duration < 0) partTime = mana / mps;
                                else if (mana - mps * duration > maxMana) partTime = (mana - maxMana) / mps;
                                mana -= mps * duration;
                                if (mana < 0) mana = 0;
                                if (mana > maxMana)
                                {
                                    mana = maxMana;
                                }
                                float x1 = graphStart + time / maxScale * graphWidth;
                                float x2 = graphStart + (time + partTime) / maxScale * graphWidth;
                                float x3 = graphStart + (time + duration) / maxScale * graphWidth;
                                float y1 = graphBottom - graphHeight * lastMana / maxMana;
                                float y2 = graphBottom - graphHeight * mana / maxMana;
                                float y3 = graphBottom;
                                g.FillPolygon(new SolidBrush(manaFill), new PointF[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y2), new PointF(x3, y3), new PointF(x1, y3) });
                                g.DrawLine(Pens.Aqua, x1, y1, x2, y2);
                                g.DrawLine(Pens.Aqua, x2, y2, x3, y2);
                            }
                            lastMana = mana;
                            time += duration;
                        }

                        maxDps *= 1.1f;
                        List<PointF> list = new List<PointF>();
                        time = 0.0f;
                        for (int i = 0; i < sequence.Count; i++)
                        {
                            int index = sequence[i].Index;
                            VariableType type = sequence[i].VariableType;
                            float duration = (float)sequence[i].Duration;
                            Cycle cycle = sequence[i].Cycle;
                            CastingState state = sequence[i].CastingState;
                            float mps = (float)sequence[i].Mps;
                            if (sequence[i].IsManaPotionOrGem) duration = 0;
                            float dps = 0;
                            if (cycle != null)
                            {
                                dps = cycle.DamagePerSecond;
                            }
                            if (duration > 0)
                            {
                                list.Add(new PointF(graphStart + (time + 0.1f * duration) / maxScale * graphWidth, graphBottom - graphHeight * dps / maxDps));
                                list.Add(new PointF(graphStart + (time + 0.9f * duration) / maxScale * graphWidth, graphBottom - graphHeight * dps / maxDps));
                            }
                            time += duration;
                        }
                        if (list.Count > 0) g.DrawLines(Pens.Red, list.ToArray());

                        for (int cooldown = 0; cooldown < cooldownList.Count; cooldown++)
                        {
                            blendSubPoint = new System.Drawing.Drawing2D.ColorBlend(3);
                            blendSubPoint.Colors = new Color[] { colorSubPointsA[cooldown], colorSubPointsB[cooldown], colorSubPointsA[cooldown] };
                            blendSubPoint.Positions = new float[] { 0f, 0.5f, 1f };
                            bool on = false;
                            float timeOn = 0.0f;
                            time = 0;
                            for (int i = 0; i < sequence.Count; i++)
                            {
                                float duration = (float)sequence[i].Duration;
                                if (sequence[i].IsManaPotionOrGem) duration = 0;
                                if (on && !sequence[i].CastingState.EffectsActive(cooldownList[cooldown]) && !sequence[i].IsManaPotionOrGem)
                                {
                                    on = false;
                                    if (time > timeOn)
                                    {
                                        RectangleF rect = new RectangleF(graphStart + graphWidth * timeOn / maxScale, graphBottom + cooldown * 4, graphWidth * (time - timeOn) / maxScale, 4);
                                        brushSubPointFill = new System.Drawing.Drawing2D.LinearGradientBrush(rect, colorSubPointsA[cooldown], colorSubPointsB[cooldown], 67f);
                                        brushSubPointFill.InterpolationColors = blendSubPoint;

                                        g.FillRectangle(brushSubPointFill, rect);
                                        g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                        g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                        g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                    }
                                }
                                else if (!on && sequence[i].CastingState.EffectsActive(cooldownList[cooldown]))
                                {
                                    on = true;
                                    timeOn = time;
                                }
                                time += duration;
                            }
                            if (on)
                            {
                                if (time - timeOn > 0)
                                {
                                    RectangleF rect = new RectangleF(graphStart + graphWidth * timeOn / maxScale, graphBottom + cooldown * 4, graphWidth * (time - timeOn) / maxScale, 4);
                                    brushSubPointFill = new System.Drawing.Drawing2D.LinearGradientBrush(rect, colorSubPointsA[cooldown], colorSubPointsB[cooldown], 67f);
                                    brushSubPointFill.InterpolationColors = blendSubPoint;

                                    g.FillRectangle(brushSubPointFill, rect);
                                    g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                    g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                    g.DrawRectangle(new Pen(brushSubPointFill), rect.X, rect.Y, rect.Width, rect.Height);
                                }
                            }
                        }
                    }
                    break;
                case "Scaling vs Spell Power":
                    Base.Graph.RenderScalingGraph(g, width, height, character, statsList, new Stats() { SpellPower = 5 }, true, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
                case "Scaling vs Crit Rating":
                    Base.Graph.RenderScalingGraph(g, width, height, character, statsList, new Stats() { CritRating = 5 }, true, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
                case "Scaling vs Haste Rating":
                    Base.Graph.RenderScalingGraph(g, width, height, character, statsList, new Stats() { HasteRating = 5 }, true, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
                case "Scaling vs Intellect":
                    Base.Graph.RenderScalingGraph(g, width, height, character, statsList, new Stats() { Intellect = 5 }, true, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
                case "Scaling vs Spirit":
                    Base.Graph.RenderScalingGraph(g, width, height, character, statsList, new Stats() { Spirit = 5 }, true, statColors, 100, "", "Dps Rating", Base.Graph.Style.Mage);
                    break;
            }
        }
Example #11
0
        public void DrawGUI(System.Drawing.Graphics g, ICodeBlock insertPoint)
        {
            using (Font f = new Font("Segoe UI", 10f))
            {
                using (SolidBrush b = new SolidBrush(Color.FromArgb(103, Color.Black)))
                {
                    if (Global.Debug && insertPoint != null)
                        g.DrawString(insertPoint.Name + ", " + insertPoint.Tag != null ? insertPoint.Tag.ToString() : "", f, b, Point.Empty);
                    SizeF textRect = g.MeasureString("Start: " + _name + "()", f);

                    Rectangle r = normalizeRect(new Rectangle(new Point(PanOffset.X + 150, PanOffset.Y + 50), new Size((int)textRect.Width + 10, (int)textRect.Height + 10)));
                    area = r;
                    guiSize = r.Size;
                    Point[] connector = new Point[4];

                    #region Start

                    b.Color = Color.FromArgb(103, Color.White);

                    connector[0] = new Point(r.X, r.Y + 15);
                    connector[1] = new Point(r.X - 15, r.Y + 15);

                    Classes.DrawingHelpers.DrawBlockBG(g, r, this.Color);
                    g.DrawString("Start: " + _name + "()", f, b, new Point(r.Left + 6, r.Top + 6));
                    b.Color = Color.Black;
                    g.DrawString("Start: " + _name + "()", f, b, new Point(r.Left + 5, r.Top + 5));

                    #endregion

                    #region Code!

                    ICodeBlock lastBlock = this;
                    Point end = new Point(r.Left, r.Bottom);
                    //if (Actions.Count > 0)
                        //area.children = new List<BlockArea>();
                    foreach (ICodeBlock item in Actions)
                    {
                        Point nEnd;
                        item.DrawGuiBlock(g, end, out nEnd, insertPoint);
                        Classes.DrawingHelpers.DrawTab(g, new Point(end.X + 10, end.Y - 1), lastBlock.Color, (insertPoint == lastBlock && lastBlock.Tag.ToString() == "after"));
                        //area.children.Add(item.BlockAreas);
                        lastBlock = item;
                        end = nEnd;
                    }

                    #endregion

                    #region end

                    textRect = g.MeasureString("End: " + _name + "()", f);
                    r = normalizeRect(new Rectangle(end, new Size((int)textRect.Width + 10, (int)textRect.Height + 10)));
                    Classes.DrawingHelpers.DrawBlockBG(g, r, Color.Red);
                    b.Color = Color.FromArgb(103, Color.White);
                    g.DrawString("End: " + _name + "()", f, b, new Point(r.Left + 6, r.Top + 6));

                    b.Color = Color.Black;
                    g.DrawString("End: " + _name + "()", f, b, new Point(r.Left + 5, r.Top + 5));
                    using (Pen connectorPen = new Pen(Color.FromArgb(150,SystemColors.ControlDark), 3f))
                    {
                        connectorPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
                        connector[3] = new Point(r.X, r.Y + 15);
                        connector[2] = new Point(r.X - 15, r.Y + 15);
                        g.DrawLines(connectorPen, connector);

                        int z = connector[1].Y; int x = connector[2].Y;
                        x -= z;
                        x /= 2;
                        int midPoint = x  + z;

                        connectorPen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
                        connectorPen.Width = 5f;
                        Point[] taskline = new Point[] { new Point(connector[1].X - 1, midPoint), new Point(connector[1].X - 15, midPoint) };
                        g.DrawLines(connectorPen, taskline);
                        SizeF texSiz = g.MeasureString("Task \"" + this.Name + "()\":", f);
                        PointF drawPoint = new PointF(taskline[1].X - 5 - texSiz.Width,
                            midPoint - texSiz.Height / 2);

                        g.DrawString("Task \"" + this.Name + "()\":", f, connectorPen.Brush, drawPoint);

                    }
                    #endregion

                    Classes.DrawingHelpers.DrawTab(g, new Point(r.Left + 10, r.Top - 1), lastBlock.Color,
                        insertPoint == lastBlock && lastBlock.Tag.ToString() == "after");
                }
            }
        }
        public override void Paint(System.Drawing.Graphics g)
        {
            PointF[] points = new PointF[5];
            switch(mConnection.From.ConnectorLocation)
            {
                case ConnectorLocations.North:case ConnectorLocations.South:
                    points[0] = mPoints[0];

                    if(mConnection.From.ConnectorLocation == ConnectorLocations.Unknown)
                        points[1] = mPoints[0];
                    else
                        points[1] = mPoints[1];

                    if(mConnection.To==null || mConnection.To.ConnectorLocation == ConnectorLocations.Unknown)
                        points[3] = mPoints[mPoints.Length-1];
                    else
                        points[3] = mPoints[mPoints.Length-2];

                    points[2] = new PointF(points[1].X,points[3].Y);
                    points[4] = mPoints[mPoints.Length-1];

                    g.DrawLines(pen,points);
                    break;
                case ConnectorLocations.East: case ConnectorLocations.West: case ConnectorLocations.Unknown:
                    points[0] = mPoints[0];

                    if(mConnection.From.ConnectorLocation == ConnectorLocations.Unknown)
                        points[1] = mPoints[0];
                    else
                        points[1] = mPoints[1];

                    if(mConnection.To==null || mConnection.To.ConnectorLocation == ConnectorLocations.Unknown)
                        points[3] = mPoints[mPoints.Length-1];
                    else
                        points[3] = mPoints[mPoints.Length-2];

                    points[2] = new PointF(points[3].X,points[1].Y);
                    points[4] = mPoints[mPoints.Length-1];

                    g.DrawLines(pen,points);
                    break;

            }
        }
        /// <summary>
        /// Paints the bundle on the canvas
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(System.Drawing.Graphics g)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            //the shadow

            switch (mCurveType)
            {
                case MultiPointType.Straight:
                    g.DrawLines(ArtPallet.BlackPen, mPoints);
                    break;
                case MultiPointType.Polygon:
                    g.DrawPolygon(ArtPallet.BlackPen, mPoints);
                    break;
                case MultiPointType.Curve:
                    //note that you can specify a tension of the curve here (greater than 0.0F)
                    g.DrawCurve(ArtPallet.BlackPen, mPoints);
                    break;
            }
        }
Example #14
0
        internal override void Draw(System.Drawing.Graphics g, DrawStyle style)
        {
            List<Point> points = new List<Point>();
            for (int i = 0; i < GraphArea.Width; i++)
            {
                double xValue =
                    ValueDimension.MinimumX +
                    (ValueDimension.XDifference / GraphArea.Width) * i;
                double yValue = Function(xValue);
                int yPixel = (int)Math.Abs(
                    (ValueDimension.MinimumY + yValue) *
                    GraphArea.Height / ValueDimension.YDifference);

                if (ValueDimension.IsBetweenYBorders(yValue))
                {   //Add point to list
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Top + yPixel));
                }
                else if (yValue < ValueDimension.MinimumY)
                {
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Bottom));
                }
                else if (yValue > ValueDimension.MaximumY)
                {
                    points.Add(new Point(GraphArea.Left + i, GraphArea.Top));
                }
                //else if (points.Count > 0)
                //{
                //    //Draw all points...
                //    g.DrawLines(LineStyle, points.ToArray());
                //    //...and clear list for next draw point in list
                //    points.Clear();
                //}
            }

            if ((style == DrawStyle.Both) || (style == DrawStyle.Lines))
            {
                if (points.Count > 0)
                    g.DrawLines(LineStyle, points.ToArray());
            }

            //****************************************************************

            points.Add(GraphArea.GetBottomRight());
            points.Add(new Point(GraphArea.Left, GraphArea.Bottom));

            byte[] types = new byte[points.Count];
            for (int i = 0; i < types.Length; i++)
                types[i] = (byte)PathPointType.Line;

            GraphicsPath path = new GraphicsPath(points.ToArray(), types);
            path.CloseAllFigures();

            if ((style == DrawStyle.Both) || (style == DrawStyle.Faces))
            {
                g.FillPath(FillStyle, path);
            }
        }