Example #1
0
        private Rectangle DrawNavigationButtons(MNPageContext context, Rectangle textBounds)
        {
            context.g.DrawLine(SMGraphics.GetPen(NormalState.ForeColor, 1), textBounds.Left, textBounds.Bottom,
                               textBounds.Right, textBounds.Bottom);
            if (HasPrevPage())
            {
                prevBtnRect = new Rectangle(textBounds.Left, textBounds.Bottom, textBounds.Width / 2 - 32, navigButtonsHeight);
                if (prevBtnPressed)
                {
                    context.g.FillRectangle(SMGraphics.GetBrush(Color.LightGreen), prevBtnRect);
                }
                context.g.DrawString("< PREV", SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f), SMGraphics.GetBrush(Color.Gray), prevBtnRect, SMGraphics.StrFormatCenter);
            }
            if (HasNextPage())
            {
                nextBtnRect = new Rectangle(textBounds.Left + textBounds.Width / 2 + 32, textBounds.Bottom, textBounds.Width / 2 - 32, navigButtonsHeight);
                if (nextBtnPressed)
                {
                    context.g.FillRectangle(SMGraphics.GetBrush(Color.LightGreen), nextBtnRect);
                }
                context.g.DrawString("NEXT >", SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f), SMGraphics.GetBrush(Color.Gray), nextBtnRect, SMGraphics.StrFormatCenter);
            }

            context.g.DrawString(string.Format("{0}/{1}", CurrentPage + 1, PageCount), SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f),
                                 SMGraphics.GetBrush(Color.Gray), new Rectangle(textBounds.Left + textBounds.Width / 2 - 48, textBounds.Bottom, 96, navigButtonsHeight),
                                 SMGraphics.StrFormatCenter);
            return(textBounds);
        }
Example #2
0
 public MNPageContext()
 {
     redConstraintTrack       = new Pen(Color.Red, 3);
     LastMatrix               = new Matrix();
     LastInvertMatrix         = new Matrix();
     CurrentPage              = null;
     HintFont                 = new Font(FontFamily.GenericSansSerif, 9);
     MenuFont                 = SMGraphics.GetFontVariation(MNFontName.GilSansMurari, 18);
     MenuTitleFont            = new Font(FontFamily.GenericSansSerif, 24);
     DragItemFont             = new Font(FontFamily.GenericSansSerif, 35);
     PageTitleFont            = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Italic);
     semitransparentGrayBrush = new SolidBrush(Color.FromArgb(128, Color.Gray));
     messageBox               = new SMTitledMessage(CurrentPage);
     SpotAreaBorderPen        = new Pen(Color.LightBlue, 3);
 }
Example #3
0
        public override void Paint(MNPageContext context)
        {
            Rectangle rect     = Area.GetBounds(context);
            Brush     keyBack  = Brushes.LightGray;
            Brush     keyPress = Brushes.Blue;

            float  ax             = rect.Width / 100f;
            float  ay             = rect.Height / 28f;
            Font   font           = SMGraphics.GetFontVariation(SystemFonts.DefaultFont, 4 * Math.Min(ax, ay));
            PointF origin         = new PointF(rect.X + rect.Width / 2 - 50 * ax, rect.Y + rect.Height / 2 - 14 * ay);
            Brush  textBrush      = Brushes.Black;
            Brush  textPressBrush = Brushes.White;

            foreach (SMKeyboardKey key in Keys)
            {
                key.PaintedRect = new RectangleF(key.X * ax + origin.X, key.Y * ay + origin.Y, key.Width * ax, key.Height * ay);
                Rectangle r = new Rectangle((int)key.PaintedRect.X, (int)key.PaintedRect.Y, (int)key.PaintedRect.Width, (int)key.PaintedRect.Height);
                context.g.FillRectangle(key.Pressed ? keyPress : keyBack, r);
                if (key.Image != null)
                {
                    float b = Math.Min(key.PaintedRect.Width / key.Image.Width, key.PaintedRect.Height / key.Image.Height);
                    b *= 0.7f;
                    Rectangle r2 = new Rectangle(Convert.ToInt32(key.PaintedRect.X + key.PaintedRect.Width / 2),
                                                 Convert.ToInt32(key.PaintedRect.Y + key.PaintedRect.Height / 2),
                                                 Convert.ToInt32(b * key.Image.Width), Convert.ToInt32(b * key.Image.Height));
                    r2.X -= r2.Width / 2;
                    r2.Y -= r2.Height / 2;
                    context.g.DrawImage(key.Image, r2);
                }
                else
                {
                    context.g.DrawString(key.Key, font, key.Pressed ? textPressBrush : textBrush, r, p_sf);
                }
            }

            base.Paint(context);
        }
Example #4
0
        public override void Paint(MNPageContext context)
        {
            Rectangle bounds = Area.GetBounds(context);

            SMStatusLayout layout = PrepareBrushesAndPens();

            if (p_format == null)
            {
                p_format               = new StringFormat();
                p_format.Alignment     = StringAlignment.Center;
                p_format.LineAlignment = StringAlignment.Center;
            }

            if (!p_prevContent.Equals(ContentCells))
            {
                AnalyzeContents();
                FindFirstEmptyCell();
                p_prevContent = ContentCells;
                if (p_xmax < 1 || p_ymax < 1)
                {
                    return;
                }
            }

            Rectangle textBounds = ContentPadding.ApplyPadding(bounds);

            // size of one cell
            p_cellx = Math.Min(textBounds.Height / p_ymax, textBounds.Width / p_xmax);
            Font usedFont = SMGraphics.GetFontVariation(Font.Font, p_cellx * 0.7f);


            // prepare rectangle for letter
            Rectangle rect = new Rectangle();

            rect.Width  = p_cellx;
            rect.Height = p_cellx;
            Brush bb;

            int lastIndex = p_ymax - 1;

            for (int x = 0; x < p_xmax; x++)
            {
                rect.X = textBounds.X + x * p_cellx;
                for (int y = 0; y < p_ymax; y++)
                {
                    rect.Y = textBounds.Y + y * p_cellx;
                    if (p_array[x, y, 1].Length > 0)
                    {
                        if (x == p_focusX && y == p_focusY)
                        {
                            context.g.FillRectangle(Brushes.LightBlue, rect);
                        }
                        else
                        {
                            context.g.FillRectangle(tempBackBrush, rect);
                        }
                        context.g.DrawLine(tempBorderPen, rect.X, rect.Y, rect.X + p_cellx, rect.Y);
                        context.g.DrawLine(tempBorderPen, rect.X, rect.Y, rect.X, rect.Y + p_cellx);
                        if (y >= p_ymax - 1 || p_array[x, y + 1, 1].Length == 0)
                        {
                            context.g.DrawLine(tempBorderPen, rect.X, rect.Y + p_cellx, rect.X + p_cellx, rect.Y + p_cellx);
                        }
                        if (x >= p_xmax - 1 || p_array[x + 1, y, 1].Length == 0)
                        {
                            context.g.DrawLine(tempBorderPen, rect.X + p_cellx, rect.Y, rect.X + p_cellx, rect.Y + p_cellx);
                        }
                        bb = ((UIStateError == MNEvaluationResult.Incorrect &&
                               (p_array[x, y, 0] != p_array[x, y, 1])) ? Brushes.Red : tempForeBrush);
                        context.g.DrawString(p_array[x, y, 0], usedFont, bb, rect, p_format);
                    }
                }
            }


            // draw selection marks
            base.Paint(context);
        }
Example #5
0
        public override void Paint(MNPageContext context)
        {
            Rectangle bounds = Area.GetBounds(context);

            Rectangle textBounds = ContentPadding.ApplyPadding(bounds);

            if (p_prevHighColor != HighlightColor)
            {
                p_prevHighColor = HighlightColor;
                p_prevHighBrush = new SolidBrush(HighlightColor);
            }

            if (p_alignedText.Length == 0 || !p_prevText.Equals(Text) || p_prevRowCol != Rows * Columns)
            {
                if (Rows < 3)
                {
                    Rows = 3;
                }
                if (Columns < 3)
                {
                    Columns = 3;
                }
                p_prevRowCol         = Rows * Columns;
                p_prevText           = Text;
                p_cellStatus         = new bool[Columns, Rows];
                p_cellExpectedStatus = new bool[Columns, Rows];
                p_alignedText        = AlignText(Text);
                for (int i = 0; i < Columns; i++)
                {
                    for (int i2 = 0; i2 < Rows; i2++)
                    {
                        p_cellStatus[i, i2] = false;
                    }
                }
            }
            SizeF sizeChar       = context.g.MeasureString("M", Font.Font);
            float cellSize       = Math.Max(sizeChar.Height, sizeChar.Width);
            float targetCellSize = Math.Min((textBounds.Width - (Columns + 1) * Spacing) / Columns,
                                            (textBounds.Height - (Rows + 1) * Spacing) / Rows);

            // recalculate actuall size for puzzle
            textBounds.Height = (int)(targetCellSize * Rows + Spacing * Rows + Spacing);
            textBounds.Width  = (int)(targetCellSize * Columns + Spacing * Columns + Spacing);

            // recalculate border
            bounds = ContentPadding.ApplyPadding(textBounds);

            context.g.DrawRectangle(Pens.Black, bounds);

            // recalculate size of font
            Font usedFont = Font.Font;

            if (targetCellSize > 0.1f)
            {
                usedFont = SMGraphics.GetFontVariation(Font.Name, Font.Size * targetCellSize / cellSize);
            }
            int index = 0;

            // prepare rectangle for letter
            Rectangle rect = new Rectangle();

            rect.Width  = (int)targetCellSize;
            rect.Height = (int)targetCellSize;

            // prepare text formating
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            p_cellSize = (int)targetCellSize;

            // drawing letters
            for (int r = 0; r < Rows; r++)
            {
                for (int c = 0; c < Columns; c++)
                {
                    rect.X = Convert.ToInt32(c * targetCellSize + (c + 1) * Spacing) + textBounds.X;
                    rect.Y = Convert.ToInt32(r * targetCellSize + (r + 1) * Spacing) + textBounds.Y;
                    string s = p_alignedText.Substring(index, 1);
                    index++;
                    if (p_cellStatus[c, r])
                    {
                        context.g.FillRectangle(p_prevHighBrush, rect);
                    }
                    if (UIStateError == MNEvaluationResult.Incorrect)
                    {
                        if (p_cellStatus[c, r] != p_cellExpectedStatus[c, r])
                        {
                            context.g.DrawString(s, usedFont, Brushes.Gray, rect, format);
                        }
                        else
                        {
                            context.g.DrawString(s, usedFont, Brushes.Black, rect, format);
                        }
                    }
                    else
                    {
                        context.g.DrawString(s, usedFont, Brushes.Black, rect, format);
                    }
                }
            }

            // draw selection marks
            base.Paint(context);
        }