public void AddMenuItem(ContextMenuItem item)
 {
     if (item != null)
     {
         itemsPanel.Children.Add(item);
         item.ItemClick += new EventHandler(item_ItemClick);
     }
 }
        void ShowSubmenu(ContextMenuItem item)
        {
            if (item != null && item.HasSubMenu)
            {
                Rect p = AgControlBase.GetSLBounds(item);
                item.SubMenu.SetLocation(new Point(p.Right, p.Top + 6));
                item.SubMenu.Opened      -= new EventHandler(SubMenu_Opened);
                item.SubMenu.Opened      += new EventHandler(SubMenu_Opened);
                item.SubMenu.Closed      -= new EventHandler(SubMenu_Closed);
                item.SubMenu.Closed      += new EventHandler(SubMenu_Closed);
                item.SubMenu.MouseEnter  -= new MouseEventHandler(SubMenu_MouseEnter);
                item.SubMenu.MouseEnter  += new MouseEventHandler(SubMenu_MouseEnter);
                item.SubMenu.Collapsed   -= new EventHandler(SubMenu_Collapsed);
                item.SubMenu.Collapsed   += new EventHandler(SubMenu_Collapsed);
                item.SubMenu.ItemClicked -= new EventHandler(SubMenu_ItemClicked);
                item.SubMenu.ItemClicked += new EventHandler(SubMenu_ItemClicked);

                item.SubMenu.IsDropDownOpen = true;
                return;
            }
        }
        protected virtual CustomContextMenu CreateContextMenu()
        {
            CustomContextMenu menu = new CustomContextMenu();
            m_ItemCut = new ContextMenuItem(Localization.ContextCmd_Cut);
            m_ItemCut.Icon = UriResources.Images.Cut16;
            m_ItemCut.ItemClick += new EventHandler(itemCut_ItemClick);
            menu.AddMenuItem(m_ItemCut);
            m_ItemCopy = new ContextMenuItem(Localization.ContextCmd_Copy);
            m_ItemCopy.Icon = UriResources.Images.Copy16;
            m_ItemCopy.ItemClick += new EventHandler(itemCopy_ItemClick);
            menu.AddMenuItem(m_ItemCopy);
            m_ItemPaste = new ContextMenuItem(Localization.ContextCmd_Paste);
            m_ItemPaste.Icon = UriResources.Images.Paste16;
            m_ItemPaste.ItemClick += new EventHandler(itemPaste_ItemClick);
            menu.AddMenuItem(m_ItemPaste);
            m_ItemDelete = new ContextMenuItem(Localization.ContextCmd_Delete);
            m_ItemDelete.Icon = UriResources.Images.Delete16;
            m_ItemDelete.ItemClick += new EventHandler(itemDelete_ItemClick);
            menu.AddMenuItem(m_ItemDelete);
            menu.AddMenuSplitter();
            ContextMenuItem item = new ContextMenuItem(Localization.ContextCmd_SelectAll);
            item.ItemClick += new EventHandler(itemSelectAll_ItemClick);
            menu.AddMenuItem(item);

            return menu;
        }
        private CustomContextMenu CreateContextMenu(AreaType areaType)
        {
            CustomContextMenu contextMenu = new CustomContextMenu();
            contextMenu.Opened += new EventHandler(contextMenu_Opened);
            contextMenu.Closed += new EventHandler(contextMenu_Closed);
            ContextMenuItem item;

            if ((areaType == AreaType.RowsArea && Rows_IsInteractive) ||
                (areaType == AreaType.ColumnsArea && Columns_IsInteractive))
            {
                item = new ContextMenuItem(Localization.PivotGrid_Expand);
                item.Tag = MemberActionType.Expand;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Expand_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Expand_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.PivotGrid_Collapse);
                item.Tag = MemberActionType.Collapse;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Collapse_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Collapse_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.PivotGrid_DrillDown);
                item.Tag = MemberActionType.DrillDown;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Drilldown_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Drilldown_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                contextMenu.AddMenuSplitter();
            }

            // Пуекты для сортировки элементов
            if ((areaType == AreaType.RowsArea) ||
                (areaType == AreaType.ColumnsArea))
            {
                item = new ContextMenuItem(Localization.ContextMenu_SortingByProperty);
                item.Tag = ControlActionType.SortingByProperty;
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.ContextMenu_SortingByMeasure);
                item.Tag = ControlActionType.SortingAxisByMeasure;
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.ContextMenu_SortingByValue);
                item.Tag = ControlActionType.SortingByValue;
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                //item = new ContextMenuItem(Localization.ContextMenu_ClearAxisSorting);
                //item.Tag = ControlActionType.ClearAxisSorting;
                //contextMenu.AddMenuItem(item);
                //item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                contextMenu.AddMenuSplitter();
            }

            if (areaType == AreaType.CellsArea)
            {

                m_CopyValueMenuItem = new ContextMenuItem(Localization.ContextMenu_CopyValue + "      ");
                m_CopyValueMenuItem.Tag = ControlActionType.ValueCopy;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_CopyValueMenuItem);
                m_CopyValueMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_DeliveryValueMenuItem = new ContextMenuItem(Localization.ContextMenu_DeliveryValue + "      ");
                m_DeliveryValueMenuItem.Tag = ControlActionType.ValueDelivery;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_DeliveryValueMenuItem);
                m_DeliveryValueMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_DeliveryValueSplitter = contextMenu.AddMenuSplitter();

                m_DrillThroughMenuItem = new ContextMenuItem(Localization.ContextMenu_DrillThrough);
                m_DrillThroughMenuItem.Tag = ControlActionType.DrillThrough;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_DrillThroughMenuItem);
                m_DrillThroughMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_CopySelectedCellsMenuItem = new ContextMenuItem(Localization.ContextMenu_Copy);
                m_CopySelectedCellsMenuItem.Tag = ControlActionType.Copy;
                m_CopySelectedCellsMenuItem.Icon = UriResources.Images.Copy16;
                contextMenu.AddMenuItem(m_CopySelectedCellsMenuItem);
                m_CopySelectedCellsMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_PasteSelectedCellsMenuItem = new ContextMenuItem(Localization.ContextMenu_Paste);
                m_PasteSelectedCellsMenuItem.Tag = ControlActionType.Paste;
                m_PasteSelectedCellsMenuItem.Icon = UriResources.Images.Paste16;
                contextMenu.AddMenuItem(m_PasteSelectedCellsMenuItem);
                m_PasteSelectedCellsMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_CopyCellsSplitter = contextMenu.AddMenuSplitter();

                if (!CanEdit)
                {
                    m_PasteSelectedCellsMenuItem.Visibility = Visibility.Collapsed;
                    m_CopyValueMenuItem.Visibility = Visibility.Collapsed;
                    m_DeliveryValueMenuItem.Visibility = Visibility.Collapsed;
                    m_DeliveryValueSplitter.Visibility = Visibility.Collapsed;
                }
                else
                {
                    m_PasteSelectedCellsMenuItem.IsEnabled = EditMode & CanEdit;
                }

                if (!DrillThroughCells)
                    m_DrillThroughMenuItem.Visibility = Visibility.Collapsed;
            }

            item = new CheckedContectMenuItem(Localization.ContextMenu_AutoWidthColumns);
            item.Tag = ControlActionType.AutoWidth;
            (item as CheckedContectMenuItem).IsChecked = AutoWidthColumns;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            #region Подменю для управления режимом реорганизации данных
            CustomContextMenu subMenu1 = new CustomContextMenu();
            item = new CheckedContectMenuItem(Localization.ContextMenu_DataReorganizationType_None);
            item.Tag = ControlActionType.DataReorganizationType_None;
            subMenu1.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            item = new CheckedContectMenuItem(Localization.ContextMenu_DataReorganizationType_MergeNeighbors);
            item.Tag = ControlActionType.DataReorganizationType_MergeNeighbors;
            subMenu1.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            item = new CheckedContectMenuItem(Localization.ContextMenu_DataReorganizationType_HitchToParent);
            item.Tag = ControlActionType.DataReorganizationType_HitchToParent;
            subMenu1.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            item = new ContextMenuItem(Localization.ContextMenu_DataReorganizationType);
            item.Tag = ControlActionType.DataReorganizationType;
            item.SubMenu = subMenu1;
            contextMenu.AddMenuItem(item);
            #endregion

            item = new ContextMenuItem(Localization.ContextMenu_ShowMDX);
            item.Tag = ControlActionType.ShowMDX;
            item.Icon = UriResources.Images.Mdx16;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            if (areaType == AreaType.RowsArea || areaType == AreaType.ColumnsArea)
            {
                item = new ContextMenuItem(Localization.ContextMenu_CustomProperties);
                item.Tag = ControlActionType.ShowAttributes;
                item.Icon = UriResources.Images.MemberProperty16;
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);
            }

            item = new ContextMenuItem(Localization.ContextMenu_Properties);
            item.Tag = ControlActionType.ShowProperties;
            item.Icon = UriResources.Images.LevelProperty16;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            return contextMenu;
        }
        protected virtual CustomContextMenu CreateContextMenu()
        {
            CustomContextMenu contextMenu = new CustomContextMenu();
            ContextMenuItem item;

            m_MoveUp_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_MoveUp);
            m_MoveUp_MenuItem.Icon = UriResources.Images.Up16;
            contextMenu.AddMenuItem(m_MoveUp_MenuItem);
            m_MoveUp_MenuItem.ItemClick += new EventHandler(MoveUp_ItemClick);

            m_MoveDown_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_MoveDown);
            m_MoveDown_MenuItem.Icon = UriResources.Images.Down16;
            contextMenu.AddMenuItem(m_MoveDown_MenuItem);
            m_MoveDown_MenuItem.ItemClick += new EventHandler(MoveDown_ItemClick);

            //contextMenu.AddMenuSplitter();

            item = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_RemoveField);
            item.Icon = UriResources.Images.RemoveHot16;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(Remove_ItemClick);

            // Используем открытие и закрытие меню для работы с тултипом
            contextMenu.PopupControl.Closed -= new EventHandler(PopupControl_Closed);
            contextMenu.PopupControl.Closed += new EventHandler(PopupControl_Closed);
            contextMenu.PopupControl.Opened -= new EventHandler(PopupControl_Opened);
            contextMenu.PopupControl.Opened += new EventHandler(PopupControl_Opened);
            return contextMenu;
        }
 public void AddMenuItem(ContextMenuItem item)
 {
     if(item != null)
     {
         itemsPanel.Children.Add(item);
         item.ItemClick += new EventHandler(item_ItemClick);
     }
 }
        private CustomContextMenu CreateContextMenu(AreaType areaType)
        {
            CustomContextMenu contextMenu = new CustomContextMenu();
            contextMenu.Opened += new EventHandler(contextMenu_Opened);
            contextMenu.Closed += new EventHandler(contextMenu_Closed);
            ContextMenuItem item;

            if ((areaType == AreaType.RowsArea && Rows_IsInteractive) ||
                (areaType == AreaType.ColumnsArea && Columns_IsInteractive))
            {
                item = new ContextMenuItem(Localization.PivotGrid_Expand);
                item.Tag = MemberActionType.Expand;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Expand_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Expand_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.PivotGrid_Collapse);
                item.Tag = MemberActionType.Collapse;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Collapse_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Collapse_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                item = new ContextMenuItem(Localization.PivotGrid_DrillDown);
                item.Tag = MemberActionType.DrillDown;
                if (areaType == AreaType.RowsArea)
                {
                    item.Shortcut = Localization.PivotGrid_Rows_Drilldown_ShortCut;
                }
                else
                {
                    item.Shortcut = Localization.PivotGrid_Columns_Drilldown_ShortCut;
                }
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);

                contextMenu.AddMenuSplitter();
            }

            if (areaType == AreaType.CellsArea)
            {

                m_CopyValueMenuItem = new ContextMenuItem(Localization.ContextMenu_CopyValue + "      ");
                m_CopyValueMenuItem.Tag = ControlActionType.ValueCopy;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_CopyValueMenuItem);
                m_CopyValueMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_DeliveryValueMenuItem = new ContextMenuItem(Localization.ContextMenu_DeliveryValue + "      ");
                m_DeliveryValueMenuItem.Tag = ControlActionType.ValueDelivery;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_DeliveryValueMenuItem);
                m_DeliveryValueMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_DeliveryValueSplitter = contextMenu.AddMenuSplitter();

                m_DrillThroughMenuItem = new ContextMenuItem(Localization.ContextMenu_DrillThrough);
                m_DrillThroughMenuItem.Tag = ControlActionType.DrillThrough;
                //item.Icon = UriResources.Images.ActionNode16;
                contextMenu.AddMenuItem(m_DrillThroughMenuItem);
                m_DrillThroughMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_CopySelectedCellsMenuItem = new ContextMenuItem(Localization.ContextMenu_Copy);
                m_CopySelectedCellsMenuItem.Tag = ControlActionType.Copy;
                m_CopySelectedCellsMenuItem.Icon = UriResources.Images.Copy16;
                contextMenu.AddMenuItem(m_CopySelectedCellsMenuItem);
                m_CopySelectedCellsMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_PasteSelectedCellsMenuItem = new ContextMenuItem(Localization.ContextMenu_Paste);
                m_PasteSelectedCellsMenuItem.Tag = ControlActionType.Paste;
                m_PasteSelectedCellsMenuItem.Icon = UriResources.Images.Paste16;
                contextMenu.AddMenuItem(m_PasteSelectedCellsMenuItem);
                m_PasteSelectedCellsMenuItem.ItemClick += new EventHandler(ContextMenu_ItemClick);

                m_CopyCellsSplitter = contextMenu.AddMenuSplitter();

                if (!CanEdit)
                {
                    m_PasteSelectedCellsMenuItem.Visibility = Visibility.Collapsed;
                    m_CopyValueMenuItem.Visibility = Visibility.Collapsed;
                    m_DeliveryValueMenuItem.Visibility = Visibility.Collapsed;
                    m_DeliveryValueSplitter.Visibility = Visibility.Collapsed;
                }
                else
                {
                    m_PasteSelectedCellsMenuItem.IsEnabled = EditMode & CanEdit;
                }

                if (!DrillThroughCells)
                    m_DrillThroughMenuItem.Visibility = Visibility.Collapsed;
            }

            item = new ContextMenuItem(Localization.ContextMenu_ShowMDX);
            item.Tag = ControlActionType.ShowMDX;
            item.Icon = UriResources.Images.Mdx16;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            if (areaType == AreaType.RowsArea || areaType == AreaType.ColumnsArea)
            {
                item = new ContextMenuItem(Localization.ContextMenu_CustomProperties);
                item.Tag = ControlActionType.ShowAttributes;
                item.Icon = UriResources.Images.MemberProperty16;
                contextMenu.AddMenuItem(item);
                item.ItemClick += new EventHandler(ContextMenu_ItemClick);
            }

            item = new ContextMenuItem(Localization.ContextMenu_Properties);
            item.Tag = ControlActionType.ShowProperties;
            item.Icon = UriResources.Images.LevelProperty16;
            contextMenu.AddMenuItem(item);
            item.ItemClick += new EventHandler(ContextMenu_ItemClick);

            return contextMenu;
        }
        void ctrl_ContextMenuCreated(object sender, EventArgs e)
        {
            AreaItemControl item = sender as AreaItemControl;
            if (item != null)
            {
                if (item.ContextMenu.Items.Count > 0)
                {
                    ContextMenuSplitter splitter = item.ContextMenu.AddMenuSplitter();
                    splitter.Tag = item;
                    splitter.Visibility = Visibility.Collapsed;
                    m_MoveSplitters[item] = splitter;

                    if (item is Values_AreaItemControl)
                    {
                        // Спец. элемент
                    }
                    else
                    {
                        ContextMenuItem MoveToFilters_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_MoveToFiltersArea);
                        MoveToFilters_MenuItem.Icon = UriResources.Images.FiltersArea16;
                        MoveToFilters_MenuItem.ItemClick += new EventHandler(MoveToFilters_MenuItem_ItemClick);
                        item.ContextMenu.AddMenuItem(MoveToFilters_MenuItem);
                        MoveToFilters_MenuItem.Tag = item;
                        MoveToFilters_MenuItem.Visibility = Visibility.Collapsed;
                        m_MoveToFilters_MenuItems[item] = MoveToFilters_MenuItem;
                    }

                    ContextMenuItem MoveToRows_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_MoveToRowsArea);
                    MoveToRows_MenuItem.Icon = UriResources.Images.RowsArea16;
                    MoveToRows_MenuItem.ItemClick += new EventHandler(MoveToRows_MenuItem_ItemClick);
                    item.ContextMenu.AddMenuItem(MoveToRows_MenuItem);
                    MoveToRows_MenuItem.Tag = item;
                    MoveToRows_MenuItem.Visibility = Visibility.Collapsed;
                    m_MoveToRows_MenuItems[item] = MoveToRows_MenuItem;

                    ContextMenuItem MoveToColumns_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_MoveToColumnsArea);
                    MoveToColumns_MenuItem.Icon = UriResources.Images.ColumnsArea16;
                    MoveToColumns_MenuItem.ItemClick += new EventHandler(MoveToColumns_MenuItem_ItemClick);
                    item.ContextMenu.AddMenuItem(MoveToColumns_MenuItem);
                    MoveToColumns_MenuItem.Tag = item;
                    MoveToColumns_MenuItem.Visibility = Visibility.Collapsed;
                    m_MoveToColumns_MenuItems[item] = MoveToColumns_MenuItem;
                }
            }
        }
        protected override Ranet.AgOlap.Controls.ContextMenu.CustomContextMenu CreateContextMenu()
        {
            CustomContextMenu contextMenu = base.CreateContextMenu();

            if (contextMenu.Items.Count > 0)
            {
                contextMenu.AddMenuSplitter();
            }

            m_Cancel_Filter_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_CancelFilter);
            m_Cancel_Filter_MenuItem.Icon = UriResources.Images.CancelFilter16;
            contextMenu.AddMenuItem(m_Cancel_Filter_MenuItem);
            m_Cancel_Filter_MenuItem.ItemClick += new EventHandler(m_Cancel_Filter_MenuItem_ItemClick);

            m_MembersFilter_MenuItem = new ContextMenuItem(Localization.MdxDesigner_ContextMenu_ChangeFilter);
            m_MembersFilter_MenuItem.Icon = UriResources.Images.ChangeFilter16;
            contextMenu.AddMenuItem(m_MembersFilter_MenuItem);
            m_MembersFilter_MenuItem.ItemClick += new EventHandler(m_Members_Filter_MenuItem_ItemClick);

            Refresh();
            return contextMenu;
        }
        void ShowSubmenu(ContextMenuItem item)
        {
            if (item != null && item.HasSubMenu)
            {
                Rect p = AgControlBase.GetSLBounds(item);
                item.SubMenu.SetLocation(new Point(p.Right, p.Top + 6));
                item.SubMenu.Opened -= new EventHandler(SubMenu_Opened);
                item.SubMenu.Opened += new EventHandler(SubMenu_Opened);
                item.SubMenu.Closed -= new EventHandler(SubMenu_Closed);
                item.SubMenu.Closed += new EventHandler(SubMenu_Closed);
                item.SubMenu.MouseEnter -= new MouseEventHandler(SubMenu_MouseEnter);
                item.SubMenu.MouseEnter += new MouseEventHandler(SubMenu_MouseEnter);
                item.SubMenu.Collapsed -= new EventHandler(SubMenu_Collapsed);
                item.SubMenu.Collapsed += new EventHandler(SubMenu_Collapsed);
                item.SubMenu.ItemClicked -= new EventHandler(SubMenu_ItemClicked);
                item.SubMenu.ItemClicked += new EventHandler(SubMenu_ItemClicked);

                item.SubMenu.IsDropDownOpen = true;
                return;
            }
        }