Example #1
0
        public static void SaveIcon(string macAddress, DeviceIconEnum icon)
        {
            //if (Settings.Default.DeviceIcons == null)
            //{
            //    Settings.Default.DeviceIcons = new System.Collections.ArrayList();

            //}
            //// Remove existing setting
            //Settings.Default.DeviceIcons.Remove(
            //        (from obj in Settings.Default.DeviceIcons.ToArray()
            //         where (obj as DeviceIcon).MacAddress.Replace(":", "-").ToLowerInvariant() == macAddress.Replace(":", "-").ToLowerInvariant()
            //             select obj).FirstOrDefault()
            //    );

            ////Save new setting
            //Settings.Default.DeviceIcons.Add(new DeviceIcon(macAddress, icon));
            //Settings.Default.Save();

            var icons = GetDeviceIcons();

            foreach (var item in
                     (from i in icons
                      where i.MacAddress.Replace(":", "-").ToLowerInvariant() == macAddress.Replace(":", "-").ToLowerInvariant()
                      select i).ToArray()
                     )
            {
                icons.Remove(item);
            }

            icons.Add(new DeviceIcon(macAddress, icon));
            SaveDeviceIcons(icons);
        }
        public static void SaveIcon(string macAddress, DeviceIconEnum icon)
        {
            //if (Settings.Default.DeviceIcons == null)
            //{
            //    Settings.Default.DeviceIcons = new System.Collections.ArrayList();

            //}
            //// Remove existing setting
            //Settings.Default.DeviceIcons.Remove(
            //        (from obj in Settings.Default.DeviceIcons.ToArray()
            //         where (obj as DeviceIcon).MacAddress.Replace(":", "-").ToLowerInvariant() == macAddress.Replace(":", "-").ToLowerInvariant()
            //             select obj).FirstOrDefault()
            //    );

            ////Save new setting
            //Settings.Default.DeviceIcons.Add(new DeviceIcon(macAddress, icon));
            //Settings.Default.Save();

            var icons = GetDeviceIcons();

            foreach(var item in
                    (from i in icons
                    where i.MacAddress.Replace(":", "-").ToLowerInvariant() == macAddress.Replace(":", "-").ToLowerInvariant()
                    select i).ToArray()
                ) {
                        icons.Remove(item);
            }

            icons.Add(new DeviceIcon(macAddress, icon));
            SaveDeviceIcons(icons);
        }
Example #3
0
 public DeviceIcon(string macAddress, DeviceIconEnum icon)
 {
     this.MacAddress = macAddress;
     this.Icon       = icon;
 }
 public DeviceIcon(string macAddress, DeviceIconEnum icon)
 {
     this.MacAddress = macAddress;
     this.Icon = icon;
 }
 public static string ToDescriptionString(this DeviceIconEnum val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
 public static string ToResourceName(this DeviceIconEnum val)
 {
     DeviceIconResourceNameAttribute[] attributes = (DeviceIconResourceNameAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DeviceIconResourceNameAttribute), false);
     return(attributes.Length > 0 ? attributes[0].ResourceName : string.Empty);
 }