/// <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);
 }
Пример #2
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();
        }
        //     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();
        }
Пример #4
0
        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>
        /// Handles the Changed event of the screen observer control and send it to view range that is defined by getTargetViewRangeForScreenCapturing().
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="tud.mci.tangram.TangramLector.CaptureChangedEventArgs"/> instance containing the event data.</param>
        void so_Changed(object sender, CaptureChangedEventArgs e)
        {
            if (currentView != LectorView.Drawing)
            {
                return;
            }
            BrailleIOViewRange vr = getTargetViewRangeForScreenCapturing();

            if (vr != null && e != null)
            {
                BrailleIOScreen vs = GetVisibleScreen();
                if (vs != null && vs.Name.Equals(BS_MINIMAP_NAME))
                {
                    setMinimapContent(vr, e);
                }
                else
                {
                    vr.SetBitmap(e.Img as Bitmap);
                }
                io.RefreshDisplay(true);
            }
        }
        /// <summary>
        /// Set the content in minimap mode. Thereby the screen capturing bitmap is shown with blinking frame.
        /// </summary>
        /// <param name="vr">ViewRange in which minimap content should be shown.</param>
        /// <param name="e">EventArgs of the screen capturing event.</param>
        void setMinimapContent(BrailleIOViewRange vr, CaptureChangedEventArgs e)
        {
            int width = vr.ContentBox.Width;
            int height = vr.ContentBox.Height;
            Bitmap bmp = new Bitmap(width, height);
            Graphics graph = Graphics.FromImage(bmp);

            if (screenBeforeMinimap != null)
            {
                BrailleIOViewRange imgvr = screenBeforeMinimap.GetViewRange(VR_CENTER_NAME);
                if (imgvr == null) return;

                int xoffset = imgvr.GetXOffset();
                int yoffset = imgvr.GetYOffset();
                int imgWidth = imgvr.ContentWidth;
                int imgHeight = imgvr.ContentHeight;

                if (imgWidth > 0 && imgHeight > 0)
                {
                    // calculate image size for minimap (complete image has to fit into view range)
                    int imgScaledWidth = imgWidth;
                    int imgScaledHeight = imgHeight;
                    double scaleFactorX = 1;
                    double scaleFactorY = 1;

                    if (width != 0 && imgScaledWidth > width)
                    {
                        scaleFactorX = (double)imgWidth / (double)width;
                        if (scaleFactorX != 0)
                        {
                            imgScaledWidth = width;
                            imgScaledHeight = (int)(imgHeight / scaleFactorX);
                        }
                    }
                    if (height != 0 && imgScaledHeight > height)
                    {
                        scaleFactorY = (double)imgScaledHeight / (double)height;
                        if (scaleFactorY != 0)
                        {
                            imgScaledHeight = height;
                            imgScaledWidth = (int)(imgScaledWidth / scaleFactorY);
                        }
                    }

                    // calculate scaling factor from original image to minimap image size
                    MinimapScalingFactor = 1 / (scaleFactorX * scaleFactorY);
                    double zoom = imgvr.GetZoom();
                    if (zoom > 0) MinimapScalingFactor = MinimapScalingFactor * zoom;

                    // calculate position and size of the blinking frame
                    int x = Math.Abs(xoffset) * imgScaledWidth / imgWidth;
                    int y = Math.Abs(yoffset) * imgScaledHeight / imgHeight;
                    int frameWidth = width * imgScaledWidth / imgWidth;
                    int frameHeigth = height * imgScaledHeight / imgHeight;

                    // draw scaled image and blinking frame
                    graph.DrawImage(e.Img, 0, 0, imgScaledWidth, imgScaledHeight);
                    Color frameColor = Color.Black;
                    if (!blinkPinsUp) frameColor = Color.White;
                    graph.DrawRectangle(new Pen(frameColor, 2), x, y, frameWidth, frameHeigth);
                    vr.SetBitmap(bmp);
                }
            }
        }
        /// <summary>
        /// Set the content in minimap mode. Thereby the screen capturing bitmap is shown with blinking frame.
        /// </summary>
        /// <param name="vr">ViewRange in which minimap content should be shown.</param>
        /// <param name="e">EventArgs of the screen capturing event.</param>
        void setMinimapContent(BrailleIOViewRange vr, CaptureChangedEventArgs e)
        {
            int      width  = vr.ContentBox.Width;
            int      height = vr.ContentBox.Height;
            Bitmap   bmp    = new Bitmap(width, height);
            Graphics graph  = Graphics.FromImage(bmp);

            if (screenBeforeMinimap != null)
            {
                BrailleIOViewRange imgvr = screenBeforeMinimap.GetViewRange(VR_CENTER_NAME);
                if (imgvr == null)
                {
                    return;
                }

                int xoffset   = imgvr.GetXOffset();
                int yoffset   = imgvr.GetYOffset();
                int imgWidth  = imgvr.ContentWidth;
                int imgHeight = imgvr.ContentHeight;

                if (imgWidth > 0 && imgHeight > 0)
                {
                    // calculate image size for minimap (complete image has to fit into view range)
                    int    imgScaledWidth  = imgWidth;
                    int    imgScaledHeight = imgHeight;
                    double scaleFactorX    = 1;
                    double scaleFactorY    = 1;

                    if (width != 0 && imgScaledWidth > width)
                    {
                        scaleFactorX = (double)imgWidth / (double)width;
                        if (scaleFactorX != 0)
                        {
                            imgScaledWidth  = width;
                            imgScaledHeight = (int)(imgHeight / scaleFactorX);
                        }
                    }
                    if (height != 0 && imgScaledHeight > height)
                    {
                        scaleFactorY = (double)imgScaledHeight / (double)height;
                        if (scaleFactorY != 0)
                        {
                            imgScaledHeight = height;
                            imgScaledWidth  = (int)(imgScaledWidth / scaleFactorY);
                        }
                    }

                    // calculate scaling factor from original image to minimap image size
                    MinimapScalingFactor = 1 / (scaleFactorX * scaleFactorY);
                    double zoom = imgvr.GetZoom();
                    if (zoom > 0)
                    {
                        MinimapScalingFactor = MinimapScalingFactor * zoom;
                    }

                    // calculate position and size of the blinking frame
                    int x           = Math.Abs(xoffset) * imgScaledWidth / imgWidth;
                    int y           = Math.Abs(yoffset) * imgScaledHeight / imgHeight;
                    int frameWidth  = width * imgScaledWidth / imgWidth;
                    int frameHeigth = height * imgScaledHeight / imgHeight;

                    // draw scaled image and blinking frame
                    graph.DrawImage(e.Img, 0, 0, imgScaledWidth, imgScaledHeight);
                    Color frameColor = Color.Black;
                    if (!blinkPinsUp)
                    {
                        frameColor = Color.White;
                    }
                    graph.DrawRectangle(new Pen(frameColor, 2), x, y, frameWidth, frameHeigth);
                    vr.SetBitmap(bmp);
                }
            }
        }
        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 { }
        }