示例#1
0
        private void tagButton_Click(object sender, EventArgs e)
        {
            var location = PointToScreen(tagButton.Location);

            using (var dialog = new UI.TagPickerDialog(
                       location.X + tagButton.Bounds.Location.X - tagButton.Width,
                       location.Y + tagButton.Bounds.Location.Y))
            {
                dialog.Select(TagSymbol);

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    var glyph = dialog.GetGlyph();
                    if (glyph != null)
                    {
                        tagButton.Text  = null;
                        tagButton.Image = glyph;
                    }
                    else
                    {
                        tagButton.Text = "?";
                    }

                    TagSymbol = dialog.Symbol;
                }
            }
        }
示例#2
0
        private void SelectTag(object sender, System.EventArgs e)
        {
            var location = PointToScreen(tagButton.Location);

            using (var dialog = new UI.TagPickerDialog(0, 0))
            {
                // TagPickerDialog customizes Left and Top in its constructor because most
                // consumers place the tagButton in a groupBox and that offsets its true
                // position, whereas here we need the actual location of tagButton
                dialog.Left = location.X + (tagButton.Width / 2);
                dialog.Top  = location.Y + tagButton.Height - 3;

                if (symbol is string sym && sym != "0")
                {
                    dialog.Select(int.Parse(sym));
                }

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    var glyph = dialog.GetGlyph();
                    if (glyph != null)
                    {
                        tagButton.Text  = null;
                        tagButton.Image = glyph;
                    }
                    else
                    {
                        tagButton.Text = "?";
                    }

                    symbol = dialog.Symbol.ToString();
                }
            }
        }