That
How do I use That
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmDienTenTS.cs
Copy
30 private void btbatdauthi_Click(object sender, EventArgs e)
31 {
32 try
33 {
34 if (tbten.Text == "" || tbmathisinh.Text == "")
35 {
36 MessageBox.Show("Bạn phải điền đầy đủ thông tin");
37 }
38 else
39 {
40 string TenThSinh = tbten.Text;
41 string MaThiSinh = tbmathisinh.Text;
42 string strSQL = "insert THISINHTHI values('" + MaThiSinh + "','" + TenThSinh + "')";
43 SqlCommand ObjCmd = new SqlCommand(strSQL, ObjCon);
44 ObjCmd.ExecuteNonQuery();
45 if (MessageBox.Show("Bạn có chắc chắn thi không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
46 {
47
48 string dienten = this.tbten.Text;//chuyen thong tin sang form thithat
49 string dienma = this.tbmathisinh.Text;
50 frmThiThat thithat = new frmThiThat(dienten, dienma);
51 thithat.ShowDialog();
52 this.Close();
53
54
55 }
56
57 }
58 }
59 catch
60 {
61 MessageBox.Show("Mã thí sinh trùng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
62 }
63
64 }
File name: frmMain.cs
Copy
107 private void thiThậtToolStripMenuItem_Click(object sender, EventArgs e)
108 {
109 frmDienTenTS dienten = new frmDienTenTS();
110 dienten.ShowDialog();
111 }
File name: frmThiThat.cs
Copy
26 public frmThiThat(string strvalue,string strvalue1)
27 {
28
29 InitializeComponent();
30 getvalueformdienten = strvalue;
31 getvalueformdienma = strvalue1;
32
33 }
File name: frmThiThat.cs
Copy
34 void Load_DeThiThat()
35 {
36 try
37 {
38 SqlConnection cnn = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security =true");
39 SqlDataAdapter da = new SqlDataAdapter("select cauhoi.mach,cauhoi,a,b,c,d ,dapan from cauhoi,DAPAN where cauhoi.mach=DAPAN.mach", cnn);
40 DataTable BangQuestion = new DataTable();
41 da.Fill(BangQuestion);
42 TaoBangRandomCauHoi(BangQuestion);
43 }
44 catch (Exception ex)
45 { MessageBox.Show(ex.Message); }
46 p = 60;//nhap thoi gian thi
47 s = 60;
48 h = 0;
49 }
File name: frmThiThat.cs
Copy
190 private void frmThiThat_Load(object sender, EventArgs e)
191 {
192
193
194 lbNgaythang.Text = DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Year.ToString();
195
196 {
197 try
198 {
199 if (DeThi == true)
200 Load_DeThiThat();
201 else
202 Load_DeThiThat();
203 TaoBangRandomCauTraLoi();
204 LoadCauHoiVaoControl();
205 timer1.Start();
206
207 btPre.Enabled = false;
208 }
209 catch (Exception ex)
210 { MessageBox.Show(ex.Message); }
211 }
212
213 }
File name: GUICustomAuth.cs
Copy
81 void OnGUI()
82 {
83 if (PhotonNetwork.connected)
84 {
85 GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
86 return;
87 }
88
89
90 GUILayout.BeginArea(GuiRect);
91 switch (guiState)
92 {
93 case GuiState.AuthFailed:
94 GUILayout.Label("Authentication Failed");
95
96 GUILayout.Space(10);
97
98 GUILayout.Label("Error message:\n'" + this.authDebugMessage + "'");
99
100 GUILayout.Space(10);
101
102 GUILayout.Label("For this demo set the Authentication URL in the Dashboard to:\nhttp://photon.webscript.io/auth-demo-equals");
103 GUILayout.Label("That authentication-service has no user-database. It confirms any user if 'name equals password'.");
104 GUILayout.Label("The error message comes from that service and can be customized.");
105
106 GUILayout.Space(10);
107
108 GUILayout.BeginHorizontal();
109 if (GUILayout.Button("Back"))
110 {
111 SetStateAuthInput();
112 }
113 if (GUILayout.Button("Help"))
114 {
115 SetStateAuthHelp();
116 }
117 GUILayout.EndHorizontal();
118 break;
119
120 case GuiState.AuthHelp:
121
122 GUILayout.Label("By default, any player can connect to Photon.\n'Custom Authentication' can be enabled to reject players without valid user-account.");
123
124 GUILayout.Label("The actual authentication must be done by a web-service which you host and customize. Example sourcecode for these services is available on the docs page.");
125
126 GUILayout.Label("For this demo set the Authentication URL in the Dashboard to:\nhttp://photon.webscript.io/auth-demo-equals");
127 GUILayout.Label("That authentication-service has no user-database. It confirms any user if 'name equals password'.");
128
129 GUILayout.Space(10);
130 if (GUILayout.Button("Configure Authentication (Dashboard)"))
131 {
132 Application.OpenURL("https://cloud.exitgames.com/dashboard");
133 }
134 if (GUILayout.Button("Authentication Docs"))
135 {
136 Application.OpenURL("https://doc.exitgames.com/en/pun/current/tutorials/pun-and-facebook-custom-authentication");
137 }
138
139
140 GUILayout.Space(10);
141 if (GUILayout.Button("Back to input"))
142 {
143 SetStateAuthInput();
144 }
145 break;
146
147 case GuiState.AuthInput:
148
149 GUILayout.Label("Authenticate yourself");
150
151 GUILayout.BeginHorizontal();
152 this.authName = GUILayout.TextField(this.authName, GUILayout.Width(Screen.width/4 - 5));
153 GUILayout.FlexibleSpace();
154 this.authToken = GUILayout.TextField(this.authToken, GUILayout.Width(Screen.width/4 - 5));
155 GUILayout.EndHorizontal();
156
157
158 if (GUILayout.Button("Authenticate"))
159 {
160 PhotonNetwork.AuthValues = new AuthenticationValues();
161 PhotonNetwork.AuthValues.SetAuthParameters(this.authName, this.authToken);
162 PhotonNetwork.ConnectUsingSettings("1.0");
163 }
164
165 GUILayout.Space(10);
166
167 if (GUILayout.Button("Help", GUILayout.Width(100)))
168 {
169 SetStateAuthHelp();
170 }
171
172 break;
173 }
174
175 GUILayout.EndArea();
176 }
File name: HubGui.cs
Copy
28 void OnGUI()
29 {
30 GUI.skin = this.Skin;
31 GUILayout.Space(10);
32
33 GUILayout.BeginHorizontal();
34 GUILayout.Space(10);
35 scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(320));
36
37 GUILayout.Label("Basics", m_Headline);
38 if (GUILayout.Button("Demo Boxes", GUILayout.Width(280)))
39 {
40 demoDescription = "
41 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoBoxes-Scene" };
42 }
43 if (GUILayout.Button("Demo Worker", GUILayout.Width(280)))
44 {
45 demoDescription = "
46 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoWorker-Scene" };
47 }
48 if (GUILayout.Button("Movement Smoothing", GUILayout.Width(280)))
49 {
50 demoDescription = "
51 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoSynchronization-Scene" };
52 }
53
54 GUILayout.Label("Advanced", m_Headline);
55 if (GUILayout.Button("Ownership Transfer", GUILayout.Width(280)))
56 {
57 demoDescription = "
58 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChangeOwner-Scene" };
59 this.webLink = new DemoBtn();
60 }
61 if (GUILayout.Button("Pickup, Teams, Scores", GUILayout.Width(280)))
62 {
63 demoDescription = "
64 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoPickup-Scene" };
65 this.webLink = new DemoBtn();
66 }
67
68 GUILayout.Label("Feature Demos", m_Headline);
69 if (GUILayout.Button("Chat", GUILayout.Width(280)))
70 {
71 demoDescription = "
72 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChat-Scene" };
73 this.webLink = new DemoBtn();
74 }
75 if (GUILayout.Button("RPG Movement", GUILayout.Width(280)))
76 {
77 demoDescription = "
78 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoRPGMovement-Scene" };
79 this.webLink = new DemoBtn();
80 }
81 if (GUILayout.Button("Mecanim Animations", GUILayout.Width(280)))
82 {
83 demoDescription = "
84 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoMecanim-Scene" };
85 this.webLink = new DemoBtn();
86 }
87 if (GUILayout.Button("2D Game", GUILayout.Width(280)))
88 {
89 demoDescription = "
90 this.demoBtn = new DemoBtn() { Text = "Start", Link = "Demo2DJumpAndRunWithPhysics-Scene" };
91 this.webLink = new DemoBtn();
92 }
93 if (GUILayout.Button("Friends & Authentication", GUILayout.Width(280)))
94 {
95 demoDescription = "
96 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoFriends-Scene" };
97 this.webLink = new DemoBtn();
98 }
99
100 GUILayout.Label("Tutorial", m_Headline);
101 if (GUILayout.Button("Marco Polo Tutorial", GUILayout.Width(280)))
102 {
103 demoDescription = "
104 this.demoBtn = new DemoBtn() { Text = "Start", Link = "MarcoPolo-Scene" };
105 this.webLink = new DemoBtn() { Text = "Open Tutorial (www)", Link = "http://tinyurl.com/nmylf44" };
106 }
107 GUILayout.EndScrollView();
108
109 GUILayout.BeginVertical(GUILayout.Width(Screen.width - 345));
110 GUILayout.Label(demoDescription);
111 GUILayout.Space(10);
112 if (!string.IsNullOrEmpty(this.demoBtn.Text))
113 {
114 if (GUILayout.Button(this.demoBtn.Text))
115 {
116 Application.LoadLevel(this.demoBtn.Link);
117 }
118 }
119 if (!string.IsNullOrEmpty(this.webLink.Text))
120 {
121 if (GUILayout.Button(this.webLink.Text))
122 {
123 Application.OpenURL(this.webLink.Link);
124 }
125 }
126 GUILayout.EndVertical();
127
128
129 GUILayout.EndHorizontal();
130 }
File name: OnPickedUpScript.cs
Copy
6 public void OnPickedUp(PickupItem item)
7 {
8 if (item.PickupIsMine)
9 {
10 Debug.Log("I picked up something. That's a score!");
11 PhotonNetwork.player.AddScore(1);
12 }
13 else
14 {
15 Debug.Log("Someone else picked up something. Lucky!");
16 }
17 }
File name: PickupCamera.cs
Copy
41 void OnEnable()
42 {
43 if( this.photonView != null && !this.photonView.isMine )
44 {
45 this.enabled = false;
46 return;
47 }
48
49 if( !cameraTransform && Camera.main )
50 cameraTransform = Camera.main.transform;
51 if( !cameraTransform )
52 {
53 Debug.Log( "Please assign a camera to the ThirdPersonCamera script." );
54 enabled = false;
55 }
56
57 m_CameraTransformCamera = cameraTransform.GetComponent
58
59
60 _target = transform;
61 if( _target )
62 {
63 controller = _target.GetComponent
64 }
65
66 if( controller )
67 {
68 CharacterController characterController = (CharacterController)_target.GetComponent
69 centerOffset = characterController.bounds.center - _target.position;
70 headOffset = centerOffset;
71 headOffset.y = characterController.bounds.max.y - _target.position.y;
72 }
73 else
74 Debug.Log( "Please assign a target to the camera that has a ThirdPersonController script attached." );
75
76
77 Cut( _target, centerOffset );
78 }
File name: ThirdPersonCamera.cs
Copy
40 void OnEnable()
41 {
42 if( !cameraTransform && Camera.main )
43 cameraTransform = Camera.main.transform;
44 if( !cameraTransform )
45 {
46 Debug.Log( "Please assign a camera to the ThirdPersonCamera script." );
47 enabled = false;
48 }
49
50 m_CameraTransformCamera = cameraTransform.GetComponent
51
52 _target = transform;
53 if( _target )
54 {
55 controller = _target.GetComponent
56 }
57
58 if( controller )
59 {
60 CharacterController characterController = (CharacterController)_target.GetComponent
61 centerOffset = characterController.bounds.center - _target.position;
62 headOffset = centerOffset;
63 headOffset.y = characterController.bounds.max.y - _target.position.y;
64 }
65 else
66 Debug.Log( "Please assign a target to the camera that has a ThirdPersonController script attached." );
67
68
69 Cut( _target, centerOffset );
70 }
Download file with original file name:That
That 121 lượt xem
Gõ tìm kiếm nhanh...