/// <summary>
        /// RevealModeProperty property changed handler.
        /// </summary>
        /// <param name="d">ExpandableContentControl that changed its RevealMode.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnRevealModePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExpandableContentControl source = (ExpandableContentControl)d;
            ExpandDirection          value  = (ExpandDirection)e.NewValue;

            if (value != ExpandDirection.Down &&
                value != ExpandDirection.Left &&
                value != ExpandDirection.Right &&
                value != ExpandDirection.Up)
            {
                // revert to old value
                source.RevealMode = (ExpandDirection)e.OldValue;

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "Properties.Resources.Expander_OnExpandDirectionPropertyChanged_InvalidValue",
                    value);
                throw new ArgumentException(message, "e");
            }

            // set the non-reveal dimension
            source.SetNonRevealDimension();

            // calculate the reveal dimension
            source.SetRevealDimension();
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //if (value is ExpandDirection direction &&
            //    targetType is { } &&
            //    parameter is string values &&
            //    values.Split(',') is { } directionValues &&
            //    directionValues.Length == 4)
            //{
            //    int index = direction switch
            //    {
            //        ExpandDirection.Left => 0,
            //        ExpandDirection.Up => 1,
            //        ExpandDirection.Right => 2,
            //        ExpandDirection.Down => 3,
            //        _ => throw new InvalidOperationException()
            //    };
            //    var converter = TypeDescriptor.GetConverter(targetType);

            //    return converter.CanConvertFrom(typeof(string)) ?
            //           converter.ConvertFromInvariantString(directionValues[index]) :
            //           directionValues[index];
            //}
            //return Binding.DoNothing;

            string values = (string)parameter;

            string[] directionValues = values.Split(',');

            ExpandDirection direction = (ExpandDirection)value;

            int index = 0;

            switch (direction)
            {
            case ExpandDirection.Down:
                index = 3;
                break;

            case ExpandDirection.Up:
                index = 1;
                break;

            case ExpandDirection.Left:
                index = 0;
                break;

            case ExpandDirection.Right:
                index = 2;
                break;
            }



            var converter = TypeDescriptor.GetConverter(targetType);

            return(converter.CanConvertFrom(typeof(string)) ?
                   converter.ConvertFromInvariantString(directionValues[index]) :
                   directionValues[index]);
        }
Пример #3
0
        public static async void FrameSwipe(Frame frame, object content, ExpandDirection direction)
        {
            await frame.Dispatcher.InvokeAsync(() => frame.Navigate(content));

            var storyboard = await Task.Run(() => FrameSwipe_Base(frame, content, direction, true, true));

            await storyboard.Dispatcher.InvokeAsync(() => storyboard.Begin());
        }
        /// <summary>
        /// ExpandDirectionProperty property changed handler.
        /// </summary>
        /// <param name="d">ExpandDirectionView that changed its ExpandDirection.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnExpandDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LinearClipper   source   = (LinearClipper)d;
            ExpandDirection oldValue = (ExpandDirection)e.OldValue;
            ExpandDirection newValue = (ExpandDirection)e.NewValue;

            source.OnExpandDirectionChanged(oldValue, newValue);
        }
Пример #5
0
        /// <summary>
        /// Check whether the passed in value o is a valid ExpandDirection enum value.
        /// </summary>
        /// <param name="o">The value to be checked.</param>
        /// <returns>True if o is a valid ExpandDirection enum value, false o/w.</returns>
        private static bool IsValidExpandDirection(object o)
        {
            ExpandDirection value = (ExpandDirection)o;

            return(value == ExpandDirection.Down ||
                   value == ExpandDirection.Left ||
                   value == ExpandDirection.Right ||
                   value == ExpandDirection.Up);
        }
        /// <summary>
        /// ExpandDirectionProperty PropertyChangedCallback call back static
        /// function.
        /// This function validates the new value before calling virtual function
        /// OnExpandDirectionChanged.
        /// </summary>
        /// <param name="d">Expander object whose ExpandDirection property is
        /// changed.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs which contains
        /// the old and new values.</param>
        private static void OnExpandDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AccordionItem   ctrl     = (AccordionItem)d;
            ExpandDirection oldValue = (ExpandDirection)e.OldValue;
            ExpandDirection newValue = (ExpandDirection)e.NewValue;

            if (!ctrl._allowedToWriteExpandDirection)
            {
                // revert to old value
                ctrl.ExpandDirection = oldValue;

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    Properties.Resources.AccordionItem_InvalidWriteToExpandDirection,
                    newValue);
                throw new InvalidOperationException(message);
            }

            // invalid value. This check is not of great importance anymore since
            // the previous check should catch all invalid sets.
            if (newValue != ExpandDirection.Down &&
                newValue != ExpandDirection.Left &&
                newValue != ExpandDirection.Right &&
                newValue != ExpandDirection.Up)
            {
                // revert to old value
                ctrl.ExpandDirection = oldValue;

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    Properties.Resources.Expander_OnExpandDirectionPropertyChanged_InvalidValue,
                    newValue);
                throw new ArgumentException(message, "e");
            }

            if (ctrl.ExpandSite != null)
            {
                // Jump to correct percentage after a direction change
#if SILVERLIGHT
                ctrl.ExpandSite.Percentage = ctrl.IsSelected ? 1 : 0;
#else
                //               ctrl.ExpandSite.RecalculatePercentage(ctrl.IsSelected ? 1 : 0);
#endif
            }

            ctrl.UpdateVisualState(true);
        }
Пример #7
0
        /// <summary>
        /// ExpandDirectionProperty PropertyChangedCallback call back static function.
        /// This function validates the new value before calling virtual function OnExpandDirectionChanged.
        /// </summary>
        /// <param name="d">Expander object whose ExpandDirection property is changed.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs which contains the old and new values.</param>
        private static void OnExpandDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Expander        ctrl     = (Expander)d;
            ExpandDirection oldValue = (ExpandDirection)e.OldValue;
            ExpandDirection newValue = (ExpandDirection)e.NewValue;

            if (!IsValidExpandDirection(newValue))
            {
                ctrl.ExpandDirection = oldValue;

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    Properties.Resources.Expander_OnExpandDirectionPropertyChanged_InvalidValue,
                    newValue);
                throw new ArgumentException(message, "e");
            }

            ctrl.UpdateVisualState(true);
        }
        /// <summary>
        /// Load the demo page.
        /// </summary>
        /// <param name="sender">Sample page.</param>
        /// <param name="e">Event arguments.</param>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // initalize customization area
            lbCustDirection.SelectionChanged += (x, y) =>
            {
                ExpandDirection d = (ExpandDirection)lbCustDirection.SelectedIndex;
                expNoButton.ExpandDirection = d;
                expBRButton.ExpandDirection = d;
                expFade.ExpandDirection     = d;
                expScale.ExpandDirection    = d;
            };

            // initialize interactive usage area
            btnChange.Click += ChangeSettings;

            tbHeader.Text          = "Header";
            tbHeaderTemplate.Text  = @"<DataTemplate><StackPanel Orientation=""Horizontal""><Ellipse Width=""10"" Height=""10"" Fill=""Red""/><Button Content=""{Binding}""/><Ellipse Width=""10"" Height=""10"" Fill=""Red""/></StackPanel></DataTemplate>";
            tbContent.Text         = "Content";
            tbContentTemplate.Text = @"<DataTemplate><Button Content=""{Binding}""/></DataTemplate>";

            expander.Expanded  += (x, y) => OutputExpander();
            expander.Collapsed += (x, y) => OutputExpander();
        }
Пример #9
0
 public EffectsBuilder Expand(ExpandDirection direction)
 {
     return(Add(EffectsList.Expand, direction.ToString().ToLower()));
 }
Пример #10
0
 public EffectsBuilder Expand(ExpandDirection direction)
 {
     return Add(EffectsList.Expand, direction.ToString().ToLower());
 }
        private void SetupLeader(FrameworkElement leader, FrameworkElement popup, bool reversePopupExpandDirection, double xDropDown, double yDropDown, double heightDropDown, ExpandDirection expandDirection, Control associatedControl, bool isNestedPopup)
        {
            if (leader != null && associatedControl != null)
            {
                leader.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                leader.VerticalAlignment = System.Windows.VerticalAlignment.Top;

                double leaderWidth = leader.ActualWidth;
                double leaderHeight = leader.ActualHeight;
                double d, leftBorder, topBorder;
                if ((leaderWidth != 0.0) && (leaderHeight != 0.0) && popup != null)
                {
                    #region Position leader, Offset dropdown to accommodate leader
                    switch (expandDirection)
                    {
                        case ExpandDirection.BottomLeft:
                            #region Left
                            d = Canvas.GetLeft(popup);
                            leftBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Left : 0;
                            Canvas.SetLeft(leader, d + leftBorder * 2);
                            #endregion
                            #region Top
                            topBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Top : 0;
                            d = Canvas.GetTop(popup);
                            Canvas.SetTop(leader, d + topBorder);//add border for overlap
                            Canvas.SetTop(popup, d + leaderHeight - topBorder);
                            #endregion
                            break;
                        case ExpandDirection.HorizontalCenter:

                            if (reversePopupExpandDirection)
                                RotateFrameworkElement(leader, 180);
                            else
                                RotateFrameworkElement(leader, 0);

                            #region Left
                            leftBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Left : 0;
                            Canvas.SetLeft(leader, !reversePopupExpandDirection ? (isNestedPopup ? 0 : xDropDown) + associatedControl.ActualWidth + leftBorder : (isNestedPopup ? 0 : xDropDown) - leaderHeight - leftBorder);//add border for overlap
                            #endregion
                            #region Top
                            topBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Top : 0;

                            Canvas.SetTop(leader, isNestedPopup ? (heightDropDown - leaderHeight) / 2 : yDropDown + (heightDropDown - leaderHeight) / 2);
                            #endregion
                            break;
                    }
                    #endregion
                }
            }
        }
 /// <summary>
 /// ExpandDirectionProperty property changed handler.
 /// </summary>
 /// <param name="oldValue">Old value.</param>
 /// <param name="newValue">New value.</param>
 protected virtual void OnExpandDirectionChanged(ExpandDirection oldValue, ExpandDirection newValue)
 {
     ClipContent();
 }
Пример #13
0
 /// <summary>
 /// ExpandDirectionProperty property changed handler.
 /// </summary>
 /// <param name="oldValue">Old value.</param>
 /// <param name="newValue">New value.</param>        
 protected virtual void OnExpandDirectionChanged(ExpandDirection oldValue, ExpandDirection newValue)
 {
     ClipContent();
 }
Пример #14
0
        private void SetPopupTop(FrameworkElement element, double yBottomDropDown, double heightRatio, double yDropDown, double popupHeight, double applicationHeight, ExpandDirection direction)
        {
            switch (direction)
            {
            case ExpandDirection.HorizontalCenter:
            {
                double top      = (yBottomDropDown - yDropDown - popupHeight) / 2;
                double overflow = Math.Abs(Math.Min(applicationHeight - (yDropDown + (yBottomDropDown - yDropDown) / 2 + popupHeight / 2 + RIGHT_CENTER_TOP_BOTTOM_MARGIN), 0.0));
                if (overflow > 0)
                {
                    top -= overflow;                                              //move up if overflowing underneath
                }
                top = Math.Max(top, -yDropDown + RIGHT_CENTER_TOP_BOTTOM_MARGIN); //did our best to calculate top, so set to top or application level x=0
                Canvas.SetTop(element, top);
            } break;

            case ExpandDirection.BottomLeft:
            default:
            {
                Canvas.SetTop(element, (yBottomDropDown - yDropDown) / heightRatio);
            } break;
            }
        }
        public void WhenTargetTypeIsObject_ItReturnsStringValue(ExpandDirection direction, string parameter, string expected)
        {
            var converter = new ExpanderDirectionConverter();

            Assert.Equal(expected, converter.Convert(direction, typeof(object), parameter, CultureInfo.CurrentUICulture));
        }
        public void WhenValuesAreValid_ItParsesExpected(ExpandDirection direction, string parameter, int expected)
        {
            var converter = new ExpanderDirectionConverter();

            Assert.Equal(expected, converter.Convert(direction, typeof(int), parameter, CultureInfo.CurrentUICulture));
        }
Пример #17
0
 public void SetCollapsed()
 {
     HeaderAngle  = -90.0;
     ExpDirection = ExpandDirection.Right;
 }
Пример #18
0
 public void SetExpanded()
 {
     HeaderAngle  = 0.0;
     ExpDirection = ExpandDirection.Down;
 }
        public void ArrangePopup(Popup ElementPopup, 
                                Canvas ElementPopupChildCanvas, 
                                Canvas ElementOutsidePopup, 
                                FrameworkElement ElementPopupChild, 
                                ContentControl LeaderPopupContent, 
                                StackPanel ElementPopupChildMaxRangeStackPanel,
                                Control AssociatedControl,
                                ExpandDirection ExpandDirection,
                                bool EnforceMinWidth = true,
                                bool isNestedPopup = true
                            )
        {
            if (ElementPopup != null && AssociatedControl != null)
            {
                bool isRTL = (AssociatedControl.FlowDirection == FlowDirection.RightToLeft);
                System.Windows.Interop.Content content = System.Windows.Application.Current.Host.Content;
                double applicationWidth = content.ActualWidth;
                double applicationHeight = content.ActualHeight;
                double popupWidth = ElementPopupChild.ActualWidth;
                double popupHeight = ElementPopupChild.ActualHeight;
                if ((applicationHeight != 0.0) && (applicationWidth != 0.0))
                {
                    GeneralTransform transform = AssociatedControl.TransformToVisual(null);
                    if (isRTL && transform is MatrixTransform)
                    {
                        var mt = (MatrixTransform) transform;
                        transform = new MatrixTransform
                                            {
                                                Matrix = new Matrix
                                                             {
                                                                 M11 = mt.Matrix.M11,
                                                                 M12 = mt.Matrix.M12,
                                                                 M21 = mt.Matrix.M21,
                                                                 M22 = mt.Matrix.M22,
                                                                 OffsetX = mt.Matrix.OffsetX - AssociatedControl.ActualWidth,
                                                                 OffsetY = mt.Matrix.OffsetY,
                                                             }
                                            };
                    }
                    if (transform != null)
                    {
                        Point topLeftTransPoint = new Point(0.0, 0.0);
                        Point topRightTransPoint = new Point(1.0, 0.0);
                        Point bottomLeftTransPoint = new Point(0.0, 1.0);
                        Point topLeftPosition = transform.Transform(topLeftTransPoint);
                        Point topRightPosition = transform.Transform(topRightTransPoint);
                        Point bottomLeftPosition = transform.Transform(bottomLeftTransPoint);
                        double xDropDown = topLeftPosition.X;
                        double yDropDown = topLeftPosition.Y;
                        double widthRatio = Math.Abs((double)(topRightPosition.X - topLeftPosition.X));
                        double heightRatio = Math.Abs((double)(bottomLeftPosition.Y - topLeftPosition.Y));
                        double heightDropDown = AssociatedControl.ActualHeight * heightRatio;
                        double widthDropDown = AssociatedControl.ActualWidth * widthRatio;
                        double yBottomDropDown = yDropDown + heightDropDown;
                        if ((heightDropDown != 0.0) && (widthDropDown != 0.0))
                        {
                            popupWidth *= widthRatio;
                            popupHeight *= heightRatio;
                            double maxDropDownHeight = double.PositiveInfinity;
                            if (ExpandDirection == ExpandDirection.BottomLeft)
                            {
                                if (double.IsInfinity(maxDropDownHeight) || double.IsNaN(maxDropDownHeight))
                                    maxDropDownHeight = ((applicationHeight - heightDropDown) * 3.0) / 5.0;
                                bool flag = true;
                                if (applicationHeight < (yBottomDropDown + popupHeight))
                                {
                                    flag = false;
                                    yBottomDropDown = yDropDown - popupHeight;
                                    if (yBottomDropDown < 0.0)
                                    {
                                        if (yDropDown < ((applicationHeight - heightDropDown) / 2.0))
                                        {
                                            flag = true;
                                            yBottomDropDown = yDropDown + heightDropDown;
                                        }
                                        else
                                        {
                                            flag = false;
                                            yBottomDropDown = yDropDown - popupHeight;
                                        }
                                    }
                                }
                                if (popupHeight != 0.0)
                                {
                                    if (flag)
                                        maxDropDownHeight = Math.Min(applicationHeight - yBottomDropDown, maxDropDownHeight);
                                    else
                                        maxDropDownHeight = Math.Min(yDropDown, maxDropDownHeight);
                                }
                            }
                            else
                            {
                                if (double.IsInfinity(maxDropDownHeight) || double.IsNaN(maxDropDownHeight))
                                    maxDropDownHeight = applicationHeight - 2 * RIGHT_CENTER_TOP_BOTTOM_MARGIN;
                            }
                            popupWidth = Math.Min(popupWidth, applicationWidth);
                            popupHeight = Math.Min(popupHeight, maxDropDownHeight);
                            popupWidth = Math.Max(widthDropDown, popupWidth);
                            double applicationRemainWidth = 0.0;
                            double leaderWidth = GetFrameworkElementWidth(LeaderPopupContent);
                            if (double.IsNaN(leaderWidth) || double.IsInfinity(leaderWidth))
                                leaderWidth = 0;

                            if (AssociatedControl.FlowDirection == FlowDirection.LeftToRight)
                            {
                                if (applicationWidth < (xDropDown + popupWidth))
                                    applicationRemainWidth = applicationWidth - (popupWidth + xDropDown);
                            }
                            else if (0.0 > (xDropDown - popupWidth))
                                applicationRemainWidth = xDropDown - popupWidth;

                            ElementPopup.HorizontalOffset = 0.0;
                            ElementPopup.VerticalOffset = 0.0;

                            Matrix identity = Matrix.Identity;
                            identity.OffsetX -= topLeftPosition.X / widthRatio;
                            identity.OffsetY -= topLeftPosition.Y / heightRatio;
                            MatrixTransform transform2 = new MatrixTransform();
                            transform2.Matrix = identity;

                            if (ElementOutsidePopup != null)
                            {
                                ElementOutsidePopup.Width = applicationWidth / widthRatio;
                                ElementOutsidePopup.Height = applicationHeight / heightRatio;
                                ElementOutsidePopup.RenderTransform = transform2;
                            }

                            double minWidthDropDown = 0.0;
                            if (EnforceMinWidth)
                            {
                                minWidthDropDown = widthDropDown / widthRatio;
                                ElementPopupChild.MinWidth = minWidthDropDown;
                            }

                            double maxPopupWidth = double.PositiveInfinity;
                            bool reversePopupExpandDirection = false;
                            if (ExpandDirection == ExpandDirection.BottomLeft)
                                maxPopupWidth = applicationWidth / widthRatio;
                            else
                            {
                                maxPopupWidth = applicationWidth - (xDropDown + widthDropDown) - leaderWidth;
                                maxPopupWidth = maxPopupWidth / widthRatio;

                                if (maxPopupWidth < popupWidth)
                                {
                                    double tempMaxPopupWidth;
                                    //try show on the other side
                                    tempMaxPopupWidth = xDropDown - leaderWidth;
                                    if (tempMaxPopupWidth >= 0 && tempMaxPopupWidth > maxPopupWidth)
                                    {
                                        maxPopupWidth = tempMaxPopupWidth;
                                        reversePopupExpandDirection = true;
                                    }
                                }
                            }

                            ElementPopupChild.MaxWidth = Math.Max(minWidthDropDown, maxPopupWidth);
                            ElementPopupChild.MinHeight = heightDropDown / heightRatio;
                            ElementPopupChild.MaxHeight = Math.Max((double)0.0, (double)(maxDropDownHeight / heightRatio));
                            ElementPopupChild.HorizontalAlignment = HorizontalAlignment.Left;
                            ElementPopupChild.VerticalAlignment = VerticalAlignment.Top;
                            ElementPopupChild.FlowDirection = AssociatedControl.FlowDirection;

                            if (ElementPopupChildMaxRangeStackPanel != null) //if horizontal central alignment, then simply reuse the maxrange canvas and align within
                            {
                                double top = isNestedPopup ? (heightDropDown - popupHeight) / 2 : Math.Max(0.0, yDropDown + (heightDropDown - popupHeight) / 2);
                                double overflow = Math.Abs(Math.Min(applicationHeight - (yDropDown + (yBottomDropDown - yDropDown) / 2 + popupHeight / 2 + RIGHT_CENTER_TOP_BOTTOM_MARGIN), 0.0));
                                if (overflow > 0)
                                {
                                    top -= overflow; //move up if overflowing underneath
                                }
                                top = Math.Max(top, -yDropDown + RIGHT_CENTER_TOP_BOTTOM_MARGIN); //did our best to calculate top, so set to top or application level x=0

                                Canvas.SetTop(ElementPopupChildMaxRangeStackPanel, top);
                                ElementPopupChildMaxRangeStackPanel.Width = maxPopupWidth;
                                ElementPopupChildMaxRangeStackPanel.Height = popupHeight;

                                if (isRTL && isNestedPopup)
                                    reversePopupExpandDirection = !reversePopupExpandDirection;

                                if (reversePopupExpandDirection)
                                    Canvas.SetLeft(ElementPopupChildMaxRangeStackPanel, isNestedPopup ? -xDropDown : 0);
                                else
                                {
                                    Canvas.SetLeft(ElementPopupChildMaxRangeStackPanel, (isNestedPopup ? 0: xDropDown) + AssociatedControl.ActualWidth + leaderWidth);
                                }

                                if (reversePopupExpandDirection)
                                    ElementPopupChild.HorizontalAlignment = HorizontalAlignment.Right;
                                
                                SetupLeader(LeaderPopupContent, ElementPopupChildMaxRangeStackPanel, reversePopupExpandDirection, xDropDown, yDropDown, heightDropDown, ExpandDirection, AssociatedControl, isNestedPopup);
                            }
                            else
                            {
                                SetPopupTop(ElementPopupChild, yBottomDropDown, heightRatio, yDropDown, popupHeight, applicationHeight, ExpandDirection);
                                SetPopupLeft(ElementPopupChild, applicationRemainWidth, widthRatio, popupWidth, maxPopupWidth, reversePopupExpandDirection, ExpandDirection, AssociatedControl, xDropDown);
                                SetupLeader(LeaderPopupContent, ElementPopupChild, reversePopupExpandDirection, xDropDown, yDropDown, heightDropDown, ExpandDirection, AssociatedControl, isNestedPopup);
                            }
                        }
                    }
                }
            }
        }
 private void SetPopupTop(FrameworkElement element, double yBottomDropDown, double heightRatio, double yDropDown, double popupHeight, double applicationHeight, ExpandDirection direction)
 {
     switch (direction)
     {
         case ExpandDirection.HorizontalCenter:
             {
                 double top = (yBottomDropDown - yDropDown - popupHeight) / 2;
                 double overflow = Math.Abs(Math.Min(applicationHeight - (yDropDown + (yBottomDropDown - yDropDown) / 2 + popupHeight / 2 + RIGHT_CENTER_TOP_BOTTOM_MARGIN), 0.0));
                 if (overflow > 0)
                 {
                     top -= overflow; //move up if overflowing underneath
                 }
                 top = Math.Max(top, -yDropDown + RIGHT_CENTER_TOP_BOTTOM_MARGIN); //did our best to calculate top, so set to top or application level x=0
                 Canvas.SetTop(element, top);
             } break;
         case ExpandDirection.BottomLeft:
         default:
             {
                 Canvas.SetTop(element, (yBottomDropDown - yDropDown) / heightRatio);
             } break;
     }
 }
        private void SetPopupLeft(FrameworkElement element, double applicationRemainWidth, double widthRatio, double popupWidth, double maxPopupWidth, bool reversePopupExpandDirection, ExpandDirection direction, Control associatedControl, double xDropDown)
        {
            switch (direction)
            {
                case ExpandDirection.HorizontalCenter:
                    {
                        if (!reversePopupExpandDirection)
                        {
                            double d = applicationRemainWidth / widthRatio;

                            if (!double.IsNaN(associatedControl.ActualWidth))
                                d += associatedControl.ActualWidth;
                            Canvas.SetLeft(element, d);
                        }
                        else
                        {
                            double d = 0;
                            if (!double.IsNaN(element.ActualWidth) || !double.IsNaN(maxPopupWidth))
                            {
                                d -= Math.Max(Math.Min(element.ActualWidth, maxPopupWidth), Math.Min(popupWidth, maxPopupWidth));
                            }
                            Canvas.SetLeft(element, d);
                        }
                    } break;
                case ExpandDirection.BottomLeft:
                default:
                    {
                        Canvas.SetLeft(element, applicationRemainWidth / widthRatio);
                    } break;
            }
        }
Пример #22
0
        private void SetupLeader(FrameworkElement leader, FrameworkElement popup, bool reversePopupExpandDirection, double xDropDown, double yDropDown, double heightDropDown, ExpandDirection expandDirection, Control associatedControl, bool isNestedPopup)
        {
            if (leader != null && associatedControl != null)
            {
                leader.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                leader.VerticalAlignment   = System.Windows.VerticalAlignment.Top;

                double leaderWidth = leader.ActualWidth;
                double leaderHeight = leader.ActualHeight;
                double d, leftBorder, topBorder;
                if ((leaderWidth != 0.0) && (leaderHeight != 0.0) && popup != null)
                {
                    #region Position leader, Offset dropdown to accommodate leader
                    switch (expandDirection)
                    {
                    case ExpandDirection.BottomLeft:
                        #region Left
                        d          = Canvas.GetLeft(popup);
                        leftBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Left : 0;
                        Canvas.SetLeft(leader, d + leftBorder * 2);
                        #endregion
                        #region Top
                        topBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Top : 0;
                        d         = Canvas.GetTop(popup);
                        Canvas.SetTop(leader, d + topBorder);    //add border for overlap
                        Canvas.SetTop(popup, d + leaderHeight - topBorder);
                        #endregion
                        break;

                    case ExpandDirection.HorizontalCenter:

                        if (reversePopupExpandDirection)
                        {
                            RotateFrameworkElement(leader, 180);
                        }
                        else
                        {
                            RotateFrameworkElement(leader, 0);
                        }

                        #region Left
                        leftBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Left : 0;
                        Canvas.SetLeft(leader, !reversePopupExpandDirection ? (isNestedPopup ? 0 : xDropDown) + associatedControl.ActualWidth + leftBorder : (isNestedPopup ? 0 : xDropDown) - leaderHeight - leftBorder);    //add border for overlap
                        #endregion
                        #region Top
                        topBorder = (associatedControl.BorderThickness != null) ? associatedControl.BorderThickness.Top : 0;

                        Canvas.SetTop(leader, isNestedPopup ? (heightDropDown - leaderHeight) / 2 : yDropDown + (heightDropDown - leaderHeight) / 2);
                        #endregion
                        break;
                    }
                    #endregion
                }
            }
        }
Пример #23
0
        private void SetPopupLeft(FrameworkElement element, double applicationRemainWidth, double widthRatio, double popupWidth, double maxPopupWidth, bool reversePopupExpandDirection, ExpandDirection direction, Control associatedControl, double xDropDown)
        {
            switch (direction)
            {
            case ExpandDirection.HorizontalCenter:
            {
                if (!reversePopupExpandDirection)
                {
                    double d = applicationRemainWidth / widthRatio;

                    if (!double.IsNaN(associatedControl.ActualWidth))
                    {
                        d += associatedControl.ActualWidth;
                    }
                    Canvas.SetLeft(element, d);
                }
                else
                {
                    double d = 0;
                    if (!double.IsNaN(element.ActualWidth) || !double.IsNaN(maxPopupWidth))
                    {
                        d -= Math.Max(Math.Min(element.ActualWidth, maxPopupWidth), Math.Min(popupWidth, maxPopupWidth));
                    }
                    Canvas.SetLeft(element, d);
                }
            } break;

            case ExpandDirection.BottomLeft:
            default:
            {
                Canvas.SetLeft(element, applicationRemainWidth / widthRatio);
            } break;
            }
        }
Пример #24
0
        public static async Task <Storyboard> FrameSwipe_Base(Frame frame, object content, ExpandDirection direction, bool useFade, bool fadeIn)
        {
            return(await Application.Current.Dispatcher.InvokeAsync(() =>
            {
                AnimationArgs animationArgs = new AnimationArgs();

                SetCurrentPage(animationArgs, frame, content);
                StorePageValues(animationArgs);
                SetPageValuesForAnimation(animationArgs);

                Storyboard storyboard = new Storyboard();
                Duration duration = new Duration(TimeSpan.FromMilliseconds(GetSwipeSpeed()));

                if (useFade)
                {
                    var fadeAnim = GetFadeAnimation(duration, fadeIn);
                    storyboard.Children.Add(fadeAnim);
                    Storyboard.SetTargetProperty(fadeAnim, new PropertyPath(Frame.OpacityProperty));
                    Storyboard.SetTarget(fadeAnim, frame);
                }

                var swipeAnim = GetSwipeAnimation(animationArgs, GetSwipeSize(), duration, direction);
                storyboard.Children.Add(swipeAnim);
                Storyboard.SetTargetProperty(swipeAnim, new PropertyPath(Frame.MarginProperty));
                Storyboard.SetTarget(swipeAnim, frame);
                return storyboard;
            }));
        }
Пример #25
0
        public void ArrangePopup(Popup ElementPopup,
                                 Canvas ElementPopupChildCanvas,
                                 Canvas ElementOutsidePopup,
                                 FrameworkElement ElementPopupChild,
                                 ContentControl LeaderPopupContent,
                                 StackPanel ElementPopupChildMaxRangeStackPanel,
                                 Control AssociatedControl,
                                 ExpandDirection ExpandDirection,
                                 bool EnforceMinWidth = true,
                                 bool isNestedPopup   = true
                                 )
        {
            if (ElementPopup != null && AssociatedControl != null)
            {
                bool isRTL = (AssociatedControl.FlowDirection == FlowDirection.RightToLeft);
                System.Windows.Interop.Content content = System.Windows.Application.Current.Host.Content;
                double applicationWidth  = content.ActualWidth;
                double applicationHeight = content.ActualHeight;
                double popupWidth        = ElementPopupChild.ActualWidth;
                double popupHeight       = ElementPopupChild.ActualHeight;
                if ((applicationHeight != 0.0) && (applicationWidth != 0.0))
                {
                    GeneralTransform transform = AssociatedControl.TransformToVisual(null);
                    if (isRTL && transform is MatrixTransform)
                    {
                        var mt = (MatrixTransform)transform;
                        transform = new MatrixTransform
                        {
                            Matrix = new Matrix
                            {
                                M11     = mt.Matrix.M11,
                                M12     = mt.Matrix.M12,
                                M21     = mt.Matrix.M21,
                                M22     = mt.Matrix.M22,
                                OffsetX = mt.Matrix.OffsetX - AssociatedControl.ActualWidth,
                                OffsetY = mt.Matrix.OffsetY,
                            }
                        };
                    }
                    if (transform != null)
                    {
                        Point  topLeftTransPoint    = new Point(0.0, 0.0);
                        Point  topRightTransPoint   = new Point(1.0, 0.0);
                        Point  bottomLeftTransPoint = new Point(0.0, 1.0);
                        Point  topLeftPosition      = transform.Transform(topLeftTransPoint);
                        Point  topRightPosition     = transform.Transform(topRightTransPoint);
                        Point  bottomLeftPosition   = transform.Transform(bottomLeftTransPoint);
                        double xDropDown            = topLeftPosition.X;
                        double yDropDown            = topLeftPosition.Y;
                        double widthRatio           = Math.Abs((double)(topRightPosition.X - topLeftPosition.X));
                        double heightRatio          = Math.Abs((double)(bottomLeftPosition.Y - topLeftPosition.Y));
                        double heightDropDown       = AssociatedControl.ActualHeight * heightRatio;
                        double widthDropDown        = AssociatedControl.ActualWidth * widthRatio;
                        double yBottomDropDown      = yDropDown + heightDropDown;
                        if ((heightDropDown != 0.0) && (widthDropDown != 0.0))
                        {
                            popupWidth  *= widthRatio;
                            popupHeight *= heightRatio;
                            double maxDropDownHeight = double.PositiveInfinity;
                            if (ExpandDirection == ExpandDirection.BottomLeft)
                            {
                                if (double.IsInfinity(maxDropDownHeight) || double.IsNaN(maxDropDownHeight))
                                {
                                    maxDropDownHeight = ((applicationHeight - heightDropDown) * 3.0) / 5.0;
                                }
                                bool flag = true;
                                if (applicationHeight < (yBottomDropDown + popupHeight))
                                {
                                    flag            = false;
                                    yBottomDropDown = yDropDown - popupHeight;
                                    if (yBottomDropDown < 0.0)
                                    {
                                        if (yDropDown < ((applicationHeight - heightDropDown) / 2.0))
                                        {
                                            flag            = true;
                                            yBottomDropDown = yDropDown + heightDropDown;
                                        }
                                        else
                                        {
                                            flag            = false;
                                            yBottomDropDown = yDropDown - popupHeight;
                                        }
                                    }
                                }
                                if (popupHeight != 0.0)
                                {
                                    if (flag)
                                    {
                                        maxDropDownHeight = Math.Min(applicationHeight - yBottomDropDown, maxDropDownHeight);
                                    }
                                    else
                                    {
                                        maxDropDownHeight = Math.Min(yDropDown, maxDropDownHeight);
                                    }
                                }
                            }
                            else
                            {
                                if (double.IsInfinity(maxDropDownHeight) || double.IsNaN(maxDropDownHeight))
                                {
                                    maxDropDownHeight = applicationHeight - 2 * RIGHT_CENTER_TOP_BOTTOM_MARGIN;
                                }
                            }
                            popupWidth  = Math.Min(popupWidth, applicationWidth);
                            popupHeight = Math.Min(popupHeight, maxDropDownHeight);
                            popupWidth  = Math.Max(widthDropDown, popupWidth);
                            double applicationRemainWidth = 0.0;
                            double leaderWidth            = GetFrameworkElementWidth(LeaderPopupContent);
                            if (double.IsNaN(leaderWidth) || double.IsInfinity(leaderWidth))
                            {
                                leaderWidth = 0;
                            }

                            if (AssociatedControl.FlowDirection == FlowDirection.LeftToRight)
                            {
                                if (applicationWidth < (xDropDown + popupWidth))
                                {
                                    applicationRemainWidth = applicationWidth - (popupWidth + xDropDown);
                                }
                            }
                            else if (0.0 > (xDropDown - popupWidth))
                            {
                                applicationRemainWidth = xDropDown - popupWidth;
                            }

                            ElementPopup.HorizontalOffset = 0.0;
                            ElementPopup.VerticalOffset   = 0.0;

                            Matrix identity = Matrix.Identity;
                            identity.OffsetX -= topLeftPosition.X / widthRatio;
                            identity.OffsetY -= topLeftPosition.Y / heightRatio;
                            MatrixTransform transform2 = new MatrixTransform();
                            transform2.Matrix = identity;

                            if (ElementOutsidePopup != null)
                            {
                                ElementOutsidePopup.Width           = applicationWidth / widthRatio;
                                ElementOutsidePopup.Height          = applicationHeight / heightRatio;
                                ElementOutsidePopup.RenderTransform = transform2;
                            }

                            double minWidthDropDown = 0.0;
                            if (EnforceMinWidth)
                            {
                                minWidthDropDown           = widthDropDown / widthRatio;
                                ElementPopupChild.MinWidth = minWidthDropDown;
                            }

                            double maxPopupWidth = double.PositiveInfinity;
                            bool   reversePopupExpandDirection = false;
                            if (ExpandDirection == ExpandDirection.BottomLeft)
                            {
                                maxPopupWidth = applicationWidth / widthRatio;
                            }
                            else
                            {
                                maxPopupWidth = applicationWidth - (xDropDown + widthDropDown) - leaderWidth;
                                maxPopupWidth = maxPopupWidth / widthRatio;

                                if (maxPopupWidth < popupWidth)
                                {
                                    double tempMaxPopupWidth;
                                    //try show on the other side
                                    tempMaxPopupWidth = xDropDown - leaderWidth;
                                    if (tempMaxPopupWidth >= 0 && tempMaxPopupWidth > maxPopupWidth)
                                    {
                                        maxPopupWidth = tempMaxPopupWidth;
                                        reversePopupExpandDirection = true;
                                    }
                                }
                            }

                            ElementPopupChild.MaxWidth            = Math.Max(minWidthDropDown, maxPopupWidth);
                            ElementPopupChild.MinHeight           = heightDropDown / heightRatio;
                            ElementPopupChild.MaxHeight           = Math.Max((double)0.0, (double)(maxDropDownHeight / heightRatio));
                            ElementPopupChild.HorizontalAlignment = HorizontalAlignment.Left;
                            ElementPopupChild.VerticalAlignment   = VerticalAlignment.Top;
                            ElementPopupChild.FlowDirection       = AssociatedControl.FlowDirection;

                            if (ElementPopupChildMaxRangeStackPanel != null) //if horizontal central alignment, then simply reuse the maxrange canvas and align within
                            {
                                double top      = isNestedPopup ? (heightDropDown - popupHeight) / 2 : Math.Max(0.0, yDropDown + (heightDropDown - popupHeight) / 2);
                                double overflow = Math.Abs(Math.Min(applicationHeight - (yDropDown + (yBottomDropDown - yDropDown) / 2 + popupHeight / 2 + RIGHT_CENTER_TOP_BOTTOM_MARGIN), 0.0));
                                if (overflow > 0)
                                {
                                    top -= overflow;                                              //move up if overflowing underneath
                                }
                                top = Math.Max(top, -yDropDown + RIGHT_CENTER_TOP_BOTTOM_MARGIN); //did our best to calculate top, so set to top or application level x=0

                                Canvas.SetTop(ElementPopupChildMaxRangeStackPanel, top);
                                ElementPopupChildMaxRangeStackPanel.Width  = maxPopupWidth;
                                ElementPopupChildMaxRangeStackPanel.Height = popupHeight;

                                if (isRTL && isNestedPopup)
                                {
                                    reversePopupExpandDirection = !reversePopupExpandDirection;
                                }

                                if (reversePopupExpandDirection)
                                {
                                    Canvas.SetLeft(ElementPopupChildMaxRangeStackPanel, isNestedPopup ? -xDropDown : 0);
                                }
                                else
                                {
                                    Canvas.SetLeft(ElementPopupChildMaxRangeStackPanel, (isNestedPopup ? 0: xDropDown) + AssociatedControl.ActualWidth + leaderWidth);
                                }

                                if (reversePopupExpandDirection)
                                {
                                    ElementPopupChild.HorizontalAlignment = HorizontalAlignment.Right;
                                }

                                SetupLeader(LeaderPopupContent, ElementPopupChildMaxRangeStackPanel, reversePopupExpandDirection, xDropDown, yDropDown, heightDropDown, ExpandDirection, AssociatedControl, isNestedPopup);
                            }
                            else
                            {
                                SetPopupTop(ElementPopupChild, yBottomDropDown, heightRatio, yDropDown, popupHeight, applicationHeight, ExpandDirection);
                                SetPopupLeft(ElementPopupChild, applicationRemainWidth, widthRatio, popupWidth, maxPopupWidth, reversePopupExpandDirection, ExpandDirection, AssociatedControl, xDropDown);
                                SetupLeader(LeaderPopupContent, ElementPopupChild, reversePopupExpandDirection, xDropDown, yDropDown, heightDropDown, ExpandDirection, AssociatedControl, isNestedPopup);
                            }
                        }
                    }
                }
            }
        }
 public static bool IsRegularOrder(this ExpandDirection orientation)
 => orientation == ExpandDirection.Down ||
 orientation == ExpandDirection.Right;
Пример #27
0
        private static ThicknessAnimation GetSwipeAnimation(AnimationArgs animationArgs, double size, Duration duration, ExpandDirection direction)
        {
            ThicknessAnimation animation0 = new ThicknessAnimation();

            switch (direction)
            {
            case ExpandDirection.Left:
                animation0.From = new Thickness(-size, 0, size, 0);
                break;

            case ExpandDirection.Right:
                animation0.From = new Thickness(size, 0, -size, 0);
                break;

            case ExpandDirection.Up:
                animation0.From = new Thickness(0, -size, 0, size);
                break;

            case ExpandDirection.Down:
                animation0.From = new Thickness(0, size, 0, -size);
                break;
            }

            animation0.To         = new Thickness(0, 0, 0, 0);
            animation0.Completed += (sender, e) =>
            {
                ResetPageValues(animationArgs);
            };
            animation0.Duration       = duration;
            animation0.EasingFunction = GetSwipeAnimationEasingFunction();
            return(animation0);
        }
        // Token: 0x06004B05 RID: 19205 RVA: 0x001524B8 File Offset: 0x001506B8
        private static bool IsValidExpandDirection(object o)
        {
            ExpandDirection expandDirection = (ExpandDirection)o;

            return(expandDirection == ExpandDirection.Down || expandDirection == ExpandDirection.Left || expandDirection == ExpandDirection.Right || expandDirection == ExpandDirection.Up);
        }
Пример #29
0
        public static void FrameSwipe(Frame frame, object content, ExpandDirection direction)
        {
            bool isPage = (content is Page);

            if (inProgress || !isPage)
            {
                return;
            }
            inProgress = true;

            CurrentContent = content as Page;

            stored_width  = CurrentContent.ActualWidth;
            stored_height = CurrentContent.ActualHeight;

            stored_min_width  = CurrentContent.MinWidth;
            stored_min_height = CurrentContent.MinHeight;

            stored_max_width  = CurrentContent.MaxWidth;
            stored_max_height = CurrentContent.MaxHeight;

            Duration _duration = new Duration(TimeSpan.FromMilliseconds(175));

            ThicknessAnimation animation0 = new ThicknessAnimation();


            double size        = 150;
            bool   transparent = true;

            switch (direction)
            {
            case ExpandDirection.Left:
                animation0.From = new Thickness(-size, 0, size, 0);
                break;

            case ExpandDirection.Right:
                animation0.From = new Thickness(size, 0, -size, 0);
                break;

            case ExpandDirection.Up:
                animation0.From = new Thickness(0, -size, 0, size);
                break;

            case ExpandDirection.Down:
                animation0.From = new Thickness(0, size, 0, -size);
                break;
            }

            animation0.To         = new Thickness(0, 0, 0, 0);
            animation0.Completed += Animation0_Completed;
            animation0.Duration   = _duration;

            CurrentContent.MinWidth  = stored_width;
            CurrentContent.MinHeight = stored_height;
            CurrentContent.MaxWidth  = stored_width;
            CurrentContent.MaxHeight = stored_height;

            if (transparent)
            {
                DoubleAnimation animation1 = new DoubleAnimation();
                animation1.From     = 0;
                animation1.To       = 1;
                animation1.Duration = _duration;
                frame.BeginAnimation(Frame.OpacityProperty, animation1);
            }
            frame.BeginAnimation(Frame.MarginProperty, animation0);
        }
Пример #30
0
        public static IntPtr Box_ExpandDirection(ExpandDirection val)
        {
            IntPtr ret = NoesisGUI_PINVOKE.Box_ExpandDirection((int)val);

            return(ret);
        }
 public static bool IsVertical(this ExpandDirection orientation)
 => orientation == ExpandDirection.Down ||
 orientation == ExpandDirection.Up;
Пример #32
0
    /// <summary>
    /// Prepares the layout of the web part.
    /// </summary>
    protected override void PrepareLayout()
    {
        StartLayout();

        Append("<div");

        // Width
        string width = Width;

        if (!string.IsNullOrEmpty(width))
        {
            Append(" style=\"width: ", width, "\"");
        }

        if (IsDesign)
        {
            Append(" id=\"", ShortClientID, "_env\">");

            Append("<table class=\"LayoutTable\" cellspacing=\"0\" style=\"width: 100%;\">");

            if (ViewModeIsDesign())
            {
                Append("<tr><td class=\"LayoutHeader\" colspan=\"2\">");

                // Add header container
                AddHeaderContainer();

                Append("</td></tr>");
            }

            Append("<tr><td style=\"width: 100%;\">");
        }
        else
        {
            Append(">");
        }

        // Header panel
        Panel pnlHeader = new Panel();

        pnlHeader.ID              = "pnlH";
        pnlHeader.CssClass        = HeaderCSSClass;
        pnlHeader.EnableViewState = false;

        // Header label
        Label lblHeader = new Label();

        lblHeader.ID = "lblH";

        pnlHeader.Controls.Add(lblHeader);

        // Header image
        Image imgHeader = new Image();

        imgHeader.CssClass = ImageCSSClass;
        imgHeader.ID       = "imgH";

        pnlHeader.Controls.Add(imgHeader);


        AddControl(pnlHeader);

        // Content panel
        Panel pnlContent = new Panel();

        pnlContent.CssClass = ContentCSSClass;
        pnlContent.ID       = "pnlC";

        AddControl(pnlContent);

        // Add the zone
        CMSWebPartZone zone = AddZone(ID + "_zone", ID, pnlContent);

        // Add the extender
        CollapsiblePanelExtender cp = new CollapsiblePanelExtender();

        cp.ID = "extCP";
        cp.TargetControlID = pnlContent.ID;

        cp.ExpandControlID   = pnlHeader.ID;
        cp.CollapseControlID = pnlHeader.ID;

        cp.TextLabelID    = lblHeader.ID;
        cp.ImageControlID = imgHeader.ID;

        cp.ExpandDirection = (ExpandDirection.EqualsCSafe("horz", true) ? CollapsiblePanelExpandDirection.Horizontal : CollapsiblePanelExpandDirection.Vertical);

        // Texts
        string expText = ResHelper.LocalizeString(ExpandedText);
        string colText = ResHelper.LocalizeString(CollapsedText);

        cp.ExpandedText  = expText;
        cp.CollapsedText = colText;

        if (String.IsNullOrEmpty(expText) && String.IsNullOrEmpty(colText))
        {
            lblHeader.Visible = false;
        }

        // Images
        string expImage = ExpandedImage;
        string colImage = CollapsedImage;

        if (!String.IsNullOrEmpty(expImage) && !String.IsNullOrEmpty(colImage))
        {
            cp.ExpandedImage  = expImage;
            cp.CollapsedImage = colImage;
        }
        else
        {
            imgHeader.Visible = false;
        }

        // Sizes
        int expSize = ExpandedSize;

        if (expSize > 0)
        {
            cp.ExpandedSize = expSize;
        }

        int collapsed = CollapsedSize;

        if (collapsed >= 0)
        {
            cp.CollapsedSize = CollapsedSize;
        }

        cp.Collapsed = Collapsed;

        if (!IsDesign)
        {
            cp.AutoCollapse = AutoCollapse;
            if (AutoExpand)
            {
                cp.AutoExpand = true;

                // Ensure some collapsed size
                if (collapsed < 0)
                {
                    cp.CollapsedSize = 10;
                }
            }
        }

        cp.ScrollContents = ScrollContent;

        // Add the extender
        Controls.Add(cp);

        if (IsDesign)
        {
            Append("</td>");

            // Width resizer
            if (AllowDesignMode)
            {
                Append("<td class=\"HorizontalResizer\" onmousedown=\"", GetHorizontalResizerScript("env", "Width"), " return false;\">&nbsp;</td>");
            }

            Append("</tr></table>");
        }

        Append("</div>");

        FinishLayout();
    }
Пример #33
0
        public static ExpandDirection Unbox_ExpandDirection(IntPtr val)
        {
            ExpandDirection ret = (ExpandDirection)NoesisGUI_PINVOKE.Unbox_ExpandDirection(val);

            return(ret);
        }
Пример #34
0
 public static T ExpandDirection <T>(this T target, ExpandDirection value) where T : Expander
 {
     target.ExpandDirection = value;
     return(target);
 }