예제 #1
0
 private void ButtonFromIncludeOnButtonPressed(YamuiButtonImage sender, EventArgs e)
 {
     // change option and image
     Config.Instance.CodeExplorerDisplayItemsFromInclude = !Config.Instance.CodeExplorerDisplayItemsFromInclude;
     filterbox.ExtraButtonsList[4].UseGreyScale          = !Config.Instance.CodeExplorerDisplayItemsFromInclude;
     // Parse the document
     ParserHandler.ParseDocumentNow();
     Sci.GrabFocus();
 }
예제 #2
0
 private void buttonSort_Click(YamuiButtonImage sender, EventArgs e)
 {
     Config.Instance.CodeExplorerSortingType++;
     if (Config.Instance.CodeExplorerSortingType > SortingType.Alphabetical)
     {
         Config.Instance.CodeExplorerSortingType = SortingType.NaturalOrder;
     }
     filterbox.ExtraButtonsList[2].BackGrndImage = Config.Instance.CodeExplorerSortingType == SortingType.Alphabetical ? ImageResources.Alphabetical_sorting : ImageResources.Numerical_sorting;
     ParserHandler.ParseDocumentNow();
     Sci.GrabFocus();
 }
예제 #3
0
 private void buttonRefresh_Click(YamuiButtonImage sender, EventArgs e)
 {
     if (Refreshing)
     {
         return;
     }
     ParserHandler.ClearStaticData();
     Npp.CurrentSci.Lines.Reset();
     ParserHandler.ParseDocumentNow();
     Sci.GrabFocus();
 }
예제 #4
0
 private void buttonExpandRetract_Click(YamuiButtonImage sender, EventArgs e)
 {
     if (_isExpanded)
     {
         YamuiList.ForceAllToCollapse();
     }
     else
     {
         YamuiList.ForceAllToExpand();
     }
     _isExpanded = !_isExpanded;
     FilterBox.ExtraButtonsList[0].BackGrndImage = _isExpanded ? Resources.Resources.Collapse : Resources.Resources.Expand;
 }
예제 #5
0
 private void buttonExpandRetract_Click(YamuiButtonImage sender, EventArgs e)
 {
     if (_isExpanded)
     {
         yamuiList.ForceAllToCollapse();
     }
     else
     {
         yamuiList.ForceAllToExpand();
     }
     _isExpanded = !_isExpanded;
     filterbox.ExtraButtonsList[1].BackGrndImage = _isExpanded ? ImageResources.Collapse : ImageResources.Expand;
     Sci.GrabFocus();
 }
예제 #6
0
        public ExportPage()
        {
            InitializeComponent();

            // dynamically reorder the controls for a correct tab order on notepad++
            SetTabOrder.RemoveAndAddForTabOrder(scrollPanel);

            // browse
            btBrowse.BackGrndImage  = ImageResources.SelectFile;
            btBrowse.ButtonPressed += BtBrowseOnButtonPressed;
            tooltip.SetToolTip(btBrowse, "Click to <b>select</b> a folder");

            btOpen.BackGrndImage  = ImageResources.OpenInExplorer;
            btOpen.ButtonPressed += BtOpenOnButtonPressed;
            tooltip.SetToolTip(btOpen, "Click to <b>open</b> this folder in the explorer");

            btHistoric.BackGrndImage  = ImageResources.Historic;
            btHistoric.ButtonPressed += BtHistoricOnButtonPressed;
            tooltip.SetToolTip(btHistoric, "Click to <b>browse</b> the previous folders");
            if (string.IsNullOrEmpty(Config.Instance.SharedConfHistoric))
            {
                btHistoric.Visible = false;
            }

            btRefresh.BackGrndImage  = ImageResources.Refresh;
            btRefresh.ButtonPressed += BtRefreshOnButtonPressed;
            tooltip.SetToolTip(btRefresh, "Click to <b>refresh</b> the local and distant file status");

            btDownloadAll.BackGrndImage  = ImageResources.DownloadAll;
            btDownloadAll.ButtonPressed += BtDownloadAllOnButtonPressed;
            btDownloadAll.Hide();
            tooltip.SetToolTip(btDownloadAll, "Click to <b>fetch</b> all the distant versions newer than the local versions");

            fl_directory.Text = Config.Instance.SharedConfFolder;

            // build the interface
            var iNbLine = 0;
            var yPos    = btRefresh.Location.Y + 35;

            foreach (var confLine in ShareExportConf.List)
            {
                var xPos = btDownloadAll.Location.X - 25;

                // label
                var label = new HtmlLabel {
                    Anchor             = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left,
                    AutoSizeHeightOnly = true,
                    BackColor          = Color.Transparent,
                    Location           = new Point(30, yPos + 2),
                    Size = new Size(topAuto.Location.X - 30, 10),
                    IsSelectionEnabled = false,
                    Text = confLine.Label
                };
                tooltip.SetToolTip(label, "File or folder handled :<br>" + confLine.HandledItem);
                scrollPanel.ContentPanel.Controls.Add(label);

                // switch, auto update?
                var toggleControl = new YamuiCheckBox {
                    Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                    Location = new Point(xPos, yPos + 2),
                    Size     = new Size(15, 15),
                    Text     = @" ",
                    Checked  = confLine.AutoUpdate,
                    Tag      = confLine
                };
                toggleControl.CheckedChanged += ToggleControlOnCheckedChanged;
                scrollPanel.ContentPanel.Controls.Add(toggleControl);
                tooltip.SetToolTip(toggleControl, "Check this option to automatically fetch the most recent version of the file<br>This update occurs on notepad++ startup and each time you refresh the local/distant file status");
                xPos += 25;

                // do we have an update available?
                var strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.OutDated,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Name          = "btm_" + iNbLine,
                    Visible       = false
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "The distant version is more recent than the local one<br>Press this button to <b>fetch</b> the distant version");
                xPos += 30;

                // local date
                var date = new HtmlLabel {
                    Anchor             = AnchorStyles.Top | AnchorStyles.Right,
                    AutoSizeHeightOnly = true,
                    BackColor          = Color.Transparent,
                    Location           = new Point(xPos, yPos + 2),
                    Size = new Size(130, 10),
                    IsSelectionEnabled = false,
                    Text = @"???",
                    Name = "datel_" + iNbLine
                };
                scrollPanel.ContentPanel.Controls.Add(date);
                xPos += 140;

                // local open
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.OpenInExplorer,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Enabled       = false,
                    Name          = "bto_" + iNbLine
                };
                strButton.ButtonPressed += OpenFileOnButtonPressed;
                strButton.MouseDown     += OpenFileOnMouseDown;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Left click to <b>open</b> this file in notepad++<br>Right click to <b>open</b> this file / folder in the explorer");
                xPos += 20;

                // local import
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.Import,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Enabled       = false,
                    Name          = "bti_" + iNbLine
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Click to <b>import</b> this file<br>It reads its content and use it in this session of 3P");
                xPos += 20;

                // local export
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.Export,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Name          = "bte_" + iNbLine,
                    Enabled       = false
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Click to <b>export</b> this file to a local version,<br>you will use the exported file instead of the embedded file in 3P");
                xPos += 20;

                // local delete
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.Delete,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Name          = "btd_" + iNbLine,
                    Enabled       = false
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Click to <b>delete</b> the local version of your file,<br>you will use the embedded (default) file of 3P instead");
                xPos += 40;

                // distant date
                date = new HtmlLabel {
                    Anchor             = AnchorStyles.Top | AnchorStyles.Right,
                    AutoSizeHeightOnly = true,
                    BackColor          = Color.Transparent,
                    Location           = new Point(xPos, yPos + 2),
                    Size = new Size(130, 10),
                    IsSelectionEnabled = false,
                    Text = @"???",
                    Name = "dated_" + iNbLine
                };
                scrollPanel.ContentPanel.Controls.Add(date);
                xPos += 140;

                // distant open
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.OpenInExplorer,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Enabled       = false,
                    Name          = "btz_" + iNbLine
                };
                strButton.ButtonPressed += OpenFileOnButtonPressed;
                strButton.MouseDown     += OpenFileOnMouseDown;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Left click to <b>open</b> this file in notepad++<br>Right click to <b>open</b> this file / folder in the explorer");
                xPos += 20;

                // distant fetch
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.Fetch,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Name          = "btf_" + iNbLine,
                    Enabled       = false
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Click to <b>fetch</b> this file from the shared directory,<br>replacing the local one");
                xPos += 20;

                // distant push
                strButton = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    BackGrndImage = ImageResources.Push,
                    Size          = new Size(20, 20),
                    Location      = new Point(xPos, yPos),
                    Tag           = confLine,
                    TabStop       = false,
                    Name          = "btp_" + iNbLine,
                    Enabled       = false
                };
                strButton.ButtonPressed += StrButtonOnButtonPressed;
                scrollPanel.ContentPanel.Controls.Add(strButton);
                tooltip.SetToolTip(strButton, "Click to <b>push</b> the local file to the shared directory,<br>replacing any existing file");

                yPos += label.Height + 15;
                iNbLine++;
            }

            // Activate scrollbars
            scrollPanel.ContentPanel.Height = yPos + 50;
        }
예제 #7
0
파일: OptionPage.cs 프로젝트: massreuy/3P
        private void GeneratePage()
        {
            var lastCategory   = "";
            var yPos           = 0;
            var configInstance = Config.Instance;

            ForEachConfigPropertyWithDisplayAttribute((property, attribute) => {
                var valObj = property.GetValue(configInstance);

                // new group
                if (!lastCategory.EqualsCi(attribute.GroupName))
                {
                    if (!string.IsNullOrEmpty(lastCategory))
                    {
                        // ReSharper disable once AccessToModifiedClosure
                        yPos += 10;
                    }
                    lastCategory = attribute.GroupName;
                    scrollPanel.ContentPanel.Controls.Add(new YamuiLabel {
                        AutoSize = true,
                        Function = FontFunction.Heading,
                        Location = new Point(0, yPos),
                        Text     = lastCategory.ToUpper()
                    });
                    yPos += 30;
                }

                // name of the field
                var label = new HtmlLabel {
                    AutoSizeHeightOnly = true,
                    BackColor          = Color.Transparent,
                    Location           = new Point(30, yPos),
                    Size = new Size(190, 10),
                    IsSelectionEnabled = false,
                    Text = attribute.Name
                };
                scrollPanel.ContentPanel.Controls.Add(label);

                var listRangeAttr = property.GetCustomAttributes(typeof(RangeAttribute), false);
                var rangeAttr     = (listRangeAttr.Any()) ? (RangeAttribute)listRangeAttr.FirstOrDefault() : null;

                if (valObj is string)
                {
                    // string
                    var strControl = new YamuiTextBox {
                        Location = new Point(240, yPos),
                        Text     = (string)property.GetValue(configInstance),
                        Size     = new Size(300, 20),
                        Tag      = property.Name
                    };

                    scrollPanel.ContentPanel.Controls.Add(strControl);
                    var strButton = new YamuiButtonImage {
                        Text          = @"save",
                        BackGrndImage = ImageResources.Save,
                        Size          = new Size(20, 20),
                        Location      = new Point(545, yPos),
                        Tag           = strControl,
                        TabStop       = false
                    };
                    strButton.ButtonPressed += SaveButtonOnButtonPressed;
                    scrollPanel.ContentPanel.Controls.Add(strButton);
                    tooltip.SetToolTip(strButton, "Click to <b>set the value</b> of this field<br>Otherwise, your modifications will not be saved");

                    var undoButton = new YamuiButtonImage {
                        BackGrndImage = ImageResources.UndoUserAction,
                        Size          = new Size(20, 20),
                        Location      = new Point(565, yPos),
                        Tag           = strControl,
                        TabStop       = false
                    };
                    undoButton.ButtonPressed += UndoButtonOnButtonPressed;
                    scrollPanel.ContentPanel.Controls.Add(undoButton);
                    tooltip.SetToolTip(undoButton, "Click to <b>reset this field</b> to its default value");

                    tooltip.SetToolTip(strControl, attribute.Description + "<br><div class='ToolTipBottomGoTo'>Click on the save button <img src='Save'> to set your modifications</div>");
                }
                if (valObj is int || valObj is double)
                {
                    // number
                    var numControl = new YamuiTextBox {
                        Location = new Point(240, yPos),
                        Text     = ((valObj is int) ? ((int)property.GetValue(configInstance)).ToString() : ((double)property.GetValue(configInstance)).ToString(CultureInfo.CurrentCulture)),
                        Size     = new Size(300, 20),
                        Tag      = property.Name
                    };

                    scrollPanel.ContentPanel.Controls.Add(numControl);
                    var numButton = new YamuiButtonImage {
                        Text          = @"save",
                        BackGrndImage = ImageResources.Save,
                        Size          = new Size(20, 20),
                        Location      = new Point(545, yPos),
                        Tag           = numControl,
                        TabStop       = false
                    };
                    numButton.ButtonPressed += SaveButtonOnButtonPressed;
                    scrollPanel.ContentPanel.Controls.Add(numButton);
                    tooltip.SetToolTip(numButton, "Click to <b>set the value</b> of this field<br>Otherwise, your modifications will not be saved");

                    var undoButton = new YamuiButtonImage {
                        BackGrndImage = ImageResources.UndoUserAction,
                        Size          = new Size(20, 20),
                        Location      = new Point(565, yPos),
                        Tag           = numControl,
                        TabStop       = false
                    };
                    undoButton.ButtonPressed += UndoButtonOnButtonPressed;
                    scrollPanel.ContentPanel.Controls.Add(undoButton);
                    tooltip.SetToolTip(undoButton, "Click to <b>reset this field</b> to its default value");

                    tooltip.SetToolTip(numControl, attribute.Description + "<br>" + (rangeAttr != null ? "<br><b><i>" + "Min value = " + rangeAttr.Minimum + "<br>Max value = " + rangeAttr.Maximum + "</i></b><br>" : "") + "<div class='ToolTipBottomGoTo'>Click on the save button <img src='Save'> to set your modifications</div>");
                }
                else if (valObj is bool)
                {
                    // bool
                    var toggleControl = new YamuiButtonToggle {
                        Location = new Point(240, yPos),
                        Size     = new Size(40, 16),
                        Text     = null,
                        Checked  = (bool)valObj,
                        Tag      = property.Name
                    };
                    toggleControl.ButtonPressed += ToggleControlOnCheckedChanged;
                    scrollPanel.ContentPanel.Controls.Add(toggleControl);

                    // tooltip
                    tooltip.SetToolTip(toggleControl, attribute.Description + "<br><div class='ToolTipBottomGoTo'>Click to <b>toggle on/off</b> this feature<br>Your choice is automatically applied</div>");
                }

                yPos += label.Height + 15;
            });

            yPos   += 15;
            _btSave = new YamuiButton {
                Location      = new Point(30, yPos),
                Size          = new Size(120, 24),
                Text          = @"Save everything",
                BackGrndImage = ImageResources.Save
            };
            _btSave.ButtonPressed += SaveAllButtonOnButtonPressed;
            tooltip.SetToolTip(_btSave, "Click to <b>save</b> all the options<br><i>This as the same effect than clicking save for each option</i>");
            scrollPanel.ContentPanel.Controls.Add(_btSave);

            var defaultButton = new YamuiButton {
                Location      = new Point(155, yPos),
                Size          = new Size(120, 24),
                Text          = @"Reset to default",
                BackGrndImage = ImageResources.UndoUserAction
            };

            defaultButton.ButtonPressed += DefaultButtonOnButtonPressed;
            tooltip.SetToolTip(defaultButton, "Click to <b>reset</b> all the options to default");
            scrollPanel.ContentPanel.Controls.Add(defaultButton);

            // add a button for the updates
            if (_allowedGroups.Contains("Updates"))
            {
                var updateButton = new YamuiButton {
                    Location      = new Point(280, yPos),
                    Size          = new Size(150, 24),
                    Text          = @"Check for updates",
                    BackGrndImage = ImageResources.Update
                };
                updateButton.ButtonPressed += (sender, args) => UpdateHandler.CheckForUpdate();
                tooltip.SetToolTip(updateButton, "Click to <b>check for updates</b>");
                scrollPanel.ContentPanel.Controls.Add(updateButton);
            }

            scrollPanel.ContentPanel.Height = yPos + 50;
        }
예제 #8
0
        private void DrawControl()
        {
            Controls.Clear();

            var treeList   = AssociatedList as YamuiFilteredTypeTreeList;
            var thisHeight = Height - Padding.Top - Padding.Bottom;

            // draw buttons on the left of the filter textbox
            var xLeftPos = Padding.Left;

            if (ExtraButtons != null && ExtraButtons.Count > 0)
            {
                ExtraButtonsList = new List <YamuiButtonImage>();
                foreach (var button in ExtraButtons.Where(button => button.Image != null))
                {
                    var extraButton = new YamuiButtonImage {
                        BackGrndImage = button.Image,
                        Size          = button.Image.Size,
                        Location      = new Point(xLeftPos, Padding.Top + (thisHeight - button.Image.Height) / 2),
                        Anchor        = AnchorStyles.Top | AnchorStyles.Left,
                        TabStop       = false
                    };
                    var button1 = button;
                    extraButton.ButtonPressed += (sender, args) => button1.OnClic((YamuiButtonImage)sender, args);
                    Controls.Add(extraButton);
                    ExtraButtonsList.Add(extraButton);
                    if (button.ToolTip != null)
                    {
                        _tooltip.SetToolTip(extraButton, button.ToolTip);
                    }
                    xLeftPos += button.Image.Width;
                }
                xLeftPos += 5;
            }

            // draw the default buttons on the right of the filter textbox
            var xRightPos = Width - Padding.Right;

            // filter mode for tree list
            if (treeList != null)
            {
                var img = treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? SearchButtonImage : FilterButtonImage;
                xRightPos -= img.Width;
                var modeButton = new YamuiButtonImage {
                    BackGrndImage = img,
                    Size          = img.Size,
                    Location      = new Point(xRightPos, Padding.Top + (thisHeight - img.Height) / 2),
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    TabStop       = false
                };
                modeButton.ButtonPressed += OnClickMode;
                Controls.Add(modeButton);
                _tooltip.SetToolTip(modeButton, treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? ModeButtonSearchTooltip : ModeButtonFilterTooltip);
            }
            // eraser
            xRightPos -= EraserButtonImage.Width;
            var eraserButton = new YamuiButtonImage {
                BackGrndImage = EraserButtonImage,
                Size          = EraserButtonImage.Size,
                Location      = new Point(xRightPos, Padding.Top + (thisHeight - EraserButtonImage.Height) / 2),
                Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                TabStop       = false
            };

            eraserButton.ButtonPressed += OnClickEraser;
            Controls.Add(eraserButton);
            _tooltip.SetToolTip(eraserButton, EraserButtonTooltip);
            xRightPos -= 5;

            // textbox
            _filterBox.SelectAllTextOnActivate = false;
            _filterBox.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
            _filterBox.Location  = new Point(xLeftPos, Padding.Top);
            _filterBox.Size      = new Size(xRightPos - xLeftPos, thisHeight);
            _filterBox.WaterMark = treeList == null || treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? WatermarkSearchText : WatermarkFilterText;
            _filterBox.Text      = AssociatedList.FilterString ?? string.Empty;
            Controls.Add(_filterBox);
            _tooltip.SetToolTip(_filterBox, TextBoxTooltip);
        }
예제 #9
0
 private void OnRefreshClic(YamuiButtonImage yamuiButtonImage, EventArgs e)
 {
     RefreshFileList();
     filterbox.FocusFilter();
 }
예제 #10
0
        /// <summary>
        /// Insert the correct input for the option
        /// </summary>
        private Control InsertInputForItem(FieldInfo property, Config.ConfigAttribute attr, ref int yPos)
        {
            // Build control type
            Control retVal;

            if (property.FieldType == typeof(bool))
            {
                // for bool
                var tg = new YamuiButtonToggle {
                    Location = new Point(320, yPos),
                    Size     = new Size(40, 16),
                    Text     = null,
                    Checked  = (bool)property.GetValue(Config.Instance)
                };
                tg.ButtonPressed += (sender, args) => OnFieldModified();
                retVal            = tg;
            }
            else if (property.FieldType.IsEnum)
            {
                // for enum
                var dataSource = new List <string>();
                foreach (var name in Enum.GetNames(property.FieldType))
                {
                    var attribute = Attribute.GetCustomAttribute(property.FieldType.GetField(name), typeof(DescriptionAttribute), true) as DescriptionAttribute;
                    dataSource.Add(attribute != null ? attribute.Description : name);
                }
                dataSource = dataSource.Select(s => s.Replace("_", " ").Trim()).ToNonNullList();
                var cb = new YamuiComboBox {
                    Location   = new Point(320, yPos),
                    Size       = new Size(Math.Min(300, dataSource.Select(s => TextRenderer.MeasureText(s, FontManager.GetStandardFont()).Width).Max() + 25), 20),
                    DataSource = dataSource,
                };
                cb.SelectedIndex = Enum.GetNames(property.FieldType).IndexOf(property.GetValue(Config.Instance).ConvertToStr());
                cb.SelectedIndexChangedByUser += box => OnFieldModified();
                retVal = cb;
            }
            else
            {
                // for everything else
                var tb = new YamuiTextBox {
                    Location         = new Point(320, yPos),
                    Size             = new Size(300, 20),
                    Text             = property.GetValue(Config.Instance).ConvertToStr(),
                    Multiline        = false,
                    CausesValidation = true
                };
                tb.Enter += (s, e) => tb.SelectAll();
                if (property.FieldType == typeof(char))
                {
                    tb.KeyPress += (s, e) => {
                        e.Handled = !char.IsControl(e.KeyChar) && tb.TextLength > 0;
                    }
                }
                ;
                else
                {
                    tb.KeyPress += (s, e) => {
                        e.Handled = Utilities.IsInvalidKey(e.KeyChar, property.FieldType);
                    }
                };
                tb.Validating  += ValidateTextBox;
                tb.Validated   += (s, e) => errorProvider.SetError(tb, "");
                tb.TextChanged += (sender, args) => OnFieldModified();
                errorProvider.SetIconPadding(tb, -18);
                errorProvider.Icon = ImageResources.IcoError;
                retVal             = tb;
            }

            var undoButton = new YamuiButtonImage {
                BackGrndImage = ImageResources.UndoUserAction,
                Size          = new Size(20, 20),
                Location      = new Point(retVal.Left + retVal.Width + 5, yPos),
                Tag           = retVal,
                TabStop       = false
            };

            undoButton.ButtonPressed += OnUndoButton;
            scrollPanel.ContentPanel.Controls.Add(undoButton);
            tooltip.SetToolTip(undoButton, "Click to <b>reset this field</b> to its default value");

            // add tooltip on the control
            if (!string.IsNullOrEmpty(attr.Tooltip))
            {
                var rangeAttr = (RangeAttribute)property.GetCustomAttributes(typeof(RangeAttribute), false).FirstOrDefault();
                tooltip.SetToolTip(retVal, "<b>" + attr.Label + ":</b><br><br>" + attr.Tooltip + (rangeAttr != null ? "<br><b><i>" + "Min value = " + rangeAttr.Minimum + "<br>Max value = " + rangeAttr.Maximum + "</i></b>" : ""));
            }

            // Set standard props
            retVal.Name = "option_" + property.Name;
            retVal.Tag  = property;

            return(retVal);
        }
예제 #11
0
        public override void OnShow()
        {
            foreach (Control control in scrollPanel.ContentPanel.Controls)
            {
                if (!control.Name.StartsWith("static"))
                {
                    control.Dispose();
                }
            }

            // build the interface
            var yPos = static_name.Location.Y + 35;

            foreach (var item in AppliMenu.Instance.ShortcutableItemList.OrderBy(item => item.ItemName))
            {
                // icon
                var imgButton = new YamuiPictureBox {
                    BackGrndImage = item.ItemImage,
                    Size          = new Size(20, 20),
                    Location      = new Point(static_name.Location.X - 30, yPos),
                    Tag           = item.ItemId,
                    TabStop       = false
                };
                scrollPanel.ContentPanel.Controls.Add(imgButton);

                // name
                var label = new HtmlLabel {
                    AutoSizeHeightOnly = true,
                    BackColor          = Color.Transparent,
                    Location           = new Point(static_name.Location.X, yPos + 2),
                    Size = new Size(340, 10),
                    IsSelectionEnabled = false,
                    Text = item.ItemName
                };
                scrollPanel.ContentPanel.Controls.Add(label);

                // keys
                var button = new YamuiButton {
                    Anchor        = AnchorStyles.Right | AnchorStyles.Top,
                    Location      = new Point(static_keys.Location.X + static_keys.Width - 220, yPos - 1),
                    Size          = new Size(220, 24),
                    Tag           = item.ItemId,
                    Text          = item.ItemSpec ?? "",
                    Name          = "bt" + item.ItemId,
                    TabStop       = true,
                    BackGrndImage = item.ItemImage,
                };
                scrollPanel.ContentPanel.Controls.Add(button);
                button.Click += ButtonOnButtonPressed;
                tooltip.SetToolTip(button, "<b>" + item.ItemName + "</b><br><br>Click to modify this shortcut<br><i>You can press ESCAPE to cancel the changes</i>");

                // reset
                button = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Right | AnchorStyles.Top,
                    BackGrndImage = ImageResources.UndoUserAction,
                    Size          = new Size(20, 20),
                    Location      = new Point(button.Location.X + button.Width + 10, yPos),
                    Tag           = item.ItemId,
                    TabStop       = false,
                };
                scrollPanel.ContentPanel.Controls.Add(button);
                button.ButtonPressed += UndoButtonOnButtonPressed;
                tooltip.SetToolTip(button, "Click this button to reset the shortcut to its default value");

                // reset
                button = new YamuiButtonImage {
                    Anchor        = AnchorStyles.Right | AnchorStyles.Top,
                    BackGrndImage = ImageResources.Delete,
                    Size          = new Size(20, 20),
                    Location      = new Point(button.Location.X + button.Width, yPos),
                    Tag           = item.ItemId,
                    TabStop       = false,
                };
                scrollPanel.ContentPanel.Controls.Add(button);
                button.ButtonPressed += ButtonDeleteOnButtonPressed;
                tooltip.SetToolTip(button, "Click this button to clear this shortcut");

                yPos += label.Height + 15;
            }

            // Activate scrollbars
            scrollPanel.ContentPanel.Height = yPos + 20;
            Height = yPos;
        }