Exemplo n.º 1
0
        protected override void Measure()
        {
            Vector2 size = ActiveStyle.CalcSize(new GUIContent(Text));

            MeasuredWidth  = MeasuredMinWidth = size.x;
            MeasuredHeight = MeasuredMinHeight = size.y;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This component uses it's custom measurement
        /// </summary>
        protected override void Measure()
        {
            if (null != Content) // content exists and height not defined in percentage
            {
                if (null == ActiveStyle.font)
                {
                    throw new TextFieldException(string.Format("{0} [Style:{1}]", ComponentException.FontRequiredToCalculateSize, ActiveStyle.name));
                }

                if (ExpandHeightToContent)
                {
                    //if (null == ExplicitWidth)
                    //{
                    //    throw new Exception("The width should be explicitely set when ExpandHeightToContent set");
                    //}

                    MeasuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH;

                    MeasuredWidth = MeasuredMinWidth = (null == ExplicitWidth) ? DEFAULT_MEASURED_WIDTH : (float)ExplicitWidth;

                    MeasuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT;

                    /**
                     * Calculate HEIGHT ONLY
                     * Do that by using the EMPTY STRING, since width is currently 0
                     * */
                    MeasuredHeight = ActiveStyle.CalcHeight(Content, MeasuredWidth) + (int)GetStyle("paddingTop") + (int)GetStyle("paddingBottom");
                }
                else
                {
                    /**
                     * Calculate HEIGHT ONLY
                     * Do that by using the EMPTY STRING, since width is currently 0
                     * */
                    float contentHeight = ActiveStyle.CalcHeight(new GUIContent("M"), Width) + (int)GetStyle("paddingTop") + (int)GetStyle("paddingBottom");

                    //if (!HasExplicitHeight && !HasPercentHeight)
                    //{
                    //    if (contentHeight > MeasuredHeight)
                    //        MeasuredHeight = contentHeight;
                    //}

                    //MinHeight = contentHeight;

                    MeasuredWidth  = MeasuredMinWidth = DEFAULT_MEASURED_WIDTH; // 50
                    MeasuredHeight = MeasuredMinHeight = contentHeight;
                }

                //Debug.LogWarning("[SimpleTextField] " + this + " -> MeasuredWidth: " + MeasuredWidth + "; MeasuredHeight: " + MeasuredHeight + "; NestLevel: " + NestLevel);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Actual draw logic
        /// </summary>
        virtual protected void Render()
        {
            //if (this is Button)
            //{
            //    //if (((Button)this).Id == "btn")
            //    Debug.Log("* btn: " + RenderingRect);
            //}
            //Debug.Log("* Render: " + RenderingRect);
            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                if (null == ActiveStyle)
                {
                    return; // throw new Exception(string.Format("ActiveStyle is null on component [{0}]", this));
                }
                //Debug.Log("* Render: " + RenderingRect);
                //if (this is Button)
                //{
                //    //if (((Button)this).Id == "btn")
                //        Debug.Log("* btn: " + RenderingRect);
                //}

                if (DragManager.IsDragging)
                {
                    ActiveStyle.Draw(RenderingRect, Content,
                                     false,
                                     false,
                                     false,
                                     false);
                }

                else
                {
                    /**
                     * 20131210
                     * Zna se pojavit sljedeći warning:
                     * "GUIContent is null. Use GUIContent.none.
                     * UnityEngine.GUIStyle:Draw(Rect, GUIContent, Boolean, Boolean, Boolean, Boolean)
                     * eDriven.Gui.Components.DisplayObject:Render() (at c:/PROJECTS/Unity/eDriven/eDriven.Gui/Components/Core/DisplayObject.cs:640)"
                     * (tako da sam umjesto "Content" ubacio "Content ?? GUIContent.none"
                     * */

                    ActiveStyle.Draw(RenderingRect, Content ?? GUIContent.none,
                                     this == MouseEventDispatcher.MouseTarget,
                                     this == MouseEventDispatcher.MouseDownComponent,
                                     false, // this should be overriden in components that have a selected state (Button)
                                     this == FocusManager.Instance.FocusedComponent);
                }
            }
        }
Exemplo n.º 4
0
        protected override void OnLoad(EventArgs onloadEvent)
        {
            base.OnLoad(onloadEvent);
#if EDNConCompDirDNN62
            ModuleInfo moduleInfo = ModuleControl.ModuleContext.Configuration;
#else
            ModuleInfo moduleInfo = DotNetNuke.UI.Containers.Container.GetPortalModuleBase(this).ModuleConfiguration;
#endif

            if (moduleInfo.IsDeleted)
            {
                return;
            }

            UserInfo user = (UserInfo)Context.Items["UserInfo"];

            MetaDefinition meta = MetaDefinition.MetaFromFolder(
                Server.MapPath(moduleInfo.ContainerPath) + "StyleWizard\\",
                true,
                (user != null && (user.IsSuperUser || user.IsInRole(PortalSettings.AdministratorRoleName)))
                );

            if
            (
                meta == null ||
                String.IsNullOrEmpty(moduleInfo.ContainerSrc) ||
                !moduleInfo.ContainerSrc.Contains("/") ||
                String.IsNullOrEmpty(moduleInfo.ContainerPath)
            )
            {
                return;
            }

            string containerFilename = moduleInfo.ContainerSrc.Substring(moduleInfo.ContainerSrc.LastIndexOf('/') + 1),
                   containerTheme    = moduleInfo.ContainerPath.Remove(moduleInfo.ContainerPath.Length - 1);

            if (!containerTheme.Contains("/"))
            {
                return;
            }

            string containerPortalFolderName = containerTheme.Remove(containerTheme.LastIndexOf('/'));

            if (!containerPortalFolderName.Contains("/"))
            {
                return;
            }

            containerPortalFolderName = containerPortalFolderName.Remove(containerPortalFolderName.LastIndexOf('/'));
            containerPortalFolderName = containerPortalFolderName.Substring(containerPortalFolderName.LastIndexOf('/') + 1);

            containerTheme = containerTheme.Substring(containerTheme.LastIndexOf('/') + 1);

            if (containerFilename.Contains("."))
            {
                containerFilename = containerFilename.Remove(containerFilename.IndexOf('.'));
            }

            ActiveStyle activeStyle = meta.GetActiveStyle(PortalSettings.PortalId, containerFilename);

            if (String.IsNullOrEmpty(templateGroup))
            {
                templateGroup = "default";
            }

            containerClass.Text = String.Concat(
                "eds_containers_", containerTheme,
                " eds_templateGroup_", templateGroup,
                " eds_template_", containerFilename,
                (activeStyle.type != "predefined" || activeStyle.id != "default" ? " eds_style_" + activeStyle.type + "_" + activeStyle.id : "")
                );

            string containerDirectoryPath = Server.MapPath(moduleInfo.ContainerPath);

            Control cssPageControl = Page.FindControl("CSS");

            if (cssPageControl == null || Page.Header.FindControl(ID) != null)
            {
                return;
            }

            AdditionalObjectResources themeObjectResources = meta.GetAdditionalObjectResources(
                PortalSettings.PortalId.ToString(),
                containerFilename,
                "eds_skin_" + containerTheme,
                moduleInfo.ContainerPath + meta.assetsClientPath
                );

            foreach (HtmlLink linkControl in themeObjectResources.css)
            {
                if (Page.Header.FindControl(linkControl.ID) == null)
                {
                    cssPageControl.Controls.Add(linkControl);
                }
            }

            if (!File.Exists(containerDirectoryPath + "StyleWizard\\developerMode") && File.Exists(containerDirectoryPath + "container.css"))
            {
                return;
            }

            new ContainerController(
                containerTheme,
                containerPortalFolderName,
                PortalSettings.HomeDirectoryMapPath,
                PortalSettings.HomeDirectory,
                PortalSettings,
                user
                )
            .rebuildCss();

            cssPageControl.Controls.Add(Utility.CreateCssLinkControl(
                                            containerPortalFolderName + "_" + containerTheme + "_containers",
                                            moduleInfo.ContainerPath + "container.css"
                                            ));
        }
        protected override void OnLoad(EventArgs onloadEvent)
        {
            base.OnLoad(onloadEvent);

            ModuleInfo moduleInfo = ModuleControl.ModuleContext.Configuration;

            if (moduleInfo.IsDeleted)
                return;

            string metaPath = Server.MapPath(moduleInfo.ContainerPath) + "StyleWizard\\meta.json",
                metaJson;

            try
            {
                metaJson = File.ReadAllText(metaPath, Encoding.UTF8);
            }
            catch (Exception e)
            {
                if (e is DirectoryNotFoundException || e is FileNotFoundException)
                    return;

                throw new Exception("The container meta file can't be read.", e);
            }

            Meta meta = new Meta();

            try
            {
                meta = JsonConvert.DeserializeObject<Meta>(metaJson);
            }
            catch (Exception e)
            {
                throw new Exception("The container meta file contains invalid JSON.", e);
            }

            string containerFilename = moduleInfo.ContainerSrc.Substring(moduleInfo.ContainerSrc.LastIndexOf('/') + 1),
                containerTheme = moduleInfo.ContainerPath.Remove(moduleInfo.ContainerPath.Length - 1),
                containerPortalId = containerTheme.Remove(containerTheme.LastIndexOf('/'));

            containerPortalId = containerPortalId.Remove(containerPortalId.LastIndexOf('/'));
            containerPortalId = containerPortalId.Substring(containerPortalId.LastIndexOf('/') + 1);

            containerTheme = containerTheme.Substring(containerTheme.LastIndexOf('/') + 1);

            containerFilename = containerFilename.Remove(containerFilename.IndexOf('.'));

            ActiveStyle activeStyle = new ActiveStyle();

            try
            {
                activeStyle = meta.activeStyles[containerFilename];
            }
            catch
            {
                activeStyle.id = "default";
                activeStyle.type = "predefined";
            }

            if (String.IsNullOrEmpty(templateGroup))
                templateGroup = "default";

            containerClass.Text = String.Concat(
                "eds_containers_", containerTheme,
                " eds_templateGroup_", templateGroup,
                " eds_template_", containerFilename,
                (activeStyle.type != "predefined" || activeStyle.id != "default" ? " eds_style_" + activeStyle.type + "_" + activeStyle.id : "")
            );

            string containersCssPath = Server.MapPath(moduleInfo.ContainerPath) + "container.css";

            if (File.Exists(containersCssPath))
                return;

            new ContainerController(containerTheme, containerPortalId, PortalSettings.HomeDirectoryMapPath, PortalSettings.HomeDirectory).rebuildCss();

            Control cssPageControl = Page.FindControl("CSS");

            if (cssPageControl == null)
                return;

            if (Page.Header.FindControl(ID) != null)
                return;

            var linkTag = new HtmlLink();
            linkTag.ID = Globals.CreateValidID(containerPortalId + "_" + containerTheme + "_containers");
            linkTag.Attributes["rel"] = "stylesheet";
            linkTag.Attributes["type"] = "text/css";
            linkTag.Href = moduleInfo.ContainerPath + "container.css";

            cssPageControl.Controls.Add(linkTag);
        }
Exemplo n.º 6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string clientSkinPath = PortalSettings.ActiveTab.SkinSrc,
                   skinFile       = clientSkinPath.Substring(clientSkinPath.LastIndexOf('/') + 1);

            skinFile = skinFile.Remove(skinFile.IndexOf('.'));

            clientSkinPath = clientSkinPath.Remove(clientSkinPath.LastIndexOf('/') + 1);
            string serverSkinPath = Page.Request.MapPath(clientSkinPath),
                   themeName      = clientSkinPath.Remove(clientSkinPath.LastIndexOf('/')),
                   themePortal    = themeName.Remove(themeName.LastIndexOf('/'));

            themeName = themeName.Substring(themeName.LastIndexOf('/') + 1);

            themePortal = themePortal.Remove(themePortal.LastIndexOf('/'));
            themePortal = themePortal.Substring(themePortal.LastIndexOf('/') + 1);

            Control cssPageControl = Page.FindControl("CSS");

            if (cssPageControl == null)
            {
                return;
            }

            if (Page.Header.FindControl(ID) != null)
            {
                return;
            }

            string skinMetaJson = String.Empty;

            try
            {
                skinMetaJson = File.ReadAllText(serverSkinPath + "StyleWizard\\meta.json", Encoding.UTF8);
            }
            catch (Exception ex)
            {
                if (ex is DirectoryNotFoundException || ex is FileNotFoundException)
                {
                    return;
                }

                throw new Exception("The skin's StyleWizard meta file can't be read.", ex);
            }

            Meta meta;

            try
            {
                meta = JsonConvert.DeserializeObject <Meta>(skinMetaJson);
            }
            catch (Exception ex)
            {
                throw new Exception("The skin's meta file contains invalid JSON.", ex);
            }

            if (!meta.activeStyles.ContainsKey(skinFile))
            {
                return;
            }

            ActiveStyle activeStyle = meta.activeStyles[skinFile];

            if (activeStyle.type == "predefined" && activeStyle.id == "default")
            {
                return;
            }

            string id = String.Concat(
                "skinStyleCss_",
                (themePortal == "_default" ? "" : themePortal + "_"),
                themeName,
                "_style_",
                activeStyle.type, "_", activeStyle.id
                );

            var linkTag = new HtmlLink();

            linkTag.ID = Globals.CreateValidID(id);
            linkTag.Attributes["rel"]  = "stylesheet";
            linkTag.Attributes["type"] = "text/css";
            linkTag.Href = String.Concat(
                clientSkinPath,
                meta.assetsClientPath,
                "css/",
                activeStyle.type,
                "/",
                activeStyle.id,
                ".css"
                );

            cssPageControl.Controls.Add(linkTag);
        }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs onloadEvent)
        {
            base.OnLoad(onloadEvent);

            ModuleInfo moduleInfo = ModuleControl.ModuleContext.Configuration;

            if (moduleInfo.IsDeleted)
            {
                return;
            }

            string metaPath = Server.MapPath(moduleInfo.ContainerPath) + "StyleWizard\\meta.json",
                   metaJson;

            try
            {
                metaJson = File.ReadAllText(metaPath, Encoding.UTF8);
            }
            catch (Exception e)
            {
                if (e is DirectoryNotFoundException || e is FileNotFoundException)
                {
                    return;
                }

                throw new Exception("The container meta file can't be read.", e);
            }

            Meta meta = new Meta();

            try
            {
                meta = JsonConvert.DeserializeObject <Meta>(metaJson);
            }
            catch (Exception e)
            {
                throw new Exception("The container meta file contains invalid JSON.", e);
            }

            string containerFilename = moduleInfo.ContainerSrc.Substring(moduleInfo.ContainerSrc.LastIndexOf('/') + 1),
                   containerTheme    = moduleInfo.ContainerPath.Remove(moduleInfo.ContainerPath.Length - 1),
                   containerPortalId = containerTheme.Remove(containerTheme.LastIndexOf('/'));

            containerPortalId = containerPortalId.Remove(containerPortalId.LastIndexOf('/'));
            containerPortalId = containerPortalId.Substring(containerPortalId.LastIndexOf('/') + 1);

            containerTheme = containerTheme.Substring(containerTheme.LastIndexOf('/') + 1);

            containerFilename = containerFilename.Remove(containerFilename.IndexOf('.'));

            ActiveStyle activeStyle = new ActiveStyle();

            try
            {
                activeStyle = meta.activeStyles[containerFilename];
            }
            catch
            {
                activeStyle.id   = "default";
                activeStyle.type = "predefined";
            }

            if (String.IsNullOrEmpty(templateGroup))
            {
                templateGroup = "default";
            }

            containerClass.Text = String.Concat(
                "eds_containers_", containerTheme,
                " eds_templateGroup_", templateGroup,
                " eds_template_", containerFilename,
                (activeStyle.type != "predefined" || activeStyle.id != "default" ? " eds_style_" + activeStyle.type + "_" + activeStyle.id : "")
                );

            string containersCssPath = Server.MapPath(moduleInfo.ContainerPath) + "container.css";

            if (File.Exists(containersCssPath))
            {
                return;
            }

            new ContainerController(containerTheme, containerPortalId, PortalSettings.HomeDirectoryMapPath, PortalSettings.HomeDirectory).rebuildCss();

            Control cssPageControl = Page.FindControl("CSS");

            if (cssPageControl == null)
            {
                return;
            }

            if (Page.Header.FindControl(ID) != null)
            {
                return;
            }

            var linkTag = new HtmlLink();

            linkTag.ID = Globals.CreateValidID(containerPortalId + "_" + containerTheme + "_containers");
            linkTag.Attributes["rel"]  = "stylesheet";
            linkTag.Attributes["type"] = "text/css";
            linkTag.Href = moduleInfo.ContainerPath + "container.css";

            cssPageControl.Controls.Add(linkTag);
        }
Exemplo n.º 8
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string clientSkinPath = PortalSettings.ActiveTab.SkinSrc,
                   skinFile       = clientSkinPath.Substring(clientSkinPath.LastIndexOf('/') + 1);

            skinFile = skinFile.Remove(skinFile.IndexOf('.'));

            clientSkinPath = clientSkinPath.Remove(clientSkinPath.LastIndexOf('/') + 1);
            string themeName   = clientSkinPath.Remove(clientSkinPath.LastIndexOf('/')),
                   themePortal = themeName.Remove(themeName.LastIndexOf('/'));

            themeName = themeName.Substring(themeName.LastIndexOf('/') + 1);

            themePortal = themePortal.Remove(themePortal.LastIndexOf('/'));
            themePortal = themePortal.Substring(themePortal.LastIndexOf('/') + 1);

            Control cssPageControl = Page.FindControl("CSS");

            if (cssPageControl == null || Page.Header.FindControl(ID) != null)
            {
                return;
            }


            UserInfo user = (UserInfo)Context.Items["UserInfo"];

            MetaDefinition meta = MetaDefinition.MetaFromFolder(
                Server.MapPath(clientSkinPath) + "StyleWizard\\",
                true,
                (user != null && (user.IsSuperUser || user.IsInRole(PortalSettings.AdministratorRoleName)))
                );

            if (meta == null)
            {
                return;
            }

            AdditionalObjectResources themeObjectResources = meta.GetAdditionalObjectResources(
                PortalSettings.PortalId.ToString(),
                skinFile,
                "eds_skin_" + themeName,
                clientSkinPath + meta.assetsClientPath
                );

            foreach (HtmlLink linkControl in themeObjectResources.css)
            {
                if (Page.Header.FindControl(linkControl.ID) == null)
                {
                    cssPageControl.Controls.Add(linkControl);
                }
            }

            ActiveStyle activeStyle = meta.GetActiveStyle(PortalSettings.PortalId, skinFile);

            if (activeStyle.type == "predefined" && activeStyle.id == "default")
            {
                return;
            }

            string id = String.Concat(
                "skinStyleCss_",
                (themePortal == "_default" ? "" : themePortal + "_"),
                themeName,
                "_style_",
                activeStyle.type, "_", activeStyle.id
                );
            string href = String.Concat(
                clientSkinPath,
                meta.assetsClientPath,
                "css/",
                activeStyle.type,
                "/",
                activeStyle.id,
                ".css"
                );

            cssPageControl.Controls.Add(Utility.CreateCssLinkControl(id, href));
        }