// -----------------------------------------------------------------------------------------------' private void cmd_create_style() { var app = Globals.ThisAddIn.Application; var doc = app.ActiveDocument; if (doc == null) { MessageBox.Show("Must have a document open"); return; } if (doc.Type != IVisio.VisDocumentTypes.visTypeDrawing) { MessageBox.Show("Must have a drawing open"); return; } var styles = doc.Styles; var form = new FormCreateStyle(); var result = form.ShowDialog(); if (result != DialogResult.OK) { return; } string name = form.StyleName.Trim(); if (name.Length < 1) { MessageBox.Show("Must have non-empty name"); return; } var names = styles.AsEnumerable().Select(s => s.NameU).ToList(); var names_lc = names.Select(s => s.ToLower()).ToList(); if (names_lc.Contains(name.ToLower())) { string msg = string.Format("Style with name \"{0}\" already exists", name); MessageBox.Show(msg); return; } short fIncludesText = VA.Convert.BoolToShort(form.IncludesText); short fIncludesLine = VA.Convert.BoolToShort(form.IncludesLine); short fIncludesFill = VA.Convert.BoolToShort(form.IncludesFill); var style = styles.Add(name, "", fIncludesText, fIncludesLine, fIncludesFill); }