/// <summary> /// Flushes the rectangular area to the screen. /// </summary> /// <param name="rect">Rectangle</param> public static void Flush(Rectangle rect) { Flush(rect.X, rect.Y, rect.Width, rect.Height); }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> public override TouchEventArgs OnTouchUp(TouchEventArgs e) { if (!_pressed) return e; if (!_moving && Rect.Contains(e.Point)) { int x = Parent.X + X; int y = Parent.Y + Y; int index = ((_listY + e.Point.Y) - y) / RowHeight; int rowIndex = index; // If headers are present the rowIndex needs to be offset if (ShowHeaders) rowIndex--; int columnIndex = 0; DataGridColumn dataGridColumn; Rectangle rect; for (int i = 0; i < _columns.Count; i++) { dataGridColumn = (DataGridColumn)_columns[i]; rect = new Rectangle(x, y, dataGridColumn.Width, Height); if (rect.Contains(e.Point)) { columnIndex = i; break; } x += dataGridColumn.Width; } if (index == 0 && ShowHeaders && SortableHeaders) { Sort(columnIndex); Invalidate(); } else { if (TappableCells) { SelectedIndex = rowIndex; TriggerTapCellEvent(this, new TapCellEventArgs(columnIndex, rowIndex)); } } } _pressed = false; _moving = false; _ignoredTouchMoves = 0; return e; }
private void Init() { if (_direction == SliderDirection.Horizontal) { _knob = new Rectangle(0, 0, _knobSize, (int)((double)Height / 1.2)); _lineSize = Width - _knobSize; } else { _knob = new Rectangle(0, 0, (int)((double)Width / 1.2), _knobSize); _lineSize = Height - _knobSize; } if (_tickInterval < 0) _tickInterval = 0; else if (_tickInterval > _lineSize) _tickInterval = _lineSize; if (_tickInterval > 0) _tickSize = (double)_lineSize / TickInterval; else _tickSize = (double)_lineSize / _lineSize; if (_snapInterval < 0) _snapInterval = 0; else if (_snapInterval > _lineSize) _snapInterval = _lineSize; if (_snapInterval > 0) _snapSize = (double)_lineSize / _snapInterval; else _snapSize = (double)_lineSize / _lineSize; if (_max > 0) _pixelsPerValue = _lineSize / (_max - _min); }
/// <summary> /// Flushes the rectangular area to the screen. /// </summary> /// <param name="rect">Rectangle</param> public static void Flush(Geom.Rectangle rect) { Flush(rect.X, rect.Y, rect.Width, rect.Height); }
/// <summary> /// Fills a rectangle on this image's parent container's graphics using it's Bitmap. /// </summary> /// <param name="rect"></param> public void FillRect(Rectangle rect) { if (Bitmap != null) Parent.Graphics.DrawImage(rect.X, rect.Y, Bitmap, rect.X, rect.Y, rect.Width, rect.Height); }
/// <summary> /// Calculates the space each key occupies using the X and Y offset. /// </summary> /// <remarks>The keys must be centered and spaced exactly the same.</remarks> public void CalculateKeys() { int size = GetContentLength(); _keyValues = new string[size]; _keyCoords = new Rectangle[size]; _keyActive = new bool[size]; int x, y, index = 0; // Loop through each row of keys for (int i = 0; i < _keyContent[(int)_view].Length; i++) { // Starting X (centered) and Y x = X + (((Glide.LCD.Width - GetKeysWidth(i)) - (_keyContent[(int)_view][i].Length - 1) * _keySpacing) / 2); y = Y + (_keySpacing + (i * _keyHeight) + (i * _keySpacing)); for (int j = 0; j < _keyContent[(int)_view][i].Length; j++) { _keyValues[index] = _keyContent[(int)_view][i][j]; _keyCoords[index] = new Rectangle(x, y, _keyWidth[(int)_view][i][j], _keyHeight); _keyActive[index] = true; for (int k = 0; k < Restricted.Length; k++) { if (_keyValues[index].ToLower() == Restricted[k].ToLower()) { _keyActive[index] = false; break; } } index++; x += _keyWidth[(int)_view][i][j] + _keySpacing; } } }
/// <summary> /// Draws text in a rectangle. /// </summary> /// <param name="text">Text</param> /// <param name="rect">Rectangle</param> /// <param name="dtFlags">Flags found in Bitmap.</param> /// <param name="color">Color</param> /// <param name="font">Font</param> public void DrawTextInRect(string text, Rectangle rect, uint dtFlags, Color color, Font font) { _bitmap.DrawTextInRect(text, rect.X, rect.Y, rect.Width, rect.Height, dtFlags, color, font); }
/// <summary> /// Draws a rectangle. /// </summary> /// <param name="rect">Rectangle</param> /// <param name="color">Color</param> /// <param name="opacity">Opacity</param> public void DrawRectangle(Rectangle rect, Color color, ushort opacity) { _bitmap.DrawRectangle(Color.Black, 0, rect.X, rect.Y, rect.Width, rect.Height, 0, 0, color, 0, 0, 0, 0, 0, opacity); }