コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: Nirklav/TCPChat
        public MainViewModel(MainWindow mainWindow)
            : base(null, true)
        {
            window = mainWindow;
              window.Closed += WindowClosed;
              Rooms = new ObservableCollection<RoomViewModel>();
              Plugins = new ObservableCollection<PluginViewModel>();
              Dispatcher = mainWindow.Dispatcher;

              KeyBoard.KeyDown += OnKeyDown;
              KeyBoard.KeyUp += OnKeyUp;

              NotifierContext.Connected += CreateSubscriber<ConnectEventArgs>(ClientConnect);
              NotifierContext.ReceiveMessage += CreateSubscriber<ReceiveMessageEventArgs>(ClientReceiveMessage);
              NotifierContext.ReceiveRegistrationResponse += CreateSubscriber<RegistrationEventArgs>(ClientRegistration);
              NotifierContext.RoomClosed += CreateSubscriber<RoomEventArgs>(ClientRoomClosed);
              NotifierContext.RoomOpened += CreateSubscriber<RoomEventArgs>(ClientRoomOpened);
              NotifierContext.AsyncError += CreateSubscriber<AsyncErrorEventArgs>(ClientAsyncError);
              NotifierContext.PluginLoaded += CreateSubscriber<PluginEventArgs>(ClientPluginLoaded);
              NotifierContext.PluginUnloading += CreateSubscriber<PluginEventArgs>(ClientPluginUnloading);

              EnableServerCommand = new Command(EnableServer, _ => !ServerModel.IsInited && !ClientModel.IsInited);
              DisableServerCommand = new Command(DisableServer, _ => ServerModel.IsInited);
              ConnectCommand = new Command(Connect, _ => !ClientModel.IsInited);
              DisconnectCommand = new Command(Disconnect, _ => ClientModel.IsInited);
              ExitCommand = new Command(_ => window.Close());
              CreateRoomCommand = new Command(CreateRoom, _ => ClientModel.IsInited);
              DeleteRoomCommand = new Command(DeleteRoom, _ => ClientModel.IsInited);
              ExitFromRoomCommand = new Command(ExitFromRoom, _ => ClientModel.IsInited);
              OpenFilesDialogCommand = new Command(OpenFilesDialog, _ => ClientModel.IsInited);
              OpenAboutProgramCommand = new Command(OpenAboutProgram);
              OpenSettingsCommand = new Command(OpenSettings);

              ClearTabs();
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: Nowsoud/TCPChat
        public MainViewModel(MainWindow mainWindow)
            : base(true)
        {
            window = mainWindow;
              window.Closed += WindowClosed;
              Rooms = new ObservableCollection<RoomViewModel>();
              AllUsers = new ObservableCollection<UserViewModel>();
              Plugins = new ObservableCollection<PluginViewModel>();
              Dispatcher = mainWindow.Dispatcher;

              KeyBoard.KeyDown += OnKeyDown;
              KeyBoard.KeyUp += OnKeyUp;

              NotifierContext.Connected += ClientConnect;
              NotifierContext.ReceiveMessage += ClientReceiveMessage;
              NotifierContext.ReceiveRegistrationResponse += ClientRegistration;
              NotifierContext.RoomRefreshed += ClientRoomRefreshed;
              NotifierContext.RoomClosed += ClientRoomClosed;
              NotifierContext.RoomOpened += ClientRoomOpened;
              NotifierContext.AsyncError += ClientAsyncError;
              NotifierContext.PluginLoaded += ClientPluginLoaded;
              NotifierContext.PluginUnloading += ClientPluginUnloading;

              ClearTabs();

              EnableServerCommand = new Command(EnableServer, obj => ServerModel.Server == null);
              DisableServerCommand = new Command(DisableServer, obj => ServerModel.Server != null);
              ConnectCommand = new Command(Connect, obj => ClientModel.Client == null);
              DisconnectCommand = new Command(Disconnect, obj => ClientModel.Client != null);
              ExitCommand = new Command(obj => window.Close());
              CreateRoomCommand = new Command(CreateRoom, obj => ClientModel.Client != null);
              DeleteRoomCommand = new Command(DeleteRoom, obj => ClientModel.Client != null);
              ExitFromRoomCommand = new Command(ExitFromRoom, obj => ClientModel.Client != null);
              OpenFilesDialogCommand = new Command(OpenFilesDialog, obj => ClientModel.Client != null);
              OpenAboutProgramCommand = new Command(OpenAboutProgram);
              OpenSettingsCommand = new Command(OpenSettings);
        }