public void ReleaseResources() { if (_item != null) { _item = null; } if (Children.Count > 0) { foreach (LayoutItem item in Children) { item.ReleaseResources(); } Children.Clear(); } }
private void RemoveSelector() { if (_isItemSelected) { _isItemSelected = false; if (_selection != null) { if (_adornerLayer != null) { var adorners = _adornerLayer.GetAdorners(_selection); if (adorners != null && adorners.Length > 0) { _adornerLayer.Remove(adorners[0]); } } _selection = null; UpdateTitle(); } } }
private void mainCanvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { RemoveSelector(); _selection = e.Source as ItemControl; if (_selection != null) { e.Handled = true; Helper.BringToFront(_selection); _isItemSelected = true; _isMousePressed = true; _originalMousePosition = e.GetPosition(mainCanvas); _originalElementPosition = new Point(Canvas.GetLeft(_selection), Canvas.GetTop(_selection)); _adornerLayer = AdornerLayer.GetAdornerLayer(_selection); _adornerLayer.Add(new ResizingAdorner(_selection, _selection.IsResizable)); UpdateTitle(); } }
public static List <Group> Load(string path) { var groups = new List <Group>(); var doc = new XmlDocument(); doc.Load(path); foreach (SettingGroup settingGroup in Settings.Groups) { var group = new Group { DisplayName = settingGroup.Name, ForceCollapse = settingGroup.ForceCollapse }; foreach (SettingItem settingItem in settingGroup.ItemSettings) { XmlNode layoutNode = doc.SelectSingleNode(String.Format("/UI/Layouts/Layout[@ID='{0}']", settingItem.LayoutID)); if (layoutNode != null) { XmlNodeList itemNodes; if (settingItem.ID == "*") { itemNodes = layoutNode.SelectNodes("Element"); } else { itemNodes = layoutNode.SelectNodes(String.Format("Element[@ID='{0}']", settingItem.ID)); } if (itemNodes != null) { foreach (XmlNode itemNode in itemNodes) { #region Parse the Child Element var item = new ItemControl { ID = itemNode.Attributes["ID"].Value, LayoutID = itemNode.ParentNode.Attributes["ID"].Value, IsResizable = settingItem.CanResize, BackgroundColor = settingItem.BackgroundColor, TextColor = settingItem.TextColor, RequestedMinWidthRatio = settingItem.MinSize.Width, RequestedMinHeightRatio = settingItem.MinSize.Height, RequestedTopRatio = double.Parse(itemNode.Attributes["Y"].Value), RequestedLeftRatio = double.Parse(itemNode.Attributes["X"].Value), RequestedHeightRatio = double.Parse(itemNode.Attributes["Height"].Value), RequestedWidthRatio = double.Parse(itemNode.Attributes["Width"].Value) }; #region Create the Display Name if (String.IsNullOrWhiteSpace(settingItem.Name)) { string displayName = item.ID; if (item.ID.StartsWith("UndockedShortcut")) { // Let's make this a little prettier for the user // UndockedShortcut2_Vertical_MarkerList int.TryParse(displayName.Split('_')[0].Replace("UndockedShortcut", ""), out int index); displayName = "Shortcut " + (index + 1); } else if (item.ID.StartsWith("UndockedHenchmen")) { // Let's make this a little prettier for the user // UndockedHenchmen0_Horizontal_MarkerList int.TryParse(displayName.Split('_')[0].Replace("UndockedHenchmen", ""), out int index); displayName = "Hireling " + (index + 1); } else { // Various names // FellowshipDisplay, ArenaScoring_SummaryPanel, Guild_Bank_Field, PendingChallengeButton displayName = displayName.Replace("_", " "); displayName = Regex.Replace(Regex.Replace(displayName, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2"); displayName = Regex.Replace(displayName, @"[ ]{2,}", @" ", RegexOptions.None); } item.DisplayName = displayName; } else { item.DisplayName = settingItem.Name; } item.Visibility = Visibility.Collapsed; #endregion group.Items.Add(item); #endregion } } } } #region Item Sorting if (group.Items.Count > 0) { const string NumberFormat = "000000"; var sorted = group.Items.OrderBy(f => { if (f.ID.StartsWith("ChatDisplay")) { int.TryParse(f.ID.Replace("ChatDisplay", ""), out int index); return("ChatDisplay" + index.ToString(NumberFormat)); } if (f.ID.StartsWith("UndockedShortcut")) { int.TryParse(f.ID.Split('_')[0].Replace("UndockedShortcut", ""), out int index); return("ShortcutsBar" + index.ToString(NumberFormat)); } if (f.ID.StartsWith("UndockedHenchmen")) { int.TryParse(f.ID.Split('_')[0].Replace("UndockedHenchmen", ""), out int index); return("Hireling" + index.ToString(NumberFormat)); } return(f.Name); }); var x = sorted.ToList(); group.Items.Clear(); group.Items.AddRange(x); } #endregion if (group.Items.Count > 0) { groups.Add(group); } } return(groups); }
public LayoutItem(ItemControl item) { _item = item; Children = new ObservableCollection <LayoutItem>(); }