Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            Title           = "Axodox " + UpdaterResources.Title;
            RUpdater.Text   = UpdaterResources.Title;
            TBProgress.Text = UpdaterResources.Connecting;

            AnimColors = new Color[] {
                Colors.White,
                Color.FromRgb(255, 221, 0),
                Color.FromRgb(255, 162, 0),
                Color.FromRgb(238, 19, 23),
                Color.FromRgb(242, 7, 117),
                Color.FromRgb(240, 15, 236),
                Color.FromRgb(154, 15, 240),
                Color.FromRgb(21, 38, 228),
                Color.FromRgb(0, 149, 249),
                Color.FromRgb(0, 249, 187),
                Color.FromRgb(37, 239, 15),
                Color.FromRgb(168, 239, 15),
                Color.FromRgb(255, 221, 0)
            };
            StartAnimation();

            ExitTimer          = new DispatcherTimer();
            ExitTimer.Tick    += ExitTimer_Tick;
            ExitTimer.Interval = new TimeSpan(0, 0, 1);

            StringDictionary settings = LoadSettings("Updater.ini");

            Server          = settings["Server"];
            Application     = settings["Application"];
            PostSetupAction = settings["PostSetupAction"];
            string excludedFiles = settings["ExcludedFiles"];

            if (excludedFiles != null)
            {
                string[] files = excludedFiles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                ProtectedFiles.AddRange(files);
            }

            if (Server == null || Application == null || PostSetupAction == null)
            {
                ToErrorState(UpdaterResources.UpdaterIniMissingOrCorrupt);
                return;
            }
            ProtectedFiles.Add("AxodoxUpdater.application");
            ProtectedFiles.Add("AxodoxUpdater.exe");
            ProtectedFiles.Add("AxodoxUpdater.exe.config");
            ProtectedFiles.Add("AxodoxUpdater.exe.manifest");
            ProtectedFiles.Add("Updater.ini");
            ProtectedFiles.Add("hu-HU//AxodoxUpdater.resources.dll");
            Success = false;
            WC      = new WebClient();
            WC.DownloadStringCompleted += WC_DownloadStringCompleted;
            UpdateState = UpdateStates.Connecting;
            SC          = SynchronizationContext.Current;
            Root        = Assembly.GetExecutingAssembly().Location;
            Root        = Root.Remove(Root.LastIndexOf('\\'));
            rootLength  = Root.Length;
            WC.DownloadStringAsync(new Uri(Server + "update.php?app=" + Application, UriKind.Absolute));
            WC.DownloadFileCompleted   += WC_DownloadFileCompleted;
            WC.DownloadProgressChanged += WC_DownloadProgressChanged;
        }