Painter/Component/ScaleBorder.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Painter.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Painter.Component
{
    public class ScaleBorder : Border, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public static DependencyProperty ScaleProperty =
            DependencyProperty.Register("Scale", typeof(double), typeof(ScaleBorder), new PropertyMetadata(1.0));

        protected Point _current_point = new Point(0, 0);
        public int SliderValue
        {
            get { return (int)((double)GetValue(ScaleProperty) >= 1 ? (double)GetValue(ScaleProperty) : -1.0 / (double)GetValue(ScaleProperty)); }
        }
        public string SliderTextValue
        {
            get { return (double)GetValue(ScaleProperty) * 100 + "%"; }
        }
        public int Interval
        {
            get
            {
                if (Scale >= 2 && Scale <= 3) return 100 / 2;
                else if (Scale >= 4 && Scale <= 6) return 100 / 5;
                else if (Scale >= 7 && Scale <= 10) return 100 / 10;
                else return 100;
            }
        }
        public double Scale
        {
            get { return (double)GetValue(ScaleProperty); }
            set
            {
                SetValue(ScaleProperty, value);
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SliderValue"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SliderTextValue"));
                InvalidateVisual();
            }
        }
        public Point CurPos
        {
            get
            {
                GroupScroll content = Child as GroupScroll;
                Thickness margin = (content.Content as FrameworkElement)?.Margin ?? new Thickness(0);
                Point pos = _current_point;
                return new Point() {
                    X = Math.Floor((pos.X - BorderThickness.Top - margin.Top < 0 ? 0 : pos.X - BorderThickness.Top - margin.Top) / Scale),
后面还有 104 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。