void DrawCursor(ChartCursor cursor) { Gdk.GC gc = new Gdk.GC(GdkWindow); gc.RgbFgColor = cursor.Color; int x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { int cy = top - AreaBorderWidth - 1; Point[] ps = new Point [4]; ps [0] = new Point(x, cy); ps [1] = new Point(x + (cursor.HandleSize / 2), cy - cursor.HandleSize + 1); ps [2] = new Point(x - (cursor.HandleSize / 2), cy - cursor.HandleSize + 1); ps [3] = ps [0]; GdkWindow.DrawPolygon(gc, false, ps); if (activeCursor == cursor) { GdkWindow.DrawPolygon(gc, true, ps); } GdkWindow.DrawLine(gc, x, top, x, top + height); } else { throw new NotSupportedException(); } }
void DrawCursor(Context ctx, ChartCursor cursor) { ctx.SetColor(cursor.Color); double x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { double cy = top - AreaBorderWidth - 1; ctx.MoveTo(x, cy); ctx.LineTo(x + (cursor.HandleSize / 2), cy - cursor.HandleSize + 1); ctx.LineTo(x - (cursor.HandleSize / 2), cy - cursor.HandleSize + 1); ctx.ClosePath(); if (activeCursor == cursor) { ctx.FillPreserve(); } ctx.Stroke(); ctx.MoveTo(x, top); ctx.RelLineTo(0, height); ctx.Stroke(); } else { throw new NotSupportedException(); } }
public void RemoveCursor(ChartCursor cursor) { cursor.ValueChanged -= new EventHandler(OnCursorChanged); cursor.LayoutChanged -= new EventHandler(OnCursorChanged); cursors.Remove(cursor); QueueDraw(); }
public void AddCursor(ChartCursor cursor, AxisDimension dimension) { cursor.Dimension = dimension; cursor.ValueChanged += new EventHandler(OnCursorChanged); cursor.LayoutChanged += new EventHandler(OnCursorChanged); cursors.Add(cursor); xrangeChanged = yrangeChanged = true; QueueDraw(); }
void DrawCursorLabel(Context ctx, ChartCursor cursor) { ctx.SetColor(cursor.Color); int x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep(cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator(minStep); tenum.Init(cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel(cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { TextLayout layout = new TextLayout(ctx); layout.Font = chartFont; layout.Text = text; Size ts = layout.GetSize(); double tl = x - ts.Width / 2; double tt = top + 4; if (tl + ts.Width + 2 >= left + width) { tl = left + width - ts.Width - 1; } if (tl < left + 1) { tl = left + 1; } ctx.SetColor(Colors.White); ctx.Rectangle(tl - 1, tt - 1, ts.Width + 2, ts.Height + 2); ctx.Fill(); ctx.Rectangle(tl - 2, tt - 2, ts.Width + 3, ts.Height + 3); ctx.SetColor(Colors.Black); ctx.DrawTextLayout(layout, tl, tt); } } else { throw new NotSupportedException(); } }
public BasicChart() { selectionStart = new ChartCursor(); selectionStart.Visible = false; selectionEnd = new ChartCursor(); selectionEnd.Visible = false; AddCursor(selectionStart, AxisDimension.X); AddCursor(selectionEnd, AxisDimension.X); selectionStart.ValueChanged += new EventHandler(OnSelectionCursorChanged); selectionEnd.ValueChanged += new EventHandler(OnSelectionCursorChanged); }
public BasicChart () { selectionStart = new ChartCursor (); selectionStart.Visible = false; selectionEnd = new ChartCursor (); selectionEnd.Visible = false; AddCursor (selectionStart, AxisDimension.X); AddCursor (selectionEnd, AxisDimension.X); selectionStart.ValueChanged += new EventHandler (OnSelectionCursorChanged); selectionEnd.ValueChanged += new EventHandler (OnSelectionCursorChanged); }
void DrawCursorLabel(ChartCursor cursor) { using (Gdk.GC gc = new Gdk.GC(GdkWindow)) { gc.RgbFgColor = cursor.Color; int x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep(cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator(minStep); tenum.Init(cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel(cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = IdeServices.FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11); layout.SetMarkup(text); int tw, th; layout.GetPixelSize(out tw, out th); int tl = x - tw / 2; int tt = top + 4; if (tl + tw + 2 >= left + width) { tl = left + width - tw - 1; } if (tl < left + 1) { tl = left + 1; } GdkWindow.DrawRectangle(Style.WhiteGC, true, tl - 1, tt - 1, tw + 2, th + 2); GdkWindow.DrawRectangle(Style.BlackGC, false, tl - 2, tt - 2, tw + 3, th + 3); GdkWindow.DrawLayout(gc, tl, tt, layout); layout.Dispose(); } } else { throw new NotSupportedException(); } } }
public ChartWidget() { this.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask; selectionStart = new ChartCursor(); selectionStart.Visible = false; selectionEnd = new ChartCursor(); selectionEnd.Visible = false; AddCursor(selectionStart, AxisDimension.X); AddCursor(selectionEnd, AxisDimension.X); selectionStart.ValueChanged += new EventHandler(OnSelectionCursorChanged); selectionEnd.ValueChanged += new EventHandler(OnSelectionCursorChanged); }
public BasicChart () { this.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask; selectionStart = new ChartCursor (); selectionStart.Visible = false; selectionEnd = new ChartCursor (); selectionEnd.Visible = false; AddCursor (selectionStart, AxisDimension.X); AddCursor (selectionEnd, AxisDimension.X); selectionStart.ValueChanged += new EventHandler (OnSelectionCursorChanged); selectionEnd.ValueChanged += new EventHandler (OnSelectionCursorChanged); }
void OnSelectionCursorChanged(object sender, EventArgs args) { if (enableSelection) { if (selectionStart.Value > selectionEnd.Value) { ChartCursor tmp = selectionStart; selectionStart = selectionEnd; selectionEnd = tmp; } chart.OnSelectionChanged(); } }
protected override void OnButtonPressed(ButtonEventArgs ev) { if (ev.Button == PointerButton.Left) { foreach (ChartCursor cursor in cursors) { int cx, cy; GetPoint(cursor.Value, cursor.Value, out cx, out cy); if (cursor.Dimension == AxisDimension.X) { if (Math.Abs(ev.X - cx) <= 2 || (ev.Y < top && (Math.Abs(ev.X - cx) <= cursor.HandleSize / 2))) { activeCursor = cursor; draggingCursor = true; activeCursor.ShowValueLabel = true; QueueDraw(); break; } } else { // Implement } } if (enableSelection && !draggingCursor) { selectionStart.Visible = true; selectionEnd.Visible = true; double x, y; GetValue((int)ev.X, (int)ev.Y, out x, out y); // avoid cursor swaping ChartCursor c1 = selectionStart; ChartCursor c2 = selectionEnd; c1.Value = x; c2.Value = x; activeCursor = selectionEnd; activeCursor.ShowValueLabel = true; draggingCursor = true; QueueDraw(); } if (draggingCursor) { return; } } base.OnButtonPressed(ev); return; }
void OnCursorChanged(object sender, EventArgs args) { ChartCursor c = (ChartCursor)sender; if (c.Value < GetStart(c.Dimension)) { c.Value = GetStart(c.Dimension); } else if (c.Value > GetEnd(c.Dimension)) { c.Value = GetEnd(c.Dimension); } QueueDraw(); }
protected override bool OnButtonPressEvent(Gdk.EventButton ev) { if (!ev.TriggersContextMenu() && ev.Button == 1) { foreach (ChartCursor cursor in cursors) { int cx, cy; GetPoint(cursor.Value, cursor.Value, out cx, out cy); if (cursor.Dimension == AxisDimension.X) { if (Math.Abs(ev.X - cx) <= 2 || (ev.Y < top && (Math.Abs(ev.X - cx) <= cursor.HandleSize / 2))) { activeCursor = cursor; draggingCursor = true; activeCursor.ShowValueLabel = true; QueueDraw(); break; } } else { // Implement } } if (enableSelection && !draggingCursor) { selectionStart.Visible = true; selectionEnd.Visible = true; double x, y; GetValue((int)ev.X, (int)ev.Y, out x, out y); // avoid cursor swaping ChartCursor c1 = selectionStart; ChartCursor c2 = selectionEnd; c1.Value = x; c2.Value = x; activeCursor = selectionEnd; activeCursor.ShowValueLabel = true; draggingCursor = true; QueueDraw(); } if (draggingCursor) { return(true); } } return(base.OnButtonPressEvent(ev)); }
public void RemoveCursor(ChartCursor cursor) { cursor.ValueChanged -= new EventHandler (OnCursorChanged); cursor.LayoutChanged -= new EventHandler (OnCursorChanged); cursors.Remove (cursor); QueueDraw (); }
void DrawCursor (Context ctx, ChartCursor cursor) { ctx.SetColor (cursor.Color); double x, y; GetPoint (cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { double cy = top - AreaBorderWidth - 1; ctx.MoveTo (x, cy); ctx.LineTo (x + (cursor.HandleSize/2), cy - cursor.HandleSize + 1); ctx.LineTo (x - (cursor.HandleSize/2), cy - cursor.HandleSize + 1); ctx.ClosePath (); if (activeCursor == cursor) ctx.FillPreserve (); ctx.Stroke (); ctx.MoveTo (x, top); ctx.RelLineTo (0, height); ctx.Stroke (); } else { throw new NotSupportedException (); } }
public void RemoveCursor(ChartCursor cursor) { widget.RemoveCursor(cursor); }
public void AddCursor(ChartCursor cursor, AxisDimension dimension) { widget.AddCursor(cursor, dimension); }
void DrawCursorLabel (Context ctx, ChartCursor cursor) { ctx.SetColor (cursor.Color); int x, y; GetPoint (cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep (cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator (minStep); tenum.Init (cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel (cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { TextLayout layout = new TextLayout (); layout.Font = chartFont; layout.Text = text; Size ts = layout.GetSize (); double tl = x - ts.Width/2; double tt = top + 4; if (tl + ts.Width + 2 >= left + width) tl = left + width - ts.Width - 1; if (tl < left + 1) tl = left + 1; ctx.SetColor (Colors.White); ctx.Rectangle (tl - 1, tt - 1, ts.Width + 2, ts.Height + 2); ctx.Fill (); ctx.Rectangle (tl - 2, tt - 2, ts.Width + 3, ts.Height + 3); ctx.SetColor (Colors.Black); ctx.DrawTextLayout (layout, tl, tt); } } else { throw new NotSupportedException (); } }
public void AddCursor(ChartCursor cursor, AxisDimension dimension) { cursor.Dimension = dimension; cursor.ValueChanged += new EventHandler (OnCursorChanged); cursor.LayoutChanged += new EventHandler (OnCursorChanged); cursors.Add (cursor); xrangeChanged = yrangeChanged = true; QueueDraw (); }
void OnSelectionCursorChanged(object sender, EventArgs args) { if (enableSelection) { if (selectionStart.Value > selectionEnd.Value) { ChartCursor tmp = selectionStart; selectionStart = selectionEnd; selectionEnd = tmp; } OnSelectionChanged (); } }
void DrawCursorLabel(ChartCursor cursor) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = cursor.Color; int x, y; GetPoint (cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep (cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator (minStep); tenum.Init (cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel (cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { Pango.Layout layout = new Pango.Layout (this.PangoContext); layout.FontDescription = Pango.FontDescription.FromString ("Tahoma 8"); layout.SetMarkup (text); int tw, th; layout.GetPixelSize (out tw, out th); int tl = x - tw/2; int tt = top + 4; if (tl + tw + 2 >= left + width) tl = left + width - tw - 1; if (tl < left + 1) tl = left + 1; GdkWindow.DrawRectangle (Style.WhiteGC, true, tl - 1, tt - 1, tw + 2, th + 2); GdkWindow.DrawRectangle (Style.BlackGC, false, tl - 2, tt - 2, tw + 3, th + 3); GdkWindow.DrawLayout (gc, tl, tt, layout); } } else { throw new NotSupportedException (); } }
void DrawCursor(ChartCursor cursor) { Gdk.GC gc = new Gdk.GC (GdkWindow); gc.RgbFgColor = cursor.Color; int x, y; GetPoint (cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { int cy = top - AreaBorderWidth - 1; Point[] ps = new Point [4]; ps [0] = new Point (x, cy); ps [1] = new Point (x + (cursor.HandleSize/2), cy - cursor.HandleSize + 1); ps [2] = new Point (x - (cursor.HandleSize/2), cy - cursor.HandleSize + 1); ps [3] = ps [0]; GdkWindow.DrawPolygon (gc, false, ps); if (activeCursor == cursor) GdkWindow.DrawPolygon (gc, true, ps); GdkWindow.DrawLine (gc, x, top, x, top + height); } else { throw new NotSupportedException (); } }
public void RemoveCursor (ChartCursor cursor) { widget.RemoveCursor (cursor); }
protected override bool OnButtonPressEvent(Gdk.EventButton ev) { if (!ev.TriggersContextMenu () && ev.Button == 1) { foreach (ChartCursor cursor in cursors) { int cx, cy; GetPoint (cursor.Value, cursor.Value, out cx, out cy); if (cursor.Dimension == AxisDimension.X) { if (Math.Abs (ev.X - cx) <= 2 || (ev.Y < top && (Math.Abs (ev.X - cx) <= cursor.HandleSize/2))) { activeCursor = cursor; draggingCursor = true; activeCursor.ShowValueLabel = true; QueueDraw (); break; } } else { // Implement } } if (enableSelection && !draggingCursor) { selectionStart.Visible = true; selectionEnd.Visible = true; double x, y; GetValue ((int)ev.X, (int)ev.Y, out x, out y); // avoid cursor swaping ChartCursor c1 = selectionStart; ChartCursor c2 = selectionEnd; c1.Value = x; c2.Value = x; activeCursor = selectionEnd; activeCursor.ShowValueLabel = true; draggingCursor = true; QueueDraw (); } if (draggingCursor) return true; } return base.OnButtonPressEvent (ev); }
public void AddCursor (ChartCursor cursor, AxisDimension dimension) { widget.AddCursor (cursor, dimension); }