예제 #1
0
 // Token: 0x06005494 RID: 21652 RVA: 0x00176A14 File Offset: 0x00174C14
 private void UpdateAnimation()
 {
     if (this._glow != null)
     {
         if (base.IsVisible && this._glow.Width > 0.0 && this._indicator.Width > 0.0)
         {
             double   num      = this._indicator.Width + this._glow.Width;
             double   num2     = -1.0 * this._glow.Width;
             TimeSpan timeSpan = TimeSpan.FromSeconds((double)((int)(num - num2)) / 200.0);
             TimeSpan t        = TimeSpan.FromSeconds(1.0);
             TimeSpan value;
             if (DoubleUtil.GreaterThan(this._glow.Margin.Left, num2) && DoubleUtil.LessThan(this._glow.Margin.Left, num - 1.0))
             {
                 value = TimeSpan.FromSeconds(-1.0 * (this._glow.Margin.Left - num2) / 200.0);
             }
             else
             {
                 value = TimeSpan.Zero;
             }
             ThicknessAnimationUsingKeyFrames thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
             thicknessAnimationUsingKeyFrames.BeginTime      = new TimeSpan?(value);
             thicknessAnimationUsingKeyFrames.Duration       = new Duration(timeSpan + t);
             thicknessAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
             thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num2, 0.0, 0.0, 0.0), TimeSpan.FromSeconds(0.0)));
             thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num, 0.0, 0.0, 0.0), timeSpan));
             this._glow.BeginAnimation(FrameworkElement.MarginProperty, thicknessAnimationUsingKeyFrames);
             return;
         }
         this._glow.BeginAnimation(FrameworkElement.MarginProperty, null);
     }
 }
예제 #2
0
        /// <summary>
        /// <see cref="FrameworkElement.MeasureOverride"/>
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            UVSize curLineSize   = new UVSize(Orientation);
            UVSize panelSize     = new UVSize(Orientation);
            UVSize uvConstraint  = new UVSize(Orientation, constraint.Width, constraint.Height);
            double itemWidth     = ItemWidth;
            double itemHeight    = ItemHeight;
            bool   itemWidthSet  = !double.IsNaN(itemWidth);
            bool   itemHeightSet = !double.IsNaN(itemHeight);

            Size childConstraint = new Size(
                (itemWidthSet ?  itemWidth  : constraint.Width),
                (itemHeightSet ? itemHeight : constraint.Height));

            UIElementCollection children = InternalChildren;

            for (int i = 0, count = children.Count; i < count; i++)
            {
                UIElement child = children[i] as UIElement;
                if (child == null)
                {
                    continue;
                }

                //Flow passes its own constrint to children
                child.Measure(childConstraint);

                //this is the size of the child in UV space
                UVSize sz = new UVSize(
                    Orientation,
                    (itemWidthSet ?  itemWidth  : child.DesiredSize.Width),
                    (itemHeightSet ? itemHeight : child.DesiredSize.Height));

                if (DoubleUtil.GreaterThan(curLineSize.U + sz.U, uvConstraint.U)) //need to switch to another line
                {
                    panelSize.U  = Math.Max(curLineSize.U, panelSize.U);
                    panelSize.V += curLineSize.V;
                    curLineSize  = sz;

                    if (DoubleUtil.GreaterThan(sz.U, uvConstraint.U)) //the element is wider then the constrint - give it a separate line
                    {
                        panelSize.U  = Math.Max(sz.U, panelSize.U);
                        panelSize.V += sz.V;
                        curLineSize  = new UVSize(Orientation);
                    }
                }
                else //continue to accumulate a line
                {
                    curLineSize.U += sz.U;
                    curLineSize.V  = Math.Max(sz.V, curLineSize.V);
                }
            }

            //the last line size, if any should be added
            panelSize.U  = Math.Max(curLineSize.U, panelSize.U);
            panelSize.V += curLineSize.V;

            //go from UV space to W/H space
            return(new Size(panelSize.Width, panelSize.Height));
        }
예제 #3
0
        /// <summary>
        /// <see cref="FrameworkElement.ArrangeOverride"/>
        /// </summary>
        protected override Size ArrangeOverride(Size finalSize)
        {
            int    firstInLine   = 0;
            double itemWidth     = ItemWidth;
            double itemHeight    = ItemHeight;
            double accumulatedV  = 0;
            double itemU         = (Orientation == Orientation.Horizontal ? itemWidth : itemHeight);
            UVSize curLineSize   = new UVSize(Orientation);
            UVSize uvFinalSize   = new UVSize(Orientation, finalSize.Width, finalSize.Height);
            bool   itemWidthSet  = !double.IsNaN(itemWidth);
            bool   itemHeightSet = !double.IsNaN(itemHeight);
            bool   useItemU      = (Orientation == Orientation.Horizontal ? itemWidthSet : itemHeightSet);

            UIElementCollection children = InternalChildren;

            for (int i = 0, count = children.Count; i < count; i++)
            {
                UIElement child = children[i] as UIElement;
                if (child == null)
                {
                    continue;
                }

                UVSize sz = new UVSize(
                    Orientation,
                    (itemWidthSet ?  itemWidth  : child.DesiredSize.Width),
                    (itemHeightSet ? itemHeight : child.DesiredSize.Height));

                if (DoubleUtil.GreaterThan(curLineSize.U + sz.U, uvFinalSize.U)) //need to switch to another line
                {
                    arrangeLine(accumulatedV, curLineSize.V, firstInLine, i, useItemU, itemU);

                    accumulatedV += curLineSize.V;
                    curLineSize   = sz;

                    if (DoubleUtil.GreaterThan(sz.U, uvFinalSize.U)) //the element is wider then the constraint - give it a separate line
                    {
                        //switch to next line which only contain one element
                        arrangeLine(accumulatedV, sz.V, i, ++i, useItemU, itemU);

                        accumulatedV += sz.V;
                        curLineSize   = new UVSize(Orientation);
                    }
                    firstInLine = i;
                }
                else //continue to accumulate a line
                {
                    curLineSize.U += sz.U;
                    curLineSize.V  = Math.Max(sz.V, curLineSize.V);
                }
            }

            //arrange the last line, if any
            if (firstInLine < children.Count)
            {
                arrangeLine(accumulatedV, curLineSize.V, firstInLine, children.Count, useItemU, itemU);
            }

            return(finalSize);
        }
예제 #4
0
        /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.WrapPanel" /> element.</summary>
        /// <param name="finalSize">The <see cref="T:System.Windows.Size" /> that this element should use to arrange its child elements.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.WrapPanel" /> element and its children.</returns>
        // Token: 0x06005B53 RID: 23379 RVA: 0x0019BE90 File Offset: 0x0019A090
        protected override Size ArrangeOverride(Size finalSize)
        {
            int    num        = 0;
            double itemWidth  = this.ItemWidth;
            double itemHeight = this.ItemHeight;
            double num2       = 0.0;
            double itemU      = (this.Orientation == Orientation.Horizontal) ? itemWidth : itemHeight;

            WrapPanel.UVSize    uvsize           = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize2          = new WrapPanel.UVSize(this.Orientation, finalSize.Width, finalSize.Height);
            bool                flag             = !DoubleUtil.IsNaN(itemWidth);
            bool                flag2            = !DoubleUtil.IsNaN(itemHeight);
            bool                useItemU         = (this.Orientation == Orientation.Horizontal) ? flag : flag2;
            UIElementCollection internalChildren = base.InternalChildren;
            int i     = 0;
            int count = internalChildren.Count;

            while (i < count)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    WrapPanel.UVSize uvsize3 = new WrapPanel.UVSize(this.Orientation, flag ? itemWidth : uielement.DesiredSize.Width, flag2 ? itemHeight : uielement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvsize.U + uvsize3.U, uvsize2.U))
                    {
                        this.arrangeLine(num2, uvsize.V, num, i, useItemU, itemU);
                        num2  += uvsize.V;
                        uvsize = uvsize3;
                        if (DoubleUtil.GreaterThan(uvsize3.U, uvsize2.U))
                        {
                            this.arrangeLine(num2, uvsize3.V, i, ++i, useItemU, itemU);
                            num2  += uvsize3.V;
                            uvsize = new WrapPanel.UVSize(this.Orientation);
                        }
                        num = i;
                    }
                    else
                    {
                        uvsize.U += uvsize3.U;
                        uvsize.V  = Math.Max(uvsize3.V, uvsize.V);
                    }
                }
                i++;
            }
            if (num < internalChildren.Count)
            {
                this.arrangeLine(num2, uvsize.V, num, internalChildren.Count, useItemU, itemU);
            }
            return(finalSize);
        }
예제 #5
0
파일: ToolBarTray.cs 프로젝트: ash2005/z
        private void MoveToolBar(ToolBar toolBar, int newBandNumber, double position)
        {
            int  i;
            bool fHorizontal = Orientation == Orientation.Horizontal;

            List <ToolBar> newBand = _bands[newBandNumber].Band;

            // calculate the new BandIndex where toolBar should insert
            // calculate Width (layout) of the items before the toolBar
            if (DoubleUtil.LessThanOrClose(position, 0))
            {
                toolBar.BandIndex = -1; // This will position toolBar at the first place
            }
            else
            {
                double toolBarOffset   = 0d;
                int    newToolBarIndex = -1;
                for (i = 0; i < newBand.Count; i++)
                {
                    ToolBar currentToolBar = newBand[i];
                    if (newToolBarIndex == -1)
                    {
                        toolBarOffset += fHorizontal ? currentToolBar.RenderSize.Width : currentToolBar.RenderSize.Height; // points at the end of currentToolBar
                        if (DoubleUtil.GreaterThan(toolBarOffset, position))
                        {
                            newToolBarIndex   = i + 1;
                            toolBar.BandIndex = newToolBarIndex;
                            // Update the currentToolBar width
                            if (fHorizontal)
                            {
                                currentToolBar.Width = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Width - toolBarOffset + position);
                            }
                            else
                            {
                                currentToolBar.Height = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Height - toolBarOffset + position);
                            }
                        }
                    }
                    else // After we insert the toolBar we need to increase the indexes
                    {
                        currentToolBar.BandIndex = i + 1;
                    }
                }
                if (newToolBarIndex == -1)
                {
                    toolBar.BandIndex = i;
                }
            }
        }
예제 #6
0
        //This creates the repeating animation
        private void UpdateAnimation()
        {
            if (_glow != null)
            {
                if (IsVisible && (_glow.Width > 0) && (_indicator.Width > 0))
                {
                    //Set up the animation
                    double endPos   = _indicator.Width + _glow.Width;
                    double startPos = -1 * _glow.Width;

                    TimeSpan translateTime = TimeSpan.FromSeconds(((int)(endPos - startPos) / 200.0)); // travel at 200px /second
                    TimeSpan pauseTime     = TimeSpan.FromSeconds(1.0);                                // pause 1 second between animations
                    TimeSpan startTime;

                    //Is the animation currenly running (with one pixel fudge factor)
                    if (DoubleUtil.GreaterThan(_glow.Margin.Left, startPos) && (DoubleUtil.LessThan(_glow.Margin.Left, endPos - 1)))
                    {
                        // make it appear that the timer already started.
                        // To do this find out how many pixels the glow has moved and divide by the speed to get time.
                        startTime = TimeSpan.FromSeconds(-1 * (_glow.Margin.Left - startPos) / 200.0);
                    }
                    else
                    {
                        startTime = TimeSpan.Zero;
                    }

                    ThicknessAnimationUsingKeyFrames animation = new ThicknessAnimationUsingKeyFrames();

                    animation.BeginTime      = startTime;
                    animation.Duration       = new Duration(translateTime + pauseTime);
                    animation.RepeatBehavior = RepeatBehavior.Forever;

                    //Start with the glow hidden on the left.
                    animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(startPos, 0, 0, 0), TimeSpan.FromSeconds(0)));
                    //Move to the glow hidden on the right.
                    animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(endPos, 0, 0, 0), translateTime));
                    //There is a pause after the glow is off screen

                    _glow.BeginAnimation(FrameworkElement.MarginProperty, animation);
                }
                else
                {
                    _glow.BeginAnimation(FrameworkElement.MarginProperty, null);
                }
            }
        }
예제 #7
0
        /// <summary>Measures the child elements of a <see cref="T:System.Windows.Controls.WrapPanel" /> in anticipation of arranging them during the <see cref="M:System.Windows.Controls.WrapPanel.ArrangeOverride(System.Windows.Size)" /> pass.</summary>
        /// <param name="constraint">An upper limit <see cref="T:System.Windows.Size" /> that should not be exceeded.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the desired size of the element.</returns>
        // Token: 0x06005B52 RID: 23378 RVA: 0x0019BC88 File Offset: 0x00199E88
        protected override Size MeasureOverride(Size constraint)
        {
            WrapPanel.UVSize    uvsize           = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize2          = new WrapPanel.UVSize(this.Orientation);
            WrapPanel.UVSize    uvsize3          = new WrapPanel.UVSize(this.Orientation, constraint.Width, constraint.Height);
            double              itemWidth        = this.ItemWidth;
            double              itemHeight       = this.ItemHeight;
            bool                flag             = !DoubleUtil.IsNaN(itemWidth);
            bool                flag2            = !DoubleUtil.IsNaN(itemHeight);
            Size                availableSize    = new Size(flag ? itemWidth : constraint.Width, flag2 ? itemHeight : constraint.Height);
            UIElementCollection internalChildren = base.InternalChildren;
            int i     = 0;
            int count = internalChildren.Count;

            while (i < count)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    uielement.Measure(availableSize);
                    WrapPanel.UVSize uvsize4 = new WrapPanel.UVSize(this.Orientation, flag ? itemWidth : uielement.DesiredSize.Width, flag2 ? itemHeight : uielement.DesiredSize.Height);
                    if (DoubleUtil.GreaterThan(uvsize.U + uvsize4.U, uvsize3.U))
                    {
                        uvsize2.U  = Math.Max(uvsize.U, uvsize2.U);
                        uvsize2.V += uvsize.V;
                        uvsize     = uvsize4;
                        if (DoubleUtil.GreaterThan(uvsize4.U, uvsize3.U))
                        {
                            uvsize2.U  = Math.Max(uvsize4.U, uvsize2.U);
                            uvsize2.V += uvsize4.V;
                            uvsize     = new WrapPanel.UVSize(this.Orientation);
                        }
                    }
                    else
                    {
                        uvsize.U += uvsize4.U;
                        uvsize.V  = Math.Max(uvsize4.V, uvsize.V);
                    }
                }
                i++;
            }
            uvsize2.U  = Math.Max(uvsize.U, uvsize2.U);
            uvsize2.V += uvsize.V;
            return(new Size(uvsize2.Width, uvsize2.Height));
        }
예제 #8
0
        // Token: 0x0600545C RID: 21596 RVA: 0x00175A78 File Offset: 0x00173C78
        internal static double ComputeScrollOffsetWithMinimalScroll(double topView, double bottomView, double topChild, double bottomChild, ref bool alignTop, ref bool alignBottom)
        {
            bool flag  = DoubleUtil.LessThan(topChild, topView) && DoubleUtil.LessThan(bottomChild, bottomView);
            bool flag2 = DoubleUtil.GreaterThan(bottomChild, bottomView) && DoubleUtil.GreaterThan(topChild, topView);
            bool flag3 = bottomChild - topChild > bottomView - topView;

            if (((flag && !flag3) || (flag2 && flag3)) | alignTop)
            {
                alignTop = true;
                return(topChild);
            }
            if ((flag || flag2) | alignBottom)
            {
                alignBottom = true;
                return(bottomChild - (bottomView - topView));
            }
            return(topView);
        }
예제 #9
0
        // Token: 0x06005860 RID: 22624 RVA: 0x00187CB4 File Offset: 0x00185EB4
        private int GetBandFromOffset(double toolBarOffset)
        {
            if (DoubleUtil.LessThan(toolBarOffset, 0.0))
            {
                return(-1);
            }
            double num = 0.0;

            for (int i = 0; i < this._bands.Count; i++)
            {
                num += this._bands[i].Thickness;
                if (DoubleUtil.GreaterThan(num, toolBarOffset))
                {
                    return(i);
                }
            }
            return(this._bands.Count);
        }
예제 #10
0
        // Token: 0x0600585F RID: 22623 RVA: 0x00187B94 File Offset: 0x00185D94
        private void MoveToolBar(ToolBar toolBar, int newBandNumber, double position)
        {
            bool           flag = this.Orientation == Orientation.Horizontal;
            List <ToolBar> band = this._bands[newBandNumber].Band;

            if (DoubleUtil.LessThanOrClose(position, 0.0))
            {
                toolBar.BandIndex = -1;
                return;
            }
            double num  = 0.0;
            int    num2 = -1;
            int    i;

            for (i = 0; i < band.Count; i++)
            {
                ToolBar toolBar2 = band[i];
                if (num2 == -1)
                {
                    num += (flag ? toolBar2.RenderSize.Width : toolBar2.RenderSize.Height);
                    if (DoubleUtil.GreaterThan(num, position))
                    {
                        num2 = i + 1;
                        toolBar.BandIndex = num2;
                        if (flag)
                        {
                            toolBar2.Width = Math.Max(toolBar2.MinLength, toolBar2.RenderSize.Width - num + position);
                        }
                        else
                        {
                            toolBar2.Height = Math.Max(toolBar2.MinLength, toolBar2.RenderSize.Height - num + position);
                        }
                    }
                }
                else
                {
                    toolBar2.BandIndex = i + 1;
                }
            }
            if (num2 == -1)
            {
                toolBar.BandIndex = i;
            }
        }
예제 #11
0
        internal static double ComputeScrollOffsetWithMinimalScroll(
            double topView,
            double bottomView,
            double topChild,
            double bottomChild,
            ref bool alignTop,
            ref bool alignBottom)
        {
            // # CHILD POSITION       CHILD SIZE      SCROLL      REMEDY
            // 1 Above viewport       <= viewport     Down        Align top edge of child & viewport
            // 2 Above viewport       > viewport      Down        Align bottom edge of child & viewport
            // 3 Below viewport       <= viewport     Up          Align bottom edge of child & viewport
            // 4 Below viewport       > viewport      Up          Align top edge of child & viewport
            // 5 Entirely within viewport             NA          No scroll.
            // 6 Spanning viewport                    NA          No scroll.
            //
            // Note: "Above viewport" = childTop above viewportTop, childBottom above viewportBottom
            //       "Below viewport" = childTop below viewportTop, childBottom below viewportBottom
            // These child thus may overlap with the viewport, but will scroll the same direction/

            bool fAbove  = DoubleUtil.LessThan(topChild, topView) && DoubleUtil.LessThan(bottomChild, bottomView);
            bool fBelow  = DoubleUtil.GreaterThan(bottomChild, bottomView) && DoubleUtil.GreaterThan(topChild, topView);
            bool fLarger = (bottomChild - topChild) > (bottomView - topView);

            // Handle Cases:  1 & 4 above
            if ((fAbove && !fLarger) ||
                (fBelow && fLarger) ||
                alignTop)
            {
                alignTop = true;
                return(topChild);
            }

            // Handle Cases: 2 & 3 above
            else if (fAbove || fBelow || alignBottom)
            {
                alignBottom = true;
                return(bottomChild - (bottomView - topView));
            }

            // Handle cases: 5 & 6 above.
            return(topView);
        }
예제 #12
0
파일: ToolBarTray.cs 프로젝트: ash2005/z
        private int GetBandFromOffset(double toolBarOffset)
        {
            if (DoubleUtil.LessThan(toolBarOffset, 0))
            {
                return(-1);
            }

            double bandOffset = 0d;

            for (int i = 0; i < _bands.Count; i++)
            {
                bandOffset += _bands[i].Thickness;
                if (DoubleUtil.GreaterThan(bandOffset, toolBarOffset))
                {
                    return(i);
                }
            }

            return(_bands.Count);
        }
예제 #13
0
파일: ToolBarTray.cs 프로젝트: ash2005/z
        private void ProcessThumbDragDelta(DragDeltaEventArgs e)
        {
            // Process thumb event only if Thumb styled parent is a ToolBar under the TollBarTray
            Thumb thumb = e.OriginalSource as Thumb;

            if (thumb != null)
            {
                ToolBar toolBar = thumb.TemplatedParent as ToolBar;
                if (toolBar != null && toolBar.Parent == this)
                {
                    // _bandsDirty would be true at this time only when a Measure gets
                    // skipped between two mouse moves. Ideally that should not happen
                    // but VS has proved that it can. Hence making the code more robust.
                    // Uncomment the line below if the measure skip issue ever gets fixed.
                    // Debug.Assert(!_bandsDirty, "Bands should not be dirty at this point");
                    if (_bandsDirty)
                    {
                        GenerateBands();
                    }

                    bool   fHorizontal = (Orientation == Orientation.Horizontal);
                    int    currentBand = toolBar.Band;
                    Point  pointRelativeToToolBarTray = Mouse.PrimaryDevice.GetPosition((IInputElement)this);
                    Point  pointRelativeToToolBar     = TransformPointToToolBar(toolBar, pointRelativeToToolBarTray);
                    int    hittestBand = GetBandFromOffset(fHorizontal ? pointRelativeToToolBarTray.Y : pointRelativeToToolBarTray.X);
                    double newPosition;
                    double thumbChange = fHorizontal ? e.HorizontalChange : e.VerticalChange;
                    double toolBarPosition;
                    if (fHorizontal)
                    {
                        toolBarPosition = pointRelativeToToolBarTray.X - pointRelativeToToolBar.X;
                    }
                    else
                    {
                        toolBarPosition = pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y;
                    }
                    newPosition = toolBarPosition + thumbChange; // New toolBar position

                    // Move within the band
                    if (hittestBand == currentBand)
                    {
                        List <ToolBar> band         = _bands[currentBand].Band;
                        int            toolBarIndex = toolBar.BandIndex;

                        // Move ToolBar within the band
                        if (DoubleUtil.LessThan(thumbChange, 0)) // Move left/up
                        {
                            double toolBarsTotalMinimum = ToolBarsTotalMinimum(band, 0, toolBarIndex - 1);
                            // Check if minimized toolbars will fit in the range
                            if (DoubleUtil.LessThanOrClose(toolBarsTotalMinimum, newPosition))
                            {
                                ShrinkToolBars(band, 0, toolBarIndex - 1, -thumbChange);
                            }
                            else if (toolBarIndex > 0) // Swap toolbars
                            {
                                ToolBar prevToolBar = band[toolBarIndex - 1];
                                Point   pointRelativeToPreviousToolBar = TransformPointToToolBar(prevToolBar, pointRelativeToToolBarTray);
                                // if pointer in on the left side of previous toolbar
                                if (DoubleUtil.LessThan((fHorizontal ? pointRelativeToPreviousToolBar.X : pointRelativeToPreviousToolBar.Y), 0))
                                {
                                    prevToolBar.BandIndex = toolBarIndex;
                                    band[toolBarIndex]    = prevToolBar;

                                    toolBar.BandIndex      = toolBarIndex - 1;
                                    band[toolBarIndex - 1] = toolBar;

                                    if (toolBarIndex + 1 == band.Count) // If toolBar was the last item in the band
                                    {
                                        prevToolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty);
                                    }
                                }
                                else
                                { // Move to the left/up and shring the other toolbars
                                    if (fHorizontal)
                                    {
                                        if (DoubleUtil.LessThan(toolBarsTotalMinimum, pointRelativeToToolBarTray.X - pointRelativeToToolBar.X))
                                        {
                                            ShrinkToolBars(band, 0, toolBarIndex - 1, pointRelativeToToolBarTray.X - pointRelativeToToolBar.X - toolBarsTotalMinimum);
                                        }
                                    }
                                    else
                                    {
                                        if (DoubleUtil.LessThan(toolBarsTotalMinimum, pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y))
                                        {
                                            ShrinkToolBars(band, 0, toolBarIndex - 1, pointRelativeToToolBarTray.Y - pointRelativeToToolBar.Y - toolBarsTotalMinimum);
                                        }
                                    }
                                }
                            }
                        }
                        else // Move right/down
                        {
                            double toolBarsTotalMaximum = ToolBarsTotalMaximum(band, 0, toolBarIndex - 1);

                            if (DoubleUtil.GreaterThan(toolBarsTotalMaximum, newPosition))
                            {
                                ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange);
                            }
                            else
                            {
                                if (toolBarIndex < band.Count - 1) // Swap toolbars
                                {
                                    ToolBar nextToolBar = band[toolBarIndex + 1];
                                    Point   pointRelativeToNextToolBar = TransformPointToToolBar(nextToolBar, pointRelativeToToolBarTray);
                                    // if pointer in on the right side of next toolbar
                                    if (DoubleUtil.GreaterThanOrClose((fHorizontal ? pointRelativeToNextToolBar.X : pointRelativeToNextToolBar.Y), 0))
                                    {
                                        nextToolBar.BandIndex = toolBarIndex;
                                        band[toolBarIndex]    = nextToolBar;

                                        toolBar.BandIndex      = toolBarIndex + 1;
                                        band[toolBarIndex + 1] = toolBar;
                                        if (toolBarIndex + 2 == band.Count) // If toolBar becomes the last item in the band
                                        {
                                            toolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty);
                                        }
                                    }
                                    else
                                    {
                                        ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange);
                                    }
                                }
                                else
                                {
                                    ExpandToolBars(band, 0, toolBarIndex - 1, thumbChange);
                                }
                            }
                        }
                    }
                    else // Move ToolBar to another band
                    {
                        _bandsDirty  = true;
                        toolBar.Band = hittestBand;
                        toolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty);

                        // move to another existing band
                        if (hittestBand >= 0 && hittestBand < _bands.Count)
                        {
                            MoveToolBar(toolBar, hittestBand, newPosition);
                        }

                        List <ToolBar> oldBand = _bands[currentBand].Band;
                        // currentBand should restore sizes to Auto
                        for (int i = 0; i < oldBand.Count; i++)
                        {
                            ToolBar currentToolBar = oldBand[i];
                            currentToolBar.ClearValue(fHorizontal ? WidthProperty : HeightProperty);
                        }
                    }

                    e.Handled = true;
                }
            }
        }
예제 #14
0
        // Token: 0x060058E9 RID: 22761 RVA: 0x00189730 File Offset: 0x00187930
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scrollHost = base.ScrollHost;

            if (scrollHost != null)
            {
                bool flag = base.FlowDirection == FlowDirection.RightToLeft;
                switch (key)
                {
                case Key.Prior:
                    if (DoubleUtil.GreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageUp();
                    }
                    else
                    {
                        scrollHost.PageLeft();
                    }
                    return(true);

                case Key.Next:
                    if (DoubleUtil.GreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageDown();
                    }
                    else
                    {
                        scrollHost.PageRight();
                    }
                    return(true);

                case Key.End:
                    scrollHost.ScrollToBottom();
                    return(true);

                case Key.Home:
                    scrollHost.ScrollToTop();
                    return(true);

                case Key.Left:
                    if (flag)
                    {
                        scrollHost.LineRight();
                    }
                    else
                    {
                        scrollHost.LineLeft();
                    }
                    return(true);

                case Key.Up:
                    scrollHost.LineUp();
                    return(true);

                case Key.Right:
                    if (flag)
                    {
                        scrollHost.LineLeft();
                    }
                    else
                    {
                        scrollHost.LineRight();
                    }
                    return(true);

                case Key.Down:
                    scrollHost.LineDown();
                    return(true);
                }
            }
            return(false);
        }
예제 #15
0
        /// <summary>Draws the contents of a <see cref="T:System.Windows.Media.DrawingContext" /> object during the render pass of a <see cref="T:System.Windows.Controls.Border" />. </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext" /> that defines the object to be drawn.</param>
        // Token: 0x06004266 RID: 16998 RVA: 0x0012FBE0 File Offset: 0x0012DDE0
        protected override void OnRender(DrawingContext dc)
        {
            bool     useLayoutRounding = base.UseLayoutRounding;
            DpiScale dpi = base.GetDpi();

            if (this._useComplexRenderCodePath)
            {
                StreamGeometry borderGeometryCache = this.BorderGeometryCache;
                Brush          brush;
                if (borderGeometryCache != null && (brush = this.BorderBrush) != null)
                {
                    dc.DrawGeometry(brush, null, borderGeometryCache);
                }
                StreamGeometry backgroundGeometryCache = this.BackgroundGeometryCache;
                if (backgroundGeometryCache != null && (brush = this.Background) != null)
                {
                    dc.DrawGeometry(brush, null, backgroundGeometryCache);
                    return;
                }
            }
            else
            {
                Thickness    borderThickness = this.BorderThickness;
                CornerRadius cornerRadius    = this.CornerRadius;
                double       topLeft         = cornerRadius.TopLeft;
                bool         flag            = !DoubleUtil.IsZero(topLeft);
                Brush        borderBrush;
                if (!borderThickness.IsZero && (borderBrush = this.BorderBrush) != null)
                {
                    Pen pen = this.LeftPenCache;
                    if (pen == null)
                    {
                        pen       = new Pen();
                        pen.Brush = borderBrush;
                        if (useLayoutRounding)
                        {
                            pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX);
                        }
                        else
                        {
                            pen.Thickness = borderThickness.Left;
                        }
                        if (borderBrush.IsFrozen)
                        {
                            pen.Freeze();
                        }
                        this.LeftPenCache = pen;
                    }
                    if (borderThickness.IsUniform)
                    {
                        double num       = pen.Thickness * 0.5;
                        Rect   rectangle = new Rect(new Point(num, num), new Point(base.RenderSize.Width - num, base.RenderSize.Height - num));
                        if (flag)
                        {
                            dc.DrawRoundedRectangle(null, pen, rectangle, topLeft, topLeft);
                        }
                        else
                        {
                            dc.DrawRectangle(null, pen, rectangle);
                        }
                    }
                    else
                    {
                        if (DoubleUtil.GreaterThan(borderThickness.Left, 0.0))
                        {
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(num, 0.0), new Point(num, base.RenderSize.Height));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Right, 0.0))
                        {
                            pen = this.RightPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Right;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.RightPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(base.RenderSize.Width - num, 0.0), new Point(base.RenderSize.Width - num, base.RenderSize.Height));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Top, 0.0))
                        {
                            pen = this.TopPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Top;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.TopPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(0.0, num), new Point(base.RenderSize.Width, num));
                        }
                        if (DoubleUtil.GreaterThan(borderThickness.Bottom, 0.0))
                        {
                            pen = this.BottomPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = borderThickness.Bottom;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }
                                this.BottomPenCache = pen;
                            }
                            double num = pen.Thickness * 0.5;
                            dc.DrawLine(pen, new Point(0.0, base.RenderSize.Height - num), new Point(base.RenderSize.Width, base.RenderSize.Height - num));
                        }
                    }
                }
                Brush background = this.Background;
                if (background != null)
                {
                    Point point;
                    Point point2;
                    if (useLayoutRounding)
                    {
                        point = new Point(UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY));
                        if (FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
                        {
                            point2 = new Point(UIElement.RoundLayoutValue(base.RenderSize.Width - borderThickness.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(base.RenderSize.Height - borderThickness.Bottom, dpi.DpiScaleY));
                        }
                        else
                        {
                            point2 = new Point(base.RenderSize.Width - UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX), base.RenderSize.Height - UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY));
                        }
                    }
                    else
                    {
                        point  = new Point(borderThickness.Left, borderThickness.Top);
                        point2 = new Point(base.RenderSize.Width - borderThickness.Right, base.RenderSize.Height - borderThickness.Bottom);
                    }
                    if (point2.X > point.X && point2.Y > point.Y)
                    {
                        if (flag)
                        {
                            Border.Radii radii    = new Border.Radii(cornerRadius, borderThickness, false);
                            double       topLeft2 = radii.TopLeft;
                            dc.DrawRoundedRectangle(background, null, new Rect(point, point2), topLeft2, topLeft2);
                            return;
                        }
                        dc.DrawRectangle(background, null, new Rect(point, point2));
                    }
                }
            }
        }
예제 #16
0
파일: Border.cs 프로젝트: beda2280/wpf-1
        /// <summary>
        /// In addition to the child, Border renders a background + border.  The background is drawn inside the border.
        /// </summary>
        protected override void OnRender(DrawingContext dc)
        {
            bool     useLayoutRounding = this.UseLayoutRounding;
            DpiScale dpi = GetDpi();

            if (_useComplexRenderCodePath)
            {
                Brush          brush;
                StreamGeometry borderGeometry = BorderGeometryCache;
                if (borderGeometry != null &&
                    (brush = BorderBrush) != null)
                {
                    dc.DrawGeometry(brush, null, borderGeometry);
                }

                StreamGeometry backgroundGeometry = BackgroundGeometryCache;
                if (backgroundGeometry != null &&
                    (brush = Background) != null)
                {
                    dc.DrawGeometry(brush, null, backgroundGeometry);
                }
            }
            else
            {
                Thickness border = BorderThickness;
                Brush     borderBrush;

                CornerRadius cornerRadius      = CornerRadius;
                double       outerCornerRadius = cornerRadius.TopLeft; // Already validated that all corners have the same radius
                bool         roundedCorners    = !DoubleUtil.IsZero(outerCornerRadius);

                // If we have a brush with which to draw the border, do so.
                // NB: We double draw corners right now.  Corner handling is tricky (bevelling, &c...) and
                //     we need a firm spec before doing "the right thing."  (greglett, ffortes)
                if (!border.IsZero &&
                    (borderBrush = BorderBrush) != null)
                {
                    // Initialize the first pen.  Note that each pen is created via new()
                    // and frozen if possible.  Doing this avoids the pen
                    // being copied when used in the DrawLine methods.
                    Pen pen = LeftPenCache;
                    if (pen == null)
                    {
                        pen       = new Pen();
                        pen.Brush = borderBrush;

                        if (useLayoutRounding)
                        {
                            pen.Thickness = UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX);
                        }
                        else
                        {
                            pen.Thickness = border.Left;
                        }
                        if (borderBrush.IsFrozen)
                        {
                            pen.Freeze();
                        }

                        LeftPenCache = pen;
                    }

                    double halfThickness;
                    if (border.IsUniform)
                    {
                        halfThickness = pen.Thickness * 0.5;


                        // Create rect w/ border thickness, and round if applying layout rounding.
                        Rect rect = new Rect(new Point(halfThickness, halfThickness),
                                             new Point(RenderSize.Width - halfThickness, RenderSize.Height - halfThickness));

                        if (roundedCorners)
                        {
                            dc.DrawRoundedRectangle(
                                null,
                                pen,
                                rect,
                                outerCornerRadius,
                                outerCornerRadius);
                        }
                        else
                        {
                            dc.DrawRectangle(
                                null,
                                pen,
                                rect);
                        }
                    }
                    else
                    {
                        // Nonuniform border; stroke each edge.
                        if (DoubleUtil.GreaterThan(border.Left, 0))
                        {
                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(halfThickness, 0),
                                new Point(halfThickness, RenderSize.Height));
                        }

                        if (DoubleUtil.GreaterThan(border.Right, 0))
                        {
                            pen = RightPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;

                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX);
                                }
                                else
                                {
                                    pen.Thickness = border.Right;
                                }

                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                RightPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(RenderSize.Width - halfThickness, 0),
                                new Point(RenderSize.Width - halfThickness, RenderSize.Height));
                        }

                        if (DoubleUtil.GreaterThan(border.Top, 0))
                        {
                            pen = TopPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = border.Top;
                                }

                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                TopPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(0, halfThickness),
                                new Point(RenderSize.Width, halfThickness));
                        }

                        if (DoubleUtil.GreaterThan(border.Bottom, 0))
                        {
                            pen = BottomPenCache;
                            if (pen == null)
                            {
                                pen       = new Pen();
                                pen.Brush = borderBrush;
                                if (useLayoutRounding)
                                {
                                    pen.Thickness = UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY);
                                }
                                else
                                {
                                    pen.Thickness = border.Bottom;
                                }
                                if (borderBrush.IsFrozen)
                                {
                                    pen.Freeze();
                                }

                                BottomPenCache = pen;
                            }

                            halfThickness = pen.Thickness * 0.5;
                            dc.DrawLine(
                                pen,
                                new Point(0, RenderSize.Height - halfThickness),
                                new Point(RenderSize.Width, RenderSize.Height - halfThickness));
                        }
                    }
                }

                // Draw background in rectangle inside border.
                Brush background = Background;
                if (background != null)
                {
                    // Intialize background
                    Point ptTL, ptBR;

                    if (useLayoutRounding)
                    {
                        ptTL = new Point(UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX),
                                         UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY));

                        if (FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
                        {
                            ptBR = new Point(UIElement.RoundLayoutValue(RenderSize.Width - border.Right, dpi.DpiScaleX),
                                             UIElement.RoundLayoutValue(RenderSize.Height - border.Bottom, dpi.DpiScaleY));
                        }
                        else
                        {
                            ptBR = new Point(RenderSize.Width - UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX),
                                             RenderSize.Height - UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY));
                        }
                    }
                    else
                    {
                        ptTL = new Point(border.Left, border.Top);
                        ptBR = new Point(RenderSize.Width - border.Right, RenderSize.Height - border.Bottom);
                    }

                    // Do not draw background if the borders are so large that they overlap.
                    if (ptBR.X > ptTL.X && ptBR.Y > ptTL.Y)
                    {
                        if (roundedCorners)
                        {
                            Radii  innerRadii        = new Radii(cornerRadius, border, false); // Determine the inner edge radius
                            double innerCornerRadius = innerRadii.TopLeft;                     // Already validated that all corners have the same radius
                            dc.DrawRoundedRectangle(background, null, new Rect(ptTL, ptBR), innerCornerRadius, innerCornerRadius);
                        }
                        else
                        {
                            dc.DrawRectangle(background, null, new Rect(ptTL, ptBR));
                        }
                    }
                }
            }
        }
예제 #17
0
        /// <summary>
        ///     This is the method that responds to the KeyDown event.
        /// </summary>
        /// <param name="e">Event Arguments</param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool handled = true;
            Key  key     = e.Key;

            switch (key)
            {
            case Key.Divide:
            case Key.Oem2:
                // Ctrl-Fowardslash = Select All
                if (((Keyboard.Modifiers & ModifierKeys.Control) == (ModifierKeys.Control)) && (SelectionMode == SelectionMode.Extended))
                {
                    SelectAll();
                }
                else
                {
                    handled = false;
                }

                break;

            case Key.Oem5:
                // Ctrl-Backslash = Select the item with focus.
                if (((Keyboard.Modifiers & ModifierKeys.Control) == (ModifierKeys.Control)) && (SelectionMode == SelectionMode.Extended))
                {
                    ListBoxItem focusedItemUI = (FocusedInfo != null) ? FocusedInfo.Container as ListBoxItem : null;
                    if (focusedItemUI != null)
                    {
                        MakeSingleSelection(focusedItemUI);
                    }
                }
                else
                {
                    handled = false;
                }

                break;

            case Key.Up:
            case Key.Left:
            case Key.Down:
            case Key.Right:
            {
                KeyboardNavigation.ShowFocusVisual();

                // Depend on logical orientation we decide to move focus or just scroll
                // shouldScroll also detects if we can scroll more in this direction
                bool shouldScroll = ScrollHost != null;
                if (shouldScroll)
                {
                    shouldScroll =
                        ((key == Key.Down && IsLogicalHorizontal && DoubleUtil.GreaterThan(ScrollHost.ScrollableHeight, ScrollHost.VerticalOffset))) ||
                        ((key == Key.Up && IsLogicalHorizontal && DoubleUtil.GreaterThan(ScrollHost.VerticalOffset, 0d))) ||
                        ((key == Key.Right && IsLogicalVertical && DoubleUtil.GreaterThan(ScrollHost.ScrollableWidth, ScrollHost.HorizontalOffset))) ||
                        ((key == Key.Left && IsLogicalVertical && DoubleUtil.GreaterThan(ScrollHost.HorizontalOffset, 0d)));
                }

                if (shouldScroll)
                {
                    ScrollHost.ScrollInDirection(e);
                }
                else
                {
                    if ((ItemsHost != null && ItemsHost.IsKeyboardFocusWithin) || IsKeyboardFocused)
                    {
                        if (!NavigateByLine(KeyboardNavigation.KeyToTraversalDirection(key),
                                            new ItemNavigateArgs(e.Device, Keyboard.Modifiers)))
                        {
                            handled = false;
                        }
                    }
                    else
                    {
                        handled = false;
                    }
                }
            }
            break;

            case Key.Home:
                NavigateToStart(new ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                break;

            case Key.End:
                NavigateToEnd(new ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                break;

            case Key.Space:
            case Key.Enter:
            {
                if (e.Key == Key.Enter && (bool)GetValue(KeyboardNavigation.AcceptsReturnProperty) == false)
                {
                    handled = false;
                    break;
                }

                // If the event came from a ListBoxItem that's a child of ours, then look at it.
                ListBoxItem source = e.OriginalSource as ListBoxItem;

                // If ALT is down & Ctrl is up, then we shouldn't handle this. (system menu)
                if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Alt)) == ModifierKeys.Alt)
                {
                    handled = false;
                    break;
                }

                // If the user hits just "space" while text searching, do not handle the event
                // Note: Space cannot be the first character in a string sent to ITS.
                if (IsTextSearchEnabled && Keyboard.Modifiers == ModifierKeys.None)
                {
                    TextSearch instance = TextSearch.EnsureInstance(this);
                    // If TextSearch enabled and Prefix is not empty
                    // then let this SPACE go so ITS can process it.
                    if (instance != null && (instance.GetCurrentPrefix() != String.Empty))
                    {
                        handled = false;
                        break;
                    }
                }

                if (source != null && ItemsControlFromItemContainer(source) == this)
                {
                    switch (SelectionMode)
                    {
                    case SelectionMode.Single:
                        if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                        {
                            MakeToggleSelection(source);
                        }
                        else
                        {
                            MakeSingleSelection(source);
                        }

                        break;

                    case SelectionMode.Multiple:
                        MakeToggleSelection(source);
                        break;

                    case SelectionMode.Extended:
                        if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control)
                        {
                            // Only CONTROL
                            MakeToggleSelection(source);
                        }
                        else if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Shift)
                        {
                            // Only SHIFT
                            MakeAnchorSelection(source, true /* clearCurrent */);
                        }
                        else if ((Keyboard.Modifiers & ModifierKeys.Shift) == 0)
                        {
                            MakeSingleSelection(source);
                        }
                        else
                        {
                            handled = false;
                        }

                        break;
                    }
                }
                else
                {
                    handled = false;
                }
            }
            break;

            case Key.PageUp:
                NavigateByPage(FocusNavigationDirection.Up, new ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                break;

            case Key.PageDown:
                NavigateByPage(FocusNavigationDirection.Down, new ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                break;

            default:
                handled = false;
                break;
            }
            if (handled)
            {
                e.Handled = true;
            }
            else
            {
                base.OnKeyDown(e);
            }
        }
예제 #18
0
파일: TreeView.cs 프로젝트: ash2005/z
        private bool HandleScrollKeys(Key key)
        {
            ScrollViewer scroller = ScrollHost;

            if (scroller != null)
            {
                bool invert = (FlowDirection == FlowDirection.RightToLeft);
                switch (key)
                {
                case Key.Up:
                    scroller.LineUp();
                    return(true);

                case Key.Down:
                    scroller.LineDown();
                    return(true);

                case Key.Left:
                    if (invert)
                    {
                        scroller.LineRight();
                    }
                    else
                    {
                        scroller.LineLeft();
                    }
                    return(true);

                case Key.Right:
                    if (invert)
                    {
                        scroller.LineLeft();
                    }
                    else
                    {
                        scroller.LineRight();
                    }
                    return(true);

                case Key.Home:
                    scroller.ScrollToTop();
                    return(true);

                case Key.End:
                    scroller.ScrollToBottom();
                    return(true);

                case Key.PageUp:
                    //if vertically scrollable - go vertical, otherwise horizontal
                    if (DoubleUtil.GreaterThan(scroller.ExtentHeight, scroller.ViewportHeight))
                    {
                        scroller.PageUp();
                    }
                    else
                    {
                        scroller.PageLeft();
                    }
                    return(true);

                case Key.PageDown:
                    //if vertically scrollable - go vertical, otherwise horizontal
                    if (DoubleUtil.GreaterThan(scroller.ExtentHeight, scroller.ViewportHeight))
                    {
                        scroller.PageDown();
                    }
                    else
                    {
                        scroller.PageRight();
                    }
                    return(true);
                }
            }

            return(false);
        }
예제 #19
0
        /// <summary>Responds to the <see cref="E:System.Windows.UIElement.KeyDown" /> event. </summary>
        /// <param name="e">Provides data for <see cref="T:System.Windows.Input.KeyEventArgs" />.</param>
        // Token: 0x06005131 RID: 20785 RVA: 0x0016C2F0 File Offset: 0x0016A4F0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool flag = true;
            Key  key  = e.Key;

            if (key <= Key.Down)
            {
                if (key != Key.Return)
                {
                    switch (key)
                    {
                    case Key.Space:
                        break;

                    case Key.Prior:
                        base.NavigateByPage(FocusNavigationDirection.Up, new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                        goto IL_379;

                    case Key.Next:
                        base.NavigateByPage(FocusNavigationDirection.Down, new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                        goto IL_379;

                    case Key.End:
                        base.NavigateToEnd(new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                        goto IL_379;

                    case Key.Home:
                        base.NavigateToStart(new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers));
                        goto IL_379;

                    case Key.Left:
                    case Key.Up:
                    case Key.Right:
                    case Key.Down:
                    {
                        KeyboardNavigation.ShowFocusVisual();
                        bool flag2 = base.ScrollHost != null;
                        if (flag2)
                        {
                            flag2 = ((key == Key.Down && base.IsLogicalHorizontal && DoubleUtil.GreaterThan(base.ScrollHost.ScrollableHeight, base.ScrollHost.VerticalOffset)) || (key == Key.Up && base.IsLogicalHorizontal && DoubleUtil.GreaterThan(base.ScrollHost.VerticalOffset, 0.0)) || (key == Key.Right && base.IsLogicalVertical && DoubleUtil.GreaterThan(base.ScrollHost.ScrollableWidth, base.ScrollHost.HorizontalOffset)) || (key == Key.Left && base.IsLogicalVertical && DoubleUtil.GreaterThan(base.ScrollHost.HorizontalOffset, 0.0)));
                        }
                        if (flag2)
                        {
                            base.ScrollHost.ScrollInDirection(e);
                            goto IL_379;
                        }
                        if ((base.ItemsHost == null || !base.ItemsHost.IsKeyboardFocusWithin) && !base.IsKeyboardFocused)
                        {
                            flag = false;
                            goto IL_379;
                        }
                        if (!base.NavigateByLine(KeyboardNavigation.KeyToTraversalDirection(key), new ItemsControl.ItemNavigateArgs(e.Device, Keyboard.Modifiers)))
                        {
                            flag = false;
                            goto IL_379;
                        }
                        goto IL_379;
                    }

                    default:
                        goto IL_377;
                    }
                }
                if (e.Key == Key.Return && !(bool)base.GetValue(KeyboardNavigation.AcceptsReturnProperty))
                {
                    flag = false;
                    goto IL_379;
                }
                ListBoxItem listBoxItem = e.OriginalSource as ListBoxItem;
                if ((Keyboard.Modifiers & (ModifierKeys.Alt | ModifierKeys.Control)) == ModifierKeys.Alt)
                {
                    flag = false;
                    goto IL_379;
                }
                if (base.IsTextSearchEnabled && Keyboard.Modifiers == ModifierKeys.None)
                {
                    TextSearch textSearch = TextSearch.EnsureInstance(this);
                    if (textSearch != null && textSearch.GetCurrentPrefix() != string.Empty)
                    {
                        flag = false;
                        goto IL_379;
                    }
                }
                if (listBoxItem == null || ItemsControl.ItemsControlFromItemContainer(listBoxItem) != this)
                {
                    flag = false;
                    goto IL_379;
                }
                switch (this.SelectionMode)
                {
                case SelectionMode.Single:
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                    {
                        this.MakeToggleSelection(listBoxItem);
                        goto IL_379;
                    }
                    this.MakeSingleSelection(listBoxItem);
                    goto IL_379;

                case SelectionMode.Multiple:
                    this.MakeToggleSelection(listBoxItem);
                    goto IL_379;

                case SelectionMode.Extended:
                    if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control)
                    {
                        this.MakeToggleSelection(listBoxItem);
                        goto IL_379;
                    }
                    if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Shift)
                    {
                        this.MakeAnchorSelection(listBoxItem, true);
                        goto IL_379;
                    }
                    if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.None)
                    {
                        this.MakeSingleSelection(listBoxItem);
                        goto IL_379;
                    }
                    flag = false;
                    goto IL_379;

                default:
                    goto IL_379;
                }
            }
            else if (key != Key.Divide && key != Key.Oem2)
            {
                if (key == Key.Oem5)
                {
                    if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control || this.SelectionMode != SelectionMode.Extended)
                    {
                        flag = false;
                        goto IL_379;
                    }
                    ListBoxItem listBoxItem2 = (base.FocusedInfo != null) ? (base.FocusedInfo.Container as ListBoxItem) : null;
                    if (listBoxItem2 != null)
                    {
                        this.MakeSingleSelection(listBoxItem2);
                        goto IL_379;
                    }
                    goto IL_379;
                }
            }
            else
            {
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && this.SelectionMode == SelectionMode.Extended)
                {
                    this.SelectAll();
                    goto IL_379;
                }
                flag = false;
                goto IL_379;
            }
IL_377:
            flag = false;
IL_379:
            if (flag)
            {
                e.Handled = true;
                return;
            }
            base.OnKeyDown(e);
        }
예제 #20
0
        // Token: 0x06005859 RID: 22617 RVA: 0x00187528 File Offset: 0x00185728
        private void ProcessThumbDragDelta(DragDeltaEventArgs e)
        {
            Thumb thumb = e.OriginalSource as Thumb;

            if (thumb != null)
            {
                ToolBar toolBar = thumb.TemplatedParent as ToolBar;
                if (toolBar != null && toolBar.Parent == this)
                {
                    if (this._bandsDirty)
                    {
                        this.GenerateBands();
                    }
                    bool   flag           = this.Orientation == Orientation.Horizontal;
                    int    band           = toolBar.Band;
                    Point  position       = Mouse.PrimaryDevice.GetPosition(this);
                    Point  point          = this.TransformPointToToolBar(toolBar, position);
                    int    bandFromOffset = this.GetBandFromOffset(flag ? position.Y : position.X);
                    double num            = flag ? e.HorizontalChange : e.VerticalChange;
                    double num2;
                    if (flag)
                    {
                        num2 = position.X - point.X;
                    }
                    else
                    {
                        num2 = position.Y - point.Y;
                    }
                    double num3 = num2 + num;
                    if (bandFromOffset == band)
                    {
                        List <ToolBar> band2     = this._bands[band].Band;
                        int            bandIndex = toolBar.BandIndex;
                        if (DoubleUtil.LessThan(num, 0.0))
                        {
                            double num4 = this.ToolBarsTotalMinimum(band2, 0, bandIndex - 1);
                            if (DoubleUtil.LessThanOrClose(num4, num3))
                            {
                                this.ShrinkToolBars(band2, 0, bandIndex - 1, -num);
                            }
                            else if (bandIndex > 0)
                            {
                                ToolBar toolBar2 = band2[bandIndex - 1];
                                Point   point2   = this.TransformPointToToolBar(toolBar2, position);
                                if (DoubleUtil.LessThan(flag ? point2.X : point2.Y, 0.0))
                                {
                                    toolBar2.BandIndex   = bandIndex;
                                    band2[bandIndex]     = toolBar2;
                                    toolBar.BandIndex    = bandIndex - 1;
                                    band2[bandIndex - 1] = toolBar;
                                    if (bandIndex + 1 == band2.Count)
                                    {
                                        toolBar2.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty);
                                    }
                                }
                                else if (flag)
                                {
                                    if (DoubleUtil.LessThan(num4, position.X - point.X))
                                    {
                                        this.ShrinkToolBars(band2, 0, bandIndex - 1, position.X - point.X - num4);
                                    }
                                }
                                else if (DoubleUtil.LessThan(num4, position.Y - point.Y))
                                {
                                    this.ShrinkToolBars(band2, 0, bandIndex - 1, position.Y - point.Y - num4);
                                }
                            }
                        }
                        else
                        {
                            double value = this.ToolBarsTotalMaximum(band2, 0, bandIndex - 1);
                            if (DoubleUtil.GreaterThan(value, num3))
                            {
                                this.ExpandToolBars(band2, 0, bandIndex - 1, num);
                            }
                            else if (bandIndex < band2.Count - 1)
                            {
                                ToolBar toolBar3 = band2[bandIndex + 1];
                                Point   point3   = this.TransformPointToToolBar(toolBar3, position);
                                if (DoubleUtil.GreaterThanOrClose(flag ? point3.X : point3.Y, 0.0))
                                {
                                    toolBar3.BandIndex   = bandIndex;
                                    band2[bandIndex]     = toolBar3;
                                    toolBar.BandIndex    = bandIndex + 1;
                                    band2[bandIndex + 1] = toolBar;
                                    if (bandIndex + 2 == band2.Count)
                                    {
                                        toolBar.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty);
                                    }
                                }
                                else
                                {
                                    this.ExpandToolBars(band2, 0, bandIndex - 1, num);
                                }
                            }
                            else
                            {
                                this.ExpandToolBars(band2, 0, bandIndex - 1, num);
                            }
                        }
                    }
                    else
                    {
                        this._bandsDirty = true;
                        toolBar.Band     = bandFromOffset;
                        toolBar.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty);
                        if (bandFromOffset >= 0 && bandFromOffset < this._bands.Count)
                        {
                            this.MoveToolBar(toolBar, bandFromOffset, num3);
                        }
                        List <ToolBar> band3 = this._bands[band].Band;
                        for (int i = 0; i < band3.Count; i++)
                        {
                            ToolBar toolBar4 = band3[i];
                            toolBar4.ClearValue(flag ? FrameworkElement.WidthProperty : FrameworkElement.HeightProperty);
                        }
                    }
                    e.Handled = true;
                }
            }
        }