Exemple #1
0
 public ToolbarButton (String text, StyleSheet scheme, Border borders,
                       uint width, uint height) : base (scheme, width, height)
 {
     Text = text;
     Borders = borders;
     base.Initialize ();
 }
Exemple #2
0
        public ToolbarToggleButton (String text_one, String text_two, bool auto_toggle, StyleSheet scheme, Border borders,
                                    uint width, uint height) : base (text_one, scheme, borders, width, height)
        {
            toggle = auto_toggle;

            CairoTexture texture = new CairoTexture (width, height);
            StyleSheet s = scheme;
            s.Foreground = scheme.Background;
            s.Background = scheme.Foreground;

            s.Standard = new Font () {
                Family = scheme.Standard.Family,
                Slant = scheme.Standard.Slant,
                Weight = scheme.Standard.Weight,
                Size = scheme.Standard.Size,
                Color = scheme.Background
            };

            s.Border = scheme.Foreground;
            Style = s;
            Text = text_two;
            Draw (texture);

            Style = scheme;
            Text = text_one;
            textures.Add (texture);
            texture.Hide ();
            this.Add (texture);

            InitializeHandlers ();
        }
        public void TestStylePropsDetails()
        {
            using (Stream from = File.Open(TESTFILE_DIR + "styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);

                sr.Execute();

                {
                    Style s = sr.GetStyle("CommentSubjectChar");
                    Assert.IsNotNull(s);

                    Assert.IsTrue(s.HasProperty("b"));
                    Assert.IsTrue(s.HasProperty("bCs"));
                    Assert.AreEqual("", s.GetProperty("b").GetAttributeValue("val"));
                    Assert.AreEqual("", s.GetProperty("bCs").GetAttributeValue("val"));

                }
                
                {
                    Style s = sr.GetStyle("CommentTextChar");
                    Assert.IsNotNull(s);

                    Assert.IsTrue(s.HasProperty("sz"));
                    Assert.IsTrue(s.HasProperty("rFonts"));
                    Assert.IsFalse(s.HasProperty("b"));
                    Assert.IsFalse(s.HasProperty("bCs"));
                    Assert.AreEqual("20", s.GetProperty("sz").GetAttributeValue("val"));
                    Assert.AreEqual("", s.GetProperty("rFonts").GetAttributeValue("val"));
                }
            }
        }
		public override Bound Apply (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			base.Apply (stylesheet, styleBound, maxBound);

			float offset = _behaviour.OffsetByIndex;
			_view.ContentOffset = new PointF (0, offset);
			return styleBound;
		}
Exemple #5
0
        public Button (StyleSheet style, uint width, uint height)
        {
            Style = style;
            Reactive = true;

            texture_width = width;
            texture_height = height;
        }
        public QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var styleEvaluator = new QuestionStyleEvaluator();

            return styleEvaluator.GetQuestionStyles(styleSheet, form.GetAllQuestions());
        }
        internal override void Validate(StyleSheet styleSheet, ValidationReport report)
        {
            base.Validate(styleSheet, report);

            foreach (var unrefferedQuestion in _unrefferedQuestions)
            {
                Report.AddError(TextPosition.None, "The QL question '{0}' is not referred in the QLS.", unrefferedQuestion);
            }
        }
    public void ApplyStyles(StyleSheet styleSheet)
    {
        if (IgnoreStyle)
            return;

        _style = styleSheet.GetStyle(this.StyleName.ToString());
        if (_style != null)
        {
            ApplyStyle(_style);
        }
    }
Exemple #9
0
 private Control BuildUI(StyleSheet styleSheet, QuestionStyleCollection questionStyles, QuestionForm form)
 {
     try
     {
         var uiBuilder = new StyleSheetUIBuilder();
         return uiBuilder.BuildUI(styleSheet, questionStyles, form, Output);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during creating of the styled user interface.", ex);
     }
 }
Exemple #10
0
 private QuestionStyleCollection GetQuestionStyles(StyleSheet styleSheet, QuestionForm form)
 {
     try
     {
         var runtimeController = new QLS.Runtime.RuntimeController();
         return runtimeController.GetQuestionStyles(styleSheet, form);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("An unexpected error occured during the evaluation of the question styles.", ex);
     }
 }
        public void TestLoadFromStream()
        {
            using (Stream from = File.Open(TESTFILE_DIR + "styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);

                sr.Execute();
                Assert.AreEqual(24, sr.Styles.Count);

                Assert.AreEqual("Normal", sr.GetStyle("Normal").Id);
            }
        }
        private void InitializeCache(StyleSheet stylesheet)
        {
            _cache.Clear();

            var visitor = new CssItemCollector<Declaration>(true);
            stylesheet.Accept(visitor);

            foreach (Declaration dec in visitor.Items.Where(d => d.PropertyName != null))
            {
                if (dec.PropertyName.Text == "display" && dec.Values.Any(v => v.Text == "inline"))
                    _cache.Add(dec);
            }
        }
        protected override Bound LayoutChildren(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
           Bound bound = LayoutBehaviour.Vertical(stylesheet, this, Childrens, styleBound, maxBound, true);

            if (Childrens.Count > 0)
            {
                Behavour.Borders.Add(Childrens[0].Frame.Top);
                foreach (IControl<View> control in Childrens)
                    Behavour.Borders.Add(control.Frame.Bottom);
            }
            Behavour.ScrolledMeasure = bound.Height;
            return bound;
        }
 public void Start()
 {
     isEditorMode = Application.isEditor;
     styles = GameObject.FindObjectOfType<StyleSheet>();
     if (styles != null)
     {
         _style = styles.GetStyle(this.StyleName.ToString());
         if (_style != null)
         {
             ApplyStyle(_style);
         }
     }
 }
		protected override Bound LayoutChildren (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			_behaviour.ScrolledMeasure = styleBound.Height;

			Bound bound = LayoutBehaviour.Vertical (stylesheet, this, _controls, styleBound, maxBound, true);

			if (_controls.Count > 0) {
				_behaviour.Borders.Add (_controls [0].Frame.Top);
				foreach (var control in _controls) 
					_behaviour.Borders.Add(control.Frame.Bottom);
			}

			return bound;
		}
Exemple #16
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            var bound = new Bound(BitBrowserApp.Current.Width, BitBrowserApp.Current.Height);

            base.Apply(stylesheet, bound, bound);

			//background color
            _view.SetBackgroundColor(Android.Graphics.Color.White);

            if (OnLoad != null)
                OnLoad.Execute();

            Frame = new Rectangle(0, 0, bound);

            return bound;
        }
        public void TestStyleDetails()
        {
            using (Stream from = File.Open(TESTFILE_DIR + "styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);

                sr.Execute();

                Style s = sr.GetStyle("EndnoteReference");
                Assert.IsNotNull(s);
                Assert.AreEqual("EndnoteReference", s.Id);
                Assert.AreEqual("DefaultParagraphFont", s.BasedOn);
                Assert.AreEqual("endnote reference", s.Name);
            }
        }
        private DocumentText CheckDocumentWithStyles(List<TriggeringNodeDefinition> existingTriggers, string stylesheet_xml, string document_xml, out XmlDocument xmlDoc)
        {
            using (Stream from = File.Open(stylesheet_xml, FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);
                sr.Execute();
                sr.Resolve();

                List<TriggeringNodeDefinition> newTriggers = sr.GenerateStyleTriggers(existingTriggers);
                foreach (TriggeringNodeDefinition tnd in newTriggers)
                {
                    existingTriggers.Add(tnd);
                }
            }

            return CheckDocument(existingTriggers, document_xml, out xmlDoc);
        }
        public ValidationReport Validate(StyleSheet styleSheet, QuestionForm form)
        {
            if (styleSheet == null) { throw new ArgumentNullException("styleSheet"); }
            if (form == null) { throw new ArgumentNullException("form"); }

            var validators = new List<ASTChecker>
            {
                new QuestionReferencingChecker(form.GetAllQuestions()),
                new StyleAttributeChecker(),
                new WidgetTypeChecker(form.GetAllQuestions())
            };

            var report = new ValidationReport();

            foreach (var validator in validators)
            {
                validator.Validate(styleSheet, report);
            }

            return report;
        }
Exemple #20
0
        public StatusBox (StyleSheet style, uint width, uint height)
        {
            this.style = style;
            this.height = height;

            Text = "test";
            spinner = new List<CairoTexture> ();

            texture = new CairoTexture (width, height);
            spinner_actor = new Group ();
            GenerateSpinners ();

            spinner_actor.SetPosition (5, 0 );

            Add (texture);
            Add (spinner_actor);

            spinner_timer = new Timer ();
            spinner_timer.Interval = 150;
            spinner_timer.Elapsed += HandleSpinnerNextFrame;

//            Update ("",true);
        }
Exemple #21
0
        private System.Windows.TriggerAction CreateTriggerAction(StyleSheet styleSheet, DependencyObject styleResourceReferenceHolder, TriggerAction action)
        {
            string actionTypeName = null;
            Type   actionType     = null;

            System.Windows.TriggerAction nativeTriggerAction = null;

            "get types etc".Measure(() =>
            {
                actionTypeName      = typeNameResolver.ResolveFullTypeName(styleSheet.Namespaces, action.Action);
                actionType          = Type.GetType(actionTypeName);
                nativeTriggerAction = (System.Windows.TriggerAction)Activator.CreateInstance(actionType);
            });

            "foreach (var parameter in action.Parameters)".Measure(() =>
            {
                foreach (var parameter in action.Parameters)
                {
                    string parameterName            = null;
                    object value                    = null;
                    string parameterValueExpression = null;
                    DependencyPropertyInfo <DependencyProperty> propertyInfo;
                    Type type = null;
                    "Parameter init".Measure(() =>
                    {
                        parameterName            = parameter.Property;
                        parameterValueExpression = parameter.Value.Trim();
                        type = typeNameResolver.GetClrPropertyType(styleSheet.Namespaces, nativeTriggerAction, parameterName);
                    });
                    "Value conversions".Measure(() =>
                    {
                        if (typeNameResolver.IsMarkupExtension(parameterValueExpression))
                        {
                            $"GetMarkupExtensionValue {parameterValueExpression}".Measure(() => value = typeNameResolver.GetMarkupExtensionValue(styleResourceReferenceHolder, parameterValueExpression, styleSheet.Namespaces));
                        }
                        else if ((propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, actionType, parameterName)) != null)
                        {
                            "GetPropertyValue".Measure(() =>
                            {
                                value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, parameterValueExpression, propertyInfo.Property, styleSheet.Namespaces);

                                if (value is DynamicResourceExtension)
                                {
                                    var dyn         = value as DynamicResourceExtension;
                                    serviceProvider = serviceProvider ?? (serviceProvider = (IServiceProvider)typeof(Application).GetProperty("ServiceProvider", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Application.Current));
                                    value           = dyn.ProvideValue(serviceProvider);
                                }
                                else if (value is StaticResourceExtension)
                                {
                                    var dyn         = value as StaticResourceExtension;
                                    serviceProvider = serviceProvider ?? (serviceProvider = (IServiceProvider)typeof(Application).GetProperty("ServiceProvider", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Application.Current));
                                    value           = dyn.ProvideValue(serviceProvider);
                                }
                            });
                        }
                        else
                        {
                            value = parameterValueExpression;
                        }

                        if (value is string valueString)
                        {
                            value = "GetConverter".Measure(() => TypeDescriptor.GetConverter(type)?.ConvertFromInvariantString(valueString) ?? value);
                        }

                        if (value == null)
                        {
                        }
                    });

                    $"Set Property Value {parameterName} = {value}".Measure(() => TypeHelpers.SetPropertyValue(nativeTriggerAction, parameterName, value));
                }
            });
            return(nativeTriggerAction);
        }
 public static void WriteStyleSheet(StyleSheet sheet, string path, UssExportOptions options = null)
 {
     File.WriteAllText(path, ToUssString(sheet, options));
 }
        public void TestResolve()
        {
            using (Stream from = File.Open(TESTFILE_DIR + "styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);

                sr.Execute();
                foreach (Style st in sr.Styles)
                {
                    Assert.IsFalse(st.Resolved);
                }

                sr.Resolve();

                foreach (Style st2 in sr.Styles)
                {
                    Assert.IsTrue(st2.Resolved, "didnt resolve style " + st2.Name);
                }

                Style s = sr.GetStyle("CommentSubjectChar");
                Assert.IsNotNull(s);

                Assert.IsTrue(s.HasProperty("sz"));
                Assert.IsTrue(s.HasProperty("rFonts"));
                Assert.IsTrue(s.HasProperty("b"), "missing the bold property - no inheritance?");
                Assert.IsTrue(s.HasProperty("bCs"));
                Assert.AreEqual("20", s.GetProperty("sz").GetAttributeValue("val"));
                Assert.AreEqual("", s.GetProperty("rFonts").GetAttributeValue("val"));
            }
        }
        public void TestGenerateStyleTriggers()
        {
            List<TriggeringNodeDefinition> existingTriggers = DocxMetadataDefinitions.HiddenDocumentText;

            using (Stream from = File.Open(TESTFILE_DIR + "styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);

                sr.Execute();
                sr.Resolve();

                foreach (TriggeringNodeDefinition tnd in existingTriggers)
                {
                    tnd.NormalizeStrings(sr.CommonNamespaces.NameTable);
                }

                List<TriggeringNodeDefinition> newTriggers = sr.GenerateStyleTriggers(existingTriggers);

                Assert.AreEqual(2, newTriggers.Count);
                TriggeringNodeDefinition tnd1 = newTriggers[0];
                Assert.AreEqual(NamespaceId.w, tnd1.namespaceId);
                Assert.AreEqual("rStyle", tnd1.nodeName);
                Assert.IsTrue(tnd1.attributeFilter.Matches(new AttribDetails("", "val", "", "FooterCharHidden")));


                {
                    MemoryStream ms = new MemoryStream();
                    StreamWriter tw = new StreamWriter(ms);
                    tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:rStyle xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:val=\"FooterCharHidden\"/>");
                    tw.Flush();
                    ms.Position = 0;
                    XmlReaderSettings set = new XmlReaderSettings();
                    set.NameTable = sr.CommonNamespaces.NameTable;
                    set.ConformanceLevel = ConformanceLevel.Fragment;
                    XmlReader r = XmlReader.Create(ms, set);
                    r.Read();
                    XmlNodeInformation xni = new XmlNodeInformation(r, sr.CommonNamespaces);
                    TriggerCollection snui = new TriggerCollection(newTriggers);
                    snui.UpdateStringsUsingNametable(set.NameTable);

                    Assert.AreEqual(1, snui.WhatDoesThisNodeTrigger(xni, null).Count);
                    TriggeringNodeDefinition tnd = snui.WhatDoesThisNodeTrigger(xni, null)[0];
                    Assert.AreEqual("rStyle", tnd.nodeName);
                    Assert.IsTrue(tnd.attributeFilter.Matches(new AttribDetails("", NameTableUtils.NormalizeString(sr.CommonNamespaces.NameTable,"val")
                        , "", "FooterCharHidden")));

                    Assert.AreEqual(NamespaceId.w, tnd.namespaceId);

                    Assert.AreEqual(1, tnd.CreateEffects( xni).Count);
                    Effect t = tnd.CreateEffects(xni)[0];
                    Assert.AreEqual(ContentType.HiddenText, t.ContentType);
                    Assert.AreEqual(true, t.BlockPolarity, "expect the polairty of blocking to be +ve as this is a style with hidden on");
                }


                {
                    MemoryStream ms = new MemoryStream();
                    StreamWriter tw = new StreamWriter(ms);
                    tw.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:rStyle xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:val=\"FooterCharNotHidden\"/>");
                    tw.Flush();
                    ms.Position = 0;
                    XmlReaderSettings set = new XmlReaderSettings();
                    set.NameTable = sr.CommonNamespaces.NameTable;
                    set.ConformanceLevel = ConformanceLevel.Fragment;
                    XmlReader r = XmlReader.Create(ms, set);
                    XmlNodeInformation xni = new XmlNodeInformation(r, sr.CommonNamespaces);
                    TriggerCollection snui = new TriggerCollection(newTriggers);

                    Assert.AreEqual(1, snui.WhatDoesThisNodeTrigger(xni, null).Count);
                    TriggeringNodeDefinition tnd = snui.WhatDoesThisNodeTrigger(xni, null)[0];
                    Assert.AreEqual("rStyle", tnd.nodeName);
                    Assert.IsTrue(tnd.attributeFilter.Matches(new AttribDetails("", NameTableUtils.NormalizeString(sr.CommonNamespaces.NameTable, "val")
                        , "", "FooterCharNotHidden")));
                    Assert.AreEqual(NamespaceId.w, tnd.namespaceId);

                    Assert.AreEqual(1, tnd.CreateEffects( xni).Count);
                    Effect t = tnd.CreateEffects( xni)[0];
                    Assert.AreEqual(ContentType.HiddenText, t.ContentType);
                    Assert.AreEqual(false, t.BlockPolarity, "should have -ve polarity because the style specifies not hidden");
                }


                Assert.AreEqual(true, existingTriggers[0].GetDescriptors()[0].DefaultPolarity, "Should not change the default polarity of the base triggerdescriptor for the non-style tag");
            }
        }
        public void TestDiscoverRealHiddenTextWithStyles()
        {
            List<TriggeringNodeDefinition> existingTriggers = DocxMetadataDefinitions.HiddenDocumentText;

            using (Stream from = File.Open(TESTFILE_DIR + "hidden_styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);
                sr.Execute();
                sr.Resolve();

                List<TriggeringNodeDefinition> newTriggers = sr.GenerateStyleTriggers(existingTriggers);
                foreach (TriggeringNodeDefinition tnd in newTriggers)
                {
                    existingTriggers.Add(tnd);
                }
            }

            using (Stream from2 = File.Open(TESTFILE_DIR + "hidden_styles_document.xml", FileMode.Open))
            {
                StateMachineBasedXmlFilter xfb = new StateMachineBasedXmlFilter(new CommonNamespaces(OpenXmlFormat.Transitional));
                xfb.ConnectToInputStream(from2);

                foreach (TriggeringNodeDefinition tnd in existingTriggers)
                {
                    xfb.AddNodeToTriggerList(tnd);
                }

                DocumentText dt = xfb.DocumentText;
                xfb.Execute();

                TextType ttHidden = dt.GetTextTypes(ContentType.HiddenText)[0] as TextType;
                Assert.IsNotNull(ttHidden);
                Assert.IsTrue(ttHidden.GetChildCount() > 0);

                Assert.AreEqual("This is some text in the document in a hidden paragraph.", ttHidden.GetChild(0).GetInfo("Content")[0].value);
                Assert.AreEqual("This para contains ", ttHidden.GetChild(1).GetInfo("Content")[0].value);
                Assert.AreEqual(" text.", ttHidden.GetChild(2).GetInfo("Content")[0].value);
                Assert.AreEqual("This hidden para contains ", ttHidden.GetChild(3).GetInfo("Content")[0].value);
                Assert.AreEqual(" text.", ttHidden.GetChild(4).GetInfo("Content")[0].value);
                Assert.AreEqual("This text in hidden style with ", ttHidden.GetChild(5).GetInfo("Content")[0].value);
                Assert.AreEqual("embedded.", ttHidden.GetChild(6).GetInfo("Content")[0].value);
                Assert.AreEqual("This text in hidden style with ", ttHidden.GetChild(7).GetInfo("Content")[0].value);
                Assert.AreEqual(" embedded.", ttHidden.GetChild(8).GetInfo("Content")[0].value);



            }

        }
 public InstanceDetailsEmployee()
 {
     InitializeComponent();
     this.Resources.Add(StyleSheet.FromAssemblyResource(IntrospectionExtensions.GetTypeInfo(typeof(SelectAppointmentService)).Assembly,
                                                        "FBCross.Styles.global.css"));
 }
Exemple #27
0
 public void SetDefaultStartContext()
 {
     StyleSheet = new StyleSheet();
     ThemeTable = new ThemeTable();
     CurrentSectionFormatting = new SectionFormatting();
     CurrentSectionFormatting.FCSPageInformation = new FCSPageInformation(); 
 }
    protected void CreartePdf(double invoiceid, double orderid)
    {
        string filname = Server.MapPath("OrderPdf/" + "TSM_Order_" + orderid + ".pdf");

        if (System.IO.File.Exists(filname))
        {
            System.IO.File.Delete(filname);
        }

        iTextSharp.text.html.simpleparser.StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
        styles.LoadStyle("wdth20", "width", "30");
        styles.LoadStyle("wdth80", "width", "80");
        styles.LoadStyle("wdth50", "width", "50");
        styles.LoadStyle("wdth140", "width", "140");
        styles.LoadStyle("wdth100", "width", "100");
        styles.LoadStyle("wdth200", "width", "200");
        styles.LoadStyle("wdth400", "width", "400");
        styles.LoadStyle("wdth51", "width", "51");
        styles.LoadStyle("wdth40", "width", "40");
        styles.LoadStyle("wdth60", "width", "60");
        styles.LoadStyle("wdth65", "width", "65");
        styles.LoadStyle("wdth55", "width", "55");

        styles.LoadStyle("hght200", "height", "200");
        styles.LoadStyle("border-left", "border-left-width", "1");
        styles.LoadStyle("borderright", "BorderWidthRight ", "1f");


        //for header
        StringWriter   swheader = new StringWriter();
        HtmlTextWriter hwheader = new HtmlTextWriter(swheader);

        pnlHeader.RenderControl(hwheader);
        StringReader srheader = new StringReader(swheader.ToString());

        PdfPCell cellLeft = new PdfPCell();

        StyleSheet style = new StyleSheet();

        style.LoadStyle("wdth20", "width", "30");
        style.LoadStyle("wdth40", "width", "40");
        style.LoadStyle("wdth60", "width", "60");
        style.LoadStyle("wdth80", "width", "80");
        style.LoadStyle("wdth81", "width", "81");
        style.LoadStyle("wdth100", "width", "100");
        style.LoadStyle("wdth50", "width", "50");
        style.LoadStyle("wdth51", "width", "51");
        style.LoadStyle("wdth140", "width", "140");
        style.LoadStyle("wdth600", "width", "552");
        style.LoadStyle("wdth200", "width", "220");
        style.LoadStyle("wdth400", "width", "331");

        style.LoadStyle("wdth550", "width", "551");
        style.LoadStyle("wdth541", "width", "551");
        style.LoadStyle("wdth65", "width", "65");
        style.LoadStyle("wdth55", "width", "55");

        List <IElement> objects = HTMLWorker.ParseToList(new StringReader(swheader.ToString()), style);  //This transforms your HTML to a list of PDF compatible objects

        for (int k = 0; k < objects.Count; ++k)
        {
            cellLeft.AddElement((IElement)objects[k]);

            //if (k == 1)
            //{
            //    cellLeft.FixedHeight = 500f;
            //    cellLeft.GetMaxHeight();//Add these objects to cell one by one
            //}
        }
        //header ends

        //for content

        StringWriter   sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        pnlMail.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());


        float    topmrg = cellLeft.GetMaxHeight() + 22;
        Document pdfDoc = new Document(PageSize.A4, 22, 22, topmrg, 40);

        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);

        htmlparser.SetStyleSheet(styles);
        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, new FileStream(filname, FileMode.Create));

        pdfDoc.Open();

        writer.PageEvent = new HeaderFooterCheckout(cellLeft);
        htmlparser.Parse(sr);
        pdfDoc.Close();
        pdfDoc.Dispose();
        sr.Close();
        sr.Dispose();
        srheader.Close();
        sr.Dispose();
        writer.Close();
        writer.Dispose();

        // Mail(orderid, filname);
    }
 static void SwallowStyleRule(
     StyleSheet toStyleSheet, StyleComplexSelector toSelector,
     StyleSheet fromStyleSheet, StyleComplexSelector fromSelector)
 {
     SwallowStyleRule(toStyleSheet, toSelector.rule, fromStyleSheet, fromSelector.rule);
 }
Exemple #30
0
        private IEnumerable <CssSourceMapNode> ProcessGeneratedMaps(string cssfileContents)
        {
            ParseItem      item       = null;
            Selector       selector   = null;
            StyleSheet     styleSheet = null;
            SimpleSelector simple     = null;
            int            start;
            var            parser = new CssParser();
            var            result = new List <CssSourceMapNode>();

            styleSheet = parser.Parse(cssfileContents, false);

            foreach (var node in MapNodes)
            {
                start  = cssfileContents.NthIndexOfCharInString('\n', node.GeneratedLine);
                start += node.GeneratedColumn;

                item = styleSheet.ItemAfterPosition(start);

                if (item == null)
                {
                    continue;
                }

                selector = item.FindType <Selector>();

                if (selector == null)
                {
                    continue;
                }

                var depth = node.OriginalSelector.TreeDepth / 2;

                if (depth < selector.SimpleSelectors.Count)
                {
                    simple = selector.SimpleSelectors.First();

                    if (simple == null)
                    {
                        simple = item.Parent != null?item.Parent.FindType <SimpleSelector>() : null;
                    }

                    if (simple == null)
                    {
                        continue;
                    }

                    var selectorText = new StringBuilder();

                    for (int i = 0; i < node.OriginalSelector.SimpleSelectors.Count; i++)
                    {
                        if (simple == null)
                        {
                            break;
                        }

                        selectorText.Append(simple.Text).Append(" ");

                        simple = simple.NextSibling as SimpleSelector;
                    }

                    StyleSheet sheet = parser.Parse(selectorText.ToString(), false);

                    if (sheet == null || !sheet.RuleSets.Any() || !sheet.RuleSets.First().Selectors.Any())
                    {
                        continue;
                    }

                    selector = sheet.RuleSets.First().Selectors.First() as Selector;

                    if (selector == null)
                    {
                        continue;
                    }
                }

                node.GeneratedSelector = selector;

                result.Add(node);
            }

            return(result);
        }
Exemple #31
0
        private void addControlNew(Property p, TabPage tp, string Caption)
        {
            IDataType dt = p.PropertyType.DataTypeDefinition.DataType;

            dt.DataEditor.Editor.ID = string.Format("prop_{0}", p.PropertyType.Alias);
            dt.Data.PropertyId      = p.Id;

            // check for buttons
            IDataFieldWithButtons df1 = dt.DataEditor.Editor as IDataFieldWithButtons;

            if (df1 != null)
            {
                // df1.Alias = p.PropertyType.Alias;

                /*
                 *              // df1.Version = _content.Version;
                 *              editDataType.Data.PropertyId = p.Id;
                 */
                ((Control)df1).ID = p.PropertyType.Alias;


                if (df1.MenuIcons.Length > 0)
                {
                    tp.Menu.InsertSplitter();
                }


                // Add buttons
                int  c          = 0;
                bool atEditHtml = false;
                bool atSplitter = false;
                foreach (object o in df1.MenuIcons)
                {
                    try
                    {
                        MenuIconI m  = (MenuIconI)o;
                        MenuIconI mi = tp.Menu.NewIcon();
                        mi.ImageURL       = m.ImageURL;
                        mi.OnClickCommand = m.OnClickCommand;
                        mi.AltText        = m.AltText;
                        mi.ID             = tp.ID + "_" + m.ID;

                        if (m.ID == "html")
                        {
                            atEditHtml = true;
                        }
                        else
                        {
                            atEditHtml = false;
                        }

                        atSplitter = false;
                    }
                    catch
                    {
                        tp.Menu.InsertSplitter();
                        atSplitter = true;
                    }

                    // Testing custom styles in editor
                    if (atSplitter && atEditHtml && dt.DataEditor.TreatAsRichTextEditor)
                    {
                        DropDownList ddl = tp.Menu.NewDropDownList();

                        ddl.Style.Add("margin-bottom", "5px");
                        ddl.Items.Add(ui.Text("buttons", "styleChoose", null));
                        ddl.ID = tp.ID + "_editorStyle";
                        if (StyleSheet.GetAll().Length > 0)
                        {
                            foreach (StyleSheet s in StyleSheet.GetAll())
                            {
                                foreach (StylesheetProperty sp in s.Properties)
                                {
                                    ddl.Items.Add(new ListItem(sp.Text, sp.Alias));
                                }
                            }
                        }
                        ddl.Attributes.Add("onChange", "addStyle(this, '" + p.PropertyType.Alias + "');");
                        atEditHtml = false;
                    }
                    c++;
                }
            }

            // check for element additions
            IMenuElement menuElement = dt.DataEditor.Editor as IMenuElement;

            if (menuElement != null)
            {
                // add separator
                tp.Menu.InsertSplitter();

                // add the element
                tp.Menu.NewElement(menuElement.ElementName, menuElement.ElementIdPreFix + p.Id.ToString(),
                                   menuElement.ElementClass, menuElement.ExtraMenuWidth);
            }


            // fieldData.Alias = p.PropertyType.Alias;
            // ((Control) fieldData).ID = p.PropertyType.Alias;
            // fieldData.Text = p.Value.ToString();

            _dataFields.Add(dt.DataEditor.Editor);


            Pane    pp     = new Pane();
            Control holder = new Control();

            holder.Controls.Add(dt.DataEditor.Editor);
            if (p.PropertyType.DataTypeDefinition.DataType.DataEditor.ShowLabel)
            {
                string caption = p.PropertyType.Name;
                if (p.PropertyType.Description != null && p.PropertyType.Description != String.Empty)
                {
                    switch (UmbracoSettings.PropertyContextHelpOption)
                    {
                    case "icon":
                        caption += " <img src=\"" + this.ResolveUrl(SystemDirectories.Umbraco) + "/images/help.png\" class=\"umbPropertyContextHelp\" alt=\"" + p.PropertyType.Description + "\" title=\"" + p.PropertyType.Description + "\" />";
                        break;

                    case "text":
                        caption += "<br /><small>" + umbraco.library.ReplaceLineBreaks(p.PropertyType.Description) + "</small>";
                        break;
                    }
                }
                pp.addProperty(caption, holder);
            }
            else
            {
                pp.addProperty(holder);
            }

            // Validation
            if (p.PropertyType.Mandatory)
            {
                try
                {
                    RequiredFieldValidator rq = new RequiredFieldValidator();
                    rq.ControlToValidate = dt.DataEditor.Editor.ID;
                    Control component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
                    ValidationPropertyAttribute attribute =
                        (ValidationPropertyAttribute)
                        TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
                    PropertyDescriptor pd = null;
                    if (attribute != null)
                    {
                        pd = TypeDescriptor.GetProperties(component, (Attribute[])null)[attribute.Name];
                    }
                    if (pd != null)
                    {
                        rq.EnableClientScript = false;
                        rq.Display            = ValidatorDisplay.Dynamic;
                        string[] errorVars = { p.PropertyType.Name, Caption };
                        rq.ErrorMessage = ui.Text("errorHandling", "errorMandatory", errorVars, null) + "<br/>";
                        holder.Controls.AddAt(0, rq);
                    }
                }
                catch (Exception valE)
                {
                    HttpContext.Current.Trace.Warn("contentControl",
                                                   "EditorControl (" + dt.DataTypeName + ") does not support validation",
                                                   valE);
                }
            }

            // RegExp Validation
            if (p.PropertyType.ValidationRegExp != "")
            {
                try
                {
                    RegularExpressionValidator rv = new RegularExpressionValidator();
                    rv.ControlToValidate = dt.DataEditor.Editor.ID;

                    Control component = dt.DataEditor.Editor; // holder.FindControl(rq.ControlToValidate);
                    ValidationPropertyAttribute attribute =
                        (ValidationPropertyAttribute)
                        TypeDescriptor.GetAttributes(component)[typeof(ValidationPropertyAttribute)];
                    PropertyDescriptor pd = null;
                    if (attribute != null)
                    {
                        pd = TypeDescriptor.GetProperties(component, (Attribute[])null)[attribute.Name];
                    }
                    if (pd != null)
                    {
                        rv.ValidationExpression = p.PropertyType.ValidationRegExp;
                        rv.EnableClientScript   = false;
                        rv.Display = ValidatorDisplay.Dynamic;
                        string[] errorVars = { p.PropertyType.Name, Caption };
                        rv.ErrorMessage = ui.Text("errorHandling", "errorRegExp", errorVars, null) + "<br/>";
                        holder.Controls.AddAt(0, rv);
                    }
                }
                catch (Exception valE)
                {
                    HttpContext.Current.Trace.Warn("contentControl",
                                                   "EditorControl (" + dt.DataTypeName + ") does not support validation",
                                                   valE);
                }
            }

            // This is once again a nasty nasty hack to fix gui when rendering wysiwygeditor
            if (dt.DataEditor.TreatAsRichTextEditor)
            {
                tp.Controls.Add(dt.DataEditor.Editor);
            }
            else
            {
                Panel ph = new Panel();
                ph.Attributes.Add("style", "padding: 0px 0px 0px 0px");
                ph.Controls.Add(pp);

                tp.Controls.Add(ph);
            }
        }
Exemple #32
0
        // A very ugly hack for a very ugly bug: https://github.com/hcatlin/libsass/issues/324
        // Remove this and its caller in previous method, when it is fixed in original repo
        // and https://github.com/andrew/node-sass/ is released with the fix.
        // Overwriting all positions belonging to original/source file.
        private async Task <IEnumerable <CssSourceMapNode> > CorrectionsForScss(string cssFileContents)
        {
            // Sort collection for generated file.
            var sortedForGenerated = MapNodes.OrderBy(x => x.GeneratedLine)
                                     .ThenBy(x => x.GeneratedColumn)
                                     .ToList();

            ParseItem      item = null;
            Selector       selector = null;
            SimpleSelector simple = null;
            StyleSheet     styleSheet = null, cssStyleSheet = null;
            int            start = 0, indexInCollection, targetDepth;
            string         fileContents = null, simpleText = "";
            var            result            = new List <CssSourceMapNode>();
            var            contentCollection = new HashSet <string>(); // So we don't have to read file for each map item.
            var            parser            = new CssParser();

            cssStyleSheet = parser.Parse(cssFileContents, false);

            foreach (var node in MapNodes)
            {
                // Cache source file contents.
                if (!contentCollection.Contains(node.SourceFilePath))
                {
                    if (!File.Exists(node.SourceFilePath)) // Lets say someone deleted the reference file.
                    {
                        continue;
                    }

                    fileContents = await FileHelpers.ReadAllTextRetry(node.SourceFilePath);

                    contentCollection.Add(node.SourceFilePath);

                    styleSheet = _parser.Parse(fileContents, false);
                }

                start  = cssFileContents.NthIndexOfCharInString('\n', node.GeneratedLine);
                start += node.GeneratedColumn;

                item = cssStyleSheet.ItemAfterPosition(start);

                if (item == null)
                {
                    continue;
                }

                selector = item.FindType <Selector>();
                simple   = item.FindType <SimpleSelector>();

                if (selector == null || simple == null)
                {
                    continue;
                }

                simpleText = simple.Text;

                indexInCollection = sortedForGenerated.FindIndex(e => e.Equals(node));//sortedForGenerated.IndexOf(node);

                targetDepth = 0;

                for (int i = indexInCollection;
                     i >= 0 && node.GeneratedLine == sortedForGenerated[i].GeneratedLine;
                     targetDepth++, --i)
                {
                    ;
                }

                start  = fileContents.NthIndexOfCharInString('\n', node.OriginalLine);
                start += node.OriginalColumn;

                item = styleSheet.ItemAfterPosition(start);

                if (item == null)
                {
                    continue;
                }

                while (item.TreeDepth > targetDepth)
                {
                    item = item.Parent;
                }

                // selector = item.FindType<RuleSet>().Selectors.First();

                RuleSet       rule;
                ScssRuleBlock scssRuleBlock = item as ScssRuleBlock;

                rule = scssRuleBlock == null ? item as RuleSet : scssRuleBlock.RuleSets.FirstOrDefault();

                if (rule == null)
                {
                    continue;
                }

                // Because even on the same TreeDepth, there may be mulitple ruleblocks
                // and the selector names may include & or other symbols which are diff
                // fromt he generated counterpart, here is the guess work
                item = rule.Children.FirstOrDefault(r => r is Selector && r.Text.Trim() == simpleText) as Selector;

                selector = item == null ? null : item as Selector;

                if (selector == null)
                {
                    // One more try: look for the selector in neighboring rule blocks then skip.
                    selector = rule.Children.Where(r => r is RuleBlock)
                               .SelectMany(r => (r as RuleBlock).Children
                                           .Where(s => s is RuleSet)
                                           .Select(s => (s as RuleSet).Selectors.FirstOrDefault(sel => sel.Text.Trim() == simpleText)))
                               .FirstOrDefault();

                    if (selector == null)
                    {
                        continue;
                    }
                }

                node.OriginalLine   = fileContents.Substring(0, selector.Start).Count(s => s == '\n');
                node.OriginalColumn = fileContents.GetLineColumn(selector.Start, node.OriginalLine);

                result.Add(node);
            }

            return(result);
        }
Exemple #33
0
        /// <summary>
        /// Generate PDF To Content
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public byte[] GeneratePDFTOCContent(byte[] content, string html)
        {
            var           reader = new PdfReader(content);
            StringBuilder sb     = new StringBuilder();

            // Title of PDF
            sb.Append("<h2><strong style='text-align:center'> Demo for Load More Button in Kendo UI Grid </ strong ></ h2 >< br > ");

            // Begin to create TOC
            // Begin to create TOC
            sb.Append("<table>");
            sb.Append(("<tr><td width='80%'><strong>{ 0}</strong ></td><td align = 'right' width = '10%'><strong >{1}</strong ></td></tr> "));
            using (MemoryStream ms = new MemoryStream())
            {
                // XML document generated by iText
                SimpleBookmark.ExportToXML(SimpleBookmark.GetBookmark(reader), ms, "UTF-8", false);

                // rewind to create xmlreader
                ms.Position = 0;
                using (XmlReader xr = XmlReader.Create(ms))
                {
                    xr.MoveToContent();
                    string page = null;
                    string text = null;

                    string format = @"<tr><td width='80%'>{0}</td>
            <td align='right' width='10%'>{1}</td></tr>";

                    // extract page number from 'Page' attribute
                    Regex re = new Regex(@"^\d+");
                    while (xr.Read())
                    {
                        if (xr.NodeType == XmlNodeType.Element &&
                            xr.Name == "Title" && xr.IsStartElement())
                        {
                            page = re.Match(xr.GetAttribute("Page")).Captures[0].Value;
                            xr.Read();

                            if (xr.NodeType == XmlNodeType.Text)
                            {
                                text = xr.Value.Trim();
                                int pageSection = int.Parse(page) + 1;
                                sb.Append(String.Format(format, text, pageSection.ToString()));
                            }
                        }
                    }
                }
            }

            sb.Append("</table>");

            MemoryStream workStream = new MemoryStream();
            var          document   = new Document(reader.GetPageSizeWithRotation(1));
            var          writer     = PdfWriter.GetInstance(document, workStream);

            writer.CloseStream = false;

            document.Open();
            document.NewPage();

            // Add TOC
            //StyleSheet styles = new StyleSheet();
            //styles.LoadTagStyle("h2", HtmlTags.ALIGN_MIDDLE, "center");
            //styles.LoadTagStyle("h2", HtmlTags.COLOR, "#F90");


            StyleSheet style = new StyleSheet();

            style.LoadTagStyle(HtmlTags.DIV, HtmlTags.WIDTH, "220px");
            style.LoadTagStyle(HtmlTags.DIV, HtmlTags.HEIGHT, "80px");
            style.LoadTagStyle(HtmlTags.DIV, HtmlTags.BGCOLOR, "@eeeeee");
            style.LoadStyle("address", "style", "font-size: 8px; text-align: justify; font-family: Arial, Helvetica, sans-serif;");
            style.LoadStyle("largeName", "style", "font-size: 10px; text-align: justify; font-family: Arial, Helvetica, sans-serif;");
            style.LoadStyle("description", "style", "font-size: 8px; text-align: justify; font-family: Arial, Helvetica, sans-serif;");


            foreach (IElement element in HTMLWorker.ParseToList(new StringReader(sb.ToString()), style))
            {
                document.Add(element);
            }

            // Append your chapter content again
            Chapter chapter = CreateChapterContent(html);

            document.Add(chapter);

            document.Close();
            writer.Close();

            byte[] byteInfo = workStream.ToArray();
            workStream.Write(byteInfo, 0, byteInfo.Length);
            workStream.Position = 0;

            return(byteInfo);
        }
 public DamageIndicator()
 {
     Current    = this;
     StyleSheet = StyleSheet.FromFile("/ui/DamageIndicator.scss");
 }
Exemple #35
0
 CssObfuscator(StyleSheet css, Obfuscator ob)
 {
     this.css = css;
     this.ob = ob;
 }
    private void SetColor(StyleSheet.StyleSheetDeclaration rule)
    {
        if (IgnoreStyle)
            return;

        Text t1 = this.GetComponent<Text>();
        if (t1 != null)
        {
            t1.color = rule.ValueColor;
        }
        Image i1 = this.GetComponent<Image>();
        if (i1 != null)
        {
            i1.color = rule.ValueColor;
        }

        Button b1 = this.GetComponent<Button>();
        if (b1 != null) // has actual pressed value
        {
            if (b1.targetGraphic != null)
            {
                ColorBlock buttonColors = new ColorBlock()
                {
                    normalColor = rule.ValueColor,
                    highlightedColor = rule.ValueColor,
                    pressedColor = rule.ValuePressedColor,
                    colorMultiplier = 1,
                    fadeDuration = 0.13f
                };

                if (i1 != null)
                {
                    i1.color = Color.white;
                }

                b1.colors = buttonColors;
            }
        }
    }
Exemple #37
0
 public void ResolveTo(StyleSheet dest)
 {
     Resolve();
     PopulateSheet(dest, Rules.Values, Options);
 }
Exemple #38
0
        public TinyMCE(IData Data, string Configuration)
        {
            _data = Data;
            try
            {
                string[] configSettings = Configuration.Split("|".ToCharArray());

                if (configSettings.Length > 0)
                {
                    _editorButtons = configSettings[0];

                    if (configSettings.Length > 1)
                    {
                        if (configSettings[1] == "1")
                        {
                            _enableContextMenu = true;
                        }
                    }

                    if (configSettings.Length > 2)
                    {
                        _advancedUsers = configSettings[2];
                    }

                    if (configSettings.Length > 3)
                    {
                        if (configSettings[3] == "1")
                        {
                            _fullWidth = true;
                        }
                        else if (configSettings[4].Split(',').Length > 1)
                        {
                            _width  = int.Parse(configSettings[4].Split(',')[0]);
                            _height = int.Parse(configSettings[4].Split(',')[1]);
                        }
                    }

                    // default width/height
                    if (_width < 1)
                    {
                        _width = 500;
                    }
                    if (_height < 1)
                    {
                        _height = 400;
                    }

                    // add stylesheets
                    if (configSettings.Length > 4)
                    {
                        foreach (string s in configSettings[5].Split(",".ToCharArray()))
                        {
                            _stylesheets.Add(s);
                        }
                    }

                    if (configSettings.Length > 6 && configSettings[6] != "")
                    {
                        _showLabel = bool.Parse(configSettings[6]);
                    }

                    if (configSettings.Length > 7 && configSettings[7] != "")
                    {
                        m_maxImageWidth = int.Parse(configSettings[7]);
                    }

                    // sizing
                    if (!_fullWidth)
                    {
                        config.Add("width", _width.ToString());
                        config.Add("height", _height.ToString());
                    }

                    if (_enableContextMenu)
                    {
                        _plugins += ",contextmenu";
                    }


                    // If the editor is used in umbraco, use umbraco's own toolbar
                    bool onFront = false;
                    if (GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current))
                    {
                        config.Add("theme_umbraco_toolbar_location", "external");
                        config.Add("skin", "umbraco");
                        config.Add("inlinepopups_skin ", "umbraco");
                    }
                    else
                    {
                        onFront = true;
                        config.Add("theme_umbraco_toolbar_location", "top");
                    }

                    // load plugins
                    IDictionaryEnumerator pluginEnum = tinyMCEConfiguration.Plugins.GetEnumerator();
                    while (pluginEnum.MoveNext())
                    {
                        var plugin = (tinyMCEPlugin)pluginEnum.Value;
                        if (plugin.UseOnFrontend || (!onFront && !plugin.UseOnFrontend))
                        {
                            _plugins += "," + plugin.Name;
                        }
                    }

                    // add the umbraco overrides to the end
                    // NB: It is !!REALLY IMPORTANT!! that these plugins are added at the end
                    // as they make runtime modifications to default plugins, so require
                    // those plugins to be loaded first.
                    _plugins += ",umbracopaste,umbracolink,umbracocontextmenu";

                    if (_plugins.StartsWith(","))
                    {
                        _plugins = _plugins.Substring(1, _plugins.Length - 1);
                    }
                    if (_plugins.EndsWith(","))
                    {
                        _plugins = _plugins.Substring(0, _plugins.Length - 1);
                    }

                    config.Add("plugins", _plugins);

                    // Check advanced settings
                    if (UmbracoEnsuredPage.CurrentUser != null && ("," + _advancedUsers + ",").IndexOf("," + UmbracoEnsuredPage.CurrentUser.UserType.Id + ",") >
                        -1)
                    {
                        config.Add("umbraco_advancedMode", "true");
                    }
                    else
                    {
                        config.Add("umbraco_advancedMode", "false");
                    }

                    // Check maximum image width
                    config.Add("umbraco_maximumDefaultImageWidth", m_maxImageWidth.ToString());

                    // Styles
                    string cssFiles = String.Empty;
                    string styles   = string.Empty;
                    foreach (string styleSheetId in _stylesheets)
                    {
                        if (styleSheetId.Trim() != "")
                        {
                            try
                            {
                                //TODO: Fix this, it will no longer work!
                                var s = StyleSheet.GetStyleSheet(int.Parse(styleSheetId), false, false);

                                if (s.nodeObjectType == StyleSheet.ModuleObjectType)
                                {
                                    cssFiles += IOHelper.ResolveUrl(SystemDirectories.Css + "/" + s.Text + ".css");

                                    foreach (StylesheetProperty p in s.Properties)
                                    {
                                        if (styles != string.Empty)
                                        {
                                            styles += ";";
                                        }
                                        if (p.Alias.StartsWith("."))
                                        {
                                            styles += p.Text + "=" + p.Alias;
                                        }
                                        else
                                        {
                                            styles += p.Text + "=" + p.Alias;
                                        }
                                    }

                                    cssFiles += ",";
                                }
                            }
                            catch (Exception ee)
                            {
                                LogHelper.Error <TinyMCE>("Error adding stylesheet to tinymce Id:" + styleSheetId, ee);
                            }
                        }
                    }
                    // remove any ending comma (,)
                    if (!string.IsNullOrEmpty(cssFiles))
                    {
                        cssFiles = cssFiles.TrimEnd(',');
                    }

                    // language
                    string userLang = (UmbracoEnsuredPage.CurrentUser != null) ?
                                      (User.GetCurrent().Language.Contains("-") ?
                                       User.GetCurrent().Language.Substring(0, User.GetCurrent().Language.IndexOf("-")) : User.GetCurrent().Language)
                        : "en";
                    config.Add("language", userLang);

                    config.Add("content_css", cssFiles);
                    config.Add("theme_umbraco_styles", styles);

                    // Add buttons
                    IDictionaryEnumerator ide = tinyMCEConfiguration.Commands.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        var cmd = (tinyMCECommand)ide.Value;
                        if (_editorButtons.IndexOf("," + cmd.Alias + ",") > -1)
                        {
                            _activateButtons += cmd.Alias + ",";
                        }
                        else
                        {
                            _disableButtons += cmd.Alias + ",";
                        }
                    }

                    if (_activateButtons.Length > 0)
                    {
                        _activateButtons = _activateButtons.Substring(0, _activateButtons.Length - 1);
                    }
                    if (_disableButtons.Length > 0)
                    {
                        _disableButtons = _disableButtons.Substring(0, _disableButtons.Length - 1);
                    }

                    // Add buttons
                    initButtons();
                    _activateButtons = "";

                    int separatorPriority = 0;
                    ide = _mceButtons.GetEnumerator();
                    while (ide.MoveNext())
                    {
                        string mceCommand  = ide.Value.ToString();
                        var    curPriority = (int)ide.Key;

                        // Check priority
                        if (separatorPriority > 0 &&
                            Math.Floor(decimal.Parse(curPriority.ToString()) / 10) >
                            Math.Floor(decimal.Parse(separatorPriority.ToString()) / 10))
                        {
                            _activateButtons += "separator,";
                        }

                        _activateButtons += mceCommand + ",";

                        separatorPriority = curPriority;
                    }


                    config.Add("theme_umbraco_buttons1", _activateButtons);
                    config.Add("theme_umbraco_buttons2", "");
                    config.Add("theme_umbraco_buttons3", "");
                    config.Add("theme_umbraco_toolbar_align", "left");
                    config.Add("theme_umbraco_disable", _disableButtons);

                    config.Add("theme_umbraco_path ", "true");
                    config.Add("extended_valid_elements", "div[*]");
                    config.Add("document_base_url", "/");
                    config.Add("relative_urls", "false");
                    config.Add("remove_script_host", "true");
                    config.Add("event_elements", "div");
                    config.Add("paste_auto_cleanup_on_paste", "true");

                    config.Add("valid_elements",
                               tinyMCEConfiguration.ValidElements.Substring(1,
                                                                            tinyMCEConfiguration.ValidElements.Length -
                                                                            2));
                    config.Add("invalid_elements", tinyMCEConfiguration.InvalidElements);

                    // custom commands
                    if (tinyMCEConfiguration.ConfigOptions.Count > 0)
                    {
                        ide = tinyMCEConfiguration.ConfigOptions.GetEnumerator();
                        while (ide.MoveNext())
                        {
                            config.Add(ide.Key.ToString(), ide.Value.ToString());
                        }
                    }

                    //if (HttpContext.Current.Request.Path.IndexOf(Umbraco.Core.IO.SystemDirectories.Umbraco) > -1)
                    //    config.Add("language", User.GetUser(BasePage.GetUserId(BasePage.umbracoUserContextID)).Language);
                    //else
                    //    config.Add("language", System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);

                    if (_fullWidth)
                    {
                        config.Add("auto_resize", "true");
                        base.Columns = 30;
                        base.Rows    = 30;
                    }
                    else
                    {
                        base.Columns = 0;
                        base.Rows    = 0;
                    }
                    EnableViewState = false;
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Incorrect TinyMCE configuration.", "Configuration", ex);
            }
        }
        public bool SaveNewDocument(string uxmlPath, string ussPath, VisualElement documentRootElement, bool isSaveAs)
        {
            if (!isSaveAs)
            {
                var ussInstanceId = mainStyleSheet.GetInstanceID().ToString();
                m_VisualTreeAsset.FixStyleSheetPaths(ussInstanceId, ussPath);

                // Fix old paths if the uss filename/path has since been changed.
                m_VisualTreeAsset.ReplaceStyleSheetPaths(ussOldPath, ussPath);

#if UNITY_2019_3_OR_NEWER
                AddStyleSheetToAllRootElements(ussPath);
#endif
            }
            else
            {
                visualTreeAsset.ReplaceStyleSheetPaths(ussOldPath, ussPath);
            }

            var tempVisualTreeAsset = m_VisualTreeAsset.DeepCopy();
            var tempMainStyleSheet  = m_MainStyleSheet.DeepCopy();

            WriteToFiles(uxmlPath, ussPath);
            AssetDatabase.Refresh();

            var loadedVisualTreeAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(uxmlPath);
            var loadedStyleSheet      = AssetDatabase.LoadAssetAtPath <StyleSheet>(ussPath);

            bool needFullRefresh =
                loadedVisualTreeAsset != m_VisualTreeAsset ||
                loadedStyleSheet != m_MainStyleSheet;

            if (needFullRefresh)
            {
                NewDocument(documentRootElement);

                // Re-init setting.
                if (m_Settings != null)
                {
                    m_Settings.UxmlGuid = AssetDatabase.AssetPathToGUID(uxmlPath);
                    m_Settings.UxmlPath = uxmlPath;
                    SaveSettingsToDisk();
                }
            }
            else
            {
                m_VisualTreeAsset.ClearUndo();
                m_MainStyleSheet.ClearUndo();
                ClearBackups();
            }

            // Recreate backups.
            m_VisualTreeAssetBackup = loadedVisualTreeAsset.DeepCopy();
            m_MainStyleSheetBackup  = loadedStyleSheet.DeepCopy();

            // To get all the selection markers into the new assets.
            tempVisualTreeAsset.DeepOverwrite(loadedVisualTreeAsset);
            tempMainStyleSheet.DeepOverwrite(loadedStyleSheet);

            // Destroy temps.
            tempVisualTreeAsset.Destroy();
            tempMainStyleSheet.Destroy();

            m_VisualTreeAsset = loadedVisualTreeAsset;
            m_MainStyleSheet  = loadedStyleSheet;

            // Reset asset name.
            m_VisualTreeAsset.name = Path.GetFileNameWithoutExtension(uxmlPath);

            m_VisualTreeAsset.ConvertAllAssetReferencesToPaths();

            m_OpenendMainStyleSheetOldPath = ussPath;

            hasUnsavedChanges = false;

            SaveToDisk();

            return(needFullRefresh);
        }
        public static bool IsSelected(this StyleSheet styleSheet)
        {
            var selector = styleSheet.FindSelector(BuilderConstants.SelectedStyleSheetSelectorName);

            return(selector != null);
        }
Exemple #41
0
        private string PreprocessorSorting(StyleSheet stylesheet)
        {
            StringBuilder sb = new StringBuilder(stylesheet.Text);

            var visitor = new CssItemCollector<CssRuleBlock>(true);
            stylesheet.Accept(visitor);

            foreach (var rule in visitor.Items.Where(r => r.IsValid).Reverse())
            {
                if (rule.Children.Count < 2)
                    continue;

                int start = rule.OpenCurlyBrace.AfterEnd;
                int length = rule.Length - 1;

                length = AdjustLength(rule, start, length);

                if (length < 1)
                    continue;

                string text = GetNormalizedText(rule, start, length);

                string[] declarations = text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                //.Where(t => !string.IsNullOrWhiteSpace(t)).ToArray();

                var sorted = SortDeclarations2(declarations);

                sb.Remove(start, length - 1);
                sb.Insert(start, string.Join("", sorted));
            }

            return sb.ToString();
        }
        public static void TransferRulePropertiesToSelector(this StyleSheet toStyleSheet, StyleComplexSelector toSelector, StyleSheet fromStyleSheet, StyleRule fromRule)
        {
            foreach (var property in fromRule.properties)
            {
                var newProperty = toStyleSheet.AddProperty(toSelector, property.name);
                foreach (var value in property.values)
                {
                    switch (value.valueType)
                    {
                    case StyleValueType.Float: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetFloat(value)); break;

                    case StyleValueType.Dimension: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetDimension(value)); break;

                    case StyleValueType.Enum: toStyleSheet.AddValueAsEnum(newProperty, fromStyleSheet.GetEnum(value)); break;

                    case StyleValueType.String: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetString(value)); break;

                    case StyleValueType.Color: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetColor(value)); break;

                    case StyleValueType.AssetReference: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetAsset(value)); break;

                    case StyleValueType.ResourcePath: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetAsset(value)); break;

                    case StyleValueType.Variable: toStyleSheet.AddVariable(newProperty, fromStyleSheet.GetString(value)); break;

                    case StyleValueType.Keyword: toStyleSheet.AddValue(newProperty, fromStyleSheet.GetKeyword(value)); break;
                    }
                }
            }
            foreach (var property in fromRule.properties)
            {
                fromStyleSheet.RemoveProperty(fromRule, property);
            }
        }
        public static string ValueHandleToUssString(StyleSheet sheet, UssExportOptions options, string propertyName, StyleValueHandle handle)
        {
            string str = "";

            switch (handle.valueType)
            {
            case StyleValueType.Keyword:
                str = sheet.ReadKeyword(handle).ToString().ToLower();
                break;

            case StyleValueType.Float:
            {
                var num = sheet.ReadFloat(handle);
                if (num == 0)
                {
                    str = "0";
                }
                else
                {
                    str = num.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    if (IsLength(propertyName))
                    {
                        str += "px";
                    }
                }
            }
            break;

            case StyleValueType.Dimension:
                var dim = sheet.ReadDimension(handle);
                if (dim.value == 0)
                {
                    str = "0";
                }
                else
                {
                    str = dim.ToString();
                }
                break;

            case StyleValueType.Color:
                UnityEngine.Color color = sheet.ReadColor(handle);
                str = ToUssString(color, options.useColorCode);
                break;

            case StyleValueType.ResourcePath:
                str = $"resource('{sheet.ReadResourcePath(handle)}')";
                break;

            case StyleValueType.Enum:
                str = sheet.ReadEnum(handle);
                break;

            case StyleValueType.String:
                str = $"\"{sheet.ReadString(handle)}\"";
                break;

#if !UNITY_2019_4 && !UNITY_2020_1
            case StyleValueType.MissingAssetReference:
                str = $"url('{sheet.ReadMissingAssetReferenceUrl(handle)}')";
                break;
#endif
            case StyleValueType.AssetReference:
                var assetRef  = sheet.ReadAssetReference(handle);
                var assetPath = AssetDatabase.GetAssetPath(assetRef);
                if (assetPath.StartsWith("Assets") || assetPath.StartsWith("Packages"))
                {
                    assetPath = "/" + assetPath;
                }
#if !UI_BUILDER_PACKAGE || UNITY_2021_1_OR_NEWER
                if (assetRef is Sprite)
                {
                    assetPath += "#" + assetRef.name;
                }
#endif
                str = assetRef == null ? "none" : $"url('{assetPath}')";
                break;

            case StyleValueType.Variable:
                str = sheet.ReadVariable(handle);
                break;

            default:
                throw new ArgumentException("Unhandled type " + handle.valueType);
            }
            return(str);
        }
Exemple #44
0
        public IList <IDomElement <TDependencyObject> > QuerySelectorAll(StyleSheet styleSheet, ISelector selector)
        {
            // var selector = cachedSelectorProvider.GetOrAdd(selectors);

            return(ChildNodes.QuerySelectorAll(styleSheet, selector));
        }
        public void TestCleanRealHiddenTextWithStyles()
        {
            List<TriggeringNodeDefinition> existingTriggers = DocxMetadataDefinitions.HiddenDocumentText;

            using (Stream from = File.Open(TESTFILE_DIR + "hidden_styles.xml", FileMode.Open))
            {
                StyleSheet sr = new StyleSheet(new CommonNamespaces(OpenXmlFormat.Transitional));
                sr.ConnectToInputStream(from);
                sr.Execute();
                sr.Resolve();

                List<TriggeringNodeDefinition> newTriggers = sr.GenerateStyleTriggers(existingTriggers);
                foreach (TriggeringNodeDefinition tnd in newTriggers)
                {
                    existingTriggers.Add(tnd);
                }
            }

            using (Stream from2 = File.Open(TESTFILE_DIR + "hidden_styles_document.xml", FileMode.Open))
            {
                StateMachineBasedXmlFilter xfb = new StateMachineBasedXmlFilter(new CommonNamespaces(OpenXmlFormat.Transitional));
                xfb.ConnectToInputStream(from2);

                MemoryStream ms = new MemoryStream();
                xfb.ConnectToOutputStream(ms);

                foreach (TriggeringNodeDefinition tnd in existingTriggers)
                {
                    xfb.AddNodeToTriggerList(tnd);
                }

                DocumentText dt = xfb.DocumentText;
                xfb.Execute();

                ms.Position = 0;
                XmlDocument doc = new XmlDocument();
                doc.Load(ms);

                XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
                CommonNamespaces cns = xfb.CommonNamespaces;
                nsmgr.AddNamespace("w", cns.GetAtomicName(NamespaceId.w));

                XmlNodeList nodes = doc.SelectNodes("//w:r/w:t", nsmgr);
                StringBuilder bld = new StringBuilder();
                foreach (XmlNode node in nodes)
                {
                    bld.Append(node.InnerText);
                }

                Assert.AreEqual("non-hiddennon-hidden styleThis para non-hidden. unhidden text anti-hidden style", bld.ToString(), "oops, didn't clean correctly - probably lots to do with w:r's going missing");

                DocxTestUtilities.ValidateDocxMainStream(doc, TESTFILE_DIR);

            }
        }
Exemple #46
0
        //public string LookupNamespaceUri(string prefix)
        //{
        //    return namespaceProvider.LookupNamespaceUri(this, prefix);
        //}

        //public string LookupPrefix(string namespaceUri)
        //{
        //    return namespaceProvider.LookupPrefix(this, namespaceUri);
        //}

        public MatchResult Matches(StyleSheet styleSheet, ISelector selector)
        {
            return(selector.Match(styleSheet, this));
        }
Exemple #47
0
 public SeekerBlackout()
 {
     StyleSheet.Load("/ui/SeekerBlackout.scss");
 }
Exemple #48
0
        public Boolean HTMLToPDF(string html, String fileName)
        {
            Boolean isOK = false;

            try
            {
                //  FontFactory.RegisterFamily("宋体", "simsun", @"c:\windows\fonts\SIMSUN.TTC,0");
                TextReader reader = new StringReader(html);
                // step 1: creation of a document-object
                //  Document document = new Document(PageSize.A4.Rotate(), 30, 30, 30, 30);
                Document document = new Document(PageSize.A4, 30, 30, 36, 36);//左右上下
                // step 2:
                // we create a writer that listens to the document
                // and directs a XML-stream to a file
                fileName = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\PDF\\" + fileName + ".pdf";
                FileStream fs     = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                PdfWriter  writer = PdfWriter.GetInstance(document, fs);
                HTMLWorker worker = new HTMLWorker(document);
                document.Open();

                document.AddTitle("创利投网站金融平台");
                document.AddAuthor("创利投");
                document.AddCreationDate();
                document.AddHeader("p2p合同", "p2p合同");
                document.AddCreator("创利投科技发展有限公司");
                document.AddKeywords("P2B合同");
                document.AddSubject("创利投四方合同");
                document.AddProducer();

                writer.PageEvent = new HeaderAndFooterEvent();
                HeaderAndFooterEvent.PAGE_NUMBER = true; //不实现页眉跟页脚
                First(document, writer);                 //封面页

                worker.StartDocument();
                StyleSheet css = new StyleSheet();
                Dictionary <String, Object> font = new Dictionary <string, object>();
                font.Add(HTMLWorker.FONT_PROVIDER, new MyFontFactory());
                Dictionary <String, String> dict = new Dictionary <string, string>();
                dict.Add(HtmlTags.BGCOLOR, "#01366C");
                dict.Add(HtmlTags.COLOR, "#00ff00");
                dict.Add(HtmlTags.SIZE, "25");
                css.LoadStyle("css", dict);

                List <IElement> p = HTMLWorker.ParseToList(reader, css, font);
                // List<IElement> p = HTMLWorker.ParseToList(reader, css);
                for (int k = 0; k < p.Count; k++)
                {
                    document.Add((IElement)p[k]);
                }
                worker.EndDocument();
                writer.Flush();
                writer.CloseStream = true;
                worker.Close();
                document.Close();
                reader.Close();
                isOK = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                isOK = false;
            }
            finally
            {
            }
            return(isOK);
        }
Exemple #49
0
        public override DependencyObject CreateTrigger(StyleSheet styleSheet, ITrigger trigger, Type targetType, DependencyObject styleResourceReferenceHolder)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException(nameof(trigger));
            }

            if (trigger is Trigger)
            {
                return("PropertyTrigger".Measure(() =>
                {
                    var propertyTrigger = trigger as Trigger;
                    var nativeTrigger = new System.Windows.Trigger();

                    var dependencyProperty = dependencyService.GetDependencyProperty(targetType, propertyTrigger.Property);
                    if (dependencyProperty == null)
                    {
                        throw new NullReferenceException($"Property '{propertyTrigger.Property}' may not be null (targetType '{targetType.Name}')!");
                    }

                    nativeTrigger.Property = dependencyProperty;
                    nativeTrigger.Value = dependencyService.GetDependencyPropertyValue(targetType, nativeTrigger.Property.Name, nativeTrigger.Property, propertyTrigger.Value);
                    "StyleDeclarationBlock".Measure(() =>
                    {
                        foreach (var styleDeclaration in propertyTrigger.StyleDeclarationBlock)
                        {
                            var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property);
                            if (propertyInfo == null)
                            {
                                continue;
                            }
                            try
                            {
                                var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces);
                                if (value == null)
                                {
                                }
                                nativeTrigger.Setters.Add(new Setter {
                                    Property = propertyInfo.Property, Value = value
                                });
                            }
                            catch (Exception e)
                            {
                                styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}");
                            }
                        }
                    });

                    $"EnterActions ({propertyTrigger.EnterActions.Count})".Measure(() =>
                    {
                        foreach (var action in propertyTrigger.EnterActions)
                        {
                            try
                            {
                                var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                                nativeTrigger.EnterActions.Add(nativeTriggerAction);
                            }
                            catch (Exception e)
                            {
                                styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" enter action: {e.Message}");
                            }
                        }
                    });
                    $"ExitActions ({propertyTrigger.ExitActions.Count})".Measure(() =>
                    {
                        foreach (var action in propertyTrigger.ExitActions)
                        {
                            try
                            {
                                var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                                nativeTrigger.ExitActions.Add(nativeTriggerAction);
                            }
                            catch (Exception e)
                            {
                                styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" exit action: {e.Message}");
                            }
                        }
                    });

                    return nativeTrigger;
                }));
            }
            else if (trigger is DataTrigger)
            {
                return("DataTrigger".Measure(() =>
                {
                    var dataTrigger = trigger as DataTrigger;
                    var nativeTrigger = new System.Windows.DataTrigger();

                    string expression = null;
                    if (typeNameResolver.IsMarkupExtension(dataTrigger.Binding))
                    {
                        expression = typeNameResolver.CreateMarkupExtensionExpression(dataTrigger.Binding);
                    }
                    else
                    {
                        expression = "{Binding " + dataTrigger.Binding + "}";
                    }

                    var binding = (System.Windows.Data.BindingBase)markupExtensionParser.ProvideValue(expression, null, styleSheet.Namespaces);
                    nativeTrigger.Binding = binding;

                    nativeTrigger.Value = GetBasicValue(dataTrigger);

                    foreach (var styleDeclaration in dataTrigger.StyleDeclarationBlock)
                    {
                        try
                        {
                            var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property);
                            if (propertyInfo == null)
                            {
                                continue;
                            }

                            var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces);
                            if (value == null)
                            {
                            }
                            nativeTrigger.Setters.Add(new Setter {
                                Property = propertyInfo.Property, Value = value
                            });
                        }
                        catch (Exception e)
                        {
                            styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}");
                        }
                    }

                    foreach (var action in dataTrigger.EnterActions)
                    {
                        try
                        {
                            var info = $"{action.Action} {string.Join(", ", action.Parameters.Select(x => x.Property + ": " + x.Value))}";
                            $"measure {info}".Measure(() =>
                            {
                                $"CreateTriggerAction outer {info}".Measure(() =>
                                {
                                    System.Windows.TriggerAction nativeTriggerAction = null;

                                    $"CreateTriggerAction {info}".Measure(() => nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action));

                                    $"Add to EnterActions {info}".Measure(() => nativeTrigger.EnterActions.Add(nativeTriggerAction));
                                });
                            });
                        }
                        catch (Exception e)
                        {
                            styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" enter action: {e.Message}");
                        }
                    }

                    foreach (var action in dataTrigger.ExitActions)
                    {
                        try
                        {
                            var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                            nativeTrigger.ExitActions.Add(nativeTriggerAction);
                        }
                        catch (Exception e)
                        {
                            styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" exit action: {e.Message}");
                        }
                    }

                    return nativeTrigger;
                }));
            }
            else if (trigger is EventTrigger)
            {
                return("EventTrigger".Measure(() =>
                {
                    var eventTrigger = trigger as EventTrigger;
                    var nativeTrigger = new System.Windows.EventTrigger();

                    nativeTrigger.RoutedEvent = (RoutedEvent)TypeHelpers.GetFieldValue(targetType, eventTrigger.Event + "Event");
                    "Actions".Measure(() =>
                    {
                        foreach (var action in eventTrigger.Actions)
                        {
                            try
                            {
                                var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                                nativeTrigger.Actions.Add(nativeTriggerAction);
                            }
                            catch (Exception e)
                            {
                                styleSheet.Errors.Add($@"ERROR in event trigger ""{eventTrigger.Event} {action.Action}"": {e.Message}");
                            }
                        }
                    });

                    return nativeTrigger;
                }));
            }

            throw new NotSupportedException($"Trigger '{trigger.GetType().FullName}' is not supported!");
        }
Exemple #50
0
        public static string generateOutputFile(enumOutputType outputType, string strTemplate, StyleSheet Style, int SwitchID, enumSwitchType SwitchType)
        {
            try
            {
                clsClient client = new clsClient(HttpContext.Current.Session["requestclientid"].ToString());
                switch (outputType)
                {
                case enumOutputType.PDF:
                    string Path    = HttpContext.Current.Server.MapPath("~/Output/PDF/");
                    string PDFPath = string.Format("{0}{1}_{2}_{3}_{4:yyyy-MM-dd}.pdf",
                                                   Path,
                                                   SwitchType.ToString(),
                                                   (new clsIFA(int.Parse(HttpContext.Current.Session["ifaid"].ToString()))).propIFA_Name,
                                                   client.propForename + " " + client.propSurname,
                                                   DateTime.Now);

                    using (clsPDF O = new clsPDF()
                    {
                        StyleSheet = Style
                    })
                    {
                        O.PageSetup(PageSize.LETTER, 40, 40, 30, 15);
                        O.FromHTMLString(strTemplate);
                        O.StartCreate(PDFPath);
                        LogOutput(enumSwitchType.Portfolio, SwitchID, PDFPath, enumOutputType.PDF);
                    }
                    return(PDFPath);

                default:
                    return("");
                }
            }
            catch (System.Net.Mail.SmtpException SE)
            {
                throw new clsOutputException(SE.Message, SE);
            }
            catch (Exception ex) { throw new clsOutputException(ex.Message, ex); }
        }
Exemple #51
0
        private static List <Value> ToValues(StyleValueHandle[] sourceValues, int from, int to, StyleSheet srcSheet)
        {
            int argCount     = sourceValues.Length;
            var parsedValues = new List <Value>(argCount);

            for (int i = from; i < to; ++i)
            {
                var valueHandle = sourceValues[i];
                if (valueHandle.valueType == StyleValueType.Function)
                {
                    parsedValues.Add(ParseFunction(sourceValues, srcSheet, valueHandle, ref i));
                }
                else
                {
                    parsedValues.Add(new Value(valueHandle.valueType, GetPropertyValue(valueHandle, srcSheet)));
                }
            }

            return(parsedValues);
        }
Exemple #52
0
 public void Setup()
 {
     CssParser.defaultCssNamespace = "XamlCSS.Tests.Dom, XamlCSS.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null";
     defaultStyleSheet             = CssParser.Parse(@"@namespace ui ""XamlCSS.Tests.Dom, XamlCSS.Tests, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"";");
 }
Exemple #53
0
 private static List <Value> ToValues(StyleProperty srcProp, StyleSheet srcSheet)
 {
     return(ToValues(srcProp.values, 0, srcProp.values.Length, srcSheet));
 }
Exemple #54
0
 public NameTags()
 {
     StyleSheet.Load("/ui/element/nametags/NameTags.scss");
 }
Exemple #55
0
 public static void SetStyleSheet(BindableObject obj, StyleSheet value)
 {
     obj.SetValue(StyleSheetProperty, value);
 }
Exemple #56
0
        public override BindableObject CreateTrigger(StyleSheet styleSheet, ITrigger trigger, Type targetType, BindableObject styleResourceReferenceHolder)
        {
            if (trigger == null)
            {
                throw new ArgumentNullException(nameof(trigger));
            }

            if (trigger is Trigger)
            {
                var propertyTrigger = trigger as Trigger;
                var nativeTrigger   = new Xamarin.Forms.Trigger(targetType);

                var bindableProperty = dependencyService.GetDependencyProperty(targetType, propertyTrigger.Property);
                if (bindableProperty == null)
                {
                    throw new NullReferenceException($"Property '{propertyTrigger.Property}' may not be null (targetType '{targetType.Name}')!");
                }

                nativeTrigger.Property = bindableProperty;
                nativeTrigger.Value    = dependencyService.GetDependencyPropertyValue(targetType, nativeTrigger.Property.PropertyName, nativeTrigger.Property, propertyTrigger.Value);

                foreach (var styleDeclaration in propertyTrigger.StyleDeclarationBlock)
                {
                    var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property);
                    if (propertyInfo == null)
                    {
                        continue;
                    }
                    try
                    {
                        var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces);

                        nativeTrigger.Setters.Add(new Setter {
                            Property = propertyInfo.Property, Value = value
                        });
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}");
                    }
                }

                foreach (var action in propertyTrigger.EnterActions)
                {
                    try
                    {
                        var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                        nativeTrigger.EnterActions.Add(nativeTriggerAction);
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" enter action: {e.Message}");
                    }
                }

                foreach (var action in propertyTrigger.ExitActions)
                {
                    try
                    {
                        var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                        nativeTrigger.ExitActions.Add(nativeTriggerAction);
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in property trigger ""{propertyTrigger.Property} {propertyTrigger.Value}"" exit action: {e.Message}");
                    }
                }

                return(nativeTrigger);
            }
            else if (trigger is DataTrigger)
            {
                var dataTrigger   = trigger as DataTrigger;
                var nativeTrigger = new Xamarin.Forms.DataTrigger(targetType);

                string expression = null;
                if (typeNameResolver.IsMarkupExtension(dataTrigger.Binding))
                {
                    expression = typeNameResolver.CreateMarkupExtensionExpression(dataTrigger.Binding);
                }
                else
                {
                    expression = "{Binding " + dataTrigger.Binding + "}";
                }

                var binding = (Binding)markupExtensionParser.ProvideValue(expression, null, styleSheet.Namespaces);
                nativeTrigger.Binding = binding;

                nativeTrigger.Value = GetBasicValue(dataTrigger);

                foreach (var styleDeclaration in dataTrigger.StyleDeclarationBlock)
                {
                    try
                    {
                        var propertyInfo = typeNameResolver.GetDependencyPropertyInfo(styleSheet.Namespaces, targetType, styleDeclaration.Property);
                        if (propertyInfo == null)
                        {
                            continue;
                        }

                        var value = typeNameResolver.GetPropertyValue(propertyInfo.DeclaringType, styleResourceReferenceHolder, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, styleSheet.Namespaces);

                        nativeTrigger.Setters.Add(new Setter {
                            Property = propertyInfo.Property, Value = value
                        });
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {styleDeclaration.Property}: {styleDeclaration.Value}"": {e.Message}");
                    }
                }

                foreach (var action in dataTrigger.EnterActions)
                {
                    try
                    {
                        var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                        nativeTrigger.EnterActions.Add(nativeTriggerAction);
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" enter action: {e.Message}");
                    }
                }

                foreach (var action in dataTrigger.ExitActions)
                {
                    try
                    {
                        var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                        nativeTrigger.ExitActions.Add(nativeTriggerAction);
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in data trigger ""{dataTrigger.Binding} {dataTrigger.Value} - {action}"" exit action: {e.Message}");
                    }
                }

                return(nativeTrigger);
            }
            else if (trigger is EventTrigger)
            {
                var eventTrigger  = trigger as EventTrigger;
                var nativeTrigger = new Xamarin.Forms.EventTrigger();

                nativeTrigger.Event = eventTrigger.Event;

                foreach (var action in eventTrigger.Actions)
                {
                    try
                    {
                        var nativeTriggerAction = CreateTriggerAction(styleSheet, styleResourceReferenceHolder, action);

                        nativeTrigger.Actions.Add(nativeTriggerAction);
                    }
                    catch (Exception e)
                    {
                        styleSheet.Errors.Add($@"ERROR in event trigger ""{eventTrigger.Event} {action.Action}"": {e.Message}");
                    }
                }

                return(nativeTrigger);
            }

            throw new NotSupportedException($"Trigger '{trigger.GetType().FullName}' is not supported!");
        }
    private void ApplyStyle(StyleSheet.StyleSheetDeclaration specificStyle)
    {
        if (IgnoreStyle)
            return;

        SetColor(specificStyle);
    }
    public DelegateEntryEditor(ExposedDelegateEditor exposedDelegateEditor, DelegateEntry delegateEntry)
    {
        this.exposedDelegateEditor = exposedDelegateEditor;
        this.delegateEntry         = delegateEntry;

        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/UtilityAI/Scripts/Editor/Delegate Entry Editor/DelegateEntryEditor.uxml");

        visualTree.CloneTree(this);

        StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/UtilityAI/Scripts/Editor/Delegate Entry Editor/DelegateEntryEditor.uss");

        this.styleSheets.Add(stylesheet);

        this.AddToClassList("delegateEntryEditor");
        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor.GetType() == typeof(UtilityAIAgentEditor))
        {
            UtilityAIAgentEditor editorWindow = (UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor;
            if (delegateEntry.TargetGO != editorWindow.utilityAIAgent.gameObject)
            {
                delegateEntry.TargetGO = editorWindow.utilityAIAgent.gameObject;
            }
        }

        delegateEntryFoldout = this.Query <Foldout>("delegateEntry");

        delegateEntryFoldout.Query <Toggle>().First().AddToClassList("delegateEntryFoldout");

        Button moveUpButton = this.Query <Button>("moveUpButton").First();

        moveUpButton.BringToFront();
        moveUpButton.clickable.clicked += MoveEntryUp;

        Button moveDownButton = this.Query <Button>("moveDownButton").First();

        moveDownButton.BringToFront();
        moveDownButton.clickable.clicked += MoveEntryDown;

        Button deleteButton = this.Query <Button>("deleteButton").First();

        deleteButton.BringToFront();
        deleteButton.clickable.clicked += DeleteEntry;
        List <Component> components = new List <Component>();

        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIAgentEditor)
        {
            components = delegateEntry.TargetGO.GetComponents <Component>().ToList();
        }
        else if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIActionSetEditor)
        {
            if (((UtilityAIActionSetEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.inheritingGameObject != null)
            {
                components = ((UtilityAIActionSetEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.inheritingGameObject.GetComponents <Component>().ToList();
            }
        }
        if (components.Count > 0)
        {
            int index = 0;
            if (delegateEntry.Target != null)
            {
                List <Component> sharedComponents = components.Where(o => o.GetType() == delegateEntry.Target.GetType()).ToList();
                if (sharedComponents.Count > 0)
                {
                    index = components.IndexOf(sharedComponents[0]);
                }
                else
                {
                    if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIAgentEditor && ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.actionSet != null)
                    {
                        ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.MakeActionsSetUnique();
                        ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).CreateInspectorGUI();
                        return;
                    }
                }
            }
            PopupField <Component> targetComponentField = new PopupField <Component>("Component: ", components, index);

            delegateEntry.Target = targetComponentField.value;
            targetComponentField.RegisterCallback <ChangeEvent <Component> >(
                e =>
            {
                delegateEntry.Target = (Component)e.newValue;
                exposedDelegateEditor.UpdateDelegateEntries();
            }
                );
            delegateEntryFoldout.Add(targetComponentField);
            if (delegateEntry.Target != null)
            {
                Type         selectedComponentType = delegateEntry.Target.GetType();
                BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
                //Get a list of methods attached to the component, and create a dropdown menu:
                List <MethodInfo>       methods           = selectedComponentType.GetMethods(flags).ToList();
                PopupField <MethodInfo> targetMethodField = new PopupField <MethodInfo>("Method: ", methods, methods.Contains(delegateEntry.Method) ? methods.IndexOf(delegateEntry.Method) : 0);
                if (delegateEntry.Method == null || delegateEntry.Method.Name != targetMethodField.value.Name)
                {
                    delegateEntry.SetMethod(selectedComponentType, targetMethodField.value.Name);
                }
                targetMethodField.RegisterCallback <ChangeEvent <MethodInfo> >(
                    e =>
                {
                    delegateEntry.SetMethod(selectedComponentType, e.newValue.Name);
                    exposedDelegateEditor.UpdateDelegateEntries();
                }
                    );
                delegateEntryFoldout.Add(targetMethodField);
                if (delegateEntry.Method != null && delegateEntry.Parameters.Length > 0)
                {
                    Foldout parametersFoldout = new Foldout();
                    parametersFoldout.text = "Parameters: ";

                    foreach (SerializableObject parameter in delegateEntry.Parameters)
                    {
                        if (parameter.obj is int)
                        {
                            IntegerField parameterField = new IntegerField();
                            parameterField.value = (int)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <int> >(
                                e =>
                            {
                                parameter.obj = (int)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is float)
                        {
                            FloatField parameterField = new FloatField();
                            parameterField.value = (float)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <float> >(
                                e =>
                            {
                                parameter.obj = (float)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is bool)
                        {
                            Toggle parameterField = new Toggle();
                            parameterField.value = (bool)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <bool> >(
                                e =>
                            {
                                parameter.obj = (bool)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is string)
                        {
                            TextField parameterField = new TextField();
                            parameterField.value = (string)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <string> >(
                                e =>
                            {
                                parameter.obj = (string)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Vector3)
                        {
                            Vector3Field parameterField = new Vector3Field();
                            parameterField.value = (Vector3)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Vector3> >(
                                e =>
                            {
                                parameter.obj = (Vector3)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Vector2)
                        {
                            Vector2Field parameterField = new Vector2Field();
                            parameterField.value = (Vector2)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Vector2> >(
                                e =>
                            {
                                parameter.obj = (Vector2)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Bounds)
                        {
                            BoundsField parameterField = new BoundsField();
                            parameterField.value = (Bounds)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Bounds> >(
                                e =>
                            {
                                parameter.obj = (Bounds)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Rect)
                        {
                            RectField parameterField = new RectField();
                            parameterField.value = (Rect)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Rect> >(
                                e =>
                            {
                                parameter.obj = (Rect)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Color)
                        {
                            ColorField parameterField = new ColorField();
                            parameterField.value = (Color)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Color> >(
                                e =>
                            {
                                parameter.obj = (Color)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is UnityEngine.Object)
                        {
                            ObjectField parameterField = new ObjectField();
                            parameterField.value = (UnityEngine.Object)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <UnityEngine.Object> >(
                                e =>
                            {
                                parameter.obj = (UnityEngine.Object)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                    }

                    delegateEntryFoldout.Add(parametersFoldout);
                }
            }
        }

        if (delegateEntry.TargetGO != null)
        {
            delegateEntryFoldout.text += delegateEntry.TargetGO.name;
            if (delegateEntry.Target != null)
            {
                delegateEntryFoldout.text += "(" + delegateEntry.Target.GetType() + ") ";
                if (delegateEntry.Method != null)
                {
                    delegateEntryFoldout.text += delegateEntry.Method.Name;
                }
            }
            delegateEntryFoldout.text += ": ";
        }
        else
        {
            delegateEntryFoldout.text = "New Delegate Entry:";
        }
        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIActionSetEditor && components.Count <= 0)
        {
            delegateEntryFoldout.text = "No inheriting object selected!";
        }
    }
Exemple #59
0
 protected override Bound LayoutChildren(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
 {
    return LayoutBehaviour.Dock(stylesheet, this, Childrens, styleBound, maxBound);
 }
Exemple #60
0
        public void DoubleList2()
        {
            var sheet = StyleSheet.Parse(@".form {
  padding-bottom: 3em;
  margin: 15px;
  padding-top: 3em;
  text-align: left;

  .field {
    position: relative;
    margin-bottom: 2em;
  
	label {
      position: absolute;
      opacity: 1;
      visibility: visible;
      display: block;
      font-size: .8em;
      line-height: 14px;
      padding: 0 15px;
      transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out, visibility 0s linear;
      transform: translate(0, -24px);
    }

    &.empty {
      label {
        opacity: 0;
        visibility: hidden;
        transition: transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
        transform: translate(0, -14px);
      }
    }
  }

  textarea { 
    height: 10em !important;
  }

  input,
  textarea {
    display: block;
    font-size: 22px;
    line-height: 40px;
    color: #333;
    width: 100%;
    height: 60px;
    padding: 10px 15px;
    margin: 0;
    border: none;
    box-shadow: none;
    border-radius: 0px;
    border-radius: 2px 2px 0 0;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
  }

  button {
    font-size: 16px;
    border: none;
    color: #fff;
    padding: 12px 50px 9px;
/*    margin-top: 1.3em;*/
    transition: background .2s ease-in-out, border .2s ease-in-out, color .2s ease-in-out;
    border-radius: 2px;
    opacity: 1;
    cursor: pointer;
    -webkit-appearance: none;
    background-size: 200%;
  }

  .message {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    right: 15px;
    top: 15px;
    padding: 7px 15px;
    font-size: .8em;
    line-height: 14px;
    font-style: normal;
    color: rgba(255, 255, 255, 0.8);
    background-color: #ef6469;
    border-radius: 2px;
    opacity: 0;
    transform: translate(0, -34px);
    transition: transform 0.2s ease-in-out, opacity 0.4s ease-in-out;
  }
}");

            sheet.Context.SetCompatibility(BrowserInfo.Chrome26, BrowserInfo.Safari5);

            Assert.Equal(@".form {
  padding-bottom: 3em;
  margin: 15px;
  padding-top: 3em;
  text-align: left;
}
.form .field label {
  position: absolute;
  opacity: 1;
  visibility: visible;
  display: block;
  font-size: 0.8em;
  line-height: 14px;
  padding: 0 15px;
  -webkit-transition: -webkit-transform 0.2s ease-in-out, opacity 0.2s ease-in-out, visibility 0s linear;
  transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out, visibility 0s linear;
  -webkit-transform: translate(0, -24px);
  transform: translate(0, -24px);
}
.form .field.empty label {
  opacity: 0;
  visibility: hidden;
  -webkit-transition: -webkit-transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
  transition: transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
  -webkit-transform: translate(0, -14px);
  transform: translate(0, -14px);
}
.form .field {
  position: relative;
  margin-bottom: 2em;
}
.form textarea { height: 10em !important; }
.form input,
.form textarea {
  display: block;
  font-size: 22px;
  line-height: 40px;
  color: #333;
  width: 100%;
  height: 60px;
  padding: 10px 15px;
  margin: 0;
  border: none;
  -webkit-box-shadow: none;
  box-shadow: none;
  border-radius: 0px;
  border-radius: 2px 2px 0 0;
  -webkit-font-smoothing: antialiased;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.form button {
  font-size: 16px;
  border: none;
  color: #fff;
  padding: 12px 50px 9px;
  -webkit-transition: background 0.2s ease-in-out, border 0.2s ease-in-out, color 0.2s ease-in-out;
  transition: background 0.2s ease-in-out, border 0.2s ease-in-out, color 0.2s ease-in-out;
  border-radius: 2px;
  opacity: 1;
  cursor: pointer;
  -webkit-appearance: none;
  background-size: 200%;
}
.form .message {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  right: 15px;
  top: 15px;
  padding: 7px 15px;
  font-size: 0.8em;
  line-height: 14px;
  font-style: normal;
  color: rgba(255, 255, 255, 0.8);
  background-color: #ef6469;
  border-radius: 2px;
  opacity: 0;
  -webkit-transform: translate(0, -34px);
  transform: translate(0, -34px);
  -webkit-transition: -webkit-transform 0.2s ease-in-out, opacity 0.4s ease-in-out;
  transition: transform 0.2s ease-in-out, opacity 0.4s ease-in-out;
}", sheet.ToString());
        }