Пример #1
0
        private void OnSelectProfile(object sender, SelectionChangedEventArgs e)
        {
            if (ProfileBox.SelectedItem == null)
            {
                return;
            }

            MissionProfile selectProfile = _missionProfiles[(string)ProfileBox.SelectedItem];

            CraftBox.Items.Clear();
            CommandBox.Items.Clear();
            PropertyBox.Items.Clear();

            foreach (string craftName in selectProfile.Commands.Keys)
            {
                CraftBox.Items.Add(craftName);
            }

            DateTime launchDate = selectProfile.Config.GetLaunchDate();

            VehicleName.Content   = selectProfile.Config.VehicleType;
            PlanetName.Content    = selectProfile.Config.ParentPlanet;
            PayloadName.Content   = UnitDisplay.Mass(selectProfile.Config.PayloadMass);
            LocalTimeName.Content = $"{launchDate.ToShortDateString()} {launchDate.ToShortTimeString()}";
        }
Пример #2
0
        public MainWindow()
        {
            _missionProfiles = new Dictionary <string, MissionProfile>();

            InitializeComponent();

            var profileLoader = new FlightProfileManager();

            var profiles = profileLoader.GetAllProfiles();

            foreach (string profile in profiles)
            {
                string displayName = Path.GetFileNameWithoutExtension(profile);

                try
                {
                    var missionProfile = new MissionProfile
                    {
                        Config   = MissionConfig.Load(profile),
                        Commands = new Dictionary <string, List <Command> >()
                    };

                    string[] commandFiles = Directory.GetFiles(profile);

                    // Load all the craft mission commands
                    foreach (string commandFile in commandFiles)
                    {
                        if (commandFile.IndexOf("MissionConfig.xml", StringComparison.InvariantCultureIgnoreCase) > 0 ||
                            commandFile.IndexOf("Structures.xml", StringComparison.CurrentCultureIgnoreCase) > 0)
                        {
                            continue;
                        }

                        var commmands = CommandReader.Read(commandFile);

                        missionProfile.Commands.Add(Path.GetFileNameWithoutExtension(commandFile), commmands);
                    }

                    _missionProfiles.Add(displayName, missionProfile);

                    ProfileBox.Items.Add(displayName);
                }
                // Swallow exceptions for broken profiles
                catch { }
            }
        }
Пример #3
0
        private void OnSelectCraft(object sender, SelectionChangedEventArgs e)
        {
            if (ProfileBox.SelectedItem == null)
            {
                return;
            }
            if (CraftBox.SelectedItem == null)
            {
                return;
            }

            MissionProfile selectProfile = _missionProfiles[(string)ProfileBox.SelectedItem];

            List <Command> commands = selectProfile.Commands[(string)CraftBox.SelectedItem];

            CommandBox.Items.Clear();
            PropertyBox.Items.Clear();

            foreach (Command command in commands)
            {
                CommandBox.Items.Add(command);
            }
        }