public PivotMemberItem(MemberInfo member)
        {
            if (member == null)
                throw new ArgumentNullException("member");

            Member = member;
        }
 public TupleItem(MemberInfo member)
 {
     if (member == null)
         throw new ArgumentNullException("member");
     Info = member;
     Hierarchy = member.HierarchyUniqueName;
     Caption = member.Caption;
 }
 public MemberWrap(MemberInfo member) 
 {
     if (member == null)
         throw new ArgumentNullException("member");
     UniqueName = member.UniqueName;
     Caption = member.Caption;
     HierarchyUniqueName = member.HierarchyUniqueName;
 }
 public MemberActionEventArgs(
     int axisNum,
     MemberInfo member,
     MemberActionType action)
 {
     this.Axis = axisNum;
     this.Member = member;
     this.Action = action;
 }
 public MemberInfoItemControl(MemberInfo info)
 {
     if (info == null)
         throw new ArgumentNullException("info");
     
     m_Info = info;
     Text = info.Caption;
     
     Icon = UriResources.Images.Member16;
 }
 public MemberItem(MemberInfo data, double val, CellInfo cell)
 {
     if (data == null)
         throw new ArgumentNullException("data");
     Cell = cell;
     Member = data;
     Caption = data.Caption;
     m_OriginalValue = val;
     m_DeliveredValue = 0;
     m_NewValue = val;
 }
 public PerformMemberActionArgs(
     MemberInfo member,
     int axisIndex,
     MemberActionType action,
     List<MemberInfo> ascendants)
     :this()
 {
     this.Member = member;
     this.AxisIndex = axisIndex;
     this.Action = action;
     this.Ascendants = ascendants;
 }
        public ColumnMemberControl(PivotGridControl owner, MemberInfo info, int drillDownDepth)
            : base(owner, info)
        {
            Margin = new Thickness(0, drillDownDepth * owner.DRILLDOWN_SPACE_HEIGHT * Scale, 0, 0);

//            Border border = LayoutRoot;
            
//            int right_Offs = Member.DrilledDownChildren.Count > 0 ? 0 : MembersAreaContol.SPLITTER_SIZE;    
//            border.BorderThickness = new Thickness(0, 0, 1 + right_Offs, 1 + MembersAreaContol.SPLITTER_SIZE);
            

            if (drillDownDepth > 0)
            {
                ShowUpBorder(true);
            }
        }
        public RowMemberControl(PivotGridControl owner, MemberInfo info, int drillDownDepth) 
            : base(owner, info)
        {
            Margin = new Thickness(drillDownDepth * owner.DRILLDOWN_SPACE_WIDTH * Scale, 0, 0, 0);

//            Border border = LayoutRoot;
//            border.BorderThickness = new Thickness(0, 0, 1 + MembersAreaContol.SPLITTER_SIZE, 1 + MembersAreaContol.SPLITTER_SIZE);

            //if(Member.DrilledDownChildren.Count > 0)
            //{
            //    RootPanel.VerticalAlignment = VerticalAlignment.Top;
            //}

            if (drillDownDepth > 0)
            {
                ShowLeftBorder(true);
            }
        }
        public CellInfo(CellData cell_descr, MemberInfo column, MemberInfo row, IList<MemberInfo> invisibleCoords)
        {
            if (cell_descr == null)
            {
                throw new ArgumentNullException("cell_descr");
            }
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }
            if (row == null)
            {
                throw new ArgumentNullException("row");
            }
            if (invisibleCoords == null)
            {
                throw new ArgumentNullException("invisibleCoords");
            }

            CellDescr = cell_descr;
            ColumnMember = column;
            RowMember = row;
            InvisibleCoords = invisibleCoords;
        }
        private PivotMemberItem AddRowMember(List <PivotMemberItem> container, MemberInfo member, int columnIndex, int rowIndex, out int memberSize, int drillDepth)
        {
            // Добавляем в случае необходимости строку и столбец
            ColumnsCount = Math.Max(ColumnsCount, columnIndex + 1);
            RowsCount    = Math.Max(RowsCount, rowIndex + 1);

            // Сохраняем максимальной глубины DrillDown
            if (m_DrillDepth.ContainsKey(columnIndex))
            {
                m_DrillDepth[columnIndex] = Math.Max(m_DrillDepth[columnIndex], drillDepth);
            }
            else
            {
                m_DrillDepth[columnIndex] = drillDepth;
            }

            // Элемент сводной таблицы
            PivotMemberItem item = new PivotMemberItem(member);

            item.PivotDrillDepth = drillDepth;
            item.ColumnIndex     = columnIndex;
            item.RowIndex        = rowIndex;

            container.Add(item);

            // Дочерние элементы начинаются отображаться с той же строки. только в соседней колонке
            // Номер строки с которой начнется отображение элемента
            int start_Child_RowIndex = rowIndex;
            // Текущий индекс строки
            int current_Child_RowIndex = start_Child_RowIndex;
            // Размер добавляемого контрола (в строках)
            int size = 0;

            foreach (MemberInfo child in member.Children)
            {
                AddRowMember(item.Children, child, columnIndex + 1, current_Child_RowIndex, out size, 0);
                current_Child_RowIndex += size;
            }
            // Номер строки, на которой закончится отображение элемента
            int end_Child_RowIndex = current_Child_RowIndex;
            int ChildrenSize       = end_Child_RowIndex - start_Child_RowIndex;

            // Дрилл-даун дочерние отображаются в этой же колонке, но со строки следующей после самого элемента и всех дочерних
            // Номер строки с которой начнется отображение элемента
            int start_DrillDown_RowIndex = ChildrenSize > 0 ? end_Child_RowIndex : rowIndex + 1;
            // Текущий индекс строки
            int current_DrillDown_RowIndex = start_DrillDown_RowIndex;

            // Размер добавляемого контрола (в строках)
            size = 0;
            int i = 0;

            foreach (MemberInfo child in member.DrilledDownChildren)
            {
                PivotMemberItem dd_item = AddRowMember(item.DrillDownChildren, child, columnIndex, current_DrillDown_RowIndex, out size, drillDepth + 1);
                if (i == 0)
                {
                    dd_item.IsFirstDrillDownChild = true;
                }
                i++;
                current_DrillDown_RowIndex += size;
            }
            // Номер строки, на которой закончится отображение элемента
            int end_DrillDown_RowIndex = current_DrillDown_RowIndex;
            int DrillDownChildrenSize  = end_DrillDown_RowIndex - start_DrillDown_RowIndex;

            // Растягиваем элемент если есть дочерние
            int span_Size = 1;
            int span_Size_WithChildren = 1;

            if (ChildrenSize > 1)
            {
                span_Size_WithChildren = ChildrenSize;
            }
            if (DrillDownChildrenSize > 0)
            {
                span_Size = span_Size_WithChildren + DrillDownChildrenSize;
            }
            else
            {
                span_Size = span_Size_WithChildren;
            }

            if (span_Size > 1)
            {
                item.RowSpan = span_Size;
            }

            item.ChildrenSize          = ChildrenSize;
            item.DrillDownChildrenSize = DrillDownChildrenSize;
            memberSize = span_Size;
            return(item);
        }
        private void InitMemberInfo(MemberInfo info, MemberData member)
        {
            if (info == null || member == null)
                return;

            info.Caption = member.Caption;
            info.ChildCount = member.ChildCount;
            info.Description = member.Description;
            info.DrilledDown = member.DrilledDown;
            info.LevelDepth = member.LevelDepth;
            info.LevelName = member.LevelName;
            info.Name = member.Name;
            info.ParentSameAsPrevious = member.ParentSameAsPrevious;

            info.HierarchyUniqueName = member.HierarchyUniqueName;
            info.Custom_Rollup = member.Custom_Rollup;
            info.Unary_Operator = member.Unary_Operator;

            info.UniqueName = member.UniqueName;

            // В коллекцию свойств добавляем Properties
            foreach (PropertyData pair in member.Properties)
            {
                String caption = pair.Name;
                if (!info.PropertiesDictionary.ContainsKey(caption))
                    info.PropertiesDictionary.Add(caption, pair.Value);
            }

            // В коллекцию свойств добавляем MemberProperties
            foreach (PropertyData pair in member.MemberProperties)
            {
                String caption = pair.Name;
                if (caption.StartsWith("-") && caption.EndsWith("-"))
                    caption = caption.Trim('-');

                if (!info.PropertiesDictionary.ContainsKey(caption))
                    info.PropertiesDictionary.Add(caption, pair.Value);
            }

            // Для вычисляемых элементов свойство DrilledDown работает неправильно. 
            // Признаком того, что это вычисляемый элемент считаем KEY0 == null. В этом случае сбрасываем DrilledDown
            if (info.PropertiesDictionary.ContainsKey(MemberInfo.KEY0_PROPERTY) &&
                info.PropertiesDictionary[MemberInfo.KEY0_PROPERTY] == null)
            {
                info.DrilledDown = false;                
            }
        }
 internal SortDescriptor GetAxisPropertySort(int axis, MemberInfo info)
 {
     if (info != null && m_CellSetProvider != null)
     {
         Dictionary<String, SortDescriptor> sortInfo = null;
         if (axis == 0)
         {
             sortInfo = m_CellSetProvider.ColumnsSortInfo;
         }
         if (axis == 1)
         {
             sortInfo = m_CellSetProvider.RowsSortInfo;
         }
         if (sortInfo != null && sortInfo.ContainsKey(info.HierarchyUniqueName))
             return sortInfo[info.HierarchyUniqueName];
     }
     return null;
 }
		void LoadMemberAttributes(MemberInfo member, List<LevelPropertyInfo> properties)
		{
			IsWaiting = true;

			QueryProvider provider = new QueryProvider(m_CSDescr.CubeName, String.Empty, member.HierarchyUniqueName);
			String query = provider.GetMember(member.UniqueName, properties);
			LogManager.LogInformation(this, this.Name + " - Loading custom member properties.");
			MdxQueryArgs query_args = CommandHelper.CreateMdxQueryArgs(Connection, query);
			OlapDataLoader.LoadData(query_args, "CUSTOM_MEMBER_PROPERTIES");
		}
        private MemberInfo CreateMemberInfo(MemberData member)
        {
            if (member == null)
                return null;

            MemberInfo info = new MemberInfo();
            InitMemberInfo(info, member);

            return info;
        }    
 public MemberClickEventArgs(
     MemberInfo member, Point point)
     : this(member)
 {
     this.Position = point;
 }
		void ShowMemberAttributes(MemberInfo member)
		{
			if (member != null)
			{
				if (!m_LevelProperties.ContainsKey(member.HierarchyUniqueName))
				{
					IsWaiting = true;
					LogManager.LogInformation(this, this.Name + " - Loading level attributes.");
					MetadataQuery args = CommandHelper.CreateLoadLevelPropertiesArgs(Connection, m_CSDescr.CubeName, String.Empty, member.HierarchyUniqueName, String.Empty);
					OlapDataLoader.LoadData(args, new MemberInfoWrapper<MetadataQuery>(member, args));
				}
				else
				{
					LoadMemberAttributes(member, m_LevelProperties[member.HierarchyUniqueName]);
				}
			}
		}
 void Raise_PerformControlAction(ControlActionType action, MemberInfo info)
 {
     EventHandler<ControlActionEventArgs<MemberInfo>> handler = Members_PerformControlAction;
     if (handler != null)
     {
         handler(this, new ControlActionEventArgs<MemberInfo>(action, info));
     }
 }
 public MemberClickEventArgs(
     MemberInfo member)
 {
     this.Member = member;
 }
 internal MemberInfoItemControl(MemberInfo info, BitmapImage image)
     : this(info)
 {
     Icon = image;
 }
        public MemberControl(PivotGridControl owner, MemberInfo info)
            : base(owner)
        {
            BorderThickness = new Thickness(0, 0, 1, 1);

            DefaultStyleKey = typeof(MemberControl);
            HorizontalAlignment = HorizontalAlignment.Stretch;
            VerticalAlignment = VerticalAlignment.Stretch;
            HorizontalContentAlignment = HorizontalAlignment.Stretch;
            VerticalContentAlignment = VerticalAlignment.Top;

            if(info == null)
                throw new ArgumentNullException("info");
            
            m_Member = info;

            m_LayoutRoot = new Grid();
            m_LayoutRoot.Margin = new Thickness(2, 2 * Scale, 0, 0);
            m_LayoutRoot.VerticalAlignment = VerticalAlignment.Top;
            m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinition column02 = new ColumnDefinition();
            column02.MaxWidth = 0; /* чтобы при сжимании иконка надвигалась на текст макс. ширину будем далее задавать жестко*/
            m_LayoutRoot.ColumnDefinitions.Add(column02);
            m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            // Колонка для отображения режима сортировки
            m_LayoutRoot.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            if (IsInteractive)
            {
                if (Member.ChildCount > 0 && !Member.IsCalculated && !Member.IsDublicate)
                {
                    var expander = new PlusMinusButton();
                    if (Member.DrilledDown)
                        expander.IsExpanded = true;
                    expander.CheckedChanged += new EventHandler(expander_CheckedChanged);
                    UseExpandingCommands = true;
                    expander.Height = expander.Width = Math.Max(5, 9 * Scale);
                    m_LayoutRoot.Children.Add(expander);
                }
                else
                {
                    ListMemberControl ctrl = new ListMemberControl();
                    ctrl.Opacity = 0.35;
                    ctrl.Height = ctrl.Width = Math.Max(5, 9 * Scale);
                    m_LayoutRoot.Children.Add(ctrl);
                }
            }

            // Название элемента
            m_LayoutRoot.Children.Add(CaptionText);
            Grid.SetColumn(CaptionText, 1);

            // Визуализация DATAMEMBER, UNKNOWNMEMBER,CUSTOM_ROLLUP и UNARY_OPERATOR
            if (Member != null)
            {
                BitmapImage custom_image = null;

                if (Member.UniqueName.Trim().EndsWith("DATAMEMBER"))
                {
                    custom_image = UriResources.Images.DataMember16;
                }

                if (Member.UniqueName.Trim().EndsWith("UNKNOWNMEMBER"))
                {
                    custom_image = UriResources.Images.UnknownMember16;
                }

                // CUSTOM_ROLLUP отображается своей иконкой.
                // UNARY_OPERATOR - каждый своей иконкой.
                // Если оба свойства установлены, то отображаем скомбинированную иконку
                if(String.IsNullOrEmpty(Member.Unary_Operator))
                {
                    // Только CUSTOM_ROLLUP
                    if (Member.HasCustomRollup)
                    {
                        custom_image = UriResources.Images.CalcFunction16;
                    }
                }
                else
                {
                    // UNARY_OPERATOR
                    if (custom_image == null && Member.Unary_Operator.Trim() == "+")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionPlus16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcPlus16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "-")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionMinus16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcMinus16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "*")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionMultiply16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcMultiply16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "/")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionDivide16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcDivide16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "~")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionTilde16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcTilde16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "=")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionEqual16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcEqual16;
                        }
                    }
                    if (custom_image == null)
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionPercent16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcPercent16;
                        }
                    }
                }

                if (custom_image != null)
                {
                    Image image1 = new Image() { Margin = new Thickness(0, 0, 2, 0) };
                    image1.Width = Math.Max(8, 16 * Scale);
                    image1.Height = Math.Max(8, 16 * Scale);
                    image1.Source = custom_image;
                    m_LayoutRoot.Children.Add(image1);
                    Grid.SetColumn(image1, 3);
                }
            }

            m_EllipsisText = new TextBlock() { Text = "..." };
            m_EllipsisText.FontSize = Owner.DefaultFontSize * Scale;
            m_LayoutRoot.Children.Add(m_EllipsisText);
            m_EllipsisText.Margin = new Thickness(-1, 0, 0, 0);
            m_EllipsisText.TextAlignment = TextAlignment.Left;
            m_EllipsisText.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetColumn(m_EllipsisText, 2);
            m_EllipsisText.Visibility = Visibility.Collapsed;

            this.SizeChanged += new SizeChangedEventHandler(MemberControl_SizeChanged);
            this.Content = m_LayoutRoot;
            this.Click += new RoutedEventHandler(MemberControl_Click);

            m_SortByValueImage = new Image() { Width = 16, Height = 16 };
            m_SortByValueImage.Visibility = Visibility.Collapsed;
            //var m_SortSelector = new SortTypeSelector() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center };
            m_LayoutRoot.Children.Add(m_SortByValueImage);
            Grid.SetColumn(m_SortByValueImage, 4); 
        }
        public void Initialize(MemberInfo member)
        {
            m_PropertiesOwnerControl.Visibility = Visibility.Visible;
            m_PropertiesOwnerControl.Content = new MemberInfoItemControl(member);

            List<PropertyItem> list = new List<PropertyItem>();
            if (member != null && member.PropertiesDictionary != null)
            {
                foreach (KeyValuePair<String, object> pair in member.PropertiesDictionary)
                {
                    PropertyItem item = new PropertyItem();
                    item.Property = pair.Key;
                    if (item.Property == "DrilledDown")
                    {
                        // Элементы на оси объединяются если идут подряд одинаковые. При этом значение данного свойства формируется по ИЛИ
                        item.Value = member.DrilledDown.ToString();
                    }
                    else
                    {
                        if (pair.Value != null)
                        {
                            item.Value = pair.Value.ToString();
                        }
                        else
                        {
                            item.Value = String.Empty;
                        }
                    }
                    list.Add(item);
                }
            }

            m_PropertiesList.Initialize(list);
        }
 void m_Tupple_SelectedItemChanged(object sender, TupleItemArgs e)
 {
     if (e != null && e.Item != null)
     {
         m_CurrentTupleItem = e.Item.Info;
         m_MembersChoice.AHierarchyName = m_CurrentTupleItem.HierarchyUniqueName;
     }
     else
     {
         m_CurrentTupleItem = null;
         m_MembersChoice.AHierarchyName = String.Empty;
     }
 }
 public static PerformMemberActionArgs CreatePerformMemberActionArgs( 
     MemberInfo member,
     int axisIndex,
     MemberActionType action,
     List<MemberInfo> ascendants)
 {
     PerformMemberActionArgs args = new PerformMemberActionArgs();
     args.Member = member;
     args.AxisIndex = axisIndex;
     args.Action = action;
     args.Ascendants = ascendants;
     return args;
 }
        public MemberControl(PivotGridControl owner, MemberInfo info)
        {
            if (owner == null)
                throw new ArgumentNullException("owner");
            if(info == null)
                throw new ArgumentNullException("info");
            
            m_Member = info;
            Owner = owner;

            this.Margin = new Thickness(0, 0, 0, 0);

            m_Border = new Border();
            m_Border.BorderBrush = Owner.MembersBorder;
            m_Border.BorderThickness = new Thickness(0, 0, 1, 1);
            m_Border.CornerRadius = new CornerRadius(CORNER_RADIUS);
            
            m_Border.Background = Owner.MembersBackground;

            //m_Border.Child = RootPanel;
            m_Border.Child = LayoutRoot;

            if (IsInteractive)
            {
                CaptionText.MouseEnter += new MouseEventHandler(MemberControl_MouseEnter);
                CaptionText.MouseLeave += new MouseEventHandler(MemberControl_MouseLeave);
                CaptionText.MouseLeftButtonDown += new MouseButtonEventHandler(CaptionText_MouseLeftButtonDown);

                PlusMinusButton expander = null;
             
                if (Member.ChildCount > 0 && !Member.IsCalculated)
                {
                    expander = new PlusMinusButton();
                    if (Member.DrilledDown)
                        expander.IsExpanded = true;
                    expander.CheckedChanged += new EventHandler(expander_CheckedChanged);
                    UseExpandingCommands = true;
                    expander.Height = expander.Width = Math.Max(5, 9 * Scale);
                    LayoutRoot.Children.Add(expander);
                }
                else
                {
                    ListMemberControl ctrl = new ListMemberControl();
                    ctrl.Opacity = 0.35;
                    ctrl.Height = ctrl.Width = Math.Max(5, 9 * Scale);
                    LayoutRoot.Children.Add(ctrl);
                }

            }

            // Название элемента
            LayoutRoot.Children.Add(CaptionText);
            Grid.SetColumn(CaptionText, 1);

            // Визуализация DATAMEMBER, UNKNOWNMEMBER,CUSTOM_ROLLUP и UNARY_OPERATOR
            if (Member != null)
            {
                BitmapImage custom_image = null;

                if (Member.UniqueName.Trim().EndsWith("DATAMEMBER"))
                {
                    custom_image = UriResources.Images.DataMember16;
                }

                if (Member.UniqueName.Trim().EndsWith("UNKNOWNMEMBER"))
                {
                    custom_image = UriResources.Images.UnknownMember16;
                }

                // CUSTOM_ROLLUP отображается своей иконкой.
                // UNARY_OPERATOR - каждый своей иконкой.
                // Если оба свойства установлены, то отображаем скомбинированную иконку
                if(String.IsNullOrEmpty(Member.Unary_Operator))
                {
                    // Только CUSTOM_ROLLUP
                    if (Member.HasCustomRollup)
                    {
                        custom_image = UriResources.Images.CalcFunction16;
                    }
                }
                else
                {
                    // UNARY_OPERATOR
                    if (custom_image == null && Member.Unary_Operator.Trim() == "+")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionPlus16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcPlus16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "-")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionMinus16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcMinus16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "*")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionMultiply16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcMultiply16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "/")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionDivide16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcDivide16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "~")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionTilde16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcTilde16;
                        }
                    }
                    if (custom_image == null && Member.Unary_Operator.Trim() == "=")
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionEqual16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcEqual16;
                        }
                    }
                    if (custom_image == null)
                    {
                        if (Member.HasCustomRollup)
                        {
                            custom_image = UriResources.Images.CalcFunctionPercent16;
                        }
                        else
                        {
                            custom_image = UriResources.Images.CalcPercent16;
                        }
                    }
                }

                if (custom_image != null)
                {
                    Image image1 = new Image() { Margin = new Thickness(0, 0, 2, 0) };
                    image1.Width = Math.Max(8, 16 * Scale);
                    image1.Height = Math.Max(8, 16 * Scale);
                    image1.Source = custom_image;
                    LayoutRoot.Children.Add(image1);
                    Grid.SetColumn(image1, 3);
                }
            }

            m_EllipsisText = new TextBlock() { Text = "..." };
            m_EllipsisText.FontSize = Owner.DefaultFontSize * Scale;
            LayoutRoot.Children.Add(m_EllipsisText);
            m_EllipsisText.Margin = new Thickness(-1, 0, 0, 0);
            m_EllipsisText.TextAlignment = TextAlignment.Left;
            m_EllipsisText.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetColumn(m_EllipsisText, 2);
            m_EllipsisText.Visibility = Visibility.Collapsed;

            this.SizeChanged += new SizeChangedEventHandler(MemberControl_SizeChanged);

            //if(UseHint)
            //{
            //    // Текст подсказки
            //    IList<MemberInfo> anc = new List<MemberInfo>();
            //    this.Member.CollectAncestors(anc);
            //    StringBuilder sb = new StringBuilder();
            //    foreach (MemberInfo mv in anc)
            //    {
            //        sb.AppendLine(mv.Caption + " : " + mv.UniqueName);
            //    }
            //    String tupleToStr = sb.ToString();
            //    tupleToStr = tupleToStr.TrimEnd('\n');
            //    tupleToStr = tupleToStr.TrimEnd('\r');

            //    // Подсказка
            //    m_ToolTip = new ToolTipControl();
            //    m_ToolTip.Caption = CaptionText.Text;
            //    m_ToolTip.Text = tupleToStr;
            //    ToolTipService.SetToolTip(this, m_ToolTip);
            //}

            this.Content = m_Border;
        }
        private PivotMemberItem AddRowMember(List<PivotMemberItem> container, MemberInfo member, int columnIndex, int rowIndex, out int memberSize, int drillDepth)
        {
            // Добавляем в случае необходимости строку и столбец
            ColumnsCount = Math.Max(ColumnsCount, columnIndex + 1);
            RowsCount = Math.Max(RowsCount, rowIndex + 1);
            
            // Сохраняем максимальной глубины DrillDown
            if (m_DrillDepth.ContainsKey(columnIndex))
                m_DrillDepth[columnIndex] = Math.Max(m_DrillDepth[columnIndex], drillDepth);
            else
                m_DrillDepth[columnIndex] = drillDepth;

            // Элемент сводной таблицы
            PivotMemberItem item = new PivotMemberItem(member);
            item.PivotDrillDepth = drillDepth;
            item.ColumnIndex = columnIndex;
            item.RowIndex = rowIndex;

            container.Add(item);

            // Дочерние элементы начинаются отображаться с той же строки. только в соседней колонке
            // Номер строки с которой начнется отображение элемента
            int start_Child_RowIndex = rowIndex;
            // Текущий индекс строки
            int current_Child_RowIndex = start_Child_RowIndex;
            // Размер добавляемого контрола (в строках)
            int size = 0;
            foreach (MemberInfo child in member.Children)
            {
                AddRowMember(item.Children, child, columnIndex + 1, current_Child_RowIndex, out size, 0);
                current_Child_RowIndex += size;
            }
            // Номер строки, на которой закончится отображение элемента
            int end_Child_RowIndex = current_Child_RowIndex;
            int ChildrenSize = end_Child_RowIndex - start_Child_RowIndex;

            // Дрилл-даун дочерние отображаются в этой же колонке, но со строки следующей после самого элемента и всех дочерних
            // Номер строки с которой начнется отображение элемента
            int start_DrillDown_RowIndex = ChildrenSize > 0 ? end_Child_RowIndex : rowIndex + 1;
            // Текущий индекс строки
            int current_DrillDown_RowIndex = start_DrillDown_RowIndex;

            // Размер добавляемого контрола (в строках)
            size = 0;
            int i = 0;
            foreach (MemberInfo child in member.DrilledDownChildren)
            {
                PivotMemberItem dd_item = AddRowMember(item.DrillDownChildren, child, columnIndex, current_DrillDown_RowIndex, out size, drillDepth + 1);
                if (i == 0)
                    dd_item.IsFirstDrillDownChild = true;
                i++;
                current_DrillDown_RowIndex += size;
            }
            // Номер строки, на которой закончится отображение элемента
            int end_DrillDown_RowIndex = current_DrillDown_RowIndex;
            int DrillDownChildrenSize = end_DrillDown_RowIndex - start_DrillDown_RowIndex;

            // Растягиваем элемент если есть дочерние
            int span_Size = 1;
            int span_Size_WithChildren = 1;
            if (ChildrenSize > 1)
            {
                span_Size_WithChildren = ChildrenSize;
            }
            if (DrillDownChildrenSize > 0)
            {
                span_Size = span_Size_WithChildren + DrillDownChildrenSize;
            }
            else
            {
                span_Size = span_Size_WithChildren;
            }

            if (span_Size > 1)
            {
                item.RowSpan = span_Size;
            }

            item.ChildrenSize = ChildrenSize;
            item.DrillDownChildrenSize = DrillDownChildrenSize;
            memberSize = span_Size;
            return item;
        }