private void ShowField(Field field) { FieldRenderer renderer = new FieldRenderer(field, null); FieldRegion region = new FieldRegion(); Pixbuf pixbuf; region.Left = region.Bottom = 0; region.Top = field.Height - 1; region.Right = field.Width - 1; pixbuf = renderer.RenderToPixbuf(region, null); if (pixbuf.Width > DEFAULT_WIDTH || pixbuf.Height > DEFAULT_HEIGHT) { int w, h; CalculateOptimalDimensions(pixbuf, out w, out h); pixbuf = pixbuf.ScaleSimple(w, h, InterpType.Tiles); } if (image == null) { image = new Gtk.Image(pixbuf); image.Show(); Add(image); } else { image.Pixbuf = pixbuf; } }
public static void FieldPosToScreenPos(ref Point p, Field field, uint zoomLevel) { FieldPoint fp; fp.X = (uint) Math.Max(0, p.X); fp.Y = (uint) Math.Max(0, p.Y); FieldPosToScreenPos(ref fp, field, zoomLevel); p.X = (int) fp.X; p.Y = (int) fp.Y; }
/** * Create a new FieldRenderer for rendering the specified field. * * @param field The field to render. * @param colors The colors to use when rendering this field. If this is null, * then the default colors will be used. * @require field != null * @ensure * this.Field == field * if colors != null: this.Colors == colors * this.ZoomLevel == 1 */ public FieldRenderer(Field field, FieldColors colors) { this.field = field; if (colors != null) { this.colors = colors; } else { this.colors = new FieldColors(); } }
public static FieldRegion ScreenSelectionToFieldRegion( Field field, uint zoomLevel, int x, int y, int width, int height ) { FieldRegion s = new FieldRegion(); s.Left = (uint) Math.Max(0, x / zoomLevel); s.Right = (uint) Math.Min(field.Width, (x + width) / zoomLevel); s.Top = (uint) Math.Max(0, field.Height - (y / zoomLevel) - 1); s.Bottom = (uint) Math.Min(field.Height, field.Height - ((y + height) / zoomLevel) - 1); return s; }
/** * Convert a position on screen to a position on the field. * * @param p [in, out] A reference to a FieldPoint which contains the * position on screen. The X and Y members will be changed * to the position on the field. This position is clamped * so that it is always within the field's dimensions. * @return True if the calculated position hadn't to be clamped to fit * in the field's dimensions, false otherwise. * @require field != null */ public static bool ScreenPosToFieldPos(ref FieldPoint p, Field field, uint zoomLevel) { bool result = true; if (p.X / zoomLevel >= field.Width) { p.X = field.Width - 1; result = false; } else { p.X /= zoomLevel; } if (p.Y / zoomLevel >= field.Height) { p.Y = 0; result = false; } else { p.Y = field.Height - (p.Y / zoomLevel) - 1; } return result; }
/** * Construct an FldField object from another Field object. */ public GZipFldField(Field field) { this.field = new FldField(field); }
/** * Convert a point on the field to a point on screen. * * @require field != null */ public static void FieldPosToScreenPos(ref FieldPoint p, Field field, uint zoomLevel) { p.X *= zoomLevel; p.Y = (field.Height - p.Y - 1) * zoomLevel; }
private void OnFieldDimensionChanged(Field field) { pixmap = null; selection = null; creatingSelection = false; QueueDraw(); }
private void OnFieldBlockChanged(Field field) { pixmap = null; QueueDraw(); }
/** * Construct this Field object from another Field object. */ protected void ConstructFromField(Field field) { Resize(field.Width, field.Height); for (uint x = 0; x < width; x++) { for (uint y = 0; y < height; y++) { SetBlock(x, y, field.GetBlock(x, y)); } } }
/// <summary> /// Returns true if the specified field matches the current filter. /// </summary> /// <param name="f"></param> /// <returns></returns> private bool IsFilterMatch(Field f) { if (Filter.IsNullOrEmpty()) return true; if (f == null) return false; return f.Group.ContainsCapsInsensitive(Filter) || f.Subgroup.ContainsCapsInsensitive(Filter) || f.Name.ContainsCapsInsensitive(Filter); }
private void Action_InitializeNewSavedField(Field newField) { if (Fields.Count <= 1) return; var lastField = Fields[Fields.Count - 2]; if (newField == null) return; if (lastField == null) return; newField.FileName = lastField.FileName; newField.Kind = lastField.Kind; newField.Offset = lastField.Offset; newField.Group = lastField.Group; newField.Subgroup = lastField.Subgroup; }
/** * Construct an FldField object from another Field object. */ public FldField(Field field) { ConstructFromField(field); }