public override void Draw(System.Drawing.Rectangle drawRegion, Tricycle.GameWindow gw) { filesPerPage = (drawRegion.Height / (_drawFont.Height + 2)) - 2; maxPages = (_romList.Count / filesPerPage); int yOffset = (drawRegion.Height - (filesPerPage * (_drawFont.Height + 2))) / 2; int page = _selected / filesPerPage; var basePage = page * filesPerPage; gw.DrawString(drawRegion.X + drawRegion.Width - (60), drawRegion.Y , Color.Red, _drawFont, "{0}|{1}", (page + 1).ToString(), maxPages.ToString()); for (int i = page * filesPerPage; i < Math.Min((page + 1) * filesPerPage, _romList.Count()); i++) { var pathStr = Path.GetFileNameWithoutExtension(_romList[i]); pathStr = pathStr.Substring(0, Math.Min(30, pathStr.Length)); if (pathStr.Length >= 30) pathStr = pathStr.Remove(pathStr.Length - 1) + "…"; if (i == _selected) { gw.DrawString(drawRegion.X, drawRegion.Y + ((i - basePage) * (_drawFont.Height + 2)), Color.Red, _drawFont, pathStr); } else { gw.DrawString(drawRegion.X + 20, drawRegion.Y + ((i - basePage) * (_drawFont.Height + 2)), Color.Black, _drawFont, pathStr); } } }
private static void Homework1() { //implement code here Console.WriteLine("This is Homework1"); Bicycle myBicycle = new Bicycle(); Bicycle myBicycle2 = new Bicycle("BMX"); Tricycle myTricycle = new Tricycle(); myBicycle.Color = "Green"; myBicycle2.Color = "Red"; myBicycle.Wheeltype = "Offroad"; myBicycle.Wheeltype = "Street"; myTricycle.Color = "Purple"; myTricycle.Wheeltype = "Street"; myBicycle.Pedal(); myBicycle2.Pedal(); myTricycle.Pedal(); myBicycle.HandleBar(); myBicycle2.HandleBar(); myTricycle.HandleBar(); myBicycle.Brake(); myBicycle2.Brake(); myTricycle.Brake(); Console.WriteLine("myBicycle Sprocket Count: " + myBicycle.Sprocket); Console.WriteLine("myBicycle2 Sprocket Count: " + myBicycle2.Sprocket); Console.WriteLine("myTricycle Sprocket Count: " + myTricycle.Sprocket); }
public override bool Process(Tricycle.GameWindow gw) { var settings = Properties.Settings.Default; var key = gw.Keyboard; if (key[settings.NextKey] || StateGlobals.EvaluateGamepad(gw, settings.NextGamePad)) { _selected++; while (StateGlobals.EvaluateGamepad(gw, settings.NextGamePad)) ; } if (key[settings.PrevKey] || StateGlobals.EvaluateGamepad(gw, settings.PrevGamePad)) { _selected--; while (StateGlobals.EvaluateGamepad(gw, settings.PrevGamePad)) ; } if (key[settings.SelectKey] || StateGlobals.EvaluateGamepad(gw, settings.SelectGamepadCombo)) { var k = _actionItems.Keys.ToList()[_selected]; var v = _actionItems[k]; v(); } if (_selected < 0) _selected = _actionItems.Count - 1; if(_selected >= _actionItems.Count) _selected = 0; return true; }
public static void Main() { var motorcycle = new Motorcycle(); var tricycle = new Tricycle(); var jetski = new JetSki(); var submarine = new Submarine(); var cessna = new Cessna(); var paraglider = new Paraglider(); // Build a collection of all vehicles that fly var flyers = new List <IAirVehicle>(); flyers.Add(cessna); flyers.Add(paraglider); // With a single `foreach`, have each vehicle Fly() foreach (var plane in flyers) { plane.Fly(); } // Build a collection of all vehicles that operate on roads var drivers = new List <IGroundVehicle>(); drivers.Add(motorcycle); drivers.Add(tricycle); // With a single `foreach`, have each road vehicle Drive() foreach (var ride in drivers) { ride.Drive(); } // Build a collection of all vehicles that operate on water var swimmers = new List <IWaterVehicle>(); swimmers.Add(jetski); swimmers.Add(submarine); // With a single `foreach`, have each water vehicle Drive() foreach (var fish in swimmers) { fish.Drive(); } Console.ReadLine(); }
//[TestMethod] public void TestIsDrivingStructure() { Tricycle trike = new Tricycle(); bool isMoving = trike.Moving(); Assert.AreEqual(false, isMoving); bool hasStarted = trike.Moving(true); Assert.IsTrue(hasStarted); bool hasStopped = trike.Moving(false); Assert.IsFalse(hasStopped); }
public override void Draw(System.Drawing.Rectangle drawRegion, Tricycle.GameWindow gw) { for(int i = 0; i < _actionItems.Count; i++) { if(i == _selected) { gw.DrawString(drawRegion.X, drawRegion.Y + (i*(_drawFont.Height + 2)), Color.Red, _drawFont, _actionItems.Keys.ToList()[i]); } else { gw.DrawString(drawRegion.X+20, drawRegion.Y+ (i * (_drawFont.Height + 2)), Color.Black, _drawFont, _actionItems.Keys.ToList()[i]); } } }
public override bool Process(Tricycle.GameWindow gw) { var settings = Properties.Settings.Default; var key = gw.Keyboard; if (key[settings.NextKey] || StateGlobals.EvaluateGamepad(gw, settings.NextGamePad)) { _selected++; while (StateGlobals.EvaluateGamepad(gw, settings.NextGamePad)) ; } if (key[settings.PrevKey] || StateGlobals.EvaluateGamepad(gw, settings.PrevGamePad)) { _selected--; while (StateGlobals.EvaluateGamepad(gw, settings.PrevGamePad)) ; } if (key[settings.PrevPageKey] || StateGlobals.EvaluateGamepad(gw, settings.PrevPageGamepad)) { _selected -= filesPerPage; while (StateGlobals.EvaluateGamepad(gw, settings.PrevPageGamepad)) ; } if (key[settings.NextPageKey] || StateGlobals.EvaluateGamepad(gw, settings.NextPageGamepad)) { _selected += filesPerPage; while (StateGlobals.EvaluateGamepad(gw, settings.NextPageGamepad)) ; } if (key[settings.SelectKey] || StateGlobals.EvaluateGamepad(gw, settings.SelectGamepadCombo)) { gw.Suspend(); var p = new Process(); p.StartInfo.FileName = settings.EmuPath; p.StartInfo.Arguments = settings.Parameters.Replace("%rom", "\"" + _romList[_selected] + "\""); p.Start(); System.Threading.Thread.Sleep(5000); while (true) { if (gw.Keyboard.GetGlobalKeyState(settings.KillKey) || StateGlobals.EvaluateGamepad(gw, settings.KillGamepadCombo)) { p.CloseMainWindow(); break; } System.Threading.Thread.Sleep(0); } p.Close(); p.Dispose(); gw.Resume(); System.Threading.Thread.Sleep(1000); } _selected = _selected % _romList.Count; if (_selected < 0) { _selected = (maxPages * filesPerPage - (filesPerPage + _selected)) - 1; } return true; }