private void HandleStyleLoaded(MapStyle obj)
        {
            var bigLabel = Expression.CreateFormatEntry(
                Expression.Get("name_en"),
                FormatOption.FormatFontScale(1.5),
                FormatOption.FormatTextColor(Color.Blue),
                FormatOption.FormatTextFont(new [] { "Ubuntu Medium", "Arial Unicode MS Regular" })
                );

            var newLine = Expression.CreateFormatEntry(
                // Add "\n" in order to break the line and have the second label underneath
                "\n",
                FormatOption.FormatFontScale(0.5)
                );

            var smallLabel = Expression.CreateFormatEntry(
                Expression.Get("name"),
                FormatOption.FormatTextColor(Color.FromHex("#d6550a")),
                FormatOption.FormatTextFont(new [] { "Caveat Regular", "Arial Unicode MS Regular" })
                );

            var format = Expression.Format(bigLabel, newLine, smallLabel);

            // Retrieve the country label layers from the style and update them with the formatting expression
            foreach (var mapLabelLayer in map.Functions.GetLayers())
            {
                if (mapLabelLayer.Id.Contains("country-label") &&
                    mapLabelLayer is SymbolLayer symbolLayer)
                {
                    // Apply formatting expression
                    symbolLayer.TextField = format;
                    map.Functions.UpdateLayer(symbolLayer);
                }
            }
        }
Пример #2
0
        bool SingleConvert(string excelPath, string coding, FormatOption format)
        {
            ExcelUtility excel    = new ExcelUtility(excelPath);
            Encoding     encoding = Encoding.GetEncoding(coding);

            bool convertFlag = false;

            switch (format)
            {
            case FormatOption.JSON:
                convertFlag = excel.ConvertToJson(ExportPath, encoding);
                break;

            case FormatOption.XML:
                convertFlag = excel.ConvertToXml(ExportPath);
                break;

            case FormatOption.CVS:
                convertFlag = excel.ConvertToCSV(ExportPath, encoding);
                break;

            default:
                break;
            }
            return(convertFlag);
        }
Пример #3
0
        internal static string FormatTerminalValue(string value, FormatOption formatOption)
        {
            if (value.IsQuoted())
            {
                return(value);
            }

            switch (formatOption)
            {
            case FormatOption.Keep:
                return(value);

            case FormatOption.Upper:
                return(value.ToUpper(CultureInfo.CurrentCulture));

            case FormatOption.Lower:
                return(value.ToLower(CultureInfo.CurrentCulture));

            case FormatOption.InitialCapital:
                return(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value.ToLower(CultureInfo.CurrentCulture)));

            default:
                throw new NotSupportedException();
            }
        }
 public static string DataFormat(string type, string value)
 {
     FormatOption option = ConfigManage.dbConfig.Format.Where(p => p.Field == type).FirstOrDefault();
     if (option == null)
         return value;
     string news = option.Values.Where(p => p.Split('|')[0] == value).FirstOrDefault();
     if (string.IsNullOrEmpty(news))
         return value;
     return news.Split('|')[1];
 }
Пример #5
0
        private void jpegRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (jpegRadioButton.Checked)
            {
                format = FormatOption.Jpeg;
                string ext = Path.GetExtension(fileName).ToLower();
                if (ext != ".jpg")
                {
                    string dir = Path.GetDirectoryName(fileName);
                    string fn  = Path.GetFileNameWithoutExtension(fileName);
                    fileName         = Path.Combine(dir, fn + ".jpg");
                    fileNameBox.Text = fileName;
                }

                transparencyGroupBox.Enabled = false;
            }
        }
Пример #6
0
        int[] MultipleConvert(string coding, FormatOption format)
        {
            int seccessCount = 0;
            int failCount    = 0;

            for (int i = 0; i < excelPathList.Count; i++)
            {
                if (SingleConvert(excelPathList[i], coding, format))
                {
                    seccessCount++;
                }
                else
                {
                    failCount++;
                }
            }
            return(new int[] { seccessCount, failCount });
        }
Пример #7
0
        public static bool chechinput(string input,FormatOption option=FormatOption.Regular)
        {
            bool flag = false;
            string inputvalue = input.Replace (" ", "");

            Regex onlyletterformat = new Regex (@"^[a-zA-Z]+$");
            Regex onlynumberformat = new Regex (@"^[0-9]+$");
            Regex regularformat = new Regex (@"^[a-zA-Z0-9\.\(\)\-]+$");
            Regex emailformat = new Regex (@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
            Regex phoneformat = new Regex (@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$");

            // format for ****/**/**; * can be any number
            Regex datetimeformat = new Regex(@"^\d{1}\d{1}\d{1}\d{1}/{1}\d{1}\d{1}/{1}\d{1}\d{1}$");

            if(!input.Equals("")){
                if (option.Equals (FormatOption.Regular)) {
                    if (regularformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                } else if (option.Equals (FormatOption.OnlyLetter)) {
                    if (onlyletterformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                } else if (option.Equals (FormatOption.OnlyNumber)) {
                    if (onlynumberformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                } else if (option.Equals (FormatOption.Phone)) {
                    if (phoneformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                } else if (option.Equals (FormatOption.Email)) {
                    if (emailformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                }else if (option.Equals (FormatOption.Date)) {
                    if (datetimeformat.Match (inputvalue).Success) {
                        flag = true;
                    }
                }
            }
            return flag;
        }
Пример #8
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            bool ok = true;

            fileName = fileNameBox.Text;
            if (jpegRadioButton.Checked)
            {
                format = FormatOption.Jpeg;
            }
            else
            {
                format = FormatOption.Png;
            }

            if (transparentRadioButton.Checked)
            {
                transparency = TransparencyOption.Transparent;
            }
            else
            {
                transparency = TransparencyOption.None;
            }

            //if the file exists, only proceed if the user confirms an overwrite
            if (File.Exists(fileName))
            {
                string msg = string.Format("Warning: The file {0} already exists. Overwrite?", Path.GetFileName(fileName));
                ok = (DialogResult.Yes == MessageBox.Show(msg, "File Exists", MessageBoxButtons.YesNo, MessageBoxIcon.Warning));
            }

            if (ok)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Пример #9
0
        internal static void FormatNumber(double number, FormatOption formatOption)
        {
            switch (formatOption)
            {
            case FormatOption.FloatingPoint:
                Console.WriteLine("{0:F2}", number);
                break;

            case FormatOption.Percent:
                if (number < 0)
                {
                    throw new ArgumentOutOfRangeException("The number must be greater or equal to 0 to convert to %.");
                }

                Console.WriteLine("{0:P0}", number);
                break;

            case FormatOption.AlignRight:
                Console.WriteLine("{0,8}", number);
                break;

            default: throw new ArgumentException("Invalid formatting option");
            }
        }
 /// <summary>
 /// Used by all Format() functions to call CreateTapePartition()
 /// </summary>
 /// <param name="option">Win32 option to send</param>
 /// <param name="count"></param>
 /// <param name="size"></param>
 private void FormatHelper(FormatOption option, UInt32 count, UInt32 size)
 {
     CheckError(TapeDriveFunctions.CreateTapePartition(tapeHandle, (UInt32)option, count, size));
 }
 /// <summary>
 /// Used by all Format() functions to call CreateTapePartition()
 /// </summary>
 /// <param name="option">Win32 option to send</param>
 /// <param name="count"></param>
 /// <param name="size"></param>
 private void FormatHelper(FormatOption option, UInt32 count, UInt32 size)
 {
     CheckError(TapeDriveFunctions.CreateTapePartition(tapeHandle, (UInt32)option, count, size));
 }
Пример #12
0
        private void AppendFormat(string value, FormatOption formatOption)
        {
            var formattedValue = OracleStatementFormatter.FormatTerminalValue(value, formatOption);

            _builder.Append(formattedValue);
        }
Пример #13
0
        private static FormatOption ProcessPrettyOptions(string[] args)
        {
            var result = new FormatOption();

            return(result);
        }
Пример #14
0
 /* ----------------------------------------------------------------- */
 ///
 /// GetVersion
 ///
 /// <summary>
 /// FormatOption に対応する Version オブジェクトを取得します。
 /// </summary>
 ///
 /// <param name="src">FormatOption</param>
 ///
 /// <returns>Version</returns>
 ///
 /* ----------------------------------------------------------------- */
 public static Version GetVersion(this FormatOption src) =>
 GetFormatOptionMap().TryGetValue(src, out var dest) ?
 dest : new Version(1, 0);
Пример #15
0
		internal static string FormatTerminalValue(string value, FormatOption formatOption)
		{
			if (value.IsQuoted())
			{
				return value;
			}

			switch (formatOption)
			{
				case FormatOption.Keep:
					return value;
				case FormatOption.Upper:
					return value.ToUpper(CultureInfo.CurrentCulture);
				case FormatOption.Lower:
					return value.ToLower(CultureInfo.CurrentCulture);
				case FormatOption.InitialCapital:
					return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(value.ToLower(CultureInfo.CurrentCulture));
				default:
					throw new NotSupportedException();
			}
		}
Пример #16
0
 private static FormatOption ProcessPrettyOptions(string[] args)
 {
     var result = new FormatOption();
     return result;
 }