예제 #1
0
        private void ButtonOpenUserList_Click(object sender, RoutedEventArgs e)
        {
            if (EventbusManager.IsViewOpen(typeof(UserlistView), 0))
            {
                return;
            }

            this._viewModel.ViewOpened = ViewOpen.Userlist;
            EventbusManager.OpenView <UserlistView>(0);
        }
예제 #2
0
        private void ButtonShowDevices_Click(object sender, RoutedEventArgs e)
        {
            if (EventbusManager.IsViewOpen(typeof(DevicesView), 2))
            {
                EventbusManager.CloseView <DevicesView>(2);
                return;
            }

            EventbusManager.OpenView <DevicesView>(2);
        }
예제 #3
0
        private void ButtonOpenMain_Click(object sender, RoutedEventArgs e)
        {
            if (EventbusManager.IsViewOpen(typeof(MainView), 0))
            {
                return;
            }

            this._viewModel.ViewOpened = ViewOpen.Main;
            EventbusManager.OpenView <MainView>(0);
        }
예제 #4
0
        private void ButtonAccept_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this._viewModel.Username))
            {
                MessageBox.Show("username must be set.");
                return;
            }

            if (string.IsNullOrEmpty(this._viewModel.HostAddress))
            {
                MessageBox.Show("host address must be set.");
                return;
            }

            var service = ServiceConnector.GetInstance();

            service.SetAddress(this._viewModel.HostAddress);

            if (service.TrySetUsername(this._viewModel.Username, out var userItem))
            {
                EventbusManager.OpenView <UserlistView>(0);
                EventbusManager.Send <MainWindow, UpdateCommandMessage>(new UpdateCommandMessage(userItem), 0);
                EventbusManager.Send <MenuView, UpdateCommandMessage>(new UpdateCommandMessage(ViewOpen.Userlist), 0);

                if (!this._viewModel.HostAddressItems.Any(a => a.Equals(this._viewModel.HostAddress)))
                {
                    this._viewModel.HostAddressItems = this._viewModel.HostAddressItems.Append(this._viewModel.HostAddress);
                }

                var settings = new SettingsFile
                {
                    Username           = this._viewModel.Username,
                    Interval           = this._viewModel.Interval,
                    ServerAddress      = this._viewModel.HostAddress,
                    ServerAddressItems = this._viewModel.HostAddressItems
                };
                UserSettingsLoader.GetInstance().Save(settings);

                MessengerManager.GetInstance().Start(this._viewModel.Interval);
                return;
            }

            MessageBox.Show($"Can not use username: {this._viewModel.Username}");
        }
예제 #5
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     EventbusManager.OpenView <MainView>(0);
     EventbusManager.Send <MenuView, UpdateCommandMessage>(new UpdateCommandMessage(ViewOpen.Main), 0);
     EventbusManager.Register <MainWindow, UpdateCommandMessage>(this.UpdateCommandMessageReceived);
 }