コード例 #1
0
ファイル: AssignForm.cs プロジェクト: oupa/fsarf
        private List<Aircraft> FindExact(RegistryAircraft reg_ac)
        {
            List<Aircraft> result = new List<Aircraft>();
            string reg_type = ICAO.GetType(reg_ac.icao);
            foreach (Aircraft ac in mainForm.analyzeForm.aircrafts)
            {
                string edited_type = ac.ui_type.Replace(" ", "");
                edited_type = edited_type.Replace("-", "");
                edited_type = edited_type.ToUpper();
                string edited_model = ac.atc_model.Replace(" ", "");
                edited_model = edited_model.Replace("-", "");
                edited_model = edited_model.ToUpper();

                if (
                       (ac.atc_model.Contains(reg_ac.icao) || 
                        ac.ui_type.Contains(reg_ac.icao) || 
                        edited_type.Contains(reg_type) || 
                        edited_model.Contains(reg_type)
                       ) 
                       && reg_ac.icao != "")
                {
                    ac.icao = reg_ac.icao;
                    if (ac.atc_airline.ToUpper() == reg_ac.airline || ac.atc_parking_codes.ToUpper() == reg_ac.airline || ac.texture.ToUpper() == reg_ac.airline)
                    {
                        ac.Fill();
                        Logger.Log("FindExact : " + reg_ac.airline + " / " + reg_ac.icao + " ==> " + ac.title);
                        result.Add(ac);
                    }
                }
            }
            return result;
        }
コード例 #2
0
 public AircraftSelectForm(RegistryAircraft eac, MainForm main)
 {
     InitializeComponent();
     edited_ac = eac;
     mainForm  = main;
     renderManufacturersCombo();
     confirmButton.Enabled = false;
 }
コード例 #3
0
        private void Analyze()
        {
            registry_path = pathTxt.Text;
            RegistryKey key;

            if (registry_type == "LOCAL_MACHINE")
            {
                key = Registry.LocalMachine.OpenSubKey(registry_path);
            }
            else
            {
                key = Registry.CurrentUser.OpenSubKey(registry_path);
            }
            registry_icao      = new List <string>();
            registry_aircrafts = new List <RegistryAircraft>();

            try
            {
                registry_icao.AddRange(key.GetSubKeyNames());

                foreach (string path in registry_icao)
                {
                    RegistryKey ac_key;
                    if (registry_type == "LOCAL_MACHINE")
                    {
                        ac_key = Registry.LocalMachine.OpenSubKey(registry_path + "\\" + path);
                    }
                    else
                    {
                        ac_key = Registry.CurrentUser.OpenSubKey(registry_path + "\\" + path);
                    }
                    foreach (string var in ac_key.GetSubKeyNames())
                    {
                        RegistryAircraft ac      = new RegistryAircraft();
                        RegistryKey      var_key = Registry.LocalMachine.OpenSubKey(registry_path + "\\" + path + "\\" + var);
                        ac.path          = registry_path + "\\" + path + "\\" + var;
                        ac.icao          = path;
                        ac.airline       = var;
                        ac.current_title = (string)var_key.GetValue(null);
                        registry_aircrafts.Add(ac);
                    }
                }
            }
            catch (NullReferenceException) {
                MessageBox.Show("No reference of FSInn registry was found on specified path, sorry");
                return;
            }

            MessageBox.Show("Total " + registry_aircrafts.Count.ToString() + " aircrafts in registry.", "Analysis complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Hide();
            mainForm.Step2Complete();
        }
コード例 #4
0
ファイル: AssignForm.cs プロジェクト: oupa/fsarf
        private List<Aircraft> FindByAirlineAndFamily(RegistryAircraft reg_ac, bool airline_only)
        {
            List<Aircraft> result = new List<Aircraft>();
            foreach (Aircraft ac in mainForm.analyzeForm.aircrafts){
                string reg_family = "";
                string ac_family = "";

                if (!airline_only)
                {
                    try
                    {
                        int min = Math.Min(2, reg_ac.icao.Length);
                        reg_family = reg_ac.icao.Substring(0, min);
                    }
                    catch (NullReferenceException)
                    {
                        return result;
                    }

                    if (ac.atc_model.Length >= 2)
                    {
                        ac_family = ac.atc_model.Substring(0, 2);
                        ac.icao = ac.atc_model;
                    } 
                    if (ac.ui_type.Length >= 2 && ac_family == "")
                    {
                        ac_family = ac.ui_type.Substring(0, 2);
                        ac.icao = ac.ui_type;
                    }
                }
                if ((ac_family == reg_family && ac_family != "" && reg_family != "") || airline_only)
                {
                    if (ac.atc_airline.ToUpper() == reg_ac.airline || ac.atc_parking_codes.ToUpper() == reg_ac.airline || ac.texture.ToUpper() == reg_ac.airline)
                    {
                        ac.Fill();
                        Logger.Log("FindByAirlineAndFamily : " + reg_ac.airline + " / " + reg_ac.icao + " ==> " + ac.title + " / " + airline_only.ToString());
                        result.Add(ac);
                    }
                }
            }

            return result;
        }
コード例 #5
0
ファイル: AssignForm.cs プロジェクト: oupa/fsarf
        private void Search()
        {
            RegistryAircraft reg_ac = mainForm.registryForm.registry_aircrafts[currentIndex];
            Logger.Log(reg_ac.icao + " " + reg_ac.airline);
            List<Aircraft> unsorted = new List<Aircraft>();
            List<Aircraft> result = new List<Aircraft>();

            // filter
            if (reg_ac.current_title != "" && checkNew.Checked) {
                //Logger.Log("Skipping (new filter)");
                SearchNext();
                return;    
            }

            if (checkAirlineFilter.Checked) {
                if (filterAirline.Text.Length > 0) {
                    if (!reg_ac.airline.Contains(filterAirline.Text)) {
                        //Logger.Log("Skipping (AL filter)");
                        SearchNext();
                        return;
                    }
                }
            }

            if (checkFamilyFilter.Checked)
            {
                if (filterIcao.Text.Length > 0)
                {
                    if (!reg_ac.icao.Contains(filterIcao.Text))
                    {
                        //Logger.Log("Skipping (icao filter)");
                        SearchNext();
                        return;
                    }
                }
            }

            //

            unsorted.AddRange(FindExact(reg_ac));

            bool exactMatch = false;
            if (unsorted.Count > 0) exactMatch = true;
            bool resolvedAirlineFamily = false;

            if (unsorted.Count == 0)
            {
                // exact match was not found - will try to search by airline and family (first 3 letters from icao)
                unsorted.AddRange(FindByAirlineAndFamily(reg_ac, false));
                if (result.Count == 0)
                { // nothing was found by airline and family - will search by airline only
                    unsorted.AddRange(FindByAirlineAndFamily(reg_ac, true));
                }
                else {
                    resolvedAirlineFamily = true;
                }
            }

            result.AddRange(SortResult(unsorted, reg_ac.icao));            

            if (result.Count > 1 || (resolvedAirlineFamily && radioButton2.Checked)) {
                if (radioButton1.Checked || (exactMatch && radioButton2.Checked))
                {
                    Aircraft res_ac = result.ElementAt(0);
                    Logger.Log("Automatic choice for " + reg_ac.icao + " / " + reg_ac.airline + " (curr " + reg_ac.current_title + " ) --> " + res_ac.title + " (" + res_ac.match_count + "pts)");
                    reg_ac.new_title = res_ac.title;
                }
                else {
                    string message = result.Count.ToString() + " matches found for " + reg_ac.icao + " / " + reg_ac.airline + "\n";
                    DecideForm decide = new DecideForm(this, message, result);
                    decide.ShowDialog();
                    Aircraft res_ac = result.ElementAt(decideResult);
                    decide.Dispose();
                    Logger.Log("User choice for " + reg_ac.icao + " / " + reg_ac.airline + " (curr " + reg_ac.current_title + " ) --> " + res_ac.title);
                    reg_ac.new_title = res_ac.title;
                }
            }
            else if (result.Count == 1)
            {
                Aircraft res_ac = result.ElementAt(0);
                Logger.Log("One match found for " + reg_ac.icao + " / " + reg_ac.airline + " (curr " + reg_ac.current_title + " ) --> " + res_ac.title);
                reg_ac.new_title = res_ac.title;
            }
            else {
                Logger.Log("No match was found");
            }

            SearchNext();
        }