Esempio n. 1
0
        public void Remove(StripElement elementToRemove)
        {
            Debug.WriteLine($"****Removing:" + elementToRemove.Start);
            Elements.Remove(elementToRemove);
            elementToRemove.Type = StripElementType.SolidRange;
            elementToRemove.Red = 0;
            elementToRemove.Green = 0;
            elementToRemove.Blue = 0;

            if (elementToRemove.Length == 0)
            {
                elementToRemove.Type = StripElementType.SolidDot;
            }

            //clear this bit
            _draw(elementToRemove);
        
            foreach (var element in Elements)
            {
                if (element == elementToRemove)
                {
                    continue;
                }
                if (element.Start <= elementToRemove.Start &&
                    element.Start + element.Length >= elementToRemove.Start + elementToRemove.Length)
                {
                    //redraw this item as it intersected the removed item
                    _draw(element);
                }
            }
        }
Esempio n. 2
0
        void _draw(StripElement element)
        {
            string command = "";
            switch (element.Type)
            {
                case StripElementType.FlashDot:
                    command = $"d {element.Start} {element.Red} {element.Green} {element.Blue}";
                    break;

                case StripElementType.FlashRange:
                    command = $"e {element.Start} {element.Red} {element.Green} {element.Blue} {element.Length}";
                    break;

                case StripElementType.SolidDot:
                    command = $"a {element.Start} {element.Red} {element.Green} {element.Blue}";
                    break;

                case StripElementType.SolidRange:
                    command = $"b {element.Start} {element.Red} {element.Green} {element.Blue} {element.Length}";
                    break;
            }
            SendCommand(command);
        }
Esempio n. 3
0
 void _add(StripElement element)
 {
     Elements.Add(element);
     _draw(element);
 }
Esempio n. 4
0
 public void SetRange(int start, int length, int red, int green, int blue, string tag = null)
 {
     var element = new StripElement
     {
         Start = start,
         Length = length,
         Red = red,
         Green = green,
         Blue = blue,
         Type = StripElementType.SolidRange,
         Tag = tag
     };
     _add(element);
 }
Esempio n. 5
0
        public void FlashDot(int dot, int red, int green, int blue, string tag = null)
        {

            //find the old flash if there was one
            
            var old = Elements.FirstOrDefault(_ => _.Type == StripElementType.FlashDot);

            if (old != null)
            {
                Remove(old);
            }

            var element = new StripElement
            {
                Start = dot,
                Red = red,
                Green = green,
                Blue = blue,
                Type = StripElementType.FlashDot,
                Tag = tag
            };

            Debug.WriteLine($"****Flashing:" + element.Start);

            _add(element);
        }
Esempio n. 6
0
 public void SolidDot(int dot, int red, int green, int blue, string tag = null)
 {
     var element = new StripElement
     {
         Start = dot,
         Red = red,
         Green = green,
         Blue = blue,
         Type = StripElementType.SolidDot,
         Tag = tag
     };
     _add(element);
 }