private async void Item_LocationChanged(IAreaContents areaitem, Point value) { if (areaitem is MockAreaContents mock) { await _shortPathLine.SetLineAsync(new Point(_item1.Left, _item1.Top), new Point(_item2.Left, _item2.Top), new Rect(), _obstacles.Select(_ => _.Bounds).ToArray()); } }
public void Add(IAreaContents areaItem) { if (areaItem is UIElement uIElement) { if (!ContentsCanvas.Children.Contains(uIElement)) { ContentsCanvas.Children.Add(uIElement); SetGroupe(areaItem, areaItem.Group); SetSelect(areaItem, areaItem.Select); } } }
public void Remove(IAreaContents areaItem) { var selectOperator = GetSelectOperator(areaItem); if (selectOperator != null) { ContentsCanvas.Children.Remove(selectOperator); SelectOperators.Remove(selectOperator); } if (SelectOperators.Count == 1) { SelectOperators[0].Edit = true; } }
public void Add(IAreaContents areaItem) { var selectOperator = new ContentsOperator() { Contents = areaItem, }; SelectOperators.Add(selectOperator); ContentsCanvas.Children.Add(selectOperator); if (SelectOperators.Count == 1) { selectOperator.Edit = true; } else { SelectOperators.ForEach(item => item.Edit = false); } }
public void Remove(IAreaContents areaItem) { if (areaItem is UIElement uIElement) { if (ContentsCanvas.Children.Contains(uIElement)) { ContentsCanvas.Children.Remove(uIElement); if (string.IsNullOrEmpty(areaItem.Group)) { Grouped[areaItem.Group].Remove(areaItem); if (Grouped[areaItem.Group].Count == 0) { Grouped.Remove(areaItem.Group); } } if (areaItem.Select) { AreaItemSelectOperator.Remove(areaItem); Selected.Remove(areaItem); } } } }
public void SetGroupe(IAreaContents areaItem, string value) { foreach (var group in Grouped) { if (group.Value.IndexOf(areaItem) > 0) { group.Value.Remove(areaItem); if (group.Value.Count == 0) { Grouped.Remove(value); } break; } } if (!string.IsNullOrEmpty(value)) { if (!Grouped.ContainsKey(value)) { Grouped[value] = new AreaItems(); } Grouped[value].Add(areaItem); } }
public void SetSelect(IAreaContents areaItem, bool value) { if (!string.IsNullOrEmpty(areaItem.Group)) { Debug.Assert(Grouped.ContainsKey(areaItem.Group)); Grouped[areaItem.Group].ForEach(item => { if (item.Select != value) { item.Select = value; } if (value) { Selected.Add(item); AreaItemSelectOperator.Add(item); } else { AreaItemSelectOperator.Remove(item); Selected.Remove(item); } }); } else { if (value) { Selected.Add(areaItem); AreaItemSelectOperator.Add(areaItem); } else { AreaItemSelectOperator.Remove(areaItem); Selected.Remove(areaItem); } } }
public ContentsOperator GetSelectOperator(IAreaContents areaItem) { return(SelectOperators.Where(x => x.Contents == areaItem).FirstOrDefault()); }