/// <summary>
 /// Calculates the zoom factor that translates the current document zoom level to a zoom level on a pin matrix display, 
 /// so that objects on the document would equate in size like they should. 
 /// </summary>
 /// <param name="wnd">The Document window of the document.</param>
 /// <returns>the zoom factor so document objects would equate in size how they should.</returns>
 public static float GetPrintZoomLevel(tud.mci.tangram.Accessibility.OoAccessibleDocWnd wnd = null)
 {
     if (wnd == null && OoConnector.Instance != null && OoConnector.Instance.Observer != null)
     {
         wnd = OoConnector.Instance.Observer.GetActiveDocument();
     }
     if (wnd != null)
     {
         var pagesObs = wnd.DrawPagesObs;
         if (pagesObs != null)
         {
             var zoomLevel = (float)pagesObs.ZoomValue / 100f;
             return _PRINT_ZOOM_FACTOR / zoomLevel;
         }
     }
     return _PRINT_ZOOM_FACTOR;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PolygonPointSelectedEventArgs"/> class.
 /// </summary>
 /// <param name="ppobs">polygon points observer.</param>
 /// <param name="point">current selected point.</param>
 public PolygonPointSelectedEventArgs(OoPolygonPointsObserver ppobs, tud.mci.tangram.util.PolyPointDescriptor point)
 {
     PolygonPoints = ppobs;
     Point = point;
 }
        private void addNavList(tud.mci.tangram.models.dialogs.ScrollableContainer sc)
        {

            #region Einführung

            introduction = CreateFixedLabel("Einführung", 0, 0, 0, 0, 0, this, "introduction_LABEL");
            SetProperty(introduction, "HelpURL", "7");
            SetProperty(introduction, "HelpText", "I");
            //SetProperty(introduction, "Tag", s.ToString()); //TODO: add the tag for the introduction
            SetProperty(introduction, "FontHeight", h1_fontHieght);
            SetProperty(introduction, "FontWeight", h1_fontWeight);
            sc.AddElementToTheEndAndAdoptTheSize(introduction as XControl, "introduction_LABEL", h1_leftMargin, 7);
         
            #region Einführung underline
            XControl line1 = CreateHorizontalFixedLine("", 0, 0, 0, 2, 0, "introduction_LABEL_line");
            //TODO: how to set the color
            line1 = sc.AddElementToTheEndAndAdoptTheSize(
                line1,
                "introduction_LABEL_line", 5, 2, sc.Width-5, 2);
            #endregion

            #endregion

            var criterionLable = CreateFixedLabel("Kriterien", 0, 0, 0, 0, 0, this, "criterion_LABEL");
            
            ////SetProperty(criterionLable, "Enable", false);
            ////SetProperty(introduction, "Tag", s.ToString()); //TODO: add the tag for the introduction
            SetProperty(criterionLable, "FontHeight", h1_fontHieght);
            SetProperty(criterionLable, "FontWeight", h1_fontWeight);
            sc.AddElementToTheEndAndAdoptTheSize(criterionLable as XControl, "criterion_LABEL", h1_leftMargin, 7);


            int c = 0;
            foreach (tud.mci.tangram.qsdialog.models.Category ca in categories)
            {

                var catLable = CreateFixedLabel(++c + ". " + ca.Name, 0, 0, 0, 0, 0, this, ca.Id);
                //SetProperty(introduction, "Tag", s.ToString()); //TODO: add the tag for the introduction
                SetProperty(catLable, "FontHeight", h2_fontHieght);
                SetProperty(catLable, "FontWeight", h2_fontWeight);
                SetProperty(catLable, "HelpText", ca.Id);
                SetProperty(catLable, "MultiLine", true);
                //SetProperty(catLable, "HelpURL", 6);
                Object t = null;
                if (catLable is XControl) 
                { 
                t = sc.AddElementToTheEndAndAdoptTheSize(catLable as XControl, ca.Id, h2_leftMargin, 7);
                }
                criteriaLabelMap.Add(ca.Id, t);
                //Debug.GetAllProperties(catLable);

                //insertRoadmapItem(1, false, ca.Name, 1);
                //List<Criterion> criteria = ca.Criteria;
                //categorie adden
                criteriaMap.Add(ca.Id, ca);
                int i = 0;
                foreach (Criterion cr in ca.Criteria)
                {
                    
                    criteriaMap.Add(cr.Id, cr);

                    int s = 3;
                    switch (cr.Rec.Type)
                    {

                        case tud.mci.tangram.qsdialog.models.CriterionType.all:
                            s = 1;
                            break;
                        case tud.mci.tangram.qsdialog.models.CriterionType.one:
                            s = 2;
                            break;
                        case tud.mci.tangram.qsdialog.models.CriterionType.count:
                            s = 3;
                            break;
                        case tud.mci.tangram.qsdialog.models.CriterionType.rating:
                            s = 3;
                            break;
                        default:
                            s = 0;
                            break;
                    }


                    var tLabel = CreateFixedLabel(c+"."+ ++i + ". " + cr.Name, 0, 0, 0, 0, 0, this, cr.Id);
                    SetProperty(tLabel, "HelpURL", s.ToString());
                    SetProperty(tLabel, "HelpText", cr.Id);
                    SetProperty(tLabel, "MultiLine", true);
                    Object l = null;

                    if (tLabel is XControl)
                    {
                        //sc.addElementAndAdoptTheSize(tLabel as XControl, cr.Id, 5, 20 + (i++ * 20));
                        l = sc.AddElementToTheEndAndAdoptTheSize(tLabel as XControl, cr.Id, h3_leftMargin, 5);
                    
                    }

                    criteriaLabelMap.Add(cr.Id, l);

                    //var t = InsertFixedLabel(cr.Name, 10, 20 + (i++ * 10), 100, 10, 0, this, cr.Id);
                    //SetProperty(t, "HelpURL", s.ToString());

                    //SetProperty(t, "HelpURL", Convert.ToString(index++));
                    //util.Debug.GetAllProperties(t);


                }
            }

            #region Auswertung

            #region Auswertung underline
            XControl line2 = CreateHorizontalFixedLine("", 0, 0, 0, 2, 0, "eval_LABEL_line");
            //TODO: how to set the color

            line2 = sc.AddElementToTheEndAndAdoptTheSize(
                line2,
                "eval_LABEL_line", 5, 10, sc.Width - 5, 2);
            #endregion

            var eval = CreateFixedLabel("Auswertung", 0, 0, 0, 0, 0, this, "eval_LABEL");
            //SetProperty(introduction, "Tag", s.ToString()); //TODO: add the tag for the introduction
            SetProperty(eval, "FontHeight", h1_fontHieght);
            SetProperty(eval, "FontWeight", h1_fontWeight);
            sc.AddElementToTheEndAndAdoptTheSize(eval as XControl, "eval_LABEL", h1_leftMargin, 7, sc.Width - h1_leftMargin, 40);


            

            #endregion


        }
        /// <summary>
        /// Sets the background image bitmap.
        /// </summary>
        /// <param name="bitmap">The bitmap.</param>
        /// <param name="mode">The fill mode <see cref="FillBitmapMode"/>.</param>
        /// <param name="Name">The name of the Fill Bitmap.</param>
        /// <returns><c>true</c> if the background image could been set, otherwise <c>false</c></returns>
        internal bool SetBackgroundBitmap(XBitmap bitmap, tud.mci.tangram.util.BitmapMode mode, String Name = "")
        {
            try
            {
                int count = this.ChildCount;
                if (count > 0) // group object
                {
                    var children = GetChilderen();
                    for (int i = 0; i < children.Count; i++)
                    {
                        OoShapeObserver child = children.ElementAt(i);

                        if (child != null)
                        {
                            child.SetBackgroundBitmap(bitmap, mode, Name);
                        }
                    }
                }

                if (bitmap != null)
                {
                    SetProperty("FillBitmap", bitmap);
                    FillBitmapMode = mode;
                    setStringProperty("FillBitmapName", Name);
                }
                return true;
            }
            catch (System.Exception ex)
            {
                Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] Can't set background image: " + ex);
            }
            return false;
        }
 /// <summary>
 /// Sets the background image bitmap.
 /// </summary>
 /// <param name="imagePath">The local path to the bitmap.</param>
 /// <param name="mode">The fill mode <see cref="FillBitmapMode"/>.</param>
 /// <param name="Name">The name of the Fill Bitmap.</param>
 /// <returns>
 /// 	<c>true</c> if the background image could been set, otherwise <c>false</c>
 /// </returns>
 public bool SetBackgroundBitmap(String imagePath, tud.mci.tangram.util.BitmapMode mode, String Name = "")
 {
     XBitmap bitmap = null;
     bitmap = OoUtils.GetGraphicFromUrl(imagePath) as XBitmap;
     return SetBackgroundBitmap(bitmap, mode, Name);
 }
 /// <summary>
 /// Gets a LineDash defines a non-continuous line.
 /// </summary>
 /// <param name="dashstyle">This sets the style of this LineDash</param>
 /// <param name="dots">This is the number of dots in this LineDash</param>
 /// <param name="dotLen">This is the length of a dot</param>
 /// <param name="dashes">This is the number of dashes</param>
 /// <param name="dashLen">This is the length of a single dash</param>
 /// <param name="distance">This is the distance between the dots</param>
 /// <returns>true and false</returns>
 public bool GetLineDash(out tud.mci.tangram.util.DashStyle dashstyle, out  short dots, out  int dotLen, out  short dashes, out int dashLen, out int distance)
 {
     dashstyle = tud.mci.tangram.util.DashStyle.RECT;
     dots = dashes = 0;
     dotLen = dashLen = distance = 0;
     var ld = GetProperty("LineDash");
     if (ld != null && ld is LineDash)
     {
         LineDash linedash = ((LineDash)ld);
         dashstyle = (tud.mci.tangram.util.DashStyle)((int)linedash.Style);
         dots = linedash.Dots;
         dotLen = linedash.DotLen;
         dashes = linedash.Dashes;
         dashLen = linedash.DashLen;
         distance = linedash.Distance;
         return true;
     }
     return false;
 }
        /// <summary>
        /// A LineDash defines a non-continuous line.
        /// </summary>
        /// <param name="dashstyle">This sets the style of this LineDash</param>
        /// <param name="dots">This is the number of dots in this LineDash</param>
        /// <param name="dotLen">This is the length of a dot</param>
        /// <param name="dashes">This is the number of dashes</param>
        /// <param name="dashLen">This is the length of a single dash</param>
        /// <param name="distance">This is the distance between the dots</param>
        public void SetLineDash(tud.mci.tangram.util.DashStyle dashstyle, short dots, int dotLen, short dashes, int dashLen, int distance)
        {
            try
            {
                LineDash dash = new LineDash((unoidl.com.sun.star.drawing.DashStyle)((int)dashstyle), dots, dotLen, dashes, dashLen, distance);

                int count = this.ChildCount;
                if (count > 0) // group object
                {
                    var children = GetChilderen();
                    for (int i = 0; i < children.Count; i++)
                    {
                        OoShapeObserver child = children.ElementAt(i);

                        if (child != null)
                        {
                            child.SetProperty("LineDash", dash);
                            child.SetLineDash(dashstyle, dots, dotLen, dashes, dashLen, distance);
                        }
                    }
                }
                SetProperty("LineDash", dash);
            }
            catch (System.Exception ex)
            {
                Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] Can't set line dash: " + ex);
            }
        }
        private static void resetScreenObserver(tud.mci.tangram.TangramLector.WindowManager wm)
        {

            if (wm != null)
            {
                if (wm.ScreenObserver != null) wm.ScreenObserver.ObserveScreen();
                wm.SetTopRegionContent("");
            }
        }
        private void handleAccessibleEvent(OoAccessibleDocWnd doc, tud.mci.tangram.Accessibility.AccessibleEventId id, AccessibleEventObject aEvent)
        {
            System.Diagnostics.Debug.WriteLine("Accessible event from DrawDocWnd :'" + doc.Title + "' ID: " + id);

            switch (id)
            {
                //case tud.mci.tangram.Accessibility.AccessibleEventId.NONE:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.ACTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.ACTIVE_DESCENDANT_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.ACTIVE_DESCENDANT_CHANGED_NOFOCUS:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.BOUNDRECT_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.CARET_CHANGED:
                //    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.CHILD:
                    //handleAccessibleChildEvent(doc, aEvent.Source, aEvent.NewValue, aEvent.OldValue);
                    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.COLUMN_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.CONTENT_FLOWS_FROM_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.CONTENT_FLOWS_TO_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.CONTROLLED_BY_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.CONTROLLER_FOR_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.DESCRIPTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.HYPERTEXT_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.INVALIDATE_ALL_CHILDREN:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.LABEL_FOR_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.LABELED_BY_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.LISTBOX_ENTRY_COLLAPSED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.LISTBOX_ENTRY_EXPANDED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.MEMBER_OF_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.NAME_CHANGED:
                //    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.PAGE_CHANGED:
                    fireDrawWindowActivatedEvent(doc);
                    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.SECTION_CHANGED:
                //    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.SELECTION_CHANGED:
                    selectionChanged(doc, aEvent);
                    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.SELECTION_CHANGED_ADD:
                    selectionChanged(doc, aEvent);
                    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.SELECTION_CHANGED_REMOVE:
                    selectionChanged(doc, aEvent);
                    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.SELECTION_CHANGED_WITHIN:
                    selectionChanged(doc, aEvent);
                    break;
                case tud.mci.tangram.Accessibility.AccessibleEventId.STATE_CHANGED:
                    stateChanged(doc, aEvent);
                    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.SUB_WINDOW_OF_RELATION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_CAPTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_MODEL_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_ROW_HEADER_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TABLE_SUMMARY_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TEXT_ATTRIBUTE_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TEXT_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.TEXT_SELECTION_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.VALUE_CHANGED:
                //    break;
                //case tud.mci.tangram.Accessibility.AccessibleEventId.VISIBLE_DATA_CHANGED:
                //    break;
                default:
                    break;
            }
        }