Exemplo n.º 1
0
        private void tsbStylesAdd_Click(object sender, EventArgs e)
        {
            string styleName = "";

            for (int i = 0; i < 99; i++)
            {
                styleName = string.Format("String{0}", i);
                if (data.FindStyle(styleName) == null)
                {
                    break;
                }
            }

            if (styleName.Length > 0)
            {
                DialogStyleName dlg = new DialogStyleName();
                dlg.Document  = data;
                dlg.StyleName = styleName;
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    MNReferencedStyle sm = data.Styles[0].CreateCopy();
                    sm.Name = dlg.StyleName;
                    data.Styles.Add(sm);
                    data.Modified = true;
                    listBoxStyles.Items.Add(sm);
                    listBoxStyles.SelectedIndex = listBoxStyles.Items.Count - 1;
                }
            }
        }
Exemplo n.º 2
0
        private void tsbStylesAdd_Click(object sender, EventArgs e)
        {
            string            styleName     = "";
            MNReferencedStyle selectedStyle = null;
            ListBox           lb            = listBoxStyles;

            if (lb.SelectedIndex >= 0 && lb.SelectedIndex < lb.Items.Count)
            {
                selectedStyle = lb.Items[lb.SelectedIndex] as MNReferencedStyle;
                styleName     = selectedStyle.Name + " (copy)";
            }
            else
            {
                selectedStyle = data.Styles[0];
                for (int i = 0; i < 99; i++)
                {
                    styleName = string.Format("String{0}", i);
                    if (data.FindStyle(styleName) == null)
                    {
                        break;
                    }
                }
            }

            if (styleName.Length > 0)
            {
                DialogStyleName dlg = new DialogStyleName();
                dlg.Document  = data;
                dlg.StyleName = styleName;
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    styleName = dlg.StyleName;
                }
                else
                {
                    styleName = "";
                }
            }

            if (styleName.Length > 0)
            {
                MNReferencedStyle sm = selectedStyle.CreateCopy();
                sm.Name = styleName;
                data.Styles.Add(sm);
                data.Modified = true;
                listBoxStyles.Items.Add(sm);
                listBoxStyles.SelectedIndex = listBoxStyles.Items.Count - 1;
                MNNotificationCenter.BroadcastMessage(this, "StyleListChanged");
            }
        }