private void AnchorPointPanel_MouseEnter(object sender, MouseEventArgs e)
        {
            DoubleAnimation daV       = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
            var             scrollBar = MyVisualTreeHelper.FindChild <ScrollBar>(this.scrollViewer, "PART_VerticalScrollBar");

            scrollBar.BeginAnimation(UIElement.OpacityProperty, daV);
        }
Beispiel #2
0
        private void OverlayElementMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _isMouseDown = true;
            var canvas = MyVisualTreeHelper.GetParent <Canvas>(_draggedDeviceVisual);

            _dragStartPoint = e.GetPosition(canvas);
            canvas.CaptureMouse();
            e.Handled = true;
        }
Beispiel #3
0
        private void DragStarted()
        {
            _isDragging = true;
            var ui = (UIElement)MyVisualTreeHelper.GetParent <ContentPresenter>(_draggedDeviceVisual);

            _dragStartLeft = DynamicCanvas.GetLeft(ui);
            _dragStartTop  = DynamicCanvas.GetTop(ui);
            SelectElement(_draggedDeviceVisual);
            _overlayElement.IsDragging = true;
        }
Beispiel #4
0
 /// <summary>
 /// 为<see cref="FinanceListView"/>中的Controls注册Delegate(Refresh)
 /// </summary>
 private void AddDelegate()
 {
     for (int i = 0; i < FinanceListView.Items.Count; i++)
     {
         var container            = FinanceListView.ContainerFromIndex(i);
         FinanceItemTemplate item = MyVisualTreeHelper.SearchVisualTree <FinanceItemTemplate>(container);
         if (item != null)
         {
             item.OnSubmitedSuccess += new FinanceItemTemplate.FinanceItemDelegate(Refresh);
         }
     }
 }
        /// <summary>
        /// 隐藏最右边的线
        /// </summary>
        private void RemoveRightLine()
        {
            ListBoxItem item = (ListBoxItem)this.ItemContainerGenerator.ContainerFromIndex(this.Items.Count - 1);

            if (item != null)
            {
                var border = MyVisualTreeHelper.FindChild <Border>(item, "PART_RightLine");
                if (border != null)
                {
                    border.Visibility = Visibility.Collapsed;
                }
            }
        }
        private void SegmentButton_Loaded(object sender, RoutedEventArgs e)
        {
            var borderList = MyVisualTreeHelper.FindVisualChildren <Border>(this, "PART_ButtonSpliteLine").ToList();

            if (borderList != null)
            {
                for (int i = 0; i < borderList.Count; i++)
                {
                    //隐藏最后一个分隔线
                    if (i == this.Items.Count - 1)
                    {
                        var border = borderList[i];
                        border.Visibility = Visibility.Collapsed;
                    }
                }
            }

            int itemsCount = this.Items.Count;

            if (itemsCount > 0)
            {
                var listboxitem = this.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement;
                var border      = MyVisualTreeHelper.FindChild <Border>(listboxitem, "PART_ItemBorder");
                if (border != null)
                {
                    //如果控件只有一项的时候,需要重新设置边框的圆角
                    if (itemsCount == 1)
                    {
                        border.CornerRadius = new CornerRadius(5, 5, 5, 5);
                    }
                    else
                    {
                        if (this.SelectedIndex == 0)
                        {
                            border.CornerRadius = new CornerRadius(5, 0, 0, 5);
                        }
                        else if (this.SelectedIndex == itemsCount - 1)
                        {
                            border.CornerRadius = new CornerRadius(5, 5, 5, 5);
                        }
                        else
                        {
                            border.CornerRadius = new CornerRadius(0, 0, 0, 0);
                        }
                    }
                }
            }
        }
Beispiel #7
0
        private void DrawingAreaPreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (_isMouseDown)
            {
                var canvas = MyVisualTreeHelper.GetParent <ItemsControl>((FrameworkElement)e.Source);
                if ((_isDragging == false) && ((Math.Abs(e.GetPosition(canvas).X - _dragStartPoint.X) > SystemParameters.MinimumHorizontalDragDistance) ||
                                               (Math.Abs(e.GetPosition(canvas).Y - _dragStartPoint.Y) > SystemParameters.MinimumVerticalDragDistance)))
                {
                    DragStarted();
                }

                if (_isDragging)
                {
                    DragMoved(canvas);
                }
            }
        }
Beispiel #8
0
        void OnListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            ListViewItem item = MyVisualTreeHelper.FindParent <ListViewItem>((DependencyObject)e.OriginalSource);

            if (item == null)
            {
                return;
            }

            if (item.Focusable && !item.IsFocused)
            {
                item.Focus();
            }
        }
Beispiel #9
0
        private void DrawingAreaPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var vsender = MyVisualTreeHelper.GetParent(((FrameworkElement)e.OriginalSource), x => x.Focusable, x => x.DataContext is ISelectableElement);

            if (vsender.Focusable && !_isDragging)
            {
                return;
            }

            if (_isMouseDown)
            {
                _isMouseDown = false;
            }
            if (_isDragging)
            {
                DragFinished(false);
                e.Handled = true;
            }
            Mouse.Capture(null);
        }
        private void SegmentButton_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index       = this.SelectedIndex;
            var listboxitem = this.ItemContainerGenerator.ContainerFromIndex(index) as FrameworkElement;
            var border      = MyVisualTreeHelper.FindChild <Border>(listboxitem, "PART_ItemBorder");

            if (border != null)
            {
                if (index == 0)
                {
                    border.CornerRadius = new CornerRadius(5, 0, 0, 5);
                }
                else if (index == this.Items.Count - 1)
                {
                    border.CornerRadius = new CornerRadius(0, 5, 5, 0);
                }
                else
                {
                    border.CornerRadius = new CornerRadius(0, 0, 0, 0);
                }
            }
        }
Beispiel #11
0
        private void DragFinished(bool cancelled)
        {
            Mouse.Capture(null);
            lock (_updaterLock)
            {
                if (_isDragging)
                {
                    if (cancelled == false)
                    {
                        var ui = (UIElement)MyVisualTreeHelper.GetParent <ContentPresenter>(_draggedDeviceVisual);
                        DynamicCanvas.SetTop(ui, _dragStartTop + _overlayElement.TopOffset);
                        DynamicCanvas.SetLeft(ui, _dragStartLeft + _overlayElement.LeftOffset);
                    }

                    SelectElement(_draggedDeviceVisual);
                    _overlayElement.IsDragging = false;
                }

                _isDragging  = false;
                _isMouseDown = false;
            }
        }
Beispiel #12
0
        private void DrawingAreaPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var vsender = MyVisualTreeHelper.GetParent(((FrameworkElement)e.OriginalSource), x => x.Focusable, x => x.DataContext is ISelectableElement);

            if (vsender == null)
            {
                SelectElement(null);
                return;
            }

            if (vsender.Focusable)
            {
                return;
            }
            var canvas = MyVisualTreeHelper.GetParent <ItemsControl>((FrameworkElement)e.Source);

            _isMouseDown         = true;
            _dragStartPoint      = e.GetPosition(canvas);
            _draggedDeviceVisual = vsender;
            SelectElement(vsender);
            canvas.CaptureMouse();
            e.Handled = true;
        }