public ColorSpaceConversion(ConversionType c) { //используем то, что у всех членов перечисления ConversionType указаны значения int type = (int)c / 2; int direction = (int)c % 2; switch (type) { case 0: ColorSpace = new HSV(); break; case 1: ColorSpace = new YCbCr(); break; case 2: ColorSpace = new GrayScale(); break; default: throw new ArgumentException("Unknown color space"); } IsForwardConversion = direction == 0; }
/// <summary> /// Creates an InDesignConverterImpl to be used for import or export. /// </summary> /// <param name="p_conversionType"> the type of conversion /// (import or export)</param> public InDesignConverterImpl(ConversionType p_conversionType) { m_log = Logger.GetLogger(); m_conversionType = p_conversionType; if (m_conversionType == ConversionType.EXPORT) { m_fileExtensionSearchPattern = EXPORT_FILE_EXT; } else if (m_conversionType == ConversionType.PREVIEW) { m_fileExtensionSearchPattern = PEVIEW_FILE_EXT; } else if (m_conversionType == ConversionType.IDML_PREVIEW) { m_fileExtensionSearchPattern = IDML_PEVIEW_FILE_EXT; } else if (m_conversionType == ConversionType.INCTXRV) { m_fileExtensionSearchPattern = INCTXRV_FILE_EXT; } else { m_fileExtensionSearchPattern = IMPORT_FILE_EXT; } }
public WordsToNumbers(string text, ConversionType ctype, bool convertShortNumbers) { this.OriginalText = text; Conversion = ctype; ConvertShortNumbers = convertShortNumbers; convert(); }
static private ConversionType MoveDirection(ConversionType conversion, DirectionType direction) { int mult = 1; if (direction == DirectionType.Down) { mult = -1; } try { ConversionType newConversion = conversion; if (conversion.ToString().Contains("i")) { newConversion = (ConversionType)((int)conversion + (mult * 10)); } else { newConversion = (ConversionType)((int)conversion + mult); } return(newConversion); } catch { return(conversion); } }
internal RecipeDTO ConvertRecipeMeasurements(RecipeDTO recipe, ConversionType conversionType, bool reverseConversion) { var returnRecipe = recipe.Clone(); foreach (var ingredientList in returnRecipe.IngredientsByComponent.Values) { foreach (var ingredient in ingredientList) { var conversionTypeString = conversionType.ToString(); var conversionTypeStringSplit = conversionTypeString.Split('_'); var leftMeasurement = (Measurement)Enum.Parse(typeof(Measurement), conversionTypeStringSplit.First()); var rightMeasurement = (Measurement)Enum.Parse(typeof(Measurement), conversionTypeStringSplit.Last()); if ((reverseConversion && ingredient.Measurement != rightMeasurement) || (!reverseConversion && ingredient.Measurement != leftMeasurement)) { continue; } if (!reverseConversion) { ingredient.Quantity *= _conversionTable[conversionType]; ingredient.Measurement = rightMeasurement; } else { ingredient.Quantity *= 1 / _conversionTable[conversionType]; ingredient.Measurement = leftMeasurement; } } } return(returnRecipe); }
public static void ConvertDown(int centerX, int y, int width, ConversionType convertType) { int worldSize = GetWorldSize(); int biomeRadius = worldSize == 3 ? 220 : worldSize == 2 ? 180 : 150; biomeRadius /= 2; switch (convertType) { case ConversionType.MIRE: { startMireX = centerX; startMireY = y; genMireWidth = width; ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertDownMireCallback), null); break; } case ConversionType.INFERNO: { startInfernoX = centerX; startInfernoY = y; genInfernoWidth = width; ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertDownInfernoCallback), null); break; } } }
/// <summary> /// 使用指定的转换类型和要复制 IL 指令的数值类型转换初始化 <see cref="NumericConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> /// <param name="conversion">要复制的数值类型转换。</param> public NumericConversion(ConversionType conversionType, NumericConversion conversion) : base(conversionType) { Contract.Requires(conversion != null); uncheckedOpCodes = conversion.uncheckedOpCodes; checkedOpCodes = conversion.checkedOpCodes; }
/// <summary> /// Get converter instances by conversion type. /// </summary> /// <param name="inConversionType"></param> /// <returns></returns> static private ConcurrentBag <FileConverter> GetConverterInstancesByType(ConversionType inConversionType) { switch (inConversionType) { case ConversionType.PDF2PNG: return(m_PDF2PNGConverterInstances); case ConversionType.PDF2PNGSingle: return(m_PDF2PNGSingleConverterInstances); case ConversionType.PDF2JPG: return(m_PDF2JPGConverterInstances); case ConversionType.PDF2EPS: return(m_PDF2EPSConverterInstances); case ConversionType.EPS2PDF: return(m_EPS2PDFConverterInstances); case ConversionType.EPS2LowResPDF: return(m_EPS2LowResPDFConverterInstances); case ConversionType.PDF2LowResPDF: return(m_PDF2LowResPDFConverterInstances); default: return(null); } }
/// <summary> /// Converts XML to object type using specified conversion type. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="xml">The XML.</param> /// <param name="conversionType">Type of the conversion.</param> /// <returns></returns> public static T ConvertFromXml <T>(this string xml, ConversionType conversionType = ConversionType.DataContractSerializerNoNamespace) { var returnObj = default(T); if (conversionType == ConversionType.XMLSerializer) { using (StringReader reader = new StringReader(xml)) { XmlSerializer serializer = new XmlSerializer(typeof(T)); returnObj = (T)serializer.Deserialize(reader); } } else if (conversionType == ConversionType.DataContractSerializerNoNamespace) { DataContractSerializer serializer = new DataContractSerializer(typeof(T)); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); using (var reader = new NoNamespaceXmltextReader(stream)) { returnObj = (T)serializer.ReadObject(reader); } } else { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { DataContractSerializer serializer = new DataContractSerializer(typeof(T)); XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas()); returnObj = (T)serializer.ReadObject(reader); } } return(returnObj); }
public static string Convert(DocumentPart part, ConversionType type) { string result; if (type == ConversionType.Html) { result = part.ToHtml(); return(result); } if (type == ConversionType.LaTeX) { result = part.ToLaTeX(); return(result); } if (type == ConversionType.PlainText) { result = part.ToPlainText(); return(result); } return(null); }
public static void ConvertFlv(InnerTubeVideo source, ConversionType conversion) { string title = FileHelper.ReplaceIllegalCharacters(source.Title); string author = FileHelper.ReplaceIllegalCharacters(source.Author); string description = FileHelper.ReplaceIllegalCharacters(source.Description); //set values based on switch string cmdLineArgs = String.Empty; string destination = String.Empty; switch (conversion) { case ConversionType.Mp4: //ffmpeg.exe -title "Chocolate Rain" -author "TayZonday" -comment "Original Song by Tay Zonday" -i "Chocolate Rain.flv" "Chocolate Rain.mp4" destination = source.DownloadedMp4; cmdLineArgs = String.Format(" -title \"{0}\" -author \"{1}\" -comment \"{2}\" -i \"{3}\" \"{4}\"", title, author, description, source.DownloadedFlv, destination); break; case ConversionType.Wmv: //ffmpeg.exe -title "Chocolate Rain" -author "TayZonday" -comment "Original Song by Tay Zonday" -i "Chocolate Rain.flv" -vcodec wmv2 "Chocolate Rain.wmv" destination = source.DownloadedWmv; cmdLineArgs = String.Format(" -title \"{0}\" -author \"{1}\" -comment \"{2}\" -i \"{3}\" -vcodec wmv2 \"{4}\"", title, author, description, source.DownloadedFlv, destination); break; } ConvertFlv(source.DownloadedFlv, destination, cmdLineArgs); }
public static ConversionResult Convert(ConversionType type, double value) { ConversionResult result = null; switch (type) { case ConversionType.TOGRAM: result = new ConversionResult { Value = ConvertToGram(value), Unit = "Gr." }; break; case ConversionType.TOOUNCE: result = new ConversionResult { Value = ConvertToOunce(value), Unit = "Oz." }; break; } // whatever you want to log return(result); }
protected override void DrawHeaderAddon() { if (unit.conversion == ConversionType.ToArrayOfObject || unit.conversion == ConversionType.ToListOfObject) { LudiqGUI.Inspector(metadata["conversion"], new Rect(headerAddonPosition.x, headerAddonPosition.y, GetHeaderAddonWidth(), 18), GUIContent.none); } else { LudiqGUI.Inspector(metadata["conversion"], new Rect(headerAddonPosition.x, headerAddonPosition.y, GetHeaderAddonWidth(), 18), GUIContent.none); LudiqGUI.Inspector(metadata["type"], new Rect(headerAddonPosition.x, headerAddonPosition.y + 20, GetHeaderAddonWidth(), 18), GUIContent.none); } if (lastConversionType != unit.conversion) { lastConversionType = unit.conversion; Reposition(); unit.Define(); } if (lastType == null || lastType != unit.type) { lastType = unit.type; unit.Define(); } }
protected override bool UpgradeProject(IProjectStore projectStore, ConversionType initialVersion, ConversionType targetVersion) { ProjectLanguage projectLanguage = ProjectStoreHelper.GetProjectLanguage(projectStore); if (projectLanguage != ProjectLanguage.CSharp && projectLanguage != ProjectLanguage.VisualBasic) { return(false); } if (targetVersion != ConversionType.WebAppProject10) { return(false); } string[] array = projectStore.ProjectImports.ToArray <string>(); for (int i = 0; i < (int)array.Length; i++) { string str = array[i]; if (WebProjectConverter.webApplicationTargetVersion.Match(str).Success&& !projectStore.ChangeImport(str, "$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v10.0\\WebApplications\\Microsoft.WebApplication.targets")) { return(false); } } if (!projectStore.SetStoreVersion(CommonVersions.Version4_0)) { return(false); } return(true); }
public OperatorDeclaration(Modifiers modifier, List <AttributeSection> attributes, List <ParameterDeclarationExpression> parameters, TypeReference typeReference, ConversionType conversionType) : base(null, modifier, typeReference, parameters, attributes) { }
public LeanScreenDepth(ConversionType newConversion, int newLayers = Physics.DefaultRaycastLayers, float newDistance = 0.0f) { Conversion = newConversion; Camera = null; Object = null; Layers = newLayers; Distance = newDistance; }
/// <summary> /// 使用指定的转换类型和要写入的 IL 指令初始化 <see cref="NumericConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> /// <param name="uncheckedOpCodes">要写入的无溢出检查的 IL 指令。</param> /// <param name="checkedOpCodes">要写入的有溢出检查的 IL 指令。</param> private NumericConversion(ConversionType conversionType, OpCode[] uncheckedOpCodes, OpCode[] checkedOpCodes) : base(conversionType) { Contract.Requires(uncheckedOpCodes != null && uncheckedOpCodes.Length >= 0); Contract.Requires(checkedOpCodes != null && checkedOpCodes.Length >= 0); this.uncheckedOpCodes = uncheckedOpCodes; this.checkedOpCodes = checkedOpCodes; }
public COMPU_METHOD(Location location, string Name, string LongIdentifier, ConversionType conversionType, string Format, string Unit) : base(location) { this.Name = Name; this.LongIdentifier = LongIdentifier; this.conversionType = conversionType; this.Format = Format; this.Unit = Unit; }
public SpaceTransform(CoordinateSpace from, CoordinateSpace to, ConversionType type, bool normalize = false, int version = kLatestVersion) { this.from = from; this.to = to; this.type = type; this.normalize = normalize; this.version = version; }
public DatabaseHelper(string path, ConversionType type) { _path = path; DirectoryHelper = new DirectoryHelper(_path, type); FailedMapConversions = new List <int>(); StartConverting(); Console.WriteLine("All maps have been converted!"); }
public ConvertRequest(string from, string to, ConversionType conversionType, float amount) { From = from; To = to; ConversionType = conversionType; Amount = amount; Buy = true; }
static void Convert( string directory, string clientName, List <object[]> users, ConversionType type, string extension = null ) { Log("Converting " + (new DirectoryInfo(directory)).Name, LogType.Information); if (!Directory.Exists(Path.Combine( directory, clientName ))) { Directory.CreateDirectory(Path.Combine( directory, clientName )); } // Run through all users of the client. foreach (object[] user in users) { string source = Path.Combine( directory, ((Guid)user[0]).ToString() + (extension != null ? extension : "") ); string destination = Path.Combine( directory, clientName, ((Guid)user[0]).ToString() + (extension != null ? extension : "") ); switch (type) { case ConversionType.Directory: if (Directory.Exists(source)) { Directory.Move(source, destination); } break; case ConversionType.File: if (File.Exists(source)) { File.Move(source, destination); } break; } } }
public static void Convert(ConversionType type, string path = "") { if (path == "") { path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "osu"); } Directory.CreateDirectory("Maps"); DatabaseHelper dh = new DatabaseHelper(path, type); }
/// <summary> /// Constructor for conversion type operators /// </summary> /// <param name="modifier"></param> /// <param name="List"></param> public OperatorDeclaration(Modifier modifier, List <AttributeSection> attributes, List <ParameterDeclarationExpression> parameters, TypeReference convertToType, ConversionType conversionType ) : base(null, modifier, TypeReference.Null, parameters, attributes) { this.ConversionType = conversionType; this.ConvertToType = convertToType; }
public DirectoryHelper(string osuPath, ConversionType type) { this.osuPath = osuPath; currentFiles = new List <string>(); currentFilesHashPath = new List <string>(); invalidPathCharacters = new char[] { '\"', '<', '>', '|', '*', '?', ':' }; Type = type; }
/// <summary> /// Returns available FileConvertor from ConcurrentBag collection by conversion type (if there is any). /// Otherwise create one and return it. /// </summary> /// <param name="inConversionType"></param> /// <returns></returns> static public FileConverter GetObject(ConversionType inConversionType) { FileConverter fileConverter; if (!GetConverterInstancesByType(inConversionType).TryTake(out fileConverter)) { fileConverter = new FileConverter(inConversionType); } return(fileConverter); }
// method used in order to convert the double into char, into ascii, into string, into a number private static ConversionType ConvertUserInputToConversionType(double userInput) { char asciiChar = (char)userInput; string asciiIntoString = asciiChar.ToString(); int inputNumber = int.Parse(asciiIntoString); ConversionType conversionType = (ConversionType)inputNumber; return(conversionType); }
public string ToString(ConversionType convType) { switch (convType) { case ConversionType.SizeInKb: return(Size.GetValueOrDefault() / 1000 + "Kb"); default: return(Size.GetValueOrDefault() + "bytes"); } }
public object ConvertBack(object value, Type targetType, object parameter, string language) { bool result = value is Visibility && (Visibility)value == Visibility.Visible; ConversionType conversionType = parameter != null ? (ConversionType)parameter : ConversionType.Normal; if (conversionType == ConversionType.Inverted) { result = !result; } return(result); }
public object Convert(object value, Type targetType, object parameter, string language) { Visibility result = (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed; ConversionType conversionType = parameter != null ? (ConversionType)parameter : ConversionType.Normal; if (conversionType == ConversionType.Inverted) { result = result == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible; } return(result); }
static public string Convert(double bytes, ConversionType conversionType, string format) { if (conversionType.ToString().Contains("i")) { return (bytes / Math.Pow(2, (int)conversionType)).ToString(format) + " " + conversionType.ToString(); } else { return (bytes / Math.Pow(1000, (int)conversionType)).ToString(format) + " " + conversionType.ToString(); } }
/// <summary> /// Converts the input image to a desired PixelFormat using /// a specified conversion quality and conversion type. /// </summary> /// <param name="img"> Input image </param> /// <param name="format"> Desired PixelFormat </param> /// <param name="quality"> Conversion quality </param> /// <param name="type"> Conversion type </param> public static Bitmap ConvertToFormat( Bitmap img, PixelFormat format, ConversionQuality quality = ConversionQuality.LowQuality, ConversionType type = ConversionType.Copy) { if (format == img.PixelFormat) return img; var bmp = new Bitmap(img.Width, img.Height, format); using (var g = Graphics.FromImage(bmp)) { SetConversionQuality(g, quality); g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height)); } SetConversionType(ref img, bmp, type); return bmp; }
private bool m_useDefaultMarshal; // Whether we marshal by default or marshal by UnmanagedType #endregion Fields #region Constructors public TypeConverter(ConverterInfo info, TypeInfo type, TypeDesc desc, ConversionType conversionType) { m_info = info; m_typeInfo = type; m_typeDesc = desc; m_conversionType = conversionType; m_paramDesc = null; m_attribute = null; m_conversionLoss = false; m_convertedType = null; m_nativeIndirections = 0; m_convertingNewEnumMember = false; ResetUnmanagedType(); // Do the conversion _Convert(); }
// The program executing with ENUMS private void allConversions(float temperature, ConversionType conversionType) { openTurn = false; if (conversionType == ConversionType.Fahrenheit) { // throw new NotImplementedException(); fahrenheit.Temperature = temperature; celsiusTextBox.Text = fahrenheit.Celsius().ToString(); kelvinTextBox.Text = fahrenheit.Kelvin().ToString(); } if (conversionType == ConversionType.Celsius) { celsius.Temperature = temperature; fahrenheitTextBox.Text = celsius.Fahrenheit().ToString(); kelvinTextBox.Text = celsius.Kelvin().ToString(); } if (conversionType == ConversionType.Kelvin) { kelvin.Temperature = temperature; fahrenheitTextBox.Text = kelvin.Fahrenheit().ToString(); celsiusTextBox.Text = kelvin.Celsius().ToString(); } openTurn = true; }
public frmFileConversion(ConversionType conversionType) { this.InitializeComponent(); IniHelper helper = new IniHelper(this.fileConversionIniPath); string str = string.Empty; this._conversionType = conversionType; switch (conversionType) { case ConversionType.GP2ToGPS: this._fileType = ".gpx"; break; case ConversionType.BinToGPS_GP2: this._fileType = ".bin"; break; case ConversionType.GPSToNMEA: case ConversionType.GPSToKML: this._fileType = ".gps"; break; case ConversionType.NMEAToGPS: this._fileType = ".nmea"; break; default: this._fileType = ".gpx"; break; } try { if (File.Exists(this.fileConversionIniPath)) { foreach (string str2 in helper.GetKeys("EMAIL")) { if (!str2.Contains("#")) { str = helper.GetIniFileString("EMAIL", str2, ""); if (str.Length != 0) { str = str.Replace(" ", "").TrimEnd(new char[] { '\n' }).TrimEnd(new char[] { '\r' }); ConfigurationManager.AppSettings[str2] = str; } } } str = helper.GetIniFileString("SETUP", "AVAILABLE_SCRIPTS", ""); if (str.Length != 0) { this.filesFullPathLists.Clear(); foreach (string str3 in str.Split(new char[] { ',' })) { if (str3.Length != 0) { this.addAvailableFiles(str3); } } } this.filesArray = this.filesFullPathLists.ToArray(); this.autoTestDirVal.Text = helper.GetIniFileString("SETUP", "SCRIPTS_DIR", ""); str = helper.GetIniFileString("SETUP", "SEND_EMAIL", ""); } } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR!"); } }
/// <summary> /// Get converter instances by conversion type. /// </summary> /// <param name="inConversionType"></param> /// <returns></returns> private static ConcurrentBag<FileConverter> GetConverterInstancesByType(ConversionType inConversionType) { switch (inConversionType) { case ConversionType.PDF2PNG: return m_PDF2PNGConverterInstances; case ConversionType.PDF2PNGSingle: return m_PDF2PNGSingleConverterInstances; case ConversionType.PDF2JPG: return m_PDF2JPGConverterInstances; case ConversionType.PDF2EPS: return m_PDF2EPSConverterInstances; case ConversionType.EPS2PDF: return m_EPS2PDFConverterInstances; case ConversionType.PDF2LowResPDF: return m_PDF2LowResPDFConverterInstances; case ConversionType.JPG2LowResJPG: return m_EJPG2LowResJPGConverterInstances; default: return null; } }
/// <summary> /// Creates a copy of the input image using a specified conversion type. /// </summary> /// <param name="img"> Input image </param> /// <param name="type"> Conversion type </param> public static Bitmap Copy(Bitmap img, ConversionType type = ConversionType.Copy) { var bmp = new Bitmap(img.Width, img.Height, img.PixelFormat); using (var g = Graphics.FromImage(bmp)) { SetConversionQuality(g, ConversionQuality.LowQuality); g.DrawImageUnscaled(img, new Rectangle(0, 0, img.Width, img.Height)); } SetConversionType(ref img, bmp, type); return bmp; }
/// <summary> /// Applies a resize operation to the input image with the desired size using /// a specified conversion quality and conversion type. /// </summary> /// <param name="img"> Input image </param> /// <param name="size"> Output size </param> /// <param name="rType"> Resizing operation </param> /// <param name="quality"> Conversion quality </param> /// <param name="type"> Conversion type </param> public static Bitmap Resize( Bitmap img, Size size, ResizeType rType = ResizeType.Scaling, ConversionQuality quality = ConversionQuality.LowQuality, ConversionType type = ConversionType.Copy) { if (img.Size == size) return img; var scaled = new Bitmap(size.Width, size.Height, img.PixelFormat); using (var g = Graphics.FromImage(scaled)) { SetConversionQuality(g, quality); switch (rType) { case ResizeType.Scaling: g.DrawImage(img, new Rectangle(0, 0, size.Width, size.Height)); break; case ResizeType.Crop: g.DrawImageUnscaledAndClipped(img, new Rectangle(0, 0, size.Width, size.Height)); break; } } SetConversionType(ref img, scaled, type); return scaled; }
private static void SetConversionType( ref Bitmap original, Bitmap result, ConversionType type) { switch (type) { case ConversionType.Copy: break; case ConversionType.Overwrite: original.Dispose(); original = result; break; } }
public OperatorDeclaration(Modifiers modifier, List<AttributeSection> attributes, List<ParameterDeclarationExpression> parameters, TypeReference typeReference, ConversionType conversionType) : base(null, modifier, typeReference, parameters, attributes) {}
private void CreateFileConversionWindow(ConversionType type) { switch (type) { case ConversionType.GP2ToGPS: gP2GPSToolStripMenuItem.Enabled = true; binGPSToolStripMenuItem.Enabled = false; gPSNMEAToolStripMenuItem.Enabled = false; NMEAtoGPStoolStripMenuItem.Enabled = false; gPSToKMLToolStripMenuItem.Enabled = false; break; case ConversionType.BinToGPS_GP2: gP2GPSToolStripMenuItem.Enabled = false; binGPSToolStripMenuItem.Enabled = true; gPSNMEAToolStripMenuItem.Enabled = false; NMEAtoGPStoolStripMenuItem.Enabled = false; gPSToKMLToolStripMenuItem.Enabled = false; break; case ConversionType.GPSToNMEA: gP2GPSToolStripMenuItem.Enabled = false; binGPSToolStripMenuItem.Enabled = false; gPSNMEAToolStripMenuItem.Enabled = true; NMEAtoGPStoolStripMenuItem.Enabled = false; gPSToKMLToolStripMenuItem.Enabled = false; break; case ConversionType.GPSToKML: gP2GPSToolStripMenuItem.Enabled = false; binGPSToolStripMenuItem.Enabled = false; gPSNMEAToolStripMenuItem.Enabled = false; NMEAtoGPStoolStripMenuItem.Enabled = false; gPSToKMLToolStripMenuItem.Enabled = true; break; case ConversionType.NMEAToGPS: gP2GPSToolStripMenuItem.Enabled = false; binGPSToolStripMenuItem.Enabled = false; gPSNMEAToolStripMenuItem.Enabled = false; NMEAtoGPStoolStripMenuItem.Enabled = true; gPSToKMLToolStripMenuItem.Enabled = false; break; default: gP2GPSToolStripMenuItem.Enabled = true; binGPSToolStripMenuItem.Enabled = true; gPSNMEAToolStripMenuItem.Enabled = true; NMEAtoGPStoolStripMenuItem.Enabled = true; gPSToKMLToolStripMenuItem.Enabled = true; break; } frmFileConversion childInstance = null; childInstance = frmFileConversion.GetChildInstance(type); if (childInstance.IsDisposed) { childInstance = new frmFileConversion(type); } childInstance.BringToFront(); childInstance.updateParent += new frmFileConversion.updateParentEventHandler(updateFileCovAvail); childInstance.MdiParent = this; childInstance.Show(); }
/// <summary> /// 使用指定的转换类型初始化 <see cref="BetweenNullableConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> private BetweenNullableConversion(ConversionType conversionType) : base(conversionType) { }
/// <summary> /// 使用指定的转换类型和要写入的 IL 指令初始化 <see cref="NumericConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> /// <param name="opCodes">要写入的 IL 指令。</param> private NumericConversion(ConversionType conversionType, params OpCode[] opCodes) : base(conversionType) { Contract.Requires(opCodes != null && opCodes.Length >= 1); this.uncheckedOpCodes = this.checkedOpCodes = opCodes; }
/// <summary> /// Provede převod z metrů na pixely nebo z pixelů na metry podle daného rozlišení světa /// </summary> /// <param name="Input">Vstupní číslo</param> /// <param name="Type">Typ převodu</param> /// <returns>Převedené číslo</returns> public double Convert(double Input, ConversionType Type) { if (Type == ConversionType.MetersToPixels) return Input * r; else return Input / r; }
static private ConversionType MoveDirection(ConversionType conversion, DirectionType direction) { int mult = 1; if (direction == DirectionType.Down) mult = -1; try { ConversionType newConversion = conversion; if (conversion.ToString().Contains("i")) newConversion = (ConversionType)((int)conversion + (mult * 10)); else newConversion = (ConversionType)((int)conversion + mult); return newConversion; } catch { return conversion; } }
/// <summary> /// Provede převod vektoru z metrů na pixely nebo z pixelů na metry podle daného rozlišení světa /// </summary> /// <param name="Input">Vstupní číslo</param> /// <param name="Type">Typ převodu</param> /// <returns>Převedené číslo</returns> public Vector Convert(Vector Input, ConversionType Type) { if (Type == ConversionType.MetersToPixels) return Input * r; else return Input / r; }
/// <summary> /// Spočítá všechny typy energií pro dané těleso /// </summary> /// <param name="Object">Těleso</param> /// <param name="Units">Jednotky</param> /// <returns>Energie</returns> public ObjectEnergy GetObjectEnergy(SimObject Object,ConversionType Units = ConversionType.MetersToPixels) { if (Object == null) throw new ArgumentNullException(); ObjectEnergy Ret = new ObjectEnergy(); if (Units == ConversionType.MetersToPixels) { Ret.Kinetic = 0.5 * Object.Mass * Vector.Pow(Object.LinearVelocity, 2); Ret.Potential = Object.Mass * Vector.PointDistance(new Vector(Object.COG[0], Level[1], 0), Object.COG) * Gravity.Magnitude; } else { Ret.Kinetic = 0.5 * Object.Mass * Vector.Pow(Convert(Object.LinearVelocity,ConversionType.PixelsToMeters), 2); Ret.Potential = Object.Mass * Convert(Vector.PointDistance(new Vector(Object.COG[0], Level[1], 0), Object.COG),ConversionType.PixelsToMeters) * Convert(Gravity,ConversionType.PixelsToMeters).Magnitude; } Ret.Rotational = 0.5 * Object.Mass * Object.MomentOfInertia * Vector.Pow(Object.AngularVelocity, 2); return Ret; }
/// <summary> /// 使用指定的转换类型初始化 <see cref="IdentityConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> private IdentityConversion(ConversionType conversionType) : base(conversionType) { }
public static frmFileConversion GetChildInstance(ConversionType fileType) { if (m_SChildform == null) { m_SChildform = new frmFileConversion(fileType); } return m_SChildform; }
/// <summary> /// Return used FileConvertor to ConcurrentBag collection by conversion type. /// </summary> /// <param name="inConversionType"></param> /// <param name="inFileConvertor"></param> public static void PutObject(ConversionType inConversionType, FileConverter inFileConvertor) { GetConverterInstancesByType(inConversionType).Add(inFileConvertor); }
/// <summary> /// 使用指定的转换类型初始化 <see cref="DecimalConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> private DecimalConversion(ConversionType conversionType) : base(conversionType) { }
/// <summary> /// 使用指定的转换类型初始化 <see cref="Conversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> internal Conversion(ConversionType conversionType) { this.ConversionType = conversionType; }
static public string Convert(double bytes, ConversionType conversionType) { return Convert(bytes, conversionType, "0.00"); }
/// <summary> /// 使用指定的转换类型初始化 <see cref="FromNullableConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> private FromNullableConversion(ConversionType conversionType) : base(conversionType) { }
/// <summary> /// 将栈顶的对象从 <paramref name="inputType"/> 转换为 <paramref name="outputType"/>。 /// </summary> /// <param name="il">IL 指令生成器。</param> /// <param name="inputType">要转换的对象的类型。</param> /// <param name="outputType">要将输入对象转换到的类型。</param> /// <param name="isChecked">是否执行溢出检查。</param> /// <param name="conversionType">类型转换类型的限制。</param> internal static void EmitConversion(this ILGenerator il, Type inputType, Type outputType, bool isChecked, ConversionType conversionType) { Contract.Requires(il != null && inputType != null && outputType != null); Contract.Requires(conversionType == ConversionType.Implicit || conversionType == ConversionType.Explicit || conversionType == ConversionType.UserDefined); Conversion conversion = conversionType == ConversionType.UserDefined ? ConversionFactory.GetConversion(inputType, outputType) : ConversionFactory.GetPreDefinedConversion(inputType, outputType); if (conversion == null || conversion.ConversionType > conversionType) { throw CommonExceptions.InvalidCast(inputType, outputType); } if (conversion is FromNullableConversion) { il.EmitGetAddress(inputType); } conversion.Emit(il, inputType, outputType, isChecked); }
/// <summary> /// 使用指定的转换类型和要复制 IL 指令的数值类型转换初始化 <see cref="NumericConversion"/> 类的新实例。 /// </summary> /// <param name="conversionType">当前转换的类型。</param> /// <param name="conversion">要复制的数值类型转换。</param> public NumericConversion(ConversionType conversionType, NumericConversion conversion) : base(conversionType) { Contract.Requires(conversion != null); this.uncheckedOpCodes = conversion.uncheckedOpCodes; this.checkedOpCodes = conversion.checkedOpCodes; }
/// <summary> /// 获取转换类型的指令生成器,能够将栈顶的对象从 <paramref name="inputType"/> 转换为 /// <paramref name="outputType"/>。 /// </summary> /// <param name="il">IL 指令生成器。</param> /// <param name="inputType">要转换的对象的类型。</param> /// <param name="outputType">要将输入对象转换到的类型。</param> /// <param name="conversionType">类型转换类型的限制。</param> /// <returns>类型转换的指令生成器,如果不能进行类型转换则返回 <c>null</c>。</returns> internal static Converter GetConversion(this ILGenerator il, Type inputType, Type outputType, ConversionType conversionType) { Contract.Requires(il != null && inputType != null && outputType != null); Contract.Requires(conversionType == ConversionType.Implicit || conversionType == ConversionType.Explicit || conversionType == ConversionType.UserDefined); Conversion conversion = conversionType == ConversionType.UserDefined ? ConversionFactory.GetConversion(inputType, outputType) : ConversionFactory.GetPreDefinedConversion(inputType, outputType); if (conversion == null || conversion.ConversionType > conversionType) { return null; } return new Converter(conversion, il, inputType, outputType); }
static string[] FilterOptions(string[] args) { List<string> argsWithoutOptions = new List<string>(); for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("-")) { switch (args[i].ToLowerInvariant()) { case "-nocdinfo": ignoreCdinfo = true; break; case "-wave": conversion = ConversionType.Wave; break; case "-ogg": conversion = ConversionType.Ogg; break; case "-flac": conversion = ConversionType.Flac; break; case "-overwrite": overwriteFolder = true; break; default: Console.Error.WriteLine("Invalid option: " + args[i]); break; } } else { argsWithoutOptions.Add(args[i]); } } return argsWithoutOptions.ToArray(); }
/// <summary> /// Returns available FileConvertor from ConcurrentBag collection by conversion type (if there is any). /// Otherwise create one and return it. /// </summary> /// <param name="inConversionType"></param> /// <returns></returns> public static FileConverter GetObject(ConversionType inConversionType) { FileConverter fileConverter; if (!GetConverterInstancesByType(inConversionType).TryTake(out fileConverter)) fileConverter = new FileConverter(inConversionType); return fileConverter; }