public void Run(Console console, string command, string[] args) { if (args.Length == 0) { System.Console.WriteLine("Available commands:"); foreach (Console.Command c in console.Commands) System.Console.WriteLine("\t" + c.CommandKey + "\t" + c.Description); } else { string needHelpWith = args[0]; Console.Command c = console.Commands.First(cx=>cx.CommandKey == needHelpWith); if (c == null) { System.Console.WriteLine("Unknown command: " + needHelpWith); } else { try { string helpString = c.Handler.Help(console, needHelpWith); helpString = helpString.Replace("\n","\n\t"); System.Console.WriteLine("Displaying further information for the '" + needHelpWith + "' command:" + System.Environment.NewLine); System.Console.WriteLine("\t" + helpString); } catch (System.Exception) { System.Console.WriteLine("There is no further information on the '" + needHelpWith + "' command."); } } } }
public MainViewModel() { //Console = Console.Default(); var mmu = new Mmu(); Console = new Console( new Cpu(mmu), mmu, new Gpu(mmu, // TODO make palettes configurable from UI //Colors.White, //Colors.LightGray, //Colors.DarkGray, //Colors.Black), //new Color { R = 0xB8, G = 0xC2, B = 0x66 }, //new Color { R = 0x7B, G = 0x8A, B = 0x32 }, //new Color { R = 0x43, G = 0x59, B = 0x1D }, //new Color { R = 0x13, G = 0x2C, B = 0x13 }), Colors.GhostWhite, Colors.LightSlateGray, Colors.DarkSlateBlue, Colors.Black), new Timer(mmu), new Controller(mmu)); Title = "GameboyEm"; OpenCommand = new ActionCommand(Open); LoadStateCommand = new ActionCommand(LoadState); SaveStateCommand = new ActionCommand(SaveState); CloseCommand = new ActionCommand(Application.Current.Shutdown); PowerOnCommand = new ActionCommand(PowerOn); PowerOffCommand = new ActionCommand(PowerOff); ResetCommand = new ActionCommand(Reset); DebuggerCommand = new ActionCommand(Debugger); }
private void CreateWindow() { Window.CreateWindow("OpenGL", _viewport.Width, _viewport.Height); Window.OnReshapeCallbacks.Add(() => { _viewport = new Viewport(Window.Width, Window.Height); _mainCamera.Viewport = _viewport; }); Window.OnCloseCallbacks.Add(DisposeScene); Console.WriteLine($"{GLHelper.DumpComputeShaderCounts()}"); }
public DebuggerViewModel(Console console) { _enableDebugger = true; _console = console; _console.OnBreakpoint += OnBreakpoint; _mmuByteProvider = new MmuByteProvider(_console.Mmu); Steps = 1; Breakpoints = new ObservableCollection<ushort>(); StepCommand = new ActionCommand(Step); AddBreakpointCommand = new ActionCommand(AddBreakpoint); RemoveBreakpointCommand = new ActionCommand(RemoveBreakpoint); Refresh(); }
public static void Main(string[] a) { int m1, m2, m3, m4, m5; float avg; D.WriteLine("Enter marks of 5 sub:"); m1 = int.Parse(D.ReadLine()); m2 = int.Parse(D.ReadLine()); m3 = int.Parse(D.ReadLine()); m4 = int.Parse(D.ReadLine()); m5 = int.Parse(D.ReadLine()); avg = (m1 + m2 + m3 + m4 + m5) / 5; D.WriteLine("Average is: " + avg); }
public GameBrowser(Console inConsole) { InitializeComponent(); Console = inConsole; Games = new ObservableCollection<Game>(); DataContext = this; ReloadGames(); if (Games.Count > 0) ctGamesListBox.SelectedItem = Games.First(); ctGamesListBox.Focus(); ctGamesListBox.KeyDown += ctGamesListBox_KeyDown; }
public static void Main(string[] a) { string name; int rollno; float per; D.WriteLine("Enter your name "); name = D.ReadLine(); D.WriteLine("Enter your roll no "); rollno = int.Parse(D.ReadLine()); D.WriteLine("Enter your percentage "); per = float.Parse(D.ReadLine()); D.WriteLine("Name: " + name + " Roll no: " + rollno + " Percentage: " + per); }
using C = System.Console; class S { int k, u, v, x, y; S() { var m = "#### # ### ## # "; for (; y < 10; y++) { for (x = 0; x < 10; x++) { D(m[W(y) * 5 + W(x)]); } } x = y = 2; D(); for (;;) { k = (int)C.ReadKey(true).Key - 36; u = x; v = y; D(' '); k = k % 2 < 1?v += k < 3?-1:1:u += k < 2?-1:1; if (m[W(v) * 5 + W(u)] == ' ') { x = u; y = v; } D(); } }
/// <summary> /// Creates and sets default values for our light shader. /// </summary> /// <returns></returns> private ShaderProgram NewLightShader() { var shader = GLHelper.NewShader("resources/light-vert.glsl", "resources/light-frag.glsl"); Console.WriteLine("Vertex Shader: {0}", shader.VertexShader.ShaderLog); Console.WriteLine("Fragment Shader: {0}", shader.FragmentShader.ShaderLog); shader["light.Position"].SetValue(new Vector3(5, 5, -2)); shader["light.Ambient"].SetValue(new Vector3(0.3f, 0.3f, 0.3f)); shader["light.Diffuse"].SetValue(Vector3.One); //shader["light.Specular"].SetValue(Vector3.One); shader["light.Constant"].SetValue(1.0f); shader["light.Linear"].SetValue(0.045f); shader["light.Quadratic"].SetValue(0.0075f); //shader["material.Color"].SetValue(new Vector3(1.0f, 1.0f, 1.0f)); shader["material.Texture"].SetValue(0); return(shader); }
private void InitInput() { Input.Subscribe('w', new Event(state => _forwardDown = state)); Input.Subscribe('a', new Event(state => _leftDown = state)); Input.Subscribe('s', new Event(state => _backDown = state)); Input.Subscribe('d', new Event(state => _rightDown = state)); Input.Subscribe('q', new Event(state => _upDown = state)); Input.Subscribe('e', new Event(state => _downDown = state)); RelativeMouse.Enabled = true; const float SpeedReduction = 5.0f; const float ClampY = 89.0f * RoxMath.ToRadians; // Relative mouse movement handler (Mouse lock enabled) RelativeMouse.AddListener((x, y) => { // Aggregate x and y values -- Hard Constraint on +Y axis _mouseX = _mouseX + (x / SpeedReduction); _mouseY = RoxMath.Min(_mouseY + (y / SpeedReduction), _viewport.Height - 1.0f); // Pull any out of bounds coordinates back into window coordinates _mouseX = (_mouseX % _viewport.Width); _mouseY = (_mouseY % _viewport.Height); // Map to Window ratio _lookRotation.X = (_mouseX / _viewport.Width) * RoxMath.TwoPi; _lookRotation.Y = (_mouseY / _viewport.Height) * RoxMath.Pi; // Constrain to: // (-360, 360) for x-axis // (-89, 89) for y-axis _lookRotation.X = RoxMath.Clamp(_lookRotation.X, RoxMath.TwoPi); _lookRotation.Y = RoxMath.Clamp(_lookRotation.Y, ClampY); }); // TBD: Voxel modification Window.OnMouseCallbacks.Add((b, s, x, y) => { Console.WriteLine($"button: {b}, state: {s}, x: {x}, y: {y}"); return(true); }); }
private static void Scratch() { var _radius = 8; var min = new Vector3( (Chunk.Width * _radius) / 2.0f, (Chunk.Height * _radius) / 2.0f, (Chunk.Depth * _radius) / 2.0f); var max = min + new Vector3(Chunk.Width, Chunk.Height, Chunk.Depth); min.X = (int)min.X / Chunk.Width; min.Y = (int)min.Y / Chunk.Height; min.Z = (int)min.Z / Chunk.Depth; max.X = (int)max.X / Chunk.Width; max.Y = (int)max.Y / Chunk.Height; max.Z = (int)max.Z / Chunk.Depth; Console.WriteLine($"Min: {min}\nMax: {max}"); Console.ReadLine(); }
public void Run() { while (true) { string url = C.ReadLine(); if (url != null) { break; } url = url.Trim(); if (string.IsNullOrEmpty(url)) { try { var ep = new Endpoint(url); string viewResult = this.d.DispatchAction(ep); System.Console.WriteLine(viewResult); } catch (System.Exception ex) { C.WriteLine(ex.Message); } } } }
static void Main(string[] z) { try { for (dynamic c, p = z[0], a = new int[30000], s = new int[9], f = 1 > 0, i = 0, d = 0, t = 0;; i = c == 51 && f & (f |= s[--t] < 0)?s[t]:++i) { c = p[i] - 42; a[d += (c - 19) * (f & c > 17 & c < 21?1:0)] += (2 - c) * (f & c > 0 & c < 4?1:0); if (f & c == 4) { C.Write((char)a[d]); } if (f & c == 2) { a[d] = C.Read(); } if (c == 49) { s[t++] = f?(f = a[d] != 0)?i:-1:i; } } } catch {} }
public FloatVar(Console console, string name, Accessor<float> target, float min, float max, string info = "") : base(console, name, info) { Min = min; Max = max; Target = target; }
for(DroidInitUI.Equals): meta::Object(Console) { }
public Func(Console console, string name, Action handler, string info = "") : base(console, name, info) { Handler = handler; }
public Drawer () { } //? public void Draw //function to draw { Console.ForegroundColor = color;
public IntegerFunc(Console console, string name, Action<int> handler, int min, int max, string info = "") : base(console, name, info) { Handler = handler; Min = min; Max = max; }
void OnLevelWasLoaded(int level) { if (level == 2) { GameObject consoleObj = GameObject.Find("Notifications"); if (consoleObj != null) { console = consoleObj.GetComponent<Console>(); modCore.console = console; modApi.console = console; } } ModCore.Log("\"" + Application.loadedLevelName + "\" (" + level + ") was loaded."); }
public BooleanFunc(Console console, string name, Action<bool> handler, string info = "") : base(console, name, info) { Handler = handler; }
public IntegerVar(Console console, string name, Accessor<int> target, int min, int max, string info = "") : base(console, name, info) { Min = min; Max = max; Target = target; }
public StringFunc(Console console, string name, Action<string> handler, int maxLength, string info = "") : base(console, name, info) { Handler = handler; MaxLength = maxLength; }
public Session(Console console) { Console = console ; }
public StringVar(Console console, string name, Accessor<string> target, int maxLength, string info = "") : base(console, name, info) { MaxLength = maxLength; Target = target; }
public MainShell(Console AConsole, Keyboard AKeyboard) : base(AConsole, AKeyboard) { }
public BooleanVar(Console console, string name, Accessor<bool> target, string info = "") : base(console, name, info) { Target = target; }
protected override int DoRun(Console.ConsoleOptions options, bool redirectOutput, bool redirectError, TestPackage package, TextWriter outWriter, TextWriter errorWriter, TestFilter testFilter, out TestResult result, EventCollector collector) { result = null; var testRunner1 = new DefaultTestRunnerFactory().MakeTestRunner(package); try { testRunner1.Load(package); if (testRunner1.Test == null) { testRunner1.Unload(); System.Console.Error.WriteLine("Unable to locate fixture {0}", options.fixture); return FIXTURE_NOT_FOUND; } } finally { var disp = testRunner1 as IDisposable; if (disp != null) disp.Dispose(); } result = new TestResult(new TestName { Name = "Global" }); var timer = new Stopwatch(); timer.Start(); var testRunnerId = 0; { var syncTestRunner = new DefaultTestRunnerFactory().MakeTestRunner(package); var syncFilter = new AndFilter(testFilter, new SynchronousFilter()); var logger = new ConsoleLoggingEventListener(collector); result.AddResult(RunPartition(redirectOutput, redirectError, package, outWriter, errorWriter, syncFilter, syncTestRunner, logger)); testRunnerId = syncTestRunner.ID; } var dep = 0; var consoleOptions = options as ConsoleOptions; if (options != null) dep = consoleOptions.degreeofparallelism; if (dep == 0) dep = 4; System.Console.WriteLine("Degree of Parallelism: {0}", dep); var state = new AsynchronousFilterState(dep); var asyncTestRunner = new ParallelTestRunner(testRunnerId + 1, dep, state); result.AddResult(RunPartition(redirectOutput, redirectError, package, outWriter, errorWriter, testFilter, asyncTestRunner, collector)); if (consoleOptions != null && consoleOptions.retestfailures) { var failedTests = (from test in Flatten(result) where test.Result.IsFailure select test).ToList(); var failedTestFilter = new SimpleNameFilter(failedTests.Select(t => t.Result.FullName)); var retestTestRunner = new DefaultTestRunnerFactory().MakeTestRunner(package); var retestFilter = new AndFilter(testFilter, failedTestFilter); var logger = new ConsoleLoggingEventListener(collector); var retestResults = RunPartition(redirectOutput, redirectError, package, outWriter, errorWriter, retestFilter, retestTestRunner, logger); var newTests = Flatten(retestResults).ToDictionary(test => test.Result.FullName); foreach (var failedTest in failedTests) { var newTest = newTests[failedTest.Result.FullName]; if (newTest.Result.IsSuccess) { failedTest.Parent.Results.Remove(failedTest.Result); failedTest.Parent.Results.Add(newTest.Result); } } } result = MergeResults(result.Test, (TestResult)result.Results[0], (TestResult)result.Results[1]); timer.Stop(); result.Time = timer.ElapsedTicks / (double)TimeSpan.TicksPerSecond; return 0; }
public string Help(Console console, string command) { return "Type '" + Command + "' followed by\nthe command you'd like further information about."; }
public static void Solve() { string inputPath = FileUtils.GetProjectFilePath("Days/Day6/ProblemA/input.txt"); string[] lines = File.ReadAllLines(inputPath); List <Point> points = new List <Point>(); int minX = Int32.MaxValue; int minY = Int32.MaxValue; int maxX = Int32.MinValue; int maxY = Int32.MinValue; foreach (var line in lines) { var p = new Point(line); if (p.X < minX) { minX = p.X; } if (p.Y < minY) { minY = p.Y; } if (p.X > maxX) { maxX = p.X; } if (p.Y > maxY) { maxY = p.Y; } points.Add(p); } Log.WriteLine("Grid is between " + minX + "," + minY + " and " + maxX + "," + maxY); Point bestPoint = null; HashSet <int> distances = new HashSet <int>(); for (int i = minX; i <= maxX; i++) { for (int j = minY; j <= maxY; j++) { int closestDistance = Int32.MaxValue; Point winningPoint = null; //distances.Clear(); foreach (var p in points) { int dist = p.ManhattanDistance(i, j); if (dist == closestDistance) // Bounce out if one or more distancs is duped { winningPoint = null; continue; } //distances.Add(dist); if (dist < closestDistance) { winningPoint = p; closestDistance = dist; } } if (winningPoint != null) { winningPoint.OwnedTerritory++; if (bestPoint == null || bestPoint.OwnedTerritory < winningPoint.OwnedTerritory) { bestPoint = winningPoint; } } } } Log.WriteLine("best point is " + bestPoint.X + "," + bestPoint.Y + " with territory " + bestPoint.OwnedTerritory); }
public VirtualStream(Console.Console console) { _console = console; _buffer = new MemoryStream(); }
private static void Main() { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(true); var logFileName = String.Format("xrConsole_{0}.log", Environment.UserName); logger = new PlainLogger(logFileName); consoleWnd = new ConsoleWindow(); console = consoleWnd.Console; console.AttachLogger(logger); console.AddCommand(new Func(console, "quit", Console_Quit)); console.AddCommand(new Func(console, "clear_log", Console_ClearLog, "Clear log")); console.AddCommand(new StringVar(console, "font_face", new Accessor<string>(Console_GetFontFace, Console_SetFontFace), 255, "Console font face")); console.AddCommand(new FloatVar(console, "font_size", new Accessor<float>(Console_GetFontSize, Console_SetFontSize), 5.0f, 20.0f, "Console font size")); console.Header.Add(new ConsoleLabel { Text = "The quick brown fox jumps over the lazy dog", Color = ConsoleColors.DarkBlue }); console.Header.Add(new ConsoleLabel { Text = "Another useful label", Color = ConsoleColors.DarkMagneta }); consoleWnd.ShowDialog(); if (logger != null) { logger.Dispose(); } }
private void LoadState() { var dlg = new OpenFileDialog { DefaultExt = ".state", Filter = "Gameboy State Files (*.state)|*.state" }; if (dlg.ShowDialog() == true) { try { using (var fs = new FileStream(dlg.FileName, FileMode.Open)) { Console = (Console)new BinaryFormatter().Deserialize(fs); } NotifyAll(); } catch (Exception e) { MessageBox.Show("Error", e.ToString(), MessageBoxButton.OK, MessageBoxImage.Error); } } }
public VirtualConsole(Session session, Console.Console console) { _writer = new VirtualWriter(console); _session = session; _console = console; }
public FloatFunc(Console console, string name, Action<float> handler, float min, float max, string info = "") : base(console, name, info) { Handler = handler; Min = min; Max = max; }
public VirtualWriter(Console.Console console) { _console = console; }
public string Help(Console console, string command) { throw new NotImplementedException(); }
public void Run(Console console, string command, string[] args) { console.Exit(); }
private void testConsoleToolStripMenuItem_Click(object sender, EventArgs e) { Console con = new Console(); con.Show(); }
/// <summary> /// Load any game content here. We have a reasonable amount to set up now; we have /// our game related setup as well as our 3d world and effects. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _sb = new SpriteBatch(GraphicsDevice); _font = Content.Load<SpriteFont>("SegoeUI"); // We'll need to know our viewport height throughout _scrWidth = GraphicsDevice.Viewport.Width; _scrHeight = GraphicsDevice.Viewport.Height; _pong = new Pong(_scrWidth, _scrHeight); _pong.Init(Content); // Set up our console _cs = new Console(GraphicsDevice, _font); _menu = new Menu(GraphicsDevice, _font); _bg = Color.Black; }
public static void Main() { BasicConsole.Clear(); Console.InitDefault(); // Wait for other system startup to occur Processes.SystemCalls.SleepThread(1000); MainConsole = new Consoles.AdvancedConsole(); MainConsole.ScreenHeight = 7; MainConsole.LineLength = 55; MainConsole.ScreenStartLineOffset = 0; MainConsole.UpdateScreenCursor = false; StatusConsole = new Consoles.AdvancedConsole(); StatusConsole.ScreenHeight = 7; StatusConsole.LineLength = 24; StatusConsole.ScreenStartLineOffset = 56; StatusConsole.UpdateScreenCursor = false; MainConsole.Clear(); StatusConsole.Clear(); bool StatusLine1 = true; Hardware.DeviceManager.AddDeviceAddedListener(DeviceManager_DeviceAdded, null); Processes.SystemCalls.SleepThread(500); Console.Default.ScreenHeight = 25 - 8; Console.Default.ScreenStartLine = 8; while (!Terminating) { try { ((Consoles.AdvancedConsole)StatusConsole).DrawBottomBorder(); ((Consoles.AdvancedConsole)StatusConsole).DrawLeftBorder(); ((Consoles.AdvancedConsole)MainConsole).DrawBottomBorder(); StatusConsole.Clear(); if (StatusLine1) { StatusConsole.WriteLine("State: 1"); } else { StatusConsole.WriteLine("State: 2"); } StatusLine1 = !StatusLine1; StatusConsole.Write("Processes: "); StatusConsole.WriteLine_AsDecimal(ProcessManager.Processes.Count); int ThreadCount = 0; int SleptThreads = 0; int IndefiniteSleptThreads = 0; for (int i = 0; i < ProcessManager.Processes.Count; i++) { List threads = ((Process)ProcessManager.Processes[i]).Threads; ThreadCount += threads.Count; for (int j = 0; j < threads.Count; j++) { Thread thread = (Thread)threads[j]; if (thread.TimeToSleep == Thread.IndefiniteSleep) { IndefiniteSleptThreads++; SleptThreads++; } else if (thread.TimeToSleep > 0) { SleptThreads++; } } } StatusConsole.Write("Threads: "); StatusConsole.Write_AsDecimal(ThreadCount); StatusConsole.Write(" / "); StatusConsole.Write_AsDecimal(SleptThreads); StatusConsole.Write(" / "); StatusConsole.WriteLine_AsDecimal(IndefiniteSleptThreads); StatusConsole.Write("Devices: "); StatusConsole.WriteLine_AsDecimal(Hardware.DeviceManager.Devices.Count); StatusConsole.Write("File Sys:"); for(int i = 0; i < FileSystemManager.FileSystemMappings.Count; i++) { FileSystemMapping mapping = (FileSystemMapping)FileSystemManager.FileSystemMappings[i]; StatusConsole.Write(" "); StatusConsole.Write(mapping.Prefix); } StatusConsole.WriteLine(); StatusConsole.Write("USB Devices: "); StatusConsole.WriteLine_AsDecimal(Hardware.USB.USBManager.Devices.Count); unsafe { StatusConsole.Write("Heap: "); //StatusConsole.Write_AsDecimal(Heap.GetTotalUsedMem()); //StatusConsole.Write(" / "); //StatusConsole.Write_AsDecimal(Heap.GetTotalMem()); uint totalMem = Heap.GetTotalMem(); StatusConsole.Write_AsDecimal(Heap.GetTotalUsedMem() / (totalMem / 100)); StatusConsole.Write("% / "); StatusConsole.Write_AsDecimal(totalMem / 1024); StatusConsole.Write(" KiB"); } } catch { MainConsole.ErrorColour(); MainConsole.WriteLine("Error updating the status console:"); if (ExceptionMethods.CurrentException != null) { MainConsole.WriteLine(ExceptionMethods.CurrentException.Message); } MainConsole.DefaultColour(); } MainConsole.Update(); StatusConsole.Update(); Processes.SystemCalls.SleepThread(500); } }