示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineweight"></param>
        public Lineweight(netDxf.Lineweight lineweight)
        {
            DataContext             = this;
            Mode                    = LineweightMode.All;
            this.InitialLineweight  = lineweight;
            this.SelectedLineweight = lineweight;

            InitializeComponent();

            var propertypath = new PropertyPath(ListView.SelectedIndexProperty)
            {
                Path = "SelectedLineweight",
            };
            var converter = new LineweightConverter();
            var bind      = new Binding()
            {
                Path               = propertypath,
                Converter          = converter,
                ConverterParameter = "1",
            };

            Lineweights.SetBinding(ListView.SelectedIndexProperty, bind);

            OnPropertyChanged("SelectedLineweight");
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineweight"></param>
        /// <param name="mode"></param>
        public Lineweight(netDxf.Lineweight lineweight, LineweightMode mode)
        {
            DataContext = this;

            InitializeComponent();

            var propertypath = new PropertyPath(ListView.SelectedIndexProperty)
            {
                Path = "SelectedLineweight",
            };
            var     converter = new LineweightConverter();
            Binding bind;

            if (mode == LineweightMode.Layer)
            {
                Lineweights.Items.Remove(ByBlock);
                Lineweights.Items.Remove(ByLayer);

                bind = new Binding()
                {
                    Path               = propertypath,
                    Converter          = converter,
                    ConverterParameter = "4",
                };
            }
            else
            {
                bind = new Binding()
                {
                    Path               = propertypath,
                    Converter          = converter,
                    ConverterParameter = "1",
                };
            }

            Lineweights.SetBinding(ListView.SelectedIndexProperty, bind);

            Mode = mode;
            switch (mode)
            {
            case LineweightMode.All:
                this.InitialLineweight  = lineweight;
                this.SelectedLineweight = lineweight;
                break;

            case LineweightMode.Layer:

                if ((this.InitialLineweight == netDxf.Lineweight.ByBlock) || (this.InitialLineweight == netDxf.Lineweight.ByLayer))
                {
                    this.InitialLineweight  = netDxf.Lineweight.Default;
                    this.SelectedLineweight = netDxf.Lineweight.Default;
                }
                else
                {
                    this.InitialLineweight  = lineweight;
                    this.SelectedLineweight = lineweight;
                }
                break;
            }

            OnPropertyChanged("SelectedLineweight");
        }