Exemple #1
0
        public void LoadHardwareSettings()
        {
            try
            {
                XPathDocument  xPathDoc  = new XPathDocument(Settings.HWSettingsFilePath);
                XPathNavigator navigator = xPathDoc.CreateNavigator();

                XPathNodeIterator xPathIterator = navigator.Select("/ScanevaHardwareSettings/IHWCompo");
                foreach (XPathNavigator compoNav in xPathIterator)
                {
                    string name      = compoNav.GetAttribute("Name", "");
                    string className = compoNav.GetAttribute("Class", "");
                    string isEnabled = compoNav.GetAttribute("IsEnabled", "");

                    try
                    {
                        // Create instance if not in HW store already (first load)
                        if (!hwStore.ContainsKey(name))
                        {
                            Type t = availableHWTypes.Values.FirstOrDefault(x => x.Name == className);

                            IHWManager hwInstance = (IHWManager)Activator.CreateInstance(t, log);
                            hwStore.Add(name, hwInstance);
                        }

                        // Load Settings
                        if (hwStore.ContainsKey(name))
                        {
                            // set enabled state
                            hwStore[name].IsEnabled = (isEnabled.ToLower() == "true");

                            ParametrizableObject compo = hwStore[name] as ParametrizableObject;
                            if (compo.GetType().Name == className)
                            {
                                compo.DeserializeParameterValues(compoNav, null);
                                compo.ParameterChanged("Settings Loaded");
                            }
                            else
                            {
                                log.Add("Found settings with name '" + name + "' and class '" + className + "' but no matching component in hwStore. Settings are ignored.", "Warning");
                            }
                        }
                        else
                        {
                            log.Add("Found settings with name '" + name + "' and class '" + className + "' but no matching component in hwStore. Settings are ignored.", "Warning");
                        }
                    }
                    catch (Exception e)
                    {
                        log.Add("Error loading HW Settings for " + name + " - " + e.ToString());
                    }
                }
                XPathNavigator objectNode = navigator.SelectSingleNode("/ScanevaHardwareSettings");
            }
            catch (Exception e)
            {
                log.Add("Error loading HW Settings - " + e.ToString());
            }
        }
Exemple #2
0
        public void AddHardware(string hwName, string hwTypeDisplayName)
        {
            // Create new HW and add to listBox
            Type t = availableHWTypes[hwTypeDisplayName];

            IHWManager hwInstance = (IHWManager)Activator.CreateInstance(t, log);

            (hwInstance as ParametrizableObject).Name = hwName;
            hwStore.Add(hwName, hwInstance);
        }