/// <summary>
 /// Communicates the selection to the user as detail-region-message and audio output.
 /// </summary>
 /// <param name="e">The e.</param>
 /// <param name="immediately">if set to <c>true</c> immediately.</param>
 public void CommunicateSelection(List <OoShapeObserver> e, bool immediately = true)
 {
     if (e.Count > 1)
     {
         String audioText = LL.GetTrans("tangram.lector.oo_observer.selected_elements", e.Count);
         if (immediately)
         {
             audioRenderer.PlaySoundImmediately(audioText);
         }
         else
         {
             audioRenderer.PlaySound(audioText);
         }
         windowManager.SetDetailRegionContent(audioText);
     }
     else if (e.Count == 1)
     {
         String elementText = OoElementSpeaker.GetElementAudioText(e[0]);
         String audioText   = LL.GetTrans("tangram.lector.oo_observer.selected", elementText);
         if (immediately)
         {
             audioRenderer.PlaySoundImmediately(audioText);
         }
         else
         {
             audioRenderer.PlaySound(audioText);
         }
         windowManager.SetDetailRegionContent(elementText);
     }
 }
        void shapeManipulatorFunctionProxy_SelectedShapeChanged(object sender, SelectedShapeChangedEventArgs e)
        {
            if (sender != null && sender is OpenOfficeDrawShapeManipulator)
            {
                StopFocusHighlightModes();
                try
                {
                    if (e.Reason != ChangeReson.Property)
                    {
                        ((OpenOfficeDrawShapeManipulator)sender).SayLastSelectedShape(false);
                    }

                    if (((OpenOfficeDrawShapeManipulator)sender).IsShapeSelected)
                    {
                        OoShapeObserver _shape = ((OpenOfficeDrawShapeManipulator)sender).LastSelectedShape;
                        if (_shape != null)
                        {
                            if (e.Reason != ChangeReson.Property) // shape changed
                            {
                                BrailleDomFocusRenderer.CurrentPolyPoint = null;
                                focusHighlightPaused = false;
                            }
                            InitBrailleDomFocusHighlightMode(null, e.Reason != ChangeReson.Property);

                            if (e.Reason != ChangeReson.Property && ((OpenOfficeDrawShapeManipulator)sender).LastSelectedShapePolygonPoints == null) // in other cases the detailed infos for the  point is sent by the manipulator itself
                            {
                                WindowManager.Instance.SetDetailRegionContent(OoElementSpeaker.GetElementAudioText(_shape));
                            }

                            if (WindowManager.Instance.FocusMode == FollowFocusModes.FOLLOW_BRAILLE_FOCUS)
                            {
                                jumpToDomFocus();
                            }

                            Logger.Instance.Log(LogPriority.MIDDLE, this, "[DRAW INTERACTION] new DOM focus " + _shape.Name + " " + _shape.Text);
                        }
                    }
                    else
                    {
                        WindowManager.Instance.SetDetailRegionContent(LL.GetTrans("tangram.lector.oo_observer.selected_no"));
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.Instance.Log(LogPriority.OFTEN, this, "[DRAW INTERACTION] new DOM focus error --> shape is null", ex);
                }
            }
        }
        void shape_ObserverDisposing(object sender, EventArgs e)
        {
            if (sender == LastSelectedShape)
            {
                try
                {
                    string name = OoElementSpeaker.GetElementAudioText(LastSelectedShape);
                    play(LL.GetTrans("tangram.oomanipulation.shape.deleted", name), true);
                }
                catch (ObjectDisposedException)
                {
                    play(LL.GetTrans("tangram.oomanipulation.shape.deleted", LL.GetTrans("tangram.oomanipulation.shape")), true);
                }
                catch (Exception ex) { }

                resetSelectedShapeProperties(true);
                LastSelectedShape = null;
            }
        }
        /// <summary>
        /// Groups the current selected obejct into a group
        /// </summary>
        /// <returns><c>true</c> if the shape was added to a group successfully; otherwise, <c>false</c>.</returns>
        private bool grouping()
        {
            if (IsShapeSelected && LastSelectedShape != null)
            {
                OoAccessibleDocWnd  draw = null;
                OoDrawPagesObserver doc  = null;
                OoDrawPageObserver  page = null;
                page = LastSelectedShape.Page;
                if (page != null)
                {
                    doc = page.PagesObserver;
                    if (doc != null)
                    {
                        draw = doc.DocWnd;
                        if (draw != null && draw.DrawPageSupplier != null)
                        {
                            var undoManager = draw.DrawPageSupplier;

                            if (_group == null) // start grouping
                            {
                                _group = createGroup();
                            }

                            if (_group != null && _group.IsGroup)
                            {
                                // set Title bar

                                // size & position
                                var size = LastSelectedShape.Size;
                                var pos  = LastSelectedShape.Position;

                                // TODO: check if this is a group
                                if (OoDrawUtils.AddShapeToGroupUndoable(_group.DomShape, LastSelectedShape.DomShape, undoManager, "Add shape to group"))
                                {
                                    LastSelectedShape.Size     = size;
                                    LastSelectedShape.Position = pos;

                                    var b = _group.Bounds;
                                    _group.Position = b.Location;

                                    play(LL.GetTrans("tangram.oomanipulation.group.added", OoElementSpeaker.GetElementAudioText(LastSelectedShape)), false);

                                    LastSelectedShape = _group;
                                    // sayLastSelectedShape(false);
                                    return(true);
                                }
                                return(false);
                            }
                        }
                    }
                }
            }
            return(false);
        }