Beispiel #1
0
        public static bool IsAProtectedClass(IStylingRule rule)
        {
            var selectorName = rule.DisplaySelectorName;
            var cleansedName = RuleRegistry.StandardizeSelector(selectorName);

            return(cleansedName.IndexOf(":visited", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":hover", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":active", StringComparison.Ordinal) > -1);
        }
        public static SnapshotSpan SnapshotSpanFromRule(ITextBuffer buffer, IStylingRule rule)
        {
            var snapshot = buffer.CurrentSnapshot;
            var span     = new Span(rule.Offset, rule.SelectorLength);

            return(new SnapshotSpan(snapshot, span));
        }
Beispiel #3
0
 public Rectangle CalculateSafeArea(Rectangle parentBoundaries,IStylingRule style, AlignmentContext context)
 {
     var width = style.Width ?? parentBoundaries.Width;
     var height = style.Height ?? parentBoundaries.Height;
     var safeArea =  new Rectangle(
        parentBoundaries.X + (parentBoundaries.Width - context.XAxis.SpaceAvailable)
        , parentBoundaries.Y + (parentBoundaries.Height - context.YAxis.SpaceAvailable)
        , width
        , height);
     return safeArea;
 }
        public static UnusedCssTag FromRuleSet(ITextBuffer buffer, IStylingRule rule)
        {
            var ss = SnapshotSpanFromRule(buffer, rule);

            return(new UnusedCssTag
            {
                ToolTipContent = string.Format(CultureInfo.CurrentCulture, "No usages of the CSS selector '{0}' have been found.", rule.DisplaySelectorName),
                ErrorType = "compiler warning",
                Span = ss,
            });
        }
        public static Task ProduceErrorListTask(this IStylingRule rule, TaskErrorCategory category, Project project, string format)
        {
            var item = ResolveVsHierarchyItem(project.UniqueName);
            var task = new ErrorTask
            {
                Document      = rule.File,
                Line          = rule.Line - 1,
                Column        = rule.Column,
                ErrorCategory = category,
                Category      = TaskCategory.Html,
                Text          = string.Format(CultureInfo.CurrentCulture, format, project.Name, rule.DisplaySelectorName, rule.File, rule.Line, rule.Column),
                HierarchyItem = item
            };

            task.Navigate += NavigateToItem;

            return(task);
        }
Beispiel #6
0
 public bool Equals(IStylingRule other)
 {
     return(!ReferenceEquals(other, null) && other.File == File && other.IsMatch(CleansedSelectorName) && other.Line == Line && other.Column == Column && other.Offset == Offset && other.Length == Length);
 }
Beispiel #7
0
 private void AddElement(IGuiElement element, IStylingRule rule, IPriority priority)
 {
     if (styledElements.ContainsKey(element))
     {
         if (priority.Amount > styledElements[element].Priority.Amount)
         {
             styledElements[element].Style.Override(rule);
         }
         else
         {
             styledElements[element].Style.Merge(rule);
         }
         return;
     }
     styledElements.Add(element, new StyleEntry(priority, rule));
 }
Beispiel #8
0
 public void Attach(ElementSelector selector, IStylingRule ruleSet)
 {
     ResolveSelector(selector, ruleSet);
 }
Beispiel #9
0
 public void Attach(IGuiElement element, IStylingRule ruleSet)
 {
     AddElement(element, ruleSet, SelectorPriority.Default);
 }
Beispiel #10
0
 public StyleEntry(IPriority priority, IStylingRule style)
 {
     Priority = priority;
     Style = style;
 }
Beispiel #11
0
        private void ResolveSelector(ElementSelector selector, IStylingRule rule)
        {
            var selectedElements = selector.GetSelection(guiTree);

            foreach (var element in selectedElements)
            {
                AddElement(element, rule, selector.Priority);
            }
        }
 public bool Equals(IStylingRule other)
 {
     return !ReferenceEquals(other, null) && other.File == File && other.IsMatch(CleansedSelectorName) && other.Line == Line && other.Column == Column && other.Offset == Offset && other.Length == Length;
 }
        public static bool IsAProtectedClass(IStylingRule rule)
        {
            var selectorName = rule.DisplaySelectorName;
            var cleansedName = RuleRegistry.StandardizeSelector(selectorName);

            return cleansedName.IndexOf(":visited", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":hover", StringComparison.Ordinal) > -1 || cleansedName.IndexOf(":active", StringComparison.Ordinal) > -1;
        }
Beispiel #14
0
 public void Override(IStylingRule other)
 {
     JoinHelper(other as StylingRule, this);
 }
Beispiel #15
0
 public void Merge(IStylingRule other)
 {
     JoinHelper(this, other as StylingRule);
 }