Example #1
0
        /// <summary>
        /// Fit the window to specified monitor
        /// </summary>
        /// <param name="monitorIndex"></param>
        /// <returns></returns>
        public bool FitToMonitor(int monitorIndex)
        {
            float dx, dy, dw, dh;

            if (LibUniWinC.GetMonitorRectangle(monitorIndex, out dx, out dy, out dw, out dh))
            {
                // 最大化状態なら一度戻す
                if (LibUniWinC.IsMaximized())
                {
                    LibUniWinC.SetMaximized(false);
                }

                // 指定モニタ中央座標
                float cx = dx + (dw / 2);
                float cy = dy + (dh / 2);

                // ウィンドウ中央を指定モニタ中央に移動
                float ww, wh;
                LibUniWinC.GetSize(out ww, out wh);
                float wx = cx - (ww / 2);
                float wy = cy - (wh / 2);
                LibUniWinC.SetPosition(wx, wy);

                // 最大化
                LibUniWinC.SetMaximized(true);

                //Debug.Log(String.Format("Monitor {4} : {0},{1} - {2},{3}", dx, dy, dw, dh, monitorIndex));
                return(true);
            }
            return(false);
        }
Example #2
0
    /// <summary>
    /// Fit the window to specified monitor
    /// </summary>
    /// <param name="monitorIndex"></param>
    /// <returns></returns>
    public bool FitToMonitor(int monitorIndex)
    {
        float x, y, width, height;

        if (LibUniWinC.GetMonitorRectangle(monitorIndex, out x, out y, out width, out height))
        {
            LibUniWinC.SetPosition(x, y);
            LibUniWinC.SetSize(width, height);
            return(true);
        }
        return(false);
    }
Example #3
0
 /// <summary>
 /// Set the window position.
 /// </summary>
 /// <param name="position">Position.</param>
 public void SetWindowPosition(Vector2 position)
 {
     LibUniWinC.SetPosition(position.x, position.y);
 }