// string path = ""; private void showExample() { BrailleIOScreen s = new BrailleIOScreen(); #region Center Region #region screenshot Image bmp = captureScreen(); #endregion BrailleIOViewRange center = new BrailleIOViewRange(0, 7, 120, 46, new bool[120, 40]); //center.Move(1,1); center.SetBitmap(bmp); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(150); center.ShowScrollbars = true; s.AddViewRange("center", center); #endregion #region Top Reagion BrailleIOViewRange top = new BrailleIOViewRange(0, 0, 120, 7); top.SetBorder(0, 0, 1); top.SetMargin(0, 0, 1); top.SetPadding(0, 0, 1); top.SetText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwxyz\r\n0123456789!\"#$%&<=>?@©®\r\n*+-~:;[],.'^_`(){}/|\\r\nß\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n"); top.SetText("Tactile screen capture"); s.AddViewRange("top", top); #endregion #region Bottom Reagion BrailleIOViewRange bottom = new BrailleIOViewRange(0, 53, 120, 7); bottom.SetBorder(1, 0, 0); bottom.SetMargin(1, 0, 0); bottom.SetPadding(1, 0, 0); bottom.SetText("Detail area: status messages can be shown"); s.AddViewRange("bottom", bottom); #endregion io.AddView(BS_MAIN_NAME, s); io.ShowView(BS_MAIN_NAME); io.RenderDisplay(); }
/// <summary> /// Sets the content of the region. /// </summary> /// <param name="screen">The screen.</param> /// <param name="vrName">Name of the region (viewRange).</param> /// <param name="content">The content.</param> /// <returns>true if the content could be set, otherwise false</returns> private bool setRegionContent(BrailleIOScreen screen, String vrName, Object content) { if (screen != null) { BrailleIOViewRange vr = screen.GetViewRange(vrName); if (vr != null) { if (content != null) { if (content is bool[, ]) { vr.SetMatrix(content as bool[, ]); } else if (content is Bitmap) { vr.SetBitmap(content as Bitmap); } else if (content is String) { vr.SetText(content.ToString()); } else { return(false); } return(true); } else { vr.SetMatrix(null); } //TODO: check if this works } } return(false); }
public override void Resize(int width, int height) { title.SetLeft(2); title.SetTop(2); title.SetWidth(width - 4); title.SetHeight(width - 4); title.SetText(ll.GetTrans("game.title") + "\n" + ll.GetTrans("game.keybindings1") + "\n" + ll.GetTrans("game.keybindings2") + "\n" + ll.GetTrans("game.keybindings3") + "\n" + ll.GetTrans("game.keybindings4")); }
public StartScreen(LL ll, int width, int height) : base("StartScreen") { this.ll = ll; title = new BrailleIOViewRange(2, 2, width - 4, height - 4); title.SetText(ll.GetTrans("game.title") + "\n" + ll.GetTrans("game.keybindings1") + "\n" + ll.GetTrans("game.keybindings2") + "\n" + ll.GetTrans("game.keybindings3") + "\n" + ll.GetTrans("game.keybindings4")); AddViewRange(title); }
// string path = ""; private void showExample() { BrailleIOScreen s = new BrailleIOScreen(); #region Center Region #region screenshot Image bmp = captureScreen(); #endregion BrailleIOViewRange center = new BrailleIOViewRange(0, 0, 120, 60, new bool[120, 40]); center.SetMargin(7, 0, 0); center.Move(1, 1); center.SetBitmap(bmp); center.SetZoom(-1); center.SetBorder(0); center.SetContrastThreshold(150); s.AddViewRange("center", center); #endregion #region Top Region BrailleIOViewRange top = new BrailleIOViewRange(0, 0, 120, 7, new bool[0, 0]); top.SetBorder(0, 0, 1); top.SetMargin(0, 0, 1); top.SetPadding(0, 0, 1); top.SetText("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwxyz\r\n0123456789!\"#$%&<=>?@©®\r\n*+-~:;[],.'^_`(){}/|\\r\nß\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n"); top.SetText("Tactile screen capture"); s.AddViewRange("top", top); #endregion IO.AddView(BS_MAIN_NAME, s); IO.ShowView(BS_MAIN_NAME); IO.RenderDisplay(); }
/// <summary> /// Set text value of a view range and scrolls to the bottom if necessary. /// </summary> /// <param name="vr">View range to fill with content.</param> /// <param name="text">Text content.</param> private void setScrollableViewRangeTextContent(BrailleIOViewRange vr, string text) { if (vr != null) { vr.SetText(text); if (text.Length <= 40) { return; // TODO: only hack because at this point contentHeight is that of last shown content --> if the new content is very short, than the scrolling would show it out of view range } int contentHeight = vr.ContentHeight - 1; // TODO: ignore last line in content renderer instead of "-1" if (vr.ShowScrollbars && (contentHeight > vr.ContentBox.Height)) // TODO: adaption also necessary if content is smaller than offset position { int diff = vr.ContentBox.Height - contentHeight; scrollViewRangeTo(vr, diff); } } }
private bool[,] RenderTextBoxTextView(IViewBoxModel view, UiElement textBoxContent) { MatrixBrailleRenderer m = new MatrixBrailleRenderer(); BrailleIOViewRange tmpTextBoxView; BrailleIOMediator brailleIOMediator = BrailleIOMediator.Instance; BrailleIOScreen screen = brailleIOMediator.GetView(textBoxContent.screenName) as BrailleIOScreen; if (screen.GetViewRange("_TextBoxText_" + textBoxContent.viewName) as BrailleIOViewRange != null) { tmpTextBoxView = screen.GetViewRange("_TextBoxText_" + textBoxContent.viewName) as BrailleIOViewRange; } else { tmpTextBoxView = new BrailleIOViewRange(view.ViewBox.Left + 3, view.ViewBox.Top + 2, view.ViewBox.Width - 5, view.ViewBox.Height - 4); tmpTextBoxView.Name = "_TextBoxText_" + textBoxContent.viewName; tmpTextBoxView.SetText(textBoxContent.text); tmpTextBoxView.ShowScrollbars = textBoxContent.isScrollbarShow; } tmpTextBoxView.SetZIndex(3); bool[,] textMatrix; if (tmpTextBoxView.ContentBox.Height <= 0 || tmpTextBoxView.ContentBox.Width <= 0) { textMatrix = new bool[0, 0]; } else { textMatrix = m.RenderMatrix(tmpTextBoxView, (textBoxContent.text as object == null ? "" : textBoxContent.text as object)); } if (screen != null) { BrailleIOViewRange viewRange = screen.GetViewRange(tmpTextBoxView.Name); if (viewRange == null) { ((BrailleIOScreen)brailleIOMediator.GetView(textBoxContent.screenName)).AddViewRange(tmpTextBoxView.Name, tmpTextBoxView); viewRange = screen.GetViewRange(tmpTextBoxView.Name); } viewRange.SetText(textBoxContent.text); } return(textMatrix); }
private void createOrUpdate(int width, int itemHeight) { if (menu != null) { if (ranges == null || ranges.Any(r => r == null)) { ranges = new BrailleIOViewRange[menu.Length]; for (int i = 0; i < ranges.Length; i++) { BrailleIOViewRange range = new BrailleIOViewRange(left, top + i * itemHeight, width - left, itemHeight); range.SetText(menu.GetLabel(i)); ranges[i] = range; AddViewRange(range); } } if (ranges != null) { for (int i = 0; i < ranges.Length; i++) { ranges[i].SetTop(top + i * itemHeight); ranges[i].SetWidth(width - left); ranges[i].SetHeight(itemHeight); if (menu.index == i) { ranges[i].SetBorder(1); ranges[i].SetPadding(1); } else { ranges[i].SetBorder(0); ranges[i].SetPadding(2); } } } } }
public bool[,] RenderGroup(IViewBoxModel view, UiElement groupViewRange) { //call pre hooks object cM = groupViewRange.text as object; callAllPreHooks(ref view, ref cM); bool[,] viewMatrix = new bool[0, 0];// = new bool[view.ViewBox.Height, view.ViewBox.Width]; //TODO: - Padding etc. int maxHeight = view.ViewBox.Height; int maxWidth = view.ViewBox.Width; if (groupViewRange.child != null) { getMax(ref maxHeight, ref maxWidth, groupViewRange.child); viewMatrix = new bool[maxHeight, maxWidth]; if (groupViewRange.child[0].renderer != null && groupViewRange.child[0].renderer.GetType().Equals(typeof(BrailleIOTabItemToMatrixRenderer)) && groupViewRange.child[0].childUiElement.uiElementSpecialContent != null) { if (groupViewRange.child[0].childUiElement.uiElementSpecialContent.GetType().Equals(typeof(UiElements.TabItem))) { UiElements.TabItem tabView = (UiElements.TabItem)groupViewRange.child[0].childUiElement.uiElementSpecialContent; if (tabView.orientation.Equals(UiElements.Orientation.Bottom)) { viewMatrix = Helper.createDownBorder(maxHeight, maxWidth); } if (tabView.orientation.Equals(UiElements.Orientation.Top)) { viewMatrix = Helper.createUpBorder(maxHeight, maxWidth); } if (tabView.orientation.Equals(UiElements.Orientation.Left)) { viewMatrix = Helper.createLeftBorder(maxHeight, maxWidth); } if (tabView.orientation.Equals(UiElements.Orientation.Right)) { viewMatrix = Helper.createRightBorder(maxHeight, maxWidth); } } } foreach (Groupelements child in groupViewRange.child) { BrailleIOViewRange tmpChildView = new BrailleIOViewRange(Convert.ToInt32(child.childBoundingRectangle.Left), Convert.ToInt32(child.childBoundingRectangle.Top), Convert.ToInt32(child.childBoundingRectangle.Width), Convert.ToInt32(child.childBoundingRectangle.Height)); // BrailleIOViewRange tmpChildView = new BrailleIOViewRange(0, Convert.ToInt32(child.childBoundingRectangle.Top), Convert.ToInt32(child.childBoundingRectangle.Width), Convert.ToInt32(child.childBoundingRectangle.Height)); tmpChildView.Name = "_" + child.childBoundingRectangle.ToString(); //child.childUiElement.viewName; tmpChildView.SetText(child.childUiElement.text); tmpChildView.ShowScrollbars = child.childUiElement.isScrollbarShow; bool[,] childMatrix; if (child.renderer != null) { childMatrix = child.renderer.RenderMatrix(tmpChildView, child.childUiElement as object); } else { MatrixBrailleRenderer m = new MatrixBrailleRenderer(); childMatrix = m.RenderMatrix(tmpChildView, child.childUiElement.text as object); } Helper.copyMatrixInMatrix(childMatrix, ref viewMatrix, Convert.ToInt32(child.childBoundingRectangle.TopLeft.X) - (Convert.ToInt32(view.ContentBox.X) + Convert.ToInt32(view.ViewBox.X)), Convert.ToInt32(child.childBoundingRectangle.TopLeft.Y) - (Convert.ToInt32(view.ContentBox.Y) + Convert.ToInt32(view.ViewBox.Y))); } } view.ContentHeight = maxHeight; view.ContentWidth = maxWidth; //call post hooks callAllPostHooks(view, cM, ref viewMatrix, false); return(viewMatrix); }
/// <summary> /// Called every frame to drive the game logic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Tick() { // Push the last update to the screen if (!buffers[0].Equals(buffers[1]) || textRegionDirty) { textRegionDirty = false; Render(); } // Update the controllers characterController.Update(); levelController.Update(); dialogueController.Update(); // Do the rendering/sound stuff. TODO: Clean this up with views buffers[bufferIndex].Clear(); buffers[bufferIndex].X = (levelModel.Avatar.X + levelModel.Avatar.Width / 2) - buffers[bufferIndex].Width / 2; buffers[bufferIndex].Y = (levelModel.Avatar.Y + levelModel.Avatar.Height / 2) - buffers[bufferIndex].Height / 2; foreach (WorldObject obj in levelModel.level.Objects) { if (!obj.isHidden) { buffers[bufferIndex].Draw(obj); } } buffers[bufferIndex].Draw(levelModel.Avatar); mainRegion.SetMatrix(buffers[bufferIndex].Data); bufferIndex = (bufferIndex + 1) % 2; if (gameState == GameState.Event && gameDialogue.HasAction()) { if (detailRegion.GetText() != gameDialogue.GetCurrent()) { detailRegion.SetText(gameDialogue.GetCurrent()); textRegionDirty = true; Audio.AbortCurrentSound(); Audio.PlaySound(gameDialogue.GetCurrent()); } if (!detailRegion.IsVisible()) { detailRegion.SetVisibility(true); textRegionDirty = true; } } else { Audio.AbortCurrentSound(); detailRegion.SetText(string.Empty); if (detailRegion.IsVisible()) { textRegionDirty = true; detailRegion.SetVisibility(false); } } }
/// <summary> /// Set text value of a view range and scrolls to the bottom if necessary. /// </summary> /// <param name="vr">View range to fill with content.</param> /// <param name="text">Text content.</param> private void setScrollableViewRangeTextContent(BrailleIOViewRange vr, string text) { if (vr != null) { vr.SetText(text); if (text.Length <= 40) return; // TODO: only hack because at this point contentHeight is that of last shown content --> if the new content is very short, than the scrolling would show it out of view range int contentHeight = vr.ContentHeight - 1; // TODO: ignore last line in content renderer instead of "-1" if (vr.ShowScrollbars && (contentHeight > vr.ContentBox.Height)) // TODO: adaption also necessary if content is smaller than offset position { int diff = vr.ContentBox.Height - contentHeight; scrollViewRangeTo(vr, diff); } } }