public MainForm()
        {
            InitializeComponent();

            Application.EnableVisualStyles();

            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer, true);

            serialParityCmBx.SelectedIndex   = 0;
            serialStopBitsCmBx.SelectedIndex = 1;
            serialBaudCmBx.SelectedIndex     = 0;
            UpdateSerialPorts();

            formatCmBx.SelectedIndex     = 0;
            lineEndingCmBx.SelectedIndex = 0;

            LoadSerialSettigns();
            LoadTcpSettings();
            LoadUdpSettings();
            LoadGlobalSettings();

            searcher = new TxtBoxSearch(ref displayTxt);

            string selectedTxtFormat = formatCmBx.GetItemText(formatCmBx.SelectedItem);

            txtFormat = StringToTextFormatType(selectedTxtFormat);

            string selectedLineEnding = lineEndingCmBx.GetItemText(lineEndingCmBx.SelectedItem);

            lineEnding = StringToLineEndingType(selectedLineEnding);
        }
Esempio n. 2
0
 public static IHtmlString FormatToHtml(this HtmlHelper helper, string text, TextFormatType format)
 {
     switch (format)
     {
         case TextFormatType.PlainText:
             return helper.Raw(HttpUtility.HtmlEncode(text ?? "").Replace("\n", "<br />"));
         case TextFormatType.MarkDown:
             lock (_Formatter)
             {
                 return helper.Raw(_Formatter.Transform(HttpUtility.HtmlEncode(text ?? "")));
             }
         default: throw new NotImplementedException();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Populate <see cref="HierarchyType"/> from <paramref name="buildFrom"/>.
        /// </summary>
        /// <param name="hierarchyType">
        /// The hierarchy type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        public void BuildList(HierarchyType hierarchyType, ILevelObject buildFrom)
        {
            int order = 1;
            do
            {
                var builtObj = new LevelType();
                hierarchyType.Level.Add(builtObj);

                string value = buildFrom.Id;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    builtObj.id = buildFrom.Id;
                }

                if (ObjectUtil.ValidString(buildFrom.Urn))
                {
                    builtObj.urn = buildFrom.Urn;
                }

                IList<ITextTypeWrapper> names = buildFrom.Names;
                if (ObjectUtil.ValidCollection(names))
                {
                    builtObj.Name = this.GetTextType(names);
                }

                IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions;
                if (ObjectUtil.ValidCollection(descriptions))
                {
                    builtObj.Description = this.GetTextType(descriptions);
                }

                if (this.HasAnnotations(buildFrom))
                {
                    builtObj.Annotations = this.GetAnnotationsType(buildFrom);
                }

                builtObj.Order = order;
                if (buildFrom.CodingFormat != null)
                {
                    var textFormatType = new TextFormatType();
                    this.PopulateTextFormatType(textFormatType, buildFrom.CodingFormat);
                    builtObj.CodingType = textFormatType;
                }

                buildFrom = buildFrom.ChildLevel;
                order++;
            }
            while (buildFrom != null);
        }
        private void formatCmBx_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedTxtFormat = formatCmBx.GetItemText(formatCmBx.SelectedItem);

            txtFormat = StringToTextFormatType(selectedTxtFormat);
            if (!firstFormatIndxChange)
            {
                Properties.Settings.Default.TextFormat = selectedTxtFormat;
                SaveProperties();
            }
            if (firstFormatIndxChange)
            {
                firstFormatIndxChange = false;
            }
        }
Esempio n. 5
0
        public static IHtmlString FormatToHtml(this HtmlHelper helper, string text, TextFormatType format)
        {
            switch (format)
            {
            case TextFormatType.PlainText:
                return(helper.Raw(HttpUtility.HtmlEncode(text ?? "").Replace("\n", "<br />")));

            case TextFormatType.MarkDown:
                lock (_Formatter)
                {
                    return(helper.Raw(_Formatter.Transform(HttpUtility.HtmlEncode(text ?? ""))));
                }

            default: throw new NotImplementedException();
            }
        }
Esempio n. 6
0
        static AttributeType createDecimalsAttribute()
        {
            AttributeType att = new AttributeType();

            att.conceptSchemeAgency = "SDMX";
            att.conceptSchemeRef    = "CROSS_DOMAIN_CONCEPTS";
            att.conceptRef          = "DECIMALS";
            att.conceptVersion      = "1.0";

            TextFormatType format = new TextFormatType();

            format.textType = TextTypeType.Integer;
            att.TextFormat  = format;

            att.assignmentStatus = AssignmentStatusType.Mandatory;
            att.attachmentLevel  = AttachmentLevelType.DataSet;

            return(att);
        }
Esempio n. 7
0
        static AttributeType createReferencePeriodAttribute(Boolean series)
        {
            AttributeType att = new AttributeType();

            att.conceptSchemeAgency = "SDMX";
            att.conceptSchemeRef    = "CROSS_DOMAIN_CONCEPTS";
            att.conceptRef          = "REF_PERIOD";
            att.conceptVersion      = "1.0";

            TextFormatType format = new TextFormatType();

            format.textType = TextTypeType.String;
            att.TextFormat  = format;

            att.assignmentStatus = series ? AssignmentStatusType.Conditional : AssignmentStatusType.Mandatory;
            att.attachmentLevel  = series ? AttachmentLevelType.Series : AttachmentLevelType.DataSet;

            return(att);
        }
Esempio n. 8
0
        static AttributeType createDayAdjAttribute(Boolean series, String agency)
        {
            AttributeType att = new AttributeType();

            att.conceptSchemeAgency = agency;
            att.conceptSchemeRef    = "DEFAULT";
            att.conceptRef          = "DAY_ADJ";
            att.conceptVersion      = "1.0";

            TextFormatType format = new TextFormatType();

            format.textType = TextTypeType.Boolean;
            att.TextFormat  = format;


            att.assignmentStatus = series ? AssignmentStatusType.Conditional : AssignmentStatusType.Mandatory;
            att.attachmentLevel  = series ? AttachmentLevelType.Series : AttachmentLevelType.DataSet;

            return(att);
        }
Esempio n. 9
0
        public string Format(TextFormatType type, ImageFormatSize size, bool includeLinkToOriginal)
        {
            string thumnailToUse = this.original_image;

            switch (size)
            {
            case ImageFormatSize.Large:
                thumnailToUse = this.large_thumbnail;
                break;

            case ImageFormatSize.Small:
                thumnailToUse = this.small_thumbnail;
                break;
            }

            switch (type)
            {
            case TextFormatType.DirectLink:
                return(String.Format("{0}", this.original_image));

            case TextFormatType.BBCode:
                return(includeLinkToOriginal ?
                       String.Format("[URL={0}][IMG]{1}[/IMG][/URL]", this.original_image, thumnailToUse) :
                       String.Format("[IMG]{0}[/IMG]", thumnailToUse));

            case TextFormatType.Html:
                return(includeLinkToOriginal ?
                       String.Format("<a href=\"{0}\" title=\"Hosted by imgur\"><img src=\"{1}\" /></a>", this.original_image, thumnailToUse) :
                       String.Format("<img src=\"{0}\" />", thumnailToUse));

            case TextFormatType.MarkdownLink:
                return(String.Format("[%linktext%]({0})", this.imgur_page));

            case TextFormatType.StackOverflowEmbeddable:
                return(String.Format("![%alttext%]({0})", thumnailToUse));
            }

            return(this.original_image);
        }
        /// <summary>
        /// The populate text format type.
        /// </summary>
        /// <param name="textFormatType">
        /// The text format type.
        /// </param>
        /// <param name="textFormat">
        /// The text format.
        /// </param>
        internal void PopulateTextFormatType(TextFormatType textFormatType, ITextFormat textFormat)
        {
            if (textFormat.TextType != null)
            {
                switch (textFormat.TextType.EnumType)
                {
                    case TextEnumType.BigInteger:
                        textFormatType.textType = TextTypeTypeConstants.BigInteger;
                        break;
                    case TextEnumType.Boolean:
                        textFormatType.textType = TextTypeTypeConstants.Boolean;
                        break;
                    case TextEnumType.Count:
                        textFormatType.textType = TextTypeTypeConstants.Count;
                        break;
                    case TextEnumType.Date:
                        textFormatType.textType = TextTypeTypeConstants.Date;
                        break;
                    case TextEnumType.DateTime:
                        textFormatType.textType = TextTypeTypeConstants.DateTime;
                        break;
                    case TextEnumType.Day:
                        textFormatType.textType = TextTypeTypeConstants.Day;
                        break;
                    case TextEnumType.Decimal:
                        textFormatType.textType = TextTypeTypeConstants.Decimal;
                        break;
                    case TextEnumType.Double:
                        textFormatType.textType = TextTypeTypeConstants.Double;
                        break;
                    case TextEnumType.Duration:
                        textFormatType.textType = TextTypeTypeConstants.Duration;
                        break;
                    case TextEnumType.ExclusiveValueRange:
                        textFormatType.textType = TextTypeTypeConstants.ExclusiveValueRange;
                        break;
                    case TextEnumType.Float:
                        textFormatType.textType = TextTypeTypeConstants.Float;
                        break;
                    case TextEnumType.InclusiveValueRange:
                        textFormatType.textType = TextTypeTypeConstants.InclusiveValueRange;
                        break;
                    case TextEnumType.Incremental:
                        textFormatType.textType = TextTypeTypeConstants.Incremental;
                        break;
                    case TextEnumType.Integer:
                        textFormatType.textType = TextTypeTypeConstants.Integer;
                        break;
                    case TextEnumType.Long:
                        textFormatType.textType = TextTypeTypeConstants.Long;
                        break;
                    case TextEnumType.Month:
                        textFormatType.textType = TextTypeTypeConstants.Month;
                        break;
                    case TextEnumType.MonthDay:
                        textFormatType.textType = TextTypeTypeConstants.MonthDay;
                        break;
                    case TextEnumType.ObservationalTimePeriod:
                        textFormatType.textType = TextTypeTypeConstants.ObservationalTimePeriod;
                        break;
                    case TextEnumType.Short:
                        textFormatType.textType = TextTypeTypeConstants.Short;
                        break;
                    case TextEnumType.String:
                        textFormatType.textType = TextTypeTypeConstants.String;
                        break;
                    case TextEnumType.Time:
                        textFormatType.textType = TextTypeTypeConstants.Time;
                        break;
                    case TextEnumType.Timespan:
                        textFormatType.textType = TextTypeTypeConstants.Timespan;
                        break;
                    case TextEnumType.Uri:
                        textFormatType.textType = TextTypeTypeConstants.URI;
                        break;
                    case TextEnumType.Year:
                        textFormatType.textType = TextTypeTypeConstants.Year;
                        break;
                    case TextEnumType.YearMonth:
                        textFormatType.textType = TextTypeTypeConstants.YearMonth;
                        break;
                }
            }

            string str0 = textFormat.Pattern;
            if (!string.IsNullOrWhiteSpace(str0))
            {
                textFormatType.pattern = textFormat.Pattern;
            }

            TimeSpan result;
            string str1 = textFormat.TimeInterval;
            if (!string.IsNullOrWhiteSpace(str1) && TimeSpan.TryParse(textFormat.TimeInterval, out result))
            {
                textFormatType.timeInterval = result;
            }

            if (textFormat.Decimals != null)
            {
                textFormatType.decimals = textFormat.Decimals;
            }

            if (textFormat.EndValue != null)
            {
                textFormatType.endValue = Convert.ToDouble(textFormat.EndValue);
            }

            if (textFormat.Interval != null)
            {
                textFormatType.interval = Convert.ToDouble(textFormat.Interval);
            }

            if (textFormat.MaxLength != null)
            {
                textFormatType.maxLength = textFormat.MaxLength;
            }

            if (textFormat.MinLength != null)
            {
                textFormatType.minLength = textFormat.MinLength;
            }

            if (textFormat.StartValue != null)
            {
                textFormatType.startValue = Convert.ToDouble(textFormat.StartValue);
            }

            if (textFormat.Sequence.IsSet())
            {
                textFormatType.isSequence = textFormat.Sequence.IsTrue;
            }
        }
Esempio n. 11
0
        static StructureType createStructure(PXModel model)
        {
            // Create structure
            StructureType structure = new StructureType();

            // Create concepts container
            ConceptsType concepts = new ConceptsType();

            structure.Concepts = concepts;
            // Concept Schemes
            List <ConceptSchemeType> conceptSchemes = new List <ConceptSchemeType>();

            //Create Common Concept Scheme
            conceptSchemes.Add(createCommonConcepts());
            // Create instance concept scheme
            ConceptSchemeType conceptScheme = new ConceptSchemeType();

            conceptScheme.agencyID = model.Meta.Agency().CleanID();
            conceptScheme.id       = "DEFAULT";
            conceptScheme.version  = "1.0";
            List <TextType> name = new List <TextType>();

            {
                TextType enName = new TextType();
                enName.lang  = "en";
                enName.Value = "Default Concept Scheme";
                name.Add(enName);
            }
            conceptScheme.Name = name.ToArray();
            List <ConceptType> schemeConcepts = new List <ConceptType>();
            // Create fixed concepts (not contained in CDC)
            // Stock/flow/average indicator
            {
                ConceptType concept = new ConceptType();
                concept.id = "SFA_INDICATOR";
                name       = new List <TextType>();
                {
                    TextType enName = new TextType();
                    enName.lang  = "en";
                    enName.Value = "Stock, flow, average indicator";
                    name.Add(enName);
                }
                concept.Name = name.ToArray();
                schemeConcepts.Add(concept);
            }
            // Seasonal adjustement
            {
                ConceptType concept = new ConceptType();
                concept.id = "SEAS_ADJ";
                name       = new List <TextType>();
                {
                    TextType enName = new TextType();
                    enName.lang  = "en";
                    enName.Value = "Seasonally adjustement";
                    name.Add(enName);
                }
                concept.Name = name.ToArray();
                schemeConcepts.Add(concept);
            }
            // Daily adjustement
            {
                ConceptType concept = new ConceptType();
                concept.id = "DAY_ADJ";
                name       = new List <TextType>();
                {
                    TextType enName = new TextType();
                    enName.lang  = "en";
                    enName.Value = "Daily adjustement";
                    name.Add(enName);
                }
                concept.Name = name.ToArray();
                schemeConcepts.Add(concept);
            }
            // Price basis
            {
                ConceptType concept = new ConceptType();
                concept.id = "PRICE_BASIS";
                name       = new List <TextType>();
                {
                    TextType enName = new TextType();
                    enName.lang  = "en";
                    enName.Value = "Price basis";
                    name.Add(enName);
                }
                concept.Name = name.ToArray();
                schemeConcepts.Add(concept);
            }

            // Create codelists container
            List <CodeListType> codeLists = new List <CodeListType>();

            //Create Common Code Lists
            codeLists.AddRange(createCommonCodes(model));

            // Create key family
            KeyFamilyType keyFamily = new KeyFamilyType();

            keyFamily.agencyID = model.Meta.Agency().CleanID();
            keyFamily.id       = model.Meta.Matrix.CleanID();
            keyFamily.version  = "1.0";
            name = new List <TextType>();
            {
                TextType enName = new TextType();
                enName.lang  = "en";
                enName.Value = model.Meta.Matrix;
                name.Add(enName);
            }
            keyFamily.Name = name.ToArray();
            ComponentsType components = new ComponentsType();

            keyFamily.Components = components;
            // Create attributes
            List <AttributeType> attributes = new List <AttributeType>();

            if (model.Meta.ContentVariable == null)
            {
                //Any non-null key words will be data set level attributes

                //Unit of measure
                attributes.Add(createUnitsAttribute(false, model.Meta.Agency().CleanID()));

                if (model.Meta.ContentInfo != null)
                {
                    // Stock, flow, average
                    if (model.Meta.ContentInfo.StockFa != null)
                    {
                        attributes.Add(createStockFlowAttribute(false, model.Meta.Agency().CleanID()));
                    }

                    // Seasonal adjustement
                    if (model.Meta.ContentInfo.SeasAdj != null)
                    {
                        attributes.Add(createSeasAdjAttribute(false, model.Meta.Agency().CleanID()));
                    }

                    // Daily adjustment
                    if (model.Meta.ContentInfo.DayAdj != null)
                    {
                        attributes.Add(createDayAdjAttribute(false, model.Meta.Agency().CleanID()));
                    }

                    // Base period
                    if (model.Meta.ContentInfo.Baseperiod != null)
                    {
                        attributes.Add(createBasePeriodAttribute(false));
                    }

                    // Reference period
                    if (model.Meta.ContentInfo.RefPeriod != null)
                    {
                        attributes.Add(createReferencePeriodAttribute(false));
                    }

                    // Current / fixed prices
                    if (model.Meta.ContentInfo.CFPrices != null)
                    {
                        attributes.Add(createPriceBasisAttribute(false, model.Meta.Agency().CleanID()));
                    }
                }
            }
            else
            {
                //Any non-null key words will be series level attributes

                //Unit of measure
                attributes.Add(createUnitsAttribute(true, model.Meta.Agency().CleanID()));

                if (model.Meta.ContentInfo != null)
                {
                    // Stock, flow, average
                    if (model.Meta.ContentInfo.StockFa != null)
                    {
                        attributes.Add(createStockFlowAttribute(true, model.Meta.Agency().CleanID()));
                    }

                    // Seasonal adjustement
                    if (model.Meta.ContentInfo.SeasAdj != null)
                    {
                        attributes.Add(createSeasAdjAttribute(true, model.Meta.Agency().CleanID()));
                    }

                    // Daily adjustment
                    if (model.Meta.ContentInfo.DayAdj != null)
                    {
                        attributes.Add(createDayAdjAttribute(true, model.Meta.Agency().CleanID()));
                    }

                    // Base period
                    if (model.Meta.ContentInfo.Baseperiod != null)
                    {
                        attributes.Add(createBasePeriodAttribute(true));
                    }

                    // Reference period
                    if (model.Meta.ContentInfo.RefPeriod != null)
                    {
                        attributes.Add(createReferencePeriodAttribute(true));
                    }

                    // Current / fixed prices
                    if (model.Meta.ContentInfo.CFPrices != null)
                    {
                        attributes.Add(createPriceBasisAttribute(true, model.Meta.Agency().CleanID()));
                    }
                }
            }
            attributes.Add(createObsStatusAttribute());
            attributes.Add(createDecimalsAttribute());

            // Add attributes to key family components
            components.Attribute = attributes.ToArray();

            // Create dimensions
            List <DimensionType> dimensions = new List <DimensionType>();
            // Create frequency dimension
            DimensionType freq = new DimensionType();

            freq.conceptAgency        = "SDMX";
            freq.conceptSchemeRef     = "CROSS_DOMAIN_CONCEPTS";
            freq.conceptRef           = "FREQ";
            freq.conceptVersion       = "1.0";
            freq.codelistAgency       = "SDMX";
            freq.codelist             = "CL_FREQ";
            freq.codelistVersion      = "1.0";
            freq.isFrequencyDimension = true;
            dimensions.Add(freq);

            // Loop through variables to create concepts, codelists, and dimensions
            foreach (Variable var in model.Meta.Variables)
            {
                if (!isStandardConcept(var))
                {
                    // Create concept
                    schemeConcepts.Add(createConcept(var));
                    // Create codelist
                    codeLists.Add(createCodelist(var));
                    // Create dimension
                    dimensions.Add(createDimension(var, model.Meta.Agency().CleanID()));
                }
            }
            // Create time dimension
            TimeDimensionType time = new TimeDimensionType();

            time.conceptAgency    = "SDMX";
            time.conceptSchemeRef = "CROSS_DOMAIN_CONCEPTS";
            time.conceptRef       = "TIME_PERIOD";
            time.conceptVersion   = "1.0";
            TextFormatType timeFormat = new TextFormatType();

            timeFormat.textType      = TextTypeType.ObservationalTimePeriod;
            time.TextFormat          = timeFormat;
            components.TimeDimension = time;

            // Add dimensions to key family components
            components.Dimension = dimensions.ToArray();

            // Create primary measure
            PrimaryMeasureType obsValue = new PrimaryMeasureType();

            obsValue.conceptSchemeAgency = "SDMX";
            obsValue.conceptSchemeRef    = "CROSS_DOMAIN_CONCEPTS";
            obsValue.conceptRef          = "OBS_VALUE";
            obsValue.conceptVersion      = "1.0";
            TextFormatType obsFormat = new TextFormatType();

            obsFormat.textType        = TextTypeType.Decimal;
            obsValue.TextFormat       = obsFormat;
            components.PrimaryMeasure = obsValue;

            // Add key family to structure
            List <KeyFamilyType> keyFamilies = new List <KeyFamilyType>();

            keyFamilies.Add(keyFamily);
            structure.KeyFamilies = keyFamilies.ToArray();
            // Add concepts to scheme
            conceptScheme.Concept = schemeConcepts.ToArray();
            conceptSchemes.Add(conceptScheme);
            concepts.ConceptScheme = conceptSchemes.ToArray();
            // Add codelists to structure
            structure.CodeLists = codeLists.ToArray();

            structure.Header = createHeader(model, false);

            return(structure);
        }
        /// <summary>
        /// The process component.
        /// </summary>
        /// <param name="componentMapType">
        /// The component map type.
        /// </param>
        /// <param name="componentMapBean">
        /// The component map bean.
        /// </param>
        private void ProcessComponent(ComponentMapType componentMapType, IComponentMapObject componentMapBean)
        {
            if (componentMapBean.MapConceptRef != null)
            {
                componentMapType.MapConceptRef = componentMapBean.MapConceptRef;
            }

            if (componentMapBean.MapTargetConceptRef != null)
            {
                componentMapType.MapTargetConceptRef = componentMapBean.MapTargetConceptRef;
            }

            if (componentMapBean.RepMapRef != null)
            {
                if (componentMapBean.RepMapRef.ToTextFormat != null)
                {
                    var textForamtType = new TextFormatType();
                    componentMapType.ToTextFormat = textForamtType;
                    this.PopulateTextFormatType(textForamtType, componentMapBean.RepMapRef.ToTextFormat);
                }

                switch (componentMapBean.RepMapRef.ToValueType)
                {
                    case ToValue.Description:
                        componentMapType.ToValueType = ToValueTypeTypeConstants.Description;
                        break;
                    case ToValue.Name:
                        componentMapType.ToValueType = ToValueTypeTypeConstants.Name;
                        break;
                    case ToValue.Value:
                        componentMapType.ToValueType = ToValueTypeTypeConstants.Value;
                        break;
                }
            }
        }