Windows
How do I use Windows
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmLogin.cs
Copy
53 private void frmLogin_Activated(object sender, EventArgs e)
54 {
55 this.WindowState = FormWindowState.Normal;
56 }
File name: NetworkingPeer.cs
Copy
185 public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol) : base(listener, connectionProtocol)
186 {
187 #if !UNITY_EDITOR && (UNITY_WINRT)
188 // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
189 Debug.LogWarning("Using PingWindowsStore");
190 PhotonHandler.PingImplementation = typeof(PingWindowsStore); // but for ping, we have to set the implementation explicitly to Win 8 Store/Phone
191 #endif
192
193 #pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
194 if (PhotonPeer.NoSocket)
195 {
196 #if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
197 Debug.Log("Using class SocketUdpNativeDynamic");
198 this.SocketImplementation = typeof(SocketUdpNativeDynamic);
199 PhotonHandler.PingImplementation = typeof(PingNativeDynamic);
200 #elif !UNITY_EDITOR && UNITY_IPHONE
201 Debug.Log("Using class SocketUdpNativeStatic");
202 this.SocketImplementation = typeof(SocketUdpNativeStatic);
203 PhotonHandler.PingImplementation = typeof(PingNativeStatic);
204 #elif !UNITY_EDITOR && (UNITY_WINRT)
205 // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
206 #else
207 this.SocketImplementation = typeof (SocketUdp);
208 PhotonHandler.PingImplementation = typeof(PingMonoEditor);
209 #endif
210
211 if (this.SocketImplementation == null)
212 {
213 Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
214 }
215 }
216 #pragma warning restore 0162
217
218 if (PhotonHandler.PingImplementation == null)
219 {
220 PhotonHandler.PingImplementation = typeof(PingMono);
221 }
222
223 this.Listener = this;
224 this.lobby = TypedLobby.Default;
225 this.LimitOfUnreliableCommands = 40;
226
227 // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
228 this.externalListener = listener;
229 this.PlayerName = playername;
230 this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
231 this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);
232
233 // RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
234 rpcShortcuts = new Dictionary
235 for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
236 {
237 var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
238 rpcShortcuts[name] = index;
239 }
240
241 this.State = global::PeerState.PeerCreated;
242 }
File name: VSCode.cs
Copy
439 static void CallVSCode(string args)
440 {
441 System.Diagnostics.Process proc = new System.Diagnostics.Process();
442 if(!VSCodeExists(CodePath))
443 {
444 PrintNotFound(CodePath);
445 return;
446 }
447
448#if UNITY_EDITOR_OSX
449 proc.StartInfo.FileName = "open";
450
451 // Check the path to see if there is "Insiders"
452 if (CodePath.Contains("Insiders"))
453 {
454 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCodeInsiders\" --args " + args.Replace(@"\", @"\\");
455 }
456 else
457 {
458 proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCode\" --args " + args.Replace(@"\", @"\\");
459 }
460
461 proc.StartInfo.UseShellExecute = false;
462#elif UNITY_EDITOR_WIN
463 proc.StartInfo.FileName = CodePath;
464 proc.StartInfo.Arguments = args;
465 proc.StartInfo.UseShellExecute = false;
466#else
467 proc.StartInfo.FileName = CodePath;
468 proc.StartInfo.Arguments = args.Replace(@"\", @"\\");
469 proc.StartInfo.UseShellExecute = false;
470#endif
471 proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
472 proc.StartInfo.CreateNoWindow = true;
473 proc.StartInfo.RedirectStandardOutput = true;
474 proc.Start();
475 }
File name: Form1.cs
Copy
236 public void Button4_Click(System.Object sender, System.EventArgs e)
237 {
238
239 string strmessage = default(string);
240 DialogResult dgrResult;
241
242 strmessage = "Are you sure you want to save data?";
243 dgrResult = MessageBox.Show(strmessage, "Save data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
244
245
246 if (dgrResult == System.Windows.Forms.DialogResult.Yes)
247 {
248
249 newgrade = gradeclass.DataModule.SaveItem();
250 }
251
252 }
File name: Form1.cs
Copy
373 public void Button11_Click(System.Object sender, System.EventArgs e)
374 {
375 string strmessage = default(string);
376 DialogResult dgrResult;
377
378 strmessage = "Are you sure you want to Delete this record?";
379 dgrResult = MessageBox.Show(strmessage, "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
380
381
382 if (dgrResult == System.Windows.Forms.DialogResult.Yes)
383 {
384
385 dsgrade = gradeclass.DataModule.deldata();
386
387 }
388
389
390
391 }
File name: Form1.cs
Copy
397 public void DataGridView1_CellDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
398 {
399 TextBox1.Text = DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
400 TextBox2.Text = DataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
401 TextBox3.Text = DataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
402 TextBox4.Text = DataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
403 TextBox5.Text = DataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
404 TextBox6.Text = DataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
405 TextBox7.Text = DataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
406 TextBox8.Text = DataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();
407 TextBox9.Text = DataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
408 TextBox10.Text = DataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
409 TextBox11.Text = DataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString();
410 TextBox12.Text = DataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
411 TextBox13.Text = DataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
412 TextBox14.Text = DataGridView1.Rows[e.RowIndex].Cells[14].Value.ToString();
413 TextBox15.Text = DataGridView1.Rows[e.RowIndex].Cells[15].Value.ToString();
414 TextBox16.Text = DataGridView1.Rows[e.RowIndex].Cells[16].Value.ToString();
415 TextBox17.Text = DataGridView1.Rows[e.RowIndex].Cells[17].Value.ToString();
416 TextBox18.Text = DataGridView1.Rows[e.RowIndex].Cells[18].Value.ToString();
417 TextBox19.Text = DataGridView1.Rows[e.RowIndex].Cells[19].Value.ToString();
418 STUDID.Text = DataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
419
420
421 }
File name: PlayerController.cs
Copy
31 void Update () {
32 if (GameplayController.instance.gameInProgress) {
33 LimitPosition ();
34 if (Application.platform == RuntimePlatform.WindowsEditor) {
35 PlayerMovement ();
36 }else if(Application.platform == RuntimePlatform.Android){
37 TouchMovement ();
38 }
39
40 }
41 }
File name: CameraFollow.cs
Copy
30 void Update () {
31 if (GameplayController.instance.gameInProgress) {
32 if (isFollowing) {
33 if (GameObject.FindGameObjectWithTag ("Player Bullet") != null) {
34 MoveCameraFollow ();
35 }
36 } else {
37 if (!GameplayController.instance.player.GetChild (0).transform.GetComponent
38 MoveCameraBackToStart ();
39 AfterShotMoveAgain ();
40 allowToMove = false;
41 } else {
42 timeSinceShot = 0;
43 allowToMove = true;
44 }
45
46 }
47
48 if (Application.platform == RuntimePlatform.Android) {
49 TouchMoveCamera ();
50 } else if (Application.platform == RuntimePlatform.WindowsEditor) {
51 MoveCamera ();
52 }
53 }
54
55 }
File name: Cannon.cs
Copy
43 void Update () {
44 if (GameplayController.instance.gameInProgress) {
45 if (readyToShoot) {
46 if(Application.platform == RuntimePlatform.Android){
47 TouchCannonShoot ();
48 }else if(Application.platform == RuntimePlatform.WindowsEditor){
49 CannonShoot ();
50 }
51
52 }
53
54 if(Application.platform == RuntimePlatform.Android){
55 TouchCannonMovement ();
56 }else if(Application.platform == RuntimePlatform.WindowsEditor){
57 CannonMovement ();
58 }
59
60 }
61 }
File name: Home.cs
Copy
61 private void closeApplicationToolStripMenuItem_Click(object sender, EventArgs e)
62 {
63 System.Windows.Forms.Application.Exit();
64 }
Windows 99 lượt xem
Gõ tìm kiếm nhanh...