Ejemplo n.º 1
0
        private void UpdateGui()
        {
            model.groups.Sort((a, b) => string.Compare(a.name, b.name, true));
            UpdateGroups();

            AbstractUserControlContext ctx = new AbstractUserControlContext()
            {
                Groups = groups.Groups
            };

            Devices = new ObservableCollection <DeviceModel>(model.devices.Select(t =>
            {
                var dm   = new DeviceModel(t);
                ctx.Info = t;

                switch (t.type)
                {
                case EDeviceType.Server:
                case EDeviceType.Workstation:
                    dm.Control = workstationADeviceControl.MakeControl(t.type).Initialize(ctx);
                    return(dm);

                case EDeviceType.System:
                    dm.Control = systemADeviceControl.MakeControl(t.type).Initialize(ctx);
                    return(dm);

                case EDeviceType.Unknown:
                    throw new ArgumentOutOfRangeException();

                // Let's use generic as the default type, so we can add new ones in
                // the future without causing a problem here.
                default:
                    dm.Control = genericADeviceControl.MakeControl(t.type).Initialize(ctx);
                    return(dm);
                }
            }));
            configuration.UpdateConfigs(model.configuration.Values.ToList());
            siteSettings.UpdateLanguages(model.languages);

            ConfigurationData site_name = null;

            if (model.configuration.TryGetValue(@"site.name", out site_name))
            {
                siteSettings.SiteName = site_name.value;
            }

            SetupDeviceFilters();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// DevicesModels are reified DeviceInfos, that is to say that devices first come into the application
        /// as pure data. It is our responsibility to inflate them into the correct DeviceModel.
        /// </summary>
        /// <returns>DeviceModel representation of a DeviceInfo</returns>
        public DeviceModel MakeDeviceModel()
        {
            EDeviceType type = GetNewDeviceType();
            var         di   = new DeviceInfo(type)
            {
                DID = new DeviceID(-1, GetDeviceName())
            };
            AbstractUserControlContext ctx = new AbstractUserControlContext()
            {
                Info = di
            };
            var dm = new DeviceModel
            {
                Type    = type,
                Control = MakeControl(type).Initialize(ctx),
                Info    = di,
                Name    = di.name
            };

            return(dm);
        }