Пример #1
0
        public ServerListViewModel()
        {
            if (!System.IO.Directory.Exists(ArmaBrowserAddonFolder))
            {
                System.IO.Directory.CreateDirectory(ArmaBrowserAddonFolder);
            }

            UpdateAvailable = new UpdateAvailableViewModel();
            UpdateAvailable.CheckForNewReleases().Wait(0);

            _version = this.GetType().Assembly.GetName().Version.ToString();

            UiTask.Initialize();
            _context = new LogicContext();
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }

            _context.ServerItems.CollectionChanged += _serverItems_CollectionChanged;
            _context.PropertyChanged += Context_PropertyChanged;

            TextFilter        = Properties.Settings.Default.TextFilter;
            _selectedEndPoint = Properties.Settings.Default.LastPlayedHost;

            LookForInstallation();

            string[]      recentlyHosts       = Properties.Settings.Default.RecentlyHosts.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Reverse().ToArray();
            IServerItem[] recentlyServerItems = _context.AddServerItems(recentlyHosts);
            foreach (var item in recentlyServerItems)
            {
                item.LastPlayed = DateTime.Now;
            }
            var refreshRecentlyServerItemsTask = _context.RefreshServerInfoAsync(recentlyServerItems);

            refreshRecentlyServerItemsTask.ContinueWith((t, o) => ServerItemsView.Refresh(), null, TaskScheduler.FromCurrentSynchronizationContext());

            Task.Run((Action)EndlessRefreshSelecteItem);
        }