/// <summary>
        /// Get factors for specified locale.
        /// </summary>
        /// <param name="locale">Locale.</param>
        /// <param name="getOnlyPublicFactors">Get only public factors or all from cache.</param>
        /// <returns>Factors for specified locale.</returns>
        protected virtual FactorList GetFactors(ILocale locale, Boolean getOnlyPublicFactors)
        {
            String factorTreeType = getOnlyPublicFactors
                                        ? FactorTreesPermissionType.PublicFactorTrees.ToString()
                                        : FactorTreesPermissionType.AllFactorTrees.ToString();

            FactorList factors = null;

            if (Factors.ContainsKey(locale.ISOCode + "#" + factorTreeType))
            {
                factors = (FactorList)(Factors[locale.ISOCode + "#" + factorTreeType]);
            }
            return(factors);
        }
        private void DrawMonitor(KeyValuePair <Pair <VirtualDesktop, HMONITOR>, ObservableCollection <DesktopWindow> > desktopMonitor, out float ScreenScalingFactorVert, out int mX, out int mY, out IEnumerable <Rectangle> gridGenerator)
        {
            HMONITOR m            = desktopMonitor.Key.Item2;
            int      windowsCount = desktopMonitor.Value.Count();

            User32.MONITORINFOEX info = new User32.MONITORINFOEX();
            info.cbSize = (uint)Marshal.SizeOf(info);
            User32.GetMonitorInfo(m, ref info);

            Gdi32.SafeHDC hdc = Gdi32.CreateDC(info.szDevice);
            int           LogicalScreenHeight  = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.VERTRES);
            int           PhysicalScreenHeight = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.DESKTOPVERTRES);
            int           LogicalScreenWidth   = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.HORZRES);
            int           PhysicalScreenWidth  = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.DESKTOPHORZRES);

            hdc.Close();

            float ScreenScalingFactorHoriz = (float)PhysicalScreenWidth / (float)LogicalScreenWidth;

            ScreenScalingFactorVert = (float)PhysicalScreenHeight / (float)LogicalScreenHeight;
            mX = info.rcWork.X + MarginLeft;
            mY = info.rcWork.Y + MarginTop;
            int mWidth  = info.rcWork.Width - MarginLeft - MarginRight;
            int mHeight = info.rcWork.Height - MarginTop - MarginBottom;

            Layout mCurrentLayout;

            try
            {
                mCurrentLayout = Layouts[desktopMonitor.Key];
            }
            catch
            {
                Layouts.Add(desktopMonitor.Key, Layout.Tall);
                mCurrentLayout = Layouts[desktopMonitor.Key];
            }

            if (!Factors.ContainsKey(desktopMonitor.Key))
            {
                Factors[desktopMonitor.Key] = 0;
            }

            gridGenerator = GridGenerator(mWidth, mHeight, windowsCount, Factors[desktopMonitor.Key], mCurrentLayout, LayoutPadding);
        }