Ejemplo n.º 1
0
        public MainWindow(string[] args)
        {
            InitializeComponent();

            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            _nzbDrive = new NZBDriveDLL.NZBDrive();

            _nzbDrive.LogLevel = NZBDriveDLL.LogLevelType.Info;

            this.Closing += MainWindow_Closing;

            _nzbDrive.EventLog += _nzbDrive_EventLog;

            _model             = new NZBDriveModel(_nzbDrive);
            this.DataContext   = _model;
            NZBDriveView.Model = _model;
            StatusBox.Status   = _model.Status;
            ToolBar.Model      = _model;

            _nzbDrive.ConnectionStateChanged += _nzbDrive_ConnectionStateChanged;
            _nzbDrive.NZBFileOpen            += _nzbDrive_NZBFileOpen;
            _nzbDrive.NZBFileClose           += _nzbDrive_NZBFileClose;
            _nzbDrive.FileAdded               += _nzbDrive_FileAdded;
            _nzbDrive.FileRemoved             += _nzbDrive_FileRemoved;
            _nzbDrive.FileInfo                += _nzbDrive_FileInfo;
            _nzbDrive.FileSegmentStateChanged += _nzbDrive_FileSegmentStateChanged;
            _nzbDrive.ConnectionInfo          += _nzbDrive_ConnectionInfo;
            _model.MountStatusHandle          += _model_MountStatus;

            NZBDriveSettings.Load(_model);

            _model.SettingsChanged += model_SettingsChanged;

            this.ContentRendered += MainWindow_ContentRendered;

            _pipe = new NamedPipeServerStream("NZBDriveApplicationPipe", PipeDirection.In,
                                              254, PipeTransmissionMode.Message, PipeOptions.Asynchronous);

            _pipeCallback = new AsyncCallback(PipedConnectionCallBack);
            _pipe.BeginWaitForConnection(_pipeCallback, this);

            _model.Mount(args);
        }
Ejemplo n.º 2
0
 void model_SettingsChanged(object sender)
 {
     NZBDriveSettings.Save(_model);
 }