Пример #1
0
        private void PasteEffectInvoke(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
        {
            if (CheckedLayer == null || g_CanPaste == false || CopiedEffect == null)
            {
                return;
            }

            args.Handled = true;
            g_CanPaste   = false;

            var copy = new EffectLineViewModel(CopiedEffect);

            copy.Left = (CheckedEffect != null) ? CheckedEffect.Right : 0;

            if (!CheckedLayer.TryInsertToTimelineFitly(copy))
            {
                // TODO
                g_CanPaste = true;
                return;
            }

            TimeSpan        delay      = TimeSpan.FromMilliseconds(400);
            ThreadPoolTimer DelayTimer = ThreadPoolTimer.CreateTimer(
                (source) =>
            {
                Dispatcher.RunAsync(
                    CoreDispatcherPriority.High,
                    () =>
                {
                    g_CanPaste = true;
                });
            }, delay);
        }
Пример #2
0
 public ColorChangeCommand(EffectLineViewModel checkedEffect, string ColorBgName, Color oldColorValue, Color currentColorValue)
 {
     _checkedEffect     = checkedEffect;
     _oldColorValue     = oldColorValue;
     _currentColorValue = currentColorValue;
     _colorBgName       = ColorBgName;
 }
Пример #3
0
        public double ApplyEffect(EffectLineViewModel placedEff)
        {
            EffectLineViewModel firstIntersecting = GetFirstIntersectingEffect(placedEff);

            if (firstIntersecting != null)
            {
                if (placedEff.Left <= firstIntersecting.Left)
                {
                    double move = placedEff.Right - firstIntersecting.Left;
                    PushAllBehindEffect(placedEff, move);

                    return(placedEff.Left);
                }
                else
                {
                    double target = firstIntersecting.Right;
                    placedEff.MovePositionWithAnimation(target);

                    EffectLineViewModel nextEff = GetTheNext(placedEff);
                    if (nextEff != null)
                    {
                        if (ControlHelper.IsPiling(target, placedEff.Width, nextEff.Left, nextEff.Width))
                        {
                            double push = target + placedEff.Width - nextEff.Left;
                            PushAllBehindEffect(placedEff, push);
                        }
                    }

                    return(target);
                }
            }

            return(placedEff.Left);
        }
Пример #4
0
        private EffectLineViewModel GetThePrevious(EffectLineViewModel eff)
        {
            double rightmostPosition           = 0;
            EffectLineViewModel previousEffect = null;

            foreach (var e in EffectLineViewModels)
            {
                if (e.Equals(eff))
                {
                    continue;
                }

                double end = e.EndTime;

                if (end > rightmostPosition)
                {
                    rightmostPosition = end;
                    previousEffect    = e;
                }
            }

            if (previousEffect != null)
            {
                return(previousEffect);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        public bool ExceedIfApplyingEff(EffectLineViewModel eff)
        {
            EffectLineViewModel first = GetFirstIntersectingEffect(eff);

            if (first != null)
            {
                double needSpace;

                if (eff.Left <= first.Left)
                {
                    needSpace = eff.Right - first.Left;
                }
                else
                {
                    eff.Left = first.Right;
                    EffectLineViewModel second = GetFirstIntersectingEffect(eff);

                    if (second == null)
                    {
                        return(eff.Right > LayerPage.MaxRightPixel);
                    }
                    else
                    {
                        needSpace = eff.Right - second.Left;
                    }
                }

                return(RemainingSpaceOnLast < needSpace);
            }

            return(LayerPage.MaxRightPixel < eff.Right);
        }
Пример #6
0
        public EffectLineViewModel GetFirstIntersectingEffect(EffectLineViewModel eff)
        {
            EffectLineViewModel result = null;

            foreach (EffectLineViewModel e in EffectLineViewModels)
            {
                if (e.Equals(eff))
                {
                    continue;
                }

                if (IsIntersecting(eff, e))
                {
                    if (result == null)
                    {
                        result = e;
                    }
                    else if (e.Left < result.Left)
                    {
                        result = e;
                    }
                }
            }

            return(result);
        }
Пример #7
0
        public RangeSlider()
        {
            this.InitializeComponent();
            m_ForSliderCheckEffected = LayerPage.Self.CheckedEffect;
            Task curtask = Task.Run(async() => await CreateRandomBgImage());

            curtask.Wait();
        }
Пример #8
0
        private void CopyEffectInvoke(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
        {
            if (CheckedEffect == null)
            {
                return;
            }

            CopiedEffect = new EffectLineViewModel(CheckedEffect);
            args.Handled = true;
        }
Пример #9
0
        private void Track_Drop(object sender, DragEventArgs e)
        {
            if (!m_Layer.TryInsertToTimelineFitly(draggingEff))
            {
                return;
            }

            LayerPage.Self.CheckedEffect = draggingEff;
            LayerPage.Self.UpdateSupportLine(-1);
            Log.Debug("[Track_Drop] Drop position : " + draggingEff.Left);
            draggingEff = null;
        }
Пример #10
0
        private EffectLineViewModel GetTheNext(EffectLineViewModel eff)
        {
            EffectLineViewModel find = GetFirstBehindPosition(eff.Left + 1);

            if (find == null)
            {
                return(null);
            }
            else
            {
                return(find);
            }
        }
Пример #11
0
            public ColorPatternModifyCommand(EffectInfoModel info, List <ColorPointLightData> oldlist, List <ColorPointLightData> newlist, int oldSelect, int newSelect)
            {
                _info      = info;
                _oldlist   = oldlist;
                _newlist   = newlist;
                _oldSelect = oldSelect;
                _newSelect = newSelect;

                if (IsCommonEffect(info.Type))
                {
                    _elvm = LayerPage.Self.CheckedEffect;
                }
            }
Пример #12
0
        private void Track_DragEnter(object sender, DragEventArgs e)
        {
            var pair = e.Data.Properties.FirstOrDefault();

            if (e.Data == null || !(pair.Value is int))
            {
                return;
            }

            needAlignPositions = LayerPage.Self.GetAlignPositions(m_Layer);

            int idx = (int)pair.Value;

            draggingEff = new EffectLineViewModel(idx);
        }
Пример #13
0
        private void PasteItem_Click(object sender, RoutedEventArgs e)
        {
            if (LayerPage.Self.CopiedEffect == null)
            {
                return;
            }

            var copy = new EffectLineViewModel(LayerPage.Self.CopiedEffect);

            copy.Left = this.EffectRight;

            if (elvm.Layer.TryInsertToTimelineFitly(copy))
            {
                // TODO
            }
        }
Пример #14
0
        public List <double> GetAllEffHeadAndTailPositions(EffectLineViewModel ExceptionalEff)
        {
            List <double> result = new List <double>();

            foreach (var eff in EffectLineViewModels)
            {
                if (eff == ExceptionalEff)
                {
                    continue;
                }
                result.Add(eff.Left);
                result.Add(eff.Right);
            }

            return(result);
        }
Пример #15
0
        public EffectLineViewModel GetRightmostEffect()
        {
            EffectLineViewModel rightmost = null;
            double rightmostPosition      = 0;

            foreach (EffectLineViewModel eff in EffectLineViewModels)
            {
                if (eff.Right > rightmostPosition)
                {
                    rightmost         = eff;
                    rightmostPosition = eff.Right;
                }
            }

            return(rightmost);
        }
Пример #16
0
        private EffectLineViewModel GetRightmostEffect()
        {
            EffectLineViewModel result = null;
            double max = 0;

            foreach (LayerModel layer in Layers)
            {
                EffectLineViewModel eff = layer.GetRightmostEffect();
                if (eff != null && eff.Right > max)
                {
                    result = eff;
                    max    = eff.Right;
                }
            }
            return(result);
        }
Пример #17
0
        private void PushAllBehindEffect(EffectLineViewModel effect, double move)
        {
            foreach (EffectLineViewModel e in EffectLineViewModels)
            {
                if (effect.Equals(e))
                {
                    continue;
                }

                if (effect.Left <= e.Left)
                {
                    double target = e.Left + move;
                    e.MovePositionWithAnimation(target);
                    ReUndoManager.Store(new MoveEffectCommand(e, e.Left, target));
                }
            }
        }
Пример #18
0
        public double GetFirstRoomPosition(double needRoomOfDuration)
        {
            double roomOfDuration = 0;

            for (int i = 0; i < EffectLineViewModels.Count; i++)
            {
                EffectLineViewModel eff = EffectLineViewModels[i];

                if (roomOfDuration <= eff.StartTime && eff.StartTime < roomOfDuration + needRoomOfDuration)
                {
                    roomOfDuration = eff.EndTime;
                    i = -1; // rescan every effect line
                }
            }

            return(roomOfDuration);
        }
Пример #19
0
        public bool TryInsertToTimelineFitly(EffectLineViewModel eff)
        {
            eff.Layer = this;

            if (ExceedIfApplyingEff(eff))
            {
                return(false);
            }

            EffectLineViewModels.Add(eff);
            double moveTo = ApplyEffect(eff);

            // Because EffectLine create after MoveTo invoke,
            // assign again to make sure position is correct.
            eff.Left = moveTo;

            return(true);
        }
Пример #20
0
        public double[] GetAlignPositions(EffectLineViewModel eff)
        {
            LayerModel    layer  = eff.Layer;
            List <double> result = new List <double>();
            int           i      = Layers.IndexOf(layer);

            result.Add(playerModel.Position);
            foreach (var l in Layers)
            {
                if (l.Equals(layer))
                {
                    result.AddRange(l.GetAllEffHeadAndTailPositions(eff));
                }
                else
                {
                    result.AddRange(l.GetAllEffHeadAndTailPositions(null));
                }
            }
            return(result.ToArray());
        }
Пример #21
0
        public void DeleteEffectLine(EffectLineViewModel eff)
        {
            EffectLineViewModel next = GetTheNext(eff);

            if (next == null)
            {
                next = GetThePrevious(eff);
            }

            if (next != null)
            {
                LayerPage.Self.CheckedEffect = next;
            }
            else
            {
                LayerPage.Self.CheckedEffect = null;
            }

            EffectLineViewModels.Remove(eff);
        }
Пример #22
0
        public EffectLineViewModel GetFirstBehindPosition(double x)
        {
            EffectLineViewModel result = null;

            foreach (EffectLineViewModel e in EffectLineViewModels)
            {
                if (e.Left >= x)
                {
                    if (result == null)
                    {
                        result = e;
                    }

                    if (e.Left < result.Left)
                    {
                        result = e;
                    }
                }
            }
            return(result);
        }
Пример #23
0
        private EffectLineViewModel GetFirstIntersectingEffect(double left, double width)
        {
            EffectLineViewModel result = null;

            foreach (var e in EffectLineViewModels)
            {
                if (ControlHelper.IsPiling(left, width, e.Left, e.Width))
                {
                    if (result == null)
                    {
                        result = e;
                    }
                    else if (e.Left < result.Left)
                    {
                        result = e;
                    }
                }
            }

            return(result);
        }
Пример #24
0
 public RangeMinChangeCommand(EffectLineViewModel checkedEffect, double oldRangeMinValue, double currentRangeMinValue)
 {
     _checkedEffect        = checkedEffect;
     _oldRangeMinValue     = oldRangeMinValue;
     _currentRangeMinValue = currentRangeMinValue;
 }
Пример #25
0
 public WidthLeftEffectCommand(EffectLineViewModel elvm, double oldV, double newV)
 {
     _elvm = elvm;
     _oldV = oldV;
     _newV = newV;
 }
Пример #26
0
 public RemoveEffectCommand(EffectLineViewModel elvm)
 {
     _elvm = elvm;
 }
Пример #27
0
 public AddEffectCommand(EffectLineViewModel elvm)
 {
     _elvm = elvm;
 }
Пример #28
0
 private bool IsIntersecting(EffectLineViewModel effect1, EffectLineViewModel effect2)
 {
     return(ControlHelper.IsPiling(
                effect1.Left, effect1.Width,
                effect2.Left, effect2.Width));
 }
Пример #29
0
 public void AddTimelineEffect(EffectLineViewModel eff)
 {
     eff.Layer = this;
     EffectLineViewModels.Add(eff);
 }
Пример #30
0
 public RainbowSpecialModeChangeCommand(EffectLineViewModel checkedEffect, int oldSpecialModeValue, int currentSpecialModeValue)
 {
     _checkedEffect           = checkedEffect;
     _oldSpecialModeValue     = oldSpecialModeValue;
     _currentSpecialModeValue = currentSpecialModeValue;
 }