Esempio n. 1
0
        private void ScreenListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Get screen index of selected screen
            int index = ScreenListBox.SelectedIndex;

            // Get screen information from ambilight

            if (index != -1)
            {
                ScreenDevice selScreen = newAmbi.GetSceenData(index);

                // Show information of selected screen
                ScreenXPosTextBox.Text   = selScreen.XPos.ToString();
                ScreenYPosTextBox.Text   = selScreen.YPos.ToString();
                ScreenWidthTextBox.Text  = selScreen.Width.ToString();
                ScreenHeightTextBox.Text = selScreen.Height.ToString();
            }
        }
Esempio n. 2
0
 public void ChangeScreen(ScreenDevice changedScreen, int index)
 {
     mon[index] = changedScreen;
 }
Esempio n. 3
0
        public override bool LoadProfile(string profileName)
        {
            Console.WriteLine("Loading Profile: " + profileName);
            try
            {
                XDocument loadedXmlDoc = XDocument.Load(profileName);

                var screens = loadedXmlDoc.Element("LedProfile").Descendants("Screen");
                var leds    = loadedXmlDoc.Element("LedProfile").Descendants("LED");

                // Loading Mode
                mode = loadedXmlDoc.Element("LedProfile").Attribute("Mode").Value;

                // Find screens and define rectangles
                int screenid = 0;
                mon = new ScreenDevice[screens.Count()];

                Console.WriteLine("new mons: " + screens.Count());

                foreach (var screen in screens)
                {
                    screenid      = Convert.ToInt32(screen.Attribute("ScreenId").Value);
                    mon[screenid] = new ScreenDevice();
                    int numRect = screen.Elements("Rectangle").Count();

                    mon[screenid].Rect = new Rectangle[numRect];

                    mon[screenid].Width  = Convert.ToInt32(screen.Element("ScreenData").Attribute("Width").Value);
                    mon[screenid].Height = Convert.ToInt32(screen.Element("ScreenData").Attribute("Height").Value);

                    mon[screenid].XPos = Convert.ToInt32(screen.Element("ScreenData").Attribute("XPos").Value);
                    mon[screenid].YPos = Convert.ToInt32(screen.Element("ScreenData").Attribute("YPos").Value);

                    var rects = screen.Descendants("Rectangle");

                    int rectNr = 0;
                    foreach (var rect in rects)
                    {
                        mon[screenid].Rect[rectNr] = new Rectangle();

                        mon[screenid].Rect[rectNr].X      = Convert.ToInt32(rect.Attribute("X").Value);
                        mon[screenid].Rect[rectNr].Y      = Convert.ToInt32(rect.Attribute("Y").Value);
                        mon[screenid].Rect[rectNr].Width  = Convert.ToInt32(rect.Attribute("W").Value);
                        mon[screenid].Rect[rectNr].Height = Convert.ToInt32(rect.Attribute("H").Value);

                        // Console.WriteLine("Loading Rectangle " + rectNr + " with X = " + mon[screenid].Rect[rectNr].X + " and Y = " + mon[screenid].Rect[rectNr].Y + " ScreenId = " + screenid);

                        rectNr++;
                    }
                }

                // Find leds

                int id     = 0;
                int numLed = leds.Count();
                LedList = new LED[numLed];

                r = new byte[numLed];
                g = new byte[numLed];
                b = new byte[numLed];

                foreach (var led in leds)
                {
                    LedList[id]._id = Convert.ToByte(led.Attribute("LedID").Value);

                    // Set color
                    LedList[id].Color    = new byte[3];
                    LedList[id].Color[0] = Convert.ToByte(led.Element("Color").Attribute("R").Value);
                    LedList[id].Color[1] = Convert.ToByte(led.Element("Color").Attribute("G").Value);
                    LedList[id].Color[2] = Convert.ToByte(led.Element("Color").Attribute("B").Value);

                    // Set intensity
                    LedList[id].Intensity    = new double[3];
                    LedList[id].Intensity[0] = Convert.ToDouble(led.Element("Intensity").Attribute("R").Value);
                    LedList[id].Intensity[1] = Convert.ToDouble(led.Element("Intensity").Attribute("G").Value);
                    LedList[id].Intensity[2] = Convert.ToDouble(led.Element("Intensity").Attribute("B").Value);

                    //Set rectangleID
                    LedList[id].RectID = Convert.ToInt32(led.Element("RectID").Attribute("Id").Value);

                    // Test output
                    //Console.WriteLine("Loading LED " + LedList[id]._id + ": " + "RectId = " + LedList[id].RectID);

                    id++;
                }

                int RectTot = 0;
                for (int i = 0; i < mon.Length; i++)
                {
                    RectTot += mon[i].Rect.Length;
                }
                avgRect = new byte[RectTot * 3];

                // Initialise RGBdata array with numLed*3 + 2 and set start and stop byte
                RGBdata    = new byte[leds.Count() * 3 + 2];
                RGBdata[0] = 0x01;
                RGBdata[leds.Count() * 3 + 1] = 0x02;
                Console.WriteLine("Loading done...");

                return(true);
            }
            catch (FileNotFoundException e)
            {
                return(false);
            }
        }