Interaction logic for Column.xaml
Inheritance: System.Windows.Controls.UserControl, IComparable
Exemplo n.º 1
0
        private void ColumnClicked(Controls.Column column)
        {
            var data = new EventData(this);

            data.Id     = "OPEN_DEVICE_DETAILS";
            data.Data01 = column.Device;
            SendData?.Invoke(data);
        }
Exemplo n.º 2
0
 private void AddColumn(DeviceDescription device)
 {
     if (device != null && device.Enabled && !Columns.ToList().Exists(o => o.Device.UniqueId == device.UniqueId))
     {
         var column = new Controls.Column(device, userConfiguration);
         column.ComparisonType = comparisonType;
         column.Clicked       += ColumnClicked;
         Columns.Add(column);
         Columns.Sort();
     }
 }
Exemplo n.º 3
0
        static bool NotEqualTo(Column c1, Column c2)
        {
            if (!object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null)) return true;
            if (object.ReferenceEquals(c1, null) && !object.ReferenceEquals(c2, null)) return true;
            if (object.ReferenceEquals(c1, null) && object.ReferenceEquals(c2, null)) return false;

            bool uniqueId = c1.Device.UniqueId != c2.Device.UniqueId;

            if (c1 != null && c2 != null && c1.Device.Description != null & c2.Device.Description != null)
            {
                var type = c1.ComparisonType;
                switch (type)
                {
                    case DeviceComparisonTypes.CONTROLLER: return uniqueId || c1.Device.Description.Controller != c2.Device.Description.Controller;
                    case DeviceComparisonTypes.DESCRIPTION: return uniqueId || c1.Device.Description.Description != c2.Device.Description.Description;
                    case DeviceComparisonTypes.DEVICE_ID: return uniqueId || c1.Device.Description.DeviceId != c2.Device.Description.DeviceId;
                    case DeviceComparisonTypes.LOCATION: return uniqueId || c1.Device.Description.Location != c2.Device.Description.Location;
                    case DeviceComparisonTypes.MANUFACTURER: return uniqueId || c1.Device.Description.Manufacturer != c2.Device.Description.Manufacturer;
                }
            }

            return uniqueId && c1.Index == c2.Index;
        }
Exemplo n.º 4
0
        static bool LessThan(Column c1, Column c2, string propertyName)
        {
            var property = typeof(Data.DescriptionInfo).GetProperty(propertyName);
            if (property != null)
            {
                var p1 = property.GetValue(c1.Device.Description, null);
                var p2 = property.GetValue(c2.Device.Description, null);

                string s1 = p1 != null ? p1 as string : null;
                string s2 = p2 != null ? p2 as string : null;

                // Check for null values and put them at the bottom of the list
                if (string.IsNullOrEmpty(s1) && string.IsNullOrEmpty(s2)) return false;
                if (string.IsNullOrEmpty(s1) && !string.IsNullOrEmpty(s2)) return false;
                if (!string.IsNullOrEmpty(s1) && string.IsNullOrEmpty(s2)) return true;

                // Evaluate property comparison
                return string.Compare(s1, s2) <= 0;
            }

            return false;
        }
Exemplo n.º 5
0
        static bool LessThan(Column c1, Column c2)
        {
            if (c1 != null && c2 != null && c1.Device.Description != null && c2.Device.Description != null)
            {
                var type = c1.ComparisonType;
                switch (type)
                {
                    case DeviceComparisonTypes.CONTROLLER: return LessThan(c1, c2, "Controller");
                    case DeviceComparisonTypes.DESCRIPTION: return LessThan(c1, c2, "Description");
                    case DeviceComparisonTypes.DEVICE_ID: return LessThan(c1, c2, "DeviceId");
                    case DeviceComparisonTypes.LOCATION: return LessThan(c1, c2, "Location");
                    case DeviceComparisonTypes.MANUFACTURER: return LessThan(c1, c2, "Manufacturer");
                }
            }

            if (c1.Index > c2.Index) return false;
            else return true;
        }
 private void AddColumn(DeviceDescription device)
 {
     if (device != null && device.Enabled && !Columns.ToList().Exists(o => o.Device.UniqueId == device.UniqueId))
     {
         var column = new Controls.Column(device, userConfiguration);
         column.ComparisonType = comparisonType;
         column.Clicked += ColumnClicked;
         Columns.Add(column);
         Columns.Sort();
     }
 }