/// <summary> /// Adds the specified elements based on the base element (and optionally as a reference) /// </summary> /// <param name="collectionNames">The names of the elements to generate</param> /// <param name="zBaseElement">The base element to copy from</param> /// <param name="sLayoutReferenceName">The reference layout to apply</param> private void AddElements(IEnumerable <string> collectionNames, ProjectLayoutElement zBaseElement, string sLayoutReferenceName = null) { var listNewElements = new List <ProjectLayoutElement>(); foreach (string sName in collectionNames) { string sTrimmed = sName.Trim(); if (m_dictionaryItems.ContainsKey(sTrimmed)) // no duplicates! { Logger.AddLogLine("Unable to add duplicated element: {0}".FormatString(sTrimmed)); continue; } var zCardElement = new ProjectLayoutElement(sTrimmed); if (null != zBaseElement) { zCardElement.DeepCopy(zBaseElement, true); zCardElement.layoutreference = sLayoutReferenceName; zCardElement.elementreference = sLayoutReferenceName == null ? null : zBaseElement.name; } else { zCardElement.lineheight = 14; zCardElement.SetElementColor(Color.Black); zCardElement.SetElementFont(FontLoader.DefaultFont); } listNewElements.Add(zCardElement); ListViewItem zLvi = CreateListViewItem(zCardElement); listViewElements.Items.Add(zLvi); } // construct a new list of elements var listElements = new List <ProjectLayoutElement>(); if (null != LayoutManager.Instance.ActiveLayout.Element) { listElements.AddRange(LayoutManager.Instance.ActiveLayout.Element); } listElements.AddRange(listNewElements); var zLayout = LayoutManager.Instance.ActiveLayout; if (null == zLayout.Element || // it is possible nothing was added if all names were duplicates (skip in that case) zLayout.Element.Length < listElements.Count) { // UserAction SetupLayoutUndo(listElements); // assign the new list to the actual project layout LayoutManager.Instance.ActiveLayout.Element = listElements.ToArray(); ProjectManager.Instance.FireElementsAdded(listNewElements); LayoutManager.Instance.FireLayoutUpdatedEvent(true); } }
private void SetColorValue(Button btnClicked, Color color, ProjectLayoutElement zElement) { if (btnClicked == btnElementBorderColor) { zElement.SetElementBorderColor(color); } else if (btnClicked == btnElementOutlineColor) { zElement.SetElementOutlineColor(color); } else if (btnClicked == btnElementFontColor || btnClicked == btnElementShapeColor) { zElement.SetElementColor(color); } }
private void AddElements(IEnumerable <string> collectionNames, ProjectLayoutElement zBaseElement) { // construct a new list of elements var listElements = new List <ProjectLayoutElement>(); if (null != LayoutManager.Instance.ActiveLayout.Element) { listElements.AddRange(LayoutManager.Instance.ActiveLayout.Element); } foreach (string sName in collectionNames) { string sTrimmed = sName.Trim(); if (m_dictionaryItems.ContainsKey(sTrimmed)) // no duplicates! { continue; } var zCardElement = new ProjectLayoutElement(sTrimmed); if (null != zBaseElement) { zCardElement.DeepCopy(zBaseElement, true); } else { zCardElement.lineheight = 14; zCardElement.SetElementColor(Color.Black); zCardElement.SetElementFont(new Font("Arial", 12)); } listElements.Add(zCardElement); ListViewItem zLvi = CreateListViewItem(zCardElement); listViewElements.Items.Add(zLvi); } var zLayout = LayoutManager.Instance.ActiveLayout; if (null == zLayout.Element || // it is possible nothing was added if all names were duplicates (skip in that case) zLayout.Element.Length < listElements.Count) { // UserAction SetupLayoutUndo(listElements); // assign the new list to the actual project layout LayoutManager.Instance.ActiveLayout.Element = listElements.ToArray(); LayoutManager.Instance.FireLayoutUpdatedEvent(true); } }