Exemplo n.º 1
0
        public MainWindowViewModel(Window owner)
        {
            this.owner = owner;
              // Set up application data and log folders
              string appDataPath = Utils.AppDataFolder;
              if (!Directory.Exists(appDataPath))
            Directory.CreateDirectory(appDataPath);
              string logPath = Path.Combine(appDataPath, "logs");
              if (!Directory.Exists(logPath))
            Directory.CreateDirectory(logPath);
              LogFile.Open(Path.Combine(logPath, "disParity.log"), false);
              LogFile.Log("Application launched (version {0})", disParity.Version.VersionString);

              updateTimer = new System.Timers.Timer(1000);
              updateTimer.AutoReset = true;
              updateTimer.Elapsed += HandleUpdateTimer;

              updateParityStatusTimer = new System.Timers.Timer(1000);
              updateParityStatusTimer.AutoReset = true;
              updateParityStatusTimer.Elapsed += UpdateParityStatus;

              pingTimer = new System.Timers.Timer(TimeSpan.FromHours(24).TotalMilliseconds);
              pingTimer.AutoReset = true;
              pingTimer.Elapsed += HandlePingTimer;

              operationManager = new OperationManager(this);
              operationManager.OperationFinished += HandleOperationFinished;

              // Try to load the config.xml now, we need it to set the main window position.
              // If it fails, use default values for everything and display a dialog in Loaded()
              try {
            config = new Config(Path.Combine(Utils.AppDataFolder, "Config.xml"));
            if (config.Exists) {
              config.Load();
              config.Validate();
            }
              }
              catch (Exception e) {
            configLoadException = e;
            config.MakeBackup();
            config.Reset();
              }

              Left = config.MainWindowX;
              Top = config.MainWindowY;
              Height = config.MainWindowHeight;
              Width = config.MainWindowWidth;
        }
Exemplo n.º 2
0
 public OperationManager(MainWindowViewModel vm)
 {
     this.vm  = vm;
     instance = this;
 }
Exemplo n.º 3
0
 public OperationManager(MainWindowViewModel vm)
 {
     this.vm = vm;
       instance = this;
 }