public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { if (key == Key.SPACE) { OpenDocument(state); } }
private void LadderBtn_Click(object sender, EventArgs e) { mainBackPanel.Controls.Clear(); _viewState = ViewerState.LadderState; for (int i = _MainSeason.ladder.Count - 1; i >= 0; i--) { Panel p = new Panel(); p.Name = $""; p.BackColor = Color.FromArgb(95, 173, 43, 200); Label lbl = new Label(); lbl.Name = "lbl" + i; lbl.Tag = i.ToString(); lbl.Click += ladderPanel_Click; lbl.Size = new Size(mainBackPanel.ClientSize.Width - 40, 65); lbl.Text = $"{i + 1}. {_MainSeason.ladder[i].name}\nWins: {_MainSeason.ladder[i].wins} | Lost: {_MainSeason.ladder[i].lost}\nPoints: {_MainSeason.ladder[i].points}\nPoints Difference: {_MainSeason.ladder[i].pointsfor - _MainSeason.ladder[i].pointsagainst}"; p.Size = new Size(mainBackPanel.ClientSize.Width - 40, 65); p.Controls.Add(lbl); mainBackPanel.Controls.Add(p); mainBackPanel.Controls.SetChildIndex(p, 0); // this moves the new one to the top! // this is just for fun: p.Paint += (ss, ee) => { ee.Graphics.DrawString(p.Name, Font, Brushes.White, 22, 11); }; p.Click += matchPanel_Click; mainBackPanel.Invalidate(); } }
public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { if (key == Key.ENTER) { state.Document.PromptEntered(builder.ToString()); state.Cursor.Down(); return; } else if (key == Key.BACKSPACE) { if (builder.Length <= 0) { return; } builder.Remove(relativeOffset - 1, 1); state.Cursor.SetPosition(state.Cursor.DocumentPosition - 1); } if (!character.HasValue) { return; } state.Cursor.SetPosition(state.Cursor.DocumentPosition + 1); builder.Insert(relativeOffset, character.Value); }
public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { if (key == Key.SPACE || key == Key.ENTER) { state.Document.ButtonClicked(this); } }
private void LoadKeyFile(string keyFileName) { if (string.IsNullOrEmpty(keyFileName)) { throw new ArgumentNullException("keyFileName"); } var file = new FileInfo(keyFileName); if (!file.Exists) { throw new FileNotFoundException(keyFileName); } var oldViewerState = (ViewerState)_viewerState.Clone(); try { _viewerState.Filename = keyFileName; _viewerState.KeyFile = KeyFile.Load(keyFileName); ParseKeyFile(); } catch (Exception e) { MessageBox.Show(string.Format("An error occurred while loading the file.\n\n {0}", e.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); _viewerState = oldViewerState; } }
public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { if (key == Key.SPACE || key == Key.ENTER) { Toggle(state); } }
private void LdrBoardBtn_Click(object sender, EventArgs e) { currentRound = 0; RoundLabel.Text = (currentRound + 1).ToString(); _viewState = ViewerState.LeaderboardState; LoadLeaderboard(currentRound); }
private void hmePage_Click(object sender, EventArgs e) { _viewState = ViewerState.MatchupsState; currentRound = 0; RoundLabel.Text = (currentRound + 1).ToString(); LoadRoundMatchups(currentRound); }
public EntryRenderContext(Document document, ViewerState state, RenderOptions renderOptions) { State = state; Document = document; RenderPosition = 0; renderOptionsStack = new Stack <RenderOptions>(); renderOptionsStack.Push(renderOptions); }
public void WriteToFrameBuffer(ViewerState state, byte[] frameBuffer, int pixelOffset) { var ctx = new SpriteRenderContext(state); foreach (var element in _spriteElements) { element.Render(ctx, frameBuffer, pixelOffset); Console.WriteLine("Rendered {0}", element); } }
private void UpdateInnerState(ViewerState state) { InnerState = state; UpdateAppBar(); if (reloadLater && state == ViewerState.Single) { LoadContents(); } }
public void SendViewerState(List <ReceiverState> receiverStates) { var viewerState = new ViewerState(UserId, receiverStates); var viewerStateJson = JsonUtility.ToJson(viewerState); var viewerStateBytes = Encoding.ASCII.GetBytes(viewerStateJson); var ms = new MemoryStream(); ms.Write(BitConverter.GetBytes(viewerStateBytes.Length), 0, 4); ms.Write(viewerStateBytes, 0, viewerStateBytes.Length); tcpSocket.Send(ms.ToArray()); }
private void SelectNextValue(ViewerState state) { selectedIndex++; if (selectedIndex >= values.Count) { selectedIndex = 0; } var k = values.Keys.ToArray()[selectedIndex]; state.Document.FieldChanged(GetArgument("PROP"), values[k]); }
public void MoveLeft_DoesNotMovePastTheBeginning() { var doc = new Document("$TX,\"Hello World!\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); cursor.Left(); Assert.AreEqual(0, cursor.DocumentPosition); }
public void MoveRight_WithinSameEntry() { var doc = new Document("$TX,\"Hello World!\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); cursor.Right(); Assert.AreEqual(1, cursor.DocumentPosition); }
private void Toggle(ViewerState state) { // Invoke macro call if an LM argument is provided. if (HasArgument("LM")) { state.Document.Macro(this); } var @checked = state.Document.GetData(Property) as bool? ?? false; state.Document.FieldChanged(GetArgument("PROP"), !@checked); }
public void MoveRight_ToNextEntry() { var doc = new Document("$TX,\"ABC\"$$TX+CX,\"Centered\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); cursor.Right(); cursor.Right(); cursor.Right(); Assert.AreEqual(36, cursor.DocumentPosition); }
private void Toggle(ViewerState state) { if (HasFlag("C", false)) { // It is expended, collapse it. Flags.Remove(Flags.FirstOrDefault(f => f.Value == "C" && !f.Status)); } else { Flags.Add(new Flag(false, "C")); } state.Document.Reload(); }
public void MoveLeft_MovesWithinSameEntry() { var doc = new Document("$TX,\"Hello World!\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); cursor.SetPosition(5); doc.Refresh(); cursor.Left(); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); Assert.AreEqual(4, cursor.DocumentPosition); }
public void MoveRight_DoesNotMovePastTheEnd() { var doc = new Document("$TX,\"ABC\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); for (int i = 0; i < 10; i++) { cursor.Right(); } Assert.AreEqual(2, cursor.DocumentPosition); }
public void MoveDown_ToNextEntry() { var doc = new Document("$TX,\"ABC\"$\nDEF"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); cursor.Down(); Assert.AreEqual(state.Columns, cursor.DocumentPosition); Assert.AreEqual(doc.Entries.First.Next.Value, cursor.SelectedEntry); }
public void MoveDown_WithinSameEntry() { var doc = new Document(new string('A', 80 * 2)); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); cursor.Down(); Assert.AreEqual(state.Columns, cursor.DocumentPosition); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); }
public void Show(string title, int width, int height, Document document = null) { thread = new Thread(() => { Log.Verbose("Starting OpenGLNativeWindow thread..."); _framebuffer = new EgaColor[width * height]; nativeWindow = new NativeWindow(new NativeWindowSettings { Size = new Vector2i(width, height), Profile = ContextProfile.Compatability, WindowBorder = WindowBorder.Fixed, IsEventDriven = false, Title = title }); unsafe { graphicsContext = new GLFWGraphicsContext(nativeWindow.WindowPtr); } nativeWindow.CenterWindow(); this.document = document ?? new Document(); viewerState = new ViewerState(this, this.document, width, height, new YaffFontProvider(), "Terminal_VGA_cp861"); viewerState.Pages.Clear(); document.Refresh(); ulong ticks = 0; timer = new Timer(_ => viewerState.Tick(ticks++), null, 0, 1000 / 30); OnLoad(); nativeWindow.KeyDown += NativeWindow_KeyDown; nativeWindow.MouseMove += NativeWindow_MouseMove; nativeWindow.MouseUp += NativeWindow_MouseUp; nativeWindow.MouseWheel += NativeWindow_MouseWheel; while (nativeWindow.Exists) { nativeWindow.ProcessEvents(); // TODO: fps restrict OnRenderFrame(); Thread.Sleep(1); } }); thread.Start(); }
private void OpenDocument(ViewerState state) { var file = string.IsNullOrEmpty(Aux) ? Tag : Aux; // Follow the link. if (!File.Exists(file)) { return; } using (var fs = File.Open(file, FileMode.Open)) { var document = DocumentLoader.Load(fs, file); state.LoadDocument(document, true); } }
public void MoveDown_UpdatesViewLine() { var doc = new Document(new string('A', 80 * 60 * 2)); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); doc.Refresh(); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); for (int i = 0; i < 62; i++) { cursor.Down(); } Assert.AreEqual(3, cursor.ViewLine); }
public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { var value = state.Document.GetData(Property)?.ToString() ?? string.Empty; if (key == Key.BACKSPACE && value.Length > 0) { value = value.Remove(value.Length - 1, 1); state.Document.FieldChanged(Property, value); return; } if (!character.HasValue) { return; } value += character.Value; state.Document.FieldChanged(Property, value); }
public void MoveLeft_ToPreviousEntry() { /* * ABC--------------------------------Centered------------------------------------- */ var doc = new Document("$TX,\"ABC\"$$TX+CX,\"Centered\"$"); var state = new ViewerState(null, doc, 640, 480); var cursor = new Cursor(state); cursor.SetPosition(36); doc.Refresh(); Assert.AreEqual(doc.Entries.First.Next.Value, cursor.SelectedEntry); cursor.Left(); Assert.AreEqual(2, cursor.DocumentPosition); Assert.AreEqual(doc.Entries.First.Value, cursor.SelectedEntry); }
public override void KeyPress(ViewerState state, Key key, char?character, int relativeOffset) { if (character.HasValue) { Arguments[0].Value = Arguments[0].Value.Insert(relativeOffset, new string(character.Value, 1)); //state.CursorPosition++; state.Cursor.Right(); } switch (key) { case Key.ENTER: Arguments[0].Value = Arguments[0].Value.Insert(relativeOffset, new string('\n', 1)); break; case Key.DEL: Arguments[0].Value = Arguments[0].Value.Remove(relativeOffset, 1); break; case Key.BACKSPACE: if (relativeOffset > 0) { Arguments[0].Value = Arguments[0].Value.Remove(relativeOffset - 1, 1); //state.CursorPosition--; state.Cursor.Left(); } else if (state.Pages[state.CursorPosition - 1].HasEntry) { state.Document.Entries.Remove(state.Pages[state.CursorPosition - 1].Entry); // TODO: update cursor minus length of entry // state.CursorPosition -= } break; } }
public Cursor(ViewerState viewerState) { _viewerState = viewerState; }
public void ChangeState(ViewerState to) { ; }