Beispiel #1
0
        private void RenameStyle(object sender, EventArgs e)
        {
            var index = 0;
            var names = new List <string>();

            foreach (GraphicStyle styleItem in namesBox.Items)
            {
                if (index != namesBox.SelectedIndex)
                {
                    names.Add(styleItem.Name);
                }

                index++;
            }

            if (!names.Any())
            {
                return;
            }

            var style = (GraphicStyle)namesBox.Items[namesBox.SelectedIndex];
            var name  = style.Name;

            using (var dialog = new NameStyleDialog(names, name)
            {
                Rename = true
            })
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                name = dialog.StyleName;
            }

            style.Name = name;
            index      = namesBox.SelectedIndex;
            namesBox.Items.RemoveAt(index);
            namesBox.Items.Insert(index, style);
            namesBox.SelectedIndex = index;
        }
Beispiel #2
0
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Following are only active when editing a theme, not creating a new style


        private void AddStyle(object sender, EventArgs e)
        {
            var index = 0;
            var names = new List <string>();

            foreach (GraphicStyle style in namesBox.Items)
            {
                names.Add(style.Name);
                if (index <= style.Index)
                {
                    index = style.Index + 1;
                }
            }

            var name = "Style-" + new Random().Next(1000, 9999).ToString();

            using (var dialog = new NameStyleDialog(names, name))
            {
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                name = dialog.StyleName;
            }

            namesBox.Items.Add(new GraphicStyle(new Style
            {
                Name  = name,
                Index = index
            },
                                                false));

            saveButton.Enabled    = true;
            reorderButton.Enabled = true;
            renameButton.Enabled  = true;
            deleteButton.Enabled  = true;

            namesBox.SelectedIndex = namesBox.Items.Count - 1;
        }