Esempio n. 1
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            SerialNumber = Int32.Parse(reader.ReadElementString("SerialNumber"), CultureInfo.InvariantCulture);
            Voltage      = int.Parse(reader.ReadElementString("Voltage"), CultureInfo.InvariantCulture);
            CurrentLimit = int.Parse(reader.ReadElementString("CurrentLimit"), CultureInfo.InvariantCulture);
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Groups");
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    reader.ReadStartElement("Group");
                    LEDGroup group = new LEDGroup(this, reader.ReadElementString("Name"));
                    group.DefaultLevel = int.Parse(reader.ReadElementString("DefaultLevel"), CultureInfo.InvariantCulture);

                    string leds = reader.ReadElementString("Leds");
                    if (!string.IsNullOrWhiteSpace(leds))
                    {
                        string[] ledSplit = leds.Split(',');
                        foreach (string led in ledSplit)
                        {
                            group.Leds.Add(int.Parse(led, CultureInfo.InvariantCulture));
                        }
                    }
                    LedGroups.Add(group);

                    reader.ReadEndElement();
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Esempio n. 2
0
 public LedGroupViewModel(PhidgetLEDBoard board, LEDGroup group)
 {
     _board = board;
     _group = group;
     for(int i=0; i < 64; i++)
     {
         _leds.Add(new LedViewModel(board, group, i));
     }
 }
Esempio n. 3
0
 public LedGroupViewModel(PhidgetLEDBoard board, LEDGroup group)
 {
     _board = board;
     _group = group;
     for (int i = 0; i < 64; i++)
     {
         _leds.Add(new LedViewModel(board, group, i));
     }
 }
Esempio n. 4
0
 public void SetGroupLevel(LEDGroup group, int level)
 {
     if (_ledBoard != null && _ledBoard.Attached)
     {
         foreach (int i in group.Leds)
         {
             _ledBoard.leds[i] = level;
         }
     }
 }
Esempio n. 5
0
 public void SetGroupPower(LEDGroup group, bool power)
 {
     if (power)
     {
         SetGroupLevel(group, group.Level);
     }
     else
     {
         SetGroupLevel(group, 0);
     }
 }
Esempio n. 6
0
 private LedGroupViewModel GetViewModelForGroup(LEDGroup group)
 {
     foreach (LedGroupViewModel groupModel in this)
     {
         if (groupModel.Group == group)
         {
             return(groupModel);
         }
     }
     return(null);
 }
Esempio n. 7
0
        private void SetPowerAction_Execute(object action, HeliosActionEventArgs e)
        {
            IBindingAction myAction = action as IBindingAction;

            if (myAction != null)
            {
                LEDGroup group = myAction.Context as LEDGroup;
                if (group != null)
                {
                    group.Power = e.Value.BoolValue;
                    SetGroupPower(group, group.Power);
                }
            }
        }
        private void AddLedGroup(object sender, RoutedEventArgs e)
        {
            PhidgetLEDBoard board = Interface as PhidgetLEDBoard;

            int i = 0;
            string name = "Led Group " + i++;
            while (board.LedGroups.ContainsKey(name))
            {
                name = "Led Group " + i++;
            }

            LEDGroup group = new LEDGroup(board, name);
            board.LedGroups.Add(group);

            LedGroupListBox.SelectedItem = GroupsViewModel.Last();

            ConfigManager.UndoManager.AddUndoItem(new AddLedGroupUndoEvent(board.LedGroups, group));
        }
Esempio n. 9
0
        private void SetBrightnessAction_Execute(object action, HeliosActionEventArgs e)
        {
            IBindingAction myAction = action as IBindingAction;

            if (myAction != null)
            {
                LEDGroup group = myAction.Context as LEDGroup;
                if (group != null)
                {
                    int newLevel = (int)Math.Truncate(e.Value.DoubleValue);
                    if (newLevel != group.Level)
                    {
                        group.Level = newLevel;
                        group.Power = true;
                        SetGroupLevel(group, group.Level);
                    }
                }
            }
        }
Esempio n. 10
0
        private string GetLedList(LEDGroup group)
        {
            string list  = "";
            bool   first = true;

            foreach (int i in group.Leds)
            {
                if (!first)
                {
                    list += ",";
                }
                else
                {
                    first = false;
                }
                list += i.ToString(CultureInfo.InvariantCulture);
            }

            return(list);
        }
Esempio n. 11
0
        private void AddLedGroup(object sender, RoutedEventArgs e)
        {
            PhidgetLEDBoard board = Interface as PhidgetLEDBoard;

            int    i    = 0;
            string name = "Led Group " + i++;

            while (board.LedGroups.ContainsKey(name))
            {
                name = "Led Group " + i++;
            }

            LEDGroup group = new LEDGroup(board, name);

            board.LedGroups.Add(group);

            LedGroupListBox.SelectedItem = GroupsViewModel.Last();

            ConfigManager.UndoManager.AddUndoItem(new AddLedGroupUndoEvent(board.LedGroups, group));
        }
Esempio n. 12
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            SerialNumber = Int32.Parse(reader.ReadElementString("SerialNumber"), CultureInfo.InvariantCulture);
            Voltage = int.Parse(reader.ReadElementString("Voltage"), CultureInfo.InvariantCulture);
            CurrentLimit = int.Parse(reader.ReadElementString("CurrentLimit"), CultureInfo.InvariantCulture);
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Groups");
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    reader.ReadStartElement("Group");
                    LEDGroup group = new LEDGroup(this, reader.ReadElementString("Name"));
                    group.DefaultLevel = int.Parse(reader.ReadElementString("DefaultLevel"), CultureInfo.InvariantCulture);

                    string leds = reader.ReadElementString("Leds");
                    if (!string.IsNullOrWhiteSpace(leds))
                    {
                        string[] ledSplit = leds.Split(',');
                        foreach (string led in ledSplit)
                        {
                            group.Leds.Add(int.Parse(led, CultureInfo.InvariantCulture));
                        }
                    }
                    LedGroups.Add(group);

                    reader.ReadEndElement();
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Esempio n. 13
0
 public void SetGroupLevel(LEDGroup group, int level)
 {
     if (_ledBoard != null && _ledBoard.Attached)
     {
         foreach (int i in group.Leds)
         {
             _ledBoard.leds[i] = level;
         }
     }
 }
Esempio n. 14
0
 public void SetGroupPower(LEDGroup group, bool power)
 {
     if (power)
     {
         SetGroupLevel(group, group.Level);
     }
     else
     {
         SetGroupLevel(group, 0);
     }
 }
Esempio n. 15
0
 public LedViewModel(PhidgetLEDBoard board, LEDGroup group, int led)
 {
     _board = board;
     _group = group;
     _led   = led;
 }
Esempio n. 16
0
        private string GetLedList(LEDGroup group)
        {
            string list = "";
            bool first = true;

            foreach (int i in group.Leds)
            {
                if (!first)
                {
                    list += ",";
                }
                else
                {
                    first = false;
                }
                list += i.ToString(CultureInfo.InvariantCulture);
            }

            return list;
        }
Esempio n. 17
0
 public LedViewModel(PhidgetLEDBoard board, LEDGroup group, int led)
 {
     _board = board;
     _group = group;
     _led = led;
 }