Exemplo n.º 1
0
        getSectionStyleId(string name)
        {
            SectionStyleCollection styles = BaseObjs._civDoc.Styles.SectionStyles;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    foreach (ObjectId style in styles)
                    {
                        SectionStyle sStyle = (SectionStyle)tr.GetObject(style, OpenMode.ForRead);
                        if (sStyle.Name == name)
                        {
                            return(sStyle.ObjectId);
                        }
                    }

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Sect_Style.cs: line: 95", ex.Message));
            }
            return(ObjectId.Null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the section style.
        /// </summary>
        /// <param name="styleNode">The style node.</param>
        private void CreateSectionStyle(XElement styleNode)
        {
            SectionStyle        sectionStyle = new SectionStyle(_document, new XElement(styleNode));
            IPropertyCollection pCollection  = new IPropertyCollection();

            if (styleNode.HasElements)
            {
                foreach (XElement node in styleNode.Elements())
                {
                    IProperty property = GetProperty(sectionStyle, new XElement(node));
                    if (property != null)
                    {
                        pCollection.Add(property);
                    }
                }
            }

            sectionStyle.Node.Value = "";

            foreach (IProperty property in pCollection)
            {
                sectionStyle.PropertyCollection.Add(property);
            }

            if (!_common)
            {
                _document.Styles.Add(sectionStyle);
            }
            else
            {
                _document.CommonStyles.Add(sectionStyle);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the section style.
        /// </summary>
        /// <param name="styleNode">The style node.</param>
        private void CreateSectionStyle(XmlNode styleNode)
        {
            SectionStyle        sectionStyle = new SectionStyle(this._document, styleNode.CloneNode(true));
            IPropertyCollection pCollection  = new IPropertyCollection();

            if (styleNode.HasChildNodes)
            {
                foreach (XmlNode node in styleNode.ChildNodes)
                {
                    IProperty property = this.GetProperty(sectionStyle, node.CloneNode(true));
                    if (property != null)
                    {
                        pCollection.Add(property);
                    }
                }
            }

            sectionStyle.Node.InnerXml = "";

            foreach (IProperty property in pCollection)
            {
                sectionStyle.PropertyCollection.Add(property);
            }

            if (!this._common)
            {
                this._document.Styles.Add(sectionStyle);
            }
            else
            {
                this._document.CommonStyles.Add(sectionStyle);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public OrderedSectionGroup()
        {
            TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));

            sectionStyle = (SectionStyle)settings.sectionStyle;
            switch (sectionStyle)
            {
            case SectionStyle.Bubbles:
                buttonStyle = "button";
                break;

            case SectionStyle.Foldout:
                buttonStyle = new GUIStyle("button");
                break;

            case SectionStyle.Box:
                buttonStyle                  = new GUIStyle("box");
                buttonStyle.alignment        = TextAnchor.MiddleCenter;
                buttonStyle.stretchWidth     = true;
                buttonStyle.normal.textColor = Color.white;
                buttonStyle.fontStyle        = FontStyle.Bold;
                break;
            }

            sectionBgColor = settings.sectionColor;
            sections       = new List <OrderedSection>();
        }
Exemplo n.º 5
0
        copySectionStyle()
        {
            Document acDocTar = BaseObjs._acadDoc;                                                              // target - Active Document
            Database dbTar    = acDocTar.Database;                                                              // target database

            Document acDocSrc = BaseObjs.openDwg("R:\\TSet\\Template\\CIVIL3D2010\\EW.dwt");                    // source - Active Document

            Application.DocumentManager.MdiActiveDocument = acDocSrc;
            CivilDocument civDocSrc = BaseObjs._civDoc;

            SectionStyleCollection objSectionStyles = civDocSrc.Styles.SectionStyles;                           //source Section Styles

            using (Transaction tr = BaseObjs.startTransactionDb()) {
                foreach (ObjectId idStyle in objSectionStyles)
                {
                    SectionStyle style = (SectionStyle)tr.GetObject(idStyle, OpenMode.ForRead);
                    if (style.Name != "Standard")
                    {
                        style.ExportTo(dbTar, Autodesk.Civil.StyleConflictResolverType.Override);                                       //export from source to target db
                    }
                }
                tr.Commit();
            }

            Application.DocumentManager.MdiActiveDocument = acDocTar;
            acDocSrc.CloseAndDiscard();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializations needed when first opening the window
        /// </summary>
        public void Start()
        {
            firstCycle = false;

            // Gets the inspector level from editorPrefs, if for some reason is not present it just defaults to normal and writes it (should never happen if i remembered to do the first time window)
            if (EditorPrefs.HasKey(TSConstants.TSEPInspectorLevel))
            {
                inspectorLevel = (InspectorLevel)EditorPrefs.GetInt(TSConstants.TSEPInspectorLevel);
            }
            else
            {
                inspectorLevel = InspectorLevel.Normal;
                EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)InspectorLevel.Normal);
            }

            // Loads the settings file if exists, creates a default one if not
            if (File.Exists(TSConstants.SettingsJSONPath))
            {
                TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));
                sectionStyle         = (SectionStyle)settings.sectionStyle;
                sectionColor         = settings.sectionColor;
                isAutoUpdateDisabled = settings.disableUpdates;
            }
            else
            {
                TSSettings settings = new TSSettings();
                settings.sectionStyle   = (int)SectionStyle.Bubbles;
                settings.sectionColor   = new Color(1, 1, 1, 1);
                settings.disableUpdates = false;
                File.WriteAllText(TSConstants.SettingsJSONPath, JsonUtility.ToJson(settings));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Default section constructor
        /// </summary>
        /// <param name="sectionTitle">Title of the section</param>
        /// <param name="open">If is open or closed upon creation</param>
        /// <param name="content">Delegate function for drawing the section content</param>
        /// <param name="changesCheck">Delegate fucntion for checks that need to be done knowing if the box is open or enabled at all</param>
        public Section(GUIContent sectionTitle, bool open, SectionContent content, ChangesCheck changesCheck)
        {
            this.sectionTitle = sectionTitle;
            this.isOpen       = open;
            this.content      = content;
            this.changesCheck = changesCheck;

            TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));

            sectionStyle        = (SectionStyle)settings.sectionStyle;
            this.sectionBgColor = settings.sectionColor;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Standard library use only.
 /// </summary>
 public Section(
     SectionStyle style, string heading, IEnumerable<Control> postHeadingControls, IEnumerable<Control> contentControls, bool? expanded,
     bool disableStatePersistence)
     : base("section")
 {
     this.style = style;
     this.heading = heading;
     this.postHeadingControls = postHeadingControls != null ? postHeadingControls.ToArray() : new Control[ 0 ];
     this.contentControls = contentControls != null ? contentControls.ToArray() : new Control[ 0 ];
     this.expanded = expanded;
     this.disableStatePersistence = disableStatePersistence;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Standard library use only.
        /// </summary>
        public Section(
            SectionStyle style, string heading, IEnumerable <Control> postHeadingControls, IEnumerable <Control> contentControls, bool?expanded,
            bool disableStatePersistence) : base("section")
        {
            this.style               = style;
            this.heading             = heading;
            this.postHeadingControls = postHeadingControls != null?postHeadingControls.ToArray() : new Control[0];

            this.contentControls = contentControls != null?contentControls.ToArray() : new Control[0];

            this.expanded = expanded;
            this.disableStatePersistence = disableStatePersistence;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a section error-display style.
        /// </summary>
        /// <param name="heading">The section's heading. Do not pass null.</param>
        /// <param name="style">The section's style.</param>
        public SectionErrorDisplayStyle(string heading, SectionStyle style = SectionStyle.Normal)
        {
            componentGetter = (errorSources, errors, componentsFocusableOnError) => {
                if (!errors.Any())
                {
                    return(Enumerable.Empty <FlowComponent>().Materialize());
                }

                return(new Section(
                           heading,
                           ((ErrorDisplayStyle <FlowComponent>) new ListErrorDisplayStyle()).GetComponents(errorSources, errors, componentsFocusableOnError),
                           style: style).ToCollection());
            };
        }
Exemplo n.º 11
0
        /// <summary>
        /// Main constructor
        /// </summary>
        /// <param name="sectionTitle">Title of the section</param>
        /// <param name="open">Is the section expanded?</param>
        /// <param name="enabled">IS the section enabled?</param>
        /// <returns></returns>
        public OrderedSection(GUIContent sectionTitle, bool open, bool enabled)
        {
            this.sectionTitle = sectionTitle;
            this.isOpen       = open;
            this.isEnabled    = enabled;
            pushState         = 0;

            isUp   = false;
            isDown = false;

            TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));

            sectionStyle        = (SectionStyle)settings.sectionStyle;
            this.sectionBgColor = settings.sectionColor;
        }
Exemplo n.º 12
0
        makeSectionStyle(string strName)
        {
            string   nameLayer = string.Format("{0}-SURFACE-SEC", strName);
            ObjectId idLayer   = Layer.manageLayers(nameLayer);
            Color    c         = clr.byl;

            switch (strName)
            {
            case "CPNT":
                Layer.modifyLayer(idLayer, 4, LineWeight.ByLayer);
                c = clr.cyn;
                break;

            case "EXIST":
                Layer.modifyLayer(idLayer, 8, LineWeight.ByLayer, "DASHED");
                c = clr.c8;
                break;

            case "SG":
                Layer.modifyLayer(idLayer, 1, LineWeight.ByLayer);
                c = clr.red;
                break;

            case "OX":
                Layer.modifyLayer(idLayer, 3, LineWeight.ByLayer);
                c = clr.grn;
                break;

            case "BOT":
                Layer.modifyLayer(idLayer, 5, LineWeight.ByLayer);
                c = clr.blu;
                break;
            }

            ObjectId idStyle = Sect_Style.getSectionStyleId(strName);

            using (var tr = BaseObjs.startTransactionDb()){
                SectionStyle objSectionStyle = (SectionStyle)tr.GetObject(idStyle, OpenMode.ForWrite);
                objSectionStyle.CreateBy = "EarthWork";
                DisplayStyle ds = objSectionStyle.GetDisplayStyleSection(SectionDisplayStyleSectionType.Segments);
                ds.Visible  = true;
                ds.Layer    = nameLayer;
                ds.Color    = c;
                ds.Linetype = "ByLayer";
                tr.Commit();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Draws the settings GUI
        /// </summary>
        private void DrawSettings()
        {
            EditorGUI.BeginChangeCheck();
            inspectorLevel = (InspectorLevel)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.InspectorLevel, inspectorLevel);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)inspectorLevel);
            }

            EditorGUI.BeginChangeCheck();
            updater.updateStream = (UpdateStream)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.UpdateStream, updater.updateStream);
            if (EditorGUI.EndChangeCheck())
            {
                LocalVersionJSON local = JsonUtility.FromJson <LocalVersionJSON>(File.ReadAllText(TSConstants.LocalJSONPath));
                local.beta = updater.updateStream == UpdateStream.Beta;
                File.WriteAllText(TSConstants.LocalJSONPath, JsonUtility.ToJson(local));
                updater.Reset();
            }

            EditorGUI.BeginChangeCheck();
            sectionStyle         = (SectionStyle)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.SectionStyle, sectionStyle);
            sectionColor         = EditorGUILayout.ColorField(TSConstants.TSWindowLabels.Color, sectionColor);
            isAutoUpdateDisabled = EditorGUILayout.Toggle(TSConstants.TSWindowLabels.DisableAutoUpdates, isAutoUpdateDisabled);
            if (EditorGUI.EndChangeCheck())
            {
                TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath));
                settings.sectionStyle   = (int)sectionStyle;
                settings.sectionColor   = sectionColor;
                settings.disableUpdates = isAutoUpdateDisabled;
                File.WriteAllText(TSConstants.SettingsJSONPath, JsonUtility.ToJson(settings));
                exampleSection = new Section(new GUIContent("Example Section"), true, delegate(MaterialEditor m){ EditorGUILayout.LabelField("Example content"); }, delegate(bool a, bool b){});
            }


            GUILayout.Space(20);
            if (exampleSection == null)
            {
                exampleSection = new Section(new GUIContent("Example Section"), true, delegate(MaterialEditor m){ EditorGUILayout.LabelField("Example content"); }, delegate(bool a, bool b){});
            }
            exampleSection.DrawSection(null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TableOfContents"/> class.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <param name="styleName">Name of the style.</param>
        /// <param name="useHyperlinks">if set to <c>true</c> [use hyperlinks].</param>
        /// <param name="protectChanges">if set to <c>true</c> [protect changes].</param>
        /// <param name="textName">Title for the Table of content e.g. Table of Content</param>
        public TableOfContents(IDocument textDocument, string styleName, bool useHyperlinks, bool protectChanges,
                               string textName)
        {
            Document      = textDocument;
            UseHyperlinks = useHyperlinks;
            Node          = new XElement(Ns.Text + "table-of-content");
            Node.SetAttributeValue(Ns.Text + "style-name", styleName);
            Node.SetAttributeValue(Ns.Text + "protected", Convert.ToString(protectChanges).ToLower());
            Node.SetAttributeValue(Ns.Text + "use-outline-level", "true");
            Node.SetAttributeValue(Ns.Text + "name", textName ?? "Table of Contents1");
            Style = new SectionStyle(this, styleName);
            Document.Styles.Add(Style);

            TableOfContentsSource = new TableOfContentsSource(this);
            TableOfContentsSource.InitStandardTableOfContentStyle();
            Node.Add(TableOfContentsSource.Node);

            CreateIndexBody();
            CreateTitlePargraph();
            InsertContentStyle();
            SetOutlineStyle();
            RegisterEvents();
        }
        /// <summary>
        /// Standard library use only.
        /// </summary>
        public Section(
            SectionStyle style, string heading, IEnumerable <Control> postHeadingControls, IEnumerable <Control> contentControls, bool?expanded,
            bool disableStatePersistence) : base("section")
        {
            postHeadingControls = postHeadingControls?.ToArray() ?? new Control[0];
            contentControls     = contentControls?.ToArray() ?? new Control[0];

            CssClass =
                CssClass.ConcatenateWithSpace(
                    allStylesBothStatesClass + " " +
                    (style == SectionStyle.Normal
                                                  ? getSectionClass(expanded, normalClosedClass, normalExpandedClass)
                                                  : getSectionClass(expanded, boxClosedClass, boxExpandedClass)));

            if (heading.Any())
            {
                var headingControls =
                    new WebControl(HtmlTextWriterTag.H1)
                {
                    CssClass = headingClass
                }.AddControlsReturnThis(heading.ToComponents().GetControls())
                .ToCollection()
                .Concat(postHeadingControls);
                if (expanded.HasValue)
                {
                    var toggleClasses = style == SectionStyle.Normal ? new[] { normalClosedClass, normalExpandedClass } : new[] { boxClosedClass, boxExpandedClass };

                    var headingContainer =
                        new Block(
                            new GenericPhrasingContainer("Click to Expand".ToComponents(), classes: closeClass).ToCollection()
                            .Concat(new GenericPhrasingContainer("Click to Close".ToComponents(), classes: expandClass))
                            .GetControls()
                            .Concat(headingControls)
                            .ToArray())
                    {
                        CssClass = headingClass
                    };
                    var actionControlStyle = new CustomActionControlStyle(c => c.AddControlsReturnThis(headingContainer));

                    this.AddControlsReturnThis(
                        disableStatePersistence
                                                        ? new CustomButton(() => "$( '#" + ClientID + "' ).toggleClass( '" + StringTools.ConcatenateWithDelimiter(" ", toggleClasses) + "', 200 )")
                    {
                        ActionControlStyle = actionControlStyle
                    }
                                                        : new ToggleButton(this.ToCollection(), actionControlStyle, false, (postBackValue, validator) => { }, toggleClasses: toggleClasses) as Control);
                }
                else
                {
                    var headingContainer = new Block(headingControls.ToArray())
                    {
                        CssClass = headingClass
                    };
                    this.AddControlsReturnThis(new Block(headingContainer));
                }
            }
            if (contentControls.Any())
            {
                this.AddControlsReturnThis(new Block(contentControls.ToArray())
                {
                    CssClass = contentClass
                });
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            TextDocument doc = new TextDocument();

            SectionColumn column1 = new SectionColumn();

            column1.RelativeWidth = 32767;
            column1.LeftSpace     = new Independentsoft.Office.Odf.Size(0, Unit.Inch);
            column1.RightSpace    = new Independentsoft.Office.Odf.Size(0, Unit.Inch);

            SectionColumn column2 = new SectionColumn();

            column2.RelativeWidth = 32767;
            column2.LeftSpace     = new Independentsoft.Office.Odf.Size(0, Unit.Inch);
            column2.RightSpace    = new Independentsoft.Office.Odf.Size(0, Unit.Inch);

            SectionStyle sectionStyle1 = new SectionStyle("Style1");

            sectionStyle1.Columns.Add(column1);
            sectionStyle1.Columns.Add(column2);

            SectionStyle sectionStyle2 = new SectionStyle("Style2");

            sectionStyle2.BackgroundColor = "#FFFF00"; //yellow

            doc.AutomaticStyles.Styles.Add(sectionStyle1);
            doc.AutomaticStyles.Styles.Add(sectionStyle2);

            Paragraph paragraph1 = new Paragraph();

            paragraph1.Add("Text in the first section.");

            Paragraph paragraph2 = new Paragraph();

            paragraph2.Add("Text in the second section.");

            Paragraph emptyParagraph = new Paragraph();

            Section section1 = new Section();

            section1.Name  = "Section1";
            section1.Style = "Style1";
            section1.Add(paragraph1);
            section1.Add(paragraph1);
            section1.Add(paragraph1);
            section1.Add(emptyParagraph);
            section1.Add(emptyParagraph);
            section1.Add(paragraph1);

            Section section2 = new Section();

            section2.Name  = "Section2";
            section2.Style = "Style2";
            section2.Add(paragraph2);
            section2.Add(paragraph2);
            section2.Add(paragraph2);
            section2.Add(paragraph2);
            section2.Add(paragraph2);
            section2.Add(paragraph2);

            doc.Body.Add(section1);
            doc.Body.Add(section2);

            doc.Save("c:\\test\\output.odt", true);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="heading">The section's heading. Do not pass null.</param>
 /// <param name="contentControls">The section's content.</param>
 /// <param name="style">The section's style.</param>
 /// <param name="postHeadingControls">Controls that follow the heading but are still part of the heading container.</param>
 /// <param name="expanded">Set to true or false if you want users to be able to expand or close the section by clicking on the heading.</param>
 public Section(
     string heading, IEnumerable<Control> contentControls, SectionStyle style = SectionStyle.Normal, IEnumerable<Control> postHeadingControls = null,
     bool? expanded = null)
     : this(style, heading, postHeadingControls, contentControls, expanded, false)
 {
 }
Exemplo n.º 18
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="contentControls">The section's content.</param>
 /// <param name="style">The section's style.</param>
 public Section( IEnumerable<Control> contentControls, SectionStyle style = SectionStyle.Normal )
     : this("", contentControls, style: style)
 {
 }
Exemplo n.º 19
0
        public Section GetSection(SectionStyle style, bool isDamaged = false, int maxTries = 0)
        {
            var cardSpaces     = 3;
            var formationTypes = new List <FormationType>()
            {
                FormationType.SUIT_RUN,
                FormationType.SAME_RANK,
                FormationType.SAME_SUIT,
                FormationType.RUN,
                FormationType.SUM
            };

            switch (style)
            {
            case SectionStyle.RightPit:
                cardSpaces     = 3;
                formationTypes = isDamaged ?
                                 new List <FormationType>()
                {
                    FormationType.RUN, FormationType.SUM
                } :
                new List <FormationType>()
                {
                    FormationType.LOW_SUM
                };
                break;

            case SectionStyle.LeftPit:
                formationTypes = isDamaged ?
                                 new List <FormationType>()
                {
                    FormationType.RUN, FormationType.SUM
                } :
                new List <FormationType>()
                {
                    FormationType.SUM
                };
                break;

            case SectionStyle.LeftTower:
            case SectionStyle.RightTower:
                if (isDamaged)
                {
                    cardSpaces     = 2;
                    formationTypes = new List <FormationType>()
                    {
                        FormationType.SAME_RANK,
                        FormationType.SUM,
                    };
                }
                else
                {
                    cardSpaces = 4;
                }
                break;

            case SectionStyle.LeftWall:
            case SectionStyle.RightWall:
                if (isDamaged)
                {
                    formationTypes = new List <FormationType>()
                    {
                        FormationType.SAME_SUIT,
                        FormationType.SUM,
                    };
                }
                break;

            case SectionStyle.Gate:
                if (isDamaged)
                {
                    cardSpaces     = 4;
                    formationTypes = new List <FormationType>()
                    {
                        FormationType.LOW_SUM
                    };
                }
                else
                {
                    cardSpaces = 2;
                }
                break;
            }

            var section = new Section()
            {
                Style     = style,
                Name      = style.ToString("F"),
                IsDamaged = isDamaged,
                Spaces    = cardSpaces,
                Types     = formationTypes,
                MaxTries  = maxTries,
            };

            return(section);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="heading">The section's heading. Do not pass null.</param>
 /// <param name="contentControls">The section's content.</param>
 /// <param name="style">The section's style.</param>
 /// <param name="postHeadingControls">Controls that follow the heading but are still part of the heading container.</param>
 /// <param name="expanded">Set to true or false if you want users to be able to expand or close the section by clicking on the heading.</param>
 public Section(
     string heading, IEnumerable <Control> contentControls, SectionStyle style = SectionStyle.Normal, IEnumerable <Control> postHeadingControls = null,
     bool?expanded = null) : this(style, heading, postHeadingControls, contentControls, expanded, false)
 {
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="heading">The section's heading. Do not pass null.</param>
 /// <param name="content">The section's content.</param>
 /// <param name="displaySetup"></param>
 /// <param name="style">The section's style.</param>
 /// <param name="classes">The classes on the section.</param>
 /// <param name="postHeadingComponents">Components that follow the heading but are still part of the heading container.</param>
 /// <param name="expanded">Set to true or false if you want users to be able to expand or close the section by clicking on the heading.</param>
 /// <param name="etherealContent"></param>
 public Section(
     string heading, IReadOnlyCollection <FlowComponent> content, DisplaySetup displaySetup = null, SectionStyle style = SectionStyle.Normal,
     ElementClassSet classes = null, IReadOnlyCollection <FlowComponent> postHeadingComponents = null, bool?expanded = null,
     IReadOnlyCollection <EtherealComponent> etherealContent = null) : this(
         displaySetup,
         style,
         classes,
         heading,
         postHeadingComponents,
         content,
         expanded,
         false,
         etherealContent)
 {
 }
Exemplo n.º 22
0
 /// <summary>
 /// Creates a section error-display style.
 /// </summary>
 /// <param name="heading">The section's heading. Do not pass null.</param>
 /// <param name="style">The section's style.</param>
 public SectionErrorDisplayStyle(string heading, SectionStyle style = SectionStyle.Normal)
 {
     this.style   = style;
     this.heading = heading;
 }
 /// <summary>
 /// Creates a section error-display style.
 /// </summary>
 /// <param name="heading">The section's heading. Do not pass null.</param>
 /// <param name="style">The section's style.</param>
 public SectionErrorDisplayStyle( string heading, SectionStyle style = SectionStyle.Normal )
 {
     this.style = style;
     this.heading = heading;
 }
Exemplo n.º 24
0
        /// <summary>
        /// BasicPage.master use only.
        /// </summary>
        public Section(
            DisplaySetup displaySetup, SectionStyle style, ElementClassSet classes, string heading, IReadOnlyCollection <FlowComponent> postHeadingComponents,
            IReadOnlyCollection <FlowComponent> content, bool?expanded, bool disableStatePersistence, IReadOnlyCollection <EtherealComponent> etherealContent)
        {
            children = new DisplayableElement(
                context => {
                var hiddenFieldId = new HiddenFieldId();
                var expandedPmv   = heading.Any() && expanded.HasValue && !disableStatePersistence ? new PageModificationValue <string>() : null;

                FlowComponent getHeadingButton()
                {
                    var headingComponents =
                        new DisplayableElement(
                            headingContext => new DisplayableElementData(
                                null,
                                () => new DisplayableElementLocalData("h1"),
                                classes: headingClass,
                                children: heading.ToComponents())).Concat(postHeadingComponents ?? Enumerable.Empty <FlowComponent>());

                    return(expanded.HasValue
                                                               ?
                           // We cannot use EwfButton because we have flow content.
                           ElementActivationBehavior.GetActivatableElement(
                               "div",
                               ElementClassSet.Empty,
                               Enumerable.Empty <Tuple <string, string> >().Materialize(),
                               ElementActivationBehavior.CreateButton(
                                   buttonBehavior: new CustomButtonBehavior(
                                       () => disableStatePersistence
                                                                                                     ? "$( '#{0}' ).toggleClass( '{1}', 200 );".FormatWith(
                                           context.Id,
                                           StringTools.ConcatenateWithDelimiter(
                                               " ",
                                               style == SectionStyle.Normal
                                                                                                                             ? new[] { normalClosedClass.ClassName, normalExpandedClass.ClassName }
                                                                                                                             : new[] { boxClosedClass.ClassName, boxExpandedClass.ClassName }))
                                                                                                     : hiddenFieldId.GetJsValueModificationStatements(
                                           "document.getElementById( '{0}' ).value === '{2}' ? '{1}' : '{2}'".FormatWith(
                                               hiddenFieldId.ElementId.Id,
                                               bool.FalseString,
                                               bool.TrueString)))),
                               new GenericFlowContainer(
                                   new GenericPhrasingContainer("Click to Expand".ToComponents(), classes: closeClass).ToCollection()
                                   .Append(new GenericPhrasingContainer("Click to Close".ToComponents(), classes: expandClass))
                                   .Concat(headingComponents)
                                   .Materialize(),
                                   classes: headingClass).ToCollection(),
                               Enumerable.Empty <EtherealComponent>().Materialize())
                                                               : new GenericFlowContainer(new GenericFlowContainer(headingComponents.Materialize(), classes: headingClass).ToCollection()));
                }

                content = content ?? Enumerable.Empty <FlowComponent>().Materialize();
                return(new DisplayableElementData(
                           displaySetup,
                           () => new DisplayableElementLocalData(
                               "section",
                               focusDependentData:
                               new DisplayableElementFocusDependentData(includeIdAttribute: heading.Any() && expanded.HasValue && disableStatePersistence)),
                           classes: allStylesBothStatesClass
                           .Add(
                               style == SectionStyle.Normal
                                                                        ? getSectionClasses(expanded, expandedPmv, normalClosedClass, normalExpandedClass)
                                                                        : getSectionClasses(expanded, expandedPmv, boxClosedClass, boxExpandedClass))
                           .Add(classes ?? ElementClassSet.Empty),
                           children: (heading.Any() ? getHeadingButton().ToCollection() : Enumerable.Empty <FlowComponent>()).Concat(
                               content.Any() ? new GenericFlowContainer(content, classes: contentClass).ToCollection() : Enumerable.Empty <FlowComponent>())
                           .Materialize(),
                           etherealChildren: (expandedPmv != null
                                                                            ? new EwfHiddenField(expanded.Value.ToString(), id: hiddenFieldId, pageModificationValue: expandedPmv).PageComponent
                                              .ToCollection()
                                                                            : Enumerable.Empty <EtherealComponent>()).Concat(etherealContent ?? Enumerable.Empty <EtherealComponent>())
                           .Materialize()));
            }).ToCollection();
        }
Exemplo n.º 25
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="contentControls">The section's content.</param>
 /// <param name="style">The section's style.</param>
 public Section(IEnumerable <Control> contentControls, SectionStyle style = SectionStyle.Normal) : this("", contentControls, style : style)
 {
 }
Exemplo n.º 26
0
 /// <summary>
 /// Creates a section.
 /// </summary>
 /// <param name="content">The section's content.</param>
 /// <param name="displaySetup"></param>
 /// <param name="style">The section's style.</param>
 /// <param name="classes">The classes on the section.</param>
 /// <param name="etherealContent"></param>
 public Section(
     IReadOnlyCollection <FlowComponent> content, DisplaySetup displaySetup = null, SectionStyle style = SectionStyle.Normal, ElementClassSet classes = null,
     IReadOnlyCollection <EtherealComponent> etherealContent = null) : this(
         "",
         content,
         displaySetup : displaySetup,
         style : style,
         classes : classes,
         etherealContent : etherealContent)
 {
 }