Example #1
0
 public dlgResolAI(string RemoteAI)
 {
     Initialised = false;
     InitializeComponent();
     tbRemoteAI.Text = RemoteAI;
     m_Mapping       = AIMapping.Instance;
     CategoryList    = m_Mapping.GetCategoryList();
     CategoryList.Insert(0, "*");
     cbCategorie.DataSource = CategoryList;
     EditeurList            = m_Mapping.GetEditeurList();
     EditeurList.Insert(0, "*");
     cbEditeur.DataSource = EditeurList;
     ATCTypeList          = m_Mapping.GetATCTypeList();
     ATCTypeList.Insert(0, "*");
     cbType.DataSource = ATCTypeList;
     ATCModelList      = m_Mapping.GetATCModelList();
     ATCModelList.Insert(0, "*");
     cbModel.DataSource = ATCModelList;
     UpdateAITitreDispo();
     m_ExistingRule = m_Mapping.GetRule(RemoteAI);
     if (m_ExistingRule != "")
     {
         cbAIRemplacement.SelectedIndex = cbAIRemplacement.FindString(m_ExistingRule);
         btnSupprimer.Visible           = true;
     }
     else
     {
         btnSupprimer.Visible = false;
     }
     Initialised = true;
 }
Example #2
0
        /// <summary>
        /// Constructeur du Singleton
        /// </summary>
        private PirepManager()
        {
            DelayedExit    = false;
            DelayReco      = false;
            AutoExit       = false;
            m_SyncAIDone   = false;
            Log            = Logger.Instance;
            LastGoodUpdate = DateTimeEx.UtcNowMilli;
            Mapping        = AIMapping.Instance;
            try
            {
                if ((m_btnConnect = ffs2play.getControl("btnConPirep") as Button) != null)
                {
                    m_btnConnect.Click += btnConPirep_Click;
                }
                else
                {
                    throw new InvalidOperationException("Le bouton btnConPirep n'existe pas");
                }
                if ((m_rtbDecryptedMetar = ffs2play.getControl("rtbDecryptedMetar") as RichTextBox) == null)
                {
                    throw new InvalidOperationException("Le contrôle richttextbox rtbDecryptedMetar n'existe pas");
                }
                if ((m_tbMetar = ffs2play.getControl("tbMetarManuel") as TextBox) == null)
                {
                    throw new InvalidOperationException("Le contrôle tbMetarManuel n'existe pas");
                }
            }
            catch (Exception e)
            {
                Log.LogMessage("Erreur Constructeur PirepManager : " + e.Message);
            }
            m_bConnected             = false;
            m_AIManagement           = false;
            m_sURL                   = "";
            Analyse                  = AnalyseurManager.Instance;
            LiveUpdateTimer          = new System.Timers.Timer(30000);
            LiveUpdateTimer.Elapsed += new ElapsedEventHandler(OnLiveUpdate);
            LiveUpdateTimer.Start();
            ATCTimer          = new System.Timers.Timer(5000);
            ATCTimer.Elapsed += new ElapsedEventHandler(OnATCUpdate);
            SCM = SCManager.Instance;
            P2P = P2PManager.Instance;
            AEStoPHPCryptography aes = new AEStoPHPCryptography();

            aes.GenerateRandomKeys();
            m_sAESKey = aes.EncryptionKeyString;
#if DEBUG
            Log.LogMessage("PManager: AES Key = " + m_sAESKey, Color.DarkRed, 2);
#endif
            ButtonsTips = new ToolTip();
        }
Example #3
0
 /// <summary>
 /// Constructeur d'un PEER P2P
 /// </summary>
 /// <param name="pServer"></param>
 public Peer(ref UDPServer pServer, IPAddress pExternalIP, int pPort, string CallSign, bool pDisabled = false, bool pLocal = false, List <IPAddress> pInternalIP = null)
 {
     m_CallSign   = CallSign;
     P2P          = P2PManager.Instance;
     m_AIMapping  = AIMapping.Instance;
     Server       = pServer;
     m_Data       = new AirData();
     m_OldData    = new AirData();
     m_SendData   = new AirData();
     m_FuturData  = new AirData();
     m_ActualPos  = new AirData();
     m_AIData     = new AIMoveStruct();
     m_ExternalIP = pExternalIP;
     m_InternalIP = pInternalIP;
     m_Port       = pPort;
     Log          = Logger.Instance;
     m_bLocal     = pLocal;
     if (!m_bLocal)
     {
         m_EP = new IPEndPoint(m_ExternalIP, m_Port);
     }
     else
     {
         m_EP = null;
     }
     m_SC             = SCManager.Instance;
     m_Analyseur      = AnalyseurManager.Instance;
     m_PM             = PirepManager.Instance;
     m_FrameRateArray = new List <double>();
     m_bDisabled      = true;
     m_Mutex          = new Mutex();
     m_sel_iplocal    = 0;
     m_TrySimpleAI    = false;
     Disabled         = pDisabled;
     Visible          = false;
     m_bSpawnable     = false;
     m_bBlockData     = false;
 }
Example #4
0
        /// <summary>
        /// Constructeur de la fenêtre principale
        /// </summary>
        public ffs2play()
        {
            // Définition de la culture par défaut
            Thread.CurrentThread.CurrentUICulture = FrenchCulture;
            // LeResourceManager prend en paramètre : nom_du_namespace.nom_de_la_ressource_principale
            RM = new System.Resources.ResourceManager("Localisation.Form1", typeof(ffs2play).Assembly);
            // Initialisation de contenu de la fenêtre
            InitializeComponent();
#if DEBUG
        #if P3D
            Text = "ffs2play P3D (version Debug)";
        #else
            Text = "ffs2play (version Debug)";
        #endif
#else
        #if P3D
            Text = "ffs2play P3D";
        #else
            Text = "ffs2play";
        #endif
#endif
            pInstance = this;
            // Préparation du bouton de connexion au simulateur
            ILConnexionFS.Images.Add(Resources.plane_red);
            ILConnexionFS.Images.SetKeyName(0, "Déconnecté");
            ILConnexionFS.Images.Add(Resources.plane_green);
            ILConnexionFS.Images.SetKeyName(1, "Connecté");
            btnConnectFS.ImageIndex = 0;

            // Préparation du bouton de connexion au serveur web
            ilServeur.Images.Add(Resources.connect2_R);
            ilServeur.Images.SetKeyName(0, "Déconnecté");
            ilServeur.Images.Add(Resources.connect2_V);
            ilServeur.Images.SetKeyName(1, "Connecté");
            btnConPirep.ImageIndex = 0;

            // Configuration par défaut de la fenêtre
            WindowState   = FormWindowState.Normal;
            StartPosition = FormStartPosition.WindowsDefaultBounds;
            SetAllowUnsafeHeaderParsing20();

            // Copy user settings from previous application version if necessary
            settings = Settings.Default;
            if ((bool)settings["UpgradeRequired"] == true)
            {
                // upgrade the settings to the latest version
                settings.Upgrade();

                // clear the upgrade flag
                settings["UpgradeRequired"] = false;
                settings.Save();
            }
            else
            {
                // the settings are up to date
            }
            // On vérifie des les données de taille et de position de la fenêtre ne sont pas vides
            // Et qu'elles sont toujours valides avec la configuration d'écran actuelle
            // Ceci pour éviter une fenêtre en dehors des limites
            if (Properties.Settings.Default.WindowPosition != Rectangle.Empty &&
                IsVisibleOnAnyScreen(Properties.Settings.Default.WindowPosition))
            {
                // Définition de la position et de la taille de la fenêtre
                StartPosition = FormStartPosition.Manual;
                DesktopBounds = Properties.Settings.Default.WindowPosition;

                // Définition de l'état de la fenêtre pour être maximisée
                // ou réduite selon la sauvegarde
                WindowState = Properties.Settings.Default.WindowState;
            }
            else
            {
                // Réinitialisation de la position à la valeur par défaut
                StartPosition = FormStartPosition.WindowsDefaultLocation;

                // Nous pouvons alors définir la taille enrégistrée si celle ci
                // Existe
                if (Properties.Settings.Default.WindowPosition != Rectangle.Empty)
                {
                    Size = Properties.Settings.Default.WindowPosition.Size;
                }
            }
            // Mise à jour de l'option Météo Automatique
            cbEnaAutoWeather.Checked = Settings.Default.MetarAutoEnable;
            // La fenêtre est configurée
            windowInitialized = true;

            log = Logger.Instance;
            log.LogMessage("ffs2play démarré");

            // Creation du contrôleur d'interface avec le simulateur
            scm = SCManager.Instance;

            // Création du contrôleur de mapping des AI

            m_Mapping = AIMapping.Instance;

            // Création du contrôleur d'inteface avec le serveur web
            pm = PirepManager.Instance;

            // Création du contrôleur d'analyse de vol
            Analyse = AnalyseurManager.Instance;

            // Création du contrôleur de connexion P2P
            P2P = P2PManager.Instance;
            if (Properties.Settings.Default.P2PEnable)
            {
                P2P.Init(true);
            }
            AcceptButton = btnSend;
            string[] arguments = Environment.GetCommandLineArgs();
            scm.openConnection();

            //Vérification de la version
            string CheckVersionURL;
#if P3D
            CheckVersionURL = "http://download.ffsimulateur2.fr/ffs2playp3d.php";
#else
            CheckVersionURL = "http://download.ffsimulateur2.fr/ffs2play.php";
#endif
            if (Properties.Settings.Default.Beta)
            {
                CheckVersionURL += "?beta";
            }
            HTTPRequestThread CheckVersion = new HTTPRequestThread(CheckVersionURL, CheckVersionCallBack);

            CheckVersion.Start();
            if (!Properties.Settings.Default.LogVisible)
            {
                scMainWindow.Panel2Collapsed = true;
                scMainWindow.Panel2.Hide();
            }
        }
Example #5
0
        public dlgP2P()
        {
            SCManager sc = SCManager.Instance;

            init = true;
            InitializeComponent();
            AIM = AIMapping.Instance;
#if DEBUG
            cbShadow = new CheckBox();
            gbMultijoueur.Controls.Add(cbShadow);
            //
            // cbShadow
            //
            cbShadow.AutoSize = true;
            cbShadow.Location = new Point(9, 21);
            cbShadow.Name     = "cbShadow";
            cbShadow.Size     = new Size(141, 17);
            cbShadow.TabIndex = 1;
            cbShadow.Text     = "Activer le mode Shadow";
            cbShadow.UseVisualStyleBackColor = true;
            cbShadow.CheckedChanged         += new EventHandler(this.cbShadow_CheckedChanged);
            cbShadow.Checked = Properties.Settings.Default.ShadowEnable;
#endif
            Changes                = false;
            NeedP2PRestart         = false;
            NeedDBReload           = false;
            cbUPNP.Checked         = Properties.Settings.Default.UPNPEnable;
            cbInfoSim.Checked      = Properties.Settings.Default.P2PInfoEnable;
            numPort.Value          = Properties.Settings.Default.P2PPort;
            numP2PTx.Value         = Properties.Settings.Default.P2PRate;
            numAIRayon.Value       = Properties.Settings.Default.P2PRadius;
            numAILimite.Value      = Properties.Settings.Default.P2PAILimite;
            cbBeta.Checked         = Properties.Settings.Default.Beta;
            cbDropRateDisp.Checked = Properties.Settings.Default.EnaDropDisp;
            cbSendDropRate.Checked = Properties.Settings.Default.EnaDropSend;
            btnAppliquer.Enabled   = false;
            btnAppliquer.BackColor = Color.LightGray;
            btnAppliquer.ForeColor = Color.Black;
            UpdateEnable();
            if (PirepManager.Instance.IsConnected())
            {
                numPort.Enabled = false;
            }
            init = false;
            Sim  = sc.GetVersion();
            switch (Sim)
            {
            case SIM_VERSION.UNKNOWN:
                FolderList         = null;
                lvItems.Enabled    = false;
                btnAddItem.Enabled = false;
                btnDelItem.Enabled = false;
                break;

            case SIM_VERSION.FSX:
                gbFSX.Text += "FSX Microsoft";
                FolderList  = Properties.Settings.Default.AIScanFoldersFSX;
                break;

            case SIM_VERSION.FSX_STEAM:
                gbFSX.Text += "FSX Steam Edition";
                FolderList  = Properties.Settings.Default.AIScanFoldersFSXSE;
                break;

            case SIM_VERSION.P3D_V2:
                gbFSX.Text += "Prepar3D V2";
                FolderList  = Properties.Settings.Default.AIScanFoldersP3DV2;
                break;

            case SIM_VERSION.P3D_V3:
                gbFSX.Text += "Prepar3D V3";
                FolderList  = Properties.Settings.Default.AIScanFoldersP3DV3;
                break;

            case SIM_VERSION.P3D_V4:
                gbFSX.Text += "Prepar3D V4";
                FolderList  = Properties.Settings.Default.AIScanFoldersP3DV4;
                break;
            }
            if (FolderList != null)
            {
                foreach (string Path in FolderList)
                {
                    lvItems.Items.Add(Path);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Constructeur du Singleton
        /// </summary>
        private P2PManager()
        {
            Log = Logger.Instance;
#if DEBUG
            Log.LogMessage("P2P Manager : Démarré", Color.Blue, 1);
#endif
            m_Mapper     = AIMapping.Instance;
            Server       = new UDPServer();
            Peers        = new List <Peer>();
            Discoverer   = new NatDiscoverer();
            m_InternalIP = new List <IPAddress>();
            m_SCM        = SCManager.Instance;
            m_Analyseur  = AnalyseurManager.Instance;
            m_Analyseur.OnStateChange += M_Analyseur_OnStateChange;
            CheckAI          = new System.Timers.Timer(5000);
            CheckAI.Elapsed += CheckAI_Elapsed;
            CheckPropertiesData();
            try
            {
                // récupération du pointeur sur le contrôle liste des utilisateurs P2P
                if ((m_lvUsers = ffs2play.getControl("lvUsers") as ListViewEx) == null)
                {
                    throw new InvalidOperationException("La liste lvUsers n'existe pas");
                }
                // récupération du pointeur sur le contrôle liste des détails Peer
                if ((m_lvPeerDetail = ffs2play.getControl("lvPeerDetail") as ListViewEx) == null)
                {
                    throw new InvalidOperationException("La liste lvPeerDetail n'existe pas");
                }
                // récupération du pointeur sur le contrôle liste des utilisateurs P2P
                if ((m_rtbLogChat = ffs2play.getControl("rtbLogChat") as RichTextBox) == null)
                {
                    throw new InvalidOperationException("La zone de tchat rtbLogChat n'existe pas");
                }
            }
            catch (Exception e)
            {
                Log.LogMessage("P2P Manager : Erreur Constructeur = " + e.Message, Color.DarkViolet);
            }
            try
            {
                // Récupératgion de l'adresse IP locale
                IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
                foreach (IPAddress ip in host.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        m_InternalIP.Add(ip);
#if DEBUG
                        Log.LogMessage("P2PManager: IP locale trouvée  = " + ip.ToString(), Color.DarkBlue, 1);
#endif
                    }
                }
                if (m_InternalIP.Count == 0)
                {
                    throw new Exception("IP Locale introuvable");
                }
            }
            catch (Exception e)
            {
                Log.LogMessage("P2P Manager : Erreur Constructeur = " + e.Message, Color.DarkViolet);
            }
            m_lvUsers.SelectedIndexChanged += M_lvUsers_SelectedIndexChanged;
            m_lvUsers.MouseClick           += M_lvUsers_MouseClick;
            m_lvUsers.ItemSelectionChanged += M_lvUsers_ItemSelectionChanged;
        }