コード例 #1
0
ファイル: Program.cs プロジェクト: treejames/P2PHomework
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //注册事件的处理
            while (true)
            {
                //生成loginForm
                LoginForm newLoginForm = new LoginForm();
                DialogResult newLoginFormResult = newLoginForm.ShowDialog();

                if (newLoginFormResult == DialogResult.OK)
                {
                    HomeForm newHomeFrom = new HomeForm();
                    newHomeFrom.userinfo = newLoginForm.userinfo;
                    newLoginForm.Close();
                    newLoginForm.Dispose();
                    Application.Run(newHomeFrom);
                    break;
                }
                //进入注册界面
                if (newLoginFormResult == DialogResult.Abort)
                {
                    newLoginForm.Close();
                    newLoginForm.Dispose();
                    RegistForm newRegistForm = new RegistForm();
                    DialogResult newRegistFormResult = newRegistForm.ShowDialog();
                    //注册成功转到登录界面
                    if (newRegistFormResult == DialogResult.OK)
                    {
                        newRegistForm.Close();
                        newRegistForm.Dispose();
                        continue;
                    }
                    //返回登录界面
                    if (newRegistFormResult == DialogResult.Retry)
                    {
                        continue;
                    }
                    break;
                }
                //点击退出
                break;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: fz1989/P2PHomework
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //注册事件的处理
            while (true)
            {
                //生成loginForm
                LoginForm    newLoginForm       = new LoginForm();
                DialogResult newLoginFormResult = newLoginForm.ShowDialog();

                if (newLoginFormResult == DialogResult.OK)
                {
                    HomeForm newHomeFrom = new HomeForm();
                    newHomeFrom.userinfo = newLoginForm.userinfo;
                    newLoginForm.Close();
                    newLoginForm.Dispose();
                    Application.Run(newHomeFrom);
                    break;
                }
                //进入注册界面
                if (newLoginFormResult == DialogResult.Abort)
                {
                    newLoginForm.Close();
                    newLoginForm.Dispose();
                    RegistForm   newRegistForm       = new RegistForm();
                    DialogResult newRegistFormResult = newRegistForm.ShowDialog();
                    //注册成功转到登录界面
                    if (newRegistFormResult == DialogResult.OK)
                    {
                        newRegistForm.Close();
                        newRegistForm.Dispose();
                        continue;
                    }
                    //返回登录界面
                    if (newRegistFormResult == DialogResult.Retry)
                    {
                        continue;
                    }
                    break;
                }
                //点击退出
                break;
            }
        }
コード例 #3
0
        private void ClientForm_Load(object sender, EventArgs e)
        {
            LoginForm loginForm = new LoginForm();

            loginForm.ShowDialog();
            if (loginForm.DialogResult == DialogResult.OK)
            {
                string user  = loginForm.UserName;
                Model  model = new Model(user);
                model.AddListener(this);
                controller = new Controller(model);
                this.Text += " - " + user;
                controller.OnConnectButton();
            }
            else
            {
                Close();
            }
        }
コード例 #4
0
        private void Client_Load(object sender, EventArgs e)
        {
            // DPI 설정 메소드 호출
            SetDpiAwareness();

            if (ClassNetConfig.GetAppConfig("SERVER_IP").Equals(""))
            {
                MessageBox.Show("서버 IP 설정이 필요합니다.", "서버 IP 미설정", MessageBoxButtons.OK, MessageBoxIcon.Information);
                using (SetIPAddressForm setIPAddressForm = new SetIPAddressForm())
                {
                    var dialogResult = setIPAddressForm.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        ClassNetConfig.SetAppConfig("SERVER_IP", setIPAddressForm.ServerIP);
                    }
                }
            }
            this.SERVER_IP = ClassNetConfig.GetAppConfig("SERVER_IP");

            isLogin = false;
            while (!isLogin)
            {
                loginForm = new LoginForm();
                loginForm.ShowDialog();      // ShowDialog 실행, 닫힐 때 까지 프로그램은 일시정지.
                stuInfo = loginForm.stuInfo; // 로그인 데이터를 변수에 담음.

                if (stuInfo.Length > 0)
                {
                    isLogin = true;
                }
            }

            if (stuInfo.Equals(ClassNetConfig.GetAppConfig("ADMIN_ID")))
            {
                ContextMenu ctx = new ContextMenu();
                ctx.MenuItems.Add(new MenuItem("설정", new EventHandler((s, ea) => BtnSetServerIP_Click(s, ea))));
                ctx.MenuItems.Add(new MenuItem("로그아웃", new EventHandler((s, ea) => BtnLogout_Click(s, ea))));

                this.notifyIcon.ContextMenu = ctx;
                this.notifyIcon.Visible     = true;

                this.Opacity = 0;

                this.ShowInTaskbar = false;
            }
            else
            {
                ContextMenu ctx = new ContextMenu();
                ctx.MenuItems.Add(new MenuItem("만든이", new EventHandler((s, ea) => BtnMade_Click(s, ea))));
                ctx.MenuItems.Add(new MenuItem("로그아웃", new EventHandler((s, ea) => BtnLogout_Click(s, ea))));

                this.notifyIcon.ContextMenu = ctx;
                this.notifyIcon.Visible     = true;

                // 폼 숨기기
                this.Opacity = 0;

                // 작업표시줄 상에서 프로그램이 표시되지 않도록 설정
                this.ShowInTaskbar = false;

                // 받은 이미지를 풀스크린으로 띄우는 설정
                this.FormBorderStyle = FormBorderStyle.None;
                this.WindowState     = FormWindowState.Maximized;

                this.Location = new Point(0, 0);
                this.Width    = Screen.PrimaryScreen.Bounds.Width;
                this.Height   = Screen.PrimaryScreen.Bounds.Height;

                screenImage.Width  = Screen.PrimaryScreen.Bounds.Width;
                screenImage.Height = Screen.PrimaryScreen.Bounds.Height;

                // 화면 폼을 가장 맨 위로
                TopMost = true;

                // JPEG 손실 압축 수준 설정
                codec          = GetEncoder(ImageFormat.Jpeg);
                param          = new EncoderParameters();
                param.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 30L);

                // 인터넷 차단, 입력 잠금, 작업관리자 잠금
                firewallPortBlocker  = new FirewallPortBlock();
                cmdProcessController = new CmdProcessController();
                taskMgrController    = new TaskMgrController();

                // 작업 관리자 잠금 실행
                taskMgrController.KillTaskMgr();

                // 소켓 연결 대기
                Task.Run(() => SocketConnection());
            }
        }
コード例 #5
0
ファイル: GUI.cs プロジェクト: michederoide/Battle.LAN
 private void LoginButton_Click(object sender, EventArgs e)
 {
     // Show the Login Form
     LoginForm loginform = new LoginForm();
     loginform.ShowDialog(this);
     if (loginform.Completed)
     {
         String username = loginform.Username;
         String password = loginform.Password;
         byte[] pwbytes = MD5.Create().ComputeHash(Encoding.Default.GetBytes(password));
         StringBuilder sb = new StringBuilder();
         foreach (byte digestbyte in pwbytes)
         {
             sb.Append(digestbyte.ToString("x2"));
         }
         String pwdigest = sb.ToString().ToUpper();
         MessageBox.Show("Username: "******"\nDigest: " + pwdigest);
         // TODO: Insert login logic here
         IsLoggedIn = true;
     }
 }