private void DeleteItemGroup(object sender, RoutedEventArgs e) { GroupElement groupElement = ItemGroups.SelectedItem as GroupElement; if (groupElement != null) { ItemGroupElement selElm = groupElement.ElementBase as ItemGroupElement; if (selElm != null) { if (!selElm.IsImported) { DeleteQuestionDialog dialog = new DeleteQuestionDialog(); bool?dialogResult = dialog.ShowDialog(); if (!dialogResult.HasValue) { return; } if (dialogResult.Value) { m_Project.DeleteItemGroup(groupElement); } } } else { DeleteItemGroupBtn.IsEnabled = false; } } }
private string ReplaceString(PackagedProjectFile contextPackagedProjectFile, string str, string filePath, bool isVisible, string replaceItemGroup, string replaceXmlItemGroup) { var groupElement = new ItemGroupElement(contextPackagedProjectFile, filePath, isVisible); var(itemGroupElement, itemGroupElementOfXaml) = groupElement.GetItemGroup(); return(str.Replace(replaceItemGroup, itemGroupElement.ToString()) .Replace(replaceXmlItemGroup, itemGroupElementOfXaml.ToString())); }
private void ItemGroupsChanged(object sender, RoutedEventArgs e) { bool isEnabled = false; GroupElement groupElement = ItemGroups.SelectedItem as GroupElement; if (groupElement != null) { ItemGroupElement selElm = groupElement.ElementBase as ItemGroupElement; isEnabled = (selElm != null); } DeleteItemGroupBtn.IsEnabled = isEnabled; AddItemBtn.IsEnabled = isEnabled; }
private void AddItem(object sender, RoutedEventArgs e) { GroupElement groupElement = ItemGroups.SelectedItem as GroupElement; if (groupElement != null) { ItemGroupElement selElm = groupElement.ElementBase as ItemGroupElement; if (selElm != null) { if (!selElm.IsImported) { AddItemDialog dialog = new AddItemDialog(selElm.PredominateType); bool? dialogResult = dialog.ShowDialog(); if (!dialogResult.HasValue) { return; } if (dialogResult.Value) { //Catch any errors and display them to the user try { selElm.ItemGroup.AddNewItem(dialog.ItemName, "(Nothing)"); groupElement.Refresh(); } catch (System.Xml.XmlException ex) { ErrorDialog errorMessage = new ErrorDialog(ex.Message); errorMessage.ShowDialog(); } catch (ArgumentException ex) { ErrorDialog errorMessage = new ErrorDialog(ex.Message); errorMessage.ShowDialog(); } } } } else { AddItemBtn.IsEnabled = false; } } }
private void DrawGroupElement(MapItem item, ItemGroupElement element, Rectangle workplaceRectangle, int curHeight) { //Calculate group element rectangle Rectangle elementRectangle = new Rectangle(workplaceRectangle.X + GroupElementLeftPadding, curHeight, workplaceRectangle.Width - GroupElementSpaceHeight - GroupElementLeftPadding, GroupElementAreaHeight); //Get element text according to nesting level string text = string.Empty; if (element.NestingLevel > 0) { for (int i = 0; i < element.NestingLevel; i++) { text += i < element.NestingLevel - 1 ? " " : " "; } text = string.Format("{0}• {1}", text, element.Text); } else { text = element.Text; } //Create item control for element ItemButton button = CreateItemButton(item, elementRectangle, ButtonColor, ButtonCaptionColor, GroupElementFont, 0, null, false, text, element, null, null); Rectangle iconStateRectangle = new Rectangle(workplaceRectangle.X + GroupSpaceHeight, curHeight, 16, 16); CreateItemImage(item, iconStateRectangle, element.Icon, element.IconVisible, element.IconCursor, element.IconHint, button, null, null); }