예제 #1
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();
        }
예제 #2
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;
 }
예제 #3
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();
            }
        }
예제 #4
0
        private void ApplyChanges()
        {
            if (!Changes)
            {
                return;
            }
            if (cbUPNP.Checked != Properties.Settings.Default.UPNPEnable)
            {
                Properties.Settings.Default.UPNPEnable = cbUPNP.Checked;
            }
            if (cbInfoSim.Checked != Properties.Settings.Default.P2PInfoEnable)
            {
                Properties.Settings.Default.P2PInfoEnable = cbInfoSim.Checked;
            }
#if DEBUG
            if (cbShadow.Checked != Properties.Settings.Default.ShadowEnable)
            {
                Properties.Settings.Default.ShadowEnable = cbShadow.Checked;
            }
#endif
            if (cbDropRateDisp.Checked != Properties.Settings.Default.EnaDropDisp)
            {
                Properties.Settings.Default.EnaDropDisp = cbDropRateDisp.Checked;
            }
            if (cbSendDropRate.Checked != Properties.Settings.Default.EnaDropSend)
            {
                Properties.Settings.Default.EnaDropSend = cbSendDropRate.Checked;
            }
            if (numPort.Value != Properties.Settings.Default.P2PPort)
            {
                Properties.Settings.Default.P2PPort = (ushort)numPort.Value;
            }
            if (numP2PTx.Value != Properties.Settings.Default.P2PRate)
            {
                Properties.Settings.Default.P2PRate = (ushort)numP2PTx.Value;
            }
            if (numAIRayon.Value != Properties.Settings.Default.P2PRadius)
            {
                Properties.Settings.Default.P2PRadius = (ushort)numAIRayon.Value;
            }
            if (numAILimite.Value != Properties.Settings.Default.P2PAILimite)
            {
                Properties.Settings.Default.P2PAILimite = (int)numAILimite.Value;
            }
            if (NeedP2PRestart)
            {
                P2PManager P2P = P2PManager.Instance;
                P2P.Init(false);
                if (Properties.Settings.Default.P2PEnable)
                {
                    P2P.Init(true);
                }
                NeedP2PRestart = false;
            }
            if (NeedDBReload)
            {
                if (FolderList != null)
                {
                    FolderList.Clear();
                    foreach (ListViewItem item in lvItems.Items)
                    {
                        FolderList.Add(item.Text);
                    }
                    //AIM.CleanAIDB();
                    AIM.StartScanSimObject();
                }
            }
            if (cbBeta.Checked != Properties.Settings.Default.Beta)
            {
                Properties.Settings.Default.Beta = cbBeta.Checked;
            }
            Properties.Settings.Default.Save();
            Changes = false;
            btnAppliquer.Enabled   = false;
            btnAppliquer.BackColor = Color.LightGray;
            btnAppliquer.ForeColor = Color.Black;
        }