public bool DrawBackground(TextEditor editor, Gdk.Drawable win, TextViewMargin.LayoutWrapper layout, int selectionStart, int selectionEnd, int startOffset, int endOffset, int y, int startXPos, int endXPos, ref bool drawBg) { drawBg = false; if (selectionStart >= 0 || editor.CurrentMode is TextLinkEditMode) { return(true); } foreach (ISegment usage in Usages) { int markerStart = usage.Offset; int markerEnd = usage.EndOffset; if (markerEnd < startOffset || markerStart > endOffset) { return(true); } int @from; int to; if (markerStart < startOffset && endOffset < markerEnd) { @from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; uint curIndex = 0, byteIndex = 0; TextViewMargin.TranslateToUTF8Index(layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); int x_pos = layout.Layout.IndexToPos((int)byteIndex).X; @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale); TextViewMargin.TranslateToUTF8Index(layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); x_pos = layout.Layout.IndexToPos((int)byteIndex).X; to = startXPos + (int)(x_pos / Pango.Scale.PangoScale); } @from = System.Math.Max(@from, editor.TextViewMargin.XOffset); to = System.Math.Max(to, editor.TextViewMargin.XOffset); if (@from < to) { using (Gdk.GC gc = new Gdk.GC(win)) { gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor; win.DrawRectangle(gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2); gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color; win.DrawRectangle(gc, false, @from, y, to - @from, editor.LineHeight - 1); } } } return(true); }
private void RenderSelection (Gdk.Drawable drawable, Gdk.Rectangle background_area, bool path_selected, StateType state) { if (view == null) { return; } if (path_selected && view.Cr != null) { Gdk.Rectangle rect = background_area; rect.X -= 2; rect.Width += 4; // clear the standard GTK selection and focus drawable.DrawRectangle (view.Style.BaseGC (StateType.Normal), true, rect); // draw the hot cairo selection if (!view.EditingRow) { view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1, background_area.Width - 2, background_area.Height - 2); } } else if (path != null && path.Equals (view.HighlightedPath) && view.Cr != null) { view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1, background_area.Width - 2, background_area.Height - 2, false); } else if (view.NotifyStage.ActorCount > 0 && view.Cr != null) { TreeIter iter; if (view.Model.GetIter (out iter, path) && view.NotifyStage.Contains (iter)) { Actor<TreeIter> actor = view.NotifyStage[iter]; Cairo.Color color = view.Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Active); color.A = Math.Sin (actor.Percent * Math.PI); view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1, background_area.Width - 2, background_area.Height - 2, true, true, color); } } }
protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { Gdk.GC gc = new Gdk.GC(window); int width = cell_area.Width / blockEvent.BlockCount; for (int i = 0; i < blockEvent.BlockCount; i++) { if (blockEvent.AllBlocksReceived) { gc.RgbFgColor = new Gdk.Color(179, 139, 83); // Brown } else if (blockEvent[i].Written) { gc.RgbFgColor = new Gdk.Color(145, 246, 145); // Green } else if (blockEvent[i].Received) { gc.RgbFgColor = new Gdk.Color(232, 176, 6); // Gold } else if (blockEvent[i].Requested) { gc.RgbFgColor = new Gdk.Color(112, 180, 224); // Blue } else { gc.RgbFgColor = new Gdk.Color(248, 227, 212); // Pink } Gdk.Rectangle rect = new Gdk.Rectangle(background_area.X + (width * i), background_area.Y + 1, width, background_area.Height - 2 * 1); window.DrawRectangle(gc, true, rect); } }
// From Mono.TextEditor.FoldMarkerMargin void DrawFoldSegment(Gdk.Drawable win, int x, int y, int w, int h, bool isOpen, bool selected) { Gdk.Rectangle drawArea = new Gdk.Rectangle(x, y, w, h); win.DrawRectangle(selected ? Style.ForegroundGC(StateType.Normal) : Style.BaseGC(StateType.Normal), true, drawArea); win.DrawRectangle(selected ? Style.ForegroundGC(StateType.Normal) : Style.DarkGC(StateType.Normal), false, drawArea); win.DrawLine(selected ? Style.BaseGC(StateType.Normal) : Style.ForegroundGC(StateType.Normal), drawArea.Left + drawArea.Width * 3 / 10, drawArea.Top + drawArea.Height / 2, drawArea.Right - drawArea.Width * 3 / 10, drawArea.Top + drawArea.Height / 2); if (!isOpen) { win.DrawLine(selected ? Style.BaseGC(StateType.Normal) : Style.ForegroundGC(StateType.Normal), drawArea.Left + drawArea.Width / 2, drawArea.Top + drawArea.Height * 3 / 10, drawArea.Left + drawArea.Width / 2, drawArea.Bottom - drawArea.Height * 3 / 10); } }
internal protected override void Draw(Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight) { Gdk.Rectangle drawArea = new Rectangle(x, y, Width, lineHeight); win.DrawRectangle(lineNumberBgGC, true, drawArea); layout.Alignment = Pango.Alignment.Right; layout.Width = Width; if (line < editor.Document.LineCount) { layout.SetText((line + 1).ToString()); win.DrawLayout(editor.Caret.Line == line ? lineNumberHighlightGC : lineNumberGC, x + Width, y, layout); } }
public void DrawCaret(Gdk.Drawable win, Gdk.Rectangle area) { if (Settings.Default.CursorBlink && !caretBlink || HexEditorData.IsSomethingSelected) { return; } if (caretGc == null) { caretGc = new Gdk.GC(win); caretGc.RgbFgColor = new Color(255, 255, 255); caretGc.Function = Gdk.Function.Xor; } long caretY = HexEditorData.Caret.Line * LineHeight - (long)HexEditorData.VAdjustment.Value; int caretX; if (HexEditorData.Caret.InTextEditor) { caretX = textEditorMargin.CalculateCaretXPos(); } else { caretX = hexEditorMargin.CalculateCaretXPos(); } if (!area.Contains(caretX, (int)caretY)) { return; } if (HexEditorData.Caret.IsInsertMode) { win.DrawRectangle(caretGc, true, new Gdk.Rectangle(caretX, (int)caretY, 2, LineHeight)); } else { win.DrawRectangle(caretGc, true, new Gdk.Rectangle(caretX, (int)caretY, textEditorMargin.charWidth, LineHeight)); } }
public void DrawRectangle(int x, int y, int width, int height) { _gc.Foreground = _active; if (x + width > _width) { width--; } if (y + height > _height) { height--; } _window.DrawRectangle(_gc, false, x, y, width, height); }
public override void Draw(TextEditor editor, Gdk.Drawable win, Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos) { int markerStart = LineSegment.Offset + System.Math.Max(StartCol, 0); int markerEnd = LineSegment.Offset + (EndCol < 0? LineSegment.Length : EndCol); if (markerEnd < startOffset || markerStart > endOffset) { return; } int from; int to; if (markerStart < startOffset && endOffset < markerEnd) { from = startXPos; to = endXPos; } else { int start = startOffset < markerStart ? markerStart : startOffset; int end = endOffset < markerEnd ? endOffset : markerEnd; from = startXPos + editor.GetWidth(editor.Document.GetTextAt(startOffset, start - startOffset)); to = startXPos + editor.GetWidth(editor.Document.GetTextAt(startOffset, end - startOffset)); } from = System.Math.Max(from, editor.TextViewMargin.XOffset); to = System.Math.Max(to, editor.TextViewMargin.XOffset); if (from >= to) { return; } using (Gdk.GC gc = new Gdk.GC(win)) { // gc.RgbFgColor = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName); int drawY = y + editor.LineHeight - 1; win.DrawLine(gc, from, drawY, to, drawY); if (@from < to) { //gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor; //win.DrawRectangle (gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2); gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color; win.DrawRectangle(gc, false, @from, y, to - @from, editor.LineHeight - 1); } } }
internal protected override void Draw(Gdk.Drawable win, Gdk.Rectangle area, int line, int x, int y, int lineHeight) { Gdk.Rectangle drawArea = new Gdk.Rectangle(x, y, Width, lineHeight); win.DrawRectangle(backgroundGC, true, drawArea); win.DrawLine(separatorGC, x + Width - 1, drawArea.Top, x + Width - 1, drawArea.Bottom); if (line < editor.Document.LineCount) { LineSegment lineSegment = editor.Document.GetLine(line); foreach (TextMarker marker in lineSegment.Markers) { if (marker is IIconBarMarker) { ((IIconBarMarker)marker).DrawIcon(editor, win, lineSegment, line, x, y, Width, editor.LineHeight); } } if (DrawEvent != null) { DrawEvent(this, new BookmarkMarginDrawEventArgs(editor, win, lineSegment, line, x, y)); } } }
protected override bool OnExposeEvent(Gdk.EventExpose e) { Gdk.Drawable draw = e.Window; Gdk.Rectangle area = e.Area; if (this.categories.Count == 0 || !string.IsNullOrEmpty(CustomMessage)) { Pango.Layout messageLayout = new Pango.Layout(this.PangoContext); messageLayout.Alignment = Pango.Alignment.Center; messageLayout.Width = (int)(Allocation.Width * 2 / 3 * Pango.Scale.PangoScale); if (!string.IsNullOrEmpty(CustomMessage)) { messageLayout.SetText(CustomMessage); } else { messageLayout.SetText(MonoDevelop.Core.GettextCatalog.GetString("There are no tools available for the current document.")); } draw.DrawLayout(Style.TextGC(StateType.Normal), Allocation.Width * 1 / 6, 12, messageLayout); messageLayout.Dispose(); return(true); } Cairo.Context cr = Gdk.CairoHelper.Create(e.Window); draw.DrawRectangle(Style.BaseGC(StateType.Normal), true, area); int xpos = (this.hAdjustement != null ? (int)this.hAdjustement.Value : 0); int vadjustment = (this.vAdjustement != null ? (int)this.vAdjustement.Value : 0); int ypos = -vadjustment; Iterate(ref xpos, ref ypos, delegate(Category category, Gdk.Size itemDimension) { const int foldSegmentHeight = 8; if (category == SelectedItem) { draw.DrawRectangle(Style.BaseGC(StateType.Selected), true, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } else { cr.NewPath(); cr.MoveTo(xpos, ypos); cr.RelLineTo(itemDimension.Width, 0); cr.RelLineTo(0, itemDimension.Height); cr.RelLineTo(-itemDimension.Width, 0); cr.RelLineTo(0, -itemDimension.Height); cr.ClosePath(); using (var pat = new Cairo.LinearGradient(xpos, ypos, xpos, ypos + itemDimension.Height)) { Cairo.Color ccol = Convert(Style.Mid(StateType.Normal)); ccol.A = 0.2; pat.AddColorStop(0, ccol); ccol.A = 1; pat.AddColorStop(1, ccol); cr.Pattern = pat; cr.FillPreserve(); } } DrawFoldSegment(draw, xpos + 2, ypos + (itemDimension.Height - foldSegmentHeight) / 2, foldSegmentHeight, foldSegmentHeight, category.IsExpanded, category == mouseOverItem && mouseX < xpos + 2 + 12); headerLayout.SetText(category.Text); int width, height; layout.GetPixelSize(out width, out height); draw.DrawLayout(Style.TextGC(category != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + 2 + 12, ypos + (itemDimension.Height - height) / 2, headerLayout); if (category == mouseOverItem) { draw.DrawRectangle(Style.DarkGC(StateType.Prelight), false, new Gdk.Rectangle(xpos, ypos, itemDimension.Width - 1, itemDimension.Height - 1)); } }, delegate(Category curCategory, Item item, Gdk.Size itemDimension) { if (item == SelectedItem) { draw.DrawRectangle(Style.BaseGC(StateType.Selected), true, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } if (listMode || !curCategory.CanIconizeItems) { draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), item.Icon, 0, 0, xpos + 4, ypos + 1 + (itemDimension.Height - item.Icon.Height) / 2, item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0); layout.SetText(item.Text); int width, height; layout.GetPixelSize(out width, out height); draw.DrawLayout(Style.TextGC(item != this.SelectedItem ? StateType.Normal : StateType.Selected), xpos + IconSize.Width + 4, ypos + (itemDimension.Height - height) / 2, layout); } else { draw.DrawPixbuf(this.Style.ForegroundGC(StateType.Normal), item.Icon, 0, 0, xpos + (itemDimension.Width - item.Icon.Width) / 2, ypos + (itemDimension.Height - item.Icon.Height) / 2, item.Icon.Width, item.Icon.Height, Gdk.RgbDither.None, 0, 0); } if (item == mouseOverItem) { draw.DrawRectangle(Style.DarkGC(StateType.Prelight), false, new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height)); } }); ((IDisposable)cr).Dispose(); return(true); }
public void draw(Gdk.Drawable da, string datasubtype, bool autoscale = false, double tMin = 0, bool manualscaleMin = false, double manualMin = -999999, bool manualscaleMax = false, double manualMax = 99999999) { try { if (data == null) { return; } if (time.Count < 5) { return; } int width, height; da.GetSize(out width, out height); double maxY, minY; minY = 99999; maxY = -99999; int startIdx = 0; for (int sIdx = 0; sIdx < this.time.Count; sIdx++) { if (this.time[sIdx] <= tMin) { startIdx = sIdx; } } int skip = (int)Math.Max(1, Math.Floor((double)((this.time.Count - startIdx) / 1000))); if (this.probe.measlistAct == null) { this.probe.measlistAct = new bool[this.probe.ChannelMap.Length]; for (int i = 0; i < this.probe.ChannelMap.Length; i++) { this.probe.measlistAct[i] = false; } this.probe.measlistAct[0] = true; } for (int i = 0; i < this.probe.ChannelMap.Length; i++) { for (int j = startIdx; j < this.data[i].Count; j++) { if (this.probe.ChannelMap[i].datasubtype.ToLower().Equals(datasubtype.ToLower())) { if (this.probe.measlistAct[i]) { double d = this.data[i][j]; // Only shown data will define the scale if (maxY < d) { maxY = d; } if (minY > d) { minY = d; } } else if (!autoscale) // This will include all the data in defining the scale { double d = this.data[i][j]; if (maxY < d) { maxY = d; } if (minY > d) { minY = d; } } } } } if (manualscaleMax) { maxY = manualMax; } if (manualscaleMin) { minY = manualMin; } double rangeY = maxY - minY; double rangeX = this.time[this.time.Count - 1] - this.time[startIdx]; int xoffset = 50; int yoffset = 1; height = height - 31; width = width - 51; Gdk.GC gc = new Gdk.GC(da); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); Rectangle rarea = new Rectangle(); rarea.X = xoffset - 1; rarea.Y = yoffset - 1; rarea.Height = height + 2; rarea.Width = width + 2; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Color(0, 0, 0); gc.RgbFgColor = new Color(255, 255, 255); rarea = new Rectangle(); rarea.X = xoffset; rarea.Y = yoffset; rarea.Height = height; rarea.Width = width; da.DrawRectangle(gc, true, rarea); gc.SetLineAttributes(2, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); // Draw stim events for (int j = 0; j < stimulus.Count; j++) { gc.RgbFgColor = stimcolor[j]; Rectangle area = new Rectangle(); for (int k = 0; k < stimulus[j].onsets.Count; k++) { if (stimulus[j].amplitude[k] > 0 & stimulus[j].onsets[k] + stimulus[j].duration[k] >= this.time[startIdx]) { area.Width = (int)(stimulus[j].duration[k] / rangeX * width); if (area.Width == 0) { area.Width = 1; } area.Height = height; area.X = (int)(xoffset + Math.Max((stimulus[j].onsets[k] - this.time[startIdx]), 0) / rangeX * width); area.Y = yoffset; da.DrawRectangle(gc, true, area); } //da.DrawLine(gc,(int)x+xoffset,yoffset,(int)x+xoffset,(int)height+yoffset); } } gc.SetLineAttributes(1, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); for (int i = 0; i < this.probe.ChannelMap.Length; i++) { if (this.probe.measlistAct[i] & this.probe.ChannelMap[i].datasubtype.Equals(datasubtype)) { gc.RgbFgColor = this.probe.colormap[i]; for (int j = 0; j < this.probe.ChannelMap.Length; j++) { if (this.probe.ChannelMap[i].sourceindex == this.probe.ChannelMap[j].sourceindex & this.probe.ChannelMap[i].detectorindex == this.probe.ChannelMap[j].detectorindex & this.probe.ChannelMap[j].datasubtype.Equals(this.probe.ChannelMap[0].datasubtype)) { gc.RgbFgColor = this.probe.colormap[j]; break; } } for (int j = startIdx + skip; j < Math.Min(this.data[i].Count, this.time.Count); j = j + skip) { double y2 = (this.data[i][j] - minY) / rangeY * height; double y1 = (this.data[i][j - skip] - minY) / rangeY * height; double x2 = (this.time[j] - this.time[startIdx]) / rangeX * width; double x1 = (this.time[j - skip] - this.time[startIdx]) / rangeX * width; da.DrawLine(gc, (int)x1 + xoffset, (int)(height - y1 + yoffset), (int)x2 + xoffset, (int)(height - y2 + yoffset)); } } } if (stimulus.Count > 0) { // add legend to window int w = 0; int h = 0; int maxw = 0; for (int j = 0; j < stimulus.Count; j++) { Gtk.Label lab = new Gtk.Label(); gc.RgbFgColor = stimcolor[j]; lab.Text = stimulus[j].name; da.DrawLayout(gc, xoffset + 10, yoffset + j * 10 + 10, lab.Layout); lab.Layout.GetPixelSize(out w, out h); if (w > maxw) { maxw = w; } } gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); rarea = new Rectangle(); rarea.X = xoffset + 4; rarea.Y = yoffset + 4; rarea.Height = stimulus.Count * 10 + 12; rarea.Width = maxw + 12; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); rarea = new Rectangle(); rarea.X = xoffset + 5; rarea.Y = yoffset + 5; rarea.Height = stimulus.Count * 10 + 10; rarea.Width = maxw + 10; da.DrawRectangle(gc, true, rarea); for (int j = 0; j < stimulus.Count; j++) { Gtk.Label lab = new Gtk.Label(); gc.RgbFgColor = stimcolor[j]; lab.Text = stimulus[j].name; da.DrawLayout(gc, xoffset + 10, yoffset + j * 10 + 10, lab.Layout); } } gc.RgbFgColor = new Gdk.Color(0, 0, 0); int numxlabels = 10; int numylabels = 5; // Add Xtick marks to the graph double tstart, tend, dt; tstart = this.time[startIdx]; tend = this.time[this.time.Count - 1]; dt = Math.Round((tend - tstart) / (1 + numxlabels)); if (dt < 1) { dt = 1; } for (double i = 0; i < rangeX; i += dt) { double x = i / rangeX * width; Gtk.Label lab = new Gtk.Label(); lab.Text = String.Format("{0}", Math.Round((tstart + i) * 10) / 10); da.DrawLayout(gc, (int)x + xoffset, (int)height + 2, lab.Layout); } double dy; dy = rangeY / (1 + numylabels); if (dy == 0.0) { dy = 1; } for (double i = 0; i < rangeY; i += dy) { double y = height - i / rangeY * height; Gtk.Label lab = new Gtk.Label(); lab.Text = String.Format("{0}", Math.Round((i + minY) * 10) / 10); da.DrawLayout(gc, 10, (int)y + yoffset, lab.Layout); } } catch { Console.WriteLine("Internal data draw failed"); } }
public void draw1020(Gdk.Drawable da) { if (!this.isregistered) { draw(da); return; } double headcirc = 0; double[,] lsrcpos = project1020(this.SrcPos3D, this.numSrc, out headcirc); double[,] ldetpos = project1020(this.DetPos3D, this.numDet, out headcirc); int width, height; da.GetSize(out width, out height); double dx, dy; dx = 10; dy = 10; width = width - 20; height = height - 20; double maxX = headcirc * 1.2; double minX = -1 * headcirc * 1.2; double maxY = headcirc * 1.2; double minY = -1 * headcirc * 1.2; ROIdrawPos = new double[ROIs.Count, 2]; for (int i = 0; i < ROIs.Count; i++) { ROIdrawPos[i, 0] = minX - .1 * headcirc; ROIdrawPos[i, 1] = minY - .2 * (i) * headcirc; } if (ROIs.Count > 0) { minY = minY - (ROIs.Count) * .2 * headcirc; minX = minX - .1 * headcirc; } double rangeX = maxX - minX; double rangeY = maxY - minY; Gdk.GC gc = new Gdk.GC(da); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); Rectangle rarea = new Rectangle(); rarea.Height = height + 20; rarea.Width = width + 20; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); rarea = new Rectangle(); rarea.Height = height + 18; rarea.Width = width + 18; rarea.X = 1; rarea.Y = 1; da.DrawRectangle(gc, true, rarea); int sz = 10; if (this.measlistAct == null) { this.measlistAct = new bool[this.ChannelMap.Length]; for (int i = 0; i < this.ChannelMap.Length; i++) { this.measlistAct[i] = false; } this.measlistAct[0] = true; } gc.RgbFgColor = new Gdk.Color(0, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); for (int i = 0; i < this.numChannels; i++) { if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype)) { if (this.measlistAct[i]) { gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0); } else { gc.RgbFgColor = new Gdk.Color(230, 230, 230); } int si = this.ChannelMap[i].sourceindex; int di = this.ChannelMap[i].detectorindex; double x1 = (ldetpos[di, 0] - minX) / rangeX * width + dx; double y1 = (ldetpos[di, 1] - minY) / rangeY * height + dy; double x2 = (lsrcpos[si, 0] - minX) / rangeX * width + dx; double y2 = (lsrcpos[si, 1] - minY) / rangeY * height + dy; da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2); //pts[cnt]=new Gdk.Point((int)x,(int)y); } } gc.RgbFgColor = new Gdk.Color(0, 255, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); // Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc]; for (int i = 0; i < this.numDet; i++) { double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); //pts[cnt]=new Gdk.Point((int)x,(int)y); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numDet; i++) { double x = (ldetpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (ldetpos[i, 1] - minY) / rangeY * height + dy - sz / 2; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("D{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 255, 0); gc.RgbFgColor = new Gdk.Color(255, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); for (int i = 0; i < this.numSrc; i++) { double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numSrc; i++) { double x = (lsrcpos[i, 0] - minX) / rangeX * width + dx - sz / 2; double y = (lsrcpos[i, 1] - minY) / rangeY * height + dy - sz / 2; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("S{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); double xx = (0) / rangeX * width + dx; double yy = (0) / rangeY * height + dy; da.DrawArc(gc, false, (int)xx, (int)yy, (int)(width), (int)(height), 0, 360 * 64); gc.RgbFgColor = new Gdk.Color(255, 0, 255); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = ROIs[i].name; da.DrawLayout(gc, (int)(x), (int)y, lab.Layout); } Gtk.Label lab2 = new Gtk.Label(); lab2.Text = "R"; da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout); }
public void draw2D(Gdk.Drawable da) { if (SrcPos == null) { return; } try { int width, height; da.GetSize(out width, out height); double dx, dy; dx = 20; dy = 20; width = width - 2 * (int)dy; height = height - 2 * (int)dx; double maxX, minX, maxY, minY; maxX = -999; maxY = -999; minX = 999; minY = 999; for (int i = 0; i < this.numDet; i++) { if (maxX < this.DetPos[i, 0]) { maxX = this.DetPos[i, 0]; } if (maxY < this.DetPos[i, 1]) { maxY = this.DetPos[i, 1]; } if (minX > this.DetPos[i, 0]) { minX = this.DetPos[i, 0]; } if (minY > this.DetPos[i, 1]) { minY = this.DetPos[i, 1]; } } for (int i = 0; i < this.numSrc; i++) { if (maxX < this.SrcPos[i, 0]) { maxX = this.SrcPos[i, 0]; } if (maxY < this.SrcPos[i, 1]) { maxY = this.SrcPos[i, 1]; } if (minX > this.SrcPos[i, 0]) { minX = this.SrcPos[i, 0]; } if (minY > this.SrcPos[i, 1]) { minY = this.SrcPos[i, 1]; } } ROIdrawPos = new double[ROIs.Count, 2]; for (int i = 0; i < ROIs.Count; i++) { ROIdrawPos[i, 0] = minX - .15 * (maxX - minX); ROIdrawPos[i, 1] = minY - .25 * (i + 1) * (maxY - minY); } if (ROIs.Count > 0) { minY = minY - (ROIs.Count + 1) * .25 * (maxY - minY); minX = minX - .15 * (maxX - minX); } double rangeX = maxX - minX; double rangeY = maxY - minY; Gdk.GC gc = new Gdk.GC(da); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(0, 0, 0); Rectangle rarea = new Rectangle(); rarea.Height = height + 2 * (int)dy; rarea.Width = width + 2 * (int)dx; da.DrawRectangle(gc, true, rarea); gc.RgbBgColor = new Gdk.Color(0, 0, 0); gc.RgbFgColor = new Gdk.Color(255, 255, 255); rarea = new Rectangle(); rarea.Height = height - 2 + 2 * (int)dx;; rarea.Width = width - 2 + 2 * (int)dx;; rarea.X = 1; rarea.Y = 1; da.DrawRectangle(gc, true, rarea); int sz = 10; if (this.measlistAct == null) { this.measlistAct = new bool[this.ChannelMap.Length]; for (int i = 0; i < this.ChannelMap.Length; i++) { this.measlistAct[i] = false; } this.measlistAct[0] = true; } gc.RgbFgColor = new Gdk.Color(0, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Projecting, JoinStyle.Round); for (int i = 0; i < this.numChannels; i++) { if (this.ChannelMap[i].datasubtype.Equals(this.ChannelMap[0].datasubtype)) { if (this.measlistAct[i]) { gc.RgbFgColor = colormap[i]; //new Gdk.Color (0, 0, 0); } else { gc.RgbFgColor = new Gdk.Color(230, 230, 230); } int si = this.ChannelMap[i].sourceindex; int di = this.ChannelMap[i].detectorindex; double x1 = (this.DetPos[di, 0] - minX) / rangeX * width; double y1 = height - ((this.DetPos[di, 1] - minY) / rangeY * height) + dy; double x2 = (this.SrcPos[si, 0] - minX) / rangeX * width; double y2 = height - ((this.SrcPos[si, 1] - minY) / rangeY * height) + dy; da.DrawLine(gc, (int)x1, (int)y1, (int)x2, (int)y2); //pts[cnt]=new Gdk.Point((int)x,(int)y); } } gc.RgbFgColor = new Gdk.Color(0, 255, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); // Gdk.Point[] pts = new Gdk.Point[this.numdet+this.numsrc]; for (int i = 0; i < this.numDet; i++) { double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); //pts[cnt]=new Gdk.Point((int)x,(int)y); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numDet; i++) { double x = (this.DetPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.DetPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("D{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbBgColor = new Gdk.Color(0, 255, 0); gc.RgbFgColor = new Gdk.Color(255, 0, 0); gc.SetLineAttributes(3, LineStyle.Solid, CapStyle.Round, JoinStyle.Round); for (int i = 0; i < this.numSrc; i++) { double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < this.numSrc; i++) { double x = (this.SrcPos[i, 0] - minX) / rangeX * width - sz / 2; double y = height - ((this.SrcPos[i, 1] - minY) / rangeY * height) - sz / 2 + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = string.Format("S{0}", i + 1); da.DrawLayout(gc, (int)x, (int)y, lab.Layout); } gc.RgbFgColor = new Gdk.Color(255, 0, 255); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz / 2; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; da.DrawArc(gc, true, (int)x, (int)y, sz, sz, 0, 360 * 64); } gc.RgbFgColor = new Gdk.Color(0, 0, 0); for (int i = 0; i < ROIs.Count; i++) { double x = (ROIdrawPos[i, 0] - minX) / rangeX * width + sz; double y = height - ((ROIdrawPos[i, 1] - minY) / rangeY * height) + dy; Gtk.Label lab = new Gtk.Label(); lab.Text = ROIs[i].name; da.DrawLayout(gc, (int)(x), (int)y, lab.Layout); } Gtk.Label lab2 = new Gtk.Label(); lab2.Text = "L"; da.DrawLayout(gc, (int)(width - 5), (int)(height - 5), lab2.Layout); } catch { } return; }