Пример #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="FavoritesViewViewModel" /> class.
        /// </summary>
        /// <param name="serverWatcher">The used server watcher instance.</param>
        /// <param name="starter">The <see cref="IG2OStarter" /> instance that should be used to start the client.</param>
        /// <param name="resourceManager">
        ///     The instance of the resource manager that should be used to provide resource strings for
        ///     the view.
        /// </param>
        public FavoritesViewViewModel(
            IServerWatcher serverWatcher,
            IG2OStarter starter,
            ResourceManager resourceManager)
            : base(resourceManager)
        {
            if (serverWatcher == null)
            {
                throw new ArgumentNullException(nameof(serverWatcher));
            }

            if (starter == null)
            {
                throw new ArgumentNullException(nameof(starter));
            }

            this.serverWatcher = serverWatcher;
            this.starter       = starter;
            this.serverWatcher.ServerStatusChanged += this.ServerWatcherServerStatusChanged;
            this.Servers = new ObservableCollection <ObservableServerEntry>();

            foreach (var watchedServer in serverWatcher.WatchedServers)
            {
                this.Servers.Add(new ObservableServerEntry(watchedServer));
            }
        }
Пример #2
0
        private Server InitialiseServer(IServerWatcher watcher)
        {
            var client  = new CruiseServerClientMock();
            var monitor = new Server(client, watcher);

            return(monitor);
        }
Пример #3
0
        public StudioController(ObjectExplorerManager mgr, IServerWatcher watcher)
        {
            manager     = mgr;
            _srvWatcher = watcher;
            _srvWatcher.OnServersAdded   += _srvWatcher_OnServersAdded;
            _srvWatcher.OnServersRemoved += _srvWatcher_OnServersRemoved;

            Servers = new Dictionary <IServer, DatabaseLoader>();
        }
Пример #4
0
 public Aria2cServer(IProcessStarter processStarter,
                     IServerValidationRunner serverValidationRunner,
                     Aria2cConfig config,
                     Logger logger,
                     IServerWatcher serverWatcher)
 {
     _processStarter = processStarter;
     _serverValidationRunner = serverValidationRunner;
     _config = config;
     _logger = logger;
     _serverWatcher = serverWatcher;
 }
Пример #5
0
 /// <summary>
 /// Initialise a new <see cref="Server"/> with a watcher and a client.
 /// </summary>
 /// <param name="client">The underlying client.</param>
 /// <param name="watcher">The watcher to use.</param>
 public Server(CruiseServerClientBase client, IServerWatcher watcher)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (watcher == null)
     {
         throw new ArgumentNullException("watcher");
     }
     InitialiseServer(client, watcher, true);
 }
Пример #6
0
 /// <summary>
 /// Initialise a new <see cref="Server"/> with a watcher and a client.
 /// </summary>
 /// <param name="client">The underlying client.</param>
 /// <param name="watcher">The watcher to use.</param>
 /// <param name="settings">The start-up settings to use.</param>
 public Server(CruiseServerClientBase client, IServerWatcher watcher, ClientStartUpSettings settings)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (watcher == null)
     {
         throw new ArgumentNullException("watcher");
     }
     InitialiseServer(client, watcher, settings.FetchVersionOnStartUp);
 }
Пример #7
0
        /// <summary>
        /// Initialise the server.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="watcher"></param>
        /// <param name="fetchVersion">Whether the version number should be fetched or not.</param>
        private void InitialiseServer(CruiseServerClientBase client, IServerWatcher watcher, bool fetchVersion)
        {
            this.watcher         = watcher;
            this.watcher.Update += OnWatcherUpdate;
            this.client          = client;

            if (fetchVersion)
            {
                try
                {
                    client.ProcessSingleAction(s =>
                    {
                        version = new Version(client.GetServerVersion());
                    }, client);
                }
                catch
                {
                    // This means there will be no version for the server
                }
            }
        }
Пример #8
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="App" /> class.
        /// </summary>
        public App()
        {
            AppDomain.CurrentDomain.UnhandledException += this.CurrentDomainUnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += this.CurrentDomainProcessExit;
            if (!this.mutex.WaitOne())
            {
                // The application is already running.
                Environment.Exit(1);
            }

            this.config = this.LoadConfig();
            if (!string.IsNullOrEmpty(this.config.SelectedLanguage))
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(this.config.SelectedLanguage);
            }
            else
            {
                this.config.SelectedLanguage = Thread.CurrentThread.CurrentCulture.Name;
            }

            CultureInfo fallbackCultureInfo = CultureInfo.GetCultureInfo("EN-us");

            this.resourceManager = new ResourceManager(Thread.CurrentThread.CurrentCulture, fallbackCultureInfo);

            this.favoritesServerWatcher = new ServerWatcher(28970, 100, 1000, 2000);
            this.favoritesServerWatcher.Start();

            // Load the saved favorites servers.
            try
            {
                foreach (var favoriteServer in this.config.FavoriteServers)
                {
                    this.favoritesServerWatcher.AddServer(favoriteServer);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(
                    this.resourceManager["resErrorInvalidServerInConfig"].Value,
                    "Invalid server address loaded",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }

            // Registry
            var registry = new RegistryConfig();

            // MainWindowViewModel
            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(
                this.config,
                registry,
                new Updater.Updater(),
                this.resourceManager);

            // NewsViewModel
            NewsViewViewModel newsViewViewModel = new NewsViewViewModel(
                this.resourceManager["resNewsNotLoaded"].Value,
                this.resourceManager);

            // FavoritesViewModel
            FavoritesViewViewModel favoritesViewViewModel = new FavoritesViewViewModel(
                this.favoritesServerWatcher,
                new G2OStarter(registry),
                this.resourceManager);

            // Main window
            MainWindow window = new MainWindow(mainWindowViewModel, newsViewViewModel, favoritesViewViewModel);

            window.Show();
        }
Пример #9
0
 private Server InitialiseServer(IServerWatcher watcher)
 {
     var client = new CruiseServerClientMock();
     var monitor = new Server(client, watcher);
     return monitor;
 }