Beispiel #1
0
    public ClientManager()
    {
        Instance = this;

        InitializeComponent();

        // Check the directories exist
        if (!Directory.Exists(Settings.Default.LibraryPath) || !Directory.Exists(Settings.Default.LibraryPath + @"\backgrounds\"))
        {
            // Will handle the create of everything here
            Directory.CreateDirectory(Settings.Default.LibraryPath + @"\backgrounds");
            Directory.CreateDirectory(Settings.Default.LibraryPath + @"\Layouts");
            Directory.CreateDirectory(Settings.Default.LibraryPath + @"\Uploads\Media");
        }

        // Create a cachemanager
        SetCacheManager();

        ShowSplashScreen();

        // Change the default Proxy class
        OptionForm.SetGlobalProxy();

        Closed += delegate
        {
            Closing();
            Environment.Exit(0);

        };

        MyCommand.InputGestures.Add(new KeyGesture(Key.Q, ModifierKeys.Control));

        CommandBindings.Add(new CommandBinding(MyCommand, MyCommandExecuted));

        InitializeComponent();

        Switcher.ClientManager = this;


        Switcher.Switch(AdvertPlayer.Instance);

      var customerPage=  CustomerPage.Instance;

      // Setup the proxy information
      OptionForm.SetGlobalProxy();

      _statLog = new StatLog();

        this.StartKeepAliveThread();

        this.StartMessageReceiveThread();

        try
        {
            // Create the Schedule
            _schedule = new Schedule(App.UserAppDataPath + "\\" + Settings.Default.ScheduleFile, ClientManager.Instance.CacheManager);

            // Bind to the schedule change event - notifys of changes to the schedule
            _schedule.ScheduleChangeEvent += ScheduleScheduleChangeEvent;

            // Initialize the other schedule components
            _schedule.InitializeComponents();
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message, LogType.Error.ToString());
            MessageBox.Show("Fatal Error initialising AdvertPlayer", "Fatal Error");

            Environment.Exit(0);
        }

    }