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;
        }
        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;
        }
        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;
        }
        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;
        }