public void Add(Frame frame)
 {
     _sequence.Push(frame);
     //добавляем модель для отображения
     var frameModel = new FrameView(frame);
     frameModel.ModelChanged += OnSequenceChanged;
     _frameViews.Add(frameModel);
 }
 public void ConvertFrame(FrameView view, Frame frame)
 {
     int idx = _frameViews.IndexOf(view);
     if (idx >= 0)
     {
         _sequence.ChangeFrame(view.Frame, frame);
         _frameViews[idx] = new FrameView(frame);
     }
 }
Example #3
0
        public void CreateNewFrame()
        {
            var startTime = TimeSpan.FromSeconds(0);
            var length = TimeSpan.FromSeconds(3.5);

            var cmd = new Frame(startTime, length);

            Assert.AreEqual(startTime, cmd.StartTime);
            Assert.AreEqual(length, cmd.Length);
        }
 public void InserBefore(Frame target, Frame newFrame)
 {
     lock (_locker)
     {
         var idx = _frames.IndexOf(target);
         if (idx >= 0)
         {
             _frames.Insert(idx, newFrame);
             newFrame.FrameChanged += OnFrameChanged;
         }
     }
 }
 public void ChangeFrame(Frame target, Frame newFrame)
 {
     lock (_locker)
     {
         var idx = _frames.IndexOf(target);
         if (idx >= 0)
         {
             _frames[idx] = newFrame;
             newFrame.FrameChanged += OnFrameChanged;
         }
     }
 }
Example #6
0
        public void FrameStartNotRequired()
        {
            var startTime = TimeSpan.FromSeconds(1);
            var length = TimeSpan.FromSeconds(4);

            var cmd = new Frame(startTime, length);

            var before = TimeSpan.FromSeconds(0.5);
            Assert.IsFalse(cmd.IsStartRequired(before));
            var after = startTime + length + TimeSpan.FromSeconds(0.5);
            Assert.IsFalse(cmd.IsStartRequired(after));
        }
Example #7
0
        public void FrameStartRequired()
        {
            var startTime = TimeSpan.FromSeconds(0);
            var length = TimeSpan.FromSeconds(4);

            var cmd = new Frame(startTime, length);

            var middle = TimeSpan.FromSeconds(2);
            Assert.IsTrue(cmd.IsStartRequired(middle));
            //bound checks
            var begin = TimeSpan.FromSeconds(0);
            Assert.IsTrue(cmd.IsStartRequired(begin));
            var end = TimeSpan.FromSeconds(4);
            Assert.IsFalse(cmd.IsStartRequired(end));
        }
        public void SaveFrame()
        {
            var color = Color.FromRgb(128, 128, 128);
            var frame1 = new Frame(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(3.5))
            {
                Command = new SetColor(color){Channel = 1}
            };
            var frame2 = new Frame(TimeSpan.FromSeconds(3.5), TimeSpan.FromSeconds(2))
            {
                Command = new SetColor(color){Channel = 1}
            };
            var seq = new FrameSequence();
            seq.Push(frame1);
            seq.Push(frame2);

            var s = JsonSerializer.SerializeToString(seq);
            Console.WriteLine(s);
        }
Example #9
0
        public Frame CreateFrameByCmdEnum(CmdEnum cmdEnum, TimeSpan startTime)
        {
            Frame result = null;
            Command cmd = null;
            switch (cmdEnum)
            {
                case CmdEnum.SetColor:
                    cmd = new SetColor(Colors.Black){Channel = Command.DefaultChannel};
                    break;
                case CmdEnum.Fade:
                    var length = (short)(DefaultLength.TotalSeconds * TicksPerSec);
                    cmd = new FadeColor(Colors.Black, Colors.Black, length){Channel = Command.DefaultChannel};
                    break;
                case CmdEnum.Blink:
                    cmd = new BlinkColor(Colors.Black, 50){Channel = Command.DefaultChannel};
                    break;
            }
            if(cmd != null)
                result = new Frame(startTime, DefaultLength) { Command = cmd };

            return result;
        }
Example #10
0
 public void Push(Frame frame)
 {
     lock (_locker)
     {
         _frames.Add(frame);
         frame.FrameChanged += OnFrameChanged;
     }
 }
Example #11
0
 public FrameView(Frame frame)
 {
     _frame = frame;
 }
Example #12
0
 public FrameView()
 {
     _frame = null;
 }
 private static Frame CreateFrame(double time1, double time2)
 {
     var span1 = TimeSpan.FromSeconds(time1);
     var span2 = TimeSpan.FromSeconds(time2);
     var frame = new Frame(span1, span2) { Command = new SetColor(Color.FromRgb(128, 128, 128)){Channel = 1} };
     return frame;
 }