Exemple #1
0
 private void TablePanel_MouseHover(object sender, EventArgs e)
 {
     if (!_tablePanel.Focused && _tablePanel.VerticalScroll.Visible)
     {
         _tablePanel.Focus();
     }
 }
        private void Tab1_Click(object sender, EventArgs e)
        {
            TableLayoutPanel table = (TableLayoutPanel)sender;

            UnselectAll(tabControler.SelectedIndex);
            table.BackColor = Color.Aqua;
            selectedLayout  = table;
            Debug.WriteLine((string)table.Tag);
            table.Focus();
        }
Exemple #3
0
        private TextBox PropertyControlDirectory(PropertyInfo property, TableLayoutPanel panel)
        {
            Size _defaultDirectoryPathBoxSize = new Size(300, 20);

            //
            // Create TextBox
            //
            var ctrl = new TextBox()
            {
                Size      = _defaultDirectoryPathBoxSize,
                Anchor    = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
                Margin    = new Padding(0, 2, 15, 2),
                TextAlign = HorizontalAlignment.Left,
            };

            ctrl.Text = property.GetValue(Settings.Instance).ToString();

            //
            // Highlight effect on change showing that the setting was updated
            //
            Timer highlightTimer = new Timer()
            {
                Interval = 2000
            };

            highlightTimer.Tick += (s, e) =>
            {
                panel.BackColor = Panel.DefaultBackColor;
                highlightTimer.Stop();
            };

            //
            // Show a Directory chooser when the user clicks the box
            //
            ctrl.Click += (s, e) =>
            {
                using (FolderBrowserDialog dialog = new FolderBrowserDialog())
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        ctrl.Text = dialog.SelectedPath;

                        // Update settings value
                        property.SetValue(Settings.Instance, ctrl.Text);
                        panel.BackColor = Color.LawnGreen;
                        panel.Focus();

                        highlightTimer.Start();
                    }
                }
            };

            return(ctrl);
        }
        private void tLP_MouseEnter(object sender, EventArgs e)
        {
            TableLayoutPanel tLP = (TableLayoutPanel)sender;

            tLP.Focus();
        }
Exemple #5
0
        /// <summary>
        ///     TODO
        /// </summary>
        private void PopulatePal()
        {
            var acCurDoc = Application.DocumentManager.MdiActiveDocument;

            if (acCurDoc == null)
            {
                return;
            }

            var acCurDb = acCurDoc.Database;

            const int imageColumn  = 0;
            const int buttonColumn = 1;
            const int barOffset    = 10;
            const int buttonOffset = 1;
            const int buttonHeight = 25;

            var backColor = Colors.GetCadBackColor();
            var foreColor = Colors.GetCadForeColor();
            var textColor = Colors.GetCadTextColor();

            var rowCounter = 0;

            try
            {
                using (acCurDoc.LockDocument())
                {
                    _palPanel.SuspendLayout();
                    _palPanel.BackColor = backColor;
                    _palPanel.Controls.Clear();
                    _palPanel.AutoScroll = false;

                    #region Table Layout

                    var palLayout = new TableLayoutPanel
                    {
                        AutoScroll   = true,
                        AutoSizeMode = AutoSizeMode.GrowAndShrink,
                        BackColor    = Colors.GetCadBackColor(),
                        ForeColor    = Colors.GetCadForeColor(),
                        ColumnCount  = 3,
                        Dock         = DockStyle.Fill
                    };

                    palLayout.MouseEnter += (s, e) => palLayout.Focus();

                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 25F));
                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                    palLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 5F));

                    #endregion

                    using (var acTrans = acCurDb.TransactionManager.StartTransaction())
                    {
                        var layerGroups = acCurDb.GetLayerTableRecord(acTrans, 0)
                                          .GroupBy(layer => layer.Name.Split(SettingsUser.LayerDelimiter)[0])
                                          .OrderBy(layer => layer.Key);

                        foreach (var group in layerGroups)
                        {
                            palLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, buttonHeight + 5));

                            if (group.Count() > 1)
                            {
                                var spButton = new SplitButton
                                {
                                    ShowSplit        = true,
                                    BackColor        = foreColor,
                                    ForeColor        = textColor,
                                    Dock             = DockStyle.Fill,
                                    Height           = buttonHeight,
                                    ContextMenuStrip = new ContextMenuStrip(),
                                    FlatStyle        = FlatStyle.Flat
                                };

                                spButton.Click += Button_Click;
                                spButton.FlatAppearance.BorderColor       = Colors.GetCadBorderColor();
                                spButton.FlatAppearance.BorderSize        = 1;
                                spButton.ContextMenuStrip.BackColor       = foreColor;
                                spButton.ContextMenuStrip.ForeColor       = textColor;
                                spButton.ContextMenuStrip.ShowImageMargin = false;
                                spButton.ContextMenuStrip.ShowCheckMargin = false;

                                Color spColor    = null;
                                var   firstParse = true;

                                foreach (var layer in group)
                                {
                                    if (firstParse)
                                    {
                                        spButton.Text = layer.Name;
                                        spColor       = layer.Color;
                                        firstParse    = false;
                                    }

                                    var tsButton = new ToolStripButton(layer.Name, GetLayerImage(layer.Color),
                                                                       ContextItem_Click)
                                    {
                                        ImageAlign = TopLeft,
                                        TextAlign  = BottomLeft,
                                        BackColor  = foreColor,
                                        ForeColor  = textColor
                                    };

                                    spButton.ContextMenuStrip.Items.Add(tsButton);
                                }

                                var picBox = new PictureBox
                                {
                                    Height = buttonHeight,
                                    Image  = GetLayerImage(spColor),
                                    Dock   = DockStyle.Fill
                                };

                                palLayout.Controls.Add(spButton, buttonColumn, rowCounter);
                                palLayout.Controls.Add(picBox, imageColumn, rowCounter);
                                rowCounter++;
                            }
                            else
                            {
                                var layer = group.First();

                                var button = new Button
                                {
                                    Text      = layer.Name,
                                    BackColor = foreColor,
                                    ForeColor = textColor,
                                    Dock      = DockStyle.Fill,
                                    Height    = buttonHeight,
                                    FlatStyle = FlatStyle.Flat
                                };

                                button.Click += Button_Click;
                                button.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                                button.FlatAppearance.BorderSize  = 1;

                                var picBox = new PictureBox
                                {
                                    Height = buttonHeight,
                                    Image  = GetLayerImage(layer.Color),
                                    Dock   = DockStyle.Fill
                                };


                                palLayout.Controls.Add(button, buttonColumn, rowCounter);
                                palLayout.Controls.Add(picBox, imageColumn, rowCounter);
                                rowCounter++;
                            }
                        }

                        //Add a blank label to the final row to keep from having a giant row at the bottom
                        var blankLabel = new Label {
                            Height = buttonHeight
                        };
                        palLayout.Controls.Add(blankLabel, buttonColumn, rowCounter + 1);
                        palLayout.RowCount++;

                        acTrans.Commit();
                    }

                    palLayout.AutoScroll = true;
                    palLayout.AutoSize   = true;
                    palLayout.Refresh();

                    if (palLayout.VerticalScroll.Visible)
                    {
                        palLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
                        palLayout.ColumnStyles[2].Width    = barOffset;
                    }
                    else
                    {
                        palLayout.ColumnStyles[2].SizeType = SizeType.Absolute;
                        palLayout.ColumnStyles[2].Width    = buttonOffset;
                    }

                    palLayout.Refresh();

                    var bLayout = new TableLayoutPanel
                    {
                        BackColor   = Colors.GetCadBackColor(),
                        ForeColor   = Colors.GetCadForeColor(),
                        ColumnCount = 2,
                        Height      = 30,
                        Dock        = DockStyle.Bottom
                    };

                    bLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80F));
                    bLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
                    bLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 30f));


                    var loadButton = new Button();
                    loadButton.Click    += Load_Click;
                    loadButton.Text      = "Load From Dwg";
                    loadButton.BackColor = foreColor;
                    loadButton.ForeColor = textColor;
                    loadButton.Dock      = DockStyle.Fill;
                    loadButton.Height    = 30;
                    loadButton.FlatStyle = FlatStyle.Flat;
                    loadButton.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                    loadButton.FlatAppearance.BorderSize  = 1;

                    var updButton = new Button();
                    updButton.Click     += Update_Click;
                    updButton.Image      = Properties.Resources.RcUpdate16X16__I_;
                    updButton.ImageAlign = MiddleCenter;
                    updButton.BackColor  = foreColor;
                    updButton.ForeColor  = textColor;
                    updButton.Dock       = DockStyle.Fill;
                    loadButton.Height    = 30;
                    updButton.FlatStyle  = FlatStyle.Flat;
                    updButton.FlatAppearance.BorderColor = Colors.GetCadBorderColor();
                    updButton.FlatAppearance.BorderSize  = 1;

                    bLayout.Controls.Add(loadButton, 0, 0);
                    bLayout.Controls.Add(updButton, 1, 0);

                    _palPanel.Controls.Add(palLayout);
                    _palPanel.Controls.Add(bLayout);

                    _palPanel.ResumeLayout();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #6
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="playerDataFile">PlayerDataFile to use</param>
        /// <param name="recipes">List of all the recipes</param>
        public SkillsTab(PlayerDataFile playerDataFile, List <RecipeBinder> recipes)
        {
            Text = "Skills";

            this.playerDataFile = playerDataFile;
            this.recipes        = recipes;

            SetUpSkills();

            panel      = new TableLayoutPanel();
            panel.Dock = DockStyle.Fill;

            TableLayoutPanel general = new TableLayoutPanel()
            {
                Size   = new Size(478, 36),
                Anchor = AnchorStyles.Top
            };

            LabeledControl LabeledPlayerLevelBox = new LabeledControl("Player level", new NumericTextBox <int>(playerDataFile.level, 1, SkillData.maxPlayerLevel, 80), 150);

            playerDataFile.level.AddListener(this);
            general.Controls.Add(LabeledPlayerLevelBox, 0, 0);

            LabeledControl LabeledSkillPointsBox = new LabeledControl("Skill points", new NumericTextBox <int>(playerDataFile.skillPoints, 0, int.MaxValue, 80), 150);

            general.Controls.Add(LabeledSkillPointsBox, 1, 0);

            LabeledControl LabeledExperienceBox = new LabeledControl("Experience", new NumericTextBox <uint>(playerDataFile.experience, 0u, (uint)(SkillData.expToPlayerLevel * SkillData.maxPlayerLevel), 80), 150);

            playerDataFile.experience.AddListener(this);
            general.Controls.Add(LabeledExperienceBox, 2, 0);

            panel.Controls.Add(general);

            TableLayoutPanel skillsPanel = new TableLayoutPanel()
            {
                CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset,
                Dock            = DockStyle.Fill,
                AutoScroll      = true
            };

            skillsPanel.MouseEnter += (sender, e) => {
                bool focusFree = true;
                foreach (SkillSlot skillSlot in skillSlots)
                {
                    if (skillSlot.levelBox.Focused || (skillSlot.expToNextLevelBox != null && skillSlot.expToNextLevelBox.Focused))
                    {
                        focusFree = false;
                        break;
                    }
                }

                if (focusFree)
                {
                    skillsPanel.Focus();
                }
            };

            TableLayoutPanel centerer = new TableLayoutPanel()
            {
                Anchor          = AnchorStyles.Top,
                CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset,
                AutoSize        = true
            };

            skillSlots = new List <SkillSlot>();
            int i = 0;

            foreach (KeyValuePair <int, Skill> skillEntry in playerDataFile.skills.skillDictionary)
            {
                SkillSlot skillSlot = new SkillSlot(new SkillBinder(skillEntry.Value, playerDataFile.level, recipes));

                skillSlots.Add(skillSlot);

                centerer.Controls.Add(skillSlot, i % 4, i / 4);

                i++;
            }

            skillsPanel.Controls.Add(centerer);
            panel.Controls.Add(skillsPanel);

            Controls.Add(panel);
        }
Exemple #7
0
        private TextBox PropertyControlString(PropertyInfo property, TableLayoutPanel panel)
        {
            Size _defaultStringTextBoxSize = new Size(200, 20);

            //
            // Create TextBox
            //
            var ctrl = new TextBox()
            {
                Size      = _defaultStringTextBoxSize,
                Anchor    = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
                Margin    = new Padding(0, 2, 15, 2),
                TextAlign = HorizontalAlignment.Right
            };

            ctrl.Text = property.GetValue(Settings.Instance).ToString();

            //
            // Highlight effect on change showing that the setting was updated
            //
            Timer highlightTimer = new Timer()
            {
                Interval = 2000
            };

            highlightTimer.Tick += (s, e) =>
            {
                panel.BackColor = Panel.DefaultBackColor;
                highlightTimer.Stop();
            };

            //
            // Set the new value in Settings
            //
            bool valueChanged = false;

            ctrl.TextChanged += (s, e) => valueChanged = true;
            ctrl.KeyUp       += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    panel.Focus();
                }
            };
            ctrl.Leave += (s, e) =>
            {
                if (!valueChanged)
                {
                    return;
                }

                // Update settings value
                property.SetValue(Settings.Instance, ctrl.Text);
                valueChanged    = false;
                panel.BackColor = Color.LawnGreen;
                panel.Focus();

                highlightTimer.Start();
            };

            return(ctrl);
        }
Exemple #8
0
        private TextBox PropertyControlCurrency(PropertyInfo property, TableLayoutPanel panel)
        {
            Size _defaultCurrencyTextBoxSize = new Size(100, 20);

            //
            // Create TextBox
            //
            var ctrl = new TextBox()
            {
                Size      = _defaultCurrencyTextBoxSize,
                Anchor    = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
                Margin    = new Padding(0, 2, 15, 2),
                TextAlign = HorizontalAlignment.Right
            };

            Action <decimal> setText = new Action <decimal>((d) =>
            {
                ctrl.Text = d.ToString("$0.00");
            });

            setText((decimal)property.GetValue(Settings.Instance));

            //
            // Highlight effect on change showing that the setting was updated
            //
            Timer highlightTimer = new Timer()
            {
                Interval = 2000
            };

            highlightTimer.Tick += (s, e) =>
            {
                panel.BackColor = Panel.DefaultBackColor;
                highlightTimer.Stop();
            };

            //
            // Set the new value in Settings
            //
            bool valueChanged = false;

            ctrl.TextChanged += (s, e) => valueChanged = true;
            ctrl.KeyUp       += (s, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    panel.Focus();
                }
            };
            ctrl.Leave += (s, e) =>
            {
                if (!valueChanged)
                {
                    return;
                }

                if (decimal.TryParse(ctrl.Text, out decimal val))
                {
                    // Update settings value
                    property.SetValue(Settings.Instance, val);
                    panel.BackColor = Color.LawnGreen;
                    setText(val);
                    valueChanged = false;
                    panel.Focus();
                }
                else
                {
                    // Reset text to settings value
                    setText((decimal)property.GetValue(Settings.Instance));
                    valueChanged    = false;
                    panel.BackColor = Color.PaleVioletRed;
                    ctrl.SelectAll();
                }
                highlightTimer.Start();
            };

            return(ctrl);
        }
Exemple #9
0
 private void FocusEntryPanel(object sender, MouseEventArgs e)
 {
     TableLayoutPanel.Focus();
 }