void DrawLineBox(Gdk.GC gc, Cairo.Context ctx, int right, int top, int line, Gtk.Widget widget, Gdk.Drawable window) { layout.SetText(""); layout.SetMarkup("<small>" + line.ToString() + "</small>"); int tw, th; layout.GetPixelSize(out tw, out th); th--; int dy = (lineHeight - th) / 2; ctx.Rectangle(right - tw - 2 + 0.5, top + dy - 1 + 0.5, tw + 2, th + 2); ctx.LineWidth = 1; ctx.SetSourceColor(widget.Style.Base(Gtk.StateType.Normal).ToCairoColor()); ctx.FillPreserve(); ctx.SetSourceColor(Styles.LogView.DiffBoxBorderColor.ToCairoColor()); ctx.Stroke(); window.DrawLayout(gc, right - tw - 1, top + dy, layout); }
void DrawCodeSegmentBorder(Gdk.GC gc, Cairo.Context ctx, double x, int width, BlockInfo firstBlock, BlockInfo lastBlock, string[] lines, Gtk.Widget widget, Gdk.Drawable window) { int shadowSize = 2; int spacing = 4; int bottomSpacing = (lineHeight - spacing) / 2; ctx.Rectangle(x + shadowSize + 0.5, firstBlock.YStart + bottomSpacing + spacing - shadowSize + 0.5, width - shadowSize * 2, shadowSize); ctx.SetSourceColor(Styles.LogView.DiffBoxSplitterColor.ToCairoColor()); ctx.LineWidth = 1; ctx.Fill(); ctx.Rectangle(x + shadowSize + 0.5, lastBlock.YEnd + bottomSpacing + 0.5, width - shadowSize * 2, shadowSize); ctx.SetSourceColor(Styles.LogView.DiffBoxSplitterColor.ToCairoColor()); ctx.Fill(); ctx.Rectangle(x + 0.5, firstBlock.YStart + bottomSpacing + spacing + 0.5, width, lastBlock.YEnd - firstBlock.YStart - spacing); ctx.SetSourceColor(Styles.LogView.DiffBoxBorderColor.ToCairoColor()); ctx.Stroke(); string text = lines[firstBlock.FirstLine].Replace("@", "").Replace("-", ""); text = "<span size='x-small'>" + text.Replace("+", "</span><span size='small'>➜</span><span size='x-small'> ") + "</span>"; layout.SetText(""); layout.SetMarkup(text); int tw, th; layout.GetPixelSize(out tw, out th); th--; int dy = (lineHeight - th) / 2; ctx.Rectangle(x + 2 + LeftPaddingBlock - 1 + 0.5, firstBlock.YStart + dy - 1 + 0.5, tw + 2, th + 2); ctx.LineWidth = 1; ctx.SetSourceColor(widget.Style.Base(StateType.Normal).ToCairoColor()); ctx.FillPreserve(); ctx.SetSourceColor(Styles.LogView.DiffBoxBorderColor.ToCairoColor()); ctx.Stroke(); window.DrawLayout(gc, (int)(x + 2 + LeftPaddingBlock), firstBlock.YStart + dy, layout); }
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"); } }
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); }
protected override void Render(Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { StateType state = RendererStateToWidgetState(flags); int text_indent = 6; int text_layout_width, text_layout_height; Gdk.Pixbuf render_icon = radio_icon; Track track = null; RadioTrackInfo radio_track = null; string text = Text; if (widget is TreeView) { TreePath path; if ((widget as TreeView).GetPathAtPos(cell_area.X, cell_area.Y, out path)) { track = model.GetTrack(path); radio_track = model.GetRadioTrackInfo(path); } } FontDescription font_description = widget.PangoContext.FontDescription.Copy(); if (playing_icon != null && track != null && PlayerEngineCore.CurrentTrack is RadioTrackInfo && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Title == track.Title && (PlayerEngineCore.CurrentTrack as RadioTrackInfo).XspfTrack.Annotation == track.Annotation) { render_icon = playing_icon; font_description.Style = Pango.Style.Normal; font_description.Weight = Pango.Weight.Bold; } else if (radio_track != null && radio_track.ParsingPlaylist) { render_icon = loading_icon; font_description.Style = Pango.Style.Italic; font_description.Weight = Pango.Weight.Normal; text = String.Format("{0}: {1}", Catalog.GetString("Loading"), Text); } else if (radio_track != null && radio_track.PlaybackError != TrackPlaybackError.None) { render_icon = error_icon; font_description.Style = Pango.Style.Italic; font_description.Weight = Pango.Weight.Normal; string prefix = null; switch (radio_track.PlaybackError) { case TrackPlaybackError.ResourceNotFound: prefix = Catalog.GetString("Missing"); break; case TrackPlaybackError.CodecNotFound: prefix = Catalog.GetString("No Codec"); break; case TrackPlaybackError.Unknown: prefix = Catalog.GetString("Unknown Error"); break; default: break; } if (prefix != null) { text = String.Format("({0}) {1}", prefix, Text); } if (!(CellRendererState.Selected & flags).Equals(CellRendererState.Selected)) { state = StateType.Insensitive; } if (track != null) { track.Title = String.Empty; } } else { font_description.Style = Pango.Style.Normal; font_description.Weight = Pango.Weight.Normal; } Gdk.GC main_gc = widget.Style.TextGC(state); if (track != null) { drawable.DrawPixbuf(main_gc, render_icon, 0, 0, cell_area.X - render_icon.Width, cell_area.Y + ((cell_area.Height - render_icon.Height) / 2), render_icon.Width, render_icon.Height, RgbDither.None, 0, 0); } else { text_indent = 0; } Pango.Layout text_layout = new Pango.Layout(widget.PangoContext); text_layout.FontDescription = font_description; text_layout.SetMarkup(GLib.Markup.EscapeText(text)); text_layout.GetPixelSize(out text_layout_width, out text_layout_height); drawable.DrawLayout(main_gc, cell_area.X + text_indent, cell_area.Y + ((cell_area.Height - text_layout_height) / 2), text_layout); }
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; }
protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (source == null) { return; } view = widget as SourceView; bool path_selected = view != null && view.Selection.PathIsSelected (path); StateType state = RendererStateToWidgetState (widget, flags); RenderSelection (drawable, background_area, path_selected, state); int title_layout_width = 0, title_layout_height = 0; int count_layout_width = 0, count_layout_height = 0; int max_title_layout_width; bool hide_counts = source.Count <= 0; Pixbuf icon = SourceIconResolver.ResolveIcon (source, RowHeight); if (state == StateType.Insensitive) { // Code ported from gtk_cell_renderer_pixbuf_render() var icon_source = new IconSource () { Pixbuf = icon, Size = IconSize.SmallToolbar, SizeWildcarded = false }; icon = widget.Style.RenderIcon (icon_source, widget.Direction, state, (IconSize)(-1), widget, "SourceRowRenderer"); } FontDescription fd = widget.PangoContext.FontDescription.Copy (); fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source ? Pango.Weight.Bold : Pango.Weight.Normal; if (view != null && source == view.NewPlaylistSource) { fd.Style = Pango.Style.Italic; hide_counts = true; } Pango.Layout title_layout = new Pango.Layout (widget.PangoContext); Pango.Layout count_layout = null; if (!hide_counts) { count_layout = new Pango.Layout (widget.PangoContext); count_layout.FontDescription = fd; count_layout.SetMarkup (String.Format ("<span size=\"small\">{0}</span>", source.Count)); count_layout.GetPixelSize (out count_layout_width, out count_layout_height); } max_title_layout_width = cell_area.Width - (icon == null ? 0 : icon.Width) - count_layout_width - 10; if (!hide_counts && max_title_layout_width < 0) { hide_counts = true; } title_layout.FontDescription = fd; title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale); title_layout.Ellipsize = EllipsizeMode.End; title_layout.SetText (source.Name); title_layout.GetPixelSize (out title_layout_width, out title_layout_height); Gdk.GC main_gc = widget.Style.TextGC (state); drawable.DrawLayout (main_gc, cell_area.X + (icon == null ? 0 : icon.Width) + 6, Middle (cell_area, title_layout_height), title_layout); if (icon != null) { drawable.DrawPixbuf (main_gc, icon, 0, 0, cell_area.X, Middle (cell_area, icon.Height), icon.Width, icon.Height, RgbDither.None, 0, 0); } if (hide_counts) { return; } Gdk.GC mod_gc = widget.Style.TextGC (state); if (state == StateType.Normal || (view != null && state == StateType.Prelight)) { Gdk.Color fgcolor = widget.Style.Base (state); Gdk.Color bgcolor = widget.Style.Text (state); mod_gc = new Gdk.GC (drawable); mod_gc.Copy (widget.Style.TextGC (state)); mod_gc.RgbFgColor = Hyena.Gui.GtkUtilities.ColorBlend (fgcolor, bgcolor); mod_gc.RgbBgColor = fgcolor; } drawable.DrawLayout (mod_gc, cell_area.X + cell_area.Width - count_layout_width - 2, Middle (cell_area, count_layout_height), count_layout); }
protected override void Render(Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { if (source == null || source is SourceManager.GroupSource) { return; } view = widget as SourceView; bool selected = view != null && view.Selection.IterIsSelected(iter); StateType state = RendererStateToWidgetState(widget, flags); RenderSelection(drawable, background_area, selected, state); int title_layout_width = 0, title_layout_height = 0; int count_layout_width = 0, count_layout_height = 0; int max_title_layout_width; int img_padding = 6; int expander_icon_spacing = 3; int x = cell_area.X; bool np_etc = (source.Order + Depth * 100) < 40; if (!np_etc) { x += Depth * img_padding + (int)Xpad; } else { // Don't indent NowPlaying and Play Queue as much x += Math.Max(0, (int)Xpad - 2); } Gdk.GC main_gc = widget.Style.TextGC(state); // Draw the expander if the source has children double exp_h = (cell_area.Height - 2.0 * Ypad) / 3.2; double exp_w = exp_h * 1.6; if (view != null && view.Cr != null && source.Children != null && source.Children.Count > 0) { var r = new Gdk.Rectangle(x, cell_area.Y + (int)((cell_area.Height - exp_h) / 2.0), (int)exp_w, (int)exp_h); view.Theme.DrawArrow(view.Cr, r, source.Expanded ? Math.PI / 2.0 : 0.0); } if (!np_etc) { x += (int)exp_w; x += 2; // a little spacing after the expander expander_right_x = x; } // Draw icon Pixbuf icon = SourceIconResolver.ResolveIcon(source, RowHeight); bool dispose_icon = false; if (state == StateType.Insensitive) { // Code ported from gtk_cell_renderer_pixbuf_render() var icon_source = new IconSource() { Pixbuf = icon, Size = IconSize.SmallToolbar, SizeWildcarded = false }; icon = widget.Style.RenderIcon(icon_source, widget.Direction, state, (IconSize)(-1), widget, "SourceRowRenderer"); dispose_icon = true; icon_source.Dispose(); } if (icon != null) { x += expander_icon_spacing; drawable.DrawPixbuf(main_gc, icon, 0, 0, x, Middle(cell_area, icon.Height), icon.Width, icon.Height, RgbDither.None, 0, 0); x += icon.Width; if (dispose_icon) { icon.Dispose(); } } // Setup font info for the title/count, and see if we should show the count bool hide_count = source.EnabledCount <= 0 || source.Properties.Get <bool> ("SourceView.HideCount"); FontDescription fd = widget.PangoContext.FontDescription.Copy(); fd.Weight = (ISource)ServiceManager.PlaybackController.NextSource == (ISource)source ? Pango.Weight.Bold : Pango.Weight.Normal; if (view != null && source == view.NewPlaylistSource) { fd.Style = Pango.Style.Italic; hide_count = true; } Pango.Layout title_layout = new Pango.Layout(widget.PangoContext); Pango.Layout count_layout = null; // If we have a count to draw, setup its fonts and see how wide it is to see if we have room if (!hide_count) { count_layout = new Pango.Layout(widget.PangoContext); count_layout.FontDescription = fd; count_layout.SetMarkup(String.Format("<span size=\"small\">{0}</span>", source.EnabledCount)); count_layout.GetPixelSize(out count_layout_width, out count_layout_height); } // Hide the count if the title has no space max_title_layout_width = cell_area.Width - x - count_layout_width;//(icon == null ? 0 : icon.Width) - count_layout_width - 10; if (!hide_count && max_title_layout_width <= 0) { hide_count = true; } // Draw the source Name title_layout.FontDescription = fd; title_layout.Width = (int)(max_title_layout_width * Pango.Scale.PangoScale); title_layout.Ellipsize = EllipsizeMode.End; title_layout.SetText(source.Name); title_layout.GetPixelSize(out title_layout_width, out title_layout_height); x += img_padding; drawable.DrawLayout(main_gc, x, Middle(cell_area, title_layout_height), title_layout); title_layout.Dispose(); // Draw the count if (!hide_count) { if (view != null && view.Cr != null) { view.Cr.Color = state == StateType.Normal || (view != null && state == StateType.Prelight) ? view.Theme.TextMidColor : view.Theme.Colors.GetWidgetColor(GtkColorClass.Text, state); view.Cr.MoveTo( cell_area.X + cell_area.Width - count_layout_width - 2, cell_area.Y + 0.5 + (double)(cell_area.Height - count_layout_height) / 2.0); PangoCairoHelper.ShowLayout(view.Cr, count_layout); } count_layout.Dispose(); } fd.Dispose(); }