Beispiel #1
0
	/* F  H I T  T E S T */
	/*----------------------------------------------------------------------------
		%%Function: FHitTest
		%%Qualified: bg.SBGE.FHitTest
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	public bool FHitTest(Point ptClient, out object oHit, out RectangleF rectfHit)
	{
		rectfHit = new RectangleF();;
		PTFI ptfiHit;

		// figure out what we hit.

		// convert the pt into a raw point compatible with our array
		PointF ptfArray = new PointF(((float)ptClient.X) + m_dxAdjust, (float)ptClient.Y);

		ptfiHit = new PTFI();
		bool fHit = false;

		// now we can go searching for a point this corresponds to
		foreach (PTFI ptfi in m_plptfi)
			{
			rectfHit = new RectangleF(ptfi.ptf.X - 4.0F, ptfi.ptf.Y - 4.0F, 8.0F, 8.0F);

			if (!rectfHit.Contains(ptfArray))
				continue;

			fHit = true;
			ptfiHit = ptfi;

			break;
			}

		oHit = ptfiHit;
		return fHit;
	}
Beispiel #2
0
		/* H O V E R  G R A P H */
		/*----------------------------------------------------------------------------
			%%Function: HoverGraph
			%%Qualified: bg.BgGraph.HoverGraph
			%%Contact: rlittle

		----------------------------------------------------------------------------*/
		private void HoverGraph(object sender, System.EventArgs e)
		{
			PictureBox pb = (PictureBox)sender;

			if (BvFromPb(pb) != BoxView.Graph)
				return;

			Grapher grph = (Grapher)pb.Tag;

			Point ptRaw = Cursor.Position;
			Point pt =  pb.PointToClient(ptRaw);

			PTFI ptfiHit = new PTFI();
			bool fHit = false;
			RectangleF rectfHit;
			object oHit;

			fHit = grph.FHitTest(pt, out oHit, out rectfHit);
			ptfiHit = (PTFI)oHit;
			if (fHit)
				{
				if (m_ch == null)
					m_ch = new Hover();
				m_ch.ShowTip(ptRaw, ptfiHit.bge);
				this.Focus();
				m_fTipShowing = true;
				m_rectfTipHitRegion = rectfHit;
				}

			this.Focus();

			// now lets register for this again
			user32.TRACKMOUSEEVENT tme = new user32.TRACKMOUSEEVENT();

			tme.cbSize = Marshal.SizeOf(tme);
			tme.dwFlags = 1;
			tme.dwHoverTime = -1;
			tme.hwndTrack = pb.Handle;
			user32.TrackMouseEvent(ref tme);
		}
Beispiel #3
0
	public void PaintGraph(Graphics gr)
	{
		int i, iLast;

		int dxAdjust = (int)(m_iFirstQuarter * m_dxQuarter);	// how much should 0 based x-coordinates be adjusted?

		Pen penMeal = new Pen(Color.Green, m_dzaLineWidth);
		Pen penBlueThin = new Pen(Color.LightBlue, (float)0.5);
		Pen penBlue = new Pen(Color.Blue, (float)1);
		Pen penGrid = new Pen(Color.DarkGray, (float)1);
		Pen penLightGrid = new Pen(Color.LightGray, (float)1);

		SolidBrush brushBlue = new SolidBrush(Color.Blue);

		if (m_fWgtAvg)
			{
            brushBlue = new SolidBrush(Color.Red);
			penBlue = new Pen(Color.Red, (float)1);
			}

		double dxFirstQuarter = m_iFirstQuarter * m_dxQuarter + (m_dxOffset + m_rcfDrawing.Left/*m_dxLeftMargin*/);
		double dxLastQuarter = dxFirstQuarter + (m_cgp.nHalfDays * 12 * 4) * m_dxQuarter;

		RectangleF rectfGraphBodyClip = new RectangleF(m_dxOffset + m_rcfDrawing.Left, 
													   m_rcfDrawing.Top, // m_dyOffset + 
													   m_rcfDrawing.Width - m_dxOffset,
													   m_rcfDrawing.Height - m_dyOffset); 

		gr.SetClip(rectfGraphBodyClip);
		// ------------------------------
		// THIRD: Graph the points
		// ------------------------------

		PTFI ptfiLastMeal = new PTFI();
		PTFI ptfi;

		ptfiLastMeal.bge = null;

		for (i = 0, iLast = m_plptfi.Count; i < iLast; i++)
			{
			PointF ptf;

			ptfi = ((PTFI)m_plptfi[i]);
			ptf = ptfi.ptf;

			// if its before our first point, skip it
			if (ptf.X < dxFirstQuarter)
				continue;

			if (ptf.Y == -1.0F && ptfi.bge.Reading == 0)
				{
				// lets get a real Y value for this by plotting a line on the curve
				if (i > 0)
					ptf.Y = ((PTFI)m_plptfi[i-1]).ptf.Y;
				else if (i < iLast)
					ptf.Y = ((PTFI)m_plptfi[i+1]).ptf.Y;
				else
					ptf.Y = 0;
				ptfi.ptf = ptf;
				m_plptfi[i] = ptfi;
				}

			if (ptfiLastMeal.bge != null && m_cgp.fShowMeals)
				{
				if (ptfiLastMeal.bge.Date.AddMinutes(90.0) <= ptfi.bge.Date
					&& ptfiLastMeal.bge.Date.AddMinutes(150.0) >= ptfi.bge.Date)
					{
					float yAdjust;
					float xLast = ptfiLastMeal.ptf.X - dxAdjust;
					float yLast = ptfiLastMeal.ptf.Y;

					yAdjust = ptf.Y - yLast;

					if (yAdjust < 0.0F)
						yAdjust -= 15.0F;
					else
						yAdjust += 15.0F;

					// we have a match
					gr.DrawLine(penMeal, xLast + m_dzaLineWidth, yLast, xLast + m_dzaLineWidth, yLast + yAdjust);
					gr.DrawLine(penMeal, xLast + m_dzaLineWidth, yLast + yAdjust, ptf.X + m_dzaLineWidth - dxAdjust, yLast + yAdjust);
					gr.DrawLine(penMeal, ptf.X + m_dzaLineWidth - dxAdjust, yLast + yAdjust, ptf.X + m_dzaLineWidth - dxAdjust, ptf.Y + m_dzaLineWidth);
					ptfiLastMeal.bge = null;
					}
				else if (ptfiLastMeal.bge.Date.AddHours(150.0) < ptfi.bge.Date)
					ptfiLastMeal.bge = null;
				}

			if (ptfi.bge.Type != BGE.ReadingType.SpotTest)
				ptfiLastMeal = ptfi;

			if (ptf.X > dxLastQuarter)
				break;

			if (ptfi.bge.InterpReading)
				gr.DrawEllipse(penBlueThin, ptf.X - m_dzaLineWidth - dxAdjust, ptf.Y - m_dzaLineWidth, m_dzaLineWidth * 4.0f, m_dzaLineWidth * 4.0f);
			else
				gr.FillEllipse(brushBlue, ptf.X - m_dzaLineWidth - dxAdjust, ptf.Y - m_dzaLineWidth, m_dzaLineWidth * 4.0f, m_dzaLineWidth * 4.0f);

			if (i > 0)
				{
				PointF ptfLast = ((PTFI)m_plptfi[i - 1]).ptf;

				if (ptfLast.X >= dxFirstQuarter)
					gr.DrawLine(penBlue,  ptfLast.X + 1 - dxAdjust, ptfLast.Y + 1, ptf.X + 1 - dxAdjust, ptf.Y + 1);

				}
			}
		// if we were doing the translucent range shading, we'd do it here.
//			ShadeRanges(pb, gr);
		gr.ResetClip();
		m_dxAdjust = dxAdjust;
	}