Beispiel #1
0
        public async Task LoginAsync(object parameter)
        {
            await RunCommand(() => LoginIsRunning, async() =>
            {
                await Task.Delay(1000);
                Task.WaitAll();

                await Task.Run(() =>
                {
                    NickName = parameter as string;
                    if (NickName == "" || !Regex.IsMatch(NickName, pattern) || NickName.Length < 4 || NickName.Length > 15)
                    {
                        ErrorText = "닉네임이 올바르지 않습니다.";
                        return;
                    }

                    CPacket message = CPacket.create((short)EProtocol.SET_NAME_REQ);
                    message.push(NickName);

                    CClient.serverlist[0].send(message);

                    bool timeOver = false;

                    var timer = new System.Timers.Timer(10000);

                    timer.Elapsed += (sender, e) =>
                    {
                        timeOver = true;
                    };

                    timer.Enabled = true;

                    while (true)
                    {
                        if (return_success == (short)EProtocol.SET_NAME_ACK)
                        {
                            (CClient.serverlist[0] as CServer).LoginPage_Return_Callback -= return_Result;

                            var VM = VMFactory.GetViewModel(typeof(MainWindowVM));
                            (VM as MainWindowVM).ContentPage = EPageNavigation.Insert;

                            this.ErrorText = string.Empty;
                            break;
                        }
                        else if (return_success == (short)EProtocol.SET_NAME_ERROR_EXISTED)
                        {
                            this.ErrorText = "해당 이름은 이미 사용중 입니다.";
                            break;
                        }
                        else if (timeOver)
                        {
                            timer.Dispose();
                            this.ErrorText = "서버와의 연결 상태가 좋지 않습니다.";
                            break;
                        }
                    }
                    return_success = -1;
                });
            });
        }
Beispiel #2
0
        public MainWindowVM(Window window)
        {
            mWindow = window;

            VMFactory.PushViewModel(this.GetType(), this);

            this.ContentPage = EPageNavigation.Login;
            this.SideMenu    = EPageNavigation.None;

            mWindow.StateChanged += (sender, e) =>
            {
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(WindowRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
            };

            MinimizeCommand = new RelayCommand(() => mWindow.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => mWindow.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(() =>
            {
                mWindow.Close();
                Application.Current.Shutdown();
            });
        }
Beispiel #3
0
        public InsertPage()
        {
            InitializeComponent();

            var VM = VMFactory.GetViewModel(typeof(MainWindowVM));

            (VM as MainWindowVM).SideMenu = EPageNavigation.SideMenuBar;
        }
Beispiel #4
0
 public async Task GoToChatPage()
 {
     await Task.Run(() =>
     {
         App.Current.Dispatcher.BeginInvoke((Action) delegate()
         {
             (VMFactory.GetViewModel(typeof(MainWindowVM)) as MainWindowVM).ContentPage = EPageNavigation.Chat;
             (ViewFactory.GetView(typeof(ChatPage)) as ChatPage).DataContext            = pageVM;
         });
     });
 }
Beispiel #5
0
        public async Task ExitAsync()
        {
            await Task.Run(() =>
            {
                CPacket message = CPacket.create((short)EProtocol.EXIT_THE_ROOM_REQ);
                message.push(RoomName);
                CClient.serverlist[0].send(message);

                (CClient.serverlist[0] as CServer).ChatPage_Return_Callback.Remove(RoomName);

                (VMFactory.GetViewModel(typeof(MainWindowVM)) as MainWindowVM).ContentPage = EPageNavigation.Insert;
                (VMFactory.GetViewModel(typeof(SideButtonControlVM)) as SideButtonControlVM).RemoveItems(SideItem);
            });
        }
Beispiel #6
0
 public LoginPage()
 {
     InitializeComponent();
     this.DataContext = VMFactory.GetViewModel(typeof(LoginPageVM));
 }
 public SideButtonControl()
 {
     InitializeComponent();
     this.DataContext = VMFactory.GetViewModel(typeof(SideButtonControlVM));
 }