Example #1
0
 public virtual void DeepCopy(IDeepCopyable source, ICopyManager copyManager)
 {
   GridLength gl = (GridLength) source;
   _unitType = gl._unitType;
   _value = gl._value;
   _finalValue = gl._finalValue;
 }
Example #2
0
		public static void AddRowDef(this Grid grid, double size = 1, GridUnitType type = GridUnitType.Star, int count = 1)
		{
			for (int i = 0; i < count; i++) {
				grid.RowDefinitions.Add(new RowDefinition() {
					Height = new GridLength(size, type)
				});
			}
		}
Example #3
0
		public static void AddColumnDef(this Grid grid, double size = 1, GridUnitType type = GridUnitType.Star, int count = 1)
		{
			for (int i = 0; i < count; i++) {
				grid.ColumnDefinitions.Add(new ColumnDefinition() {
					Width = new GridLength(size, type)
				});
			}
		}
Example #4
0
 public static ColumnDefinition AddColumn(this Grid grid, double width, GridUnitType unit = GridUnitType.Pixel)
 {
     var column = new ColumnDefinition
     {
         Width = new GridLength(width, unit)
     };
     grid.ColumnDefinitions.Add(column);
     return column;
 }
Example #5
0
 public static RowDefinition AddRow(this Grid grid, double height, GridUnitType unit = GridUnitType.Pixel)
 {
     var row = new RowDefinition
     {
         Height = new GridLength(height, unit)
     };
     grid.RowDefinitions.Add(row);
     return row;
 }
Example #6
0
		public GridLength(double value, GridUnitType type)
		{
			if (value < 0 || double.IsNaN(value))
				throw new ArgumentException("value is less than 0 or is not a number", "value");
			if ((int)type < (int)GridUnitType.Absolute || (int)type > (int)GridUnitType.Auto)
				throw new ArgumentException("type is not a valid GridUnitType", "type");

			Value = value;
			GridUnitType = type;
		}
Example #7
0
		public GridLength (double value, GridUnitType type)
		{
			if ((value < 0.0d) || Double.IsNaN (value) || Double.IsInfinity (value))
				throw new ArgumentException ("Invalid value", "value");
			if ((type < GridUnitType.Auto) || (type > GridUnitType.Star))
				throw new ArgumentException ("Invalid value", "type");

			val = value;
			this.type = type;
		}
        void SetGridLengthUnit(GridUnitType unit, DesignItem item, DependencyProperty property)
        {
            DesignItemProperty itemProperty = item.Properties[property];
            GridLength         oldValue     = (GridLength)itemProperty.ValueOnInstance;
            GridLength         value        = GetNewGridLength(unit, oldValue);

            if (value != oldValue)
            {
                itemProperty.SetValue(value);
            }
        }
Example #9
0
        private void SetAllColumnWidths(int length, GridUnitType defaultType)
        {
            this.ColumnDefaultSize = new GridLength(length, defaultType);

            for (int i = 1; i < this.gridLayout.ColumnDefinitions.Count; i++)
            {
                this.ColumnWidthsCollection[i] = this.ColumnDefaultSize;
                this.ColumnHeaderTextBlockCollection[i - 1].Text = this.ParseGridLength(this.ColumnDefaultSize);
            }

            this.txtColumnSize.Text = string.Empty;
        }
Example #10
0
            public static RowDefinitionCollection Rows(GridUnitType Unit, params double[] Heights)
            {
                RowDefinitionCollection Return = new RowDefinitionCollection();

                foreach (int Height in Heights)
                {
                    Return.Add(new RowDefinition {
                        Height = new GridLength(Height, Unit)
                    });
                }
                return(Return);
            }
Example #11
0
            public static ColumnDefinitionCollection Columns(GridUnitType Unit, params double[] Widths)
            {
                ColumnDefinitionCollection Return = new ColumnDefinitionCollection();

                foreach (int Width in Widths)
                {
                    Return.Add(new ColumnDefinition {
                        Width = new GridLength(Width, Unit)
                    });
                }
                return(Return);
            }
Example #12
0
        private void SetAllRowsHeights(int height, GridUnitType defaultType)
        {
            this.RowDefaultSize = new GridLength(height, defaultType);

            for (int i = 1; i < this.gridLayout.RowDefinitions.Count; i++)
            {
                this.RowHeightsCollection[i] = this.RowDefaultSize;
                this.RowHeaderTextBlockCollection[i - 1].Text = this.ParseGridLength(this.RowDefaultSize);
            }

            this.txtRowSize.Text = string.Empty;
        }
 public void SetFirstPanelSize(double value, GridUnitType type)
 {
     if (_orientation == Orientation.Vertical)
     {
         var col = ColumnDefinitions[0];
         col.Width = new GridLength(value, type);
     }
     else
     {
         var row = RowDefinitions[0];
         row.Height = new GridLength(value, type);
     }
 }
Example #14
0
        static public string GetDefinitionString(this GridUnitType item, double value)
        {
            switch (item)
            {
            case GridUnitType.Auto: return("auto");

            case GridUnitType.Star: return("*".PrependIf(value != 1.0, value.ToString()));

            case GridUnitType.Pixel: return(value + "px");
            }

            throw new UnaccountedBranchException("item", item);
        }
Example #15
0
        static public string GetDefinitionString(this GridUnitType item)
        {
            switch (item)
            {
            case GridUnitType.Auto: return("auto");

            case GridUnitType.Star: return("*");

            case GridUnitType.Pixel: return("px");
            }

            throw new UnaccountedBranchException("item", item);
        }
Example #16
0
        public GridLength(double value, GridUnitType gridUnitType)
        {
            if (double.IsNaN(value) || double.IsInfinity(value) || value < 0.0 ||
                (gridUnitType != GridUnitType.Auto &&
                 gridUnitType != GridUnitType.Pixel &&
                 gridUnitType != GridUnitType.Star))
            {
                throw new ArgumentException($"Invalid GridLength {value}{gridUnitType}.", nameof(value));
            }

            Value        = (gridUnitType == GridUnitType.Auto) ? 1.0 : value;
            GridUnitType = gridUnitType;
        }
Example #17
0
        private static GridLength GetGridLength(GridUnitType type)
        {
            switch (type)
            {
            case GridUnitType.Auto:
                return(GridLength.Auto);

            case GridUnitType.Pixel:
            case GridUnitType.Star:
            default:
                return(new GridLength(1, type));
            }
        }
Example #18
0
 public void AddColumnDefinition(
     float value,
     GridUnitType unit = GridUnitType.Pixel
     )
 {
     Grid.AddDefinition(
         ref this._coldefs,
         ref this._coldefCount,
         new GridLength
     {
         Value  = value,
         IsStar = unit == GridUnitType.Star
     });
 }
Example #19
0
        public GridLength(double value, GridUnitType type)
        {
            if (Double.IsNaN(value) || Double.IsInfinity(value) || value < 0.0)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, "value");
            }
            if (type != GridUnitType.Auto && type != GridUnitType.Pixel && type != GridUnitType.Star)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, "type");
            }

            _unitValue = (type == GridUnitType.Auto) ? Default : value;
            _unitType  = type;
        }
Example #20
0
        public GridLength(double value, GridUnitType type)
        {
            if ((value < 0.0d) || Double.IsNaN(value) || Double.IsInfinity(value))
            {
                throw new ArgumentException("Invalid value", "value");
            }
            if ((type < GridUnitType.Auto) || (type > GridUnitType.Star))
            {
                throw new ArgumentException("Invalid value", "type");
            }

            val       = value;
            this.type = type;
        }
Example #21
0
        public GridLength(double value, GridUnitType type)
        {
            if (value < 0 || double.IsNaN(value))
            {
                throw new ArgumentException("value is less than 0 or is not a number", "value");
            }
            if ((int)type < (int)GridUnitType.Absolute || (int)type > (int)GridUnitType.Auto)
            {
                throw new ArgumentException("type is not a valid GridUnitType", "type");
            }

            Value        = value;
            GridUnitType = type;
        }
Example #22
0
        public GridLength(double value, GridUnitType type)
        {
            if (!IsFinite(value) || value < 0.0)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, nameof(value));
            }
            if (type != GridUnitType.Auto && type != GridUnitType.Pixel && type != GridUnitType.Star)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, nameof(type));
            }

            _unitValue = (type == GridUnitType.Auto) ? Default : value;
            _unitType  = type;
        }
Example #23
0
        public async void ToString_AllCulture_Should_Pass(double d, GridUnitType type, string result)
        {
            List <CultureInfo> cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList();
            GridLength         length       = new GridLength(d, type);

            foreach (var culture in cultureInfos)
            {
                await Task.Run(() =>
                {
                    CultureInfo.CurrentCulture = culture;
                    Assert.Equal(result, length.ToString());
                });
            }
        }
Example #24
0
        public GridLength(double value, GridUnitType type)
        {
            if (Double.IsNaN(value) || Double.IsInfinity(value) || value < 0.0)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, "value");
            }
            if (type != GridUnitType.Auto && type != GridUnitType.Pixel && type != GridUnitType.Star)
            {
                throw new ArgumentException(SR.DirectUI_InvalidArgument, "type");
            }

            _unitValue = (type == GridUnitType.Auto) ? Default : value;
            _unitType = type;
        }
Example #25
0
        private void animateColumn(GridLength from, GridLength to, GridUnitType unit, FrameworkContentElement element)
        {
            GridLengthAnimation gridLengthAnim = new GridLengthAnimation();

            gridLengthAnim.GridUnitType = unit;//GridUnitType.Pixel;
            gridLengthAnim.From         = from;
            gridLengthAnim.To           = to;
            gridLengthAnim.Duration     = new Duration(new TimeSpan(0, 0, 0, 0, 250));
            Storyboard.SetTargetName(gridLengthAnim, element.Name);
            Storyboard.SetTargetProperty(gridLengthAnim, new PropertyPath("Width"));
            Storyboard board = new Storyboard();

            board.Children.Add(gridLengthAnim);
            board.Begin(this);
        }
Example #26
0
 private void CreateColumnsAndRows(bool isColumn, int length, GridUnitType type)
 {
     if (isColumn)
     {
         _grid.ColumnDefinitions.Add(new ColumnDefinition {
             Width = new GridLength(length, type)
         });
     }
     else
     {
         _grid.RowDefinitions.Add(new RowDefinition {
             Height = new GridLength(length, type)
         });
     }
 }
Example #27
0
        public GridLength(float value, GridUnitType gridUnitType)
        {
            if (float.IsNaN(value))
            {
                throw new ArgumentException();
            }

            if (float.IsInfinity(value))
            {
                throw new ArgumentException();
            }

            this.value        = gridUnitType == GridUnitType.Auto ? 1 : value;
            this.gridUnitType = gridUnitType;
        }
Example #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GridLength" /> struct.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="type">The type.</param>
        /// <exception cref="System.ArgumentException">Invalid Parameter No NaN</exception>
        public GridLength(float value, GridUnitType type)
        {
            if (float.IsNaN(value))
            {
                throw new ArgumentException("InvalidParameterNoNaN");
            }

            if (double.IsInfinity(value))
            {
                throw new ArgumentException("InvalidParameterNoInfinity");
            }

            this.value = (type == GridUnitType.Auto) ? 0f : value;
            this.type  = type;
        }
Example #29
0
        public GridLength(double value, GridUnitType gridUnitType)
        {
            if (double.IsNaN(value))
            {
                throw new ArgumentException();
            }

            if (double.IsInfinity(value))
            {
                throw new ArgumentException();
            }

            this.value = gridUnitType == GridUnitType.Auto ? 1 : value;
            this.gridUnitType = gridUnitType;
        }
Example #30
0
 public void SetWidths(GridUnitType type, params int[] values)
 {
     for (int i = 0; i < values.Length; i++)
     {
         if (ColumnDefinitions.Count <= i)
         {
             ColumnDefinitions.Add(new ColumnDefinition());
         }
         int w = values[i];
         if (w > 0)
         {
             ColumnDefinitions[i].Width = new GridLength(w, type);
         }
     }
 }
Example #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GridLength"/> struct.
        /// </summary>
        /// <param name="value">The size of the GridLength.</param>
        /// <param name="type">The unit of the GridLength.</param>
        public GridLength(double value, GridUnitType type)
        {
            if (value < 0 || double.IsNaN(value) || double.IsInfinity(value))
            {
                throw new ArgumentException("Invalid value", "value");
            }

            if (type < GridUnitType.Auto || type > GridUnitType.Star)
            {
                throw new ArgumentException("Invalid value", "type");
            }

            _type  = type;
            _value = value;
        }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GridLength"/> struct.
        /// </summary>
        /// <param name="value">The size of the GridLength.</param>
        /// <param name="type">The unit of the GridLength.</param>
        public GridLength(double value, GridUnitType type = GridUnitType.Pixel)
        {
            if (value < 0 || double.IsNaN(value) || double.IsInfinity(value))
            {
                throw new ArgumentException("Invalid value", nameof(value));
            }

            if (type < GridUnitType.Auto || type > GridUnitType.Star)
            {
                throw new ArgumentException("Invalid value", nameof(type));
            }

            this.type  = type;
            this.value = value;
        }
Example #33
0
 public void SetHeights(GridUnitType type, params int[] values)
 {
     for (int i = 0; i < values.Length; i++)
     {
         if (RowDefinitions.Count <= i)
         {
             RowDefinitions.Add(new RowDefinition());
         }
         int w = values[i];
         if (w > 0)
         {
             RowDefinitions[i].Height = new GridLength(w, type);
         }
     }
 }
Example #34
0
 public GridLength(float value, GridUnitType type)
 {
     if (float.IsNaN(value))
     {
         throw new ArgumentException("Invalid GridLength NaN value");
     }
     if (float.IsInfinity(value))
     {
         throw new ArgumentException("Invalid GridLength Infinity value");
     }
     if (type != GridUnitType.Auto && type != GridUnitType.Pixel && type != GridUnitType.Star)
     {
         throw new ArgumentException("Invalid GridLength unit type");
     }
     this._type  = type;
     this._value = type == GridUnitType.Auto ? 0.0f : value;
 }
Example #35
0
 /// <summary>
 /// Initializes a new instance of the GridLength structure and specifies what kind of value it holds.
 /// </summary>
 /// <param name="value"> The initial value of this instance of GridLength. </param>
 /// <param name="type"> The GridUnitType held by this instance of GridLength. </param>
 /// <exception cref="System.ArgumentException">Pixels is equal to float.NegativeInfinity, float.PositiveInfinity, or float.NaN </exception>
 public GridLength(float value, GridUnitType type)
 {
     if (float.IsNaN(value))
     {
         throw new ArgumentException("Invalid constructor parameter (value is NaN)");
     }
     if (float.IsInfinity(value))
     {
         throw new ArgumentException("Invalid constructor parameter (value is Infinity)");
     }
     if (((type != GridUnitType.Auto) && (type != GridUnitType.Pixel)) && (type != GridUnitType.Star))
     {
         throw new ArgumentException("Invalid constructor parameter (Unknown GridUnitType)");
     }
     this._UnitValue = (type == GridUnitType.Auto) ? 0.0f : value;
     this._UnitType  = type;
 }
Example #36
0
        private void GetOrCreateEditorControl(string editorName)
        {
            if (string.IsNullOrEmpty(editorName))
            {
                CurrentEditor = null;
            }
            else
            {
                if (!m_loadedEditors.ContainsKey(editorName))
                {
                    Control newControl = InitialiseEditorControl(editorName);
                    Grid.SetRow(newControl, 1);
                    grid.Children.Add(newControl);

                    CurrentEditor = newControl;

                    m_loadedEditors.Add(editorName, newControl);
                }
                else
                {
                    CurrentEditor = m_loadedEditors[editorName];
                }

                if (CurrentEditor != null)
                {
                    GridUnitType controlRowGridUnit = GridUnitType.Auto;

                    if (CurrentElementEditor != null)
                    {
                        CurrentElementEditor.Helper.DoInitialise(m_controller, m_definition);
                        CurrentElementEditor.Populate(m_data);
                        if (CurrentElementEditor.Helper.Options.Resizable || m_definition.Expand)
                        {
                            controlRowGridUnit = GridUnitType.Star;
                        }
                    }

                    CurrentEditor.Visibility = Visibility.Visible;
                    controlRow.Height        = new GridLength(1, controlRowGridUnit);
                }
            }

            HideOtherEditors();
            SetEditorAttributes();
        }
        public static Grid CreateGrid(int columns, int rows, GridUnitType columnType, GridUnitType rowType)
        {
            Grid grid = new Grid();

            for (int i = 0; i < columns; i++)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(1, columnType);
                grid.ColumnDefinitions.Add(col);
            }
            for (int i = 0; i < rows; i++)
            {
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(1, rowType);
                grid.RowDefinitions.Add(row);
            }
            return(grid);
        }
Example #38
0
        // Token: 0x0600072A RID: 1834 RVA: 0x00016B3C File Offset: 0x00014D3C
        internal static string ToString(GridLength gl, CultureInfo cultureInfo)
        {
            GridUnitType gridUnitType = gl.GridUnitType;

            if (gridUnitType == GridUnitType.Auto)
            {
                return("Auto");
            }
            if (gridUnitType != GridUnitType.Star)
            {
                return(Convert.ToString(gl.Value, cultureInfo));
            }
            if (!DoubleUtil.IsOne(gl.Value))
            {
                return(Convert.ToString(gl.Value, cultureInfo) + "*");
            }
            return("*");
        }
Example #39
0
        public void SetGridLengthUnit(GridUnitType unit)
        {
            DesignItem item = unitSelector.SelectedItem;

            grid.UpdateLayout();

            Debug.Assert(item != null);

            if (orientation == Orientation.Vertical)
            {
                SetGridLengthUnit(unit, item, RowDefinition.HeightProperty);
            }
            else
            {
                SetGridLengthUnit(unit, item, ColumnDefinition.WidthProperty);
            }
            grid.UpdateLayout();
            InvalidateVisual();
        }
Example #40
0
 private void setPaddingSpacers(int gridUnitValue, GridUnitType gridUnitType)
 {
     mGrid.ColumnDefinitions[0].Width = new GridLength(gridUnitValue, gridUnitType);
     mGrid.ColumnDefinitions[mGrid.ColumnDefinitions.Count - 1].Width = new GridLength(gridUnitValue, gridUnitType);
 }
Example #41
0
 public GridLength(GridUnitType unitType, double value)
 {
   _unitType = unitType;
   _value = value;
 }
Example #42
0
 public GridLength()
 {
   _unitType = GridUnitType.Auto;
 }
Example #43
0
 public GridLength(double value)
 {
   _unitType = GridUnitType.Pixel;
   _value = value;
 }
Example #44
0
 public Segment(double offeredSize, double min, double max, GridUnitType type)
 {
     OriginalSize = 0;
     Min = min;
     Max = max;
     DesiredSize = 0;
     OfferedSize = offeredSize;
     Stars = 0;
     Type = type;
 }
Example #45
0
        private void AssignSize(
            Segment[,] matrix,
            int start,
            int end,
            ref double size,
            GridUnitType type,
            bool desiredSize)
        {
            double count = 0;
            bool assigned;

            // Count how many segments are of the correct type. If we're measuring Star rows/cols
            // we need to count the number of stars instead.
            for (int i = start; i <= end; i++)
            {
                double segmentSize = desiredSize ? matrix[i, i].DesiredSize : matrix[i, i].OfferedSize;
                if (segmentSize < matrix[i, i].Max)
                {
                    count += type == GridUnitType.Star ? matrix[i, i].Stars : 1;
                }
            }

            do
            {
                double contribution = size / count;

                assigned = false;

                for (int i = start; i <= end; i++)
                {
                    double segmentSize = desiredSize ? matrix[i, i].DesiredSize : matrix[i, i].OfferedSize;

                    if (!(matrix[i, i].Type == type && segmentSize < matrix[i, i].Max))
                    {
                        continue;
                    }

                    double newsize = segmentSize;
                    newsize += contribution * (type == GridUnitType.Star ? matrix[i, i].Stars : 1);
                    newsize = Math.Min(newsize, matrix[i, i].Max);
                    assigned |= newsize > segmentSize;
                    size -= newsize - segmentSize;

                    if (desiredSize)
                    {
                        matrix[i, i].DesiredSize = newsize;
                    }
                    else
                    {
                        matrix[i, i].OfferedSize = newsize;
                    }
                }
            }
            while (assigned);
        }
Example #46
0
 private GridLength(GridUnitType gridUnitType, double value)
 {
     this.GridUnitType = gridUnitType;
     this.Value = value;
 }
Example #47
0
 public ColumnDefinition(double value, GridUnitType type)
 {
     this.Width = new GridLength(value, type);
 }
Example #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RowDefinition"/> class.
 /// </summary>
 /// <param name="value">The height of the row.</param>
 /// <param name="type">The height unit of the column.</param>
 public RowDefinition(double value, GridUnitType type)
 {
     Height = new GridLength(value, type);
 }
Example #49
0
		GridLength GetNewGridLength(GridUnitType unit, GridLength oldValue)
		{
			if (unit == GridUnitType.Auto) {
				return GridLength.Auto;
			}
			return new GridLength(oldValue.Value, unit);
		}
            //Sets all the inter widget spacers to 0, star or auto
            private void setSpacers(int gridUnitValue, GridUnitType gridUnitType)
            {
                if (0 != mGrid.RowDefinitions[1].Height.Value || false == mGrid.RowDefinitions[1].Height.IsAbsolute)
                    mGrid.RowDefinitions[1].Height = new GridLength(0, GridUnitType.Pixel);
                if (0 != mGrid.RowDefinitions[mGrid.RowDefinitions.Count - 2].Height.Value || false == mGrid.RowDefinitions[mGrid.RowDefinitions.Count - 2].Height.IsAbsolute)
                    mGrid.RowDefinitions[mGrid.RowDefinitions.Count - 2].Height = new GridLength(0, GridUnitType.Pixel);

                int step = 0;

                for (int i = 3; i < mGrid.RowDefinitions.Count - 2; i++)
                {
                    step++;
                    if (2 >= step)
                    {
                        mGrid.RowDefinitions[i].Height = new GridLength(gridUnitValue, gridUnitType);
                    }
                    else step = 0;
                }
            }
            /**
             * AddChild function override
             * @param child IWidget the "child" widget that needs to be added
             */
            public override void AddChild(IWidget child)
            {
                base.AddChild(child);
                MoSync.Util.RunActionOnMainThreadSync(() =>
                {
                    WidgetBaseWindowsPhone widget = (child as WidgetBaseWindowsPhone);
                    RowDefinition rowDef = new RowDefinition(); //The row definition for the widget

                    //In order to be able to set various properties on the layout
                    //there appeared the need for two spacers, top spacer, and
                    //bottom spacer. For each widget one of each would be added
                    //to the layout.

                    RowDefinition upperSpacerRowDef = new RowDefinition(); //The row definition for the upper spacer
                    RowDefinition bottomSpacerRowDef = new RowDefinition(); //The row definition for the bottom spacer

                    if (widget.fillSpaceVerticalyEnabled) //FillSpaceVerticaly
                    {
                        //Check if the paddings are not set by the user
                        if (false == mPaddingSetByUser)
                        {
                            setPaddingSpacers(0, GridUnitType.Pixel);
                        }
                        else
                        {
                            setPaddingSpacers(1, GridUnitType.Auto);
                        }
                        rowDef.Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
                        mGridUnitType = GridUnitType.Pixel;
                        mGridUnitTypeValue = 0;
                    }
                    else if(double.IsNaN( widget.Height ) == false) //Absolute value
                    {
                        rowDef.Height = new System.Windows.GridLength(widget.Height, System.Windows.GridUnitType.Pixel);
                    }
                    else //Wrap content as default
                    {
                        //Check if the paddings are not set by the user
                        if (false == mPaddingSetByUser)
                        {
                            setPaddingSpacers(0, GridUnitType.Pixel);
                        }
                        rowDef.Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Auto);
                        mGridUnitType = GridUnitType.Pixel;
                        mGridUnitTypeValue = 0;
                    }

                    mGrid.RowDefinitions.Insert(mGrid.RowDefinitions.Count - 1, upperSpacerRowDef);
                    mGrid.RowDefinitions.Insert(mGrid.RowDefinitions.Count - 1, rowDef);
                    mGrid.RowDefinitions.Insert(mGrid.RowDefinitions.Count - 1, bottomSpacerRowDef);

                    Grid.SetColumn((widget.View as System.Windows.FrameworkElement), 1);
                    Grid.SetRow((widget.View as System.Windows.FrameworkElement), mGrid.RowDefinitions.Count - 3);

                    if (widget.View is FrameworkElement)
                    {
                        (widget.View as FrameworkElement).HorizontalAlignment = this.mGrid.HorizontalAlignment;
                        (widget.View as FrameworkElement).VerticalAlignment = this.mGrid.VerticalAlignment;
                    }
                    mGrid.Children.Add(widget.View);

                    setSpacers(mGridUnitTypeValue, mGridUnitType);
                });
            }
Example #52
0
		public void SetGridLengthUnit(GridUnitType unit)
		{
			DesignItem item = unitSelector.SelectedItem;
			grid.UpdateLayout();
			
			Debug.Assert(item != null);
			
			if (orientation == Orientation.Vertical) {
				SetGridLengthUnit(unit, item, RowDefinition.HeightProperty);
			} else {
				SetGridLengthUnit(unit, item, ColumnDefinition.WidthProperty);
			}
			grid.UpdateLayout();
			InvalidateVisual();
		}
Example #53
0
		void SetGridLengthUnit(GridUnitType unit, DesignItem item, DependencyProperty property)
		{
			DesignItemProperty itemProperty = item.Properties[property];
			GridLength oldValue = (GridLength)itemProperty.ValueOnInstance;
			GridLength value = GetNewGridLength(unit, oldValue);
			
			if (value != oldValue) {
				itemProperty.SetValue(value);
			}
		}
Example #54
0
 public GridLength( GridUnitType unitType, int value ) {
     this.gridUnitType = unitType;
     this.value = value;
 }
 private void setPaddingSpacers(int gridUnitValue, GridUnitType gridUnitType)
 {
     mGrid.RowDefinitions[0].Height = new GridLength(gridUnitValue, gridUnitType);
     mGrid.RowDefinitions[mGrid.RowDefinitions.Count - 1].Height = new GridLength(gridUnitValue, gridUnitType);
 }
Example #56
0
        // Parse a GridLength from a string given the CultureInfo.
        static internal void FromString(
                string       s, 
                CultureInfo  cultureInfo,
            out double       value,
            out GridUnitType unit)
        {
            string goodString = s.Trim().ToLowerInvariant();

            value = 0.0;
            unit = GridUnitType.Pixel;

            int i;
            int strLen = goodString.Length;
            int strLenUnit = 0;
            double unitFactor = 1.0;

            //  this is where we would handle trailing whitespace on the input string.
            //  peel [unit] off the end of the string
            i = 0;

            if (goodString == UnitStrings[i])
            {
                strLenUnit = UnitStrings[i].Length;
                unit = (GridUnitType)i;
            }
            else
            {
                for (i = 1; i < UnitStrings.Length; ++i)
                {
                    //  Note: this is NOT a culture specific comparison.
                    //  this is by design: we want the same unit string table to work across all cultures.
                    if (goodString.EndsWith(UnitStrings[i], StringComparison.Ordinal))
                    {
                        strLenUnit = UnitStrings[i].Length;
                        unit = (GridUnitType)i;
                        break;
                    }
                }
            }

            //  we couldn't match a real unit from GridUnitTypes.
            //  try again with a converter-only unit (a pixel equivalent).
            if (i >= UnitStrings.Length)
            {
                for (i = 0; i < PixelUnitStrings.Length; ++i)
                {
                    //  Note: this is NOT a culture specific comparison.
                    //  this is by design: we want the same unit string table to work across all cultures.
                    if (goodString.EndsWith(PixelUnitStrings[i], StringComparison.Ordinal))
                    {
                        strLenUnit = PixelUnitStrings[i].Length;
                        unitFactor = PixelUnitFactors[i];
                        break;
                    }
                }
            }

            //  this is where we would handle leading whitespace on the input string.
            //  this is also where we would handle whitespace between [value] and [unit].
            //  check if we don't have a [value].  This is acceptable for certain UnitTypes.
            if (    strLen == strLenUnit 
                &&  (   unit == GridUnitType.Auto
                    ||  unit == GridUnitType.Star   )   )
            {
                value = 1;
            }
            //  we have a value to parse.
            else
            {
                Debug.Assert(   unit == GridUnitType.Pixel 
                            ||  DoubleUtil.AreClose(unitFactor, 1.0)    );

                string valueString = goodString.Substring(0, strLen - strLenUnit);
                value = Convert.ToDouble(valueString, cultureInfo) * unitFactor;
            }
        }
Example #57
0
        static ConvertibleKind GridUnitTypeToConvertibleKind(GridUnitType type)
        {
            Contract.Requires((int)type >= GridUnitType_First);
            Contract.Requires((int)type <= GridUnitType_Last);
            Contract.Ensures((int)Contract.Result<ConvertibleKind>() >= ConvertibleKind_GridUnitFirst);
            Contract.Ensures((int)Contract.Result<ConvertibleKind>() <= ConvertibleKind_GridUnitLast);

            return (ConvertibleKind)((int)type - GridUnitType_First + ConvertibleKind_GridUnitFirst);
        }
            /**
             * The constructor
             */
            public VerticalLayout()
            {
                mGrid = new System.Windows.Controls.Grid();

                mColDef = new ColumnDefinition();
                mSpacerUp = new RowDefinition();
                mSpacerDown = new RowDefinition();

                mSpacerRight = new ColumnDefinition();
                mSpacerLeft = new ColumnDefinition();

                mColDef.Width = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);

                mSpacerUp.Height = new System.Windows.GridLength(0);
                mSpacerDown.Height = new System.Windows.GridLength(0);
                mSpacerRight.Width = new System.Windows.GridLength(0);
                mSpacerLeft.Width = new System.Windows.GridLength(0);

                mGrid.RowDefinitions.Add(mSpacerUp);
                mGrid.RowDefinitions.Add(mSpacerDown);

                mGrid.ColumnDefinitions.Add(mSpacerLeft);
                mGrid.ColumnDefinitions.Add(mColDef);
                mGrid.ColumnDefinitions.Add(mSpacerRight);

                this.fillSpaceVerticalyEnabled = false;
                this.fillSpaceHorizontalyEnabled = false;

                mGridUnitType = GridUnitType.Auto;
                mGridUnitTypeValue = 1;

                mPaddingSetByUser = false;

                mView = mGrid;

                mGrid.Margin = new Thickness(0.0);
                //#if DEBUG
                //                mGrid.ShowGridLines = true;
                //#endif
            }
Example #59
0
 public GridLength(GridUnitType unit)
 {
   _value = 0;
   _unit = unit;
 }
Example #60
0
 public void Init(double offeredSize, double min, double max, GridUnitType type)
 {
     OfferedSize = offeredSize;
     Min = min;
     Max = max;
     Type = type;
 }