Example #1
0
        void expander_CheckedChanged(object sender, EventArgs e)
        {
            MemberActionType action = MemberActionType.Expand;

            if (Member.DrilledDown)
            {
                action = MemberActionType.Collapse;
            }

            PlusMinusButton expander = sender as PlusMinusButton;

            if (expander != null)
            {
                expander.CheckedChanged -= new EventHandler(expander_CheckedChanged);
                expander.IsChecked       = new bool?(!expander.IsChecked.Value);
                expander.CheckedChanged += new EventHandler(expander_CheckedChanged);
            }

            Raise_DrillDownMember(action);
        }
Example #2
0
        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;
        }
        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);
        }