private void UpdateMyControls() { bool enableOkButton = true; string warningMessage = string.Empty; // For YVU9, the image must have a width and height that is a multiple of 4 // For YUY2 and UYVY, the width and height that is a multiple of 2 ConvertItem item = (ConvertItem)_cbColorFormat.SelectedItem; if (item.Format == ConversionColorFormat.Yvu9) { if ((_width % 4) != 0 || (_height % 4) != 0) { enableOkButton = false; warningMessage = string.Format("For YVU9 color format, the image must have a width and height value that is a multiple of 4.{0}Current image has a width of {1} and height of {2} pixels.", Environment.NewLine, _width, _height); } } else if (item.Format == ConversionColorFormat.Yuy2 || item.Format == ConversionColorFormat.Uyvy) { if ((_width % 2) != 0 || (_height % 2) != 0) { enableOkButton = false; warningMessage = string.Format("For YUY2 and UYVY color format, the image must have a width and height value that is a multiple of 2.{0}Current image has a width of {1} and height of {2} pixels.", Environment.NewLine, _width, _height); } } _btnOK.Enabled = enableOkButton; _lblWarning.Text = warningMessage; }
private static void UpdateConverter(Type sourceType, Type targetType, ConvertItem convertItem) { ConcurrentDictionary <Type, ConvertItem> dic = s_map.GetOrAdd(sourceType, new ConcurrentDictionary <Type, ConvertItem>()); convertItem.Order = dic.Count; dic.AddOrUpdate(targetType, convertItem, (k, v) => convertItem); }
private void _cbColorFormat_SelectedIndexChanged(object sender, System.EventArgs e) { ConvertItem item = (ConvertItem)_cbColorFormat.SelectedItem; UpdateMyControls(); ConvertToColorSpace(item.Format); }
private static void AddConverter(Type sourceType, Type targetType, ConvertItem convertItem) { ConcurrentDictionary <Type, ConvertItem> dic = s_map.GetOrAdd(sourceType, new ConcurrentDictionary <Type, ConvertItem>()); convertItem.Order = dic.Count; dic.TryAdd(targetType, convertItem); }
internal static void Convert(this ILGenerator il, ConvertItem convertItem) { if (convertItem == null) { throw new ArgumentNullException(nameof(convertItem)); } if (convertItem.OpCode.HasValue) { il.Emit(convertItem.OpCode.Value); } else { convertItem.Action(il); } }
public static bool SearchConvertItem(Type source, Type target, out ConvertItem convertItem) { if (source.IsEnum) { source = GetEmumType(source); } if (target.IsEnum) { target = GetEmumType(target); } convertItem = default; if (s_map.TryGetValue(source, out ConcurrentDictionary <Type, ConvertItem> dic)) { return(dic.TryGetValue(target, out convertItem)); } return(false); }
public bool GetProcessConvertRule(ref JObject JConvert, ConvertCategory category, int iIndex, ConvertItem key, ref string valReturn) { bool bProcess = false; try { valReturn = JConvert[category.ToString()][iIndex][key.ToString()].ToString(); bProcess = true; } catch (Exception ex) { } return(bProcess); }
public bool GetProcessConvertRuleValidService(ref JObject JConvert, ConvertCategory category, int iIndex, ConvertItem key, string filePath) { bool bProcess = false; string valReturn = string.Empty; string[] validKey = null; try { valReturn = JConvert[category.ToString()][iIndex][key.ToString()].ToString(); validKey = valReturn.Split(':'); foreach (string curtVal in validKey) { if (filePath.Contains(curtVal) == true) { bProcess = true; break; } } bProcess = false; } catch (Exception ex) { bProcess = true; } return(bProcess); }
public bool GetProcessValidService(ref JObject JConvert, ConvertCategory category, int iIndex, ConvertItem key, string[] fileKey, int iCheckStart, string fileName) { bool bProcess = false; string valReturn = string.Empty; try { // service="ALL" valReturn = JConvert[category.ToString()][iIndex][key.ToString()].ToString().ToLower(); bool bCheckALLPattern = false; string sFirstChar = ""; string[] invloveService = valReturn.Split('|'); for (int j = 0; j <= invloveService.Length - 1; j++) { if (invloveService[j].ToLower().Substring(0, 1) == "!") { bCheckALLPattern = true; break; } } for (int i = iCheckStart + 1; i <= fileKey.Length - 1; i++) { for (int j = 0; j <= invloveService.Length - 1; j++) { sFirstChar = invloveService[j].ToLower().Substring(0, 1); // Take most priority if (sFirstChar == "!") { bProcess = CheckIsPatternfile(fileKey, invloveService[j].ToLower()); if (bProcess == true) { bProcess = false; return(bProcess); } } if (sFirstChar == "*") { bProcess = CheckIsPatternfile(fileKey, invloveService[j].ToLower()); if (bCheckALLPattern == false) { return(bProcess); } } if (invloveService[j].ToLower() == "all") { bProcess = true; if (bCheckALLPattern == false) { return(bProcess); } } if (fileKey[i].ToLower() == invloveService[j].ToLower()) { bProcess = true; if (bCheckALLPattern == false) { return(bProcess); } } //for check the files in the include directory. if (invloveService[j].Length < fileName.Length && invloveService[j].ToLower() == fileName.Substring(0, invloveService[j].Length)) { bProcess = true; if (bCheckALLPattern == false) { return(bProcess); } } } } } catch (Exception ex) { } return(bProcess); }