Ejemplo n.º 1
0
        private string GetElementTypeName(PartElement element)
        {
            switch (element)
            {
            case PartSurface _:
                return(ModelLocalizations.Label_Surface);

            case PartBone _:
                return(ModelLocalizations.Label_Bone);

            case MaleStudModel _:
                return(ModelLocalizations.ModelComponentType_MaleStud);

            case FemaleStudModel _:
                return(ModelLocalizations.ModelComponentType_FemaleStud);

            case BrickTubeModel _:
                return(ModelLocalizations.ModelComponentType_BrickTube);

            case PartModel _:
                return(ModelLocalizations.ModelComponentType_Part);

            case ModelMeshReference _:
                return(ModelLocalizations.Label_Mesh);

            case PartConnection _:
                return(ModelLocalizations.Label_Connection);

            case PartCollision _:
                return(ModelLocalizations.Label_Collision);
            }

            return(element.GetType().Name);
        }
Ejemplo n.º 2
0
 public static PartElement Field(this PartElement me, string label, int length, string id = "*")
 {
     me?.Fields.Add(new FieldElement {
         Label = label, Length = length, Id = id
     });
     return(me);
 }
Ejemplo n.º 3
0
        private void FillSelectionDetails(PartElement selection)
        {
            if (SelectedElement != null)
            {
                SelectedElement.PropertyChanged -= SelectedElement_PropertyChanged;
                SelectedElement = null;
            }

            using (FlagManager.UseFlag("FillSelectionDetails"))
            {
                FillElementProperties(selection);

                if (ProjectManager.SelectedElements.Count > 1)
                {
                    FillStudRefDetails(null);
                }
                else
                {
                    FillStudRefDetails(selection as PartCullingModel);
                }

                SelectedElement = selection;
                if (SelectedElement != null)
                {
                    SelectedElement.PropertyChanged += SelectedElement_PropertyChanged;
                }
            }
        }
Ejemplo n.º 4
0
 public ElementCollectionNode(PartElement element, IElementCollection collection, string text)
 {
     Element    = element;
     Collection = collection;
     NodeID     = collection.GetHashCode().ToString();
     Text       = text;
 }
        public static void Run()
        {
            // ExStart:CreateStructureElements
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_WorkingDocuments();

            // Create Pdf Document
            Document document = new Document();

            // Get Content for work with TaggedPdf
            ITaggedContent taggedContent = document.TaggedContent;

            // Set Title and Language for Documnet
            taggedContent.SetTitle("Tagged Pdf Document");
            taggedContent.SetLanguage("en-US");

            // Create Grouping Elements
            PartElement       partElement       = taggedContent.CreatePartElement();
            ArtElement        artElement        = taggedContent.CreateArtElement();
            SectElement       sectElement       = taggedContent.CreateSectElement();
            DivElement        divElement        = taggedContent.CreateDivElement();
            BlockQuoteElement blockQuoteElement = taggedContent.CreateBlockQuoteElement();
            CaptionElement    captionElement    = taggedContent.CreateCaptionElement();
            TOCElement        tocElement        = taggedContent.CreateTOCElement();
            TOCIElement       tociElement       = taggedContent.CreateTOCIElement();
            IndexElement      indexElement      = taggedContent.CreateIndexElement();
            NonStructElement  nonStructElement  = taggedContent.CreateNonStructElement();
            PrivateElement    privateElement    = taggedContent.CreatePrivateElement();

            // Create Text Block-Level Structure Elements
            ParagraphElement paragraphElement = taggedContent.CreateParagraphElement();
            HeaderElement    headerElement    = taggedContent.CreateHeaderElement();
            HeaderElement    h1Element        = taggedContent.CreateHeaderElement(1);

            // Create Text Inline-Level Structure Elements
            SpanElement  spanElement  = taggedContent.CreateSpanElement();
            QuoteElement quoteElement = taggedContent.CreateQuoteElement();
            NoteElement  noteElement  = taggedContent.CreateNoteElement();

            // Create Illustration Structure Elements
            FigureElement  figureElement  = taggedContent.CreateFigureElement();
            FormulaElement formulaElement = taggedContent.CreateFormulaElement();

            // Methods are under development
            ListElement      listElement      = taggedContent.CreateListElement();
            TableElement     tableElement     = taggedContent.CreateTableElement();
            ReferenceElement referenceElement = taggedContent.CreateReferenceElement();
            BibEntryElement  bibEntryElement  = taggedContent.CreateBibEntryElement();
            CodeElement      codeElement      = taggedContent.CreateCodeElement();
            LinkElement      linkElement      = taggedContent.CreateLinkElement();
            AnnotElement     annotElement     = taggedContent.CreateAnnotElement();
            RubyElement      rubyElement      = taggedContent.CreateRubyElement();
            WarichuElement   warichuElement   = taggedContent.CreateWarichuElement();
            FormElement      formElement      = taggedContent.CreateFormElement();

            // Save Tagged Pdf Document
            document.Save(dataDir + "StructureElements.pdf");
            // ExEnd:CreateStructureElements
        }
Ejemplo n.º 6
0
 public static PartElement Constant(this PartElement me, string label, int length,
                                    string value)
 {
     me?.Fields.Add(new ConstantElement {
         Label = label, Value = value
     });
     return(me);
 }
Ejemplo n.º 7
0
 public ProjectElementNode(PartElement element)
 {
     Element = element;
     NodeID  = element.ID;
     if (string.IsNullOrEmpty(NodeID))
     {
         NodeID = element.GetHashCode().ToString();
     }
 }
Ejemplo n.º 8
0
        public static PartElement Part(this PartCollection me, string id)
        {
            var p = new PartElement {
                Id = id
            };

            me?.Add(p);
            return(p);
        }
Ejemplo n.º 9
0
        public static SwitchElement Switch(this PartElement me, string label, string on)
        {
            var sw = new SwitchElement {
                Label = label, On = on
            };

            me?.Fields.Add(sw);
            return(sw);
        }
Ejemplo n.º 10
0
        public static LoopElement Loop(this PartElement me, string label, string from, string to, string step = "1")
        {
            var loop = new LoopElement {
                Label = label, From = from, To = to, Step = step
            };

            me?.Fields.Add(loop);
            return(loop);
        }
Ejemplo n.º 11
0
        public static GroupElement Group(this PartElement me, string label)
        {
            var group = new GroupElement {
                Label = label
            };

            me?.Fields.Add(group);
            return(group);
        }
Ejemplo n.º 12
0
        private void RefreshElementName(PartElement element)
        {
            var elemNode = FindElementNode(element);

            if (elemNode != null)
            {
                elemNode.Text = element.Name;
                ProjectTreeView.RefreshObject(elemNode);
            }
        }
Ejemplo n.º 13
0
        private void DeserializeBaseElement(PartElement element, XElement xml)
        {
            if (xml.HasAttribute("ID", out XAttribute idAttr))
            {
                element.ID = idAttr.Value;
            }

            if (xml.HasAttribute("Name", out XAttribute nameAttr))
            {
                element.InternalSetName(nameAttr.Value);
            }
        }
Ejemplo n.º 14
0
        protected PartElementModel(PartElement element)
        {
            Element = element;
            Element.PropertyChanged += Element_PropertyChanged;

            ModelExtension = element.GetExtension <ModelElementExtension>();

            if (ModelExtension != null)
            {
                Visible = ModelExtension.IsVisible;
                ModelExtension.VisibilityChanged += Extender_VisibilityChanged;
            }
        }
Ejemplo n.º 15
0
 private void SelectElementNodeDelayed(PartElement element)
 {
     BeginInvoke((Action)(() =>
     {
         var elementNode = FindElementNode(element);
         if (elementNode.Parent != null)
         {
             ProjectTreeView.Expand(elementNode.Parent);
         }
         using (FlagManager.UseFlag("ManualSelect"))
             ProjectTreeView.SelectObject(elementNode);
     }));
 }
Ejemplo n.º 16
0
        public override void FreeObjects()
        {
            base.FreeObjects();

            if (Element != null)
            {
                var modelExtension = GetElementExtension <ModelElementExtension>();
                if (modelExtension != null)
                {
                    modelExtension.VisibilityChanged -= ModelExtension_VisibilityChanged;
                }
                Element.ParentChanged -= Element_ParentChanged;
                Element = null;
            }
        }
Ejemplo n.º 17
0
        protected XElement SerializeBaseElement(PartElement element, string elementName)
        {
            var elem = new XElement(elementName);

            if (!string.IsNullOrEmpty(element.ID))
            {
                elem.Add(new XAttribute("ID", element.ID));
            }

            if (!string.IsNullOrEmpty(element.Name))
            {
                elem.Add(new XAttribute("Name", element.Name));
            }

            return(elem);
        }
Ejemplo n.º 18
0
        public ProjectElementNode(PartElement element)
        {
            Element = element;
            NodeID  = element.ID;
            if (string.IsNullOrEmpty(NodeID))
            {
                NodeID = element.GetHashCode().ToString();
            }
            Element.ParentChanged += Element_ParentChanged;

            var modelExtension = GetElementExtension <ModelElementExtension>();

            if (modelExtension != null)
            {
                modelExtension.VisibilityChanged += ModelExtension_VisibilityChanged;
            }
        }
Ejemplo n.º 19
0
        protected PartElementModel(PartElement element)
        {
            Element = element;
            Element.PropertyChanged += Element_PropertyChanged;

            ModelExtension = element.GetExtension <ModelElementExtension>();

            if (ModelExtension != null)
            {
                Visible = ModelExtension.IsVisible;
                ModelExtension.VisibileChanged += Extender_VisibileChanged;
            }

            Element.ParentChanging += Element_ParentChanging;
            Element.ParentChanged  += Element_ParentChanged;

            Element_ParentChanged(null, EventArgs.Empty);
        }
Ejemplo n.º 20
0
        public XElement ToXML()
        {
            XElement xOutputDocumentClass = new XElement(Fb2Const.fb2DefaultNamespace + OutputDocumentElementName);

            xOutputDocumentClass.Add(new XAttribute("name", Name));
            if (Create != GenerationInstructionEnum.Unknown)
            {
                xOutputDocumentClass.Add(new XAttribute("create", GetXCreate()));
            }
            if (Price != null)
            {
                xOutputDocumentClass.Add(new XAttribute("price", Price.ToString()));
            }
            foreach (ShareInstructionType PartElement in parts)
            {
                xOutputDocumentClass.Add(PartElement.ToXML());
            }
            return(xOutputDocumentClass);
        }
Ejemplo n.º 21
0
        private string GetElementTypeName2(PartElement element)
        {
            if (element is PartSurface)
            {
                return(ModelLocalizations.Label_Surface);
            }

            switch (element)
            {
            case PartSurface _:
                return(ModelLocalizations.Label_Surface);

            case PartBone _:
                return(ModelLocalizations.Label_Bone);

            case MaleStudModel _:
                return(ModelLocalizations.ModelComponentType_MaleStud);

            case FemaleStudModel _:
                return(ModelLocalizations.ModelComponentType_FemaleStud);

            case BrickTubeModel _:
                return(ModelLocalizations.ModelComponentType_BrickTube);

            case PartModel _:
                return(ModelLocalizations.ModelComponentType_Part);

            case ModelMeshReference _:
                return(ModelLocalizations.Label_Mesh);

            case PartConnection conn:
                return($"{ModelLocalizations.Label_Connection} <{conn.ConnectorType.ToString()}>");

            //return ModelLocalizations.ResourceManager.GetString($"ConnectorType_{conn.ConnectorType}");
            case PartCollision coll:
                string collType = ModelLocalizations.ResourceManager.GetString($"CollisionType_{coll.CollisionType}");
                return($"{ModelLocalizations.Label_Collision} ({collType})");
            }

            return(element.GetType().Name);
        }
Ejemplo n.º 22
0
        public static ProjectElementNode CreateDefault(PartElement element)
        {
            var node = new ProjectElementNode(element);

            if (element is PartSurface surface)
            {
                if (surface.SurfaceID == 0)
                {
                    node.Text = ModelLocalizations.Label_MainSurface;

                    node.ImageKey = "Surface_Main";
                }
                else
                {
                    node.Text     = string.Format(ModelLocalizations.Label_DecorationSurfaceNumber, surface.SurfaceID);
                    node.ImageKey = "Surface_Decoration";
                }
            }
            else
            {
                node.Text = element.Name;
                if (element is SurfaceComponent component)
                {
                    node.ImageKey = $"Model_{component.ComponentType}";
                }
                else if (element is PartConnection connection)
                {
                    node.ImageKey = $"Connection_{connection.ConnectorType}";
                }
                else if (element is PartCollision collision)
                {
                    node.ImageKey = $"Collision_{collision.CollisionType}";
                }
                else if (element is ModelMeshReference || element is ModelMesh)
                {
                    node.ImageKey = "Mesh";
                }
            }
            return(node);
        }
Ejemplo n.º 23
0
 public BoneElementExtension(PartElement element) : base(element)
 {
 }
Ejemplo n.º 24
0
 public ProjectElementNode FindElementNode(PartElement element)
 {
     return(GetAllTreeNodes().OfType <ProjectElementNode>()
            .FirstOrDefault(x => x.Element == element));
 }
Ejemplo n.º 25
0
 public PartElementModel GetElementModel(PartElement element)
 {
     return(Models.OfType <PartElementModel>().FirstOrDefault(x => x.Element == element));
 }
Ejemplo n.º 26
0
        private void FillElementProperties(PartElement element)
        {
            ToggleControlsEnabled(element != null,
                                  NameTextBox,
                                  NameLabel);

            NameTextBox.Text = element?.Name ?? string.Empty;

            SubMaterialIndexLabel.Visible = element is PartSurface;
            SubMaterialIndexBox.Visible   = element is PartSurface;

            CollisionRadiusLabel.Visible = element is PartSphereCollision;
            CollisionRadiusBox.Visible   = element is PartSphereCollision;

            CollisionSizeLabel.Visible  = element is PartBoxCollision;
            CollisionSizeEditor.Visible = element is PartBoxCollision;

            if (SelectionTransformEdit.Tag != null)
            {
                SelectionTransformEdit.BindPhysicalElement(null);
            }

            if (element != null)
            {
                SelectionInfoLabel.Text = GetElementTypeName(element);

                switch (element)
                {
                case PartSurface surface:
                    SubMaterialIndexBox.Value = surface.SubMaterialIndex;
                    break;

                case PartBoxCollision boxCollision:
                    CollisionSizeEditor.Value = boxCollision.Size * 2d;
                    break;

                case PartSphereCollision sphereCollision:
                    CollisionRadiusBox.Value = sphereCollision.Radius;
                    break;
                }
            }
            else
            {
                if (ProjectManager.SelectedElements.Count > 1)
                {
                    SelectionInfoLabel.Text = MultiSelectionMsg.Text;
                }
                else
                {
                    SelectionInfoLabel.Text = NoSelectionMsg.Text;
                }
            }

            if (element is IPhysicalElement physicalElement)
            {
                SelectionTransformEdit.BindPhysicalElement(physicalElement);
                SelectionTransformEdit.Tag     = physicalElement;
                SelectionTransformEdit.Enabled = true;
            }
            else
            {
                SelectionTransformEdit.Enabled = false;
            }
        }