Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

Similar documents
CALCULATOR APPLICATION

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

CSIS 1624 CLASS TEST 6

You can call the project anything you like I will be calling this one project slide show.

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Click on the empty form and apply the following options to the properties Windows.

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

Form Properties Window

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

Start Visual Studio, create a new project called Helicopter Game and press OK

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

Visual Basic/C# Programming (330)

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

IBSDK Quick Start Tutorial for C# 2010

Object oriented lab /second year / review/lecturer: yasmin maki

Visual Basic/C# Programming (330)

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

// Precondition: None // Postcondition: The address' name has been set to the // specified value set;

// Program 2 - Extra Credit // CIS // Spring // Due: 3/11/2015. // By: Andrew L. Wright. //Edited by : Ben Spalding

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

เว บแอพล เคช น. private void Back_Click(object sender, EventArgs e) { this.webbrowser2.goback(); }

Brian Kiser November Vigilant C# 2.5. Commonwealth of Kentucky Frankfort, Kentucky

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

Sub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

Create your own Meme Maker in C#

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

Huw Talliss Data Structures and Variables. Variables

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

namespace csharp_gen277x214 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

Annex B: Prototype Draft Model Code. April 30 th, 2015 Siamak Khaledi, Ankit Shah, Matthew Shoaf

XNA 4.0 RPG Tutorials. Part 24. Level Editor Continued

II. Programming Technologies

C# winforms gridview

UNIT-3. Prepared by R.VINODINI 1

private void closetoolstripmenuitem_click(object sender, EventArgs e) { this.close(); }

Writing Your First Autodesk Revit Model Review Plug-In

Conventions in this tutorial

Representing Recursive Relationships Using REP++ TreeView

LAMPIRAN A : LISTING PROGRAM

XNA 4.0 RPG Tutorials. Part 11b. Game Editors

Inheriting Windows Forms with Visual C#.NET

PS2 Random Walk Simulator

Chapter 12. Tool Strips, Status Strips, and Splitters

LIGHT_P_TOGGLE, LIGHT_N_TOGGLE, BATTERY_TOGGLE, ALTERNATOR_TOGGLE, AVIONICS_TOGGLE, FLOAT_RETRACT, FLOAT_EXTEND }

emkt Browserless Coding For C#.Net and Excel

EL-USB-RT API Guide V1.0

The Network. Multithreading. This tutorial can be found on -

Quick Guide for the ServoWorks.NET API 2010/7/13

Using Template Bookmarks for Automating Microsoft Word Reports

2.3 Add GDS Google Map to Visual Studio Toolbox and create a simple map project

Chapter 6 Dialogs. Creating a Dialog Style Form

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects

CSC 355 PROJECT 4 NETWORKED TIC TAC TOE WITH WPF INTERFACE

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

NI USB-TC01 Thermocouple Measurement Device

Chapter 8 Advanced GUI Features

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

FDSc in ICT. Building a Program in C#

APARAT DE MASURA. Descrierea programului

This is the start of the server code

Chapter 13 Working with Threads

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

Lecture 8 Building an MDI Application

namespace Gen837X222A1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Answer on Question# Programming, C#

Developing for Mobile Devices Lab (Part 1 of 2)

عنوان مقاله : خواندن و نوشتن محتوای فایل های Excel بدون استفاده ازAutomation Excel تهیه وتنظیم کننده : مرجع تخصصی برنامه نویسان

Appendix A Programkod

The Gracefulness of the Merging Graph N ** C 4 with Dotnet Framework

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية

namespace csharp_gen837x223a2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Визуал програмчлал. Багш: Ж. Шинэбаяр /Маг/

IST311 Chapter13.NET Files (Part2)

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

SMITE API Developer Guide TABLE OF CONTENTS

Bachelor s Thesis: Building Web Application for Mahabad University Graduate Affairs Afsaneh Nezami Savojbolaghi

Model JI-4040 USB Multifunction Digital I/O Module - Isolated. Programmer s Interface Document

In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics.

Class Test 4. Question 1. Use notepad to create a console application that displays a face. See figure 1. Figure 1. Question2

Advanced Programming C# Lecture 2. dr inż. Małgorzata Janik

Classes in C# namespace classtest { public class myclass { public myclass() { } } }

Class Test 5. Create a simple paint program that conforms to the following requirements.

Hands-On Lab (MBL04) Lab Manual Incorporating COM Objects into Your.NET Compact Framework 2.0 Application

static String usersname; public static int numberofplayers; private static double velocity, time;

How to read/write text file

Examples. Products. W informs Controls > Products > Navigation Bar > Examples. This topic provides how -to examples, grouped by features.

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Transcription:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace Final public partial class Game : Form //holds class level variables string OddEven ; String choose ; String contnum; String color; int amountbet = 0; string numpick; String Color1 = null; const int big=35; public Game() InitializeComponent(); Main Game Code //this is in the file drop down and takes you to the main page private void maintoolstripmenuitem_click(object sender, EventArgs e) Main newform = new Main(); newform.show(); this.hide(); //this is in the file drop down and exits the application private void exittoolstripmenuitem_click(object sender, EventArgs e) Application.Exit(); //this is the site i got the hide show from: http://stackoverflow.com/questions/1513887/ //this is the timer object on the form, private void t_tick(object sender, EventArgs e) //creates a method timer called t MethodTimer t = (MethodTimer)sender; //calls to functions t.stop(); t.method.invoke(); //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

internal class MethodTimer : Timer //MethodInvoker provides a simple delegate that is used to invoke a method with a void parameter list. //This delegate can be used when making calls to a control's Invoke method, or when you need a simple delegate but do not want to define one yourself. public readonly MethodInvoker Method; public MethodTimer(MethodInvoker method) Method = method; public void user(int amountbet) // checks if the user entery can be parsed to an int try amountbet = int.parse(txtbet.text); lblshowbet.text = amountbet.tostring(); lblshowbet.visible = true; lbldiswin.visible = true; pctstop.visible = false; pctplay.visible = true; timer(); catch MessageBox.Show("Enter a Valid Number"); txtbet.backcolor = Color.Yellow; lblshowbet.visible = false; lbldiswin.visible = false; pctstop.visible = true; pctplay.visible = false; //sets the timer for the animation public void timer() hide //this is the code where the spin button is pressed and the animation runs for 5 seconds MethodTimer hide = new MethodTimer(hideAction);//calls the hide action which turns animation off stores in MethodTimer show = new MethodTimer(showAction);//turns on the animation stores is show MethodTimer showlbl = new MethodTimer(showAction);// hide.interval = 5000; show.interval = 1; lblshowbet.visible = true; hide.tick += new EventHandler(t_Tick);//use the windows timer for tick counter adds to it show.tick += new EventHandler(t_Tick);//uses the windows timer for tick counter adds to it hide.start(); show.start();

//handles the button spin event private void btnspin_click(object sender, EventArgs e) int winnum = 0; //creates random number for the winning number and displays it Random rnd = new Random(); winnum = rnd.next(1, 10); // creates a number between 1 and 10 //stores the winning number in var winnum //parse the total money and stores it in variable total int total = int.parse(lbltotal.text); //tryparse the amount bet and puts it int variable amountbet int.tryparse(txtbet.text, out amountbet); if (txtbet.text == null) MessageBox.Show("Please Bet your amount"); else if (txtbet.text!= null) lbldiswin.text = ("The Winning Number Is: ") + winnum.tostring(); // creates 2 numbers and assigns it case of red or black and changes //the color of the winning number text int wincolor = rnd.next(0, 2); Color1 = wincolor.tostring(); switch (Color1) case "0": lbldiswin.forecolor = Color.Red; choose = "Red"; case "1": lbldiswin.forecolor = Color.Black; choose = "Black"; //displays what the user chooses for the group boxes stores //the color red or black into color var if (radblack.checked) color = "Black"; else if (radred.checked) color = "Red";

//displays what the user chooses for the group boxes stores //the odd or even into contnum var if (radodd.checked) contnum = "Odd"; else if (radeven.checked) contnum = "Even"; // takes the win number and sees if its odd or even int workdamit; workdamit = winnum % 2; if (workdamit == 1) OddEven = "Odd"; else if (workdamit == 0) OddEven = "Even"; //makes sure your not betting more than you have if (total < amountbet) MessageBox.Show("You can't bet more then you have"); txtbet.text = ""; //tests if the betting properties are decided if (numpick == null && color == null && contnum == null) MessageBox.Show("place your bet"); lbltest.visible = false; clear(); else //checks if the number is picked out of list box, then check if it matches winning number while //the other conditions are null if (numpick!= null && color == null && contnum == null) if (int.parse(numpick) == winnum) total = total + (amountbet * big); lbltest.text = ("you win") + (amountbet * big); else if (int.parse(numpick)!= winnum) total = total - amountbet; lbltest.text = ("you lose ") + amountbet;

winner //checks that the list number is blank and the color is chosen, and oddeven is blank then checks if its a if (numpick == null && choose!= null && contnum == null) if (color == choose) total = total + (amountbet + amountbet); lbltest.text = ("you win ") + (amountbet + amountbet); else if (color!= choose) total = total - amountbet; lbltest.text = ("you Lose ") + amountbet; //checks that the odd even is picked and the others empty if (numpick == null && color == null && contnum!= null) if (contnum == OddEven) total = total + (amountbet + amountbet); lbltest.text = ("you win ") + (amountbet + amountbet); else if (contnum!= OddEven) total = total - amountbet; lbltest.text = ("you Lose ") + amountbet;

//test 2 conditions are true, the number and the color if (numpick!= null && color!= null && contnum == null) if (int.parse(numpick) == winnum && color == choose) total = total + ((amountbet * big) + (amountbet * 2)); lbltest.text = ("you win ") + ((amountbet *big) + (amountbet * 2)); else if (int.parse(numpick)!= winnum color!= choose) total = total - (amountbet * 2); lbltest.text = ("you Lose ") + (amountbet * 2); //test 2 conditions are true, the number and the type if (numpick!= null && color == null && contnum!= null) if (int.parse(numpick) == winnum && contnum == OddEven) total = total + ((amountbet * big) + (amountbet * 2)); lbltest.text = ("you win ") + ((amountbet * big) + (amountbet * 2)); else if (int.parse(numpick)!= winnum contnum!= OddEven) total = total - amountbet; lbltest.text = ("you Lose ") + (amountbet * 2); //test 2 conditions are true, the color and the type if (numpick == null && color!= null && contnum!= null) if (color == choose && contnum == OddEven)

total = total + ((amountbet * 2) + (amountbet * 2)); lbltest.text = ("you win ") + (amountbet * 4); else if (color!= choose contnum!= OddEven) total = total - amountbet; lbltest.text = ("you lose ") + (amountbet * 2); //checks all conditions are picked if (numpick!= null && color!= null && contnum!= null) if (int.parse(numpick) == winnum && color == choose && contnum == OddEven) total = total + ((amountbet * 4) + (amountbet * 35)); lbltest.text = ("you win ") + ((amountbet * 4) + (amountbet * 35)); else if (int.parse(numpick)!= winnum color!= choose contnum == OddEven) total = total - (amountbet * 4); lbltest.text = ("you lose ") + (amountbet * 4); // calls the functions user and clear if (pctstop.visible == true) user(amountbet); clear(); //function to hide aniamtion

private void hideaction() pctplay.visible = false; pctstop.visible = true; //function to start aniamtion private void showaction() pctplay.visible = true; pctstop.visible = false; // this group shows pictures if buttons are changed private void radred_checkedchanged(object sender, EventArgs e) pctred.visible = true; pctblsck.visible = false; private void radblack_checkedchanged(object sender, EventArgs e) pctblsck.visible = true; pctred.visible = false; private void radodd_checkedchanged(object sender, EventArgs e) pctodd.visible = true; pcteven.visible = false; private void radeven_checkedchanged(object sender, EventArgs e) pctodd.visible = false; pcteven.visible = true; //shows what your bet is on the table based on the number selected private void lstpicknum_selectedindexchanged(object sender, EventArgs e) if (lstpicknum.selectedindex!= -1) numpick = lstpicknum.selecteditem.tostring(); switch (numpick) case "1": pct1.visible = true;

case "2": pct2.visible = true; case "3": pct3.visible = true; case "4": pct4.visible = true; case "5": pct5.visible = true; case "6":

pct6.visible = true; case "7": pct7.visible = true; case "8": pct8.visible = true; case "9": pct9.visible = true; case "10":

pct10.visible = true; //clears all feilds public void clear() contnum = null; choose = null; color = null; radeven.checked = false; radodd.checked = false; radred.checked = false; radblack.checked = false; txtbet.text = ""; numpick = null; pctblsck.visible = false; pctred.visible = false; pctodd.visible = false; pcteven.visible = false; lstpicknum.selectedindex = -1; //creates a file and saves the text in total into a document private void btnsave_click(object sender, EventArgs e) StreamWriter Saved; Saved = File.CreateText("Saved_Game.txt"); Saved.WriteLine(lbltotal.Text); Saved.Close(); //exits the application private void btnexit_click(object sender, EventArgs e) Application.Exit(); //reads the file Saved_Game and displays the total that was saved private void btnload_click(object sender, EventArgs e) string line; int counter = 0; // Read the file and display it line by line. StreamReader file = new StreamReader("Saved_Game.txt");

while ((line = file.readline())!= null) lbltotal.text=(line); counter++; file.close(); //takes you to the rules page private void rulestoolstripmenuitem_click(object sender, EventArgs e) Rules newform = new Rules(); newform.show(); this.hide();