Beispiel #1
0
 private static T GetValue <T>(ICompositeObject compositeObject, string key)
 {
     if (compositeObject.TryGetValue(key, out T value))
     {
         return(value);
     }
     return(default(T));
 }
Beispiel #2
0
        public decimal CalculateImageInFile(string FileFormatInDoc)
        {
            LoadDocument();

            Decimal pixelHeight = 96;
            Decimal pixelWidthl = 96;
            Decimal pixelArea   = pixelHeight * pixelWidthl;
            Decimal amount      = multiplier;
            Decimal finalAmount = 0;

            Spire.Doc.Document document = new Spire.Doc.Document(FileFormatInDoc);
            int index = 0;

            //Create a new Que
            Queue <ICompositeObject> containers = new Queue <ICompositeObject>();

            //Put the document Objects in the queue
            containers.Enqueue(document);

            while (containers.Count > 0)
            {
                ICompositeObject container = (ICompositeObject)containers.Dequeue();

                IDocumentObjectCollection docObjects = container.ChildObjects;

                foreach (DocumentObject docObject in docObjects)
                {
                    //judge the object type

                    if (docObject.DocumentObjectType == Spire.Doc.Documents.DocumentObjectType.Picture)
                    {
                        DocPicture picture = docObject as DocPicture;

                        decimal picHeight = pixelToInches(picture.Height + (picture.Height * 0.33));
                        decimal picWidth  = pixelToInches(picture.Width + (picture.Width * 0.33));
                        decimal picArea   = picHeight * picWidth;

                        finalAmount = finalAmount + (picArea * amount);
                        //'Name the image.
                        //'Dim imageName As String = String.Format("Image-{0}.png", index)
                        //'Save the image.
                        //'picture.Image.Save(imageName, System.Drawing.Imaging.ImageFormat.Png)
                        index += 1;
                    }
                    else
                    {
                        if (docObject is ICompositeObject)
                        {
                            containers.Enqueue(docObject as ICompositeObject);
                        }
                    }
                }
            }
            //MessageBox.Show(Convert.ToString(Math.Round(finalAmount, 0)), "Output");
            var value = Convert.ToString(Math.Round(finalAmount, 0));

            return(Convert.ToDecimal(value));
        }
        internal virtual void RemoveSelf()
        {
            ICompositeObject owner = base.Owner as ICompositeObject;

            if ((owner != null) && (owner.ChildObjects != null))
            {
                owner.ChildObjects.Remove(this);
            }
        }
Beispiel #4
0
        internal int method_5()
        {
            ICompositeObject owner = this.Owner as ICompositeObject;

            if (owner != null)
            {
                return(owner.ChildObjects.IndexOf(this));
            }
            return(-1);
        }
Beispiel #5
0
 public bool Fetch()
 {
     if (((this.Current != null) && (this.Current.Owner != null)) && this.Current.Owner.IsComposite)
     {
         ICompositeObject owner = this.Current.Owner as ICompositeObject;
         if (owner.ChildObjects.Count > (this.Index + 1))
         {
             this.Index++;
             this.Current = owner.ChildObjects[this.Index];
             return(true);
         }
     }
     this.Current = null;
     this.Index   = -1;
     return(false);
 }
Beispiel #6
0
        private ISensor FindSensor(string id, ICompositeObject cobject)
        {
            var result = cobject.Sensors.Where(s => s.HardId == id).FirstOrDefault();

            if (result == null)
            {
                foreach (var cobj in cobject.GetCompositeObjects())
                {
                    result = FindSensor(id, cobj);
                    if (result != null)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Beispiel #7
0
        private ICompositeObject FindCompositeObject(string id, ICompositeObject obj)
        {
            var result = obj.GetCompositeObjects().Where(s => s.ClientId == id).FirstOrDefault();

            if (result == null)
            {
                foreach (var cobj in obj.GetCompositeObjects())
                {
                    result = FindCompositeObject(id, cobj);
                    if (result != null)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //open document
            Document document = new Document(@"..\..\..\..\..\..\Data\Template.docx");

            //document elements, each of them has child elements
            Queue <ICompositeObject> nodes = new Queue <ICompositeObject>();

            nodes.Enqueue(document);

            //embedded images list.
            IList <Image> images = new List <Image>();

            //traverse
            while (nodes.Count > 0)
            {
                ICompositeObject node = nodes.Dequeue();
                foreach (IDocumentObject child in node.ChildObjects)
                {
                    if (child is ICompositeObject)
                    {
                        nodes.Enqueue(child as ICompositeObject);

                        if (child.DocumentObjectType == DocumentObjectType.Picture)
                        {
                            DocPicture picture = child as DocPicture;
                            images.Add(picture.Image);
                        }
                    }
                }
            }
            //save images
            for (int i = 0; i < images.Count; i++)
            {
                String fileName = String.Format("Image-{0}.png", i);
                images[i].Save(fileName, ImageFormat.Png);
            }

            if (images.Count > 0)
            {
                //show the first image
                System.Diagnostics.Process.Start("Image-0.png");
            }
        }
Beispiel #9
0
        internal virtual void CloneCommit()
        {
            ICompositeObject obj2 = this as ICompositeObject;

            if (obj2 != null)
            {
                DocumentObjectCollection childObjects = obj2.ChildObjects;
                int num   = 0;
                int count = childObjects.Count;
                while (num < count)
                {
                    childObjects[num].CloneCommit();
                    if (childObjects.Count < count)
                    {
                        num--;
                        count--;
                    }
                    num++;
                }
            }
        }
Beispiel #10
0
    public Class883(Field A_0)
    {
        int num5 = 0x11;

        this.list_0 = new List <Struct28>();
        this.list_1 = new List <int>();
        this.list_2 = new List <Struct30>();
        this.int_0  = -2147483648;
        if (A_0 == null)
        {
            throw new ArgumentNullException(BookmarkStart.b("儶倸帺儼嬾", num5));
        }
        this.field_0 = A_0;
        ICompositeObject owner = A_0.Owner as ICompositeObject;

        if (owner != null)
        {
            int index = owner.ChildObjects.IndexOf(A_0);
            int num2  = -1;
            if (A_0.Owner.Owner != null)
            {
                num2 = (A_0.Owner.Owner as ICompositeObject).ChildObjects.IndexOf(A_0.Owner);
            }
            this.struct30_0 = new Struct30(num2, index);
            int num3 = owner.ChildObjects.IndexOf(A_0.Range.method_10());
            int num4 = -1;
            if (A_0.Range.method_10() is ParagraphBase)
            {
                num4 = num2;
            }
            else if (A_0.Range.method_10() is Paragraph)
            {
                Paragraph entity = A_0.Range.method_10() as Paragraph;
                num3 = entity.Items.IndexOf(A_0.End);
                num4 = entity.Owner.ChildObjects.IndexOf(entity);
            }
            this.struct30_1 = new Struct30(num4, num3);
        }
    }
Beispiel #11
0
        private ISensor FindSensor(string id, ICompositeObject cobject)
        {
            var result = cobject.Sensors.Where(s => s.HardId == id).FirstOrDefault();

            if (result == null)
            {
                foreach (var cobj in cobject.GetCompositeObjects())
                {
                    result = FindSensor(id, cobj);
                    if (result != null)
                        break;
                }
            }

            return result;
        }
Beispiel #12
0
 public ICompositeObject AddCompositeObject(ICompositeObject cobject)
 {
     AddCompositeObjectInternal(cobject);
     return(this);
 }
Beispiel #13
0
 protected void AddCompositeObjectInternal(ICompositeObject obj)
 {
     _all.Add(obj);
     obj.Parent = this;
 }
Beispiel #14
0
 protected void AddCompositeObjectInternal(ICompositeObject obj)
 {
     _all.Add(obj);
 }
Beispiel #15
0
 public ICompositeObject AddCompositeObject(ICompositeObject cobject)
 {
     AddCompositeObjectInternal(cobject);
     return this;
 }
Beispiel #16
0
        private ICompositeObject FindCompositeObject(string id, ICompositeObject obj)
        {
            var result = obj.GetCompositeObjects().Where(s => s.ClientId == id).FirstOrDefault();

            if (result == null)
            {
                foreach (var cobj in obj.GetCompositeObjects())
                {
                    result = FindCompositeObject(id, cobj);
                    if (result != null)
                        break;
                }
            }

            return result;
        }
Beispiel #17
0
 protected void AddCompositeObjectInternal(ICompositeObject obj)
 {
     _all.Add(obj);
     obj.Parent = this;
 }
Beispiel #18
0
    private void method_116()
    {
        Borders borders = this.paragraph_0.Format.Borders;

        if (!borders.NoBorder && !this.paragraph_0.SectionEndMark)
        {
            Class372 class1 = base.Interface22.imethod_0();
            class1.method_5(class1.method_4() + (borders.Top.LineWidth + borders.Top.Space));
            if (borders.Bottom.Shadow)
            {
                Class372 class2 = base.Interface22.imethod_0();
                class2.method_13(class2.method_12() + ((borders.Bottom.LineWidth * 2f) + borders.Bottom.Space));
            }
            else
            {
                Class372 class3 = base.Interface22.imethod_0();
                class3.method_13(class3.method_12() + (borders.Bottom.LineWidth + borders.Bottom.Space));
            }
        }
        if (((this.paragraph_0.PreviousSibling is Paragraph) && ((this.paragraph_0.PreviousSibling as Paragraph).Format.Borders.Bottom.BorderType != BorderStyle.Cleared)) && (((this.paragraph_0.PreviousSibling as Paragraph).Format.Borders.Bottom.BorderType != BorderStyle.None) && ((this.paragraph_0.PreviousSibling as Paragraph).Format.Borders.Bottom.LineWidth > 0f)))
        {
            Class372 class4 = base.Interface22.imethod_0();
            class4.method_5(class4.method_4() + (this.paragraph_0.PreviousSibling as Paragraph).Format.Borders.Bottom.LineWidth);
        }
        if (!borders.NoBorder)
        {
            if (borders.Bottom.BorderType != BorderStyle.None)
            {
                base.Interface22.imethod_0().method_15(borders.Bottom.Space);
            }
            if (borders.Top.BorderType != BorderStyle.None)
            {
                base.Interface22.imethod_0().method_7(borders.Top.Space);
            }
            IDocumentObject previousSibling = this.paragraph_0.PreviousSibling;
            if ((previousSibling == null) && (borders.Top.BorderType != BorderStyle.None))
            {
                base.method_50(true);
            }
            else
            {
                if ((!(previousSibling is Paragraph) && (this.paragraph_0.Owner is SDTContent)) && (this.paragraph_0.Owner.Owner is StructureDocumentTag))
                {
                    ICompositeObject owner = this.paragraph_0.Owner.Owner.Owner as ICompositeObject;
                    int index = owner.ChildObjects.IndexOf(this.paragraph_0.Owner.Owner);
                    if ((index >= 1) && (index <= (owner.ChildObjects.Count - 1)))
                    {
                        previousSibling = owner.ChildObjects[index - 1];
                    }
                    else
                    {
                        previousSibling = null;
                    }
                }
                if (previousSibling is StructureDocumentTag)
                {
                    previousSibling = (previousSibling as StructureDocumentTag).ChildObjects.LastItem;
                }
                if (previousSibling is Paragraph)
                {
                    Paragraph       paragraph2 = previousSibling as Paragraph;
                    ParagraphFormat format     = this.paragraph_0.method_93();
                    ParagraphFormat format2    = paragraph2.method_93();
                    Borders         borders2   = !paragraph2.Format.Borders.NoBorder ? paragraph2.Format.Borders : ((((paragraph2.ParaStyle == null) || (paragraph2.ParaStyle.ParagraphFormat == null)) || paragraph2.ParaStyle.ParagraphFormat.Borders.NoBorder) ? null : paragraph2.ParaStyle.ParagraphFormat.Borders);
                    if (borders2 != null)
                    {
                        if (borders2.NoBorder && (borders.Top.BorderType != BorderStyle.None))
                        {
                            base.method_50(true);
                        }
                        else if (!borders2.NoBorder && ((!format.method_68(format2) || !format.method_69(format2)) || (((borders2.Bottom.BorderType == BorderStyle.None) || !borders2.Bottom.method_57(borders.Top)) && (!borders2.Bottom.method_57(borders.Bottom) || !borders2.Top.method_57(borders.Top)))))
                        {
                            base.method_50(true);
                        }
                    }
                    else if ((borders2 == null) && (borders.Top.BorderType != BorderStyle.None))
                    {
                        base.method_50(true);
                    }
                }
            }
            IDocumentObject nextSibling = this.paragraph_0.NextSibling;
            if ((nextSibling == null) && (borders.Bottom.BorderType != BorderStyle.None))
            {
                base.method_48(true);
            }
            else
            {
                if ((!(nextSibling is Paragraph) && (this.paragraph_0.Owner is SDTContent)) && (this.paragraph_0.Owner.Owner is StructureDocumentTag))
                {
                    ICompositeObject obj2 = this.paragraph_0.Owner.Owner.Owner as ICompositeObject;
                    int num = obj2.ChildObjects.IndexOf(this.paragraph_0.Owner.Owner);
                    if ((num >= 0) && (num <= (obj2.ChildObjects.Count - 2)))
                    {
                        nextSibling = obj2.ChildObjects[num + 1];
                    }
                    else
                    {
                        nextSibling = null;
                    }
                }
                if (nextSibling is StructureDocumentTag)
                {
                    nextSibling = (nextSibling as StructureDocumentTag).ChildObjects.FirstItem;
                }
                if (nextSibling is Paragraph)
                {
                    Paragraph       paragraph = nextSibling as Paragraph;
                    ParagraphFormat format3   = this.paragraph_0.method_93();
                    ParagraphFormat format4   = paragraph.method_93();
                    Borders         borders3  = !paragraph.Format.Borders.NoBorder ? paragraph.Format.Borders : ((((paragraph.ParaStyle == null) || (paragraph.ParaStyle.ParagraphFormat == null)) || paragraph.ParaStyle.ParagraphFormat.Borders.NoBorder) ? null : paragraph.ParaStyle.ParagraphFormat.Borders);
                    if (borders3 != null)
                    {
                        if (borders3.NoBorder && (borders.Bottom.BorderType != BorderStyle.None))
                        {
                            base.method_48(true);
                        }
                        else if (!borders3.NoBorder && ((!format3.method_68(format4) || !format3.method_69(format4)) || (((borders3.Top.BorderType == BorderStyle.None) || !borders3.Top.method_57(borders.Bottom)) && (!borders3.Bottom.method_57(borders.Bottom) || !borders3.Top.method_57(borders.Top)))))
                        {
                            base.method_48(true);
                        }
                    }
                    else if ((borders3 == null) && (borders.Bottom.BorderType != BorderStyle.None))
                    {
                        base.method_48(true);
                    }
                }
            }
        }
        if (!base.method_49())
        {
            base.Interface22.imethod_0().method_5(0.0);
            base.Interface22.imethod_0().method_7(0f);
        }
        if (!base.method_47())
        {
            base.Interface22.imethod_0().method_13(0.0);
            base.Interface22.imethod_0().method_15(0f);
        }
    }
 public IViewComponentResult Invoke(ICompositeObject obj)
 {
     return View(obj);
 }