Esempio n. 1
0
        // Callback invoked when VectorHeight changes
        private static void onVectorHeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SharpDisplay   self       = (SharpDisplay)d;
            AdvancedLength new_height = (AdvancedLength)e.NewValue;

            if (self.IsLoaded)
            {
                updateActualVectorSize(self, self.VectorWidth, new_height);
            }
        }
Esempio n. 2
0
        // Recompute the Vector's ActualWidth and ActualSize base on current size conditions
        private static void updateActualVectorSize(SharpDisplay self, AdvancedLength new_width, AdvancedLength new_height)
        {
            self.VectorStretch = Stretch.Fill;
            if (new_width.Unit == AdvancedLength.UnitType.Auto || new_height.Unit == AdvancedLength.UnitType.Auto)
            {
                self.VectorStretch = Stretch.Uniform;
            }

            self.ActualVectorHeight = self.computeActualVectorSize(new_height, self.ActualHeight);
            self.ActualVectorWidth  = self.computeActualVectorSize(new_width, self.ActualWidth);
        }
Esempio n. 3
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof(string))
            {
                throw new Exception("Unable to convert an AdvancedLength object to " + destinationType + "!");
            }
            AdvancedLength len = (AdvancedLength)value;

            if (len == null)
            {
                return(null);
            }
            return(this.ToString());
        }
Esempio n. 4
0
        //This function should ONLY be invoked from updateVectorSize() (in  c# 7 this can be turned into a local function)
        private double computeActualVectorSize(AdvancedLength len, double container_len)
        {
            switch (len.Unit)
            {
            case AdvancedLength.UnitType.Auto:
                return(double.NaN);    //In Auto mode, we set the Vector width (or length) to NaN and let the Vector.Strech = Uniform take care of the ActualWidth(or length)

            case AdvancedLength.UnitType.Percent:
                return(len.Value * container_len / 100);

            case AdvancedLength.UnitType.Pixel:
                return(len.Value);

            case AdvancedLength.UnitType.Star:
                return(container_len);

            default:
                throw new InvalidEnumArgumentException("Unhandled value: " + len.Unit);
            }
        }