/// <summary> /// Moves to a child element. /// </summary> /// <param name="shape">The parent shape to get the child of.</param> /// <param name="index">The index of the child to get (infinite loop by modulo child count).</param> /// <returns> /// The child shape on the screen if possible otherwise the child in the DOM if possible otherwise <c>null</c> /// </returns> public static OoShapeObserver MoveToChild(OoShapeObserver shape, ref int index) { if (shape != null && shape.IsValid()) { // move thought the Accessible tree because this elements should be visible on the screen and the tree navigation is faster // TODO remove false to use search in accessibility tree again. Currently accessing the page AccessibleShape element during search crashes openoffice! if (false && shape.AccComponent != null && shape.AccComponent.IsValid()) { OoAccComponent comp = shape.AccComponent; while (true) { OoAccComponent child = moveToChildComponent(comp, ref index); if (child != null && child != comp) { if (acceptAsUsableShape(child)) { return(getObserverForAccessible(child, shape.Page)); } else { child = moveToChildComponent(child, ref index); } } break; } } else // go through the dom tree { return(moveToChildShape(shape, ref index)); } } return(null); }
/// <summary> /// Sets the current bounding box by shape. /// </summary> /// <param name="currentSelectedShape">The current selected shape.</param> public void SetCurrentBoundingBoxByShape(OoShapeObserver currentSelectedShape) { if (currentSelectedShape != null && currentSelectedShape.IsValid(false)) { CurrentBoundingBox = currentSelectedShape.GetAbsoluteScreenBoundsByDom(); } else { CurrentBoundingBox = new Rectangle(-1, -1, 0, 0); } }
/// <summary> /// Sets the Braille focus to that element which currently has the Mouse (GUI) focus. /// </summary> private void chooseElementWithGuiFocus() { if (OoConnection != null) { OoShapeObserver shape = OoConnection.GetCurrentDrawSelection() as OoShapeObserver; if (shape != null && shape.IsValid()) { Logger.Instance.Log(LogPriority.DEBUG, this, "[NOTICE]\t[INTERACTION]\t[NAVIGATION]\t" + "synchronize with GUI focus"); AudioRenderer.Instance.Abort(); // stop current audio to return the shape change LastSelectedShape = shape; AudioRenderer.Instance.PlaySoundImmediately(LL.GetTrans("tangram.oomanipulation.set_braille_focus", LastSelectedShape.Name)); return; } } playError(); }
/// <summary> /// Moves to the next element. /// </summary> /// <param name="shape">The shape to get the next sibling.</param> /// <returns> /// The next shape on the screen if possible otherwise the next in the DOM if possible otherwise <c>null</c> /// </returns> public static OoShapeObserver MoveToNext(OoShapeObserver shape) { if (shape != null && shape.IsValid()) { // move thought the Accessible tree because this elements should be visible on the screen and the tree navigation is faster // TODO remove false to use search in accessibility tree again. Currently accessing the page AccessibleShape element during search crashes openoffice! if (false && shape.AccComponent != null && shape.AccComponent.IsValid()) { OoAccComponent comp = shape.AccComponent; while (true) { OoAccComponent next = moveToNextComponent(comp); if (next != null && next != comp && next.IsValid()) { if (acceptAsUsableShape(next)) { OoShapeObserver obs = getObserverForAccessible(next, shape.Page); if (obs != null) { return(obs); } else { break; } } else { comp = next; continue; } } break; } } // go through the dom tree { return(moveToNextShape(shape)); } } return(null); }
/// <summary> /// Sets the shape or point to blink and starts the blinking frame around the last selected shape. /// </summary> internal void InitBrailleDomFocusHighlightMode(OoShapeObserver _shape = null, bool visualize = true) { if (shapeManipulatorFunctionProxy != null) { if (_shape == null) { _shape = shapeManipulatorFunctionProxy.LastSelectedShape; } if (_shape != null && _shape.IsValid(false)) { StartFocusHighlightModes(); // inform sighted user if (visualize) { byte[] pngData; if (_shape.GetShapeAsPng(out pngData) > 0) { DesktopOverlayWindow.Instance.initBlinking( ref pngData, // png as byte array _shape.GetAbsoluteScreenBoundsByDom(), // bounding box 0.75, // opacity (0.0 (transparent) .. 1.0) 1500, // The total blinking time in ms until blinking stops and the window is hidden again //The pattern of milliseconds to be on|off|..., // e.g. [250,150,250,150,250,150,800,1000] for three short flashes (on for 250ms) // with gaps (of 150ms) and one long on time (800ms) followed by a pause(1s). // The pattern is repeated until the total blinking time is over. // If less than 2 values are given, the default of [500, 500] is used! new int[8] { 250, 150, 250, 150, 250, 150, 500, 150 } ); } } } } }
/// <summary> /// Gets the audio text for the given element. /// </summary> /// <param name="element">The element to get the text of.</param> /// <param name="additionalText">An additional text, that is put behind the element properties and befor the label (if available).</param> /// <returns>A string that should describe the element in the following form: [ROLE] [NAME] [TITLE] (addintionalText) [TEXT]</returns> public static String GetElementAudioText(OoShapeObserver element, string additionalText = "") { String result = String.Empty; if (element != null && element.IsValid(false)) { try { bool isText = element.IsText; #region default element handling if (isText) { result = LL.GetTrans("tangram.oomanipulation.element_speaker.text_element", element.Text, element.Title); } else { //result += element.AccComponent.Role + " " + element.Name; result += element.Name; if (!String.IsNullOrWhiteSpace(element.Title)) { result += (result.EndsWith(" ") ? "" : " ") + element.Title; } } if (!String.IsNullOrEmpty(additionalText)) { result += (result.EndsWith(" ") ? "" : " ") + additionalText; } else { result = result.Trim(); } #endregion #region object text if (!isText && !String.IsNullOrWhiteSpace(element.Text)) { result += " - " + LL.GetTrans("tangram.oomanipulation.element_speaker.text_value", element.Text); } #endregion #region Group if (element.IsGroup || element.HasChildren) { int cCount = element.ChildCount; result += (result.EndsWith(" ") ? "" : " ") + "- " + LL.GetTrans("tangram.oomanipulation.element_speaker.has_" + (cCount == 1 ? "one_child" : "children"), cCount.ToString()); } #endregion #region Group Member if (element.IsGroupMember && element.Parent != null) { result += " - " + LL.GetTrans("tangram.oomanipulation.element_speaker.child_of", element.Parent.Name); } #endregion } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, "OoElementSpeaker", "[ERROR] Can't play element: " + ex); } } return(String.IsNullOrWhiteSpace(result) ? LL.GetTrans("tangram.oomanipulation.element_speaker.default") : result); }