//protected AnimatorView ViewModel = new AnimatorView();
        public GlowBeanWindow()
        {
            InitializeComponent();
            _driver = new UsbDriver();

            CurrentFrame = new WindowFrame();
            DataContext = CurrentFrame;
        }
        private void SetControlsToFrame(WindowFrame frame)
        {
            CurrentFrame.Red = frame.Red;
            CurrentFrame.Green = frame.Green;
            CurrentFrame.Blue = frame.Blue;

            Led1.IsChecked = frame.IsBitOn(0);
            Led2.IsChecked = frame.IsBitOn(1);
            Led3.IsChecked = frame.IsBitOn(2);
            Led4.IsChecked = frame.IsBitOn(3);
            Led5.IsChecked = frame.IsBitOn(4);
            Led6.IsChecked = frame.IsBitOn(5);
            Led7.IsChecked = frame.IsBitOn(6);
            Led8.IsChecked = frame.IsBitOn(7);
            Led9.IsChecked = frame.IsBitOn(8);
            Led10.IsChecked = frame.IsBitOn(9);
            Led11.IsChecked = frame.IsBitOn(10);
            Led12.IsChecked = frame.IsBitOn(11);
        }
        private WindowFrame GetFrameFromControls()
        {
            var frame = new WindowFrame
            {
                Red = (byte)Red.Value,
                Blue = (byte)Blue.Value,
                Green = (byte)Green.Value,
            };
            frame.SetBitValue(0, Led1.IsChecked.Value);
            frame.SetBitValue(1, Led2.IsChecked.Value);
            frame.SetBitValue(2, Led3.IsChecked.Value);
            frame.SetBitValue(3, Led4.IsChecked.Value);
            frame.SetBitValue(4, Led5.IsChecked.Value);
            frame.SetBitValue(5, Led6.IsChecked.Value);
            frame.SetBitValue(6, Led7.IsChecked.Value);
            frame.SetBitValue(7, Led8.IsChecked.Value);
            frame.SetBitValue(8, Led9.IsChecked.Value);
            frame.SetBitValue(9, Led10.IsChecked.Value);
            frame.SetBitValue(10, Led11.IsChecked.Value);
            frame.SetBitValue(11, Led12.IsChecked.Value);

            frame.Thumbnail = GetThumbnail();
            return frame;
        }
        private void SetControlsToFrame(WindowFrame frame)
        {
            CurrentFrame.Red0 = frame.Red0;
            CurrentFrame.Green0 = frame.Green0;
            CurrentFrame.Blue0 = frame.Blue0;
            CurrentFrame.Red1 = frame.Red1;
            CurrentFrame.Green1 = frame.Green1;
            CurrentFrame.Blue1 = frame.Blue1;

            //BrightnessRed.Value = frame.Red0;
            //BrightnessRed2.Value = frame.Red1;
            //BrightnessBlue.Value = frame.Blue0;
            //BrightnessBlue2.Value = frame.Blue1;
            //BrightnessGreen.Value = frame.Green0;
            //BrightnessGree2n.Value = frame.Green1;
            Led0Active.IsChecked = frame.IsBitOn(0);
            Led1Active.IsChecked = frame.IsBitOn(1);
            Led2Active.IsChecked = frame.IsBitOn(2);
            Led3Active.IsChecked = frame.IsBitOn(3);
            Led4Active.IsChecked = frame.IsBitOn(4);
            Led5Active.IsChecked = frame.IsBitOn(5);
            Led6Active.IsChecked = frame.IsBitOn(6);
            Led7Active.IsChecked = frame.IsBitOn(7);
            Led8Active.IsChecked = frame.IsBitOn(8);
            Led9Active.IsChecked = frame.IsBitOn(9);
            Led10Active.IsChecked = frame.IsBitOn(10);
        }
        private bool SendFrameToDevice(WindowFrame frame)
        {
            bool result = false;

            try
            {
                const byte requestType =
                    (byte)UsbEndpointDirection.EndpointOut
                    | (byte)UsbRequestRecipient.RecipDevice
                    | (byte)UsbRequestType.TypeVendor;

                var controlPacket = new UsbSetupPacket(requestType, (byte)Command.SetFrameData, 0, 0, 8);
                int transferred;
                result = MyUsbDevice.ControlTransfer(ref controlPacket, frame.ToByteArray(), 8, out transferred);
                if (!result)
                {
                    Log("Frame Data Transfer failure.");
                }

            }
            catch (Exception exception)
            {
                Log("");
                Log("An error occurred during control transmission:");
                Log(exception.Message);
            }
            return result;
        }
 private WindowFrame GetFrameFromControls()
 {
     var frame = new WindowFrame
                     {
                         Red0 = (byte) BrightnessRed.Value,
                         Red1 = (byte) BrightnessRed2.Value,
                         Blue0 = (byte) BrightnessBlue.Value,
                         Blue1 = (byte) BrightnessBlue2.Value,
                         Green0 = (byte) BrightnessGreen.Value,
                         Green1 = (byte) BrightnessGree2n.Value
                     };
     frame.SetBitValue(0, Led0Active.IsChecked.Value);
     frame.SetBitValue(1, Led1Active.IsChecked.Value);
     frame.SetBitValue(2, Led2Active.IsChecked.Value);
     frame.SetBitValue(3, Led3Active.IsChecked.Value);
     frame.SetBitValue(4, Led4Active.IsChecked.Value);
     frame.SetBitValue(5, Led5Active.IsChecked.Value);
     frame.SetBitValue(6, Led6Active.IsChecked.Value);
     frame.SetBitValue(7, Led7Active.IsChecked.Value);
     frame.SetBitValue(8, Led8Active.IsChecked.Value);
     frame.SetBitValue(9, Led9Active.IsChecked.Value);
     frame.SetBitValue(10, Led10Active.IsChecked.Value);
     return frame;
 }