Esempio n. 1
0
        private void ScrollSelected()
        {
            PathListBox pathListBox = this.AssociatedObject as PathListBox;

            if (pathListBox == null)
            {
                return;
            }
            PathListBoxItem newItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromItem(pathListBox.SelectedItem);

            // find the item on the path that is closest to the position
            PathListBoxItem closestItem = null;
            PathListBoxItem pathListBoxItem;

            for (int i = 0; i < pathListBox.Items.Count; i++)
            {
                pathListBoxItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromIndex(i);
                if (pathListBoxItem != null && pathListBoxItem.IsArranged)
                {
                    if (closestItem == null)
                    {
                        closestItem = pathListBoxItem;
                    }
                    else if (Math.Abs(pathListBoxItem.LocalOffset - this.DesiredOffset) < Math.Abs(closestItem.LocalOffset - this.DesiredOffset))
                    {
                        closestItem = pathListBoxItem;
                    }
                }
            }

            if (closestItem == null || newItem == null || !newItem.IsArranged || !closestItem.IsArranged)
            {
                return;
            }
            int increment = 0;

            if (newItem.GlobalOffset < closestItem.GlobalOffset && newItem.GlobalIndex > closestItem.GlobalIndex)
            {
                increment = -(pathListBox.Items.Count - newItem.GlobalIndex + closestItem.GlobalIndex);
            }
            else if (newItem.GlobalOffset > closestItem.GlobalOffset && newItem.GlobalIndex < closestItem.GlobalIndex)
            {
                increment = (pathListBox.Items.Count - closestItem.GlobalIndex + newItem.GlobalIndex);
            }
            else
            {
                increment = newItem.GlobalIndex - closestItem.GlobalIndex;
            }

            bool hideEnteringItem = this.HideEnteringItem;

            this.HideEnteringItem = false;

            Scroll(increment);

            this.HideEnteringItem = hideEnteringItem;
        }
Esempio n. 2
0
        private void PathListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PathListBox pathListBox = sender as PathListBox;

            if (selectObj != null)
            {
                selectObj.SetPropertyValue("childsShow", "Collapsed", false);
            }
            selectObj = pathListBox.SelectedItem as GeneralObject;
            if (selectObj != null)
            {
                selectObj.SetPropertyValue("childsShow", "Visible", false);
            }
        }
Esempio n. 3
0
        private void menus_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            PathListBox pathListBox = sender as PathListBox;

            if (selectObj != null)
            {
                selectObj.SetPropertyValue("childsShow", "Collapsed", false);
            }
            selectObj = pathListBox.SelectedItem as GeneralObject;
            if (selectObj != null)
            {
                selectObj.SetPropertyValue("childsShow", "Visible", false);
            }
        }
Esempio n. 4
0
        private void InitializeComponent()
        {
            _pathListBox = new PathListBox();

            _pathListBox.Size = new Size(300, 100);
            //^(?<id>\d+)(?:__[a-zA-Zа-яА-Я0-9\-\+_]+)?(?:\.(?<ext>[a-zA-Z0-9]+))?$ derpibooru name regex

            MinimizeBox         = false;
            MaximizeBox         = false;
            ShowInTaskbar       = false;
            AutoScaleDimensions = new SizeF(7F, 15F);
            ClientSize          = new Size(450, 250);
            AutoScaleMode       = AutoScaleMode.Font;
            FormBorderStyle     = FormBorderStyle.FixedDialog;
            Controls.Add(_pathListBox);
            Icon = ImageUtils.IconFromImage(Images.Line.Tech);
        }
Esempio n. 5
0
        private void ListBox1_MouseUp(object sender, MouseEventArgs e)
        {
            int index = PathListBox.IndexFromPoint(e.Location);

            if (index != ListBox.NoMatches)
            {
                string fileName = PathListBox.Items[index] as string;
                if (e.Button == MouseButtons.Left)
                {
                    // 存在しないパスならコメントとする
                    if (fileName == "")
                    {
                        return;
                    }
                    if (fileName.IsPathExist( ))
                    {
                        var parent = Directory.GetParent(fileName).FullName;
                        Environment.CurrentDirectory = parent;
                        var proc = Process.Start(fileName);
                        Environment.CurrentDirectory = FirstCurrent;
                        //proc.StartInfo.EnvironmentVariables.
                    }
                    if (fileName.StartsWith("http"))
                    {
                        Process.Start(fileName);
                    }
                }
                // 右クリックなら要素削除、中クリックなら親フォルダを開く
                else if (e.Button == MouseButtons.Right)
                {
                    PathListBox.Items.RemoveAt(index);
                    Redraw( );
                }
                else
                {
                    OpenParent(fileName);
                }
            }
            else
            {
                // 試しに更新
                UpdateQSaveList( );
                OpenParent(OpeningPath);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Determines the number of items currently arranged on the specified layout path.</summary>
        /// <param name=”layoutPathIndex”> The specified layout path.</param>
        /// <returns> The number of items arranged.</returns>
        public static int GetItemsArrangedCount(this PathListBox pathListBox, int layoutPathIndex)
        {
            if (pathListBox == null)
            {
                return(0);
            }
            int             count = 0;
            PathListBoxItem pathListBoxItem;

            for (int i = 0; i < pathListBox.Items.Count; i++)
            {
                pathListBoxItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromItem(pathListBox.Items[i]);
                if (pathListBoxItem != null && (layoutPathIndex == -1 || pathListBoxItem.LayoutPathIndex == layoutPathIndex))
                {
                    count++;
                }
            }
            return(count);
        }
Esempio n. 7
0
        /// <summary>
        /// Finds the item that is laid out at the end of the specified layout path.</summary>
        /// <param name=”layoutPathIndex”> The specified layout path.</param>
        /// <returns> The global index of the item.</returns>
        public static int GetLastArrangedIndex(this PathListBox pathListBox, int layoutPathIndex)
        {
            if (pathListBox == null)
            {
                return(0);
            }

            PathListBoxItem pathListBoxItem;
            PathListBoxItem lastItemArranged  = null;
            int             lastArrangedIndex = 0;

            for (int i = 0; i < pathListBox.Items.Count; i++)
            {
                pathListBoxItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromIndex(i);
                if (pathListBoxItem != null && pathListBoxItem.LayoutPathIndex == layoutPathIndex)
                {
                    if (lastItemArranged == null)
                    {
                        if (pathListBoxItem.IsArranged)
                        {
                            lastItemArranged  = pathListBoxItem;
                            lastArrangedIndex = lastItemArranged.GlobalIndex;
                        }
                    }
                    else
                    {
                        if (pathListBoxItem.LocalIndex > lastItemArranged.LocalIndex &&
                            pathListBoxItem.Visibility == Visibility.Visible && pathListBoxItem.IsArranged)
                        {
                            lastItemArranged  = pathListBoxItem;
                            lastArrangedIndex = lastItemArranged.GlobalIndex;
                        }
                    }
                }
            }
            return(lastArrangedIndex);
        }
Esempio n. 8
0
 private void DeselectPath(object sender, RoutedEventArgs e) => PathListBox.UnselectAll();
Esempio n. 9
0
        private void UpdateTransform()
        {
            if (this.pathListBox == null)
            {
                this.pathListBox = PathListBoxItemTransformer.FindAncestor <PathListBox>(this);
                if (this.pathListBox == null)
                {
                    return;
                }
            }

            if (this.pathLayoutItem == null)
            {
                this.pathLayoutItem = PathListBoxItemTransformer.FindAncestor <IPathLayoutItem>(this);
                if (this.pathLayoutItem == null)
                {
                    return;
                }
                this.pathLayoutItem.PathLayoutUpdated += this.IPathLayoutItem_PathLayoutUpdated;
            }

            double offset = 0;

            if (this.UseGlobalOffset)
            {
                offset = this.pathLayoutItem.GlobalOffset;
            }
            else
            {
                offset = this.pathLayoutItem.LocalOffset;
            }

            offset = (offset + Math.Abs(this.Shift)) % 1;

            int zIndex          = 0;
            int layoutPathIndex = -1;

            zIndex          = this.pathLayoutItem.LocalIndex;
            layoutPathIndex = this.pathLayoutItem.LayoutPathIndex;

            // Adjust the offset so that it is normalized over a range of -1 to 1 if falloff from center.
            if (this.IsCentered)
            {
                offset = Math.Abs(PathListBoxItemTransformer.Lerp(-1, 1, (offset + 0.5) % 1.0));
                int numItems = this.pathListBox.GetItemsArrangedCount(layoutPathIndex) / 2;
                zIndex = (int)Math.Round(offset * numItems);
            }

            UIElement element = this.pathLayoutItem as UIElement;

            if (element != null && Canvas.GetZIndex(element) != zIndex)
            {
                Canvas.SetZIndex(element, (int)zIndex);
            }

            // Adjust the offset by the user specified easing function.
            if (this.Ease != null)
            {
                offset = this.Ease.Ease(offset);
            }

            // Check value before setting it to avoid layout cycle exceptions.
            if (this.AdjustedOffset != offset)
            {
                this.AdjustedOffset = offset;
            }

            // Use the adjusted offset to interpolate between the user specified start and end for scale and opacity.
            double scale = 1;

            scale = PathListBoxItemTransformer.Lerp(this.ScaleRange.X, this.ScaleRange.Y, this.AdjustedOffset);
            ScaleTransform scaleTransform = (ScaleTransform)this.transformGroup.Children[0];

            scaleTransform.ScaleX = scale;
            scaleTransform.ScaleY = scale;

            double          angle           = PathListBoxItemTransformer.Lerp(this.AngleRange.X, this.AngleRange.Y, this.AdjustedOffset) + this.pathLayoutItem.OrientationAngle;
            RotateTransform rotateTransform = (RotateTransform)this.transformGroup.Children[1];

            rotateTransform.Angle = angle;

            this.Opacity = PathListBoxItemTransformer.Lerp(this.OpacityRange.X, this.OpacityRange.Y, this.AdjustedOffset);
        }
Esempio n. 10
0
 public PathToCarousel(PathListBox InitPath)
 {
     TransformedCarousel = InitPath;
 }
 public PathToCarousel(PathListBox InitPath)
 {
     TransformedCarousel = InitPath;
 }
Esempio n. 12
0
        private void AnimateStart(PathListBox pathListBox, int increment, int layoutPathIndex, int startItemIndex, Duration newDuration, bool isStoryboardInterruped)
        {
            LayoutPath layoutPath = pathListBox.LayoutPaths[layoutPathIndex];

            if (layoutPath == null || increment == 0)
            {
                return;
            }

            // Get the distance between the two elements that are being arranged to compute the distance to animate start.
            int itemCount = pathListBox.Items.Count;

            int firstIndex = 0;
            int nextIndex  = 0;

            firstIndex = PathListBoxExtensions.GetFirstArrangedIndex(pathListBox, layoutPathIndex);
            nextIndex  = (firstIndex + 1) % itemCount;

            PathListBoxItem plbiStart = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(firstIndex));
            PathListBoxItem plbiEnd   = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(nextIndex));

            if (plbiStart.IsArranged == false || plbiEnd.IsArranged == false)
            {
                if (pathListBox.WrapItems)
                {
                    while (plbiStart.IsArranged == false || plbiEnd.IsArranged == false)
                    {
                        firstIndex = (firstIndex + 1) % itemCount;
                        nextIndex  = (nextIndex + 1) % itemCount;
                        plbiStart  = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(firstIndex));
                        plbiEnd    = (PathListBoxItem)(pathListBox.ItemContainerGenerator.ContainerFromIndex(nextIndex));
                    }
                }
                else
                {
                    return;
                }
            }

            double startDx = 0;

            if (plbiStart.LocalOffset > plbiEnd.LocalOffset)
            {
                // if the Start and End cross 0
                startDx = increment * ((1 - plbiStart.LocalOffset) + plbiEnd.LocalOffset);
            }
            else
            {
                startDx = increment * (plbiEnd.LocalOffset - plbiStart.LocalOffset);
            }

            double startFrom = layoutPath.Start;
            double startTo   = layoutPath.Start;

            PropertyPath propertyPath = new PropertyPath(String.Format("(ec:PathListBox.LayoutPaths)[{0}].(ec:LayoutPath.Start)", layoutPathIndex));

            DoubleAnimation startPropertyAnimation = null;

            if (isStoryboardInterruped)
            {
                // Find the DoubleAnimation that has already been created for this LayoutPath
                for (int i = 0; i < this.startPropertyStoryboard.Children.Count; i++)
                {
                    DoubleAnimation currentAnimation = (DoubleAnimation)this.startPropertyStoryboard.Children[i];
                    PropertyPath    pp = Storyboard.GetTargetProperty(currentAnimation);
                    if (currentAnimation != null && String.Equals(pp.Path, propertyPath.Path))
                    {
                        startPropertyAnimation = currentAnimation;
                        break;
                    }
                }
                startTo = (double)startPropertyAnimation.To;
                ShowItems();
                startFrom = startTo;
            }
            else
            {
                startPropertyAnimation = new DoubleAnimation();
                Storyboard.SetTarget(startPropertyAnimation, pathListBox);
                Storyboard.SetTargetProperty(startPropertyAnimation, propertyPath);
                this.startPropertyStoryboard.Children.Add(startPropertyAnimation);
            }

            startFrom += startDx;

            int EnteringItemIndex = 0;

            if (increment > 0)
            {
                EnteringItemIndex = pathListBox.GetLastArrangedIndex(layoutPathIndex);
                EnteringItemIndex = (EnteringItemIndex + 1) % itemCount;
            }
            else
            {
                EnteringItemIndex = (pathListBox.GetFirstArrangedIndex(layoutPathIndex) - 1) % itemCount;
                if (EnteringItemIndex < 0)
                {
                    if (pathListBox.WrapItems)
                    {
                        EnteringItemIndex += itemCount;
                    }
                }
            }
            PathListBoxItem pathListBoxItem = (PathListBoxItem)pathListBox.ItemContainerGenerator.ContainerFromIndex(EnteringItemIndex);

            if (pathListBoxItem != null && this.HideEnteringItem)
            {
                this.enteringItem         = pathListBoxItem;
                this.enteringItem.Opacity = 0;
            }

            startPropertyAnimation.Duration       = newDuration;
            startPropertyAnimation.From           = startFrom + 0.0001;
            startPropertyAnimation.To             = startTo;
            startPropertyAnimation.EasingFunction = this.Ease;
        }
Esempio n. 13
0
 private void UpdateStartItemIndex(PathListBox pathListBox)
 {
     pathListBox.StartItemIndex = this.newIndex;
     this.newIndex = -1;
 }
Esempio n. 14
0
        private void Scroll(int increment)
        {
            bool hideEnteringItem = this.HideEnteringItem;

            if (Math.Abs(increment) > 1)
            {
                this.HideEnteringItem = false;
            }

            PathListBox pathListBox = this.AssociatedObject as PathListBox;

            if (pathListBox == null || pathListBox.Items == null || pathListBox.Items.Count <= 1)
            {
                return;
            }

            if (pathListBox.StartItemIndex >= pathListBox.Items.Count)
            {
                throw new ArgumentOutOfRangeException("StartItemIndex", "Value may be greater than the number of items in the collection.");
            }

            int startItemIndex = Math.Max(0, (int)Math.Round(pathListBox.StartItemIndex));
            int itemCount      = pathListBox.Items.Count;

            // We have interrupted a storyboard already in progress, so save off what the
            // startItemIndex would have been if the storyboard completed and increment
            // the this.newIndex.
            if (this.newIndex != -1)
            {
                startItemIndex = this.newIndex;
            }

            int newIndex = (startItemIndex + increment) % itemCount;

            if (newIndex < 0)
            {
                if (pathListBox.WrapItems)
                {
                    newIndex += itemCount;
                }
                else
                {
                    return;
                }
            }
            this.newIndex = newIndex;

            // If the storyboard is playing interupt it.
            TimeSpan timeRemaining = new TimeSpan();

            if (IsStoryboardPlaying())
            {
                timeRemaining = this.startPropertyStoryboard.GetCurrentTime();
                this.startPropertyStoryboard.Pause();
            }
            else
            {
                this.startPropertyStoryboard.Stop();
                this.startPropertyStoryboard.Children.Clear();
            }

            // Compute the new duration based on whatever is remaining plus what the user specified.
            Duration newDuration = new Duration(timeRemaining);

            if (this.Duration == Duration.Automatic)
            {
                // if the duration is automatic it is 1 second
                newDuration += new TimeSpan(0, 0, 1);
            }
            else
            {
                newDuration += this.Duration;
            }

            for (int i = 0; i < pathListBox.LayoutPaths.Count; i++)
            {
                this.AnimateStart(pathListBox, increment, i, startItemIndex, newDuration, !TimeSpan.Equals(timeRemaining, new TimeSpan()));
            }

            this.UpdateStartItemIndex(pathListBox);

            this.startPropertyStoryboard.Begin();

            this.HideEnteringItem = hideEnteringItem;
        }