Пример #1
0
        public LoginForm()
        {
            InitializeComponent();

            initIndicator.Visibility = Visibility.Hidden;
            _webClientFactory        = new WebClientFactory();
            _xmlhelper = new XmlHelper();
            _web       = _webClientFactory.Create();
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            #region SET VISIBILITY ELEMENTS

            SetVisibilityToHotNewsBlock(false);
            ProgressBar1.Visibility  = Visibility.Hidden;
            bannersLoader.Visibility = Visibility.Hidden;
            initIndicator.Visibility = Visibility.Hidden;

            #endregion

            #region Конфиги Mysql и игровые
            _webClientFactory = new WebClientFactory();
            _web = _webClientFactory.Create();

            var mySqlConfig = new IpPortConfig
            {
                Ip   = Settings.Default.mysql_ip,
                Port = Settings.Default.mysql_port
            };
            var worldConfig = new IpPortConfig
            {
                Ip   = Settings.Default.world_ip,
                Port = Settings.Default.world_port
            };
            #endregion

            #region ADRESSET (Логика для использования функций серверной части)

            var addressSet = new AddressSet
            {
                ServerPid         = UrlHelper.Combine(Settings.Default.update_folder, Wow.FileName.PID_FILE_NAME),
                ServerPidClientPt = UrlHelper.Combine(Settings.Default.down_client_pt, Wow.FileName.PID_FILE_NAME),
                ServerPidClientEn = UrlHelper.Combine(Settings.Default.down_client_en, Wow.FileName.PID_FILE_NAME),

                ServerPatchFile = Settings.Default.patchlist,
                //ServerFilesRoot = Settings.Default.update_folder,

                HotNews        = string.Format(Settings.Default.api_url + "?_key={0}&_url=hot_news", Settings.Default.skey_api),
                LoadBannerNews = string.Format(Settings.Default.api_url + "?_key={0}&_url=news", Settings.Default.skey_api),
            };

            #endregion

            _addressSet  = addressSet;
            _mySqlConfig = mySqlConfig;
            _worldConfig = worldConfig;
            _xmlhelper   = new XmlHelper();

            var    ClientLocation = LocalConfiguration.Instance.Files.ConfDataFile;
            string rootDirectory  = _xmlhelper.GetSettingValue("realm1_client_location");
            string localPidFile   = Path.Combine(rootDirectory, Wow.FileName.PID_FILE_NAME);

            #region IF PATH TO GAME EXISTS - CHECK AN UPDATE
            if (rootDirectory != "")
            {
                string langApp = _xmlhelper.GetSettingValue("client_lang");
                switch (langApp)
                {
                case "pt":
                    string ServerFilesRootPT = Settings.Default.down_client_pt;
                    string ServerPatchFilePt = Settings.Default.down_client_pt_patch;

                    _updater = new WowUpdater(rootDirectory, addressSet.ServerPidClientPt, localPidFile, ServerPatchFilePt, ServerFilesRootPT);
                    _updater.UpdateProgressChanged += Updater_UpdateProgressChanged;
                    _updater.UpdateStateChanged    += Updater_UpdateStateChanged;
                    _updater.UpdateDownloadInfo    += Updater_UpdateInfoChanged;
                    break;

                case "en":
                    string ServerFilesRootEN = Settings.Default.down_client_en;
                    string ServerPatchFileEn = Settings.Default.down_client_en_patch;
                    _updater = new WowUpdater(rootDirectory, addressSet.ServerPidClientEn, localPidFile, ServerPatchFileEn, ServerFilesRootEN);
                    _updater.UpdateProgressChanged += Updater_UpdateProgressChanged;
                    _updater.UpdateStateChanged    += Updater_UpdateStateChanged;
                    _updater.UpdateDownloadInfo    += Updater_UpdateInfoChanged;
                    break;

                default:
                    break;
                }


                this.WelcomeBlock.HideBlock();
            }
            else
            {
                this.WelcomeBlock.ShowBlock();
                playButton.Visibility = Visibility.Hidden;
            }
            #endregion

            #region LAUNCHER LOGIC

            _launcher = new LauncherLogic(addressSet, mySqlConfig, worldConfig);

            #endregion
        }