コード例 #1
0
        public Paragraph AddToDocParagraph(WIKIParser wikiParser, OpenXmlElement parent, int level, int id, string headingStyle)
        {
            // Add the heading
            if (this.IsHeading && !string.IsNullOrEmpty(this.Context))
            {
                Paragraph pHeading = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = headingStyle
                }),
                    DocHelper.CreateRun(this.Context));
                parent.Append(pHeading);

                if (!string.IsNullOrEmpty(this.HeadingDescription))
                {
                    OpenXmlElement parsedHeadingDescription = wikiParser.ParseAsOpenXML(this.HeadingDescription);

                    if (parsedHeadingDescription != null)
                    {
                        foreach (OpenXmlElement cParsedChild in parsedHeadingDescription.ChildElements)
                        {
                            OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                            this.ApplyStyleToElement(cClonedParsedChild);
                            parent.Append(cClonedParsedChild);
                        }
                    }
                }
            }

            // Add the description above the constraint definition
            if (!string.IsNullOrEmpty(this.Description))
            {
                OpenXmlElement parsedDescription = wikiParser.ParseAsOpenXML(this.Description);

                if (parsedDescription != null)
                {
                    foreach (OpenXmlElement cParsedChild in parsedDescription.ChildElements)
                    {
                        OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                        this.ApplyStyleToElement(cClonedParsedChild);
                        parent.Append(cClonedParsedChild);
                    }
                }
            }

            // Add the constraint definition
            Paragraph para = new Paragraph(
                new ParagraphProperties(
                    new NumberingProperties(
                        new NumberingLevelReference()
            {
                Val = level
            },
                        new NumberingId()
            {
                Val = id
            })));

            foreach (ConstraintPart cPart in this.parts)
            {
                switch (cPart.PartType)
                {
                case ConstraintPart.PartTypes.Keyword:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.ConformanceVerbStyle));
                    break;

                case ConstraintPart.PartTypes.Context:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.ConstraintContextStyle));
                    break;

                case ConstraintPart.PartTypes.Template:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.TemplateOidStyle));
                    break;

                case ConstraintPart.PartTypes.Vocabulary:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.VocabularyConstraintStyle));
                    break;

                case ConstraintPart.PartTypes.Link:
                    para.Append(
                        DocHelper.CreateAnchorHyperlink(cPart.Text, cPart.LinkDestination, Properties.Settings.Default.LinkStyle));
                    break;

                case ConstraintPart.PartTypes.Constraint:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, (cPart.IsAnchor ? "C_" + this.Number : string.Empty)));
                    break;

                case ConstraintPart.PartTypes.PrimitiveText:
                    wikiParser.ParseAndAppend(cPart.Text, para, true);
                    break;

                default:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text));
                    break;
                }
            }

            // Add the label after a line break on the run to the paragraph
            if (!string.IsNullOrEmpty(this.Label))
            {
                string additionalLabel = string.Format("Note: {0}", this.Label);
                para.AppendChild(new Break());
                para.AppendChild(
                    DocHelper.CreateRun(additionalLabel));
            }

            parent.Append(para);

            return(para);
        }
コード例 #2
0
        public Paragraph AddToDocParagraph(MainDocumentPart mainPart, HyperlinkTracker hyperlinkTracker, OpenXmlElement parent, int level, int id, string headingStyle)
        {
            // Add the heading
            if (this.IsHeading && !string.IsNullOrEmpty(this.Context))
            {
                string headingTitle = this.Context;

                if (!string.IsNullOrEmpty(this.Category))
                {
                    headingTitle += " for " + this.Category;
                }

                Paragraph pHeading = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = headingStyle
                }),
                    DocHelper.CreateRun(headingTitle));
                parent.Append(pHeading);

                if (!string.IsNullOrEmpty(this.HeadingDescription))
                {
                    OpenXmlElement parsedHeadingDescription = this.HeadingDescription.MarkdownToOpenXml(this.tdb, mainPart);

                    if (parsedHeadingDescription != null)
                    {
                        foreach (OpenXmlElement cParsedChild in parsedHeadingDescription.ChildElements)
                        {
                            OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                            this.ApplyStyleToElement(cClonedParsedChild);
                            parent.Append(cClonedParsedChild);
                        }
                    }
                }
            }

            // Add the description above the constraint definition
            if (!string.IsNullOrEmpty(this.Description))
            {
                OpenXmlElement parsedDescription = this.Description.MarkdownToOpenXml(this.tdb, mainPart);

                if (parsedDescription != null)
                {
                    foreach (OpenXmlElement cParsedChild in parsedDescription.ChildElements)
                    {
                        OpenXmlElement cClonedParsedChild = cParsedChild.CloneNode(true);
                        this.ApplyStyleToElement(cClonedParsedChild);
                        parent.Append(cClonedParsedChild);
                    }
                }
            }

            // Add the constraint definition
            Paragraph para = new Paragraph(
                new ParagraphProperties(
                    new NumberingProperties(
                        new NumberingLevelReference()
            {
                Val = level
            },
                        new NumberingId()
            {
                Val = id
            })));

            foreach (ConstraintPart cPart in this.parts)
            {
                switch (cPart.PartType)
                {
                case ConstraintPart.PartTypes.Keyword:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.ConformanceVerbStyle));
                    break;

                case ConstraintPart.PartTypes.Context:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.ConstraintContextStyle));
                    break;

                case ConstraintPart.PartTypes.Template:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.TemplateOidStyle));
                    break;

                case ConstraintPart.PartTypes.Vocabulary:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text, style: Properties.Settings.Default.VocabularyConstraintStyle));
                    break;

                case ConstraintPart.PartTypes.Link:
                    hyperlinkTracker.AddHyperlink(para, cPart.Text, cPart.LinkDestination, Properties.Settings.Default.LinkStyle);
                    break;

                case ConstraintPart.PartTypes.Constraint:
                    var newRun = DocHelper.CreateRun(cPart.Text);

                    if (cPart.IsAnchor)
                    {
                        hyperlinkTracker.AddAnchorAround(para, "C_" + this.Number, newRun);
                    }
                    else
                    {
                        para.Append(newRun);
                    }

                    break;

                case ConstraintPart.PartTypes.PrimitiveText:
                    var element = cPart.Text.MarkdownToOpenXml(this.tdb, mainPart, styleKeywords: true);
                    OpenXmlHelper.Append(element, para);
                    break;

                default:
                    para.Append(
                        DocHelper.CreateRun(cPart.Text));
                    break;
                }
            }

            // Add the label after a line break on the run to the paragraph
            if (!string.IsNullOrEmpty(this.Label))
            {
                string additionalLabel = string.Format("Note: {0}", this.Label);
                para.AppendChild(
                    new Run(
                        new Break()));
                para.AppendChild(
                    DocHelper.CreateRun(additionalLabel));
            }

            parent.Append(para);

            return(para);
        }
コード例 #3
0
 public DocHandler(DocHelper docHelper)
 {
     Log = new LogWrapper(this); 
     this.docHelper = docHelper;
 }
コード例 #4
0
ファイル: KeyedData.cs プロジェクト: wintelgoog/RimTrans
        public static KeyedData Load(string name, string path, bool backupInvalidFile = false)
        {
            KeyedData keyedData = new KeyedData();

            keyedData._data = new SortedDictionary <string, XDocument>();
            keyedData.Name  = name;

            DirectoryInfo dirInfo = new DirectoryInfo(path);

            if (dirInfo.Exists)
            {
                Log.Info();
                Log.Write("Loading Keyed: ");
                Log.WriteLine(ConsoleColor.Cyan, path);
                int countValidFiles   = 0;
                int countInvalidFiles = 0;
                int splitIndex        = dirInfo.FullName.Length + 1;
                foreach (FileInfo fileInfo in dirInfo.GetFiles("*.xml", SearchOption.AllDirectories))
                {
                    XDocument doc      = null;
                    string    filePath = fileInfo.FullName;
                    try {
                        doc = DocHelper.LoadLanguageDoc(filePath);
                        countValidFiles++;
                    } catch (XmlException ex) {
                        Log.Error();
                        Log.Write("Loading file failed: ");
                        Log.WriteLine(ConsoleColor.Red, filePath);
                        Log.Indent();
                        Log.WriteLine(ex.Message);
                        if (backupInvalidFile)
                        {
                            try {
                                string backupFile = filePath + ".BAK";
                                fileInfo.CopyTo(backupFile, true);
                                Log.Indent();
                                Log.Write("Having been backed up to: ");
                                Log.WriteLine(ConsoleColor.Yellow, backupFile);
                            } catch (Exception) {
                                Log.Error();
                                Log.WriteLine("Backing up failed.");
                                throw;
                            }
                        }
                        countInvalidFiles++;
                    }
                    if (doc != null)
                    {
                        keyedData._data.Add(filePath.Substring(splitIndex), doc);
                    }
                }
                if (countValidFiles > 0)
                {
                    if (countInvalidFiles == 0)
                    {
                        Log.Info();
                        Log.WriteLine("Completed Loading Keyed: {0} file(s).", countValidFiles);
                    }
                    else
                    {
                        Log.Warning();
                        Log.WriteLine("Completed Loading Keyed: Success: {0} file(s), Failure: {1} file(s).", countValidFiles, countInvalidFiles);
                    }
                }
                else
                {
                    if (countInvalidFiles == 0)
                    {
                        Log.Info();
                        Log.WriteLine("Directory \"Keyed\" is empty.");
                    }
                    else
                    {
                        Log.Error();
                        Log.WriteLine("Loading failed: {1} file(s).", countInvalidFiles);
                    }
                }
            }
            else
            {
                Log.Info();
                Log.Write("Directory \"Keyed\" does not exist: ");
                Log.WriteLine(ConsoleColor.Cyan, path);
            }
            return(keyedData);
        }
コード例 #5
0
 /// <summary>
 /// Registers all the input parameters for this component.
 /// </summary>
 /// <param name="pManager">Use the pManager to register new parameters. pManager is never null.</param>
 protected override void RegisterInputParams(GH_InputParamManager pManager)
 {
     pManager.AddCurveParameter("Polyline", "Pl", "A list of polylines to offset", GH_ParamAccess.item);
     pManager.AddPointParameter("Point", "P", "Offset Distance", GH_ParamAccess.item);
     pManager.AddPlaneParameter("Plane", "Pln", "Plane to project the polylines to", GH_ParamAccess.item, default);
     pManager.AddNumberParameter("Tolerance", "T", "Tolerance: all floating point data beyond this precision will be discarded.", GH_ParamAccess.item, DocHelper.GetModelTolerance());
 }
コード例 #6
0
        public IHttpActionResult Post(Guid?id, [FromBody] ExceptionActionForm form)
        {
            Guid   guid  = id.Value;
            string notes = form.archiveComment;
            int    iret;
            string message;

            if (string.IsNullOrWhiteSpace(notes))
            {
                iret    = -1;
                message = "Please enter resubmit comments.";
                return(Json(new { status = iret, message }));
            }
            else if (notes.Length < 10 || notes.Length > 1000)
            {
                iret    = -3;
                message = "Please make sure to enter resubmit comments of more than 9 characters and less then 1000 characters.";
                return(Json(new { status = iret, message }));
            }

            string user = (HttpContext.Current?.User as AuthPrincipal)?.UserName;

            if (form.action == "Archive")
            {
                string referenceNo = form.referenceNo;
                notes = string.IsNullOrWhiteSpace(user) ? "Unknow user" : user + $" archived this document on : {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}. Comment:{notes}";

                if (!Information.IsNumeric(referenceNo))
                {
                    iret    = -2;
                    message = "Please enter a number for reference number.";
                }
                else
                {
                    iret = DocHelper.ArchiveDoc(new Guid(form.appId), guid, referenceNo, notes);

                    if (iret >= 0)
                    {
                        message = "The document has been archived successfully.";
                    }
                    else
                    {
                        message = "Error occurred when archive document. Please contact technical support.";
                    }
                }

                return(Json(new { status = iret, message }));
            }
            else if (form.action == "Resubmit")
            {
                notes = string.IsNullOrWhiteSpace(user) ? "Unknow user" : user + $" resubmitted this document on : {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}. Comment:{notes}";

                iret = DocHelper.ResubmitDoc(new Guid(form.appId), guid, notes);
                if (iret >= 0)
                {
                    message = "Document has been resubmitted successfully.";
                }
                else
                {
                    message = "Error occurred when resubmit document. Please contact technical support.";
                }

                return(Json(new { status = iret, message }));
            }

            return(null);
        }
コード例 #7
0
        private void AddTemplateConstraint(TemplateConstraint constraint, int level)
        {
            // TODO: May be able to make this more efficient
            List <TemplateConstraint> childConstraints = this.AllConstraints
                                                         .Where(y => y.ParentConstraintId == constraint.Id)
                                                         .OrderBy(y => y.Order)
                                                         .ToList();

            this.templateConstraintCount++;

            // Add the description before the constraint
            if (!string.IsNullOrEmpty(constraint.Description))
            {
                Paragraph pDescription = new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId()
                {
                    Val = Properties.Settings.Default.TemplateDescriptionStyle
                })
                {
                    SpacingBetweenLines = new SpacingBetweenLines()
                    {
                        Before = new StringValue("80")
                    }
                },
                    DocHelper.CreateRun(constraint.Description, style: "Normal,Normal Not Indented"));
                this.DocumentBody.Append(pDescription);
            }

            Paragraph pConstraint = new Paragraph(
                new ParagraphProperties(
                    new NumberingProperties(
                        new NumberingLevelReference()
            {
                Val = level - 1
            },
                        new NumberingId()
            {
                Val = GenerationConstants.BASE_TEMPLATE_INDEX + (int)this.CurrentTemplate.Id
            })));
            string context = constraint.Context;

            // Build the constraint text
            if (constraint.IsPrimitive == true)
            {
                string narrativeText = !string.IsNullOrEmpty(constraint.PrimitiveText) ? constraint.PrimitiveText : "MISSING NARRATIVE";
                this.AddNarrative(pConstraint, narrativeText);
                pConstraint.Append(
                    DocHelper.CreateRun(" (CONF:" + constraint.Id.ToString() + ")"));
            }
            else
            {
                // SHOULD | SHALL | MAY | ETC.
                if (!string.IsNullOrEmpty(constraint.Conformance))
                {
                    pConstraint.Append(
                        DocHelper.CreateRun(constraint.Conformance, style: Properties.Settings.Default.ConformanceVerbStyle));
                    pConstraint.Append(
                        DocHelper.CreateRun(" contain "));
                }
                else
                {
                    pConstraint.Append(
                        DocHelper.CreateRun("Contains "));
                }

                // exactly one, zero or one, at least one, etc.
                switch (constraint.Cardinality)
                {
                case "1..1":
                    pConstraint.Append(
                        DocHelper.CreateRun(this.IGSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityOneToOne) + " "));
                    break;

                case "0..1":
                    pConstraint.Append(
                        DocHelper.CreateRun(this.IGSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZeroToOne) + " "));
                    break;

                case "1..*":
                    pConstraint.Append(
                        DocHelper.CreateRun(this.IGSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityAtLeastOne) + " "));
                    break;

                case "0..*":
                    pConstraint.Append(
                        DocHelper.CreateRun(this.IGSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZeroOrMore) + " "));
                    break;

                case "0..0":
                    pConstraint.Append(
                        DocHelper.CreateRun(this.IGSettings.GetSetting(IGSettingsManager.SettingProperty.CardinalityZero) + " "));
                    break;

                default:
                    pConstraint.Append(
                        DocHelper.CreateRun("[" + constraint.Cardinality + "] "));
                    break;
                }

                var containedTemplate = (from tcr in constraint.References
                                         join t in this.DataSource.Templates on tcr.ReferenceIdentifier equals t.Oid
                                         where tcr.ReferenceType == ConstraintReferenceTypes.Template
                                         select t).FirstOrDefault();

                if (!string.IsNullOrEmpty(constraint.Context))
                {
                    string dataType = constraint.DataType != null?constraint.DataType.ToLower() : string.Empty;

                    if ((context.ToLower() == "value" || context.ToLower() == "code" || context.ToLower() == "statuscode") && (dataType == "cd" || dataType == "cs" || dataType == "cv" || dataType == "ce"))
                    {
                        if (!string.IsNullOrEmpty(constraint.Value) || constraint.ValueSet != null || constraint.CodeSystem != null)
                        {
                            context = context + "/@code";
                        }
                    }
                    else if (context.ToLower() == "value" && !string.IsNullOrEmpty(constraint.DataType))
                    {
                        context = string.Format("value with @xsi:type=\"{0}\"", constraint.DataType);
                    }

                    pConstraint.Append(
                        DocHelper.CreateRun(context, style: Properties.Settings.Default.ConstraintContextStyle));
                }
                else if (containedTemplate != null)
                {
                    if (this.AllTemplates.Exists(y => y.Id == containedTemplate.Id))
                    {
                        pConstraint.Append(
                            this.HyperlinkTracker.CreateHyperlink(containedTemplate.Name, containedTemplate.Bookmark, Properties.Settings.Default.LinkStyle),
                            DocHelper.CreateRun(" (" + containedTemplate.Oid + ")", style: Properties.Settings.Default.TemplateOidStyle));
                    }
                    else
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(containedTemplate.Name),
                            DocHelper.CreateRun(" (" + containedTemplate.Oid + ")", style: Properties.Settings.Default.TemplateOidStyle));
                    }
                }

                if (constraint.ValueConformance != null)
                {
                    string valueConformance = constraint.Conformance;
                    string staticDynamic    = string.Empty;

                    if (constraint.IsStatic == true)
                    {
                        staticDynamic = "STATIC";
                    }
                    else if (constraint.IsStatic == false)
                    {
                        staticDynamic = "DYNAMIC";
                    }

                    if (constraint.ValueSet != null)
                    {
                        string lValueSetAnchor = constraint.ValueSet.Name.Replace(" ", "_");

                        pConstraint.Append(
                            DocHelper.CreateRun(", which "),
                            DocHelper.CreateRun(valueConformance, style: Properties.Settings.Default.ConformanceVerbStyle),
                            DocHelper.CreateRun(" be selected from ValueSet "),
                            new BookmarkStart()
                        {
                            Id = lValueSetAnchor, Name = lValueSetAnchor
                        },
                            DocHelper.CreateRun(
                                constraint.ValueSet.Name + " " + constraint.ValueSet.GetIdentifier(this.IGTypePlugin),
                                style: Properties.Settings.Default.VocabularyConstraintStyle),
                            new BookmarkEnd()
                        {
                            Id = lValueSetAnchor
                        });
                    }
                    else if (constraint.CodeSystem != null)
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(", which "),
                            DocHelper.CreateRun(valueConformance, style: Properties.Settings.Default.ConformanceVerbStyle),
                            DocHelper.CreateRun(" be selected from CodeSystem "),
                            DocHelper.CreateRun(constraint.CodeSystem.Name + " (" + constraint.CodeSystem.Oid + ")", style: Properties.Settings.Default.VocabularyConstraintStyle));
                    }

                    pConstraint.Append(
                        DocHelper.CreateRun(" " + staticDynamic, style: Properties.Settings.Default.ConformanceVerbStyle));
                }

                if (!string.IsNullOrEmpty(constraint.Value))
                {
                    if (context.Contains("@xsi:type"))
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(", where the @code"));
                    }

                    pConstraint.Append(
                        DocHelper.CreateRun("="),
                        DocHelper.CreateRun("\"" + constraint.Value + "\"", style: Properties.Settings.Default.VocabularyConstraintStyle));

                    if (!string.IsNullOrEmpty(constraint.DisplayName))
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(" " + constraint.DisplayName));
                    }

                    if (constraint.CodeSystem != null)
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(" (CodeSystem: "),
                            DocHelper.CreateRun(constraint.CodeSystem.Name + " " + constraint.CodeSystem.Oid, style: Properties.Settings.Default.TemplateOidStyle),
                            DocHelper.CreateRun(")"));
                    }

                    if (constraint.ValueSet != null)
                    {
                        pConstraint.Append(
                            DocHelper.CreateRun(" (ValueSet: "),
                            DocHelper.CreateRun(constraint.ValueSet.Name + " " + constraint.ValueSet.GetIdentifier(this.IGTypePlugin), style: Properties.Settings.Default.TemplateOidStyle),
                            DocHelper.CreateRun(")"));
                    }
                }

                pConstraint.Append(
                    new BookmarkStart()
                {
                    Id = "C_" + constraint.Id.ToString(), Name = "C_" + constraint.Id.ToString()
                },
                    DocHelper.CreateRun(string.Format(" (CONF:{0})", constraint.Id)),
                    new BookmarkEnd()
                {
                    Id = "C_" + constraint.Id.ToString()
                });

                if (constraint.IsBranch == true && childConstraints.Count > 0)
                {
                    pConstraint.Append(
                        DocHelper.CreateRun(" such that it"));
                }
            }

            // Add the constraint as a bullet to the document
            this.DocumentBody.Append(pConstraint);

            // Add child constraints
            foreach (TemplateConstraint cConstraint in childConstraints)
            {
                this.AddTemplateConstraint(cConstraint, level + 1);
            }
        }
コード例 #8
0
ファイル: BooleanComponent.cs プロジェクト: tkahng/clipper
        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        /// <param name="pManager">Use the pManager to register new parameters. pManager is never null.</param>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            EvenOdd = EvenOdd;
            pManager.AddCurveParameter("A", "A", "The first polyline", GH_ParamAccess.list);
            pManager.AddCurveParameter("B", "B", "The first polyline", GH_ParamAccess.list);
            pManager[1].Optional = true;
            // ctIntersection, ctUnion, ctDifference, ctXor };
            var btParamIndex = pManager.AddIntegerParameter("BooleanType", "BT", "Type: (0: intersection, 1: union, 2: difference, 3: xor)", GH_ParamAccess.item, 0);
            var btParam      = pManager[btParamIndex] as Param_Integer;

            ParamHelper.AddEnumOptionsToParam <BooleanClipType>(btParam);

            pManager.AddPlaneParameter("Plane", "Pln", "Plane to project the polylines to", GH_ParamAccess.item, default);
            pManager.AddNumberParameter("Tolerance", "T", "Tolerance: all floating point data beyond this precision will be discarded.", GH_ParamAccess.item, DocHelper.GetModelTolerance());
        }
コード例 #9
0
ファイル: OffsetComponent.cs プロジェクト: tkahng/clipper
        /// <summary>
        /// Registers all the input parameters for this component.
        /// </summary>
        /// <param name="pManager">Use the pManager to register new parameters. pManager is never null.</param>
        protected override void RegisterInputParams(GH_InputParamManager pManager)
        {
            // set the message for this component.
            pManager.AddCurveParameter("Polylines", "P", "A list of polylines to offset", GH_ParamAccess.list);
            pManager.AddNumberParameter("Distance", "D", "Offset Distance", GH_ParamAccess.item);
            pManager.AddPlaneParameter("Plane", "Pln", "Plane to project the polylines to", GH_ParamAccess.item, default);


            pManager.AddNumberParameter("Tolerance", "T", "Tolerance: all floating point data beyond this precision will be discarded.", GH_ParamAccess.item, DocHelper.GetModelTolerance());
            //public enum ClosedFilletType { Round, Square, Miter }
            var cfParamIndex = pManager.AddIntegerParameter("ClosedFillet", "CF", "Closed fillet type (0 = Round, 1 = Square, 2 = Miter)", GH_ParamAccess.list, new List <int> {
                1
            });
            var cfParam = pManager[cfParamIndex] as Param_Integer;

            ParamHelper.AddEnumOptionsToParam <Polyline3D.ClosedFilletType>(cfParam);

            //public enum OpenFilletType { Round, Square, Butt }
            var ofParamIndex = pManager.AddIntegerParameter("OpenFillet", "OF", "Open fillet type (0 = Round, 1 = Square, 2 = Butt)", GH_ParamAccess.list, new List <int> {
                1
            });
            var ofParam = pManager[ofParamIndex] as Param_Integer;

            ParamHelper.AddEnumOptionsToParam <Polyline3D.OpenFilletType>(ofParam);

            pManager.AddNumberParameter("Miter", "M", "If closed fillet type of Miter is selected: the maximum extension of a curve is Distance * Miter", GH_ParamAccess.item, 2);
        }
コード例 #10
0
        public async Task <IHttpActionResult> Get(Guid DocId)
        {
            try
            {
                var fullDoc = DataService.getFullDoc(DocId);

                IHttpActionResult result;
                MemoryStream      mem = new MemoryStream();


                // Create Document
                using (WordprocessingDocument wordDocument =
                           WordprocessingDocument.Create(mem, WordprocessingDocumentType.Document, true))
                {
                    // Add a main document part.
                    MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
                    DocHelper.AddStyles(mainPart);

                    // Create the document structure and add some text.
                    mainPart.Document = new Document();
                    Body body = mainPart.Document.AppendChild(new Body());

                    // Title and Sub-title
                    Paragraph titlePara = body.AppendChild(new Paragraph());
                    DocHelper.ApplyStyleToParagraph(wordDocument, "unknown", "Title", titlePara);
                    Run run = titlePara.AppendChild(new Run());
                    run.AppendChild(new Text(fullDoc.Header.Title));

                    Paragraph subTitlePara = body.AppendChild(new Paragraph());
                    DocHelper.ApplyStyleToParagraph(wordDocument, "unknown", "Subtitle", subTitlePara);
                    subTitlePara.AppendChild(new Run(new Text($"Created {fullDoc.Header.Created} (UTC)")));

                    // Paragraph for each para in the list
                    foreach (var para in fullDoc.Paragraphs)
                    {
                        var paragraph = body.AppendChild(new Paragraph(new Run(new Text(
                                                                                   $"[{para.TimeStamp} (UTC)] - {para.Text}"))));
                        if (!string.IsNullOrWhiteSpace(para.Style))
                        {
                            DocHelper.ApplyStyleToParagraph(wordDocument, "unknown", para.Style, paragraph);
                        }
                    }


                    mainPart.Document.Save();
                }

                mem.Seek(0, SeekOrigin.Begin);

                HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.OK);
                msg.Content = new StreamContent(mem);

                msg.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
                msg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = $"{fullDoc.Header.FileName}"
                };
                result = ResponseMessage(msg);


                return(result);
            }
            catch (KeyNotFoundException e)
            {
                return(NotFound());
            }
        }