Ejemplo n.º 1
0
 protected override void OnStartup(StartupEventArgs e)
 {
     // check for a handle on the command-line;
       // if not found, prompt user for input
       String handle;
       var result = getHandle(e.Args,out handle);
       if (result.HasValue && result.Value)
       {
     // handle acquired, pass to Model
     var chatzClient = new ChatzClient(handle);
     // reset "automatic" shuntdown mode
     Current.ShutdownMode            = ShutdownMode.OnMainWindowClose;
     // initialize View (i.e. the app's main form)
     Current.MainWindow              = new MainWindow();
     // initialize ViewModel and bind to View
     Current.MainWindow.DataContext  = new MainWindowViewModel(chatzClient);
     // launch GUI
     Current.MainWindow.Show();
       }
       else
       {
     // no handle given, user has opted to exit application
     Current.Shutdown();
       }
 }
Ejemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // check for a handle on the command-line;
            // if not found, prompt user for input
            String handle;
            var    result = getHandle(e.Args, out handle);

            if (result.HasValue && result.Value)
            {
                // handle acquired, pass to Model
                var chatzClient = new ChatzClient(handle);
                // reset "automatic" shuntdown mode
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                // initialize View (i.e. the app's main form)
                Current.MainWindow = new MainWindow();
                // initialize ViewModel and bind to View
                Current.MainWindow.DataContext = new MainWindowViewModel(chatzClient);
                // launch GUI
                Current.MainWindow.Show();
            }
            else
            {
                // no handle given, user has opted to exit application
                Current.Shutdown();
            }
        }
Ejemplo n.º 3
0
        public MainWindowViewModel(ChatzClient model)
        {
            // initialize list of received broadcasts
            messages_ = new ObservableCollection <SentMessage>();
            // receiving a broadcast triggers INotifyPropertyChanged
            messages_.CollectionChanged += (_, e) => { Notify("Messages"); };

            // store proxy connection to chat server
            this.model = model;
            // handle receipt of broadcst message
            model.MessageReceived += (_, e) => { messages_.Add(e.Message); };

            // expose handle to GUI
            Handle = model.Handle;

            // wire-up command to pass messages to server; resets GUI input
            sendMessage = new RelayCommand(_ => { this.model.Send(this.Input ?? "");
                                                  this.Input = null; });
        }
Ejemplo n.º 4
0
        public MainWindowViewModel(ChatzClient model)
        {
            // initialize list of received broadcasts
              messages_ = new ObservableCollection<SentMessage>();
              // receiving a broadcast triggers INotifyPropertyChanged
              messages_.CollectionChanged += (_, e) => { Notify("Messages"); };

              // store proxy connection to chat server
              this.model = model;
              // handle receipt of broadcst message
              model.MessageReceived += (_, e) => { messages_.Add(e.Message); };

              // expose handle to GUI
              Handle = model.Handle;

              // wire-up command to pass messages to server; resets GUI input
              sendMessage = new RelayCommand(_ => { this.model.Send(this.Input ?? "");
                                            this.Input = null; });
        }