Example #1
0
 /// <summary>
 /// Fills a rectangle on this image's parent container's graphics using it's Bitmap.
 /// </summary>
 /// <param name="rect"></param>
 public void FillRect(Geom.Rectangle rect)
 {
     if (Bitmap != null)
     {
         Parent.Graphics.DrawImage(rect.X, rect.Y, Bitmap, rect.X, rect.Y, rect.Width, rect.Height);
     }
 }
Example #2
0
        /// <summary>
        /// Renders and flushes the specified key within the current view.
        /// </summary>
        /// <param name="index"></param>
        public void DrawKeyDown(int index)
        {
            if (index > -1 && index < _keyValues.Length)
            {
                Geom.Rectangle keyCoord = _keyCoords[index];
                Parent.Graphics.DrawRectangle(TinyCLR2.Glide.Ext.Colors.Black, 0, keyCoord.X, keyCoord.Y, keyCoord.Width, keyCoord.Height, 0, 0, TinyCLR2.Glide.Ext.Colors.Black, 0, 0, TinyCLR2.Glide.Ext.Colors.Black, 0, 0, 0xff);
                Glide.Flush(keyCoord);
            }
            else
            {
                string currentView = String.Empty;
                switch (_view)
                {
                case View.Letters:
                    currentView = "Letters";
                    break;

                case View.Numbers:
                    currentView = "Numbers";
                    break;

                case View.Symbols:
                    currentView = "Symbols";
                    break;
                }
                throw new ArgumentOutOfRangeException("index", "Index does not exist within the " + currentView + " view.");
            }
        }
Example #3
0
        /// <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, Geom.Rectangle rect, uint dtFlags, System.Drawing.Color color, System.Drawing.Font font)
        {
            SolidBrush brush = new SolidBrush(color);

            _bitmap.DrawString(text, font, brush, rect.X, rect.Y);
            //_bitmap.DrawTextInRect(text, rect.X, rect.Y, rect.Width, rect.Height, dtFlags, color, font);
        }
Example #4
0
        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">Rectangle</param>
        /// <param name="color">Color</param>
        /// <param name="opacity">Opacity</param>
        public void DrawRectangle(Geom.Rectangle rect, System.Drawing.Color color, ushort opacity)
        {
            var brush = new SolidBrush(color);

            //var pen = new Pen(color);
            _bitmap.FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
            //_bitmap.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
            //_bitmap.DrawRectangle(0, 0, rect.X, rect.Y, rect.Width, rect.Height, 0, 0, color.ToNativeColor(), 0, 0, 0, 0, 0, opacity);
        }
Example #5
0
        /// <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;
                Geom.Rectangle rect;

                for (int i = 0; i < _columns.Count; i++)
                {
                    dataGridColumn = (DataGridColumn)_columns[i];
                    rect           = new Geom.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);
        }
Example #6
0
 /// <summary>
 /// Fills a rectangle on this window's graphics using it's background image (if it exists) or the background color.
 /// </summary>
 /// <param name="rect">Rectangle object.</param>
 public void FillRect(Geom.Rectangle rect)
 {
     if (BackImage != null)
     {
         Graphics.DrawImage(rect.X, rect.Y, BackImage, rect.X, rect.Y, rect.Width, rect.Height, Alpha);
     }
     else
     {
         Graphics.DrawRectangle(0, 0, rect.X, rect.Y, rect.Width, rect.Height, 0, 0, BackColor, 0, 0, BackColor, 0, 0, Alpha);
     }
 }
Example #7
0
        private void Init()
        {
            if (_direction == SliderDirection.Horizontal)
            {
                _knob     = new Geom.Rectangle(0, 0, _knobSize, (int)((double)Height / 1.2));
                _lineSize = Width - _knobSize;
            }
            else
            {
                _knob     = new Geom.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);
            }
        }
Example #8
0
        /// <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 Geom.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 Geom.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;
                }
            }
        }
Example #9
0
        public override void EventOccurred(IEventData data, EventType type)
        {
            if (!type.Equals(EventType.RENDER_TEXT))
            {
                return;
            }

            TextRenderInfo renderInfo = (TextRenderInfo)data;

            float counter = increaseCounter();

            var font             = renderInfo.GetFont().GetFontProgram();
            var originalFontName = font.ToString();
            var fontRegex        = Regex.Match(originalFontName, @"(?<=\+)[a-zA-Z\s]+");

            string fontName = fontRegex.Success ? fontRegex.Value : originalFontName;

            var fontStyle = font.GetFontNames().GetFontStyle();

            float curFontSize = renderInfo.GetFontSize();

            float key = counter;

            IList <TextRenderInfo> text = renderInfo.GetCharacterRenderInfos();

            foreach (TextRenderInfo character in text)
            {
                key += 0.001f;

                var textRenderMode = character.GetTextRenderMode();
                var opacity        = character.GetGraphicsState().GetFillOpacity();

                //if (textRenderMode != 0 || opacity != 1)
                //{

                //}

                string letter = character.GetText();

                Color color;

                var fillColor = character.GetFillColor();
                var colors    = fillColor.GetColorValue();
                if (colors.Length == 1)
                {
                    color = Color.FromArgb((int)(255 * (1 - colors[0])), Color.Black);
                }
                else if (colors.Length == 3)
                {
                    color = Color.FromArgb((int)(255 * colors[0]), (int)(255 * colors[1]), (int)(255 * colors[2]));
                }
                else if (colors.Length == 4)
                {
                    color = Color.FromArgb((int)(255 * colors[0]), (int)(255 * colors[1]), (int)(255 * colors[2]), (int)(255 * colors[3]));
                }
                else
                {
                    color = Color.Black;
                }

                //if(letter == "A")
                //{

                //}

                if (string.IsNullOrWhiteSpace(letter))
                {
                    continue;
                }

                //Get the bounding box for the chunk of text
                var bottomLeft = character.GetDescentLine().GetStartPoint();
                var topRight   = character.GetAscentLine().GetEndPoint();

                //Create a rectangle from it
                var rect = new Geom.Rectangle(
                    bottomLeft.Get(Vector.I1),
                    topRight.Get(Vector.I2),
                    topRight.Get(Vector.I1),
                    topRight.Get(Vector.I2)
                    );

                var currentChunk = new itext.pdfimage.Models.TextChunk()
                {
                    Text       = letter,
                    Rect       = rect,
                    FontFamily = fontName,
                    FontSize   = (int)curFontSize,
                    FontStyle  = fontStyle,
                    Color      = color,
                    SpaceWidth = character.GetSingleSpaceWidth() / 2f
                };

                chunkDictionairy.Add(key, currentChunk);
            }

            base.EventOccurred(data, type);
        }