Пример #1
0
        /// <inheritdoc />
        public override void AddChild(ProfileElement child, int?order = null)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException("Folder");
            }

            base.AddChild(child, order);
            CalculateRenderProperties();
        }
Пример #2
0
        /// <inheritdoc />
        public override void RemoveChild(ProfileElement child)
        {
            if (Disposed)
            {
                throw new ObjectDisposedException("Folder");
            }

            base.RemoveChild(child);
            CalculateRenderProperties();
        }
Пример #3
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="name">The name of the folder</param>
        public Folder(ProfileElement parent, string name) : base(parent.Profile)
        {
            FolderEntity = new FolderEntity();
            EntityId     = Guid.NewGuid();

            Parent  = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile = Parent.Profile;
            Name    = name;

            Parent.AddChild(this);
        }
Пример #4
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class based on the provided folder entity
        /// </summary>
        /// <param name="profile">The profile the folder belongs to</param>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="folderEntity">The entity of the folder</param>
        public Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity) : base(parent.Profile)
        {
            FolderEntity = folderEntity;
            EntityId     = folderEntity.Id;

            Profile = profile;
            Parent  = parent;
            Name    = folderEntity.Name;
            Enabled = folderEntity.Enabled;
            Order   = folderEntity.Order;

            Load();
        }
Пример #5
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Layer" /> class based on the provided layer entity
        /// </summary>
        /// <param name="profile">The profile the layer belongs to</param>
        /// <param name="parent">The parent of the layer</param>
        /// <param name="layerEntity">The entity of the layer</param>
        public Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity) : base(parent.Profile)
        {
            LayerEntity = layerEntity;
            EntityId    = layerEntity.Id;

            Profile    = profile;
            Parent     = parent;
            _general   = new LayerGeneralProperties();
            _transform = new LayerTransformProperties();

            _leds = new List <ArtemisLed>();

            Load();
            Initialize();
        }
Пример #6
0
        internal Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity)
        {
            LayerEntity = layerEntity;
            Profile     = profile;
            Parent      = parent;
            General     = new LayerGeneralProperties();
            Transform   = new LayerTransformProperties();

            _layerEffects           = new List <BaseLayerEffect>();
            _leds                   = new List <ArtemisLed>();
            _expandedPropertyGroups = new List <string>();

            Load();
            Initialize();
        }
Пример #7
0
        internal Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity)
        {
            FolderEntity = folderEntity;

            EntityId = folderEntity.Id;

            Profile = profile;
            Parent  = parent;
            Name    = folderEntity.Name;
            Enabled = folderEntity.Enabled;
            Order   = folderEntity.Order;

            _layerEffects           = new List <BaseLayerEffect>();
            _expandedPropertyGroups = new List <string>();
            Load();
        }
Пример #8
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Layer" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the layer</param>
        /// <param name="name">The name of the layer</param>
        public Layer(ProfileElement parent, string name) : base(parent.Profile)
        {
            LayerEntity = new LayerEntity();
            EntityId    = Guid.NewGuid();

            Parent     = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile    = Parent.Profile;
            Name       = name;
            Enabled    = true;
            _general   = new LayerGeneralProperties();
            _transform = new LayerTransformProperties();

            _leds = new List <ArtemisLed>();

            Initialize();
            Parent.AddChild(this, 0);
        }
Пример #9
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="name">The name of the folder</param>
        public Folder(ProfileElement parent, string name)
        {
            FolderEntity = new FolderEntity();
            EntityId     = Guid.NewGuid();

            Parent              = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile             = Parent.Profile;
            Name                = name;
            Enabled             = true;
            DisplayContinuously = true;

            _layerEffects           = new List <BaseLayerEffect>();
            _expandedPropertyGroups = new List <string>();

            ApplyRenderElementDefaults();
            Parent.AddChild(this);
        }
Пример #10
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Layer" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the layer</param>
        /// <param name="name">The name of the layer</param>
        public Layer(ProfileElement parent, string name)
        {
            LayerEntity = new LayerEntity();
            EntityId    = Guid.NewGuid();

            Parent              = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile             = Parent.Profile;
            Name                = name;
            Enabled             = true;
            DisplayContinuously = true;
            General             = new LayerGeneralProperties();
            Transform           = new LayerTransformProperties();

            _layerEffects           = new List <BaseLayerEffect>();
            _leds                   = new List <ArtemisLed>();
            _expandedPropertyGroups = new List <string>();

            Initialize();
            ApplyRenderElementDefaults();

            Parent.AddChild(this);
        }
Пример #11
0
        public override void Update(double deltaTime)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("Folder");
            }

            if (!Enabled)
            {
                return;
            }

            // Disable data bindings during an override
            bool wasApplyingDataBindings = ApplyDataBindingsEnabled;

            ApplyDataBindingsEnabled = false;

            UpdateDisplayCondition();

            // Update the layer timeline, this will give us a new delta time which could be negative in case the main segment wrapped back
            // to it's start
            UpdateTimeline(deltaTime);

            foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
            {
                baseLayerEffect.BaseProperties?.Update(deltaTime);
                baseLayerEffect.Update(deltaTime);
            }

            // Iterate the children in reverse because that's how they must be rendered too
            for (int index = Children.Count - 1; index > -1; index--)
            {
                ProfileElement profileElement = Children[index];
                profileElement.Update(deltaTime);
            }

            // Restore the old data bindings enabled state
            ApplyDataBindingsEnabled = wasApplyingDataBindings;
        }
Пример #12
0
        public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("Folder");
            }

            if (Path == null || !Enabled || !Children.Any(c => c.Enabled))
            {
                return;
            }

            // No need to render if at the end of the timeline
            if (TimelinePosition > TimelineLength)
            {
                return;
            }

            if (_folderBitmap == null)
            {
                _folderBitmap = new SKBitmap(new SKImageInfo((int)Path.Bounds.Width, (int)Path.Bounds.Height));
            }
            else if (_folderBitmap.Info.Width != (int)Path.Bounds.Width || _folderBitmap.Info.Height != (int)Path.Bounds.Height)
            {
                _folderBitmap.Dispose();
                _folderBitmap = new SKBitmap(new SKImageInfo((int)Path.Bounds.Width, (int)Path.Bounds.Height));
            }

            using SKPath folderPath     = new SKPath(Path);
            using SKCanvas folderCanvas = new SKCanvas(_folderBitmap);
            using SKPaint folderPaint   = new SKPaint();
            folderCanvas.Clear();

            folderPath.Transform(SKMatrix.MakeTranslation(folderPath.Bounds.Left * -1, folderPath.Bounds.Top * -1));

            SKPoint targetLocation = Path.Bounds.Location;

            if (Parent is Folder parentFolder)
            {
                targetLocation -= parentFolder.Path.Bounds.Location;
            }

            canvas.Save();

            using SKPath clipPath = new SKPath(folderPath);
            clipPath.Transform(SKMatrix.MakeTranslation(targetLocation.X, targetLocation.Y));
            canvas.ClipPath(clipPath);

            foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
            {
                baseLayerEffect.PreProcess(folderCanvas, _folderBitmap.Info, folderPath, folderPaint);
            }

            // No point rendering if the alpha was set to zero by one of the effects
            if (folderPaint.Color.Alpha == 0)
            {
                return;
            }

            // Iterate the children in reverse because the first layer must be rendered last to end up on top
            for (int index = Children.Count - 1; index > -1; index--)
            {
                folderCanvas.Save();
                ProfileElement profileElement = Children[index];
                profileElement.Render(deltaTime, folderCanvas, _folderBitmap.Info);
                folderCanvas.Restore();
            }

            // If required, apply the opacity override of the module to the root folder
            if (IsRootFolder && Profile.Module.OpacityOverride < 1)
            {
                double multiplier = Easings.SineEaseInOut(Profile.Module.OpacityOverride);
                folderPaint.Color = folderPaint.Color.WithAlpha((byte)(folderPaint.Color.Alpha * multiplier));
            }

            foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
            {
                baseLayerEffect.PostProcess(canvas, canvasInfo, folderPath, folderPaint);
            }
            canvas.DrawBitmap(_folderBitmap, targetLocation, folderPaint);

            canvas.Restore();
        }