Ejemplo n.º 1
0
 public DeviceContainer(Device device, LampControl deviceElement)
 {
     State             = ContainerState.Entering;
     Device            = device;
     DeviceElement     = deviceElement;
     DeviceVisual      = ElementCompositionPreview.GetElementVisual(DeviceElement);
     OffsetDestination = Vector3.Zero;
 }
Ejemplo n.º 2
0
        private void Element_AssetLoadComplete(LampControl element)
        {
            element.AssetLoadComplete -= Element_AssetLoadComplete;

            var container = GetContainer(element);

            container.State = ContainerState.Entering;

            UpdateLayoutBounds(UpdateDeviceContainerAnimMode.Enter);

            int index = _containers.IndexOf(container);

            UpdateDeviceContainers(UpdateDeviceContainerAnimMode.Enter);

            if (_disableAnimations)
            {
                container.DeviceVisual.Offset  = new Vector3(container.OffsetDestination.X, container.OffsetDestination.Y, 0f);
                container.DeviceVisual.Opacity = 1f;
                container.DeviceElement.SetValue(Canvas.ZIndexProperty, 101);
                container.State = ContainerState.Normal;
            }
            else
            {
                float containerOffsetY = _layoutHeight - element.LayoutSize.Y + _layoutOrigin.Y;
                container.DeviceVisual.Offset  = new Vector3(_layoutOrigin.X + index * (_deviceSpacing + _deviceWidth), containerOffsetY, _introZOrigin);
                container.DeviceVisual.Opacity = 0f;

                var compositor = Window.Current.Compositor;

                container.AnimBatch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

                var introOffsetAnim = compositor.CreateVector3KeyFrameAnimation();
                introOffsetAnim.InsertKeyFrame(1f, new Vector3(container.OffsetDestination.X, container.OffsetDestination.Y, 0f), _introAnimEasing);
                introOffsetAnim.Duration = _introAnimDuration;
                var introOpacityAnim = compositor.CreateScalarKeyFrameAnimation();
                introOpacityAnim.InsertKeyFrame(1f, 1f, _introAnimEasing);
                introOpacityAnim.Duration = _introAnimDuration;

                container.DeviceVisual.StartAnimation("Offset", introOffsetAnim);
                container.DeviceVisual.StartAnimation("Opacity", introOpacityAnim);

                container.AnimBatch.Completed += EnterAnimBatch_Completed;
                container.AnimBatch.End();
            }

            element.Visibility = Visibility.Visible;
        }
Ejemplo n.º 3
0
        private void AddNewContainer(Device device)
        {
            LampControl element = new LampControl();

            element.Width = _deviceWidth;
            element.SetValue(Canvas.ZIndexProperty, 2);
            element.LayoutSizeUpdated += Element_LayoutSizeUpdated;
            element.AssetLoadComplete += Element_AssetLoadComplete;
            element.Visibility         = Visibility.Collapsed;
            var container = new DeviceContainer(device, element);

            container.State = ContainerState.Loading;

            _containers.Add(container);
            _containers.Sort((a, b) => a.Device.CompareTo(b.Device));

            element.Device = device;
            LayoutContainer.Children.Add(element);

            element.InitializeComp();
        }
Ejemplo n.º 4
0
 private void Element_LayoutSizeUpdated(LampControl source, Vector2 layoutSize)
 {
     UpdateLayoutBounds(UpdateDeviceContainerAnimMode.Normal);
     UpdateDeviceContainers(UpdateDeviceContainerAnimMode.Normal);
 }
Ejemplo n.º 5
0
 private DeviceContainer GetContainer(LampControl control)
 {
     return(_containers.FirstOrDefault((a) => a.DeviceElement == control));
 }