コード例 #1
0
ファイル: RelativeCanvas.cs プロジェクト: EbrahimBGA/Glass
        private void UpdateChildLocationsAfterSizeChange(SizeInfo newSizeInfo)
        {
            foreach (UIElement uiElement in Children)
            {
                if (newSizeInfo.WidthChanged)
                {
                    var relativeX = (double)uiElement.GetValue(HorizontalProportionProperty);

                    if (!double.IsInfinity(relativeX))
                    {
                        var newX = relativeX * newSizeInfo.Size.Width;
                        SetLeftOfRelativePoint(uiElement, newX);
                    }
                }

                if (newSizeInfo.HeightChanged)
                {
                    var relativeY = (double)uiElement.GetValue(VerticalProportionProperty);

                    if (!double.IsInfinity(relativeY))
                    {
                        var newY = relativeY * newSizeInfo.Size.Height;
                        SetTopOfRelativePoint(uiElement, newY);
                    }
                }
            }
        }
コード例 #2
0
        void OnLoaded(object sender, RoutedEventArgs e) {


            if (firstLoad) {
                foreach (UIElement child in Children) {
                    UpdateHorizontalProportions(child);
                    UpdateVerticalProportions(child);
                }
                firstLoad = false;
            } else {
                var newSizeInfo = new SizeInfo(new Size(ActualWidth, ActualHeight)) { WidthChanged = true, HeightChanged = true };
                UpdateChildLocationsAfterSizeChange(newSizeInfo);
            }

            SizeChanged += OnSizeChanged;
        }
コード例 #3
0
ファイル: RelativeCanvas.cs プロジェクト: EbrahimBGA/Glass
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (firstLoad)
            {
                foreach (UIElement child in Children)
                {
                    UpdateHorizontalProportions(child);
                    UpdateVerticalProportions(child);
                }
                firstLoad = false;
            }
            else
            {
                var newSizeInfo = new SizeInfo(new Size(ActualWidth, ActualHeight))
                {
                    WidthChanged = true, HeightChanged = true
                };
                UpdateChildLocationsAfterSizeChange(newSizeInfo);
            }

            SizeChanged += OnSizeChanged;
        }
コード例 #4
0
        private void UpdateChildLocationsAfterSizeChange(SizeInfo newSizeInfo) {

            foreach (UIElement uiElement in Children) {

                if (newSizeInfo.WidthChanged) {
                    var relativeX = (double)uiElement.GetValue(HorizontalProportionProperty);

                    if (!double.IsInfinity(relativeX)) {
                        var newX = relativeX * newSizeInfo.Size.Width;
                        SetLeftOfRelativePoint(uiElement, newX);
                    }
                }

                if (newSizeInfo.HeightChanged) {
                    var relativeY = (double)uiElement.GetValue(VerticalProportionProperty);

                    if (!double.IsInfinity(relativeY)) {
                        var newY = relativeY * newSizeInfo.Size.Height;
                        SetTopOfRelativePoint(uiElement, newY);
                    }
                }
            }

        }