// Overrides the ConvertTo method of TypeConverter. public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { var v = value as IEnumerable<String>; if (destinationType == typeof(string)) { return string.Join(", ", v.Select(AddQuotes).ToArray()); } return base.ConvertTo(context, culture, value, destinationType); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var flag = false; if (value is bool) { flag = (bool)value; } else if (value is bool?) { var nullable = (bool?)value; flag = nullable.GetValueOrDefault(); } if (parameter != null) { if (bool.Parse((string)parameter)) { flag = !flag; } } if (flag) { return "/Resources/Images/License_Valid.png"; } else { return "/Resources/Images/License_Invalid.png"; } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { var vs = ((string)value).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); return vs.Select(v => v.Trim('"')).ToList(); } return base.ConvertFrom(context, culture, value); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { RepeatType repeatType = RepeatType.NotRepeated; if (value is int) { switch ((int)value) { case 0: repeatType = RepeatType.NotRepeated; break; case 1: repeatType = RepeatType.Daily; break; case 2: repeatType = RepeatType.Weekly; break; case 3: repeatType = RepeatType.Monthly; break; case 4: repeatType = RepeatType.Yearly; break; default: break; } } return repeatType; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int index = value is int ? (int)value : 0; int type = parameter is string ? Int32.Parse((string)parameter) : 0; switch (type) { case Background: if (index % 2 == 0) { return MotionFullItemBackgroundEven; } return MotionFullItemBackgroundOdd; case TopSeperator: if (index % 2 == 0) { return MotionFullItemTopSeperatorEven; } return MotionFullItemTopSeperatorOdd; case BottomSeperator: if (index % 2 == 0) { return MotionFullItemBottomSeperatorEven; } return MotionFullItemBottomSeperatorOdd; default: Debug.Assert(type != 0, "Null type"); return null; } }
public object Convert( object value, Type targetType, object parameter, CultureInfo culture ) { if ( value == null ) return null; if ( value.GetType() == typeof( System.Net.IPAddress ) ) return ( ( System.Net.IPAddress ) value ).ToString(); return String.Empty; }
private object ConvertSimple(Type typeToConvertTo, object value, CultureInfo cultureInfo) { if (typeToConvertTo.IsEnum && value is string) return Enum.Parse(typeToConvertTo, (string)value, true); return System.Convert.ChangeType(value, typeToConvertTo, cultureInfo); }
public static void Ctor_CultureInfo(object a, object b, int expected) { var culture = new CultureInfo("en-US"); var comparer = new Comparer(culture); Assert.Equal(expected, Math.Sign(comparer.Compare(a, b))); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return null; double rankNumber = 0; if (value is string) { rankNumber = double.Parse((string) value); } else { rankNumber = System.Convert.ToDouble(value); } if (rankNumber >= 1 && rankNumber < 2) return new Uri("/resources/images/ranks/elo01.png", UriKind.Relative); if (rankNumber >= 2 && rankNumber < 3) return new Uri("/resources/images/ranks/elo02.png", UriKind.Relative); if (rankNumber >= 3 && rankNumber < 4) return new Uri("/resources/images/ranks/elo03.png", UriKind.Relative); if (rankNumber >= 4 && rankNumber < 5) return new Uri("/resources/images/ranks/elo04.png", UriKind.Relative); if (rankNumber >= 5 && rankNumber < 6) return new Uri("/resources/images/ranks/elo05.png", UriKind.Relative); if (rankNumber >= 6 && rankNumber < 7) return new Uri("/resources/images/ranks/elo06.png", UriKind.Relative); if (rankNumber >= 7 && rankNumber < 8) return new Uri("/resources/images/ranks/elo07.png", UriKind.Relative); if (rankNumber >= 8 && rankNumber < 9) return new Uri("/resources/images/ranks/elo08.png", UriKind.Relative); if (rankNumber >= 9 && rankNumber < 10) return new Uri("/resources/images/ranks/elo09.png", UriKind.Relative); if (rankNumber >= 10 && rankNumber < 11) return new Uri("/resources/images/ranks/elo10.png", UriKind.Relative); if (rankNumber >= 11 && rankNumber < 12) return new Uri("/resources/images/ranks/elo11.png", UriKind.Relative); if (rankNumber >= 12 && rankNumber < 13) return new Uri("/resources/images/ranks/elo12.png", UriKind.Relative); if (rankNumber >= 13 && rankNumber < 14) return new Uri("/resources/images/ranks/elo13.png", UriKind.Relative); if (rankNumber >= 14 && rankNumber < 15) return new Uri("/resources/images/ranks/elo14.png", UriKind.Relative); if (rankNumber >= 15 && rankNumber < 16) return new Uri("/resources/images/ranks/elo15.png", UriKind.Relative); if (rankNumber >= 16 && rankNumber < 17) return new Uri("/resources/images/ranks/elo16.png", UriKind.Relative); if (rankNumber >= 17 && rankNumber < 18) return new Uri("/resources/images/ranks/elo17.png", UriKind.Relative); if (rankNumber >= 18) return new Uri("/resources/images/ranks/elo18.png", UriKind.Relative); return new Uri("/resources/images/ranks/no_rank.png", UriKind.Relative); }
/// <summary> /// Converts the source value to a target value. /// </summary> /// <param name="value">The source value to convert.</param> /// <param name="targetType">The type of the target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> /// <remarks> /// This method will only be called if the mode of the <see cref="SingleSourceBinding"/> is either <see cref="BindingMode.TwoWay"/> /// or <see cref="BindingMode.OneWayToTarget"/>. /// </remarks> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType != typeof (string)) return value; return ((DateTime) value).ToString("d", culture); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var flag = false; if (value is bool) { flag = (bool)value; } else if (value is bool?) { var nullable = (bool?)value; flag = nullable.GetValueOrDefault(); } if (parameter != null) { if (bool.Parse((string)parameter)) { flag = !flag; } } if (flag) { return Visibility.Visible; } else { return Visibility.Collapsed; } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { var numberAsString = value as string; if (string.IsNullOrEmpty(numberAsString)) { return this.AllowsEmpty ? new ValidationResult(true, null) : new ValidationResult(false, "値を入力してください。"); } int number; try { number = int.Parse(numberAsString); } catch (Exception) { return new ValidationResult(false, "数値を入力してください。"); } if (this.Min.HasValue && number < this.Min) { return new ValidationResult(false, string.Format("{0} 以上の数値を入力してください。", this.Min)); } if (this.Max.HasValue && this.Max < number) { return new ValidationResult(false, string.Format("{0} 以下の数値を入力してください。", this.Max)); } return new ValidationResult(true, null); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType != typeof(bool)) throw new InvalidOperationException("The target must be boolean."); return !(bool)value; }
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (context == null) return null; var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider; return p != null ? p.GetName (value) : null; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is bool)) return DependencyProperty.UnsetValue; bool visible = ((bool)value) ^ VisibleWhenFalse; return visible ? Visibility.Visible : Visibility.Collapsed; }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return TimeConverter.ConvertTimeToDouble(value, targetType, parameter, culture); /*if (targetType == typeof(Double)) { TimePart timePart = TimeConverter.GetTimePart(parameter, culture); if (value is TimeSpan) { return TimeConverter.TimeSpanToDouble((TimeSpan)value, timePart); } if (value is Duration) { return TimeConverter.DurationToDouble((Duration)value, timePart); } if (value is DateTime) { return TimeConverter.DateTimeToDouble((DateTime)value, timePart); } } return DependencyProperty.UnsetValue;*/ }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var format = parameter as string; if (format == "B") return ConvertUnit(value, CommonLocale.B, 1024, "", CommonLocale.ki, CommonLocale.Mi, CommonLocale.Gi); return value; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return TimeConverter.ConvertDoubleToTime(value, targetType, parameter, culture); /*if (value is Double) { Double d = (Double)value; TimePart timePart = TimeConverter.GetTimePart(parameter, culture); if (targetType == typeof(TimeSpan)) { return TimeConverter.DoubleToTimeSpan(d, timePart); } if (targetType == typeof(Duration)) { return TimeConverter.DoubleToDuration(d, timePart); } if (targetType == typeof(DateTime)) { return TimeConverter.DoubleToDateTime(d, timePart); } } return DependencyProperty.UnsetValue;*/ }
/// <summary> /// </summary> /// <param name="culture">Текущие сведения о языке и региональных параметрах</param> /// <param name="authUri">Url авторизации</param> /// <param name="blankUri">Url на который возвращаются данные авторизации</param> /// <param name="availableHostNames">Доступные имена хостов в браузере. Если NulL, то доступен переход на любой хост</param> public AuthorizationParameters(CultureInfo culture, Uri authUri, Uri blankUri, IEnumerable<string> availableHostNames = null) { _culture = culture; _authUri = authUri; _blankUri = blankUri; _availableHostNames = availableHostNames; }
// ---------------------------------------------------------------------- public TimeFormatter( CultureInfo culture = null, string contextSeparator = "; ", string startEndSeparator = " - ", string durationSeparator = " | ", string dateTimeFormat = null, string shortDateFormat = null, string longTimeFormat = null, string shortTimeFormat = null, DurationFormatType durationType = DurationFormatType.Compact, bool useDurationSeconds = false, bool useIsoIntervalNotation = false) { if ( culture == null ) { culture = CultureInfo.CurrentCulture; } this.culture = culture; listSeparator = culture.TextInfo.ListSeparator; this.contextSeparator = contextSeparator; this.startEndSeparator = startEndSeparator; this.durationSeparator = durationSeparator; this.dateTimeFormat = dateTimeFormat; this.shortDateFormat = shortDateFormat; this.longTimeFormat = longTimeFormat; this.shortTimeFormat = shortTimeFormat; this.durationType = durationType; this.useDurationSeconds = useDurationSeconds; this.useIsoIntervalNotation = useIsoIntervalNotation; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return Visibility.Collapsed; bool visibility = (bool)value; return visibility ? Visibility.Collapsed : Visibility.Visible; }
public static Task CreateTaskByTable(DataTable dt) { Task task = null; try { task = new Task(); task.TaskNo = (dt.Rows[0]["TaskNo"] == null ? "" : dt.Rows[0]["TaskNo"].ToString()); task.BatchNo = (dt.Rows[0]["BatchNo"] == null ? "" : dt.Rows[0]["BatchNo"].ToString()); task.ItemNo = (dt.Rows[0]["ItemNo"] == null ? "" : dt.Rows[0]["ItemNo"].ToString()); task.ItemName = (dt.Rows[0]["ItemName"] == null ? "" : dt.Rows[0]["ItemName"].ToString()); task.Sn = (dt.Rows[0]["Sn"] == null ? "" : dt.Rows[0]["Sn"].ToString()); task.PV = (dt.Rows[0]["PV"] == null ? 0 : int.Parse(dt.Rows[0]["PV"].ToString())); task.Result = (dt.Rows[0]["Result"] == null ? 0 : int.Parse(dt.Rows[0]["Result"].ToString())); task.redundantVaue = (dt.Rows[0]["RedundantVaue"] == null ? 0 : int.Parse(dt.Rows[0]["RedundantVaue"].ToString())); IFormatProvider ifp = new CultureInfo("zh-CN", true); if (dt.Rows[0]["StartTime"] != null) { DateTime.TryParseExact(dt.Rows[0]["StartTime"].ToString(), DateTimeFormat2, ifp, DateTimeStyles.None, out task.StartTime); } if (dt.Rows[0]["CompleteTime"] != null) { DateTime.TryParseExact(dt.Rows[0]["CompleteTime"].ToString(), DateTimeFormat2, ifp, DateTimeStyles.None, out task.CompleteTime); } return task; } catch (Exception ex) { Program.WriteErrorLog("CreateTaskByTable", ex); return task; } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ScanStatus s1 = (ScanStatus)value; ScanStatus s2 = (ScanStatus)parameter; return s1 == s2 ? Visibility.Visible : Visibility.Collapsed; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Parse value into equation and remove spaces var mathEquation = parameter as string; mathEquation = mathEquation.Replace(" ", ""); mathEquation = mathEquation.Replace("@VALUE", value.ToString()); // Validate values and get list of numbers in equation var numbers = new List<double>(); double tmp; foreach (string s in mathEquation.Split(_allOperators)) { if (s != string.Empty) { if (double.TryParse(s, out tmp)) { numbers.Add(tmp); } else { // Handle Error - Some non-numeric, operator, or grouping character found in string throw new InvalidCastException(); } } } // Begin parsing method EvaluateMathString(ref mathEquation, ref numbers, 0); // After parsing the numbers list should only have one value - the total return numbers[0]; }
public void Test1() { string[] edays = { "\u661F\u671F\u65E5", "\u661F\u671F\u4E00", "\u661F\u671F\u4E8C", "\u661F\u671F\u4E09", "\u661F\u671F\u56DB", "\u661F\u671F\u4E94", "\u661F\u671F\u516D" }; string[] emonths = GetMonthNames(); DateTimeFormatInfo dtfi = new CultureInfo("zh-TW").DateTimeFormat; dtfi.Calendar = new TaiwanCalendar(); // Actual Day Names and Month Names for TaiwanCalendar string[] adays = dtfi.DayNames; for (int i = 0; i < edays.Length; i++) { Assert.Equal(edays[i], adays[i]); } string[] amonths = dtfi.MonthNames; for (int i = 0; i < edays.Length; i++) { Assert.Equal(emonths[i], amonths[i]); } }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Check security CheckSecurity(); // Set cultures SetCulture(); IFormatProvider culture = DateTimeHelper.DefaultIFormatProvider; IFormatProvider currentCulture = new CultureInfo(Thread.CurrentThread.CurrentUICulture.IetfLanguageTag); // Get report info string reportName = ValidationHelper.GetString(Request.QueryString["reportname"], ""); ReportInfo report = ReportInfoProvider.GetReportInfo(reportName); if (report != null) { // Get report parameters string parameters = QueryHelper.GetString("parameters", ""); DataRow drParameters = ReportHelper.GetReportParameters(report, parameters, AnalyticsHelper.PARAM_SEMICOLON, culture, currentCulture); // Init report if (drParameters != null) { DisplayReport1.LoadFormParameters = false; DisplayReport1.ReportParameters = drParameters; } DisplayReport1.ReportName = report.ReportName; DisplayReport1.DisplayFilter = false; Page.Title = GetString("Report_Print.lblPrintReport") + " " + HTMLHelper.HTMLEncode(report.ReportDisplayName); } }
private CultureInfo alteraCulturaThread(bool ponto) { //Passar para o Frmk - Gustavo. System.Globalization.CultureInfo obj = null; try { if (ponto) { obj = new System.Globalization.CultureInfo("PT-BR", true); obj.NumberFormat.CurrencyGroupSeparator = ","; obj.NumberFormat.CurrencyDecimalSeparator = "."; obj.NumberFormat.NumberGroupSeparator = ","; obj.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = obj; } else { obj = new System.Globalization.CultureInfo("PT-BR", true); obj.NumberFormat.CurrencyGroupSeparator = "."; obj.NumberFormat.CurrencyDecimalSeparator = ","; obj.NumberFormat.NumberGroupSeparator = "."; obj.NumberFormat.NumberDecimalSeparator = ","; System.Threading.Thread.CurrentThread.CurrentCulture = obj; } } catch (Exception ex) { obj = null; } return obj; }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value that is produced by the binding target.</param> /// <param name="targetType">The type to convert to.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns <c>null</c>, the valid <c>null</c> value is used. /// </returns> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var b = (bool)value; if (b != this.NullValue) { var ult = Nullable.GetUnderlyingType(targetType); if (ult != null) { if (ult == typeof(DateTime)) { return DateTime.Now; } return Activator.CreateInstance(ult); } if (targetType == typeof(string)) { return string.Empty; } return Activator.CreateInstance(targetType); } if (targetType == typeof(double)) { return double.NaN; } return null; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if ((bool) value) return "true"; return "false"; }
/// <summary> /// Constructor specifying both the IPublishedContent and the CultureInfo /// </summary> /// <param name="content"></param> /// <param name="culture"></param> public RenderModel(IPublishedContent content, CultureInfo culture) { if (content == null) throw new ArgumentNullException("content"); if (culture == null) throw new ArgumentNullException("culture"); Content = content; CurrentCulture = culture; }
private static ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, bool ignoreCase, Reflection.BindingFlags bindingAttr, Reflection.Binder binder, object[] args, Globalization.CultureInfo culture, object[] activationAttributes) { return(CreateInstanceFromInternal(assemblyFile, typeName, ignoreCase, bindingAttr, binder, args, culture, activationAttributes, null)); }
private static ObjectHandle CreateInstanceFromInternal(String assemblyFile, String typeName, bool ignoreCase, Reflection.BindingFlags bindingAttr, Reflection.Binder binder, Object[] args, Globalization.CultureInfo culture, Object[] activationAttributes, Security.Policy.Evidence securityInfo) { #if FEATURE_CAS_POLICY Contract.Assert(AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled || securityInfo == null); #endif // FEATURE_CAS_POLICY #pragma warning disable 618 Reflection.Assembly assembly = Reflection.Assembly.LoadFrom(assemblyFile); //, securityInfo); #pragma warning restore 618 Type t = assembly.GetType(typeName, true, ignoreCase); Object o = Activator.CreateInstance(t, bindingAttr, binder, args, culture, activationAttributes); // Log(o != null, "CreateInstanceFrom:: ", "Created Instance of class " + typeName, "Failed to create instance of class " + typeName); if (o == null) { return(null); } else { ObjectHandle Handle = new ObjectHandle(o); return(Handle); } }
public static string ToString(this char c, Globalization.CultureInfo cultureInfo) { return(c.ToString()); }
public string GetText(System.Globalization.CultureInfo ci = null) { return(GetDocElement(TextNodes, ci)); }
protected void Page_Load(object sender, EventArgs e) { title = valObj._ZhName + "详细"; Page.Title = title; if (!IsPostBack) { try { if (!string.IsNullOrEmpty(Request["BILL_ID"])) { valObj = BLLTable <SYS_BILL> .Factory(conn).GetRowData(SYS_BILL.Attribute.BILL_ID, Request["BILL_ID"]); if (valObj == null) { return; } txtBILL_ID.Text = Convert.ToString(valObj.BILL_ID);//Convert.ToInt32 txtBILL_NAME.Text = Convert.ToString(valObj.BILL_NAME);//Convert.ToString txtBILL_TYPE.Text = Convert.ToString(valObj.BILL_TYPE);//Convert.ToString txtBILL_SQL.Text = Convert.ToString(valObj.BILL_SQL);//Convert.ToString txtADDTIME.Text = (valObj.ADDTIME == DateTime.MinValue) ? "" : valObj.ADDTIME.ToString("yyyy-MM-dd HH:mm"); txtEDITIME.Text = (valObj.EDITIME == DateTime.MinValue) ? "" : valObj.EDITIME.ToString("yyyy-MM-dd HH:mm"); txtADDER.Text = Convert.ToString(valObj.ADDER);//Convert.ToString txtTABLE_NAME.Text = Convert.ToString(valObj.TABLE_NAME);//Convert.ToString txtP_BILL_ID.Text = Convert.ToString(valObj.P_BILL_ID);//Convert.ToInt32 } } catch (Exception ex) { litWarn.Text = ex.Message; } if (Request["ajax"] != null) { Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文 //Response.ContentType = "html/text"; this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); divC.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); } } }
public Form1() { InitializeComponent(); this.Text = "FlexASIO GUI v0.2"; System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); enc1252 = Encoding.GetEncoding(1252); System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentUICulture = customCulture; TOMLPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\FlexASIO.toml"; flexGUIConfig = new FlexGUIConfig(); if (File.Exists(TOMLPath)) { flexGUIConfig = Toml.ReadFile <FlexGUIConfig>(TOMLPath); } numericBufferSize.Maximum = 8192; numericBufferSize.Value = 256; numericBufferSize.Increment = 16; numericLatencyInput.Increment = 0.1m; numericLatencyOutput.Increment = 0.1m; for (var i = 0; i < Configuration.HostApiCount; i++) { comboBackend.Items.Add(Configuration.GetHostApiInfo(i).name); } if (comboBackend.Items.Contains(flexGUIConfig.backend)) { comboBackend.SelectedIndex = comboBackend.Items.IndexOf(flexGUIConfig.backend); } else { comboBackend.SelectedIndex = 0; } numericBufferSize.Value = (Int64)flexGUIConfig.bufferSizeSamples; treeDevicesInput.SelectedNode = treeDevicesInput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.input.device == "" ? "(None)" : flexGUIConfig.input.device)); treeDevicesOutput.SelectedNode = treeDevicesOutput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.output.device == "" ? "(None)" : flexGUIConfig.output.device)); numericLatencyInput.Value = (decimal)(double)flexGUIConfig.input.suggestedLatencySeconds; numericLatencyOutput.Value = (decimal)(double)flexGUIConfig.output.suggestedLatencySeconds; numericChannelsInput.Value = (decimal)(flexGUIConfig.input.channels ?? 0); numericChannelsOutput.Value = (decimal)(flexGUIConfig.output.channels ?? 0); wasapiExclusiveInput.Checked = flexGUIConfig.input.wasapiExclusiveMode; wasapiExclusiveOutput.Checked = flexGUIConfig.output.wasapiExclusiveMode; wasapiAutoConvertInput.Checked = flexGUIConfig.input.wasapiAutoConvert; wasapiAutoConvertOutput.Checked = flexGUIConfig.output.wasapiAutoConvert; InitDone = true; SetStatusMessage($"FlexASIO GUI for FlexASIO 0.15 started ({Configuration.VersionString})"); GenerateOutput(); }
/// <summary> /// Comverts an <seealso cref="UmlTypes"/> enumeration member into a string or /// the equivalent string for <seealso cref="UmlTypes"/>.Undefined if conversion failed. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(null); } if ((value is UmlTypes) == false) { return(null); } string str = string.Empty; if (this.mMapUmlTypeToString.TryGetValue((UmlTypes)value, out str) == false) { this.mMapUmlTypeToString.TryGetValue(UmlTypes.Undefined, out str); } return(str); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new InvalidOperationException(); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value == null ? string.Empty : value); }
static void Main(string[] args) { try { List <FlightDetails> lst = new List <FlightDetails>(); System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture; //Path given for the provider files. System.IO.TextReader readFile = new StreamReader(@"Provider1.txt"); System.IO.TextReader readFile2 = new StreamReader(@"Provider2.txt"); System.IO.TextReader readFile3 = new StreamReader(@"Provider3.txt"); String strContinue; //reading and parsing first file var csv = new CsvReader(readFile); string format = "M/dd/yyyy H:mm:ss"; csv.Configuration.Delimiter = ","; csv.Read(); csv.ReadHeader(); while (csv.Read()) { var origin = csv.GetField <string>(0); string departTime = csv.GetField <string>(1); DateTime departureTime; if (!DateTime.TryParseExact(departTime, format, provider, System.Globalization.DateTimeStyles.None, out departureTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var destination = csv.GetField <string>(2); var destTime = csv.GetField <string>(3); DateTime destinationTime; if (!DateTime.TryParseExact(destTime, format, provider, System.Globalization.DateTimeStyles.None, out destinationTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var price = csv.GetField <string>(4); var doublePrice = Convert.ToDouble(price.Substring(1)); lst.Add(new FlightDetails(origin, departureTime, destination, destinationTime, doublePrice)); } readFile.Close(); //reading and parsing second file var csv2 = new CsvReader(readFile2); string format2 = "M-dd-yyyy H:mm:ss"; csv2.Configuration.Delimiter = ","; csv2.Read(); csv2.ReadHeader(); while (csv2.Read()) { var origin = csv2.GetField <string>(0); string departTime = csv2.GetField <string>(1); DateTime departureTime; if (!DateTime.TryParseExact(departTime, format2, provider, System.Globalization.DateTimeStyles.None, out departureTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var destination = csv2.GetField <string>(2); var destTime = csv2.GetField <string>(3); DateTime destinationTime; if (!DateTime.TryParseExact(destTime, format2, provider, System.Globalization.DateTimeStyles.None, out destinationTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var price = csv2.GetField <string>(4); var doublePrice = Convert.ToDouble(price.Substring(1)); lst.Add(new FlightDetails(origin, departureTime, destination, destinationTime, doublePrice)); } readFile2.Close(); //reading and parsing third file var csv3 = new CsvReader(readFile3); csv3.Configuration.Delimiter = "|"; csv3.Read(); csv3.ReadHeader(); while (csv3.Read()) { var origin = csv3.GetField <string>(0); string departTime = csv3.GetField <string>(1); DateTime departureTime; if (!DateTime.TryParseExact(departTime, format, provider, System.Globalization.DateTimeStyles.None, out departureTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var destination = csv3.GetField <string>(2); var destiTime = csv3.GetField <string>(3); DateTime destinationTime; if (!DateTime.TryParseExact(destiTime, format, provider, System.Globalization.DateTimeStyles.None, out destinationTime)) { // If TryParseExact Failed Console.WriteLine("Failed to Parse Date"); } var price = csv3.GetField <string>(4); var doublePrice = Convert.ToDouble(price.Substring(1)); FlightDetails flightDetails = new FlightDetails(origin, departureTime, destination, destinationTime, doublePrice); lst.Add(flightDetails); } readFile3.Close(); //Console.WriteLine(">>>>>>>>>>>>>>>>>>>SORTED&DISTICT<<<<<<<<<<<<<<<<<<<<<<"); lst.Sort(new CompareProduct()); //removing duplicates Int32 index = 0; while (index < lst.Count - 1) { if (lst[index].Origin == (lst[index + 1].Origin) && lst[index].DepartureTime == (lst[index + 1].DepartureTime)) { lst.RemoveAt(index); } else { index++; } } Console.WriteLine("Origin-->Destination (DepartureTime-->DestinationTime) - Price"); foreach (FlightDetails flightDetail in lst) { Console.WriteLine(flightDetail.Origin + " --> " + flightDetail.Destination + " (" + flightDetail.DepartureTime + " --> " + flightDetail.DestinationTime + ")" + " - $" + flightDetail.Price); } do { Console.WriteLine("Please Enter Origin"); String strOriginInput = Console.ReadLine(); Console.WriteLine("Please Enter Destination"); String strDestinationInput = Console.ReadLine(); Console.WriteLine("search Flights -o " + strOriginInput.ToUpper() + " -d " + strDestinationInput.ToUpper()); List <FlightDetails> searchedResults = new List <FlightDetails>(); foreach (FlightDetails flightDetail in lst) { if (flightDetail.Origin == strOriginInput.ToUpper() && flightDetail.Destination == strDestinationInput.ToUpper()) { searchedResults.Add(flightDetail); } } if (searchedResults.Count > 1) { Console.WriteLine("Origin-->Destination (DepartureTime-->DestinationTime) - Price"); foreach (FlightDetails flightDetail in searchedResults) { Console.WriteLine(flightDetail.Origin + " --> " + flightDetail.Destination + " (" + flightDetail.DepartureTime + " --> " + flightDetail.DestinationTime + ")" + " - $" + flightDetail.Price); } } else { Console.WriteLine("No Flights for " + strOriginInput + "-->" + strDestinationInput); } Console.WriteLine(" >>>>> Please enter Y if you want to search more flights !!"); strContinue = Console.ReadLine(); } while (strContinue.ToUpper() == "Y"); } catch (IOException ex) { Console.WriteLine(ex.StackTrace); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value.ToString().Replace('_', ' ')); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(((Enum)value).HasFlag((Enum)parameter)); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value.Equals(true) ? parameter : Binding.DoNothing); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(double.Parse(value.ToString()) - 5); }
public static string getLocalLongTimeFormat() { System.Globalization.CultureInfo current = System.Globalization.CultureInfo.CurrentCulture; return(current.DateTimeFormat.LongTimePattern.ToString()); }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(value); } Color color = (Color)ColorConverter.ConvertFromString(value.ToString()); return(new SolidColorBrush(color)); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(string.IsNullOrEmpty(value?.ToString())); }
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(Colors.White); } return((Color)ColorConverter.ConvertFromString(value.ToString())); }
/// <summary> /// Converts a string into an <seealso cref="UmlTypes"/> enumeration member or /// the Undefined memeber if the conversion failed. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(null); } if ((value is string) == false) { return(null); } UmlTypes umlTypes; if (this.mMapStringToUmlType.TryGetValue(value as string, out umlTypes) == false) { return(UmlTypes.Undefined); } return(umlTypes); }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(value); } if (value is TimeSpan && ((TimeSpan)value).TotalSeconds == 0) { return(null); } if (value is int && (int)value == 0) { return(null); } if (value is long && (long)value == 0) { return(null); } return(value); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!eventsGrid.IsXmlHttpRequest) { setRange("Today"); using (HyperCatalog.Business.ApplicationComponentCollection batchComponents = HyperCatalog.Business.ApplicationComponent.GetAll(HyperCatalog.Business.ApplicationComponentTypes.Batch)) { componentList.DataSource = batchComponents; componentList.DataTextField = "Name"; componentList.DataValueField = "Id"; componentList.DataBind(); componentList.Items.Insert(0, new ListItem("-- All batches", "-1")); } #region url parameters if (Request["AppComponentId"] != null) { try { componentList.SelectedValue = Request["AppComponentId"]; mainToolBar.Items.Remove(mainToolBar.Items.FromKeyCustom("componentList")); mainToolBar.Items.Remove(mainToolBar.Items.FromKeyLabel("filter")); mainToolBar.Items.Remove(mainToolBar.Items.FromKeySeparator("filterSep")); } catch { } } if (Request["before"] != null) { try { //Response.Write("Init Date Before<br/>"); endDate.Value = DateTime.Parse(Request["before"]); startDate.Value = DateTime.MinValue; } catch { } } if (Request["after"] != null) { try { //Response.Write("Init Date after<br/>"); startDate.Value = DateTime.Parse(Request["after"]); } catch { } } #endregion } mainToolBar.Items.FromKeyButton("Today").Selected = true; } eventsGrid.DisplayLayout.EnableInternalRowsManagement = false; eventsGrid.DisplayLayout.AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.No; eventsGrid.DisplayLayout.LoadOnDemand = Infragistics.WebUI.UltraWebGrid.LoadOnDemand.Xml; Utils.InitGridSort(ref eventsGrid, false); System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); ci.DateTimeFormat.ShortDatePattern = SessionState.User.FormatDate; ci.DateTimeFormat.LongDatePattern = SessionState.User.FormatDate; startDate.CalendarLayout.Culture = ci; endDate.CalendarLayout.Culture = ci; startDate.MinDate = DateTime.Today.AddMonths(-1); startDate.MaxDate = DateTime.Today; endDate.MinDate = DateTime.Today.AddMonths(-1); endDate.MaxDate = DateTime.Today; }
public string GetLabel(System.Globalization.CultureInfo ci = null) { return(GetDocElement(LabelNodes, ci)); }
protected override string Convert(DateTime value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value.ToString("hh:mm tt", CultureInfo.InvariantCulture)); }
public override object ConvertFrom(ComponentModel.ITypeDescriptorContext context, Globalization.CultureInfo culture, object value) { if (value is string) { string valstr = value as string; if (string.IsNullOrEmpty(valstr) == false && valstr.StartsWith("data:")) { return(DataUri.Parse(valstr)); } else { return(null); } } return(base.ConvertFrom(context, culture, value)); }
public override string GetMessage(System.Globalization.CultureInfo culture = null) { return(this.Info.GetMessage(culture)); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { //反转换方法,就是对照上面的把男女再转换回去 return((Visibility)value == Visibility.Collapsed); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(value?.Equals(parameter)); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { //将bool值转换为什么呢?自己在这里定义 return((bool)value ? Visibility.Collapsed : Visibility.Visible); }