Exemplo n.º 1
0
        /// <summary>
        /// Returns a Style Value of the Page.
        /// </summary>
        /// <param name="SetName"></param>
        /// <param name="Page"></param>
        /// /// <param name="StyleProperty"></param>
        /// <returns></returns>
        public static string GetStyleValue(string SetName, string Page, string StyleProperty)
        {
            List <DisplayPageSet> l   = ClsDisplayControler.DisplayPageSets();
            DisplayPageSet        dps = (from x in l where x.PageSetName == SetName select x).FirstOrDefault();

            List <DisplayPage> pl = ClsDisplayControler.DisplayPagesForPageSet(dps.ID);
            DisplayPage        dp = (from x in pl where x.PageName == Page select x).FirstOrDefault();

            string ret = "";

            using (ClsStyleGenerator sg = new ClsStyleGenerator())
            {
                sg.ParseStyleString(dp.Style);
                ret = sg.GetStyle(StyleProperty);
            }

            return(ret);
        }
Exemplo n.º 2
0
        //public static void NewDiv(int PageSetID, int PageID)
        //{
        //	List<DisplayPageSet> dpsl = ClsDisplayControler.DisplayPageSets();
        //	DisplayPageSet dps = (from x in dpsl where x.PageSetName == SetName select x).FirstOrDefault();

        //	List<DisplayPage> dpl = ClsDisplayControler.DisplayPagesForPageSet(dps.ID);
        //	DisplayPage dp = (from x in dpl where x.PageName == Page select x).FirstOrDefault();

        //	NewDiv(PageSetID, PageID);
        //}

        public static void NewDiv(
            long SetID,
            long PageID,
            string varText    = "S00",
            string varPicture = "B00",
            string varTable   = "T00",
            string Style      = "",
            string innerText  = "",
            long Speed        = 0,
            string TableStyle = "")
        {
            // zIndex berechnen
            long nextno = 0;

            if (ClsDisplayControler.DisplayObjectsForPage(PageID).Count > 0)
            {
                long max = (from x in ClsDisplayControler.DisplayObjectsForPage(PageID) select x.Zindex).Max();
                nextno = max + 1;
            }

            // pos berechnen
            string left = "10vw";
            string top  = "10vh";

            if (Style != "")
            {
                using (ClsStyleGenerator sg = new ClsStyleGenerator())
                {
                    sg.ParseStyleStringJson(Style);
                    top  = sg.GetStyle("top");
                    left = sg.GetStyle("left");
                }
            }

            List <DisplayObject> ol = ClsDisplayControler.DisplayObjectsForPage(PageID);

            if (ol.Count > 0)
            {
                for (int i = 0; i < ol.Count; i++)
                {
                    using (ClsStyleGenerator sg = new ClsStyleGenerator())
                    {
                        sg.ParseStyleStringJson(ol[i].style);
                        string t = sg.GetStyle("top");
                        string l = sg.GetStyle("left");
                        if (t == top && l == left)
                        {
                            decimal to = Convert.ToDecimal(top.Substring(0, top.Length - 2), CultureInfo.InvariantCulture);
                            decimal le = Convert.ToDecimal(left.Substring(0, left.Length - 2), CultureInfo.InvariantCulture);
                            top  = (to + 1).ToString(CultureInfo.InvariantCulture) + "vh";
                            left = (le + 1).ToString(CultureInfo.InvariantCulture) + "vw";
                        }
                    }
                }
            }

            DisplayObject o = new DisplayObject();

            o.PageSetNo = SetID;
            o.PageNo    = PageID;
            if (innerText == "")
            {
                o.innerText = "Box " + nextno;
            }
            else
            {
                o.innerText = innerText;
            }
            o.textid     = varText;
            o.bgid       = varPicture;
            o.tableid    = varTable;
            o.Zindex     = nextno;
            o.Speed      = Speed;
            o.TableStyle = TableStyle;

            string s = "";

            using (ClsStyleGenerator sg = new ClsStyleGenerator())
            {
                sg.SetStyle("position", "absolute");
                sg.SetStyle("top", top);
                sg.SetStyle("left", left);
                sg.SetStyle("height", "10vh");
                sg.SetStyle("width", "10vw");
                sg.SetStyle("display", "flex");
                sg.SetStyle("justify-content", "center");
                sg.SetStyle("align-items", "center");
                sg.SetStyle("background-color", "#56884e");
                sg.SetStyle("z-index", nextno.ToString());
                sg.SetStyle("visibility", "visible");
                sg.SetStyle("border-color", "#000000");
                sg.SetStyle("border-style", "solid");
                sg.SetStyle("border-width", "1px");
                sg.SetStyle("border-radius", "0px");
                sg.SetStyle("color", "black");
                sg.SetStyle("font-family", "Arial");
                sg.SetStyle("font-size", "5vh");
                sg.SetStyle("font-style", "normal");
                sg.SetStyle("font-weight", "normal");
                sg.SetStyle("white-space", "nowrap");
                sg.SetStyle("background-position", "center");
                sg.SetStyle("background-repeat", "no-repeat");
                sg.SetStyle("background-size", "contain");
                sg.SetStyle("background-position", "center");
                sg.SetStyle("background-repeat", "no-repeat");
                sg.SetStyle("box-sizing", "border-box");

                s = sg.GetStyleStringJson();
            }

            if (Style == "")
            {
                o.style = s;
            }
            else
            {
                using (ClsStyleGenerator sg = new ClsStyleGenerator())
                {
                    sg.ParseStyleStringJson(Style);
                    sg.SetStyle("top", top);
                    sg.SetStyle("left", left);
                    sg.SetStyle("z-index", nextno.ToString());
                    o.style = sg.GetStyleStringJson();
                }
            }

            ClsDisplayControler.AddDisplayObject(o);

            SetDivInfo(o.ID);
        }