public void AddItem(AreaItemControl item) { // Если ListBoxItem ранее был удален из списка (при перетаскивании например), то item.Tag содержит тот ListBoxItem, который удалялся. И попытка создать новый и присвоить в Content текущий item приведет к ошибке, т.к. Parent остался старый // В этом случае просто восстановим ListBoxItem из св-ва Tag ListBoxItem list_Item = null; list_Item = item.Tag as ListBoxItem; if (list_Item == null) { list_Item = new ListBoxItem(); } list_Item.HorizontalContentAlignment = HorizontalAlignment.Stretch; item.Remove += new EventHandler(item_Remove); item.MoveUp += new EventHandler(item_MoveUp); item.MoveDown += new EventHandler(item_MoveDown); item.ShowContextMenu += new EventHandler <PositionArgs>(item_ShowContextMenu); item.ContextMenuCreated += new EventHandler(item_ContextMenuCreated); list_Item.Content = item; item.Tag = list_Item; m_List.Items.Add(list_Item); Raise_ItemsListChanged(); }
void item_ShowContextMenu(object sender, PositionArgs e) { AreaItemControl item = sender as AreaItemControl; if (item != null) { if (item.ContextMenu.IsDropDownOpen) { item.ContextMenu.IsDropDownOpen = false; } Raise_BeforeShowContextMenu(item); // Управляем доступностью кнопок Вверх/Вниз ListBoxItem list_Item = item.Tag as ListBoxItem; if (list_Item != null) { int indx = m_List.Items.IndexOf(list_Item); item.CanMoveUp = indx > 0; item.CanMoveDown = (indx > -1 && indx < m_List.Items.Count - 1); } else { item.CanMoveUp = false; item.CanMoveDown = false; } item.ContextMenu.SetLocation(e.Position); item.ContextMenu.Tag = item; item.ContextMenu.IsDropDownOpen = true; } }
public AreaItemArgs(AreaItemControl itemControl) { if (itemControl == null) { throw new ArgumentNullException("itemControl"); } ItemControl = itemControl; }
public void RemoveItem(AreaItemControl ctrl) { if (ctrl != null) { ctrl.Area = null; } m_ItemsList.RemoveItem(ctrl); }
public void RemoveItem(AreaItemControl ctrl, bool raise_ListChanged) { if (ctrl != null) { ctrl.Area = null; } m_ItemsList.RemoveItem(ctrl, raise_ListChanged); }
void item_ContextMenuCreated(object sender, EventArgs e) { AreaItemControl item = sender as AreaItemControl; if (item != null) { Raise_ContextMenuCreated(item); } }
void Raise_BeforeShowContextMenu(AreaItemControl item) { EventHandler <AreaItemArgs> handler = BeforeShowContextMenu; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
void Raise_ContextMenuCreated(AreaItemControl item) { EventHandler <AreaItemArgs> handler = ContextMenuCreated; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
void Raise_ItemRemoved(AreaItemControl item) { EventHandler <AreaItemArgs> handler = ItemRemoved; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
public void AddItem(AreaItemControl ctrl, bool raise_ItemsListChanged) { if (ctrl != null) { ctrl.Area = this; ctrl.DragStarted += new DragStartedEventHandler(ctrl_DragStarted); ctrl.DragDelta += new DragDeltaEventHandler(ctrl_DragDelta); ctrl.DragCompleted += new DragCompletedEventHandler(ctrl_DragCompleted); m_ItemsList.AddItem(ctrl, raise_ItemsListChanged); } }
void item_MoveUp(object sender, EventArgs e) { AreaItemControl item = sender as AreaItemControl; if (item != null) { ListBoxItem list_Item = item.Tag as ListBoxItem; if (list_Item != null) { int indx = m_List.Items.IndexOf(list_Item); if (indx > 0) { m_List.Items.RemoveAt(indx); // Контент убивается при удалении list_Item.Content = item; m_List.Items.Insert(indx - 1, list_Item); Raise_ItemsListChanged(); } } } }
public void RemoveItem(AreaItemControl item, bool raise_ListChanged) { if (item != null && item.Tag != null) { if (m_List.Items.Contains(item.Tag)) { m_List.Items.Remove(item.Tag); item.Remove -= new EventHandler(item_Remove); item.MoveUp -= new EventHandler(item_MoveUp); item.MoveDown -= new EventHandler(item_MoveDown); item.ShowContextMenu -= new EventHandler <PositionArgs>(item_ShowContextMenu); item.ContextMenuCreated -= new EventHandler(item_ContextMenuCreated); Raise_ItemRemoved(item); if (raise_ListChanged) { Raise_ItemsListChanged(); } } } }
public void Clear() { List <AreaItemControl> list = new List <AreaItemControl>(); foreach (ListBoxItem list_Item in m_List.Items) { AreaItemControl item = list_Item.Content as AreaItemControl; if (item != null) { list.Add(item); } } foreach (AreaItemControl item in list) { RemoveItem(item, false); } if (list.Count > 0) { Raise_ItemsListChanged(); } }
public DragAreaItemArgs(AreaItemControl item, T args) { Item = item; Args = args; }
public void AddItem(AreaItemControl item) { // Если ListBoxItem ранее был удален из списка (при перетаскивании например), то item.Tag содержит тот ListBoxItem, который удалялся. И попытка создать новый и присвоить в Content текущий item приведет к ошибке, т.к. Parent остался старый // В этом случае просто восстановим ListBoxItem из св-ва Tag ListBoxItem list_Item = null; list_Item = item.Tag as ListBoxItem; if (list_Item == null) { list_Item = new ListBoxItem(); } list_Item.HorizontalContentAlignment = HorizontalAlignment.Stretch; item.Remove += new EventHandler(item_Remove); item.MoveUp += new EventHandler(item_MoveUp); item.MoveDown += new EventHandler(item_MoveDown); item.ShowContextMenu += new EventHandler<PositionArgs>(item_ShowContextMenu); item.ContextMenuCreated += new EventHandler(item_ContextMenuCreated); list_Item.Content = item; item.Tag = list_Item; m_List.Items.Add(list_Item); Raise_ItemsListChanged(); }
public AreaItemArgs(AreaItemControl itemControl) { if (itemControl == null) throw new ArgumentNullException("itemControl"); ItemControl = itemControl; }
public void AddItem(AreaItemControl item) { AddItem(item, true); }
void ChangeMoveToFiltersVisibility(AreaItemControl item, Visibility type) { if (item != null) { if (m_MoveToFilters_MenuItems.ContainsKey(item)) { m_MoveToFilters_MenuItems[item].Visibility = type; } } }
void ChangeMoveSplitterVisibility(AreaItemControl item, Visibility type) { if (item != null) { if (m_MoveSplitters.ContainsKey(item)) { m_MoveSplitters[item].Visibility = type; } } }
public void RemoveItem(AreaItemControl item) { RemoveItem(item, true); }
void Raise_BeforeShowContextMenu(AreaItemControl item) { EventHandler<AreaItemArgs> handler = BeforeShowContextMenu; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
public void AddItem(AreaItemControl ctrl) { AddItem(ctrl, true); }
public void RemoveItem(AreaItemControl item) { RemoveItem(item, true); }
bool CanDragToArea(PivotAreaContainer container, AreaItemControl item) { if (item != null && container != null) { if (container == m_DataAreaContainer) { // В область данных можно таскать только меры, KPI и вычисляемые элементы if (item is Kpi_AreaItemControl || item is Measure_AreaItemControl || item is CalculatedMember_AreaItemControl) return true; } if (container == m_RowsAreaContainer || container == m_ColumnsAreaContainer) { // В область строк и колонок можно таскать: иерархии, уровни, Set(ы) и узел "Values" if (item is Hierarchy_AreaItemControl || item is Level_AreaItemControl || item is CalculateNamedSet_AreaItemControl || item is Values_AreaItemControl) return true; } if (container == m_FilterAreaContainer) { // В область фильтров можно таскать: иерархии, уровни if (item is Hierarchy_AreaItemControl || item is Level_AreaItemControl) return true; } } return false; }
void Raise_ItemRemoved(AreaItemControl item) { EventHandler<AreaItemArgs> handler = ItemRemoved; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
void Raise_ContextMenuCreated(AreaItemControl item) { EventHandler<AreaItemArgs> handler = ContextMenuCreated; if (handler != null) { handler(this, new AreaItemArgs(item)); } }
String BuildItemSet(AreaItemControl item) { String result = String.Empty; if (item != null) { InfoItemControl info_Item = item as InfoItemControl; if (info_Item != null) { FilteredItemControl filtered_Item = item as FilteredItemControl; if (filtered_Item != null && filtered_Item.FilteredWrapper != null) { if (filtered_Item.FilteredWrapper != null && filtered_Item.FilteredWrapper.CompositeFilter.MembersFilter.IsUsed && !String.IsNullOrEmpty(filtered_Item.FilteredWrapper.CompositeFilter.MembersFilter.FilterSet)) result = filtered_Item.FilteredWrapper.CompositeFilter.MembersFilter.FilterSet; else { Hierarchy_AreaItemControl hierarchy_Item = item as Hierarchy_AreaItemControl; if (hierarchy_Item != null) { return String.Format(HIERARCHY_MEMBERS_SET_BLANK, hierarchy_Item.Hierarchy.UniqueName); } Level_AreaItemControl level_Item = item as Level_AreaItemControl; if (level_Item != null) { return String.Format(LEVEL_MEMBERS_SET_BLANK, level_Item.Level.UniqueName); } } } CalculatedMember_AreaItemControl calcMember_Item = item as CalculatedMember_AreaItemControl; if (calcMember_Item != null && calcMember_Item.CalculatedMember != null) { CalculationInfoBase info = GetCalculatedMember(calcMember_Item.CalculatedMember.Name); if (info != null) { return info.Name; } } CalculateNamedSet_AreaItemControl calculatedSet_Item = item as CalculateNamedSet_AreaItemControl; if (calculatedSet_Item != null) { CalculationInfoBase info = GetCalculatedNamedSet(calculatedSet_Item.CalculatedNamedSet.Name); if (info != null) { return info.Name; } } NamedSet_AreaItemControl set_Item = item as NamedSet_AreaItemControl; if (set_Item != null) { return OlapHelper.ConvertToQueryStyle(set_Item.NamedSet.Name); } Measure_AreaItemControl measure_Item = item as Measure_AreaItemControl; if (measure_Item != null) { return measure_Item.Measure.UniqueName; } Kpi_AreaItemControl kpi_Item = item as Kpi_AreaItemControl; if (kpi_Item != null) { if (kpi_Item.Type == KpiControlType.Goal) { return kpi_Item.Kpi.Custom_KpiGoal; } if (kpi_Item.Type == KpiControlType.Value) { return kpi_Item.Kpi.Custom_KpiValue; } if (kpi_Item.Type == KpiControlType.Status) { return kpi_Item.Kpi.Custom_KpiStatus; } if (kpi_Item.Type == KpiControlType.Trend) { return kpi_Item.Kpi.Custom_KpiTrend; } } } // Если специальный элемент VALUES if (item is Values_AreaItemControl) { result = String.Empty; foreach (AreaItemControl child in m_DataAreaContainer.Items) { String toAdd = String.Empty; Measure_AreaItemControl measure_Item = child as Measure_AreaItemControl; if (measure_Item != null) { toAdd = measure_Item.Measure.UniqueName; } CalculatedMember_AreaItemControl calcMember_Item = child as CalculatedMember_AreaItemControl; if (calcMember_Item != null && calcMember_Item.CalculatedMember != null) { CalculationInfoBase info = GetCalculatedMember(calcMember_Item.CalculatedMember.Name); if (info != null) { toAdd = info.Name; } } Kpi_AreaItemControl kpi_Item = item as Kpi_AreaItemControl; if (kpi_Item != null) { if (kpi_Item.Type == KpiControlType.Goal) { toAdd = kpi_Item.Kpi.Custom_KpiGoal; } if (kpi_Item.Type == KpiControlType.Value) { toAdd = kpi_Item.Kpi.Custom_KpiValue; } if (kpi_Item.Type == KpiControlType.Status) { toAdd = kpi_Item.Kpi.Custom_KpiStatus; } if (kpi_Item.Type == KpiControlType.Trend) { toAdd = kpi_Item.Kpi.Custom_KpiTrend; } } if (!String.IsNullOrEmpty(toAdd)) { if (!String.IsNullOrEmpty(result)) result += ", "; result += toAdd; } } } if (!String.IsNullOrEmpty(result)) { result = "{" + result + "}"; } } return result; }
public void RemoveItem(AreaItemControl item, bool raise_ListChanged) { if (item != null && item.Tag != null) { if (m_List.Items.Contains(item.Tag)) { m_List.Items.Remove(item.Tag); item.Remove -= new EventHandler(item_Remove); item.MoveUp -= new EventHandler(item_MoveUp); item.MoveDown -= new EventHandler(item_MoveDown); item.ShowContextMenu -= new EventHandler<PositionArgs>(item_ShowContextMenu); item.ContextMenuCreated -= new EventHandler(item_ContextMenuCreated); Raise_ItemRemoved(item); if (raise_ListChanged) { Raise_ItemsListChanged(); } } } }
void ChangeMoveItemsVisibility(AreaItemControl item, Visibility type) { if (item != null) { ChangeMoveSplitterVisibility(item, type); ChangeMoveToColumnsVisibility(item, type); ChangeMoveToFiltersVisibility(item, type); ChangeMoveToRowsVisibility(item, type); } }
public void AddItem(AreaItemControl item) { AddItem(item, true); }