public void btnPaletteCreate_Click(object sender, EventArgs e) { string name = ""; string description = ""; string subTitle = ""; Palette.Purpose purpose = Palette.Purpose.Custom; bool isFlow = true; if (frmPaletteDetails.Display(ref name, ref description, ref subTitle, ref purpose, ref isFlow, false) != System.Windows.Forms.DialogResult.OK) { return; } string display = Strings.Translate(description) + (!string.IsNullOrEmpty(subTitle) ? " (" + Strings.Translate(subTitle) + ")" : ""); if (m_DisplayedPalettes.Any(d => d.PaletteEditingFullDescription == display)) { MessageBox.Show(Strings.Item("Palette_DescriptionDuplicate")); return; } Document document = new Document(false) { ActivityID = Activities.PaletteID, PaletteWithin = m_Config, PaletteTitle = name, PaletteDescription = description, PalettePurpose = purpose, SnapMode = Shape.SnapModes.Grid, SubTitle = subTitle }; document.PaletteDesignSize = new SizeF(60, 30); document.Page(0).SetSize(document.PaletteDesignSize, 0); document.Page(0).Paper = Paper.CreateNew(Paper.Papers.Graph, document.Page(0).Paper); document.Page(0).Paper.SetIntervals(1, 1, 10); if (isFlow) { Flow flow = new Flow() { Direction = Flow.Directions.RightThenDown, ShapeSeparation = 1 }; flow.LineStyle.SetDefaults(); flow.FillStyle.SetDefaults(); flow.LineStyle.Colour = Color.Empty; flow.FillStyle.Colour = System.Drawing.Color.Empty; flow.SetBounds(document.Page(0).Bounds); document.Page(0).AddNew(flow, null); } m_Config.CustomPalettes.Add(document); Palette registration = new Palette(document); if (document.PalettePurpose.IsCustom) // ensure new custom one shown { m_Config.Write(Config.ShowPaletteKey(registration), true.ToString()); } WrittenToCurrent(); Palette.Register(registration); Form.CloseAndEditPalette(document); }
private void CreatePaletteLists(bool registerCustom = false) { m_CustomPalettes = new Dictionary <string, Document>(); m_AllPalettes = new List <Palette>(); // First add the system palettes which are not in any configuration: m_AllPalettes.AddRange(Palette.List.Values.Where(x => x.UserDefined == false)); foreach (Config config in Configurations) { foreach (Document document in config.CustomPalettes.Values) { string ID = document.ID.ToString(); if (!m_CustomPalettes.ContainsKey(ID)) // just in case { m_CustomPalettes.Add(ID, document); // Now add the palette object. If possible the one from the global list is used; is not a new object is created if (Palette.List.ContainsKey(ID)) { m_AllPalettes.Add(Palette.List[ID]); } else { Palette palette = new Palette(document); if (registerCustom) { Palette.Register(palette); } m_AllPalettes.Add(palette); } } } } }