Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static string ToWindowFeatureClientString(this IWindowFeature windowFeature, QuatationMarkType quatationMarkType)
        {
            StringBuilder strB      = new StringBuilder(256);
            string        strWidth  = GetStringValue(windowFeature.Width, windowFeature.WidthScript, null, WindowFeatureDefaultWidth.ToString());
            string        strHeight = GetStringValue(windowFeature.Height, windowFeature.HeightScript, null, WindowFeatureDefaultHeigth.ToString());

            strB.Append(GetLengthString("width", windowFeature.Width, strWidth, "=", ",", quatationMarkType, string.Empty));
            strB.Append(GetLengthString("height", windowFeature.Height, strHeight, "=", ",", quatationMarkType, string.Empty));

            string leftScript = windowFeature.LeftScript;

            if (windowFeature.Left == null && string.IsNullOrEmpty(windowFeature.LeftScript) && windowFeature.Center.HasValue && windowFeature.Center.Value)
            {
                leftScript = string.Format("(window.screen.width - {0}) / 2",
                                           strWidth);
            }

            string topScript = windowFeature.TopScript;

            if (windowFeature.Top == null && string.IsNullOrEmpty(windowFeature.TopScript) && windowFeature.Center.HasValue && windowFeature.Center.Value)
            {
                topScript = string.Format("(window.screen.height - {0}) / 2",
                                          strHeight);
            }

            strB.Append(GetLengthString("left", windowFeature.Left, leftScript, "=", ",", quatationMarkType, string.Empty));
            strB.Append(GetLengthString("top", windowFeature.Top, topScript, "=", ",", quatationMarkType, string.Empty));

            if (windowFeature.Resizable != null)
            {
                strB.AppendFormat("resizable={0},", BoolToStr(windowFeature.Resizable.Value));
            }

            if (windowFeature.ShowScrollBars != null)
            {
                strB.AppendFormat("scrollbars={0},", BoolToStr(windowFeature.ShowScrollBars.Value));
            }

            if (windowFeature.ShowStatusBar != null)
            {
                strB.AppendFormat("status={0},", BoolToStr(windowFeature.ShowStatusBar.Value));
            }

            if (windowFeature.ShowToolBar != null)
            {
                strB.AppendFormat("toolbar={0},", BoolToStr(windowFeature.ShowToolBar.Value));
            }

            if (windowFeature.ShowAddressBar != null)
            {
                strB.AppendFormat("location={0},", BoolToStr(windowFeature.ShowAddressBar.Value));
            }

            if (strB.Length > 0)
            {
                strB.Remove(strB.Length - 1, 1);
            }

            return(strB.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 调整窗口大小和位置
        /// </summary>
        /// <param name="windowFeature"></param>
        public static void AdjustWindow(IWindowFeature windowFeature)
        {
            RequiredScript(typeof(DeluxeScript));

            string clintObject = WindowFeatureHelper.GetClientObject(windowFeature);
            string script      = string.Format("$HGRootNS.WindowFeatureFunction.adjustWindow({0});", clintObject);

            Page page = GetCurrentPage();

            DeluxeClientScriptManager.RegisterStartupScript(page, script);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取调整窗口大小和位置脚本
        /// </summary>
        /// <param name="windowFeature"></param>
        /// <param name="addScriptTags"></param>
        /// <returns></returns>
        public static string ToAdjustWindowScriptBlock(this IWindowFeature windowFeature, bool addScriptTags)
        {
            string requireScript = WebUtility.GetRequiredScriptBlock(typeof(DeluxeScript));

            string clintObject = WindowFeatureHelper.GetClientObject(windowFeature);
            //string callScript = string.Format("$HGRootNS.WindowFeatureFunction.adjustWindow({0});", clintObject);
            string callScript = string.Format("$HGRootNS.WindowFeatureFunction.registerAdjustWindow({0});", clintObject);

            string script = string.Format("{0}\n{1}", requireScript, callScript);

            if (addScriptTags)
            {
                script = DeluxeClientScriptManager.AddScriptTags(script);
            }

            return(script);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="windowFeature"></param>
        /// <param name="quatationMarkType"></param>
        /// <returns></returns>
        public static string ToDialogFeatureClientString(this IWindowFeature windowFeature, QuatationMarkType quatationMarkType)
        {
            StringBuilder strB = new StringBuilder(256);

            strB.Append(GetLengthString("dialogWidth", windowFeature.Width, windowFeature.WidthScript, ":", ";", quatationMarkType, "px"));
            strB.Append(GetLengthString("dialogHeight", windowFeature.Height, windowFeature.HeightScript, ":", ";", quatationMarkType, "px"));
            strB.Append(GetLengthString("dialogTop", windowFeature.Top, windowFeature.TopScript, ":", ";", quatationMarkType, "px"));
            strB.Append(GetLengthString("dialogLeft", windowFeature.Left, windowFeature.LeftScript, ":", ";", quatationMarkType, "px"));

            if (windowFeature.Center != null)
            {
                strB.AppendFormat("center:{0};", BoolToStr(windowFeature.Center.Value));
            }

            if (windowFeature.Resizable != null)
            {
                strB.AppendFormat("resizable:{0};", BoolToStr(windowFeature.Resizable.Value));
            }

            if (windowFeature.ShowScrollBars != null)
            {
                strB.AppendFormat("scroll:{0};", BoolToStr(windowFeature.ShowScrollBars.Value));
            }

            if (windowFeature.ShowStatusBar != null)
            {
                strB.AppendFormat("status:{0};", BoolToStr(windowFeature.ShowStatusBar.Value));
            }

            if (strB.Length > 0)
            {
                strB.Remove(strB.Length - 1, 1);
            }

            return(strB.ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowFeature"></param>
 /// <returns></returns>
 public static string ToWindowFeatureClientString(this IWindowFeature windowFeature)
 {
     return(ToWindowFeatureClientString(windowFeature, QuatationMarkType.Single));
 }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowFeature"></param>
 /// <returns></returns>
 public static string GetClientObject(this IWindowFeature windowFeature)
 {
     return(JSONSerializerExecute.Serialize(windowFeature, typeof(IWindowFeature)));
 }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowFeature"></param>
 /// <returns></returns>
 public static string GetWindowFeatureClientString(IWindowFeature windowFeature)
 {
     return(GetWindowFeatureClientString(windowFeature, QuatationMarkType.Single));
 }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="windowFeature"></param>
 /// <returns></returns>
 public static string GetClientObject(IWindowFeature windowFeature)
 {
     return(JsonHelper.Serialize(windowFeature, typeof(IWindowFeature)));
 }