示例#1
0
 public void WxClear(Microsoft.FlightSimulator.SimConnect.SimConnect simconnect)
 {
     simconnect.WeatherSetModeGlobal();
     simconnect.WeatherSetModeTheme("");
     simconnect.WeatherSetModeCustom();
     simconnect.WeatherSetDynamicUpdateRate(0U);
     Thread.Sleep(1000);
 }
示例#2
0
        public string WxInject(Microsoft.FlightSimulator.SimConnect.SimConnect simconnect, List <WxGridClass.wxStruct> wxGrid, Form1.dataPosStruct acPos, string type, double radius, int maxstations, uint seconds, bool firstInject)
        {
            List <WxGridClass.wxStruct> source1 = new List <WxGridClass.wxStruct>();

            WxGridClass.wxStruct wxStruct1 = new WxGridClass.wxStruct();
            bool   flag1 = false;
            bool   flag2 = false;
            int    num1  = 0;
            int    millisecondsTimeout = 0;
            string str1 = (string)this._regKeys.GetValue("EzdokGlobalEnable");
            string str2 = "Injection mode: " + type + " - ";

            foreach (WxGridClass.wxStruct wxStruct2 in wxGrid)
            {
                WxGridClass.wxStruct wxStruct3 = wxStruct2;
                wxStruct3.dist_from_ac = GeoClass.Dist(acPos.lat, acPos.lon, (double)wxStruct2.lat, (double)wxStruct2.lon);
                if (wxStruct3.dist_from_ac <= radius)
                {
                    source1.Add(wxStruct3);
                }
            }
            List <WxGridClass.wxStruct> source2 = source1.OrderBy <WxGridClass.wxStruct, double>((Func <WxGridClass.wxStruct, double>)(o => o.dist_from_ac)).ToList <WxGridClass.wxStruct>();

            if (!(type == "ovconly"))
            {
                if (!(type == "ovcdist"))
                {
                    if (!(type == "ovctime"))
                    {
                        if (!(type == "ovcgrnd"))
                        {
                            if (!(type == "all"))
                            {
                                return("Invalid injection type");
                            }
                            flag1 = true;
                            flag2 = true;
                            millisecondsTimeout = 5000;
                        }
                        else
                        {
                            num1 = 1;
                            foreach (WxGridClass.wxStruct wxStruct2 in source2)
                            {
                                str2 = str2 + wxStruct2.station_id + " nearby - ";
                                Regex regex = new Regex("\\b[345678](AS|CU)(\\d\\d\\d)", RegexOptions.Compiled);
                                if (regex.Matches(wxStruct2.sky_fsx_smooth).Count > 0 && Convert.ToInt32(regex.Match(wxStruct2.sky_fsx_smooth).Groups[2].Value) < 100)
                                {
                                    str2  = str2 + regex.Match(wxStruct2.sky_fsx_smooth).Groups[0].ToString() + " - ";
                                    flag1 = true;
                                    flag2 = false;
                                    millisecondsTimeout = 0;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        num1 = 1;
                        double num2 = (double)GeoClass.BearingSub((int)acPos.hdg, 100);
                        double num3 = (double)GeoClass.BearingAdd((int)acPos.hdg, 100);
                        foreach (WxGridClass.wxStruct wxStruct2 in source2)
                        {
                            double num4 = GeoClass.DegreeBearing(acPos.lat, acPos.lon, (double)wxStruct2.lat, (double)wxStruct2.lon);
                            if (num3 > num2 && num4 >= num2 && num4 <= num3 || num3 < num2 && (num4 >= num2 || num4 <= num3))
                            {
                                str2 = str2 + wxStruct2.station_id + " ahead - ";
                                Regex regex = new Regex("\\b[345678](AS|CU)(\\d\\d\\d)", RegexOptions.Compiled);
                                if (regex.Matches(wxStruct2.sky_fsx_smooth).Count > 0 && Convert.ToInt32(regex.Match(wxStruct2.sky_fsx_smooth).Groups[2].Value) < 100)
                                {
                                    str2  = str2 + regex.Match(wxStruct2.sky_fsx_smooth).Groups[0].ToString() + " - ";
                                    flag1 = true;
                                    flag2 = false;
                                    millisecondsTimeout = 0;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    num1 = 1;
                    double num2 = (double)GeoClass.BearingSub((int)acPos.hdg, 100);
                    double num3 = (double)GeoClass.BearingAdd((int)acPos.hdg, 100);
                    foreach (WxGridClass.wxStruct wxStruct2 in source2)
                    {
                        double num4 = GeoClass.DegreeBearing(acPos.lat, acPos.lon, (double)wxStruct2.lat, (double)wxStruct2.lon);
                        if (num3 > num2 && num4 >= num2 && num4 <= num3 || num3 < num2 && (num4 >= num2 || num4 <= num3))
                        {
                            str2 = str2 + wxStruct2.station_id + " ahead - ";
                            Regex regex = new Regex("\\b[5678](AS|CU)(\\d\\d\\d)", RegexOptions.Compiled);
                            if (regex.Matches(wxStruct2.sky_fsx_smooth).Count > 0 && Convert.ToInt32(regex.Match(wxStruct2.sky_fsx_smooth).Groups[2].Value) < 100)
                            {
                                str2  = str2 + regex.Match(wxStruct2.sky_fsx_smooth).Groups[0].ToString() + " - ";
                                flag1 = true;
                                flag2 = false;
                                millisecondsTimeout = 0;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                List <WxGridClass.wxStruct> wxStructList = new List <WxGridClass.wxStruct>();
                num1 = 1;
                double num2 = (double)GeoClass.BearingSub((int)acPos.hdg, 100);
                double num3 = (double)GeoClass.BearingAdd((int)acPos.hdg, 100);
                foreach (WxGridClass.wxStruct wxStruct2 in source2)
                {
                    double num4 = GeoClass.DegreeBearing(acPos.lat, acPos.lon, (double)wxStruct2.lat, (double)wxStruct2.lon);
                    if (num3 > num2 && num4 >= num2 && num4 <= num3 || num3 < num2 && (num4 >= num2 || num4 <= num3))
                    {
                        str2 = str2 + wxStruct2.station_id + " ahead - ";
                        Regex regex = new Regex("\\b[5678](AS|CU)(\\d\\d\\d)", RegexOptions.Compiled);
                        if (regex.Matches(wxStruct2.sky_fsx_smooth).Count > 0 && Convert.ToInt32(regex.Match(wxStruct2.sky_fsx_smooth).Groups[2].Value) < 100)
                        {
                            str2  = str2 + regex.Match(wxStruct2.sky_fsx_smooth).Groups[0].ToString() + " - ";
                            flag1 = true;
                            flag2 = false;
                            millisecondsTimeout = 0;
                            wxStructList.Add(wxStruct2);
                        }
                    }
                }
                source2.Clear();
                source2 = wxStructList;
            }
            int num5 = 0;

            foreach (WxGridClass.wxStruct wxStruct2 in source2)
            {
                if (!this._createdWxStations.Contains(wxStruct2.station_id))
                {
                    simconnect.WeatherCreateStation((Enum)Form1.DATA_REQUESTS.WEATHERSTATIONNEW, wxStruct2.station_id, wxStruct2.station_id, wxStruct2.lat, wxStruct2.lon, (float)(wxStruct2.elevation_m + 60));
                    this._createdWxStations.Add(wxStruct2.station_id);
                    this._removedWxStations.Remove(wxStruct2.station_id);
                    ++num5;
                }
            }
            string str3 = str2 + num5.ToString() + " new stations created - ";

            if (str1 == "" | firstInject)
            {
                flag2 = false;
            }
            if (flag1)
            {
                if (flag2)
                {
                    Process.Start(this._ezdokExe);
                    str3 += "EZdok disabled - ";
                }
                if (source2.Count > maxstations)
                {
                    source2 = source2.GetRange(0, maxstations);
                }
                List <WxGridClass.wxStruct> list = source2.OrderBy <WxGridClass.wxStruct, string>((Func <WxGridClass.wxStruct, string>)(o => o.station_id)).ToList <WxGridClass.wxStruct>();
                for (int index = 0; index <= num1; ++index)
                {
                    num5 = 0;
                    foreach (WxGridClass.wxStruct wxStruct2 in list)
                    {
                        simconnect.WeatherSetObservation(seconds, wxStruct2.fsx);
                        ++num5;
                    }
                }
                if (flag2)
                {
                    Thread.Sleep(millisecondsTimeout);
                    Process.Start(this._ezdokExe);
                }
            }
            string str4 = str3 + num5.ToString() + " stations injected" + (num1 > 0 ? " - " + num1.ToString() + " repeats" : "");

            simconnect.WeatherSetDynamicUpdateRate(0U);
            return(str4);
        }