/// <summary>
        /// Renders a content object into an boolean matrix;
        /// while <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </summary>
        /// <param name="view">The frame to render in. This gives access to the space to render and other parameters. Normally this is a BrailleIOViewRange/&gt;.</param>
        /// <param name="content">The content to render.</param>
        /// <param name="callHooks">if set to <c>true</c> [call the pre- and post-rendering hooks].</param>
        /// <returns>
        /// A two dimensional boolean M x N matrix (bool[M,N]) where M is the count of rows (this is height)
        /// and N is the count of columns (which is the width).
        /// Positions in the Matrix are of type [i,j]
        /// while i is the index of the row (is the y position)
        /// and j is the index of the column (is the x position).
        /// In the matrix <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </returns>
        public override bool[,] RenderMatrix(IViewBoxModel view, object content, bool callHooks = true)
        {
            if (view != null && content != null)
            {
                if (callHooks)
                {
                    callAllPreHooks(ref view, ref content);
                }

                bool renderScrollbars = view is IPannable ? ((IPannable)view).ShowScrollbars : false;

                int  width       = view.ContentBox.Width;
                int  height      = view.ContentBox.Height;
                bool scrolleBars = renderScrollbars && EstimateNeedOfScrollBar(content as String, width, height);
                var  matrix      = RenderMatrix(width, content, scrolleBars);

                // rerender if scrollbars were needed
                if (renderScrollbars && !scrolleBars && matrix.GetLength(0) > height)
                {
                    matrix = RenderMatrix(width, content, true);
                }

                view.ContentHeight = matrix.GetLength(0);
                view.ContentWidth  = matrix.GetLength(1);

                if (callHooks)
                {
                    callAllPostHooks(view, content, ref matrix);
                }

                return(matrix);
            }
            return(new bool[1, 1]);
        }
Example #2
0
        /// <summary>
        /// Determines whether the entry is visible or not.
        /// </summary>
        /// <param name="renderedEntry">The rendered entry.</param>
        /// <param name="view">The view to check for (BrailleIoViewRange).</param>
        /// <returns>
        /// -1 if not visible; 0 if party visible, and 1 if fully visible.
        /// </returns>
        public virtual int IsEntryVisible(RenderElement renderedEntry, IViewBoxModel view = null)
        {
            if (!renderedEntry.IsEmpty())
            {
                if (view == null)
                {
                    view = _lastView;
                }
                if (view != null && view.ContentBox.Width * view.ContentBox.Height > 0)
                {
                    int left, top, right, bottom;
                    left = top = 0;
                    if (view is IPannable)
                    {
                        left = ((IPannable)view).GetXOffset();
                        top  = ((IPannable)view).GetYOffset();
                    }
                    right  = view.ContentBox.Width + left;
                    bottom = view.ContentBox.Height + top;

                    if (renderedEntry.IsInArea(left, left + right, top, top + bottom))
                    {
                        if (renderedEntry.IsCompletelyInArea(left, right, top, bottom))
                        {
                            return(1);
                        }
                        return(0);
                    }
                }
            }
            return(-1);
        }
        /// <summary>
        /// Draws scrollbars in the viewMatrix.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="viewMatrix">The view matrix.</param>
        /// <param name="xOffset">The x offset.</param>
        /// <param name="yOffset">The y offset.</param>
        /// <param name="paintArrows">if set to <c>true</c> [paint arrows].</param>
        /// <returns></returns>
        public static bool DrawScrollbars(IViewBoxModel view, ref bool[,] viewMatrix, int xOffset, int yOffset, bool paintArrows = false)
        {
            AbstractViewBoxModelBase vb = view as AbstractViewBoxModelBase;

            if (vb != null)
            {
                if (vb.GetXOffset() != 0)
                {
                    xOffset = vb.GetXOffset();
                }

                if (vb.GetYOffset() != 0)
                {
                    yOffset = vb.GetYOffset();
                }
            }

            bool vertical = false;

            if (view.ContentBox.Height < view.ContentHeight)
            {
                vertical = true;
                drawVerticalScrollBar(view, ref viewMatrix, yOffset, (view.ContentBox.Height < 8 ? true : paintArrows));
            }

            if (view.ContentBox.Width < view.ContentWidth)
            {
                drawHorizontalScrollBar(view, ref viewMatrix, xOffset, vertical, (view.ContentBox.Width < 8 ? true : paintArrows));
            }
            return(true);
        }
        /*Builds the text matrix with cursor if needed.*/
        private bool[,] buildTextMatrix(IViewBoxModel view)
        {
            bool[,] renderedText = emptyMatrix;

            if (view != null)
            {
                //Renders the InputBox content
                renderedText = textRenderer.RenderTitleMatrix(view, editFieldEntry, boxProperties.LineContentWidth, boxProperties.LineCount, boxProperties.CharsPerLine, titleHasChanged);

                //If EditField is activated, the cursor will be rendered into the content matrix
                if (editFieldEntry.Status.HasFlag(DialogEntryStatus.Editing) && cursorRenderer.ShowCursorForBlinking)
                {
                    int position = editFieldEntry.GetCursorPosition();
                    //Adjust CursorPosition for Rendereing
                    if (editFieldEntry.InputBox.BoxHeightType == BoxHeightTypes.SingleLine || editFieldEntry.InputBox.MinimizeType == MinimizeTypes.AlwaysMinimize)
                    {
                        //Position has a shifting due to dots infront/after SingleLine Text
                        position = position - textRenderer.GetLastSegmentIndex() + textRenderer.GetPositionOffset();
                    }
                    //Position has a shifting due to line breaks that might ignore spaces in next lines
                    else if (boxProperties.LineCount != null && boxProperties.LineCount > 1)
                    {
                        position = getCharPositionsAfterLineBreaks(renderedText, position, editFieldEntry.Title);
                    }

                    renderedText = cursorRenderer.renderCursorIntoTitleMatrix(renderedText, editFieldEntry, position, cursorHasChanged);
                    //renderedText = renderCursorIntoTitleMatrix(renderedText, position);
                }
            }

            return(renderedText);
        }
Example #5
0
        /// <summary>
        /// Renders the breadcrumb menu.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="activeDialog">The active dialog.</param>
        /// <param name="renderedEntries">The rendered entries list for touch interaction.</param>
        protected virtual bool renderBreadcrumbMenu(IViewBoxModel view, Dialog activeDialog, ref List <RenderedDialogEntry> renderedEntries)
        {
            if (TitleRenderer != null)
            {
                var tm = TitleRenderer.RenderMatrix(view, activeDialog);
                if (tm != null && !tm.Equals(emptyMatrix))
                {
                    IList <RenderElement> rE = TitleRenderer is BreadcrumbRenderer ?
                                               ((BreadcrumbRenderer)TitleRenderer).GetAllRenderElements() :
                                               TitleRenderer is ITouchableRenderer ?
                                               ((ITouchableRenderer)TitleRenderer).GetAllContentInArea(0, tm.GetLength(1), 0, tm.GetLength(0)) as IList <RenderElement> :
                                               null;

                    renderedEntries.Add(new RenderedDialogEntry(tm, rE));

                    renderedEntries.Add(onePinSpacerEntry);                             // spacing
                    renderedEntries.Add(getSolidDividerEntry(view.ContentBox.Width));   // separation
                    // renderedEntries.Add(getSolidDividerEntry(view.ContentBox.Width));   // separation
                    renderedEntries.Add(onePinSpacerEntry);                             // spacing

                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// Informs the renderer that the content the or view has changed.
        /// You have to call the PrerenderMatrix function manually if you want to have a cached result.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="content">The content.</param>
        public virtual void ContentOrViewHasChanged(IViewBoxModel view, object content)
        {
            string viewString = viewToString(view);

            // if (!ViewBoxModelEquals(lastView, view))
            contentOrViewHasChanged(viewString, content);
        }
Example #7
0
 private void calculateLineWidth(IViewBoxModel view4rendering)
 {
     if (view4rendering != null)
     {
         LineWidth = view4rendering.ContentBox.Width - SCROLLBAR_WIDTH;
     }
 }
Example #8
0
        /// <summary>
        /// Renders a content object into an boolean matrix;
        /// while <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </summary>
        /// <param name="view">The frame to render in. This gives access to the space to render and other parameters. Normally this is a BrailleIOViewRange.</param>
        /// <param name="content">The content to render.</param>
        /// <returns>
        /// A two dimensional boolean M x N matrix (bool[M,N]) where M is the count of rows (this is height)
        /// and N is the count of columns (which is the width).
        /// Positions in the Matrix are of type [i,j]
        /// while i is the index of the row (is the y position)
        /// and j is the index of the column (is the x position).
        /// In the matrix <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </returns>
        public bool[,] RenderMatrix(IViewBoxModel view, object content)
        {
            callAllPreHooks(ref view, ref content, null);

            if (!ViewBoxModelEquals(lastView, view))
            {
                ContentOrViewHasChanged(view, content);
            }
            else if (!lastContent.Equals(content))
            {
                ContentOrViewHasChanged(view, content);
            }

            if (ContentChanged)
            {
                _cachedMatrix  = RenderMatrix(view, content, CallHooksOnCacherendering);
                LastRendered   = DateTime.Now;
                ContentChanged = false;
            }

            bool[,] output = GetCachedMatrix().Clone() as bool[, ];
            callAllPostHooks(view, content, ref output, null);

            return(output);
        }
 // Result is addressed in [y, x] notation.
 void IBailleIORendererHook.PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     if (Active && DoRenderBoundingBox && WindowManager.Instance != null && !WindowManager.Instance.IsInMinimapMode())
     {
         doBlinkingBoundingBox(view, content, ref result, additionalParams);
     }
 }
Example #10
0
        /// <summary>
        /// Gets the page bounds in view range.
        /// </summary>
        /// <param name="view">The view the page is presented in.</param>
        /// <param name="pagePosOnScreen">The page bounds on the screen in pixels.</param>
        /// <returns>The page bounds in the content of the view range in pins.</returns>
        public static Rectangle GetPageBoundsInViewRange(IViewBoxModel view, Rectangle pagePosOnScreen)
        {
            // make the document bounds relative to the chosen zoom level
            double zoom = view is BrailleIO.Interface.IZoomable ? zoom = ((BrailleIO.Interface.IZoomable)view).GetZoom() : 1;

            if (((BrailleIOViewRange)view).Name.Equals(WindowManager.VR_CENTER_NAME) && ((BrailleIOViewRange)view).Parent.Name.Equals(WindowManager.BS_MINIMAP_NAME))
            {
                if (WindowManager.Instance != null)
                {
                    zoom = WindowManager.Instance.MinimapScalingFactor; // handling for minimap mode
                }
            }

            Rectangle zPos = new Rectangle(
                (int)(pagePosOnScreen.X * zoom),
                (int)(pagePosOnScreen.Y * zoom),
                (int)(pagePosOnScreen.Width * zoom),
                (int)(pagePosOnScreen.Height * zoom)
                );

            // add the panning offsets
            if (view is IPannable)
            {
                zPos.X += ((IPannable)view).GetXOffset();
                zPos.Y += ((IPannable)view).GetYOffset();
            }

            return(zPos);
        }
        public void PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
        {
            if (view != null && content != null && result != null)
            {
                if (!String.IsNullOrEmpty(selectedString) && content.ToString().ToLower().Contains(selectedString.ToLower()))
                {
                    int start = content.ToString().ToLower().IndexOf(selectedString.ToLower());
                    //check
                    int end = start + selectedString.Length;
                    start = start * 3;    // each letter has 3 dot * 5
                    end   = end * 3;
                    int underlinePos = 4; // underline 4 & 8

                    for (int i = start; i < end; i++)
                    {
                        if (result.GetLength(0) > underlinePos)
                        {
                            if (result.GetLength(1) > i)
                            {
                                result[underlinePos, i] = true;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Renders the label.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        public bool[,] RenderLabel(EditField_DialogEntry entry, IViewBoxModel view)
        {
            bool[,] labelMatrix = emptyMatrix;

            if (cachedLabelMatrix == null)
            {
                if (view != null && entry != null && entry.HasLabel)
                {
                    string titleBackup = entry.Title;

                    this.Entry.Title = entry.Label;

                    labelMatrix = renderDialogEntry(view);

                    cachedLabelMatrix = labelMatrix;

                    this.Entry.Title = titleBackup;

                    lastLabel = entry.Label;
                }
            }
            else
            {
                labelMatrix = (bool[, ])cachedLabelMatrix.Clone();
            }

            return(labelMatrix);
        }
        /*Builds the cached matrix consisting out of edges, borders, title and cursor.
         * Parts will be rendered new depending on changes on runtime.
         * If entry is NOT graphical, boders and edges will not be rendered.*/
        private bool[,] buildContentMatrix(IViewBoxModel view)
        {
            bool[,] boxMatrix = emptyMatrix;

            if (view != null && editFieldEntry != null && editFieldEntry.Title != null)
            {
                //Renders the field text, if needed with cursor
                bool[,] renderedText = buildTextMatrix(view);

                //Renders Box that will contain text. If Graphical, it gets borders and edges. If Not, it will have enough
                // space for an indenting and will get 1 extra pin line to seperate label and content
                boxMatrix = boxRenderer.RenderBoxMatrix(boxProperties.BoxDimensions, borderOrEdgeHaveChanged,
                                                        editFieldEntry.InputBox.IsGraphical, EditField_BoxProperties.BORDER_THICKNESS);

                //if editFieldEntry.Title is not empty, fill the box matrix with text matrix
                if (editFieldEntry.Title.Length > 0 || editFieldEntry.Status.HasFlag(DialogEntryStatus.Editing))
                {
                    boxMatrix = fillBoxMatrixWithTextMatrix(boxMatrix, renderedText);
                }

                lastView           = view;
                lastTitle          = Entry.Title;
                lastCursorPosition = editFieldEntry.GetCursorPosition();
                lastIsMinimized    = editFieldEntry.InputBox.IsMinimized;
            }
            return(boxMatrix);
        }
Example #14
0
 // Result is addressed in [y, x] notation.
 void IBailleIORendererHook.PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     if (Active && _doRenderBoundingBox &&
         WindowManager.Instance != null && !WindowManager.Instance.IsInMinimapMode())
     {
         doBlinkingBoundingBox(view, content, ref result, additionalParams);
     }
 }
Example #15
0
        /// <summary>
        /// Renders a content object into an boolean matrix;
        /// while <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </summary>
        /// <param name="view">The frame to render in. This gives access to the space to render and other parameters. Normally this is a IBrailleIOViewRange.</param>
        /// <param name="content">The content to render.</param>
        /// <returns>
        /// A two dimensional boolean M x N matrix (bool[M,N]) where M is the count of rows (this is height)
        /// and N is the count of columns (which is the width).
        /// Positions in the Matrix are of type [i,j]
        /// while i is the index of the row (is the y position)
        /// and j is the index of the column (is the x position).
        /// In the matrix <c>true</c> values indicating raised pins and <c>false</c> values indicating lowered pins
        /// </returns>
        public bool[,] RenderMatrix(IViewBoxModel view, object content)
        {
            bool[,] m = emptyMatrix;

            if (content != null && content is Dialog && view != null)
            {
                Dialog activeDialog = ((Dialog)content).GetActiveDialog();
                if (activeDialog != null)
                {
                    List <RenderedDialogEntry> renderedEntries = new List <RenderedDialogEntry>();

                    if (Properties.HasFlag(DialogRenderingProperties.HideEntries))
                    {
                        //////// BREADCRUMB //////
                        if (Properties.HasFlag(DialogRenderingProperties.ShowHeader))
                        {
                            renderBreadcrumbMenu(view, activeDialog, ref renderedEntries);
                        }
                    }
                    else
                    {
                        /////////// HELP ////////////
                        if (activeDialog.HelpIsShown)
                        {
                            m = renderHelp(view, activeDialog);
                        }
                        ////////// NORMAL //////////
                        else
                        {
                            //////// BREADCRUMB //////
                            if (Properties.HasFlag(DialogRenderingProperties.ShowHeader))
                            {
                                renderBreadcrumbMenu(view, activeDialog, ref renderedEntries);
                            }
                            //////// ENTRIES //////
                            renderDialogEntries(view, activeDialog, ref renderedEntries);
                        }
                    }

                    // build them together
                    if (renderedEntries != null && renderedEntries.Count > 0)
                    {
                        m = combineEntries(renderedEntries);
                    }

                    view.ContentHeight = m.GetLength(0);
                    view.ContentWidth  = m.GetLength(1);

                    // check if scrollbars are needed
                    if (view.ContentHeight > view.ContentBox.Height)
                    {
                        view.ContentWidth -= 3; // cut of the overlapping line elements. Text content is rendered with respect of scrollbar space
                    }
                }
            }
            _lastView = view;
            return(m);
        }
Example #16
0
 /// <summary>
 /// Informs the renderer that the content the or view has changed.
 /// You have to call the PrerenderMatrix function manually if you want to have a cached result.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="content">The content.</param>
 public virtual void ContentOrViewHasChanged(IViewBoxModel view, object content)
 {
     if (!ViewBoxModelEquals(lastView, view))
     {
         lastView = view;                                      //Clone(view);
     }
     lastContent    = content;
     ContentChanged = true;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DummyViewBox"/> class.
 /// </summary>
 /// <param name="baseModel">The base model this dummy is copied from.</param>
 public DummyViewBox(IViewBoxModel baseModel)
 {
     if (baseModel != null)
     {
         _contentBox = baseModel.ContentBox;
         _viewBox    = baseModel.ViewBox;
         _cWidth     = baseModel.ContentWidth;
         _cHeight    = baseModel.ContentHeight;
     }
 }
Example #18
0
 /// <summary>
 /// Calculates the height of the line content.
 /// </summary>
 /// <param name="view4rendering">The view4rendering.</param>
 public void CalculateLineContentHeight(IViewBoxModel view4rendering)
 {
     if (view4rendering != null && LineCount > 0)
     {
         /*
          * All char heights view4rendering.ContentHeight * LineCount
          * one line space between multiple lines (LineCount - 1)
          * */
         LineContentHeight = CHAR_HEIGHT * LineCount + (LineCount - 1) + (2 * BORDER_THICKNESS);
     }
 }
        public bool[,] RenderImage(Bitmap img, IViewBoxModel view, IPannable offset, bool invert, double zoom, bool autoThreshold)
        {
            // FIXME: check this (invalidoperationexception nach schwellwert mehrmals absenken)
            var    vr   = view.ContentBox;
            Bitmap img2 = img.Clone() as Bitmap;

            if (img2 != null)
            {
                return(RenderImage(img2, view, offset, invert, zoom, GraphicUtils.GetAverageGrayscale(vr.Width, vr.Height, new Bitmap(img2, new Size((int)Math.Round(img2.Width * zoom), (int)Math.Round(img2.Height * zoom))))));
            }
            return(null);
        }
Example #20
0
 /// <summary>
 /// Calculates the box properties.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="entry">The entry.</param>
 public void CalculateBoxProperties(IViewBoxModel view, EditField_DialogEntry entry)
 {
     if (view != null && entry != null)
     {
         calculateLineWidth(view);
         calculateLineContentWidth();
         calculateCharsPerLine();
         CalculateLineCount(entry);
         CalculateLineContentHeight(view);
         CalculateBoxDimensions(view, entry);
     }
 }
Example #21
0
        /// <summary>
        ///  estimate if scrollbars are needed or not
        /// </summary>
        /// <param name="view">The view to show the content in.</param>
        /// <param name="dialog">The dialog to display.</param>
        /// <returns><c>true</c> if scrollbars are needed; otherwise <c>false</c>.</returns>
        bool needScrollbars(IViewBoxModel view, Dialog dialog)
        {
            if (view != null && view.ContentBox.Height > 0 && dialog != null)
            {
                if (view is IPannable && !((IPannable)view).ShowScrollbars)
                {
                    return(false);
                }

                return(view.ContentBox.Height < estimateContentHeight(dialog.EntryCount));
            }
            return(false);
        }
Example #22
0
        private bool[,] RenderDropDownMenuVertical(IViewBoxModel view, UiElement uiContent)
        {//TODO: Element muss eine Mindestgröße haben
            //call pre hooks
            object cM = uiContent.text as object;

            callAllPreHooks(ref view, ref cM);
            bool[,] boxMatrix;
            if (uiContent.isDisabled)
            {
                boxMatrix = Helper.createBoxDeaktivatedLeft(view.ViewBox.Height, view.ViewBox.Width - 2);
            }
            else
            {
                boxMatrix = Helper.createBox(view.ViewBox.Height, view.ViewBox.Width - 2);       //erstmal eine eckige Matrix // view.ViewBox.Width -2 => da open/close noch angezeigt werden muss
            }
            DropDownMenuItem dropDownMenu = (DropDownMenuItem)uiContent.uiElementSpecialContent; //Der Type mussan dieser Stelle vorher nicht geprüft werden, da das schon in der aufrufenden Methode gemacht wurde

            if (dropDownMenu.hasPrevious)
            {
                //Helper.RemoveBottomBoarder(ref boxMatrix);
                Helper.RemoveTopBoarder(ref boxMatrix);
            }
            //String to Braille/Matrix
            MatrixBrailleRenderer m = new MatrixBrailleRenderer();

            bool[,] textMatrix = m.RenderMatrix(view.ViewBox.Width - 4, (uiContent.text as object == null ? "" : uiContent.text as object), false);
            Helper.copyTextMatrixInMatrix(textMatrix, ref boxMatrix, 2);
            if (dropDownMenu.hasNext)
            {
                SeparatorNextDropDownMenuElementDown(ref boxMatrix);
            }
            bool[,] viewMatrix = new bool[view.ViewBox.Height, view.ViewBox.Width];
            // bool[,] viewMatrix =  Helper.createBox(view.ViewBox.Height - 2, view.ViewBox.Width);
            Helper.copyMatrixInMatrix(boxMatrix, ref viewMatrix); // macht platz in der Matrix für open/close
            //Anpassungen je nach spezifischen DropDownMenuItem
            if (dropDownMenu.hasChild)
            {
                if (dropDownMenu.isOpen)
                {
                    OpenDropDownMenuElementRight(ref viewMatrix);
                }
                else
                {
                    CloseDropDownMenuElementRight(ref viewMatrix);
                }
            }
            //call post hooks
            callAllPostHooks(view, cM, ref viewMatrix, false);

            return(viewMatrix);
        }
Example #23
0
        public bool[,] RenderListItem(IViewBoxModel view, UiElement uiElement)
        {
            //mehrere ListItems (als Gruppe zusammengefasst) bilden eine Liste

            ListMenuItem listmenuItem;

            if (uiElement.uiElementSpecialContent == null)
            {
                return(new bool[0, 0]);
            }
            Type typeSpecialContent = uiElement.uiElementSpecialContent.GetType();

            if (typeof(ListMenuItem).Equals(typeSpecialContent))
            {
                listmenuItem = (ListMenuItem)uiElement.uiElementSpecialContent;
            }
            else
            {
                throw new InvalidCastException("Can't cast uiElementSpecialContent to ListMenuItem! {0}");
            }
            bool[,] matrix = new bool[view.ViewBox.Height, view.ViewBox.Width];
            bool[,] text;
            MatrixBrailleRenderer m = new MatrixBrailleRenderer();

            if (listmenuItem.hasNext)
            {
                bool[,] seperatorLine = Helper.createInterruptedLine(view.ViewBox.Width);
                Helper.copyMatrixInMatrix(seperatorLine, ref matrix, 0, view.ViewBox.Height - 1);
            }
            if (listmenuItem.isMultipleSelection)
            {
                bool [,] box;
                if (listmenuItem.isSelected)
                {
                    box = Helper.createSelectedBox(4, 4);
                }
                else
                {
                    box = Helper.createBox(4, 4);
                }
                Helper.copyMatrixInMatrix(box, ref matrix, 1, 1);
                text = m.RenderMatrix(view.ViewBox.Width - 4, (uiElement.text as object == null ? "" : uiElement.text as object), false);
                Helper.copyMatrixInMatrix(text, ref matrix, 6, 1);
            }
            else
            {
                text = m.RenderMatrix(view.ViewBox.Width, (uiElement.text as object == null ? "" : uiElement.text as object), false);
                Helper.copyMatrixInMatrix(text, ref matrix, 0, 1);
            }
            return(matrix);
        }
        /// <summary>
        /// Determine if the content or some important variables of the view have changed or not.
        /// </summary>
        /// <param name="view">The view the content is presented in.</param>
        /// <param name="content">The content to render.</param>
        /// <returns><c>true</c> if some important variables has been changed since the last rendering; otherwise, <c>false</c>.</returns>
        protected virtual bool DidContentOrViewHaveChanged(IViewBoxModel view, object content)
        {
            string viewString = viewToString(view);

            if (!viewString.Equals(lastView))// !ViewBoxModelEquals(lastView, view))
            {
                contentOrViewHasChanged(viewString, content);
            }
            else if (!lastContent.Equals(content))
            {
                ContentOrViewHasChanged(view, content);
            }
            return(ContentChanged);
        }
Example #25
0
 /// <summary>
 /// Draw a blinking frame around the current selected shape.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="content"></param>
 /// <param name="result"></param>
 /// <param name="additionalParams"></param>
 virtual protected void doBlinkingBoundingBox(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     //draw frame as bool pins
     if (_doRenderBoundingBox &&
         CurrentPoint.X < 0 && CurrentPoint.Y < 0 &&
         !(CurrentBoundingBox.Width * CurrentBoundingBox.Height < 1))
     {
         result = paintBoundingBoxMarker(view, result);
     }
     else
     {
         result = paintPolygonPointMarker(view, result);
     }
 }
        /*Checks if changes have occured and which parts of the inputbox need to be rendered again*/
        private bool changeOccured(IViewBoxModel view)
        {
            if (view != null && editFieldEntry != null && editFieldEntry.InputBox != null)
            {
                if (lastView != null && lastCursorPosition != null && lastTitle != null && lastIsMinimized != null)
                {
                    if (lastView.ContentBox.Width != view.ContentBox.Width)
                    {
                        cursorHasChanged        = true;
                        borderOrEdgeHaveChanged = true;
                        titleHasChanged         = true;
                        viewHasChanged          = true;
                    }
                    else
                    {
                        if (editFieldEntry.InputBox.IsMinimized != lastIsMinimized || editFieldEntry.Title.Length != lastTitle.Length)
                        {
                            borderOrEdgeHaveChanged = true;
                            cursorHasChanged        = true;
                            titleHasChanged         = true;
                        }
                        if (!editFieldEntry.Title.Equals(lastTitle))
                        {
                            titleHasChanged  = true;
                            cursorHasChanged = true;
                        }
                        if (editFieldEntry.GetCursorPosition() != lastCursorPosition)
                        {
                            cursorHasChanged = true;
                            if (editFieldEntry.InputBox.BoxHeightType != null && (editFieldEntry.InputBox.BoxHeightType == BoxHeightTypes.SingleLine || editFieldEntry.InputBox.MinimizeType == MinimizeTypes.AlwaysMinimize))
                            {
                                titleHasChanged = true;
                            }
                        }
                    }
                }
                else
                {
                    lastTitle       = editFieldEntry.Title;
                    lastView        = view;
                    lastIsMinimized = editFieldEntry.InputBox.IsMinimized;

                    viewHasChanged          = true;
                    titleHasChanged         = true;
                    borderOrEdgeHaveChanged = true;
                    cursorHasChanged        = true;
                }
            }
            return(viewHasChanged || titleHasChanged || borderOrEdgeHaveChanged || cursorHasChanged);
        }
        /// <summary>
        /// Renders the image.
        /// </summary>
        /// <param name="img">The image.</param>
        /// <param name="view">The view.</param>
        /// <param name="offset">The offset for translation.</param>
        /// <param name="invert">if set to <c>true</c>  the result will be inverted.</param>
        /// <param name="zoom">The zoom factor.</param>
        /// <param name="autoThreshold">if set to <c>true</c> [automatic threshold] is applied.</param>
        /// <param name="callHooks">if set to <c>true</c> per- and post renderer hooks  are called.</param>
        /// <returns>
        /// a bool matrix
        /// </returns>
        public bool[,] RenderImage(Bitmap img, IViewBoxModel view, IPannable offset, bool invert, double zoom, bool autoThreshold, bool callHooks = true)
        {
            var    vr   = view.ContentBox;
            Bitmap img2 = img.Clone() as Bitmap;

            if (img2 != null)
            {
                return(RenderImage(img2, view, offset, invert, zoom,
                                   GraphicUtils.GetAverageGrayscale(vr.Width, vr.Height, new Bitmap(img2, new Size((int)Math.Round(img2.Width * zoom), (int)Math.Round(img2.Height * zoom))))
                                   , callHooks
                                   ));
            }
            return(null);
        }
Example #28
0
        /// <summary>
        /// Renders the dialog entries and add the results into the global list of
        /// rendered entries for a combination afterwards.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="activeDialog">The active dialog to render.</param>
        /// <param name="renderedEntries">The rendered entries for touch interaction where the
        /// rendering results where added to.</param>
        /// <param name="horizontalOffset">The horizontal offset (spacing/indentation)
        /// from the left for some kind of indentation.</param>
        /// <returns>
        ///   <c>true</c> if the entries were rendered successfully.
        /// </returns>
        protected virtual bool renderDialogEntries(IViewBoxModel view, Dialog activeDialog, ref List <RenderedDialogEntry> renderedEntries, int horizontalOffset = 0)
        {
            // var entries2render = activeDialog.GetEntryList().ToList<IDialogComponent>();

            // get only top-level entries
            List <IDialogComponent> entries2render = activeDialog.GetEntryList().FindAll(
                (entry) => { return(entry != null && !entry.IsInGroup()); }).ToList <IDialogComponent>();

            using (DialogEntryRenderer der = new DialogEntryRenderer())
            {
                renderEntries(view, entries2render, ref renderedEntries, horizontalOffset, der);
            }
            return(true);
        }
        /// <summary>
        /// Renders a content object into an boolean matrix;
        /// while <c>true</c> values indicating raised pins and <c>false</c> values indicating lowerd pins
        /// </summary>
        /// <param name="view">The frame to render in. This gives acces to the space to render and other paramenters. Normaly this is a <see cref="BrailleIOViewRange"/>.</param>
        /// <param name="content">The content to render.</param>
        /// <returns>
        /// A two dimensional boolean M x N matrix (bool[M,N]) where M is the count of rows (this is height)
        /// and N is the count of columns (which is the width).
        /// Positions in the Matrix are of type [i,j]
        /// while i is the index of the row (is the y position)
        /// and j is the index of the column (is the x position).
        /// In the matrix <c>true</c> values indicating raised pins and <c>false</c> values indicating lowerd pins
        /// </returns>
        public bool[,] RenderMatrix(IViewBoxModel view, object content)
        {
            callAllPreHooks(ref view, ref content);

            int  width       = view.ContentBox.Width;
            bool scrolleBars = false;
            var  matrix      = RenderMatrix(width, content, scrolleBars);

            view.ContentHeight = matrix.GetLength(0);
            view.ContentWidth  = matrix.GetLength(1);

            callAllPostHooks(view, content, ref matrix);

            return(matrix);
        }
 void IBailleIORendererHook.PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     _lastView = view as BrailleIOViewRange;
     if (Active
         && CanBeActivated()
         )
     {
         List<TextElemet> visibleTexts = getVisibleTextElements(view);
         foreach (var visibleText in visibleTexts)
         {
             renderTextFieldInMatrix(ref result, visibleText, ((BrailleIOViewRange)view).GetXOffset(), ((BrailleIOViewRange)view).GetYOffset(), ((BrailleIOViewRange)view).GetZoom());
         }
         visibleTexts = null;
     }
 }
        private List<TextElemet> getVisibleTextElements(IViewBoxModel view)
        {
            List<TextElemet> texts = getAllTextElementsOfDoc();

            List<TextElemet> visibleTexts = new List<TextElemet>();
            foreach (var text in texts)
            {
                if (IsElementsBoundingBoxVisibleInView(view as BrailleIOViewRange, text.ScreenPosition))
                {
                    visibleTexts.Add(text);
                }
            }

            return visibleTexts;
        }
Example #32
0
        public bool[,] RenderMatrix(IViewBoxModel view, object otherContent)
        {
            UiElement uiElement;
            Type      typeOtherContent = otherContent.GetType();

            if (typeof(UiElement).Equals(typeOtherContent))
            {
                uiElement = (UiElement)otherContent;
            }
            else
            {
                throw new InvalidCastException("Can't cast otherContent to UiElement! {0}");
            }
            return(RenderListItem(view, uiElement));
        }
Example #33
0
 void IBailleIORendererHook.PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     _lastView = view as BrailleIOViewRange;
     if (Active &&
         CanBeActivated()
         )
     {
         List <TextElemet> visibleTexts = getVisibleTextElements(view);
         foreach (var visibleText in visibleTexts)
         {
             renderTextFieldInMatrix(ref result, visibleText, ((BrailleIOViewRange)view).GetXOffset(), ((BrailleIOViewRange)view).GetYOffset(), ((BrailleIOViewRange)view).GetZoom());
         }
         visibleTexts = null;
     }
 }
        public void PreRenderHook(ref IViewBoxModel view, ref object content, params object[] additionalParams)
        {
            if (boolBlink && content != null && content is String)
            {
                string contentStr = (string)content;

                int caretPos = getCaretOff(contentStr) + BKI.Caret;
                string character = caretPos < contentStr.Length ? contentStr.Substring(caretPos, 1) : " ";
                var dotPattern = ScriptFunctionProxy.Instance.BrailleKeyboard.GetDotsForChar(character);
                if (dotPattern == null)
                {
                    dotPattern = "";
                }
                if (!dotPattern.Contains("8"))
                {
                    if (!dotPattern.Contains("7"))
                    {
                        dotPattern += "7";
                    }
                    //append 8 at the end of the string
                    dotPattern += "8";
                }
                else
                {
                    if (!dotPattern.Contains("7"))
                    {
                        dotPattern.Replace("8", "78");
                    }
                }
                string nc = ScriptFunctionProxy.Instance.BrailleKeyboard.GetCharFromDots(dotPattern); // char with underline dots 7 & 8

                if (caretPos >= contentStr.Length)
                {
                    contentStr += nc;
                }
                else
                {
                    contentStr = contentStr.Substring(0, caretPos) + nc + contentStr.Substring(caretPos + 1);
                }
                content = contentStr;
            }
        }
 void IBailleIORendererHook.PreRenderHook(ref IViewBoxModel view, ref object content, params object[] additionalParams) 
 {
 
 }
 public void PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     return;
 }
        void IBailleIORendererHook.PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
        {
            if (Active && Wnd != null)
            {
                if (Wnd.Disposed)
                {
                    Wnd = null;
                    //TODO: maybe set this as not active
                    return;
                }
                if (!ask) // refresh regularly
                {
                    if ((DateTime.Now - last) > refresh) ask = true;
                }

                // check if the bound have to be updated or not
                if (ask || pos.Width < 1 || pos.Height < 1)
                {
                    var activePage = Wnd.GetActivePage();
                    if (activePage != null)
                    {

                        System.Drawing.Rectangle pageBoundsInPx = OoDrawUtils.convertToPixel(
                            new System.Drawing.Rectangle(
                                -activePage.PagesObserver.ViewOffset.X + activePage.BorderLeft,
                                -activePage.PagesObserver.ViewOffset.Y + activePage.BorderTop,
                                activePage.Width - activePage.BorderLeft - activePage.BorderRight,
                                activePage.Height - activePage.BorderTop - activePage.BorderBottom),
                            activePage.PagesObserver.ZoomValue,
                            OoDrawPagesObserver.PixelPerMeterY,
                            OoDrawPagesObserver.PixelPerMeterY);
                       var spos = new System.Drawing.Rectangle(pageBoundsInPx.X, pageBoundsInPx.Y, pageBoundsInPx.Width, pageBoundsInPx.Height);

                        if (spos.Width > 0 && spos.Height > 0)
                        {
                            pos = spos;
                        }
                        ask = false;
                        last = DateTime.Now;

                    }
                }

                // make the document bounds relative to the chosen zoom level
                double zoom = view is BrailleIO.Interface.IZoomable ? zoom = ((BrailleIO.Interface.IZoomable)view).GetZoom() : 1;
                if (((BrailleIOViewRange)view).Name.Equals(WindowManager.VR_CENTER_NAME) && ((BrailleIOViewRange)view).Parent.Name.Equals(WindowManager.BS_MINIMAP_NAME))
                {
                    if (WindowManager.Instance != null)
                    {
                        zoom = WindowManager.Instance.MinimapScalingFactor; // handling for minimap mode
                    }
                }

                Rectangle zPos = new Rectangle(
                    (int)(pos.X * zoom),
                    (int)(pos.Y * zoom),
                    (int)(pos.Width * zoom),
                    (int)(pos.Height * zoom)
                    );

                // add the panning offsets
                if (view is IPannable)
                {
                    zPos.X += ((IPannable)view).GetXOffset();
                    zPos.Y += ((IPannable)view).GetYOffset();
                }

                //TODO: decide in inner frame or outer frame
                int y1 = zPos.Y - 1;
                int y2 = zPos.Y + zPos.Height;
                int x1 = 0;

                int width = result.GetLength(1);
                int height = result.GetLength(0);

                //horizontal lines
                for (int x = 0; x < zPos.Width; x += 2)
                {
                    x1 = zPos.X + x;

                    if (x1 >= 0 && x1 < width)
                    {
                        if (y1 >= 0 && y1 < height)
                        {
                            result[y1, x1] = true;
                        }

                        if (y2 >= 0 && y2 < height)
                        {
                            result[y2, x1] = true;
                        }
                    }
                }

                x1 = zPos.X - 1;
                int x2 = zPos.X + zPos.Width;

                //vertical lines
                for (int y = 0; y < zPos.Height; y += 2)
                {
                    y1 = zPos.Y + y;
                    if (y1 >= 0 && y1 < height)
                    {

                        if (x1 >= 0 && x1 < width)
                        {
                            result[y1, x1] = true;
                        }

                        if (x2 >= 0 && x2 < width)
                        {
                            result[y1, x2] = true;
                        }
                    }
                }
            }
        }
        private bool[,] paintBoundingBoxMarker(IViewBoxModel view, bool[,] result)
        {
            if (view is IZoomable && view is IPannable)
            {
                double zoom = ((BrailleIO.Interface.IZoomable)view).GetZoom();
                int xOffset = ((IPannable)view).GetXOffset();
                int yOffset = ((IPannable)view).GetYOffset();

                //if (WindowManager.Instance != null && WindowManager.Instance.ScreenObserver != null && WindowManager.Instance.ScreenObserver.ScreenPos is System.Drawing.Rectangle)
                //{

                Rectangle pageBounds = getPageBounds();

                if (pageBounds.Width > 0 && pageBounds.Height > 0)
                {
                    // coords of the shapes bounding box, relative to the whole captured image
                    Rectangle relbBox = new Rectangle(CurrentBoundingBox.X - pageBounds.X, CurrentBoundingBox.Y - pageBounds.Y, CurrentBoundingBox.Width, CurrentBoundingBox.Height);
                    // converted to braille output coords, as shown in the original view (with zoom factor and panning position applied)
                    Rectangle out_bBox = new Rectangle(
                        (int)Math.Round((relbBox.X * zoom) + xOffset - 1), // x
                        (int)Math.Round((relbBox.Y * zoom) + yOffset - 1), // y
                        (int)Math.Round((relbBox.Width * zoom) + 2),       // w
                        (int)Math.Round((relbBox.Height * zoom) + 2));     // h

                    // check for minimal height and width
                    if (out_bBox.Width < MIN_FRAME_SIZE)
                    {
                        int oldWidth = out_bBox.Width;
                        out_bBox.Width = MIN_FRAME_SIZE;
                        int change = out_bBox.Width - oldWidth;
                        out_bBox.X -= ((change) / 2);
                    }

                    if (out_bBox.Height < MIN_FRAME_SIZE)
                    {
                        int oldHeight = out_bBox.Height;
                        out_bBox.Height = MIN_FRAME_SIZE;
                        int change = out_bBox.Height - oldHeight;

                        out_bBox.Y -= ((change) / 2);
                    }

                    if (out_bBox.Width > 0 && out_bBox.Height > 0)
                    {
                        int result_x_max = result.GetLength(1) - 1;
                        int result_y_max = result.GetLength(0) - 1;
                        // rectangle coords within matrix:
                        int x1 = Math.Max(0, out_bBox.X);                                // from bBox x (or 0)
                        int x2 = Math.Min(out_bBox.X + out_bBox.Width, result_x_max);    // to bBox x + w (or x rightmost of matrix)
                        int y1 = Math.Max(0, out_bBox.Y);                                // from bBox y (or 0)
                        int y2 = Math.Min(out_bBox.Y + out_bBox.Height, result_y_max);   // to bBox y + h (or y bottom of matrix)

                        // TODO capture on blink one frame, one blink out frame of matrix withing bounding box to let the content blink after capturing without having to modify dom any more
                        // TODO: check if shape is in visible view port --> if shape is not visible, do not blink

                        if (y2 >= y1 && x2 >= x1)
                        {
                            /* draw outer (inflated box) and inner (deflated box) lowered pins around the raised pins bounding box itself to improve contrast
                                *   ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
                                * ○ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ○
                                * ○ ● ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ● ○
                                * ○ ● ○                     ○ ● ○
                                * ○ ● ○                     ○ ● ○
                                * ○ ● ○                     ○ ● ○
                                * ○ ● ○                     ○ ● ○
                                * ○ ● ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ● ○
                                * ○ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ○
                                *   ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 
                            */

                            bool[,] target = result;

                            // draw horizontal lines
                            Parallel.For(x1, x2,
                                (x) =>
                                {
                                    if (x >= 0 && x <= result_x_max)
                                    {
                                        if (y1 >= 0 && y1 <= result_y_max)
                                        {
                                            // top border
                                            if (y1 > 0) target[y1 - 1, x] = false;   // outer (lowered pins)
                                            if (y1 < result_y_max && x > x1 && x < x2) target[y1 + 1, x] = false;   // inner (lowered pins)
                                            target[y1, x] = (!_dashed || (x - x1) % 3 != 2) ? true : false;        // raised pins, except every 3rd in dashed mode

                                        }
                                        if (y2 >= 0 && y2 <= result_y_max)
                                        {
                                            // bottom border
                                            if (y2 > 0 && x > x1 && x < x2) target[y2 - 1, x] = false;   // inner (lowered pins)
                                            if (y2 < result_y_max) target[y2 + 1, x] = false;   // outer (lowered pins)
                                            target[y2, x] = (!_dashed || (x - x1) % 3 != 2) ? true : false;        // raised pins, except every 3rd in dashed mode
                                        }
                                    }
                                }
                               );

                            // draw vertical lines
                            Parallel.For(y1, y2 + 1,
                                (y) =>
                                {
                                    if (y >= 0 && y <= result_y_max)
                                    {
                                        if (x1 >= 0 && x1 <= result_x_max)
                                        {
                                            // left border 
                                            if (x1 > 0) target[y, x1 - 1] = false;  // outer (lowered pins)
                                            if (x1 < result_x_max && y > y1 && y < y2) target[y, x1 + 1] = false;  // inner (lowered pins)
                                            target[y, x1] = (!_dashed || (y - y1) % 3 != 2) ? true : false;        // raised pins, except every 3rd in dashed mode
                                        }
                                        if (x2 >= 0 && x2 <= result_x_max)
                                        {
                                            // right border 
                                            if (x2 > 0 && y > y1 && y < y2) target[y, x2 - 1] = false;  // inner (lowered pins)
                                            if (x2 < result_x_max) target[y, x2 + 1] = false;  // outer (lowered pins)
                                            target[y, x2] = (!_dashed || (y - y1) % 3 != 2) ? true : false;        // raised pins, except every 3rd in dashed mode
                                        }
                                    }
                                }
                                );

                            result = target;
                        }
                    }
                }
                //}
            }
            return result;
        }
        private bool[,] paintPolygonPointMarker(IViewBoxModel view, bool[,] result)
        {
            // point;
            if (result != null
                //&& CurrentBoundingBox.X >= 0 && CurrentBoundingBox.Y >= 0
                && CurrentPoint.X > 0 && CurrentPoint.Y > 0
                )
            {
                int result_x_max = result.GetLength(1);
                int result_y_max = result.GetLength(0);

                if (result_x_max * result_y_max > 0)
                {

                    if (view is IZoomable && view is IPannable)
                    {
                        //Rectangle pageBounds = getPageBounds();
                        double zoom = ((BrailleIO.Interface.IZoomable)view).GetZoom();
                        int xOffset = ((IPannable)view).GetXOffset();
                        int yOffset = ((IPannable)view).GetYOffset();
                        // coords of the shapes bounding box, relative to the whole captured image
                        // Rectangle relbBox = new Rectangle(CurrentBoundingBox.X - pageBounds.X, CurrentBoundingBox.Y - pageBounds.Y, CurrentBoundingBox.Width, CurrentBoundingBox.Height);

                        Point relPoint = new Point(CurrentPoint.X
                            //- pageBounds.X
                            , CurrentPoint.Y
                            //- pageBounds.Y
                            );

                        // converted to braille output coords, as shown in the original view (with zoom factor and panning position applied)
                        Point out_bBox = new Point(
                            (int)Math.Round((relPoint.X * zoom) + xOffset - 1), // x
                            (int)Math.Round((relPoint.Y * zoom) + yOffset - 1)); // y

                        int x = out_bBox.X;
                        int y = out_bBox.Y;

                        /*
                         * DoRenderBoundingBox
                         *     true             |  false
                         *      ○               |  
                         *    ○ ● ○             |    ○
                         *  ○ ● + ● ○           |  ○ + ○
                         *    ○ ● ○             |    ○
                         *      ○               |
                         */

                        // cross
                        setSaveDot(x, y, ref result, DoRenderBoundingBox, result_x_max, result_y_max);
                        setSaveDot(x - 1, y, ref result, DoRenderBoundingBox, result_x_max, result_y_max);
                        setSaveDot(x + 1, y, ref result, DoRenderBoundingBox, result_x_max, result_y_max);
                        setSaveDot(x, y - 1, ref result, DoRenderBoundingBox, result_x_max, result_y_max);
                        setSaveDot(x, y + 1, ref result, DoRenderBoundingBox, result_x_max, result_y_max);

                        if (DoRenderBoundingBox)
                        {
                            // cross spacing
                            setSaveDot(x - 2, y, ref result, false, result_x_max, result_y_max);
                            setSaveDot(x + 2, y, ref result, false, result_x_max, result_y_max);

                            setSaveDot(x - 1, y - 1, ref result, false, result_x_max, result_y_max);
                            setSaveDot(x - 1, y + 1, ref result, false, result_x_max, result_y_max);

                            setSaveDot(x, y - 2, ref result, false, result_x_max, result_y_max);
                            setSaveDot(x, y + 2, ref result, false, result_x_max, result_y_max);

                            setSaveDot(x + 1, y - 1, ref result, false, result_x_max, result_y_max);
                            setSaveDot(x + 1, y + 1, ref result, false, result_x_max, result_y_max);
                        }
                    }
                }
            }
            return result;
        }
 /// <summary>
 /// Draw a blinking frame around the current selected shape.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="content"></param>
 /// <param name="result"></param>
 /// <param name="additionalParams"></param>
 private void doBlinkingBoundingBox(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
 {
     //draw frame as bool pins
     if (DoRenderBoundingBox &&
         CurrentPoint.X < 0 && CurrentPoint.Y < 0 &&
         !(CurrentBoundingBox.Width * CurrentBoundingBox.Height < 1))
     {
         result = paintBoundingBoxMarker(view, result);
     }
     else
     {
         result = paintPolygonPointMarker(view, result);
     }
 }
 public void PreRenderHook(ref IViewBoxModel view, ref object content, params object[] additionalParams) { }
        public void PostRenderHook(IViewBoxModel view, object content, ref bool[,] result, params object[] additionalParams)
        {
            if (view != null && content != null && result != null)
            {
                if (!String.IsNullOrEmpty(selectedString) && content.ToString().ToLower().Contains(selectedString.ToLower()))
                {
                    int start = content.ToString().ToLower().IndexOf(selectedString.ToLower());
                    //check
                    int end = start + selectedString.Length;
                    start = start * 3; // each letter has 3 dot * 5
                    end = end * 3;
                    int underlinePos = 4; // underline 4 & 8

                    for (int i = start; i < end; i++)
                    {
                        if (result.GetLength(0) > underlinePos)
                        {
                            if (result.GetLength(1) > i)
                            {
                                result[underlinePos, i] = true;
                            }
                        }
                    }
                }
            }
        }