private void initRendererHook() { WindowManager wm = WindowManager.Instance; if (wm != null) { BrailleIOMediator io = BrailleIOMediator.Instance; if (io != null) { var fsScreen = io.GetView(WindowManager.BS_FULLSCREEN_NAME); var nsScreen = io.GetView(WindowManager.BS_MAIN_NAME); addRendererHookToScreen(fsScreen as BrailleIOScreen); addRendererHookToScreen(nsScreen as BrailleIOScreen); } } }
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); }
bool updateMainScreen(int width, int height) { if (io != null) { // main screen BrailleIOScreen mainScreen = io.GetView(BS_MAIN_NAME) as BrailleIOScreen; if (mainScreen != null) { mainScreen.SetHeight(height); mainScreen.SetWidth(width); // center BrailleIOViewRange center = mainScreen.GetViewRange(VR_CENTER_NAME); if (center != null) { center.SetHeight(height); center.SetWidth(width); } // center 2 BrailleIOViewRange center2 = mainScreen.GetViewRange(VR_CENTER_2_NAME); if (center2 != null) { center2.SetHeight(height); center2.SetWidth(width); } //top BrailleIOViewRange top = mainScreen.GetViewRange(VR_TOP_NAME); if (top != null) { top.SetWidth((int)(width * 1.4)); // only that region content is not doing line breaks } // status BrailleIOViewRange status = mainScreen.GetViewRange(VR_STATUS_NAME); if (status != null) { status.SetLeft(width - 12); } // center 2 BrailleIOViewRange detail = mainScreen.GetViewRange(VR_DETAIL_NAME); if (detail != null) { detail.SetTop(height - 7); detail.SetWidth(width); } io.RefreshDisplay(true); return(true); } } return(false); }
private bool[,] RenderTextBox(IViewBoxModel view, UiElement textBoxContent) { bool[,] viewMatrix; if (textBoxContent.isDisabled) { viewMatrix = Helper.createBoxDeaktivatedUpDown(view.ViewBox.Height, view.ViewBox.Width); } else { viewMatrix = Helper.createBox(view.ViewBox.Height, view.ViewBox.Width); //erstmal eine eckige Matrix } //Ecke links oben abrunden Debug.Print(viewMatrix.GetLength(0).ToString()); Debug.Print(viewMatrix.GetLength(1).ToString()); if (viewMatrix.GetLength(0) <= 0 || viewMatrix.GetLength(1) <= 0) { return(new bool[0, 0]); } viewMatrix[0, 0] = false; if (viewMatrix.GetLength(1) > 1) { viewMatrix[1, 0] = false; } if (viewMatrix.GetLength(0) > 1) { viewMatrix[0, 1] = false; } if (viewMatrix.GetLength(0) > 1 && viewMatrix.GetLength(1) > 1) { viewMatrix[1, 1] = true; } BrailleIOViewRange tmpBoxView = new BrailleIOViewRange(view.ViewBox.Left, view.ViewBox.Top, view.ViewBox.Width, view.ViewBox.Height); tmpBoxView.Name = "_B_" + textBoxContent.screenName + view.ViewBox.Left + view.ViewBox.Top + view.ViewBox.Width + view.ViewBox.Height; // tmpBoxView.SetText(textBoxText); tmpBoxView.SetMatrix(viewMatrix); // tmpBoxView.ShowScrollbars = true; tmpBoxView.SetYOffset(0); tmpBoxView.SetZIndex(2); object cM = textBoxContent.text as object; IViewBoxModel tmpModel = tmpBoxView as IViewBoxModel; callAllPreHooks(ref tmpModel, ref cM); tmpBoxView = tmpBoxView as BrailleIOViewRange; BrailleIOMediator brailleIOMediator = BrailleIOMediator.Instance; BrailleIOScreen screen = (BrailleIOScreen)brailleIOMediator.GetView(textBoxContent.screenName); if (screen != null) { BrailleIOViewRange viewRange = screen.GetViewRange(tmpBoxView.Name); if (viewRange == null) { ((BrailleIOScreen)brailleIOMediator.GetView(textBoxContent.screenName)).AddViewRange(tmpBoxView.Name, tmpBoxView); } } callAllPostHooks(tmpBoxView, cM, ref viewMatrix, false); return(viewMatrix); }
void zoom(string viewName, string viewRangeName, double factor) { if (io == null && io.GetView(viewName) as BrailleIOScreen != null) { return; } // zoom in BrailleIOViewRange vr = ((BrailleIOScreen)io.GetView(viewName)).GetViewRange(viewRangeName); if (vr != null) { if (vr.GetZoom() > 0) { //TODO: make zoom to center var oldZoom = vr.GetZoom(); var newZoom = oldZoom * factor; var oldvrdin = vr.ViewBox; Point oldcenter = new Point( (int)Math.Round(((double)oldvrdin.Width / 2) + (vr.GetXOffset() * -1)), (int)Math.Round(((double)oldvrdin.Height / 2) + (vr.GetYOffset() * -1)) ); Point newCenter = new Point( (int)Math.Round(oldcenter.X * newZoom / oldZoom), (int)Math.Round(oldcenter.Y * newZoom / oldZoom) ); Point newOffset = new Point( (int)Math.Round((newCenter.X - ((double)oldvrdin.Width / 2)) * -1), (int)Math.Round((newCenter.Y - ((double)oldvrdin.Height / 2)) * -1) ); vr.SetZoom(newZoom); vr.SetXOffset(newOffset.X); vr.SetYOffset(newOffset.Y); } } this. io.RenderDisplay(); }