Ejemplo n.º 1
0
        public override CssBoxArea Handle(IParentElement Owner, cssElement[] controls)
        {
            Reset();

            for (int i = 0; i < controls.Length; i++)
            {
                var E = controls[i];
                if (!E.Affects_Layout)
                {
                    continue;
                }

                // Get the elements bounds
                var cSize = E.Box.Content.Get_Dimensions();

                // Add the current element to our line
                Add_To_Line(E, E.Box.Content, cSize);
                Start_New_Line();
            }

            if (Line.Count > 0)
            {
                Start_New_Line();                // Make sure our line in progress is added
            }
            Perform_Alignment((Owner as cssElement).Style.TextAlign);
            Finalize_Positions();

            return(layoutBlock);
        }
Ejemplo n.º 2
0
        private static List <ISchemaElement> ChildrenToArray(IParentElement parent)
        {
            var children = new List <ISchemaElement>();

            foreach (ISchemaElement child in parent.Children)
            {
                children.Add(child);
            }

            return(children);
        }
Ejemplo n.º 3
0
        public override CssBoxArea Handle(IParentElement Owner, cssElement[] controls)
        {
            Rect2i MaxArea = Owner.Get_Layout_Area();

            Reset();

            for (int i = 0; i < controls.Length; i++)
            {
                var E = controls[i];
                if (!E.Affects_Layout)
                {
                    continue;
                }

                // Get the elements bounds

                var cArea  = E.Box.Content;
                var cSize  = cArea.Get_Dimensions();
                int cRight = (layoutPos.X + cSize.Width);

                // If the last element we positioned was a block-level element then start a new row...
                if (Previous != null && Previous.Style.Display == EDisplayMode.BLOCK)
                {
                    Start_New_Line();
                }
                // If this is a block element and we already have other elements on this row then start a new row...
                else if (E.Style.Display == EDisplayMode.BLOCK && Line.Count > 0)
                {
                    Start_New_Line();
                }
                // Check if putting the element on the current row would place it out of bounds.
                else if (cRight > MaxArea.Width && Line.Count > 0)// Check if this control will extend beyond the edges of it's container
                {
                    // This isnt the first element of this row (this check ensures each row has atleast 1 element on it, even if they go out of bounds)
                    Start_New_Line();
                }

                // ====[ BLOCK entitys get a row to themselves ]====

                // Add the current element to our line
                Add_To_Line(E, cArea, cSize);
            }

            if (Line.Count > 0)
            {
                Start_New_Line();                // Make sure our line in progress is added
            }
            Perform_Alignment((Owner as cssElement).Style.TextAlign);
            Finalize_Positions();

            return(layoutBlock);
        }
Ejemplo n.º 4
0
 private IParentElement findParentInGrandparent(IParentElement grandParentToSearch, IChildElement child, bool searchUp, int startIndex)
 {
     if (grandParentToSearch.ValidChildren.Contains(child.ActionType))
     {
         // grandparent is a valid parent... return the grandparent
         return(grandParentToSearch);
     }
     else
     {
         int[] rangeToSearch;
         if (searchUp)
         {
             if (startIndex > 0)
             {
                 rangeToSearch = Enumerable.Range(0, startIndex - 1).ToArray();
             }
             else
             {
                 rangeToSearch = new int[] { 0 };
             }
         }
         else
         {
             rangeToSearch = Enumerable.Range(startIndex + 1, grandParentToSearch.SubChildren.Count - 1).ToArray();
         }
         foreach (int i in rangeToSearch)
         {
             if (grandParentToSearch.SubChildren[i] is IParentElement)
             {
                 IParentElement rp = findParentWithinParent(grandParentToSearch.SubChildren[i] as IParentElement, child, searchUp);
                 if (null != rp)
                 {
                     return(rp);
                 }
             }
         }
     }
     if (!(grandParentToSearch is IAction))
     {
         // can you take me hiiiiiigher...
         IParentElement ggp = findParentInGrandparent(grandParentToSearch.Parent as IParentElement, child, searchUp, grandParentToSearch.SubChildren.IndexOf(grandParentToSearch as IChildElement));
         if (null != ggp)
         {
             return(ggp);
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
        private static T ExpectChild <T>(IParentElement parent)
        {
            List <ISchemaElement> children = ChildrenToArray(parent);

            if (children.Count != 1)
            {
                throw new InvalidOperationException(string.Format("The element “{0}” is expected to have exactly one child of type “{1}”, but found some {2} children.", parent.GetType().AssemblyQualifiedName, typeof(T).AssemblyQualifiedName, children.Count));
            }

            if (!(children[0] is T))
            {
                throw new InvalidOperationException(string.Format("The element “{0}” is expected to have exactly one child of type “{1}”, but found a child of type “{2}” instead.", parent.GetType().AssemblyQualifiedName, typeof(T).AssemblyQualifiedName, children[0].GetType().AssemblyQualifiedName));
            }

            return((T)children[0]);
        }
Ejemplo n.º 6
0
        private List <IChildElement> GetChildElements(IParentElement p)
        {
            List <IChildElement> childElements = new List <IChildElement>();

            foreach (IChildElement c in p.SubChildren)
            {
                childElements.Add(c);
                if (c is IParentElement)
                {
                    foreach (IChildElement rc in GetChildElements(c as IParentElement))
                    {
                        childElements.Add(rc);
                    }
                }
            }
            return(childElements);
        }
Ejemplo n.º 7
0
        private void ParseObjectFromElement(ISchemaElement schemaElement, XmlElement element)
        {
            foreach (XmlAttribute attribute in element.Attributes)
            {
                SetAttributeOnObject(schemaElement, attribute.LocalName, attribute.Value);
            }

            foreach (XmlNode node in element.ChildNodes)
            {
                XmlElement childElement = node as XmlElement;
                if (childElement != null)
                {
                    ISchemaElement  childSchemaElement = null;
                    ICreateChildren createChildren     = schemaElement as ICreateChildren;
                    if (createChildren == null)
                    {
                        throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_ISchemaElementDoesnotImplementICreateChildren, element.LocalName));
                    }
                    else
                    {
                        childSchemaElement = createChildren.CreateChild(childElement.LocalName);
                    }

                    if (childSchemaElement == null)
                    {
                        childSchemaElement = this.CreateObjectFromElement(childElement);
                        if (childSchemaElement == null)
                        {
                            throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixHarvesterStrings.EXP_XmlElementDoesnotHaveISchemaElement, childElement.LocalName));
                        }
                    }

                    this.ParseObjectFromElement(childSchemaElement, childElement);
                    IParentElement parentElement = (IParentElement)schemaElement;
                    parentElement.AddChild(childSchemaElement);
                }
                else
                {
                    XmlText childText = node as XmlText;
                    if (childText != null)
                    {
                        SetAttributeOnObject(schemaElement, "Content", childText.Value);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parses an ISchemaElement from the XmlElement.
        /// </summary>
        /// <param name="schemaElement">ISchemaElement to fill in.</param>
        /// <param name="element">XmlElement to parse from.</param>
        private void ParseObjectFromElement(ISchemaElement schemaElement, XmlElement element)
        {
            foreach (XmlAttribute attribute in element.Attributes)
            {
                this.SetAttributeOnObject(schemaElement, attribute.LocalName, attribute.Value);
            }

            foreach (XmlNode node in element.ChildNodes)
            {
                XmlElement childElement = node as XmlElement;
                if (childElement != null)
                {
                    ISchemaElement  childSchemaElement = null;
                    ICreateChildren createChildren     = schemaElement as ICreateChildren;
                    if (createChildren == null)
                    {
                        throw new InvalidOperationException("ISchemaElement with name " + element.LocalName + " does not implement ICreateChildren.");
                    }
                    else
                    {
                        childSchemaElement = createChildren.CreateChild(childElement.LocalName);
                    }

                    if (childSchemaElement == null)
                    {
                        childSchemaElement = this.CreateObjectFromElement(childElement);
                        if (childSchemaElement == null)
                        {
                            throw new InvalidOperationException("XmlElement with name " + childElement.LocalName + " does not have a corresponding ISchemaElement.");
                        }
                    }

                    this.ParseObjectFromElement(childSchemaElement, childElement);
                    IParentElement parentElement = (IParentElement)schemaElement;
                    parentElement.AddChild(childSchemaElement);
                }
                else
                {
                    XmlText childText = node as XmlText;
                    if (childText != null)
                    {
                        this.SetAttributeOnObject(schemaElement, "Content", childText.Value);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        protected List <T> GetElements <T>(IParentElement parentElement)
        {
            List <T> list = new List <T>();

            foreach (ISchemaElement element in parentElement.Children)
            {
                if (element.GetType() == typeof(T))
                {
                    list.Add((T)element);
                }
                if (element is IParentElement)
                {
                    list.AddRange(GetElements <T>(element as IParentElement));
                }
            }

            return(list);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Parses an ISchemaElement from the XmlElement.
        /// </summary>
        /// <param name="schemaElement">ISchemaElement to fill in.</param>
        /// <param name="element">XmlElement to parse from.</param>
        private void ParseObjectFromElement(ISchemaElement?schemaElement, XmlElement element)
        {
            foreach (XmlAttribute attribute in element.Attributes)
            {
                if (attribute == null)
                {
                    throw new InvalidOperationException("XmlElement.Attributes contains null attribute");
                }

                if (schemaElement == null)
                {
                    throw new ArgumentNullException(nameof(schemaElement));
                }

                this.SetAttributeOnObject(schemaElement, attribute.LocalName, attribute.Value);
            }

            foreach (XmlNode node in element.ChildNodes)
            {
                if (node is XmlElement childElement)
                {
                    ISchemaElement?childSchemaElement;
                    if (!(schemaElement is ICreateChildren createChildren))
                    {
                        throw new InvalidOperationException("ISchemaElement with name " + element.LocalName + " does not implement ICreateChildren.");
                    }
                    else
                    {
                        childSchemaElement = createChildren.CreateChild(childElement.LocalName);
                    }

                    if (childSchemaElement == null)
                    {
                        childSchemaElement = this.CreateObjectFromElement(childElement);
                        if (childSchemaElement == null)
                        {
                            throw new InvalidOperationException("XmlElement with name " + childElement.LocalName + " does not have a corresponding ISchemaElement.");
                        }
                    }

                    this.ParseObjectFromElement(childSchemaElement, childElement);
                    IParentElement parentElement = (IParentElement)schemaElement;
                    parentElement.AddChild(childSchemaElement);
                }
Ejemplo n.º 11
0
 private IParentElement findParentWithinParent(IParentElement parentToSearch, IChildElement child, bool searchUp)
 {
     if (parentToSearch.ValidChildren.Contains(child.ActionType))
     {
         // the parent we're searching is a valid parent, just return it
         return(parentToSearch);
     }
     else
     {
         if (searchUp)
         {
             foreach (IChildElement c in parentToSearch.SubChildren.Reverse())
             {
                 if (c is IParentElement)
                 {
                     IParentElement rp = findParentWithinParent(c as IParentElement, child, searchUp);
                     if (null != rp)
                     {
                         return(rp);
                     }
                 }
             }
         }
         else
         {
             // enumerate the parent's children, and search them too
             foreach (IChildElement c in parentToSearch.SubChildren)
             {
                 if (c is IParentElement)
                 {
                     IParentElement rp = findParentWithinParent(c as IParentElement, child, searchUp);
                     if (null != rp)
                     {
                         return(rp);
                     }
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Instantiate a new decompiler core.
 /// </summary>
 /// <param name="rootElement">The root element of the decompiled database.</param>
 /// <param name="messageHandler">The message handler.</param>
 internal DecompilerCore(IParentElement rootElement)
 {
     this.elements    = new Hashtable();
     this.rootElement = rootElement;
 }
Ejemplo n.º 13
0
 public abstract CssBoxArea Handle(IParentElement Owner, cssElement[] controls);
Ejemplo n.º 14
0
 /// <summary>
 /// Instantiate a new decompiler core.
 /// </summary>
 /// <param name="rootElement">The root element of the decompiled database.</param>
 /// <param name="messageHandler">The message handler.</param>
 internal DecompilerCore(IParentElement rootElement, MessageEventHandler messageHandler)
 {
     this.elements       = new Hashtable();
     this.MessageHandler = messageHandler;
     this.rootElement    = rootElement;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Harvests the satellite files for an assembly.
        /// </summary>
        /// <param name="sFileLocalName">Local name (without path, but with extension) of the file to seek for.</param>
        /// <param name="errorlevel">How to treat the missing file.</param>
        /// <param name="sSatelliteDisplayName">Display name of the satellite to be included into the error message.</param>
        /// <param name="wixparent">The parent component to mount the new entry into.</param>
        /// <param name="assemblyxml">The assembly for which we're seeking for satellites.</param>
        private void HarvestSatellite(AssemblyXml assemblyxml, string sFileLocalName, IParentElement wixparent, MissingSatelliteErrorLevel errorlevel, string sSatelliteDisplayName, Dictionary <string, string> mapTargetFiles)
        {
            if (sFileLocalName == null)
            {
                throw new ArgumentNullException("sFileLocalName");
            }
            if (sSatelliteDisplayName == null)
            {
                throw new ArgumentNullException("sSatelliteDisplayName");
            }
            if (wixparent == null)
            {
                throw new ArgumentNullException("wixparent");
            }

            // Full path
            var fi = new FileInfo(Path.Combine(Bag.GetString(AttributeName.ProductBinariesDir), sFileLocalName));

            // Missing?
            if (!fi.Exists)
            {
                string sErrorMessage = string.Format("Could not locate the {2} for the “{0}” assembly. The expected full path is “{1}”.", assemblyxml.Include, fi.FullName, sSatelliteDisplayName);
                switch (errorlevel)
                {
                case MissingSatelliteErrorLevel.None:
                    break;                     // Ignore

                case MissingSatelliteErrorLevel.Warning:
                    Log.LogWarning(sErrorMessage);
                    break;

                case MissingSatelliteErrorLevel.Error:
                    throw new InvalidOperationException(sErrorMessage);

                default:
                    throw new ArgumentOutOfRangeException("errorlevel", errorlevel, "Oops.");
                }
                return;
            }

            // Create an entry
            var wixFile = new File();

            wixparent.AddChild(wixFile);
            wixFile.Id       = string.Format("{0}{1}", FileIdPrefix, fi.Name);
            wixFile.Name     = fi.Name;
            wixFile.KeyPath  = YesNoType.no;
            wixFile.Checksum = YesNoType.no;
            wixFile.Vital    = YesNoType.no;

            RegisterTargetFile(wixFile.Name, string.Format("Satellite for the {0} product assembly.", assemblyxml.Include), mapTargetFiles);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Instantiate a new decompiler core.
 /// </summary>
 /// <param name="rootElement">The root element of the decompiled database.</param>
 /// <param name="messageHandler">The message handler.</param>
 internal DecompilerCore(IParentElement rootElement, MessageEventHandler messageHandler)
 {
     this.elements = new Hashtable();
     this.MessageHandler = messageHandler;
     this.rootElement = rootElement;
 }
Ejemplo n.º 17
0
 public Text(IParentElement p)
 {
     Parent    = p;
     ViewModel = new ViewModels.Actions.Children.TextViewModel(this);
 }
Ejemplo n.º 18
0
 public Match(IParentElement parent)
 {
     Parent    = parent;
     ViewModel = new MatchViewModel(this);
 }
Ejemplo n.º 19
0
        protected void Load(RegistryCaptureKey key, IParentElement component)
        {
            // Iterate.

            foreach (RegistryCaptureKey subKey in key.SubKeys)
            {
                Load(subKey, component);
            }

            // Iterate over values.

            foreach (RegistryCaptureValue value in key.Values)
            {
                // Add the common information.

                RegistryValue registryValue = new RegistryValue();
                if (!string.IsNullOrEmpty(value.Name))
                {
                    registryValue.Name = value.Name;
                }
                registryValue.Action = RegistryValue.ActionType.write;
                registryValue.Root   = GetRegistryRoot(key.Root);
                registryValue.Key    = key.RootRelativePath;

                // Add the type specific value.

                if (value is RegistryCaptureStringValue)
                {
                    registryValue.Type  = RegistryValue.TypeType.@string;
                    registryValue.Value = GetValue((RegistryCaptureStringValue)value);
                }
                else if (value is RegistryCaptureDWordValue)
                {
                    registryValue.Type  = RegistryValue.TypeType.integer;
                    registryValue.Value = GetValue((RegistryCaptureDWordValue)value);
                }
                else if (value is RegistryCaptureBinaryValue)
                {
                    registryValue.Type  = RegistryValue.TypeType.binary;
                    registryValue.Value = GetValue((RegistryCaptureBinaryValue)value);
                }
                else if (value is RegistryCaptureExpandStringValue)
                {
                    registryValue.Type  = RegistryValue.TypeType.@string;
                    registryValue.Value = GetValue((RegistryCaptureExpandStringValue)value);
                }
                else if (value is RegistryCaptureMultiStringValue)
                {
                    registryValue.Type = RegistryValue.TypeType.multiString;

                    foreach (string multiStringValueContent in ((RegistryCaptureMultiStringValue)value).Value)
                    {
                        MultiStringValue multiStringValue = new MultiStringValue();
                        multiStringValue.Content = multiStringValueContent;
                        registryValue.AddChild(multiStringValue);
                    }
                }
                else
                {
                    registryValue.Type  = RegistryValue.TypeType.@string;
                    registryValue.Value = GetValue(value);
                }

                component.AddChild(registryValue);
            }
        }
Ejemplo n.º 20
0
        public void MoveSub(string direction)
        {
            IChildElement childElement = SelectedSubActionsTreeView;
            int           childIndex   = (childElement.Parent as IParentElement).SubChildren.IndexOf(childElement);
            int           parentCount  = (childElement.Parent as IParentElement).SubChildren.Count;

            switch (direction)
            {
            case "top":
                IParentElement topParent = findNewParent(SelectedActionsTreeView as IParentElement, SelectedSubActionsTreeView, true);
                (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                topParent.SubChildren.Insert(0, childElement);
                childElement.Parent = topParent;
                break;

            case "bottom":
                IParentElement bottomParent = findNewParent(SelectedActionsTreeView as IParentElement, SelectedSubActionsTreeView, false);
                (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                bottomParent.SubChildren.Add(childElement);
                childElement.Parent = bottomParent;
                break;

            case "down":
                if (childIndex == parentCount - 1)
                {
                    // if the parent is the action, we're as far down as we can go
                    if (!(childElement.Parent is IAction))
                    {
                        IParentElement nextParent = findParentInGrandparent((childElement.Parent.Parent as IParentElement), childElement, false, (childElement.Parent.Parent as IParentElement).SubChildren.IndexOf((childElement.Parent as IChildElement)) + 1);
                        if (null != nextParent)
                        {
                            (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                            nextParent.SubChildren.Insert((childElement.Parent.Parent as IParentElement).SubChildren.IndexOf((childElement.Parent as IChildElement)) + 1, childElement);
                            childElement.Parent = nextParent;
                        }
                    }
                }
                else if ((childElement.Parent as IParentElement).SubChildren[childIndex + 1] is IParentElement)
                {
                    // the next element after the child is a parent element, look for parents within
                    IParentElement nextParent = findParentWithinParent((childElement.Parent as IParentElement).SubChildren[childIndex + 1] as IParentElement, childElement, false);
                    if (null != nextParent)
                    {
                        (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                        nextParent.SubChildren.Insert(0, childElement);
                        childElement.Parent = nextParent;
                    }
                    else
                    {
                        // the next element isn't a valid parent, and has no valid parents... NEXT
                        (childElement.Parent as IParentElement).SubChildren.Move(childIndex, childIndex + 1);
                    }
                }
                else
                {
                    // it's not at the end, and the next element isn't a parent, so move it
                    (childElement.Parent as IParentElement).SubChildren.Move(childIndex, childIndex + 1);
                }
                break;

            case "up":
                if (childIndex == 0)
                {
                    if (!(childElement.Parent is IAction))
                    {
                        IParentElement nextParent = findParentInGrandparent((childElement.Parent.Parent as IParentElement), childElement, true, (childElement.Parent.Parent as IParentElement).SubChildren.IndexOf((childElement.Parent as IChildElement)));
                        if (null != nextParent)
                        {
                            (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                            nextParent.SubChildren.Insert((childElement.Parent.Parent as IParentElement).SubChildren.IndexOf((childElement.Parent as IChildElement)), childElement);
                            childElement.Parent = nextParent;
                        }
                    }
                }
                else if ((childElement.Parent as IParentElement).SubChildren[childIndex - 1] is IParentElement)
                {
                    // the previous element is a parent element, look for parents within
                    IParentElement previousParent = findParentWithinParent((childElement.Parent as IParentElement).SubChildren[childIndex - 1] as IParentElement, childElement, true);
                    if (null != previousParent)
                    {
                        (childElement.Parent as IParentElement).SubChildren.Remove(childElement);
                        previousParent.SubChildren.Add(childElement);
                        childElement.Parent = previousParent;
                    }
                    else
                    {
                        // the previous element isn't a valid parent, and has no valid parents... PREVIOUS!
                        (childElement.Parent as IParentElement).SubChildren.Move(childIndex, childIndex - 1);
                    }
                }
                else
                {
                    // it's not at the beginning, and the previous isn't a parent, so move it
                    (childElement.Parent as IParentElement).SubChildren.Move(childIndex, childIndex - 1);
                }
                // find previous parent
                break;
            }
            foreach (IChildElement c in GetChildElements(SelectedActionsTreeView as IParentElement))
            {
                c.TVSelected = false;
            }
            foreach (IElement c in GetParentElements(childElement))
            {
                c.TVIsExpanded = true;
            }
            SelectedSubActionsTreeView = childElement;
            childElement.TVSelected    = true;
            _eventAggregator.BeginPublishOnUIThread(new ChangeUI("PreviewChange", null));
        }
Ejemplo n.º 21
0
 private IParentElement findNewParent(IParentElement searchRoot, IChildElement child, bool searchUp = false)
 {
     // if searchroot is a valid parent, return it
     if (searchRoot.ValidChildren.Contains(child.ActionType))
     {
         return(searchRoot);
     }
     // otherwise find the topmost or bottommost parent
     if (searchUp)
     {
         // start from the top and move down
         foreach (IChildElement c in searchRoot.SubChildren)
         {
             if (c is IParentElement)
             {
                 // if the parent is valid, return it, otherwise recurse down the
                 // parent's subchildren for other parents
                 if (c.ValidChildren.Contains(child.ActionType))
                 {
                     return(c as IParentElement);
                 }
                 else
                 {
                     foreach (IChildElement rc in (c as IParentElement).SubChildren)
                     {
                         if (rc is IParentElement)
                         {
                             IParentElement rp = findNewParent(rc as IParentElement, child, true);
                             if (null != rp)
                             {
                                 return(rp);
                             }
                         }
                     }
                 }
             }
         }
         return(null); // couldn't find a parent (this technically should never return null, because by definition the child exists in a parent somewhere)
     }
     else
     {
         // start from the bottom and move up
         foreach (IChildElement c in searchRoot.SubChildren.Reverse())
         {
             if (c.ValidChildren.Contains(child.ActionType))
             {
                 return(c as IParentElement);
             }
             if (c is IParentElement)
             {
                 foreach (IChildElement rc in (c as IParentElement).SubChildren.Reverse())
                 {
                     if (rc is IParentElement)
                     {
                         IParentElement rp = findNewParent(rc as IParentElement, child, false);
                         if (null != rp)
                         {
                             return(rp);
                         }
                     }
                 }
             }
         }
         return(null); // couldn't find a parent (this technically should never return null, because by definition the child exists in a parent somewhere)
     }
 }
Ejemplo n.º 22
0
 public SoftwareListRef(IParentElement p)
 {
     Parent    = p;
     ViewModel = new ViewModels.Actions.Children.SoftwareListRefViewModel(this);
 }