Example #1
0
        public Bitmap GetBitmap()
        {
            int    width = 134;
            int    height = 83;
            Bitmap bitmap = new Bitmap(width, height);
            int    x = 0, y = height - 1;

            for (int i = 1; i < (width) * height * 2; i += 2)
            {
                byte b1 = _data[i + 1];
                byte b2 = _data[i];

                bitmap.SetPixel(x, y, MerthsoftExtensions.ColorFrom565(b1, b2));

                x += 1;
                if (x == width - 1)
                {
                    i += 2;
                    x  = 0;
                    y--;
                }
            }

            return(bitmap);
        }
Example #2
0
        public ColorPicker()
        {
            InitializeComponent();

            for (int i = 0; i < 256; i++)
            {
                Color color = MerthsoftExtensions.ColorFrom8BitHLRGB(i);
                XLibPalette.Add(color);
                XLibBrushes.Add(new SolidBrush(color));
            }
        }
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || m_DraggedTab == null || MerthsoftExtensions.IsRunningOnMono())
            {
                return;
            }

            TabPage tab = TabAt(e.Location);

            if (tab == null || tab == m_DraggedTab)
            {
                return;
            }

            Swap(m_DraggedTab, tab);
            SelectedTab = m_DraggedTab;
        }
Example #4
0
        /// <summary>
        /// Draws an ellipse to the sprite.
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="color">The color to draw.</param>
        /// <param name="plotWidth">The pen width.</param>
        /// <param name="fill">True to fill the ellipse.</param>
        public void DrawEllipse(int x1, int y1, int x2, int y2, int color, int plotWidth = 1, bool fill = false)
        {
            if (x2 < x1)
            {
                MerthsoftExtensions.Swap(ref x1, ref x2);
            }
            if (y2 < y1)
            {
                MerthsoftExtensions.Swap(ref y1, ref y2);
            }

            int hr = (x2 - x1) / 2;
            int kr = (y2 - y1) / 2;
            int h  = x1 + hr;
            int k  = y1 + kr;

            DrawEllipseUsingRadius(h, k, hr, kr, color, plotWidth, fill);
        }
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            TabPage clickedTab = TabAt(e.Location);

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (MerthsoftExtensions.IsRunningOnMono())
                {
                    return;
                }
                m_DraggedTab = clickedTab;
                break;

            case MouseButtons.Middle:
                TabCloseEventHandler temp = TabClose;
                if (temp != null)
                {
                    TabCloseEventArgs args = new TabCloseEventArgs(clickedTab);
                    temp(this, args);
                    if (!args.Cancel)
                    {
                        TabPages.Remove(clickedTab);
                    }
                }
                break;

            case MouseButtons.None:
                break;

            case MouseButtons.Right:
                break;

            case MouseButtons.XButton1:
                break;

            case MouseButtons.XButton2:
                break;

            default:
                break;
            }
        }
Example #6
0
 /// <summary>
 /// Draws a rectangle to the sprite.
 /// </summary>
 /// <param name="x1"></param>
 /// <param name="y1"></param>
 /// <param name="x2"></param>
 /// <param name="y2"></param>
 /// <param name="color">The color to draw.</param>
 /// <param name="plotWidth">The pen width.</param>
 /// <param name="fill">True to fill the rectangle.</param>
 public void DrawRectangle(int x1, int y1, int x2, int y2, int color, int plotWidth = 1, bool fill = false)
 {
     if (!fill)
     {
         DrawLine(x1, y1, x1, y2, color, plotWidth);
         DrawLine(x1, y2, x2, y2, color, plotWidth);
         DrawLine(x2, y2, x2, y1, color, plotWidth);
         DrawLine(x1, y1, x2, y1, color, plotWidth);
     }
     else
     {
         if (x1 > x2)
         {
             MerthsoftExtensions.Swap(ref x1, ref x2);
         }
         for (int x = x1; x <= x2; x++)
         {
             DrawLine(x, y1, x, y2, color, plotWidth);
         }
     }
 }