Пример #1
0
        internal override void KeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar >= '0' && e.KeyChar <= '9')
            {
                SizesSetMember ssm = currentSet[e.KeyChar - '0'];
                if (ssm is SizeSubmenuEntry)
                {
                    SizeSubmenuEntry sse = (SizeSubmenuEntry)ssm;
                    currentSet = sse.SubMenu;
                    vc.Invalidate();
                }
                else
                {
                    SizeEntry se = (SizeEntry)ssm;
                    select(se);
                }
            }
            else
            {
                switch (e.KeyChar)
                {
                case ',':
                case '.':
                    select(new SizeEntry(-1, -1));
                    break;

                case '-':
                case '\b':
                    currentSet = currentSet.Parent;
                    if (currentSet == null)
                    {
                        if (widthValue != null)
                        {
                            widthValue = null;
                            currentSet = defaultSet;
                        }
                        else
                        {
                            vc.NextState = ViewState.START;
                        }
                    }
                    vc.Invalidate();
                    break;
                }
            }
        }
Пример #2
0
        internal override void Paint(PaintEventArgs e)
        {
            Font f = ScaleFont(e.Graphics, vc.Font, vc.Width / 15);

            using (Pen black = new Pen(Color.Black))
                using (Brush green = new SolidBrush(Color.LightGreen), blackb = new SolidBrush(Color.Black))
                {
                    if (widthValue == null)
                    {
                        int w = vc.Width;
                        int h = vc.Height;
                        for (int i = 0; i < 10; i++)
                        {
                            int ii = (i + 9) % 10;
                            e.Graphics.DrawRectangle(black, 0, h * i / 10, w, h / 10);
                            if (currentSet[i] is SizeSubmenuEntry)
                            {
                                SizeSubmenuEntry sse = (SizeSubmenuEntry)currentSet[i];
                                DrawString(e.Graphics, f, i + ": " + sse.Title, 10, h * ii / 10 + h / 20, 0, 0.5f, blackb);
                            }
                            else
                            {
                                SizeEntry se = (SizeEntry)currentSet[i];
                                e.Graphics.FillRectangle(green, w * se.From / 12, h * ii / 10 + 5, w * (se.To - se.From) / 12, h / 10 - 10);
                                e.Graphics.DrawRectangle(black, w * se.From / 12, h * ii / 10 + 5, w * (se.To - se.From) / 12, h / 10 - 10);
                                DrawString(e.Graphics, f, "" + i, w * (se.From + se.To) / 24, h * ii / 10 + h / 20, 0.5f, 0.5f, blackb);
                            }
                        }
                        if (vc.ShowHints && currentSet.Parent == null)
                        {
                            DrawHelpBox(e.Graphics, vc.Font, w * 3 / 4, 20,
                                        "Select horitontal size\n\n" +
                                        "4 and 6 open submenus,\n" +
                                        "other digits select,\n" +
                                        ",: Use old window width\n" +
                                        "Backspace/-: One menu back");
                        }
                    }
                    else
                    {
                        int w = vc.Width;
                        int h = vc.Height;
                        for (int i = 0; i < 10; i++)
                        {
                            int ii = (i + 9) % 10;
                            e.Graphics.DrawRectangle(black, w * i / 10, 0, w / 10, h);
                            if (currentSet[i] is SizeSubmenuEntry)
                            {
                                SizeSubmenuEntry sse = (SizeSubmenuEntry)currentSet[i];
                                DrawString(e.Graphics, f, i + "", w * ii / 10 + w / 20, 10, 0.5f, 0, blackb);
                                // print title?
                            }
                            else
                            {
                                SizeEntry se = (SizeEntry)currentSet[i];
                                e.Graphics.FillRectangle(green, w * ii / 10 + 5, h * se.From / 12, w / 10 - 10, h * (se.To - se.From) / 12);
                                e.Graphics.DrawRectangle(black, w * ii / 10 + 5, h * se.From / 12, w / 10 - 10, h * (se.To - se.From) / 12);
                                DrawString(e.Graphics, f, "" + i, w * ii / 10 + w / 20, h * (se.From + se.To) / 24, 0.5f, 0.5f, blackb);
                            }
                        }
                        if (vc.ShowHints && currentSet.Parent == null)
                        {
                            DrawHelpBox(e.Graphics, vc.Font, w * 3 / 4, 20,
                                        "Select vertical size\n\n" +
                                        "4 and 6 open submenus,\n" +
                                        "other digits select,\n" +
                                        ",: Use old window height\n" +
                                        "Backspace/-: One menu back");
                        }
                    }
                }
        }