public ThreadHeaderFormatControl(FormatType formatType) { InitializeComponent(); switch (formatType) { case FormatType.ImageHeader: for (int i = 1; i < DeanCCCore.Core._2ch.ThreadHeader.FormatNamePairs.Length; i += 2) { formatComboBox.Items.Add(DeanCCCore.Core._2ch.ThreadHeader.FormatNamePairs[i]); } for (int i = 1; i < DeanCCCore.Core.ImageHeader.FormatNamePairs.Length; i += 2) { formatComboBox.Items.Add(DeanCCCore.Core.ImageHeader.FormatNamePairs[i]); } break; default: case FormatType.ThreadHeader: for (int i = 1; i < DeanCCCore.Core._2ch.ThreadHeader.FormatNamePairs.Length; i += 2) { formatComboBox.Items.Add(DeanCCCore.Core._2ch.ThreadHeader.FormatNamePairs[i]); } break; } formatComboBox.SelectedIndex = 0; }
public static unsafe void SetData(this ITexture2D texture2D, int level, byte[] data, FormatColor formatColor, FormatType type) { fixed (byte* pData = data) { texture2D.SetData(level, (IntPtr)pData, formatColor, type); } }
public static string Get(Dictionary<string, string> dict, FormatType formatType, string code) { if (formatType == FormatType.GetKey) return dict.FirstOrDefault(d => d.Value == code).Key; else return dict.FirstOrDefault(d => d.Key == code).Value; }
public static void SetGridColumnFormat(GridView view, String columnName, FormatType type, String formatString) { GridColumn column = view.Columns.ColumnByFieldName(columnName); if (column != null) { column.DisplayFormat.FormatType = type; column.DisplayFormat.FormatString = formatString; } }
protected BaseService(FormatType format) { if (Config.GitHub.Authentication != null && !string.IsNullOrEmpty(Config.GitHub.Authentication.UserName) && !string.IsNullOrEmpty(Config.GitHub.Authentication.ApiToken)) Client = new GithubClient(format, Config.GitHub.Authentication.UserName, Config.GitHub.Authentication.ApiToken); else Client = new GithubClient(format); }
public GithubClient(FormatType formatType) { FormatType = formatType; if (Config.GitHub.Authentication != null && !string.IsNullOrEmpty(Config.GitHub.Authentication.UserName) && !string.IsNullOrEmpty(Config.GitHub.Authentication.ApiToken)) LoginInfo = new NameValueCollection { { "login", Config.GitHub.Authentication.UserName }, { "token", Config.GitHub.Authentication.ApiToken } }; }
private DefaultProfile(ICredentialProvider icredential, String region, FormatType format) { this.regionId = region; this.AcceptFormat = format; this.icredential = icredential; this.iendpoints = new InternalEndpointsParser(); }
private WrappedTexture(Device device, int width, int height, UsageType usageType, FormatType formatType) { _width = width; _height = height; _usageType = usageType; _formatType = formatType; CreateTexture(device); }
public static WrappedCubeTexture Create(Device device, int edgeSize, UsageType usageType, FormatType formatType) { var usage = DirectXGraphicsContext.MapUsage(usageType); var format = DirectXGraphicsContext.MapFormat(formatType); var wrappedCubeTexture = new WrappedCubeTexture(device, edgeSize, usage, format, Pool.Default); return wrappedCubeTexture; }
public static IReader CreateInstance(FormatType? format) { if (FormatType.JSON == format) return new JsonReader(); if (FormatType.XML == format) return new XmlReader(); return null; }
public static string TypeToString(FormatType type) { if (type == FormatType.Json) return "json"; else if (type == FormatType.Xml) return "xml"; else // if (type == FormatType.Yaml) return "yaml"; }
public static unsafe extern bool CryptQueryObject( CertQueryObjectType dwObjectType, void* pvObject, ExpectedContentTypeFlags dwExpectedContentTypeFlags, ExpectedFormatTypeFlags dwExpectedFormatTypeFlags, int dwFlags, // reserved - always pass 0 out CertEncodingType pdwMsgAndCertEncodingType, out ContentType pdwContentType, out FormatType pdwFormatType, out SafeCertStoreHandle phCertStore, out SafeCryptMsgHandle phMsg, out SafeCertContextHandle ppvContext );
public Dictionary<String, String> RefreshSignParameters(Dictionary<String, String> parameters, ISigner signer, String accessKeyId, FormatType? format) { Dictionary<String, String> immutableMap = new Dictionary<String, String>(parameters); DictionaryUtil.Add(immutableMap, "Timestamp", ParameterHelper.FormatIso8601Date(DateTime.Now)); DictionaryUtil.Add(immutableMap, "SignatureMethod", signer.SignerName); DictionaryUtil.Add(immutableMap, "SignatureVersion", signer.SignerVersion); DictionaryUtil.Add(immutableMap, "SignatureNonce", Guid.NewGuid().ToString()); DictionaryUtil.Add(immutableMap, "AccessKeyId", accessKeyId); DictionaryUtil.Add(immutableMap, "Format", format.ToString()); return immutableMap; }
public override string Format(string inputValue, FormatType formatType, string formatString) { string result = ""; decimal d; decimal.TryParse(inputValue, out d); switch (formatType) { case FormatType.ToString: result = d.ToString(formatString); break; case FormatType.StringFormat: result = string.Format(formatString, d); break; } return result; }
public override string Format(string inputValue, FormatType formatType, string formatString) { string result=""; int i; int.TryParse(inputValue, out i); switch (formatType) { case FormatType.ToString: result = i.ToString(formatString); break; case FormatType.StringFormat: result = string.Format(formatString, i); break; } return result; }
private static void ConvertFiles(string sourcePath, string destPath, bool recursive, FormatType format) { var options = SearchOption.TopDirectoryOnly; var timeStarted = DateTime.Now; if (recursive) { options = SearchOption.AllDirectories; } var files = Directory.GetFiles(sourcePath, "*.wmf", options); //foreach (string filePath in files) //{ // ConvertWmfFile(filePath, destPath, format); //} ParallelForSTA(0, files.Length, i => ConvertWmfFile(sourcePath, files[i], destPath, format)); Console.WriteLine(DateTime.Now - timeStarted); }
/// <summary> /// GEt Tencent Pure text content request url /// </summary> /// <param name="requestUrl">request url</param> /// <param name="formatType">format type</param> /// <param name="content">send content</param> /// <param name="clientIp">client ip address</param> /// <returns>request url</returns> public string GetPureTextContentUrl(string requestUrl, string appkey, string accesstoken, string openid, string content, FormatType format, string clientip="", string oauthVersion = "2.a",string scope="all") { requestUrl += "t/add"; #region merge all post argument to list if (PostArgumentList == null) PostArgumentList = new List<KeyValuePair<string, object>>(); PostArgumentList.Add(new KeyValuePair<string, object>("oauth_consumer_key", appkey)); PostArgumentList.Add(new KeyValuePair<string, object>("access_token", accesstoken)); PostArgumentList.Add(new KeyValuePair<string, object>("openid", openid)); PostArgumentList.Add(new KeyValuePair<string, object>("clientip", clientip)); PostArgumentList.Add(new KeyValuePair<string, object>("oauth_version", oauthVersion)); PostArgumentList.Add(new KeyValuePair<string, object>("scope", scope)); PostArgumentList.Add(new KeyValuePair<string, object>("format", format.ToString().ToLower())); PostArgumentList.Add(new KeyValuePair<string, object>("content", content)); #endregion return requestUrl; }
private ColumnDefinition( string binding, string alias, string caption, int? width, string formatString, FormatType formatType, HorizontalAlignment textAlign, HorizontalAlignment captionAlign, bool visible) { _binding = binding; _alias = alias; _caption = caption; _width = width; _formatString = formatString; _formatType = formatType; _textAlign = textAlign; _captionAlign = captionAlign; _visible = visible; }
/// <summary> /// Format /// </summary> /// <param name="source"></param> /// <param name="formatType"> /// <see cref="FormatType" /> /// </param> /// <returns></returns> public static string Format(this string source, FormatType formatType) { if (string.IsNullOrWhiteSpace(source)) return string.Empty; var format = ""; var text = source.OnlyNumbers(); if (formatType == FormatType.Cnpj) format = @"{0:00\.000\.000\/0000\-00}"; if (formatType == FormatType.Cpf) format = @"{0:000\.000\.000\-00}"; if (formatType == FormatType.ZipCode) format = @"{0:00000\-000}"; if (formatType == FormatType.Phone) { format = text.Length == 11 ? @"{0:(00) 00000\-0000}" : @"{0:(00) 0000\-0000}"; } return !string.IsNullOrWhiteSpace(format) ? string.Format(format, Convert.ToDouble(text)) : source; }
public FormatOutput(FormatType format) : base(format) { }
public ColumnFormat(FormatType type, string prefix) : this() { this.type = type; this.prefix = prefix; }
public static extern void rs_enable_stream( IntPtr device, StreamType stream, int width, int height, FormatType format, int framerate, out IntPtr error );
public static extern void rs_get_stream_mode(IntPtr device, StreamType stream, int index, out int width, out int height, out FormatType format, out int framerate, out IntPtr error);
private bool write2FreeFormat(string resultsForOneYear, int[] fields, StreamWriter writer, bool needWriteHeader, FormatType format) { StringBuilder sb = new StringBuilder(); using (CachedCsvReader csv = new CachedCsvReader(new StringReader(resultsForOneYear), true)) { if (csv.FieldCount < 27) return false; string date = ""; if (needWriteHeader) { string[] fieldNames = csv.GetFieldHeaders(); sb.Append(formatFreeFormatData(fieldNames[0], format, true)); foreach (int field in fields) { if (format == FormatType.SIMPLE_CSV) sb.Append(","); sb.Append(formatFreeFormatData(fieldNames[field], format, false)); } sb.AppendLine(); } while (csv.ReadNextRecord()) { date = csv[0]; sb.Append(formatFreeFormatData(date, format, true)); foreach (int field in fields) { if (format == FormatType.SIMPLE_CSV) sb.Append(","); sb.Append(formatFreeFormatData(csv[field], format, false)); } sb.AppendLine(); } checkLastDayofYear(date); } if (sb.Length > 0) writer.Write(sb.ToString()); return sb.Length > 0; }
private bool save2Ascii(int[] fields, int startYear, int endYear, string destinationFolder, FormatType format) { //get the file name using station name string fileName = string.Format("{0}\\{1}{2}.{3}", Path.GetFullPath(destinationFolder), _id, getTimeAffix(),getExtentionFromType(format)); //precipitation this.setProgress(0, string.Format("Processing station {0}", _id)); this.setProgress(0, fileName); //open the file and write the data int processPercent = 0; bool hasResults = false; clearFailureYears(); clearUncompletedYears(); using (StreamWriter writer = new StreamWriter(fileName)) { for (int i = startYear; i <= endYear; i++) { setProgress(processPercent, string.Format("Downloading data for station: {0}, year: {1}", _id, i)); string resultsForOneYear = this.retrieveAnnualDailyClimateData(i, true); if (resultsForOneYear.Length == 0) { addFailureYear(i); continue; } processPercent += 1; setProgress(processPercent, "Writing data"); if (format == FormatType.SIMPLE_CSV || format == FormatType.SIMPLE_TEXT) hasResults = write2FreeFormat(resultsForOneYear, fields, writer, i == startYear, format); processPercent += 1; } } return hasResults; }
/// <summary> /// get result file extension (txt, csv or dbf) from result format /// </summary> /// <param name="type"></param> /// <returns></returns> private string getExtentionFromType(FormatType type) { if (type == FormatType.ARCSWAT_DBF) return "dbf"; else if (type == FormatType.SIMPLE_CSV) return "csv"; return "txt"; }
private string formatFreeFormatData(string v, FormatType format, bool isDate) { if (format == FormatType.SIMPLE_CSV) return v; else if (format == FormatType.SIMPLE_TEXT) { if (isDate) return v.PadRight(FIXED_FIELD_WIDTH); else return v.PadLeft(FIXED_FIELD_WIDTH); } return ""; }
public bool save(int[] fields, int startYear, int endYear, string destinationFolder, FormatType format) { if (!Exist) { setProgress(0,string.Format(WARNING_FORMAT, "Station " + _id + " desn't exist")); return false; } if (format == FormatType.ARCSWAT_DBF) return save2ArcSWATdbf(startYear, endYear, destinationFolder); else if (format == FormatType.ARCSWAT_TEXT) return save2ArcSWATAscii(startYear, endYear, destinationFolder); else if (format == FormatType.SIMPLE_CSV || format == FormatType.SIMPLE_TEXT) return save2Ascii(fields, startYear, endYear, destinationFolder, format); else return false; }
public void EnableStream( StreamType stream, int width, int height, FormatType format, int framerate ) { IntPtr error = IntPtr.Zero; NativeMethod.Device.rs_enable_stream( device, stream, width, height, format, framerate, out error ); RealSenseException.Handle( error ); }
/// <summary> /// Serializes the specified generic type to the specified filename using the specified format. /// </summary> /// <param name="fullFilename">The fully qualified file name of the file to which the data is to be serialized.</param> /// <param name="data">The data to be serialized.</param> /// <typeparam name="T">The object type to be serialized.</typeparam> /// <param name="formatType">The format to be used to serialize the generic type: Binary; SOAP; Xml.</param> public static void Serialize <T>(string fullFilename, T data, FormatType formatType) { // Provides functionality for formatting serialized objects. IFormatter formatter; // Provides support for serializing objects using XML format. XmlSerializer xmlSerializer; // Exposes a stream around a file, supporting both synchronous and asynchronous read and write operations. FileStream fileStream; // Ensure that the specified filename is valid. FileInfo fileInfo = new FileInfo(fullFilename); DirectoryInfo directoryInfo = new DirectoryInfo(fileInfo.Directory.ToString()); if (directoryInfo.Exists) { Cursor.Current = Cursors.WaitCursor; // If the file already exists, delete it. If we don't do this there can be problems when saving the data in XML mode. If the new data is smaller // than the data in the existing file then the new data appears to be overlayed into the existing file which mean that when the file is read the // XML code may contains spurious remnants of the existing XML code at the end of the file which may throw an exception. try { if (fileInfo.Exists) { fileInfo.Delete(); } } catch (Exception exception) { MessageBox.Show(exception.Message + CommonConstants.NewPara + Resources.MBTLayoutChangesNotSaved, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } fileStream = fileInfo.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); try { // Serialize the data using the appropriate serialization type. switch (formatType) { case FormatType.Binary: formatter = new BinaryFormatter(); formatter.Serialize(fileStream, data); break; case FormatType.SOAP: formatter = new BinaryFormatter(); formatter.Serialize(fileStream, data); break; case FormatType.Xml: xmlSerializer = new XmlSerializer(typeof(T)); xmlSerializer.Serialize(fileStream, data); break; case FormatType.Csv: CsvSerializer csvSerializer = new CsvSerializer(typeof(T)); csvSerializer.Serialize(fileStream, data); break; } } catch (Exception exception) { MessageBox.Show(exception.Message, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { fileStream.Close(); Cursor.Current = Cursors.Default; } } }
public void In( [FriendlyName("Target", "The integer you wish to convert to a string.")] int Target, [FriendlyName("Standard Format", "Standard numeric formatting string.\n\n" + "The following results will be generated when the Target value is equal to 125 and the Invariant Culture is used:\n\n" + "\tGeneral:\t\t\t125\n" + "\tCurrency:\t\t$125.00\n" + "\tDecimal:\t\t\t125\n" + "\tExponential:\t1.250000E+002\n" + "\tFixedPoint:\t\t125.00\n" + "\tNumber:\t\t\t125.00\n" + "\tPercent:\t\t\t12500.00 %\n" + "\tHexidecimal:\t7D" )] [DefaultValue(FormatType.General), SocketState(false, false)] FormatType StandardFormat, [FriendlyName("Custom Format", "An optional custom numeric format string. If none is specified, the chosen Standard Format will be used instead.\n\n" + "The following results will be generated when the Target value is equal to 125 and the Invariant Culture is used:\n\n" + "\t#.####:\t\t\t125\n" + "\t0.####:\t\t\t125\n" + "\t0.0000:\t\t\t125.0000\n" + "\t0000.0000:\t\t0125.0000\n" + "\tC5:\t\t\t\t$125.00000" )] [DefaultValue(""), SocketState(false, false)] string CustomFormat, [FriendlyName("Custom Culture", "An optional custom culture string. If none is specified, the Invariant Culture will be used.\n\n" + "The following results will be generated when the Target value is equal to 125 and the custom culture is set to \"sv-SE\"." + " Note the use of ',' instead of '.' for the decimal separator and the currency symbol for Swedish Krona:\n\n" + "\tGeneral:\t\t\t125\n" + "\tCurrency:\t\t125,00 kr" )] [DefaultValue(""), SocketState(false, false)] string CustomCulture, [FriendlyName("Result", "The string representation of the Target value as specified by format and culture.")] out string Result ) { string format = CustomFormat; #if (!UNITY_FLASH && !UNITY_WEBPLAYER && !UNITY_WP8 && !UNITY_WP8_1 && !UNITY_WINRT_8_1) System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture(CustomCulture); #endif if (string.IsNullOrEmpty(format)) { switch (StandardFormat) { case FormatType.Currency: format = "C"; break; case FormatType.Decimal: format = "D"; break; case FormatType.Exponential: format = "E"; break; case FormatType.FixedPoint: format = "F"; break; case FormatType.Number: format = "N"; break; case FormatType.Percent: format = "P"; break; case FormatType.Hexadecimal: format = "X"; break; default: format = "G"; break; } } #if (!UNITY_FLASH && !UNITY_WEBPLAYER && !UNITY_WP8 && !UNITY_WP8_1 && !UNITY_WINRT_8_1) Result = Target.ToString(format, ci); #else Result = Target.ToString(); #endif }
public ShowInLicenseInfoAttribute(bool showInLicenseInfo, string displayAs, FormatType dataFormatType) { _showInLicenseInfo = showInLicenseInfo; _displayAs = displayAs; _formatType = dataFormatType; }
public static void ConvertFile(string inputPath, string fileIn, string fileOut, FormatType inputFormat, FormatType outputFormat) { fileOut = ChangeFileExtension(fileOut, outputFormat); Logger.LogMessage(null, "INFO", inputPath); try { using (var fIn = new FileStream(fileIn, FileMode.Open, FileAccess.Read)) using (var ms = new MemoryStream()) { if (inputFormat == FormatType.MBIN) { fileOut = ConvertMBIN(inputPath, fIn, ms, fileOut); } else if (inputFormat == FormatType.EXML) { fileOut = ConvertEXML(inputPath, fIn, ms, fileOut); } if (!(StreamToConsole && inputFormat == FormatType.MBIN)) { ms.Flush(); FileMode fileMode; if (!GetFileMode(fileOut, out fileMode)) { return; } Directory.CreateDirectory(Path.GetDirectoryName(fileOut)); using (var fOut = new FileStream(fileOut, fileMode, FileAccess.Write)) ms.WriteTo(fOut); } } } catch (Exception e) { if (e is CompilerException) { throw; } throw new CompilerException(e, fileIn); } }
/// <summary> /// De-serializes the data contained within the specified file into the specified generic type. /// </summary> /// <param name="fullFilename">The fully qualified filename of the file containing the serialized data.</param> /// <param name="formatType">The format that was used to serialize the object: Binary; SOAP; Xml.</param> /// <typeparam name="T">The object type being de-serialized.</typeparam> /// <returns>The de-serialized object.</returns> public static T Load <T>(string fullFilename, FormatType formatType) { // Provides functionality for formatting serialized objects. IFormatter formatter; // Provides support for serializing objects using XML format. XmlSerializer xmlSerializer; // Exposes a stream around a file, supporting both synchronous and asynchronous read and write operations. FileStream fileStream; // The de-serialized object. T data = default(T); try { fileStream = new FileStream(fullFilename, FileMode.Open, FileAccess.Read, FileShare.None); if (fileStream != null) { Cursor.Current = Cursors.WaitCursor; try { // De-serialize the data using the appropriate serialization object. switch (formatType) { case FormatType.Binary: formatter = new BinaryFormatter(); data = (T)formatter.Deserialize(fileStream); break; case FormatType.SOAP: formatter = new BinaryFormatter(); data = (T)formatter.Deserialize(fileStream); break; case FormatType.Xml: xmlSerializer = new XmlSerializer(typeof(T)); data = (T)xmlSerializer.Deserialize(fileStream); break; } } catch (Exception exception) { MessageBox.Show(exception.Message, Resources.MBCaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error); return(data); } finally { fileStream.Close(); Cursor.Current = Cursors.Default; } return(data); } } catch (FileNotFoundException fileNotFoundException) { MessageBox.Show(fileNotFoundException.Message, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(data); } return(data); }
protected BaseService(FormatType format, string gitHubUserName, string gitHubApiToken) { Client = new GithubClient(format, gitHubUserName, gitHubApiToken); }
public void AddColumn(string caption, string fieldname, int width, bool edited, FormatType type, String formatstr) { index++; DevExpress.XtraGrid.Columns.GridColumn column = new DevExpress.XtraGrid.Columns.GridColumn() { Caption = caption, FieldName = fieldname, Width = width, }; column.DisplayFormat.FormatType = type; //FormatType.Numeric; column.DisplayFormat.FormatString = formatstr; column.AppearanceCell.Font = new Font(gridView1.Appearance.Row.Font, FontStyle.Bold); gridView1.Columns.Add(column); column.VisibleIndex = 0; }