public virtual void WriteEndTag(IXhtmlWriter writer, IElement element)
 {
     if (element.ContentModel.Count > 0)
     {
         writer.WriteEndElement(element.TagName);
     }
 }
        /// <summary>
        /// Executes the specified solution.
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        protected override void Execute(IElement element)
        {
            Shell.Instance.Locks.AssertReadAccessAllowed();

              var node = element.ToTreeNode();
              if (node == null)
              {
            return;
              }

              IInvocationExpression invocationExpression = null;

              while (node != null)
              {
            invocationExpression = node as IInvocationExpression;

            if (invocationExpression != null)
            {
              break;
            }

            node = node.Parent;
              }

              if (invocationExpression == null)
              {
            return;
              }

              Execute(invocationExpression);
        }
Example #3
0
     /**
     * Adds content to this object.
     * @param element
     * @throws BadElementException
     */
     public void AddElement(IElement element) {
         if (cellgroup) {
             if (element is SimpleCell) {
                 if (((SimpleCell)element).Cellgroup) {
                     throw new BadElementException("You can't add one row to another row.");
                 }
                 content.Add(element);
                 return;
             }
             else {
                 throw new BadElementException("You can only add cells to rows, no objects of type " + element.GetType().ToString());
             }
         }
         if (element.Type == Element.PARAGRAPH
                 || element.Type == Element.PHRASE
                 || element.Type == Element.ANCHOR
                 || element.Type == Element.CHUNK
                 || element.Type == Element.LIST
                 || element.Type == Element.MARKED
                 || element.Type == Element.JPEG
 				|| element.Type == Element.JPEG2000
                 || element.Type == Element.JBIG2
                 || element.Type == Element.IMGRAW
                 || element.Type == Element.IMGTEMPLATE) {
             content.Add(element);
         }
         else {
             throw new BadElementException("You can't add an element of type " + element.GetType().ToString() + " to a SimpleCell.");
         }
     }
        public GenerationMenuWidget(Window parent, IElement referer, Bus bus, string busName)
        {
            if (referer.Data != null) {
                MenuItem path = new MenuItem("Call " + referer.Name + "...");
                ObjectPath p = new ObjectPath(referer.Parent.Parent.Path);

                if (!referer.Data.IsProperty) {
                    path.Activated += delegate {
                        MethodInvokeDialog diag = new MethodInvokeDialog (parent, bus, busName, p, referer);

                        while (diag.Run () == (int)ResponseType.None);
                        diag.Destroy();
                    };
                } else {
                    path.Activated += delegate {
                        PropertyInvokeDialog diag = new PropertyInvokeDialog (parent, bus, busName, p, referer);

                        while (diag.Run () == (int)ResponseType.None);
                        diag.Destroy();
                    };
                }

                this.Append(path);
                path.ShowAll();
            }
        }
        public IElement FindFirst(IElement context, LocatorStrategy strategy, string locator)
        {
            AutomationProperty property = this.ToAutomationProperty(strategy);
            AutomationElement element = null;
            switch (strategy)
            {
                case LocatorStrategy.Id:
                case LocatorStrategy.Name:
                case LocatorStrategy.ClassName:
                    element = context.AutomationElement.FindFirst(
                        TreeScope.Descendants,
                        new PropertyCondition(property, locator));
                    break;

                case LocatorStrategy.TagName:
                    ControlType type = this.uiAutomation.FromTagName(locator);
                    element = context.AutomationElement.FindFirst(
                        TreeScope.Descendants,
                        new PropertyCondition(property, type));
                    break;

                case LocatorStrategy.XPath:
                    element = this.uiAutomation.FindFirstByXPath(context.AutomationElement, locator);
                    break;

                default:
                    throw new FailedCommandException(
                        string.Format("Usupported locator startegy: {0}", strategy.ToString()),
                        32); // InvalidSelector (32)
            }

            return element == null ? null : this.elementFactory.GetElement(element);
        }
        public override ICodeBlock GenerateAddToManagers(ICodeBlock codeBlock, IElement element)
        {
            if (ShouldGenerate)
            {
                foreach (var layer in GetObjectsForGumLayers(element))
                {
                    var rfs = GetScreenRfsIn(element);
                    if (rfs != null)
                    {

                        codeBlock.Line(layer.InstanceName + "Gum = RenderingLibrary.SystemManagers.Default.Renderer.AddLayer();");


                        codeBlock.Line(rfs.GetInstanceName() + ".AddGumLayerToFrbLayer(" + layer.InstanceName + "Gum, " + layer.InstanceName + ");");
                    }
                }
                // todo:  Need to register the layer here
                foreach (var item in element.AllNamedObjects.Where(item =>
                    GumPluginCodeGenerator.IsGue(item) &&
                    !string.IsNullOrEmpty(item.LayerOn) &&
                    NamedObjectSaveCodeGenerator.GetFieldCodeGenerationType(item) == CodeGenerationType.Full))
                {
                    codeBlock.Line(item.FieldName + ".MoveToLayer(" + item.LayerOn + "Gum);");
                }
            }
            return base.GenerateAddToManagers(codeBlock, element);
        }
 public ElementInstancesAddedEventArgs(IElement[] elements)
 {
     if(elements==null)
         _Elements = new IElement[0];
     else
         _Elements = elements;
 }
Example #8
0
        /// <summary>
        /// Constructs a simplified regular expression pattern.
        /// </summary>
        /// <param name="pattern">The input pattern.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="pattern"/> is null.</exception>
        /// <exception cref="RegexLiteException">Thrown if <paramref name="pattern"/> is invalid.</exception>
        public RegexLite(string pattern)
        {
            if (pattern == null)
                throw new ArgumentNullException("pattern");

            this.root = Parser.Run(pattern);
        }
        public static string GetSharedCodeFullFileName(IElement container, string baseProjectDirectory)
        {

            string fileName = GetEventFileNameForElement(container);
            return baseProjectDirectory + fileName;
        
        }
Example #10
0
        String IMarkupFormatter.OpenTag(IElement element, Boolean selfClosing)
        {
            var prefix = element.Prefix;
            var temp = Pool.NewStringBuilder();
            temp.Append(Symbols.LessThan);

            if (!String.IsNullOrEmpty(prefix))
            {
                temp.Append(prefix).Append(Symbols.Colon);
            }

            temp.Append(element.LocalName);

            foreach (var attribute in element.Attributes)
            {
                temp.Append(" ").Append(Instance.Attribute(attribute));
            }

            if (selfClosing || !element.HasChildNodes)
            {
                temp.Append(" /");
            }

            temp.Append(Symbols.GreaterThan);
            return temp.ToPool();
        }
Example #11
0
		public ITextPatternRange RangeFromChild (IElement childElement)
		{
			Element child = childElement as Element;
			if (child == null || child.Parent != this)
				throw new InvalidOperationException ();
			return new TextRangePattern (accessible);
		}
Example #12
0
        protected override bool CheckResolve(IReference reference, IElement element)
        {
            if (reference is TableReference && !DatabaseManager.GetInstance(element.GetManager().Solution).Enabled)
                return false;

            return base.CheckResolve(reference, element);
        }
Example #13
0
 String IMarkupFormatter.CloseTag(IElement element, Boolean selfClosing)
 {
     var prefix = element.Prefix;
     var name = element.LocalName;
     var tag = !String.IsNullOrEmpty(prefix) ? prefix + ":" + name : name;
     return (selfClosing || !element.HasChildNodes) ? String.Empty : String.Concat("</", tag, ">");
 }
 public void ReactToChange(string changedMember, object oldValue, EventResponseSave ers, IElement container)
 {
     if (changedMember == "EventName")
     {
         ReactToEventRename(oldValue, ers, container);
     }
 }
Example #15
0
        protected override bool CheckElement(IElement element)
        {
            if (!NHProjectFileLanguageService.IsNHFile(element.GetProjectFile()))
                return false;

            return base.CheckElement(element);
        }
 public static void GenerateStart(IElement saveObject, ICodeBlock codeBlock, string appendName)
 {
     if (ObjectFinder.Self.GlueProject.PerformanceSettingsSave.RecordInitializeSegments)
     {
         StartMeasurement(saveObject, codeBlock, appendName, true);
     }
 }
Example #17
0
 public void addNewTab(String name, IElement element)
 {
     Label tablabel = new Label(name);
     this.AppendPage((Widget)element,tablabel);
     this.ShowAll();
     TabCount++;
 }
        public ScalableElementRuntime(IElement elementSave, Layer layerProvidedByContainer,
            NamedObjectSave namedObjectSave, EventHandler<VariableSetArgs> onBeforeVariableSet,
            EventHandler<VariableSetArgs> onAfterVariableSet)
            : base(elementSave, layerProvidedByContainer, namedObjectSave, onBeforeVariableSet, onAfterVariableSet)
        {

        }
 private static void TryGenerateRemoveShapeCollectionFromManagers(ICodeBlock codeBlock, IElement element)
 {
     if (element.IsICollidable())
     {
         codeBlock.Line("mGeneratedCollision.RemoveFromManagers(clearThis: false);");
     }
 }
        public override Boolean Match(IElement element)
        {
            var parent = element.ParentElement;

            if (parent != null)
            {
                var n = Math.Sign(_step);
                var k = 0;

                for (var i = parent.ChildNodes.Length - 1; i >= 0; i--)
                {
                    var child = parent.ChildNodes[i] as IElement;

                    if (child != null && child.NodeName.Is(element.NodeName))
                    {
                        k += 1;

                        if (child == element)
                        {
                            var diff = k - _offset;
                            return diff == 0 || (Math.Sign(diff) == n && diff % _step == 0);
                        }
                    }
                }
            }

            return false;
        }
    public IEnumerable<UnitTestElementDisposition> AcceptElement(IElement element, IFile file)
#endif
    {
      IDeclaration declaration = (IDeclaration)element;
      var behaviorElement = _behaviorFactory.CreateBehavior(declaration.DeclaredElement);
      
      if (behaviorElement == null)
      {
        yield break;
      }

      yield return new UnitTestElementDisposition(behaviorElement,
#if RESHARPER_6
                                                  file.GetSourceFile().ToProjectFile(),
#else
                                                  file.ProjectFile,
#endif
                                                  declaration.GetNavigationRange().TextRange,
                                                  declaration.GetDocumentRange().TextRange);

      var behaviorSpecifications =
        _behaviorSpecificationFactory.CreateBehaviorSpecificationsFromBehavior(behaviorElement,
                                                                               declaration.DeclaredElement);

      foreach (var behaviorSpecificationElement in behaviorSpecifications)
      {
        yield return new UnitTestElementDisposition(new UnitTestElementLocation[0],
                                                    behaviorSpecificationElement);
      }
    }
Example #22
0
        /// <summary>
        /// Computes the declarations for the given element in the context of
        /// the specified styling rules.
        /// </summary>
        /// <param name="rules">The styles to use.</param>
        /// <param name="element">The element that is questioned.</param>
        /// <param name="pseudoSelector">The optional pseudo selector to use.</param>
        /// <returns>The style declaration containing all the declarations.</returns>
        public static CssStyleDeclaration ComputeDeclarations(this StyleCollection rules, IElement element, String pseudoSelector = null)
        {
            var computedStyle = new CssStyleDeclaration();
            var pseudoElement = PseudoElement.Create(element, pseudoSelector);

            if (pseudoElement != null)
            {
                element = pseudoElement;
            }

            computedStyle.SetDeclarations(rules.ComputeCascadedStyle(element).Declarations);
            var htmlElement = element as IHtmlElement;

            if (htmlElement != null)
            {
                var declarations = htmlElement.Style.OfType<CssProperty>();
                computedStyle.SetDeclarations(declarations);
            }

            var nodes = element.GetAncestors().OfType<IElement>();

            foreach (var node in nodes)
            {
                var style = rules.ComputeCascadedStyle(node);
                computedStyle.UpdateDeclarations(style.Declarations);
            }

            return computedStyle;
        }
        public override ICodeBlock GenerateAdditionalMethods(ICodeBlock codeBlock, IElement element)
        {
            EntitySave entitySave = element as EntitySave;

            if (entitySave == null || (!entitySave.ImplementsIClickable && !entitySave.ImplementsIWindow))
            {
                return codeBlock;
            }


            if (entitySave.ImplementsIWindow)
            {
                bool inheritsFromIWindow = entitySave.GetInheritsFromIWindow();

                // Add all the code that never changes if this is the base IWindow (doesn't have a parent IWindow)
                if (!inheritsFromIWindow)
                {
                    GenerateEnabledVariable(codeBlock, element);      
                }
            }

            IWindowCodeGenerator.WriteCodeForHasCursorOver(
                entitySave, codeBlock, entitySave.GetInheritsFromIWindowOrIClickable());

            var isVirtual = string.IsNullOrEmpty(entitySave.BaseEntity) || entitySave.GetInheritsFromIWindowOrIClickable() == false;

            codeBlock
                .Function("WasClickedThisFrame", "FlatRedBall.Gui.Cursor cursor", Public: true, Virtual: isVirtual, Override: !isVirtual, Type: "bool")
                .Line("return cursor.PrimaryClick && HasCursorOver(cursor);")
                .End();

            return codeBlock;
        }
        private void GenerateInitializeLevel(ICodeBlock codeBlock, IElement element)
        {
            #region /////////////////////////////////Early out////////////////////////////////
            bool shouldGenerate = GetIfShouldGenerate(element);

            if (!shouldGenerate)
            {
                return;
            }

            ///////////////////////////////End early out/////////////////////////////
            #endregion


            codeBlock.Line("FlatRedBall.TileGraphics.LayeredTileMap CurrentTileMap;");
            var function = codeBlock.Function("void", "InitializeLevel", "string levelName");

            GenerateInitializeLevelObjects(function);

            GenerateInitializeCamera(function);

            GenerateAddCollisionAndEntities(function);

            GenerateInitializeAnimations(function);
        }
Example #25
0
 public OutputNeutralPort(Guid id, IElement parent)
 {
     Id = id;
     _pipes = new List<INeutralPipe>();
     ParentElement = parent;
     Index = -1;
 }
 public override bool Apply(IElement element)
 {
     if (element == null)
         return false;
     return element.ElementType == LanguageElementType.For 
         || element.ElementType == LanguageElementType.ForEach;
 }
        private static void TryToRemoveInvalidState(this GlueProjectSave glueProjectSave, bool showPopupsOnFixedErrors, IElement containingElement, NamedObjectSave nos)
        {
            if (nos.SourceType == SourceType.Entity && !string.IsNullOrEmpty(nos.SourceClassType) && !string.IsNullOrEmpty(nos.CurrentState))
            {
                EntitySave foundEntitySave = glueProjectSave.GetEntitySave(nos.SourceClassType);

                if (foundEntitySave != null)
                {
                    bool hasFoundState = false;

                    hasFoundState = foundEntitySave.GetStateRecursively(nos.CurrentState) != null;

                    if (!hasFoundState)
                    {
                        if (showPopupsOnFixedErrors)
                        {
                            MessageBox.Show("The Object " + nos.InstanceName + " in " + containingElement.Name + " uses the invalid state " + nos.CurrentState +
                                "\nRemoving this current State");
                        }

                        nos.CurrentState = null;

                    }
                }
            }
        }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the DummyInputNetworkPort class, This class maintains the dataObj
 /// as a member, does NOT use the backingStore of the pipe.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="inPipe"></param>
 /// <param name="dataObj"></param>
 /// <param name="isValid"></param>
 public DummyInputNetworkPort(IElement parent, INetworkPipe inPipe, INetwork dataObj, bool isValid)
 {
     _parent = parent;
     _inPipe = inPipe;
     _netObj = dataObj;
     _IsValid = isValid;
 }
        /// <summary>Executes the specified solution.</summary>
        /// <param name="element">The element.</param>
        protected override void Execute(IElement element)
        {
            var node = element.ToTreeNode();
              if (node == null)
              {
            return;
              }

              IInvocationExpression invocationExpression = null;

              while (node != null)
              {
            invocationExpression = node as IInvocationExpression;

            if (invocationExpression != null)
            {
              break;
            }

            node = node.Parent;
              }

              if (invocationExpression == null)
              {
            return;
              }

              Execute(invocationExpression);
        }
Example #30
0
		// TODO: Rename to GetAutomationElements
		internal static AutomationElement [] GetOrCreateAutomationElements (IElement [] sourceElements)
		{
			AutomationElement [] ret = new AutomationElement [sourceElements.Length];
			for (int i = 0; i < sourceElements.Length; i++)
				ret [i] = GetOrCreateAutomationElement (sourceElements [i]);
			return ret;
		}
Example #31
0
        public static D2D1.Geometry Create(D2D1.RenderTarget target, FontManager fontManager, IFrameContext context, IClip clipPath, IElement targetElement)
        {
            if (clipPath == null)
            {
                return(null);
            }

            IList <D2D1.Geometry> list = (
                from element in clipPath.Children
                let geom = CreateGeometry(target, fontManager, element, context, clipPath.ClipPathUnits, targetElement)
                           where geom != null
                           select geom
                ).ToArray();

            switch (list.Count)
            {
            case 0:
                return(null);

            case 1:
                return(list[0]);

            default:
                return(new D2D1.GeometryGroup(target.Factory, D2D1.FillMode.Winding, list.ToArray()));
            }
        }
Example #32
0
 public void AddElement(IElement element)
 {
     innerList.Add(element);
 }
Example #33
0
 /// <summary>
 /// Raises the <c>@onkeyup</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
 /// to the event handler.
 /// </summary>
 /// <param name="element">The element to raise the event on.</param>
 /// <param name="eventArgs">The event arguments to pass to the event handler.</param>
 public static void Keyup(this IElement element, KeyboardEventArgs eventArgs) => _ = KeyupAsync(element, eventArgs);
Example #34
0
 /// <summary>
 /// Raises the <c>@onkeyup</c> event on <paramref name="element"/>,  passing the provided
 /// properties to the event handler via a <see cref="KeyboardEventArgs"/> object
 /// </summary>
 /// <param name="element">The element to raise the event on.</param>
 /// <param name="key">
 ///     The key value of the key represented by the event. If the value has a printed
 ///     representation, this attribute's value is the same as the char attribute. Otherwise,
 ///     it's one of the key value strings specified in 'Key values'. If the key can't
 ///     be identified, this is the string "Unidentified"
 /// </param>
 /// <param name="code">
 ///     Holds a string that identifies the physical key being pressed. The value is not
 ///     affected by the current keyboard layout or modifier state, so a particular key
 ///     will always return the same value.
 /// </param>
 /// <param name="location">The location of the key on the device.</param>
 /// <param name="repeat">true if a key has been depressed long enough to trigger key repetition, otherwise false.</param>
 /// <param name="ctrlKey">true if the control key was down when the event was fired. false otherwise.</param>
 /// <param name="shiftKey">true if the shift key was down when the event was fired. false otherwise.</param>
 /// <param name="altKey">true if the alt key was down when the event was fired. false otherwise.</param>
 /// <param name="metaKey">true if the meta key was down when the event was fired. false otherwise.</param>
 /// <param name="type">The type of the event.</param>
 public static void Keyup(this IElement element, string key, string?code = default, float location = default, bool repeat = default, bool ctrlKey = default, bool shiftKey = default, bool altKey = default, bool metaKey = default, string?type = default)
 => KeyupAsync(element, new KeyboardEventArgs {
     Key = key, Code = code, Location = location, Repeat = repeat, CtrlKey = ctrlKey, ShiftKey = shiftKey, AltKey = altKey, MetaKey = metaKey, Type = type
 });
Example #35
0
 /// <summary>
 /// Raises the <c>@onkeydown</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/>
 /// to the event handler.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="eventArgs"></param>
 /// <returns>A task that completes when the event handler is done.</returns>
 public static Task KeydownAsync(this IElement element, KeyboardEventArgs eventArgs) => element.TriggerEventAsync("onkeydown", eventArgs);
Example #36
0
        public static BitmapImage GetImage(object value)
        {
            if (!initialized)
            {
                Initialize();
            }
            IElement e = value as IElement;

            if (e != null)
            {
                if (e.Name.In("Tables", "Procedures", "Views", "Columns", "Indexes"))
                {
                    if (e.Status == "Expanded")
                    {
                        return(FolderOpenImage);
                    }
                    else
                    {
                        return(FolderClosedImage);
                    }
                }
                if (e.Name.In("Connection", "Connect...", "Connections"))
                {
                    return(ConnectImage);
                }
                if (e.Name == "Databases")
                {
                    return(DatabasesImage);
                }
                if (e.Name == "Users")
                {
                    return(UsersImage);
                }
                if (e.Name == "Query")
                {
                    return(QueryImage);
                }
                if (e is ServerConnection)
                {
                    return(ServerImage);
                }
                if (e is IServer)
                {
                    return(ServerImage);
                }
                if (e is IDatabase)
                {
                    return(DatabaseImage);
                }
                if (e is Table)
                {
                    return(TableImage);
                }
                if (e is Procedure)
                {
                    return(ProcedureImage);
                }
                if (e is View)
                {
                    return(ViewImage);
                }
                if (e is Column)
                {
                    return(TableImage);
                }
                if (e is Index)
                {
                    return(IndexImage);
                }
                if (e is User)
                {
                    return(UserImage);
                }
            }
            return(null);
        }
Example #37
0
        private static D2D1.Geometry CreateGeometry(D2D1.RenderTarget target, FontManager fontManager, IElement element, IFrameContext context, ClipPathUnits clipPathUnits, IElement targetElement)
        {
            if (clipPathUnits == ClipPathUnits.UserSpaceOnUse)
            {
                switch (element.ElementType)
                {
                case "rect":
                    return(new D2D1.RectangleGeometry(target.Factory, element.GetBounds(context).ToDx()));

                case "circle":
                    var r = element.GetRadius(context);
                    return(new D2D1.EllipseGeometry(target.Factory, new D2D1.Ellipse()
                    {
                        Point = element.GetCxCy(context).ToDx(),
                        RadiusX = r,
                        RadiusY = r
                    }));

                case "path":
                    return(PathBuilder.Create(target, element.GetPath(), D2D1.FillMode.Alternate));

                case "text":
                    var geom = new D2D1.PathGeometry(target.Factory);
                    using (var sink = geom.Open())
                    {
                        var font         = element.GetFont(context);
                        var fontFace     = fontManager.GetFontFace(font);
                        var glyphIndices = fontFace.GetGlyphIndices("Clip Test");
                        var xx           = new[] { 35f, 50f, 55f, 65f, 45f, 48f, 52f, 32f, 61f };
                        fontFace.GetGlyphRunOutline(
                            font.Size,
                            glyphIndices,
                            xx,
                            null,
                            glyphIndices.Length,
                            false,
                            false,
                            sink);

                        sink.Close();

                        return(new D2D1.TransformedGeometry(
                                   target.Factory,
                                   geom,
                                   Matrix3x2.Translation(0, font.Size)
                                   ));

                        //return geom;
                    }

                default:
                    return(null);
                }
            }
            else
            {
                var targetBounds = GetBounds(targetElement, context);

                switch (element.ElementType)
                {
                case "rect":
                    var rectBounds = element.GetBounds(context);
                    var w          = targetBounds.Width * rectBounds.Width;
                    var h          = targetBounds.Height * rectBounds.Height;
                    var x          = targetBounds.X + (targetBounds.Width * rectBounds.X);
                    var y          = targetBounds.Y + (targetBounds.Height * rectBounds.Y);
                    return(new D2D1.RectangleGeometry(
                               target.Factory,
                               new RawRectangleF(x, y, x + w, y + h)
                               ));

                case "circle":
                    var r    = element.GetRadius(context);
                    var cxCy = element.GetCxCy(context);
                    return(new D2D1.EllipseGeometry(target.Factory, new D2D1.Ellipse()
                    {
                        Point = new RawVector2(targetBounds.X + (cxCy.X * targetBounds.Width), targetBounds.Y + (cxCy.Y * targetBounds.Height)),
                        RadiusX = r * targetBounds.Width,
                        RadiusY = r * targetBounds.Width
                    }));

                case "path":
                    return(PathBuilder.Create(target, element.GetPath(), D2D1.FillMode.Alternate));

                default:
                    return(null);
                }
            }
        }
Example #38
0
 public PradaProduct(IElement element)
 {
     _element = element;
 }
Example #39
0
        private static UIBase ParseAttributeForOptionsField(IElement element, int[] layout)
        {
            int[] elmLayout = GetLayout(element.Children[0].Style, layout);
            var   tmp       = new UIOptions()
            {
                x      = elmLayout[0],
                y      = elmLayout[1],
                width  = elmLayout[2],
                height = elmLayout[3]
            };


            try
            {
                if (element.Children[0].TextContent[0] != '~')
                {   // Is readonly attribute
                    tmp.Text     = element.Children[0].TextContent;
                    tmp.ReadOnly = true;
                }
                else
                {
                    tmp.Text = element.Children[0].TextContent.Substring(1);
                }
                tmp.WidthLabel = element.Children[0].GetWidth();
                tmp.NestedName = element.Children[1].GetAttribute("nested-name");
                tmp.Value      = element.Children[1].GetAttribute("value");

                tmp.Options = new Dictionary <string, string>();
                tmp.Options.Add("", "");

                foreach (var elm in element.Children[1].Children)
                {
                    if (elm.TagName == "OPTION")
                    {
                        // Get the value of the selection (id)
                        string value = elm.GetAttribute("value");
                        // Get the description of the option
                        string key = elm.TextContent.Replace('\u00A0', ' '); /// Make sur no break spaces are replaced by spaces.
                        // This can be used to lookup the comos value to change in case user select a description (key)
                        tmp.Options[key] = value;                            // !! comos web could have duplicate optons, assuming here values will be same.

                        string selected = elm.GetAttribute("selected");
                        if (selected != null && string.Compare(selected, "selected") == 0)
                        {
                            // We assume here that when a comos spec has a unit. The selection of the unit
                            // Is the last xhtml eleemnt of the spec.
                            tmp.Value = key;
                        }
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                }
                if (tmp.Value == null)
                {
                    tmp.Value = " ";
                }
            }
            catch (Exception)
            {
                //throw;
            }



            return(tmp);
        }
Example #40
0
 public EventElement(IElement child)
 {
     Child = child;
 }
Example #41
0
 private static UIBase ParseAttributeQuery(IElement element, int[] layout)
 {
     return(new UIQuery());
 }
 public Polyline(IElement element, SVG svg) : base(element, svg)
 {
     Points = Element.GetAttributeOrEmpty("points").ToPoints();
 }
Example #43
0
        private static void ParseAttributes(CAttributes attributes, IElement element, int indent)
        {
            foreach (var elm in element.Children)
            {
                string nested_name = elm.GetAttribute("nested-name");
                if (!string.IsNullOrEmpty(nested_name))
                {
                    CAttribute attribute = attributes[nested_name];
                    if (attribute == null)
                    {
                        attribute               = new CAttribute();
                        attribute.NestedName    = nested_name;
                        attributes[nested_name] = attribute;
                    }
                    if (elm.TagName == "SPAN")
                    {
                        if (elm.TextContent[0] != '~')
                        {
                            attribute.Description = elm.TextContent;
                            attribute.ReadOnly    = true;
                        }
                        else
                        {
                            // Is a readonly attribute
                            attribute.Description = elm.TextContent.Substring(1);
                        }
                    }
                    else if (elm.TagName == "INPUT")
                    {
                        switch (elm.ClassName)
                        {
                        case "SUICheckBox":
                        {
                            string value = elm.GetAttribute("checked");
                            if (string.IsNullOrEmpty(value) ||
                                string.Compare(value, "checked") != 0)
                            {
                                attribute.Value = false.ToString();
                            }
                            else
                            {
                                attribute.Value = true.ToString();
                            }
                            attribute.IsBoolean = true;
                        }
                        break;

                        case "SUIText":
                            attribute.Value = elm.GetAttribute("value");
                            break;

                        default:
                            Debug.Assert(false);
                            break;
                        }
                    }
                    else if (elm.TagName == "SELECT")
                    {
                        ParseOptions(attribute, elm, indent + 1);
                        continue;
                    }
                    else if (elm.TagName == "TEXTAREA")
                    {
                        attribute.Value = elm.TextContent;
                        continue;
                    }


                    //else
                    //    DumpElement(elm, indent);

                    // Do the controls stuff
                    if (elm.ClassName != null)
                    {
                        UIType uitype = (UIType)Enum.Parse(typeof(UIType), elm.ClassName);
                    }
                }
                ParseAttributes(attributes, elm, indent + 1);
            }
        }
Example #44
0
        private static UIBase ParseAttributeForCheckBox(IElement element, int[] layout, CheckBoxOrientation checkBoxOrientation)
        {
            // Test for check box
            int[] elmLayout = GetLayout(element.Children[0].Style, layout);
            // This is a Checkbox
            var checkbox = new UICheckBox()
            {
                x      = elmLayout[0],
                y      = elmLayout[1],
                width  = elmLayout[2],
                height = elmLayout[3]
            };

            checkbox.NestedName = element.Children[0].GetAttribute("nested-name");
            string value;

            if (checkBoxOrientation == CheckBoxOrientation.RIGHT)
            {
                value = element.Children[1].GetAttribute("checked");
            }
            else
            {
                value = element.Children[0].GetAttribute("checked");
            }

            if (string.IsNullOrEmpty(value) ||
                string.Compare(value, "checked") != 0)
            {
                checkbox.Value = false;
            }
            else
            {
                checkbox.Value = true;
            }

            if (element.Children[(int)checkBoxOrientation].TextContent[0] != '~')
            {   // Is readonly attribute
                checkbox.Text     = element.Children[(int)checkBoxOrientation].TextContent;
                checkbox.ReadOnly = true;
            }
            else
            {
                checkbox.Text = element.Children[(int)checkBoxOrientation].TextContent.Substring(1);
            }
            checkbox.WidthLabel = element.Children[(int)checkBoxOrientation].GetWidth();
            elmLayout           = GetLayout(element.Children[1].Style, layout);
            if (checkbox.x < elmLayout[0])
            {
                checkbox.x = elmLayout[0];
            }
            if (checkbox.y < elmLayout[1])
            {
                checkbox.y = elmLayout[1];
            }
            if (checkbox.width < elmLayout[2])
            {
                checkbox.width = elmLayout[2];
            }
            if (checkbox.height < elmLayout[3])
            {
                checkbox.height = elmLayout[3];
            }

            return(checkbox);
        }
Example #45
0
 public override void AddElement(IElement element)
 {
     throw new ArgumentException("HTML table does not support AddElement operation!");
 }
Example #46
0
        private static void ParseAttributeForUI(List <UIBase> attributes, List <UIBase> attributesNotIn, IElement element, int[] layout)
        {
            UIBase elm        = null;
            int    nbChildren = element.Children.Count();

            if ((element.Id != null) && (element.Id.ToUpper().Contains("LABEL")))
            {
                elm = ParseAttributeForLabel(element, layout);
            }


            if (nbChildren == 2)
            {
                // Could be an edit field, option list or checkbox
                if (element.Children[0].ClassName == "SUICheckBox")
                {
                    // Is a left check box
                    elm = ParseAttributeForCheckBox(element, layout, CheckBoxOrientation.LEFT);
                }
                else if (element.Children[1].ClassName == "SUICheckBox")
                {
                    // Is a right check box
                    elm = ParseAttributeForCheckBox(element, layout, CheckBoxOrientation.RIGHT);
                }
                else if (element.Children[1].ClassName == "SUIText")
                {
                    // Is an edit field
                    elm = ParseAttributeForTextField(element, layout);
                }
                else if (element.Children[0].ClassName == "SUITextArea")
                {
                    // Is an memo field
                    elm = ParseAttributeForMemoField(element, layout, 0);
                }
                else if (element.Children[1].ClassName == "SUITextArea")
                {
                    // Is an memo field
                    elm = ParseAttributeForMemoField(element, layout, 1);
                }
                else if (element.Children[1].TagName == "SELECT")
                {
                    // Is an options field
                    elm = ParseAttributeForOptionsField(element, layout);
                }
            }
            else if (nbChildren == 3)
            {
                if (element.Children[1].ClassName == "SUIText" && element.Children[2].TagName == "SELECT")
                {
                    // Is a text field with Unit selection.
                    elm = ParseAttributeForTextFieldWidthUnit(element, layout);
                }
                else if (element.Children[1].ClassName == "SUITextArea")
                {
                    // Is an memo field with button
                    elm = ParseAttributeForMemoField(element, layout, 1);
                }
            }
            else if (nbChildren == 4)
            {
                // Comos Date
                elm = ParseAttributeForTextField(element, layout);
            }
            else if (nbChildren == 5)
            {
                // Comos Link
                Debug.WriteLine("Unsupported at this stage.");
            }
            else
            {
                // Comos Button
                Debug.WriteLine("Unsupported at this stage.");
            }

            bool found = false;

            if (elm != null)
            {
                // find the frame it belongs to
                foreach (var item in attributes)
                {
                    var frame = item as UIFrame;
                    if (frame != null)
                    {
                        if (elm.IsIn(frame))
                        {
                            frame.AddChild(elm);
                            found = true;
                        }
                    }
                }
                if (!found)
                {
                    attributesNotIn.Add(elm);
                }
            }
        }
Example #47
0
        public IMatrix MassMatrix(IElement element)
        {
            double x2 = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2 = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double z2 = Math.Pow(element.Nodes[1].Z - element.Nodes[0].Z, 2);
            double L  = 1d / Math.Sqrt(x2 + y2 + z2);
            //double halfMass = 0.5 * Density * SectionArea * L;

            //var massMatrix = new SymmetricMatrix<double>(new double[] { halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0, 0,
            //    halfMass, 0, 0, 0,
            //    halfMass, 0, 0,
            //    halfMass, 0,
            //    halfMass
            //});
            double halfMass   = Density * SectionArea / L / 6d;
            int    order      = 12;
            Matrix massMatrix = SymmetricMatrix.CreateFromPackedRowMajorArray(
                new double[] { halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0, 0,
                               0, 0, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0, 0,
                               halfMass, 0, 0, 0, 0,
                               halfMass, 0, 0, 0,
                               0, 0, 0,
                               0, 0,
                               0 }, order).CopyToFullMatrix();

            var refx = new double[] { 1, 1, 1 };
            var beamTransformation = Matrix.CreateZero(order, order);

            beamTransformation[0, 0] = (element.Nodes[1].X - element.Nodes[0].X) * L;
            beamTransformation[0, 1] = (element.Nodes[1].Y - element.Nodes[0].Y) * L;
            beamTransformation[0, 2] = (element.Nodes[1].Z - element.Nodes[0].Z) * L;

            beamTransformation[1, 0] = refx[1] * beamTransformation[0, 2] - refx[2] * beamTransformation[0, 1];
            beamTransformation[1, 1] = refx[2] * beamTransformation[0, 0] - refx[0] * beamTransformation[0, 2];
            beamTransformation[1, 2] = refx[0] * beamTransformation[0, 1] - refx[1] * beamTransformation[0, 0];
            double dn = 1.0 / Math.Sqrt(beamTransformation[1, 0] * beamTransformation[1, 0] + beamTransformation[1, 1] * beamTransformation[1, 1] + beamTransformation[1, 2] * beamTransformation[1, 2]);

            beamTransformation[1, 0] = beamTransformation[1, 0] * dn;
            beamTransformation[1, 1] = beamTransformation[1, 1] * dn;
            beamTransformation[1, 2] = beamTransformation[1, 2] * dn;
            beamTransformation[2, 0] = beamTransformation[0, 1] * beamTransformation[1, 2] - beamTransformation[0, 2] * beamTransformation[1, 1];
            beamTransformation[2, 1] = beamTransformation[0, 2] * beamTransformation[1, 0] - beamTransformation[0, 0] * beamTransformation[1, 2];
            beamTransformation[2, 2] = beamTransformation[0, 0] * beamTransformation[1, 1] - beamTransformation[0, 1] * beamTransformation[1, 0];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    beamTransformation[i + 3, j + 3] = beamTransformation[i, j];
                    beamTransformation[i + 6, j + 6] = beamTransformation[i, j];
                    beamTransformation[i + 9, j + 9] = beamTransformation[i, j];
                }
            }
            CalculateRotTranformation(element);

            return(dofEnumerator.GetTransformedMatrix(
                       rotTransformation.ThisTransposeTimesOtherTimesThis(
                           beamTransformation.ThisTransposeTimesOtherTimesThis(massMatrix))));
        }
Example #48
0
        private static void ParseAttributesForUI(List <UIBase> attributes, List <UIBase> attributesNotIn, IElement element, int[] layout)
        {
            int[] lay = GetLayout(element.Style, layout);

            if (element.TagName == "DIV")
            {
                // Test if the element could be a comos frame.
                if (element.Style.BorderRadius == "4px")
                {
                    // This is a frame
                    attributes.Add(new UIFrame()
                    {
                        x      = lay[0],
                        y      = lay[1],
                        width  = lay[2],
                        height = lay[3]
                    });
                }
                // Test if element is label defining the frame.
                else if (element.Id != null && element.Id.StartsWith("Border"))
                {
                    // This defines a text of a frame
                    // This text is always after the border definition.
                    // => Get the matching UIFrame (is last in list)
                    UIFrame frame = (UIFrame)attributes.Last();
                    frame.Text = element.TextContent;
                }
                // Else the children elements of this div define a specific tab control attribute
                else if (element.Children.Count() == 1)
                {
                    ParseAttributeForUI(attributes, attributesNotIn, element.Children[0], lay);
                }
                else if (element.ClassName == "SUIQuery")
                {
                    // query spec
                    ParseQueryForUI(attributes, element, lay);
                }
                else
                {
                    Debug.Assert(false); // All elements should be divs
                }
            }
            else
            {
                Debug.Assert(false); // All elements should be divs
            }
        }
Example #49
0
        private IMatrix StiffnessMatrixPure(IElement element)
        {
            double x2 = Math.Pow(element.Nodes[1].X - element.Nodes[0].X, 2);
            double y2 = Math.Pow(element.Nodes[1].Y - element.Nodes[0].Y, 2);
            double z2 = Math.Pow(element.Nodes[1].Z - element.Nodes[0].Z, 2);
            double L  = 1 / Math.Sqrt(x2 + y2 + z2);
            double L2 = L * L;
            double L3 = L2 * L;
            //double EIx = m.YoungModulus * MomentOfInertiaX;
            double EIy = this.youngModulus * MomentOfInertiaY;
            double EIz = this.youngModulus * MomentOfInertiaZ;
            double GJL = this.youngModulus * L * MomentOfInertiaPolar / (2 * (1 + this.poissonRatio));
            double EAL = this.youngModulus * SectionArea * L;

            //TODO: optimize this
            int    order           = 12;
            Matrix stiffnessMatrix = SymmetricMatrix.CreateFromPackedRowMajorArray(new double[]
            {
                EAL, 0, 0, 0, 0, 0, -EAL, 0, 0, 0, 0, 0,
                12 * EIz * L3, 0, 0, 0, 6 * EIz * L2, 0, -12 * EIz * L3, 0, 0, 0, 6 * EIz * L2,
                12 * EIy * L3, 0, -6 * EIy * L2, 0, 0, 0, -12 * EIy * L3, 0, -6 * EIy * L2, 0,
                GJL, 0, 0, 0, 0, 0, -GJL, 0, 0,
                4 * EIy * L, 0, 0, 0, 6 * EIy * L2, 0, 2 * EIy * L, 0,
                4 * EIz * L, 0, -6 * EIz * L2, 0, 0, 0, 2 * EIz * L,
                EAL, 0, 0, 0, 0, 0,
                12 * EIz * L3, 0, 0, 0, -6 * EIz * L2,
                12 * EIy * L3, 0, 6 * EIy * L2, 0,
                GJL, 0, 0,
                4 * EIy * L, 0,
                4 * EIz * L
            }, order).CopyToFullMatrix();

            var refx = new double[] { 1, 1, 1 };
            var beamTransformation = Matrix.CreateZero(order, order);

            beamTransformation[0, 0] = (element.Nodes[1].X - element.Nodes[0].X) * L;
            beamTransformation[0, 1] = (element.Nodes[1].Y - element.Nodes[0].Y) * L;
            beamTransformation[0, 2] = (element.Nodes[1].Z - element.Nodes[0].Z) * L;

            //beamTransformation[2, 0] = refx[0];
            //beamTransformation[2, 1] = refx[1];
            //beamTransformation[2, 2] = refx[2];

            //beamTransformation[1, 0] = beamTransformation[2, 1] * beamTransformation[0, 2] - beamTransformation[2, 2] * beamTransformation[0, 1];
            //beamTransformation[1, 1] = beamTransformation[2, 2] * beamTransformation[0, 0] - beamTransformation[2, 0] * beamTransformation[0, 2];
            //beamTransformation[1, 2] = beamTransformation[2, 0] * beamTransformation[0, 1] - beamTransformation[2, 1] * beamTransformation[0, 0];
            beamTransformation[1, 0] = refx[1] * beamTransformation[0, 2] - refx[2] * beamTransformation[0, 1];
            beamTransformation[1, 1] = refx[2] * beamTransformation[0, 0] - refx[0] * beamTransformation[0, 2];
            beamTransformation[1, 2] = refx[0] * beamTransformation[0, 1] - refx[1] * beamTransformation[0, 0];
            double dn = 1.0 / Math.Sqrt(beamTransformation[1, 0] * beamTransformation[1, 0] + beamTransformation[1, 1] * beamTransformation[1, 1] + beamTransformation[1, 2] * beamTransformation[1, 2]);

            beamTransformation[1, 0] = beamTransformation[1, 0] * dn;
            beamTransformation[1, 1] = beamTransformation[1, 1] * dn;
            beamTransformation[1, 2] = beamTransformation[1, 2] * dn;
            beamTransformation[2, 0] = beamTransformation[0, 1] * beamTransformation[1, 2] - beamTransformation[0, 2] * beamTransformation[1, 1];
            beamTransformation[2, 1] = beamTransformation[0, 2] * beamTransformation[1, 0] - beamTransformation[0, 0] * beamTransformation[1, 2];
            beamTransformation[2, 2] = beamTransformation[0, 0] * beamTransformation[1, 1] - beamTransformation[0, 1] * beamTransformation[1, 0];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    beamTransformation[i + 3, j + 3] = beamTransformation[i, j];
                    beamTransformation[i + 6, j + 6] = beamTransformation[i, j];
                    beamTransformation[i + 9, j + 9] = beamTransformation[i, j];
                }
            }

            return(beamTransformation.ThisTransposeTimesOtherTimesThis(stiffnessMatrix));

            ////if (element.Nodes.Count(n => n.EmbeddedInElement != null) == 0) return stiffnessMatrix;
            //stiffnessMatrix = new SymmetricMatrix<double>(beamTransformation.Transpose() * stiffnessMatrix.ToMatrix() * beamTransformation);
            //if (embeddedNodes.Count == 0) return stiffnessMatrix;

            ////var hostElements = element.Nodes.Select(x => x.EmbeddedInElement).Distinct();
            //var size = GetElementDOFTypes(element).SelectMany(x => x).Count();
            //transformation = new Matrix<double>(dofs.SelectMany(d => d).Count(), size);
            //isNodeEmbedded = new bool[element.Nodes.Count];

            ////TODO : SEPARATE FROM ELEMENT!!
            ////TODO: Must match DOFs of host with embedded element
            //int row = 0;
            //int col = 0;
            //hostElementList = new List<Element>();
            //for (int i = 0; i < element.Nodes.Count; i++)
            //{
            //    var node = element.Nodes[i];
            //    var embeddedNode = embeddedNodes.Where(x => x.Node == node).FirstOrDefault();
            //    //var hostElement = node.EmbeddedInElement;
            //    Element hostElement = embeddedNode == null ? null : embeddedNode.EmbeddedInElement;
            //    if (hostElement == null)
            //    {
            //        isNodeEmbedded[i] = false;
            //        for (int j = 0; j < dofs[i].Length; j++)
            //        {
            //            transformation[row, col] = 1;
            //            row++;
            //            col++;
            //        }
            //    }
            //    else
            //    {
            //        isNodeEmbedded[i] = true;
            //        //double[] hostShapeFunctions = ((IEmbeddedHostElement)hostElement.ElementType).GetShapeFunctionsForNode(hostElement, node);
            //        double[] hostShapeFunctions = ((IEmbeddedHostElement)hostElement.ElementType).GetShapeFunctionsForNode(hostElement, embeddedNode);

            //        if (hostElementList.IndexOf(hostElement) < 0)
            //            hostElementList.Add(hostElement);
            //        else
            //            col -= hostShapeFunctions.Length * hostDofsPerNode;

            //        for (int j = 0; j < commonDofsPerNode; j++)
            //        {
            //            for (int k = 0; k < hostShapeFunctions.Length; k++)
            //                transformation[row, hostDofsPerNode * k + col + j] = hostShapeFunctions[k];
            //            row++;
            //        }
            //        row += embeddedDofsPerNode - commonDofsPerNode;
            //        col += hostShapeFunctions.Length * hostDofsPerNode;
            //    }
            //}

            //// Add identity matrix
            //int index = 0;
            //if (isNodeEmbedded[0])
            //{
            //    transformation[3, col] = 1;
            //    transformation[4, col + 1] = 1;
            //    transformation[5, col + 2] = 1;
            //    index += 3;
            //}
            //if (isNodeEmbedded[1])
            //{
            //    transformation[9, col + index] = 1;
            //    transformation[10, col + index + 1] = 1;
            //    transformation[11, col + index + 2] = 1;
            //}

            //var transformedMatrix = new SymmetricMatrix<double>(transformation.Transpose() * stiffnessMatrix.ToMatrix() * transformation);
            ////var sw = File.CreateText(@"d:\BeamTransformed.txt");
            ////for (int i = 0; i < 54; i++)
            ////{
            ////    var s = string.Empty;
            ////    for (int j = 0; j < 54; j++)
            ////        s += transformedMatrix[i, j].ToString() + ";";
            ////    sw.WriteLine(s);
            ////}
            ////sw.Close();
            //return transformedMatrix;
        }
Example #50
0
 public Tuple <double[], double[]> CalculateStresses(IElement element, double[] localDisplacements, double[] localdDisplacements)
 {
     return(new Tuple <double[], double[]>(new double[6], new double[6]));
     //throw new NotImplementedException();
 }
        internal void AnalyzeWikiContentBlock(List <WebPartEntity> webparts, IHtmlDocument htmlDoc, List <WebPartPlaceHolder> webPartsToRetrieve, int rowCount, int colCount, IElement content)
        {
            // Drop elements which we anyhow can't transform and/or which are stripped out from RTE
            CleanHtml(content, htmlDoc);

            StringBuilder textContent = new StringBuilder();
            int           order       = 0;

            foreach (var node in content.ChildNodes)
            {
                // Do we find a web part inside...
                if (((node as IHtmlElement) != null) && ContainsWebPart(node as IHtmlElement))
                {
                    var    extraText              = StripWebPart(node as IHtmlElement);
                    string extraTextAfterWebPart  = null;
                    string extraTextBeforeWebPart = null;
                    if (!string.IsNullOrEmpty(extraText))
                    {
                        // Should be, but checking anyhow
                        int webPartMarker = extraText.IndexOf(webPartMarkerString);
                        if (webPartMarker > -1)
                        {
                            extraTextBeforeWebPart = extraText.Substring(0, webPartMarker);
                            extraTextAfterWebPart  = extraText.Substring(webPartMarker + webPartMarkerString.Length);

                            // there could have been multiple web parts in a row (we don't support text inbetween them for now)...strip the remaining markers
                            extraTextBeforeWebPart = extraTextBeforeWebPart.Replace(webPartMarkerString, "");
                            extraTextAfterWebPart  = extraTextAfterWebPart.Replace(webPartMarkerString, "");
                        }
                    }

                    if (!string.IsNullOrEmpty(extraTextBeforeWebPart))
                    {
                        textContent.AppendLine(extraTextBeforeWebPart);
                    }

                    // first insert text part (if it was available)
                    if (!string.IsNullOrEmpty(textContent.ToString()))
                    {
                        order++;
                        webparts.Add(CreateWikiTextPart(textContent.ToString(), rowCount, colCount, order));
                        textContent.Clear();
                    }

                    // then process the web part
                    order++;
                    Regex regexClientIds = new Regex(@"id=\""div_(?<ControlId>(\w|\-)+)");
                    if (regexClientIds.IsMatch((node as IHtmlElement).OuterHtml))
                    {
                        foreach (Match webPartMatch in regexClientIds.Matches((node as IHtmlElement).OuterHtml))
                        {
                            // Store the web part we need, will be retrieved afterwards to optimize performance
                            string serverSideControlId            = webPartMatch.Groups["ControlId"].Value;
                            var    serverSideControlIdToSearchFor = $"g_{serverSideControlId.Replace("-", "_")}";
                            webPartsToRetrieve.Add(new WebPartPlaceHolder()
                            {
                                ControlId = serverSideControlIdToSearchFor, Id = serverSideControlId, Row = rowCount, Column = colCount, Order = order
                            });
                        }
                    }

                    // Process the extra text that was positioned after the web part (if any)
                    if (!string.IsNullOrEmpty(extraTextAfterWebPart))
                    {
                        textContent.AppendLine(extraTextAfterWebPart);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(node.TextContent.Trim()) && node.TextContent.Trim() == "\n")
                    {
                        // ignore, this one is typically added after a web part
                    }
                    else
                    {
                        if (node.HasChildNodes)
                        {
                            textContent.AppendLine((node as IHtmlElement).OuterHtml);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(node.TextContent.Trim()))
                            {
                                textContent.AppendLine(node.TextContent);
                            }
                            else
                            {
                                if (node.NodeName.Equals("br", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    textContent.AppendLine("<BR>");
                                }
                                // given that wiki html can contain embedded images and videos while not having child nodes we need include these.
                                // case: img/iframe tag as "only" element to evaluate (e.g. first element in the contenthost)
                                else if (node.NodeName.Equals("img", StringComparison.InvariantCultureIgnoreCase) ||
                                         node.NodeName.Equals("iframe", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    textContent.AppendLine((node as IHtmlElement).OuterHtml);
                                }
                            }
                        }
                    }
                }
            }

            // there was only one text part
            if (!string.IsNullOrEmpty(textContent.ToString()))
            {
                // insert text part to the web part collection
                order++;
                webparts.Add(CreateWikiTextPart(textContent.ToString(), rowCount, colCount, order));
            }
        }
Example #52
0
 public IMatrix StiffnessMatrix(IElement element)
 {
     CalculateRotTranformation(element);
     return(dofEnumerator.GetTransformedMatrix(
                rotTransformation.ThisTransposeTimesOtherTimesThis(StiffnessMatrixPure(element))));
 }
Example #53
0
 public void SetWidth(IElement element, double width)
 {
     (element.Native as FrameworkElement).Width = width;
 }
Example #54
0
        private void CalculateRotTranformation(IElement element)
        {
            if (rotNodes[0] == null && rotNodes[1] == null)
            {
                rotTransformation = Matrix.CreateIdentity(12);
                return;
            }

            int[] transMatrixRows    = new int[] { 3, 9 };
            int[] transMatrixCols    = new int[] { 6, 18 };
            int[] transMatrixColRows = new int[] { 0, 3 };
            int   nonRotationalDOFs  = 24;

            //            int nonRotationalDOFs = 0;
            if (rotNodes[0] == null)
            {
                nonRotationalDOFs  = 13;
                transMatrixRows    = new int[] { -1, 9 };
                transMatrixCols    = new int[] { -1, 9 };
                transMatrixColRows = new int[] { -1, 6 };
            }
            if (rotNodes[1] == null)
            {
                nonRotationalDOFs  = 13;
                transMatrixRows    = new int[] { 3, -1 };
                transMatrixCols    = new int[] { 9, -1 };
                transMatrixColRows = new int[] { 0, -1 };
            }

            for (int i = 0; i < 2; i++)
            {
                if (rotNodes[i] == null)
                {
                    nonRotationalDOFs += 2;
                }
            }
            //else
            //    nonRotationalDOFs += 12;

            rotTransformation       = Matrix.CreateZero(12, nonRotationalDOFs + 6);
            rotTransformation[0, 0] = 1;
            rotTransformation[1, 1] = 1;
            rotTransformation[2, 2] = 1;
            if (rotNodes[0] == null)
            {
                rotTransformation[3, 3] = 1;
                rotTransformation[4, 4] = 1;
                rotTransformation[5, 5] = 1;
                rotTransformation[6, 6] = 1;
                rotTransformation[7, 7] = 1;
                rotTransformation[8, 8] = 1;
            }
            else if (rotNodes[1] == null)
            {
                rotTransformation[6, 3]  = 1;
                rotTransformation[7, 4]  = 1;
                rotTransformation[8, 5]  = 1;
                rotTransformation[9, 6]  = 1;
                rotTransformation[10, 7] = 1;
                rotTransformation[11, 8] = 1;
            }
            else
            {
                rotTransformation[6, 3] = 1;
                rotTransformation[7, 4] = 1;
                rotTransformation[8, 5] = 1;
            }

            double[][] rotDifsX       = new double[2][];
            double[][] rotDifsY       = new double[2][];
            double[][] rotDifsZ       = new double[2][];
            double[][] lengthsSquared = new double[2][];
            for (int i = 0; i < 2; i++)
            {
                if (rotNodes[i] == null)
                {
                    continue;
                }

                rotDifsX[i] = new double[]
                {
                    rotNodes[i][0].X - element.Nodes[i].X,
                    rotNodes[i][1].X - element.Nodes[i].X,
                    rotNodes[i][2].X - element.Nodes[i].X,
                    rotNodes[i][3].X - element.Nodes[i].X
                };
                rotDifsY[i] = new double[]
                {
                    rotNodes[i][0].Y - element.Nodes[i].Y,
                    rotNodes[i][1].Y - element.Nodes[i].Y,
                    rotNodes[i][2].Y - element.Nodes[i].Y,
                    rotNodes[i][3].Y - element.Nodes[i].Y
                };
                rotDifsZ[i] = new double[]
                {
                    rotNodes[i][0].Z - element.Nodes[i].Z,
                    rotNodes[i][1].Z - element.Nodes[i].Z,
                    rotNodes[i][2].Z - element.Nodes[i].Z,
                    rotNodes[i][3].Z - element.Nodes[i].Z
                };

                lengthsSquared[i] = new double[]
                {
                    Math.Pow(rotDifsX[i][0], 2) + Math.Pow(rotDifsY[i][0], 2) + Math.Pow(rotDifsZ[i][0], 2),
                    Math.Pow(rotDifsX[i][1], 2) + Math.Pow(rotDifsY[i][1], 2) + Math.Pow(rotDifsZ[i][1], 2),
                    Math.Pow(rotDifsX[i][2], 2) + Math.Pow(rotDifsY[i][2], 2) + Math.Pow(rotDifsZ[i][2], 2),
                    Math.Pow(rotDifsX[i][3], 2) + Math.Pow(rotDifsY[i][3], 2) + Math.Pow(rotDifsZ[i][3], 2)
                };
            }

            for (int i = 0; i < 2; i++)
            {
                if (rotNodes[i] == null)
                {
                    continue;
                }

                int r  = transMatrixRows[i];
                int c  = transMatrixCols[i];
                int cr = transMatrixColRows[i];

                rotTransformation[r + 0, cr + 1] = rotDifsY[i][3] / lengthsSquared[i][3] -
                                                   rotDifsY[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 0, cr + 2] = rotDifsZ[i][3] / lengthsSquared[i][3] -
                                                   rotDifsZ[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 0, c + 4]  = rotDifsY[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 0, c + 5]  = rotDifsZ[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 0, c + 10] = -rotDifsY[i][3] / lengthsSquared[i][3];
                rotTransformation[r + 0, c + 11] = -rotDifsZ[i][3] / lengthsSquared[i][3];

                rotTransformation[r + 1, cr + 0] = rotDifsX[i][2] / lengthsSquared[i][2] -
                                                   rotDifsX[i][0] / lengthsSquared[i][0] + rotDifsZ[i][3] / lengthsSquared[i][3] -
                                                   rotDifsZ[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 1, cr + 2] = rotDifsZ[i][2] / lengthsSquared[i][2] -
                                                   rotDifsZ[i][0] / lengthsSquared[i][0] + rotDifsX[i][3] / lengthsSquared[i][3] -
                                                   rotDifsX[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 1, c + 0]  = rotDifsX[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 1, c + 2]  = rotDifsZ[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 1, c + 3]  = rotDifsX[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 1, c + 5]  = rotDifsZ[i][1] / lengthsSquared[i][1];
                rotTransformation[r + 1, c + 6]  = -rotDifsX[i][2] / lengthsSquared[i][2];
                rotTransformation[r + 1, c + 8]  = -rotDifsZ[i][2] / lengthsSquared[i][2];
                rotTransformation[r + 1, c + 9]  = -rotDifsX[i][3] / lengthsSquared[i][3];
                rotTransformation[r + 1, c + 11] = -rotDifsZ[i][3] / lengthsSquared[i][3];

                rotTransformation[r + 2, cr + 0] = rotDifsX[i][2] / lengthsSquared[i][2] -
                                                   rotDifsX[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 2, cr + 1] = rotDifsY[i][2] / lengthsSquared[i][2] -
                                                   rotDifsY[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 2, c + 0] = rotDifsX[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 2, c + 1] = rotDifsY[i][0] / lengthsSquared[i][0];
                rotTransformation[r + 2, c + 6] = -rotDifsX[i][2] / lengthsSquared[i][2];
                rotTransformation[r + 2, c + 7] = -rotDifsY[i][2] / lengthsSquared[i][2];

                //rotTransformation[r + 0, cr + 1] = rotDifsY[i][3] / lengthsSquared[i][3] +
                //    rotDifsY[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 0, cr + 2] = rotDifsZ[i][3] / lengthsSquared[i][3] +
                //    rotDifsZ[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 0, c + 4] = rotDifsY[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 0, c + 5] = rotDifsZ[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 0, c + 10] = rotDifsY[i][3] / lengthsSquared[i][3];
                //rotTransformation[r + 0, c + 11] = rotDifsZ[i][3] / lengthsSquared[i][3];

                //rotTransformation[r + 1, cr + 0] = rotDifsX[i][2] / lengthsSquared[i][2] +
                //    rotDifsX[i][0] / lengthsSquared[i][0] + rotDifsZ[i][3] / lengthsSquared[i][3] +
                //    rotDifsZ[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 1, cr + 2] = rotDifsZ[i][2] / lengthsSquared[i][2] +
                //    rotDifsZ[i][0] / lengthsSquared[i][0] + rotDifsX[i][3] / lengthsSquared[i][3] +
                //    rotDifsX[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 1, c + 0] = rotDifsX[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 1, c + 2] = rotDifsZ[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 1, c + 3] = rotDifsX[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 1, c + 5] = rotDifsZ[i][1] / lengthsSquared[i][1];
                //rotTransformation[r + 1, c + 6] = rotDifsX[i][2] / lengthsSquared[i][2];
                //rotTransformation[r + 1, c + 8] = rotDifsZ[i][2] / lengthsSquared[i][2];
                //rotTransformation[r + 1, c + 9] = rotDifsX[i][3] / lengthsSquared[i][3];
                //rotTransformation[r + 1, c + 11] = rotDifsZ[i][3] / lengthsSquared[i][3];

                //rotTransformation[r + 2, cr + 0] = rotDifsX[i][2] / lengthsSquared[i][2] +
                //    rotDifsX[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 2, cr + 1] = rotDifsY[i][2] / lengthsSquared[i][2] +
                //    rotDifsY[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 2, c + 0] = rotDifsX[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 2, c + 1] = rotDifsY[i][0] / lengthsSquared[i][0];
                //rotTransformation[r + 2, c + 6] = rotDifsX[i][2] / lengthsSquared[i][2];
                //rotTransformation[r + 2, c + 7] = rotDifsY[i][2] / lengthsSquared[i][2];
            }
        }
Example #55
0
 public void SetLeft(IElement element, double left)
 {
     Canvas.SetLeft(element.Native as FrameworkElement, left);
 }
Example #56
0
 public void SetHeight(IElement element, double height)
 {
     (element.Native as FrameworkElement).Height = height;
 }
Example #57
0
 public double GetWidth(IElement element)
 {
     return((element.Native as FrameworkElement).Width);
 }
Example #58
0
 public void SetTop(IElement element, double top)
 {
     Canvas.SetTop(element.Native as FrameworkElement, top);
 }
Example #59
0
 public double GetTop(IElement element)
 {
     return(Canvas.GetTop(element.Native as FrameworkElement));
 }
Example #60
0
 public double GetHeight(IElement element)
 {
     return((element.Native as FrameworkElement).Height);
 }