bool updateFullScreen(int width, int height)
        {
            if (io != null)
            {
                // main screen
                BrailleIOScreen fullScreen = io.GetView(BS_FULLSCREEN_NAME) as BrailleIOScreen;
                if (fullScreen != null)
                {
                    fullScreen.SetHeight(height);
                    fullScreen.SetWidth(width);

                    // center
                    BrailleIOViewRange center = fullScreen.GetViewRange(VR_CENTER_NAME);
                    if (center != null)
                    {
                        center.SetHeight(height);
                        center.SetWidth(width);
                    }

                    io.RefreshDisplay(true);
                    return(true);
                }
            }
            return(false);
        }
 /// <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);
 }
 /// <summary>
 /// Get the touched view range.
 /// </summary>
 /// <param name="x">x value of the tap (on pin device)</param>
 /// <param name="y">y value of the tap (on pin device)</param>
 /// <param name="s">visible screen</param>
 /// <returns>touched view range</returns>
 public BrailleIOViewRange GetTouchedViewRange(double x, double y, BrailleIOScreen s)
 {
     if (s != null)
     {
         OrderedDictionary viewRanges = s.GetViewRanges();
         if (viewRanges.Count > 0)
         {
             object[] keys = new object[viewRanges.Keys.Count];
             viewRanges.Keys.CopyTo(keys, 0);
             for (int i = keys.Length - 1; i >= 0; i--)
             {
                 BrailleIOViewRange vr = viewRanges[keys[i]] as BrailleIOViewRange;
                 if (vr != null && vr.IsVisible())
                 {
                     if (x >= vr.GetLeft() && x <= (vr.GetLeft() + vr.GetWidth()))
                     {
                         if (y >= vr.GetTop() && y <= (vr.GetTop() + vr.GetHeight()))
                         {
                             return(vr);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
        /// <summary>
        /// Updates the content of status region.
        /// </summary>
        private void updateStatusRegionContent()
        {
            BrailleIOScreen vs = io.GetView(BS_MAIN_NAME) as BrailleIOScreen;

            if (vs != null)
            {
                if (InteractionManager != null)
                {
                    if (InteractionManager.Mode.Equals(InteractionMode.Braille))
                    {
                        setRegionContent(vs, VR_STATUS_NAME, LectorStateNames.BRAILLE_MODE);
                        return;
                    }
                }
                FollowFocusModes mode = FocusMode;
                switch (mode)
                {
                case FollowFocusModes.FOLLOW_MOUSE_FOCUS:
                    setRegionContent(vs, VR_STATUS_NAME, LectorStateNames.FOLLOW_MOUSE_FOCUS_MODE);
                    break;

                case FollowFocusModes.FOLLOW_BRAILLE_FOCUS:
                    setRegionContent(vs, VR_STATUS_NAME, LectorStateNames.FOLLOW_BRAILLE_FOCUS_MODE);
                    break;

                default:
                    setRegionContent(vs, VR_STATUS_NAME, LectorStateNames.STANDARD_MODE);
                    break;
                }
            }
        }
        /// <summary>
        /// Move current view range to the given object.
        /// For example, this should be used for following the focused object on the pin device.
        /// </summary>
        /// <param name="objectBounds">object that should be shown centered on pin device</param>
        public void MoveToObject(Rectangle boundingBox)
        {
            if (boundingBox == null || IsInMinimapMode())
            {
                return;
            }

            BrailleIOScreen    vs     = GetVisibleScreen();
            BrailleIOViewRange center = GetActiveCenterView(vs);

            if (center != null)
            {
                // use not whole screen, but open office document position as screen position, because contentWidth and contentHeight of view range is related to this instead of to the whole screen
                //Rectangle boundingBox = new Rectangle(objectBounds.X, objectBounds.Y, objectBounds.Width, objectBounds.Height);
                Point centeredScreenPosition = new Point((int)Math.Round(boundingBox.X + boundingBox.Width * 0.5), (int)Math.Round(boundingBox.Y + boundingBox.Height * 0.5));
                //Point centeredScreenPosition = new Point(boundingBox.X, boundingBox.Y);

                Point  pinDevicePosition = new Point(0, 0);
                double zoom = center.GetZoom();
                if (zoom != 0)
                {
                    pinDevicePosition = new Point((int)(Math.Round(centeredScreenPosition.X * -zoom) + ((int)Math.Round(center.ContentBox.Width * 0.5))), (int)(Math.Round(centeredScreenPosition.Y * -zoom) + ((int)Math.Round(center.ContentBox.Height * 0.5))));
                    //pinDevicePosition = new Point((int)(Math.Round(centeredScreenPosition.X * -zoom)), (int)(Math.Round(centeredScreenPosition.Y * -zoom)));
                }
                MoveToPosition(vs.Name, center.Name, pinDevicePosition);
            }
        }
        /// <summary>
        /// Fills the center region of the main screen with the content depending on the currentView.
        /// </summary>
        private void fillMainCenterContent(BrailleIOScreen screen)
        {
            if (screen != null)
            {
                BrailleIOViewRange center  = screen.GetViewRange(VR_CENTER_NAME);
                BrailleIOViewRange center2 = screen.GetViewRange(VR_CENTER_2_NAME);
                if (center != null)
                {
                    switch (currentView)
                    {
                    case LectorView.Drawing:
                        setCaptureArea();
                        if (center2 != null)
                        {
                            center2.SetVisibility(false);
                        }
                        break;

                    case LectorView.Braille:
                        String content = "Hallo Welt";     // TODO: set real content
                        setRegionContent(screen, VR_CENTER_2_NAME, content);
                        break;

                    default:
                        setCaptureArea();
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Switch between fullscreen and main screen.
        /// </summary>
        private void toggleFullscreen()
        {
            if (io.GetView(BS_FULLSCREEN_NAME) != null)
            {
                var             view = io.GetView(BS_FULLSCREEN_NAME) as BrailleIO.Interface.IViewable;
                BrailleIOScreen ms   = io.GetView(BS_MAIN_NAME) as BrailleIOScreen;
                if (view != null && ms != null)
                {
                    BrailleIOViewRange mainscreenCenterVR = ms.GetViewRange(VR_CENTER_NAME);
                    BrailleIOViewRange fullscreenCenterVR = (view as BrailleIOScreen).GetViewRange(VR_CENTER_NAME);

                    if (view.IsVisible())
                    {
                        if (mainscreenCenterVR != null && fullscreenCenterVR != null)
                        {
                            syncViewRangeWithVisibleCenterViewRange(mainscreenCenterVR);
                            syncContrastSettings(fullscreenCenterVR, mainscreenCenterVR);
                        }
                        io.HideView(BS_FULLSCREEN_NAME);
                        io.ShowView(BS_MAIN_NAME);
                    }
                    else
                    {
                        if (mainscreenCenterVR != null && fullscreenCenterVR != null)
                        {
                            syncViewRangeWithVisibleCenterViewRange(fullscreenCenterVR);
                            syncContrastSettings(mainscreenCenterVR, fullscreenCenterVR);
                        }
                        io.HideView(BS_MAIN_NAME);
                        io.ShowView(BS_FULLSCREEN_NAME);
                    }
                }
            }
        }
        /// <summary>
        /// Opens Title and Description dialog for current selected shape in Detail area.
        /// </summary>
        private void openTitleDescDialog()
        {
            if (shapeManipulatorFunctionProxy == null || shapeManipulatorFunctionProxy.IsShapeSelected /*.LastSelectedShape == null*/)
            {
                return;
            }

            // quit full screen to allow for showing dialog in detail region
            BrailleIOScreen vs = WindowManager.Instance.GetVisibleScreen();

            if (vs != null && vs.Name.Equals(WindowManager.BS_FULLSCREEN_NAME))
            {
                WindowManager.Instance.QuitFullscreen();
            }

            string dialogTitle = LL.GetTrans("tangram.lector.oo_observer.dialog.title_desc.dialogtitle", shapeManipulatorFunctionProxy.LastSelectedShape.Name);

            WindowManager.Instance.SetTopRegionContent(dialogTitle);
            AudioRenderer.Instance.PlaySoundImmediately(dialogTitle);

            //TODO class GUI-Dialog for Image
            //ImageData imageDataView = new ImageData(InteractionManager.BKI,io);
            InteractionManager.Instance.ChangeMode(InteractionMode.Braille);

            if (imgDataFunctionProxy != null && ScriptFunctionProxy.Instance != null)
            {
                ScriptFunctionProxy.Instance.AddProxy(imgDataFunctionProxy);
                imgDataFunctionProxy.Active = true;
                imgDataFunctionProxy.ShowImageDetailView(TITLE_DESC_VIEW_NAME, 15, 0, Property.Title, true);
            }
        }
        /// <summary>
        /// Determines whether the minimap mode is active.
        /// </summary>
        /// <returns>
        ///     <c>true</c> if minimap mode is active; otherwise, <c>false</c>.
        /// </returns>
        public bool IsInMinimapMode()
        {
            BrailleIOScreen vs = GetVisibleScreen();

            if (vs != null && vs.Name.Equals(BS_MINIMAP_NAME))
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Get the view range where screen capturing should be shown (center view range of the visible screen).
        /// </summary>
        /// <returns>view range</returns>
        BrailleIOViewRange getTargetViewRangeForScreenCapturing()
        {
            BrailleIOScreen s = GetVisibleScreen();

            if (s != null)
            {
                return(s.GetViewRange(VR_CENTER_NAME));
            }
            return(io.GetView(VR_CENTER_NAME) as BrailleIOViewRange);
        }
        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);
        }
        // TODO: correct toggle function for active detail area view range
        private void toggleFullDetailScreen()
        {
            BrailleIOScreen    vs       = GetVisibleScreen();
            BrailleIOViewRange detailVR = vs.GetViewRange(VR_DETAIL_NAME); // TODO: ImageData class creates own detail area --> do not use global detailarea
            BrailleIOViewRange topVR    = vs.GetViewRange(VR_TOP_NAME);

            detailVR.SetHeight(deviceSize.Height - topVR.GetHeight());
            detailVR.SetTop(topVR.GetHeight() - 3);
            io.RefreshDisplay();
            audioRenderer.PlaySoundImmediately(LL.GetTrans("tangram.lector.wm.views.detail_maximize"));
        }
 /// <summary>
 /// Fills the center region of the main screen with the content depending on the currentView.
 /// </summary>
 private void fillMainCenterContent()
 {
     if (io != null)
     {
         BrailleIOScreen screen = GetVisibleScreen();
         if (screen != null)
         {
             fillMainCenterContent(screen);
         }
     }
 }
Пример #14
0
        //     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 status region.
        /// </summary>
        /// <param name="status">Should be a string of the LectorStateNames class.</param>
        public void SetStatusRegionContent(String status)
        {
            BrailleIOScreen vs = io.GetView(BS_MAIN_NAME) as BrailleIOScreen;

            if (vs != null)
            {
                int width         = vs.GetViewRange(VR_STATUS_NAME).GetWidth();
                int maxCharacters = width / 3 - 1; // one Braille letter needs 3 pins
                status = status.Substring(0, maxCharacters);
                setRegionContent(vs, VR_STATUS_NAME, status);
            }
        }
 /// <summary>
 /// Moves the content of the view in vertical direction.
 /// </summary>
 /// <param name="screen">The screen the view is located in.</param>
 /// <param name="viewRangeName">Name of the view range inside the screen.</param>
 /// <param name="pins">The pins to move in vertical direction. Negative values will move the content to the right; positive values to the left.</param>
 /// <param name="render">if set to <c>true</c> a new rendering is forced.</param>
 /// <returns>
 ///   <c>true</c> if the content was moved successfully.
 /// </returns>
 /// <remarks>
 /// Views will change their presentation only after calling <see cref="BrailleIOMediator.Instance.RenderDisplay()" />.
 /// Call the <c>RenderDisplay()</c> function after you have done all your changes to see the results.
 /// </remarks>
 public static bool MoveVertical(BrailleIOScreen screen, string viewRangeName, int pins, bool render = false)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(viewRangeName);
         if (vr != null)
         {
             return(MoveVertical(vr, pins, render));
         }
     }
     return(false);
 }
 /// <summary>
 /// Zooms the specified view by the given factor.
 /// </summary>
 /// <param name="screen">The screen containing the view.</param>
 /// <param name="viewRangeName">Name of the view range inside the screen.</param>
 /// <param name="changeFactor">The change factor for zoom.</param>
 /// <param name="render">if set to <c>true</c> a new rendering is forced.</param>
 /// <returns>
 ///   <c>true</c> if the zoom factor of the view was changed successfully.
 /// </returns>
 /// <remarks>
 /// Views will change their presentation only after calling <see cref="BrailleIOMediator.Instance.RenderDisplay()" />.
 /// Call the <c>RenderDisplay()</c> function after you have done all your changes to see the results.
 /// </remarks>
 private static bool Zoom(BrailleIOScreen screen, string viewRangeName, double changeFactor, bool render = false)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(viewRangeName);
         if (vr != null)
         {
             return(Zoom(vr, changeFactor, render));
         }
     }
     return(false);
 }
        /// <summary>
        /// Generates the main screen consisting of title (top region), detail region and center region.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="view">The view of the main region.</param>
        /// <returns></returns>
        BrailleIOScreen buildMainScreen(int width, int height, LectorView view)
        {
            BrailleIOScreen mainScreen = new BrailleIOScreen(BS_MAIN_NAME);

            mainScreen.SetHeight(height);
            mainScreen.SetWidth(width);

            var center = getMainScreenCenterRegion(0, 0, width, height);

            center.ShowScrollbars = true;
            var center2 = getMainScreenCenter2Region(0, 0, width, height);

            center2.ShowScrollbars = true;
            center2.SetVisibility(false);
            center2.SetZoom(1);

            var top    = getMainTopRegion(0, 0, width, 7);
            var status = getMainStatusRegion(width - 12, 0, 12, 5);

            status.SetText(LectorStateNames.STANDARD_MODE);

            var detail = getMainDetailRegion(0, height - 7, width, 7);

            detail.ShowScrollbars = true;                                         // make the region scrollable
            // make the BrailleRenderer to ignore the last line space
            detail.SetText(LL.GetTrans("tangram.lector.wm.no_element_selected")); // set text to enable the BrailleRenderer
            var renderer = detail.ContentRender;

            if (renderer != null && renderer is MatrixBrailleRenderer)
            {
                ((MatrixBrailleRenderer)renderer).RenderingProperties |= RenderingProperties.IGNORE_LAST_LINESPACE;
            }

            mainScreen.AddViewRange(VR_CENTER_2_NAME, center2);
            mainScreen.AddViewRange(VR_CENTER_NAME, center);
            mainScreen.AddViewRange(VR_TOP_NAME, top);
            mainScreen.AddViewRange(VR_STATUS_NAME, status);
            mainScreen.AddViewRange(VR_DETAIL_NAME, detail);

            setRegionContent(mainScreen, VR_TOP_NAME, MAINSCREEN_TITLE);
            setRegionContent(mainScreen, VR_DETAIL_NAME, LL.GetTrans("tangram.lector.wm.no_element_selected"));

            currentView = view;
            fillMainCenterContent(mainScreen);

            if (io != null)
            {
                io.AddView(BS_MAIN_NAME, mainScreen);
                io.ShowView(BS_MAIN_NAME);
                io.RefreshDisplay(true);
            }
            return(mainScreen);
        }
        /// <summary>
        /// Get the content offset position of the region.
        /// </summary>
        /// <param name="screen">The screen.</param>
        /// <param name="vrName">Name of the region (viewRange).</param>
        /// <returns>Offset position or Point.Empty if there is no valid data.</returns>
        public Point GetContentOffsetOfRegion(BrailleIOScreen screen, String vrName)
        {
            Point offset = Point.Empty;

            if (screen != null)
            {
                BrailleIOViewRange vr = screen.GetViewRange(vrName);
                if (vr != null)
                {
                    offset = vr.OffsetPosition;
                }
            }
            return(offset);
        }
        /// <summary>
        /// Get the text content of the region.
        /// </summary>
        /// <param name="screen">The screen.</param>
        /// <param name="vrName">Name of the region (viewRange).</param>
        /// <returns>Text content or String.Empty if there is no valid data (e.g. content is not text).</returns>
        public String GetTextContentOfRegion(BrailleIOScreen screen, String vrName)
        {
            String content = String.Empty;

            if (screen != null)
            {
                BrailleIOViewRange vr = screen.GetViewRange(vrName);
                if (vr != null)
                {
                    content = vr.GetText();
                }
            }
            return(content);
        }
        /// <summary>
        /// Quit Fullscreen mode.
        /// </summary>
        public bool QuitFullscreen()
        {
            BrailleIOScreen vs = GetVisibleScreen();

            if (vs != null && vs.Name.Equals(WindowManager.BS_FULLSCREEN_NAME))
            {
                if (fullscreenVisible())
                {
                    toggleFullscreen();
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// set content of current detail region (without adding to history)
        /// </summary>
        /// <param name="content">content to render</param>
        private void setDetailRegionContent(String content)
        {
            BrailleIOScreen vs = GetVisibleScreen();

            if (vs != null)
            {
                setRegionContent(vs, VR_DETAIL_NAME, content);
                BrailleIOViewRange vr = vs.GetViewRange(VR_DETAIL_NAME);
                if (vr != null)
                {
                    scrollViewRangeTo(vr, 0);
                }
            }
        }
        internal void BuildScreens()
        {
            if (io != null && io.AdapterManager != null && io.AdapterManager.ActiveAdapter != null && io.AdapterManager.ActiveAdapter.Device != null)
            {
                deviceSize = new Size(io.AdapterManager.ActiveAdapter.Device.DeviceSizeX, io.AdapterManager.ActiveAdapter.Device.DeviceSizeY);
            }
            else
            {
                //showOffAdapter size
                deviceSize = new Size(120, 60);
            }
            BrailleIOScreen mainScreen = buildMainScreen(deviceSize.Width, deviceSize.Height, currentView);

            buildFullScreen(deviceSize.Width, deviceSize.Height);
            buildMinimapScreen(deviceSize.Width, deviceSize.Height);
        }
 /// <summary>
 /// Get the active center view of the given screen
 /// </summary>
 /// <param name="screen">screen</param>
 /// <returns>active center view</returns>
 public BrailleIOViewRange GetActiveCenterView(BrailleIOScreen screen)
 {
     if (screen != null)
     {
         BrailleIOViewRange center  = screen.GetViewRange(VR_CENTER_NAME);
         BrailleIOViewRange center2 = screen.GetViewRange(VR_CENTER_2_NAME);
         if (center != null && center.IsVisible())
         {
             return(center);
         }
         else if (center2 != null && center2.IsVisible())
         {
             return(center2);
         }
     }
     return(null);
 }
        /// <summary>
        /// Switch between minimap and currently visible screen.
        /// </summary>
        private void toggleMinimap()
        {
            BrailleIOScreen vs = GetVisibleScreen();

            if (vs != null)
            {
                if (vs.Name.Equals(BS_MINIMAP_NAME)) // exit minimap mode
                {
                    BrailleIOScreen ms = screenBeforeMinimap;
                    if (ms != null)
                    {
                        BrailleIOViewRange ocvr = vs.GetViewRange(VR_CENTER_NAME);
                        BrailleIOViewRange ncvr = ms.GetViewRange(VR_CENTER_NAME);
                        if (ocvr != null && ncvr != null)
                        {
                            syncContrastSettings(ocvr, ncvr);
                        }
                    }
                    io.HideView(vs.Name);
                    io.ShowView(ms.Name);
                    SetDetailRegionContent(GetLastDetailRegionContent());
                }
                else // show minimap
                {
                    screenBeforeMinimap = vs;

                    BrailleIOScreen ms = io.GetView(BS_MINIMAP_NAME) as BrailleIOScreen;
                    if (ms != null)
                    {
                        BrailleIOViewRange ocvr = vs.GetViewRange(VR_CENTER_NAME);
                        BrailleIOViewRange ncvr = ms.GetViewRange(VR_CENTER_NAME);
                        if (ocvr != null && ncvr != null)
                        {
                            syncContrastSettings(ocvr, ncvr);
                        }
                    }
                    io.HideView(vs.Name);
                    io.ShowView(BS_MINIMAP_NAME);
                    BrailleIOViewRange vr = vs.GetViewRange(VR_CENTER_NAME);
                    if (vr != null)
                    {
                        SetDetailRegionContent(LL.GetTrans("tangram.lector.wm.zooming.current.short", ((int)(vr.GetZoom() * 100)).ToString()));
                    }
                }
            }
        }
Пример #26
0
        // selects the closest view range in the given direction to the given view range
        public BrailleIOViewRange SelectClosestViewRange(String direction, BrailleIOScreen mainscreen, BrailleIOViewRange viewRangeCurrentlySelected)
        {
            OrderedDictionary viewRangeOrderedDict = mainscreen.GetViewRanges();                              // get all of the view ranges on the screen

            if (viewRangeCurrentlySelected == null)
            {
                return(viewRangeOrderedDict[1] as BrailleIOViewRange);                                        // if no view range is currently selected, select the first one on the screen
            }
            else
            {
                AForge.Point        centerPoint  = FindCenter(viewRangeCurrentlySelected.ViewBox);                       // find the center point of the view range currently selected
                List <AForge.Point> pointOptions = ExtractPointsFromViewRangeDict(centerPoint, viewRangeOrderedDict);    // extract the center points from all other view ranges on the screen
                pointOptions = ScanForPoints(centerPoint, pointOptions, direction, 52);                                  // elimate points that fall above a certain angle threshold
                AForge.Point       nearestPoint       = FindNearestPoint(centerPoint, pointOptions);                     // out of the points remaining, find the one nearest to the current view range
                BrailleIOViewRange viewRangeToDisplay = SearchViewRanges(nearestPoint, viewRangeOrderedDict);            // get the view range that corresponds to that point
                return(viewRangeToDisplay);
            }
        }
        /// <summary>
        /// Shows the center region in full screen (other regions are set invisible).
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <returns></returns>
        BrailleIOScreen buildFullScreen(int width, int height)
        {
            BrailleIOScreen    fullScreen = new BrailleIOScreen(BS_FULLSCREEN_NAME);
            BrailleIOViewRange center     = new BrailleIOViewRange(0, 0, width, height);

            center.SetZoom(-1);
            center.SetBorder(0);
            center.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD);
            center.ShowScrollbars = true;

            fullScreen.AddViewRange(VR_CENTER_NAME, center);
            if (io != null)
            {
                io.AddView(BS_FULLSCREEN_NAME, fullScreen);
            }
            fullScreen.SetVisibility(false);

            return(fullScreen);
        }
 /// <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>
 /// <param name="renderer">The renderer to use to transform the content into a matrix.</param>
 /// <returns>true if the content could be set, otherwise false</returns>
 public bool SetRegionContent(BrailleIOScreen screen, String vrName, Object content, IBrailleIOContentRenderer renderer)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             if (content != null)
             {
                 vr.SetOtherContent(content, renderer);
             }
             else
             {
                 vr.SetMatrix(null);
             }
         }
     }
     return(false);
 }
Пример #29
0
        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);
        }
        //     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>
 /// Get the touched view range.
 /// </summary>
 /// <param name="x">x value of the tap (on pin device)</param>
 /// <param name="y">y value of the tap (on pin device)</param>
 /// <param name="s">visible screen</param>
 /// <returns>touched view range</returns>
 public BrailleIOViewRange GetTouchedViewRange(double x, double y, BrailleIOScreen s)
 {
     if (s != null)
     {
         OrderedDictionary viewRanges = s.GetViewRanges();
         if (viewRanges.Count > 0)
         {
             object[] keys = new object[viewRanges.Keys.Count];
             viewRanges.Keys.CopyTo(keys, 0);
             for (int i = keys.Length - 1; i >= 0; i--)
             {
                 BrailleIOViewRange vr = viewRanges[keys[i]] as BrailleIOViewRange;
                 if (vr != null && vr.IsVisible())
                 {
                     if (x >= vr.GetLeft() && x <= (vr.GetLeft() + vr.GetWidth()))
                     {
                         if (y >= vr.GetTop() && y <= (vr.GetTop() + vr.GetHeight()))
                         {
                             return vr;
                         }
                     }
                 }
             }
         }
     }
     return null;
 }
 /// <summary>
 /// Adds the renderer hook to a screen that has a viewRangen named WindowManager.VR_CENTER_NAME.
 /// </summary>
 /// <param name="screen">The screen.</param>
 private void addRendererHookToScreen(BrailleIOScreen screen)
 {
     if (screen != null)
     {
         //try to get the main view range
         if (screen.HasViewRange(WindowManager.VR_CENTER_NAME))
         {
             BrailleIOViewRange vr = screen.GetViewRange(WindowManager.VR_CENTER_NAME);
             if (vr != null)
             {
                 if (vr.IsImage() && vr.ContentRender != null && vr.ContentRender is IBrailleIOHookableRenderer)
                 {
                     ((IBrailleIOHookableRenderer)vr.ContentRender).RegisterHook(BrailleDomFocusRenderer);
                     ((IBrailleIOHookableRenderer)vr.ContentRender).RegisterHook(DrawSelectFocusRenderer);
                     ((IBrailleIOHookableRenderer)vr.ContentRender).RegisterHook(TextRendererHook);
                 }
                 else
                 {
                     vr.RendererChanged += new EventHandler<EventArgs>(vr_RendererChanged);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Changes the active center view to the given one (center or center_2).
        /// </summary>
        /// <param name="screen">The screen.</param>
        /// <param name="viewName">Name of the view. [VR_CENTER_NAME or VR_CENTER_2_NAME]</param>
        /// <returns></returns>
        BrailleIOViewRange changeActiveCenterView(BrailleIOScreen screen, String viewName)
        {
            //TODO: do this generic?!
            if (screen != null)
            {
                BrailleIOViewRange center = screen.GetViewRange(VR_CENTER_NAME);
                BrailleIOViewRange center2 = screen.GetViewRange(VR_CENTER_2_NAME);

                if (viewName.Equals(VR_CENTER_2_NAME))
                {
                    if (center2 != null)
                    {
                        if (center != null) { center.SetVisibility(false); }
                        center2.SetVisibility(true);
                        return center2;
                    }
                }
                else
                {
                    if (center != null) { center.SetVisibility(true); }
                    if (center2 != null) { center2.SetVisibility(false); }
                    return center;
                }
            }
            return null;
        }
 /// <summary>
 /// Fills the center region of the main screen with the content depending on the currentView.
 /// </summary>
 private void fillMainCenterContent(BrailleIOScreen screen)
 {
     if (screen != null)
     {
         BrailleIOViewRange center = screen.GetViewRange(VR_CENTER_NAME);
         BrailleIOViewRange center2 = screen.GetViewRange(VR_CENTER_2_NAME);
         if (center != null)
         {
             switch (currentView)
             {
                 case LectorView.Drawing:
                     setCaptureArea();
                     if (center2 != null)
                         center2.SetVisibility(false);
                     break;
                 default:
                     setCaptureArea();
                     break;
             }
         }
     }
 }
 /// <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>
 /// <param name="renderer">The renderer to use to transform the content into a matrix.</param>
 /// <returns>true if the content could be set, otherwise false</returns>
 public bool SetRegionContent(BrailleIOScreen screen, String vrName, Object content, IBrailleIOContentRenderer renderer)
 {
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             if (content != null)
             {
                 vr.SetOtherContent(content, renderer);
             }
             else { vr.SetMatrix(null); }
         }
     }
     return false;
 }
 /// <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;
 }
        /// <summary>
        /// Shows the center region in full screen (other regions are set invisible).
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <returns></returns>
        BrailleIOScreen buildMinimapScreen(int width, int height)
        {
            BrailleIOScreen minimapScreen = new BrailleIOScreen(BS_MINIMAP_NAME);

            var center = getMainScreenCenterRegion(0, 0, width, height);
            var top = getMainTopRegion(0, 0, width, 7);
            var detail = getMainDetailRegion(0, height-7, width, 7);

            minimapScreen.AddViewRange(VR_CENTER_NAME, center); // TODO auch center2 nötig?
            minimapScreen.AddViewRange(VR_TOP_NAME, top);
            minimapScreen.AddViewRange(VR_DETAIL_NAME, detail);

            setRegionContent(minimapScreen, VR_TOP_NAME, "Minimap");
            setRegionContent(minimapScreen, VR_DETAIL_NAME, LL.GetTrans("tangram.lector.wm.minimap.vr_detail"));

            if (io != null) io.AddView(BS_MINIMAP_NAME, minimapScreen);
            minimapScreen.SetVisibility(false);

            return minimapScreen;
        }
        /// <summary>
        /// Shows the center region in full screen (other regions are set invisible).
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <returns></returns>
        BrailleIOScreen buildFullScreen(int width, int height)
        {
            BrailleIOScreen fullScreen = new BrailleIOScreen(BS_FULLSCREEN_NAME);
            BrailleIOViewRange center = new BrailleIOViewRange(0, 0, width, height);
            center.SetZoom(-1);
            center.SetBorder(0);
            center.SetContrastThreshold(STANDARD_CONTRAST_THRESHOLD);
            center.ShowScrollbars = true;

            fullScreen.AddViewRange(VR_CENTER_NAME, center);
            if (io != null) io.AddView(BS_FULLSCREEN_NAME, fullScreen);
            fullScreen.SetVisibility(false);

            return fullScreen;
        }
        /// <summary>
        /// Generates the main screen consisting of title (top region), detail region and center region.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="view">The view of the main region.</param>
        /// <returns></returns>
        BrailleIOScreen buildMainScreen(int width, int height, LectorView view)
        {
            BrailleIOScreen mainScreen = new BrailleIOScreen(BS_MAIN_NAME);
            mainScreen.SetHeight(height);
            mainScreen.SetWidth(width);

            var center = getMainScreenCenterRegion(0, 0, width, height);
            center.ShowScrollbars = true;
            var center2 = getMainScreenCenter2Region(0, 0, width, height);
            center2.ShowScrollbars = true;
            center2.SetVisibility(false);
            center2.SetZoom(1);

            var top = getMainTopRegion(0, 0, width, 7);
            var status = getMainStatusRegion(width -12, 0, 12, 5);
            status.SetText(LectorStateNames.STANDARD_MODE);

            var detail = getMainDetailRegion(0, height-7, width, 7);
            detail.ShowScrollbars = true; // make the region scrollable
            // make the BrailleRenderer to ignore the last line space
            detail.SetText(LL.GetTrans("tangram.lector.wm.no_element_selected")); // set text to enable the BrailleRenderer
            var renderer = detail.ContentRender;
            if (renderer != null && renderer is MatrixBrailleRenderer)
            {
                ((MatrixBrailleRenderer)renderer).RenderingProperties |= RenderingProperties.IGNORE_LAST_LINESPACE;
            }

            mainScreen.AddViewRange(VR_CENTER_2_NAME, center2);
            mainScreen.AddViewRange(VR_CENTER_NAME, center);
            mainScreen.AddViewRange(VR_TOP_NAME, top);
            mainScreen.AddViewRange(VR_STATUS_NAME, status);
            mainScreen.AddViewRange(VR_DETAIL_NAME, detail);

            setRegionContent(mainScreen, VR_TOP_NAME, MAINSCREEN_TITLE);
            setRegionContent(mainScreen, VR_DETAIL_NAME, LL.GetTrans("tangram.lector.wm.no_element_selected"));

            currentView = view;
            fillMainCenterContent(mainScreen);

            if (io != null)
            {
                io.AddView(BS_MAIN_NAME, mainScreen);
                io.ShowView(BS_MAIN_NAME);
                io.RefreshDisplay(true);
            }
            return mainScreen;
        }
        private void setTangramScreen()
        {
            try
            {
                if (io != null)
                {
                    string name = "TangramSceen";
                    BrailleIOScreen ts = new BrailleIOScreen(name);

                    BrailleIOViewRange tv = new BrailleIOViewRange(0, 0, io.GetDeviceSizeX(), io.GetDeviceSizeY());
                    tv.SetBitmap(Bitmap.FromFile(@"config/pics/tactile_logo.bmp"));
                    ts.AddViewRange(name + "View", tv);
                    io.AddView(name, ts);
                    io.ShowView(name);
                    io.RefreshDisplay();
                    io.RefreshDisplay();
                    System.Threading.Thread.Sleep(10);
                }
            }
            catch { }
        }
 /// <summary>
 /// Get the text content of the region.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="vrName">Name of the region (viewRange).</param>
 /// <returns>Text content or String.Empty if there is no valid data (e.g. content is not text).</returns>
 public String GetTextContentOfRegion(BrailleIOScreen screen, String vrName)
 {
     String content = String.Empty;
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             content = vr.GetText();
         }
     }
     return content;
 }
 /// <summary>
 /// Get the content offset position of the region.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <param name="vrName">Name of the region (viewRange).</param>
 /// <returns>Offset position or Point.Empty if there is no valid data.</returns>
 public Point GetContentOffsetOfRegion(BrailleIOScreen screen, String vrName)
 {
     Point offset = Point.Empty;
     if (screen != null)
     {
         BrailleIOViewRange vr = screen.GetViewRange(vrName);
         if (vr != null)
         {
             offset = vr.OffsetPosition;
         }
     }
     return offset;
 }
 private void createDetailView(string detailViewName, int left, int top, int width, int height, bool scrollable)
 {
     try
     {
         if (!detailViewDic.ContainsKey(detailViewName))
         {
             detailViewDic.Add(detailViewName, null);
         }
         brailleIoScreen = wManager.GetVisibleScreen();
         detailViewDic[detailViewName] = new BrailleIOViewRange(left, top, width, height);
         brailleIoScreen.AddViewRange(viewRangename, detailViewDic[detailViewName]);
         viewRangename = detailViewDic[detailViewName].Name;
         detailViewDic[detailViewName].SetVisibility(true);
         detailViewDic[detailViewName].SetZIndex(99);
         detailViewDic[detailViewName].SetBorder(1, 0, 0);
         detailViewDic[detailViewName].SetMargin(1, 0, 0);
         detailViewDic[detailViewName].SetPadding(1, 0, 0);
         detailViewDic[detailViewName].HasBorder = true;
         detailViewDic[detailViewName].ShowScrollbars = scrollable;
         detailViewDic[detailViewName].SetText("");
         var render = detailViewDic[detailViewName].ContentRender;
         if (render != null && render is IBrailleIOHookableRenderer)
         {
             if (detailViewName == TITLE_DESC_VIEW_NAME)
             {
                 ((IBrailleIOHookableRenderer)render).RegisterHook(CaretHook);
             }
             else if (detailViewName == TITLE_DESC_SAVE_VIEW_NAME)
             {
                 ((IBrailleIOHookableRenderer)render).RegisterHook(UnderLiningHook);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] while changing the height of the detail region", ex);
     }
 }
 /// <summary>
 /// Get the active center view of the given screen
 /// </summary>
 /// <param name="screen">screen</param>
 /// <returns>active center view</returns>
 public BrailleIOViewRange GetActiveCenterView(BrailleIOScreen screen)
 {
     if (screen != null)
     {
         BrailleIOViewRange center = screen.GetViewRange(VR_CENTER_NAME);
         BrailleIOViewRange center2 = screen.GetViewRange(VR_CENTER_2_NAME);
         if (center != null && center.IsVisible()) return center;
         else if (center2 != null && center2.IsVisible()) return center2;
     }
     return null;
 }