コード例 #1
0
        private void UpdateZoneRects()
        {
            UIElementCollection previewChildren = Preview.Children;
            int previewChildrenCount            = previewChildren.Count;

            while (previewChildrenCount < Model.Zones.Count)
            {
                CanvasZone zone = new CanvasZone();
                zone.Model = Model;
                Preview.Children.Add(zone);
                previewChildrenCount++;
            }

            for (int i = 0; i < previewChildrenCount; i++)
            {
                Int32Rect  rect = Model.Zones[i];
                CanvasZone zone = previewChildren[i] as CanvasZone;

                zone.ZoneIndex = i;
                Canvas.SetLeft(zone, rect.X);
                Canvas.SetTop(zone, rect.Y);
                zone.MinHeight = rect.Height;
                zone.MinWidth  = rect.Width;
            }
        }
コード例 #2
0
        private void UpdateZoneRects()
        {
            UIElementCollection previewChildren = Preview.Children;
            int previewChildrenCount            = previewChildren.Count;

            while (previewChildrenCount < _model.Zones.Count)
            {
                CanvasZone zone = new CanvasZone
                {
                    Model = _model,
                };
                Preview.Children.Add(zone);
                previewChildrenCount++;
            }

            while (previewChildrenCount > _model.Zones.Count)
            {
                Preview.Children.RemoveAt(previewChildrenCount - 1);
                previewChildrenCount--;
            }

            for (int i = 0; i < previewChildrenCount; i++)
            {
                Int32Rect  rect = _model.Zones[i];
                CanvasZone zone = previewChildren[i] as CanvasZone;

                zone.ZoneIndex = i;
                Canvas.SetLeft(zone, rect.X);
                Canvas.SetTop(zone, rect.Y);
                zone.Height          = rect.Height;
                zone.Width           = rect.Width;
                zone.LabelID.Content = i + 1;
            }
        }