/// <summary>
        /// Loads the UIConfigurationNea from its default path.
        /// </summary>
        /// <returns></returns>
        public static UIConfigurationNea Load()
        {
            string configFile = Path.Combine(Utilities.GetLocalAppDataFolderPath(), "IlsAnsbachNeaOperationViewerConfig.xml");
            if (!File.Exists(configFile))
            {
                return new UIConfigurationNea();
            }

            UIConfigurationNea configuration = new UIConfigurationNea();

            XDocument doc = XDocument.Load(configFile);

            XElement vehicleE = doc.Root.Element("Vehicles");
            configuration.VehicleMustContainAbbreviations = vehicleE.Attribute("MustContainAbbreviations").Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (XElement resE in vehicleE.Elements("Vehicle"))
            {
                Vehicle vehicle = new Vehicle();
                vehicle.Identifier = resE.Attribute("Identifier").Value;
                vehicle.Name = resE.Attribute("Name").Value;

                // Try to parse shortkey
                string shortkeyS = resE.TryGetAttributeValue("Shortkey", null);
                if (!string.IsNullOrWhiteSpace(shortkeyS))
                {
                    Key shortkey = Key.None;
                    Enum.TryParse<Key>(shortkeyS, true, out shortkey);
                    vehicle.Shortkey = shortkey;
                }

                string imagePath = resE.Attribute("Image").Value;
                FileInfo imageFile = null;
                if (!Path.IsPathRooted(imagePath))
                {
                    imageFile = new FileInfo(Path.Combine(Utilities.GetLocalAppDataFolderPath(), imagePath));
                }
                else
                {
                    imageFile = new FileInfo(imagePath);
                }
                vehicle.Image = imageFile.FullName;

                configuration.Vehicles.Add(vehicle);
            }

            return configuration;
        }
Example #2
0
        /// <summary>
        /// Loads the UIConfigurationNea from its default path.
        /// </summary>
        /// <returns></returns>
        public static UIConfigurationNea Load()
        {
            string configFile = Path.Combine(Utilities.GetWorkingDirectory(Assembly.GetExecutingAssembly()), "Config\\IlsAnsbachNeaOperationViewerConfig.xml");

            if (configFile == null)
            {
                return(null);
            }

            UIConfigurationNea configuration = new UIConfigurationNea();

            XDocument doc = XDocument.Load(configFile);

            XElement vehicleE = doc.Root.Element("Vehicles");

            configuration.VehicleMustContainAbbreviations = vehicleE.Attribute("MustContainAbbreviations").Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (XElement resE in vehicleE.Elements("Vehicle"))
            {
                Vehicle vehicle = new Vehicle();
                vehicle.Identifier = resE.Attribute("Identifier").Value;
                vehicle.Name       = resE.Attribute("Name").Value;

                // Try to parse shortkey
                string shortkeyS = resE.TryGetAttributeValue("Shortkey", null);
                if (!string.IsNullOrWhiteSpace(shortkeyS))
                {
                    Key shortkey = Key.None;
                    Enum.TryParse <Key>(shortkeyS, true, out shortkey);
                    vehicle.Shortkey = shortkey;
                }

                FileInfo imageFile = new FileInfo(Path.Combine(Utilities.GetWorkingDirectory(Assembly.GetExecutingAssembly()), resE.Attribute("Image").Value));
                vehicle.Image = imageFile.FullName;

                configuration.Vehicles.Add(vehicle);
            }

            return(configuration);
        }
        /// <summary>
        /// Loads the UIConfigurationNea from its default path.
        /// </summary>
        /// <returns></returns>
        public static UIConfigurationNea Load()
        {
            string configFile = Path.Combine(Utilities.GetWorkingDirectory(Assembly.GetExecutingAssembly()), "Config\\IlsAnsbachNeaOperationViewerConfig.xml");
            if (configFile == null)
            {
                return null;
            }

            UIConfigurationNea configuration = new UIConfigurationNea();

            XDocument doc = XDocument.Load(configFile);

            XElement vehicleE = doc.Root.Element("Vehicles");
            configuration.VehicleMustContainAbbreviations = vehicleE.Attribute("MustContainAbbreviations").Value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            foreach (XElement resE in vehicleE.Elements("Vehicle"))
            {
                Vehicle vehicle = new Vehicle();
                vehicle.Identifier = resE.Attribute("Identifier").Value;
                vehicle.Name = resE.Attribute("Name").Value;

                // Try to parse shortkey
                string shortkeyS = resE.TryGetAttributeValue("Shortkey", null);
                if (!string.IsNullOrWhiteSpace(shortkeyS))
                {
                    Key shortkey = Key.None;
                    Enum.TryParse<Key>(shortkeyS, true, out shortkey);
                    vehicle.Shortkey = shortkey;
                }

                FileInfo imageFile = new FileInfo(Path.Combine(Utilities.GetWorkingDirectory(Assembly.GetExecutingAssembly()), resE.Attribute("Image").Value));
                vehicle.Image = imageFile.FullName;

                configuration.Vehicles.Add(vehicle);
            }

            return configuration;
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IlsAnsbachNeaViewModel"/> class.
        /// </summary>
        /// <param name="configuration"></param>
        public IlsAnsbachNeaViewModel(UIConfigurationNea configuration)
        {
            _configuration = configuration;

            _manuallyDeployedVehicles = new ObservableCollection <ResourceViewModel>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IlsAnsbachNeaViewModel"/> class.
        /// </summary>
        /// <param name="configuration"></param>
        public IlsAnsbachNeaViewModel(UIConfigurationNea configuration)
        {
            _configuration = configuration;

            _manuallyDeployedVehicles = new ObservableCollection<ResourceViewModel>();
        }