protected override object ConvertCore(object value, Type targetType, object parameter, CultureInfo culture) { var roundingMode = RoundingMode.MidPointFromZero; if (value is double) { var dblValue = (double)value; return(DoubleUtils.Round(dblValue, Digits, roundingMode)); } if (value is Point) { var ptValue = (Point)value; return(PointUtils.Round(ptValue, roundingMode, Digits)); } if (value is Size) { var szValue = (Size)value; return(SizeUtils.Round(szValue, roundingMode, Digits)); } if (value is Rect) { var rcValue = (Rect)value; return(RectUtils.Round(rcValue, roundingMode, Digits)); } return(value); }
public static void LogSizeEvent(string name, long size) { try { string scale = SizeUtils.GetSizeScale(size); Cat.GetProducer().LogEvent(name, scale, CatConstants.SUCCESS, "size=" + size); } catch (Exception ex) { Cat.lastException = ex; } }
public string GetFormattedTotal() { if (_sizeLevel == SizeLevel.None) { _sizeLevel = SizeUtils.GetProperSizeLevel(DiskTotalSize - DiskFreeSize); } return($"Total: {SizeUtils.GetPrettySize(DiskTotalSize, _sizeLevel)}"); }
public void CanFillRectangleWithRectangles_ShouldBeFalse_WhenCanNotFill( int mainWidth, int mainHeight, int innerWidth, int innerHeight, int count) { var mainSize = new Size(mainWidth, mainHeight); var innerSize = new Size(innerWidth, innerHeight); var result = SizeUtils.CanFillSizeWithSizes(mainSize, innerSize, count); result.Should().BeFalse(); }
private static ListViewItem CreateListViewItem(string path) { var di = new DirectoryInfo(path); return(new ListViewItem(di.Name) { SubItems = { SizeUtils.DirectorySize(di).ToFileSize() }, Tag = path }); }
public void GetSizedWords_ShouldReturnScaledSize_OnBigPictureSize() { var expectedSizes = new List <Size> { SizeUtils.GetWordBasedSize(word1.Value, pictureConfig.FontFamily, word1MinFontSize * 14), SizeUtils.GetWordBasedSize(word2.Value, pictureConfig.FontFamily, word2MinFontSize * 14), SizeUtils.GetWordBasedSize(word3.Value, pictureConfig.FontFamily, word3MinFontSize * 14) }; pictureConfig.Size = new Size(200, 100); var result = wordSizeSetter.GetSizedWords(words, pictureConfig); result.Select(w => w.WordRectangleSize).Should().BeEquivalentTo(expectedSizes); }
public IEnumerable <Word> GetSizedWords(IEnumerable <Word> words, PictureConfig pictureConfig) { var wordsList = words.ToList(); var maxWord = wordsList.OrderByDescending(w => w.Count).First(); var maxWordFontSize = GetMaxWordFontSize(maxWord, wordsList.Count, pictureConfig); var fontSizeCoefficient = Math.Max(wordsList.Count / wordsCountCorrectionCoefficient, 1) * maxWordFontSize / maxWord.Count; foreach (var word in wordsList) { var fontSize = word.Count * fontSizeCoefficient; var size = SizeUtils.GetWordBasedSize(word.Value, pictureConfig.FontFamily, fontSize); yield return(word.SetSize(size).SetFontSize(fontSize)); } }
public PdfGenerator(View view, PageOrientation orientation, PageSize pageSize, bool resizeToFit) { _pageSize = pageSize; _orientation = orientation; _rootView = view; _desiredPageSize = SizeUtils.GetAvailablePageSize(pageSize, orientation); if (resizeToFit) { _scaleFactor = _desiredPageSize.Width / view.Bounds.Width; } else { _scaleFactor = 1; } }
public override void OnSpellEffect(SpellPacketBody spell) { Logger.Info("Righteous Might OnSpellEffect"); spell.duration = 1 * spell.casterLevel; var target_item = spell.Targets[0]; // size mod // print "Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) SizeUtils.IncSizeCategory(target_item.Object); // save target_list Co8PersistentData.AddToSpellActiveList(RM_KEY, spell.spellId, target_item.Object); // print "new Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "new Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) target_item.Object.AddCondition("sp-Righteous Might", spell.spellId, spell.duration, 0); target_item.ParticleSystem = AttachParticles("sp-Righteous Might", target_item.Object); }
private float GetMaxWordFontSize(Word mostFrequentWord, int wordsCount, PictureConfig pictureConfig) { var currentSize = SizeUtils.GetWordBasedSize( mostFrequentWord.Value, pictureConfig.FontFamily, minFontSize); if (!SizeUtils.CanFillSizeWithSizes( pictureConfig.Size, currentSize, wordsCount)) { throw new ArgumentException( $"Picture size {pictureConfig.Size.Width}x{pictureConfig.Size.Height} is too small for this word set"); } var currentFontSize = minFontSize; while (SizeUtils.CanFillSizeWithSizes(pictureConfig.Size, currentSize, wordsCount) && 2 * currentSize.Width < pictureConfig.Size.Width) { currentFontSize++; currentSize = SizeUtils.GetWordBasedSize(mostFrequentWord.Value, pictureConfig.FontFamily, currentFontSize); } return(currentFontSize - 1); }
public static OrientedSize AsOriented(this Size size, Orientation orientation) { return(SizeUtils.AsOriented(size, orientation)); }
public static Size Truncate(this Size size) { return(SizeUtils.Truncate(size)); }
internal static Size Round(this Size size, RoundingMode roundingMode, int digits = 0) { return(SizeUtils.Round(size, roundingMode, digits)); }
public static Size Ceiling(this Size size) { return(SizeUtils.Ceiling(size)); }
public static OrientedSize ExpandTo(this OrientedSize size, OrientedSize value) { return(SizeUtils.ExpandTo(size, value)); }
public static Size Round(this Size size, int digits = 0) { return(SizeUtils.Round(size, digits)); }
public static bool IsCloseTo(this Size a, Size b) { return(SizeUtils.AreClose(a, b)); }
public override string ToString() { //ffmpeg -i test.mp4 -f image2 -ss 00:00:14.435 -s 960*550 -vframes 1 out.jpg //ffmpeg -i test.mp4 -ss 00:00:14.435 -s 960*550 -f image2 -vframes 1 out.jpg //ffmpeg -i input.flv -f image2 -vf fps=fps=1 out%d.png var builder = new StringBuilder(); builder.Append(" -i "); builder.Append(Source.FilePath); builder.Append(" -f image2"); if (ResizeType == ResizeType.Scale) { var sourceSize = new Size(Source.VideoInfo.Width, Source.VideoInfo.Height); var resultSize = SizeUtils.CalculateOutSize(sourceSize, Width, Height); builder.AppendFormat(" -s {0}x{1}", resultSize.Width, resultSize.Height); } else { builder.AppendFormat(" -s {0}x{1}", Width, Height); } var dir = Path.GetDirectoryName(OutputPath); if (string.IsNullOrEmpty(dir)) { throw new ApplicationException("snapshot outpath directory is null."); } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var filename = Path.GetFileNameWithoutExtension(OutputPath); if (string.IsNullOrEmpty(filename)) { throw new ApplicationException("snapshot outpath filename is null."); } var ext = Path.GetExtension(OutputPath); if (string.IsNullOrEmpty(ext)) { ext = ".jpg"; } if (null != Time) { builder.AppendFormat(" -ss {0} -vframes 1", Time.Value); builder.Append(" "); builder.Append(OutputPath); } if (null != Number) { var duration = Source.VideoInfo.Duration; var num = duration.TotalSeconds / (Number.Value - 1); builder.AppendFormat(" -vf fps=fps=1/{0} {1}\\{2}%d{3}", Math.Floor(num), dir, filename, ext); } return(builder.ToString()); }
public static double HalfIndirect(this OrientedSize orientedSize) { return(SizeUtils.HalfIndirect(orientedSize)); }
public static double HalfWidth(this Size size) { return(SizeUtils.HalfWidth(size)); }
public static Size Clamp(this Size value, Size min, Size max) { return(SizeUtils.Clamp(value, min, max)); }
public static double GetIndirect(this Size size, Orientation orientation) { return(SizeUtils.GetIndirect(size, orientation)); }
public static Size Floor(this Size size) { return(SizeUtils.Floor(size)); }
/// <summary> /// get formatted size /// </summary> /// <returns></returns> public string GetFormatSize() { CheckSize(); return(SizeUtils.GetPrettySize(Length)); }
internal static Size LayoutRound(this Size size, RoundingMode roundingMode) { return(SizeUtils.LayoutRound(size, roundingMode)); }
public override void OnSpellEffect(SpellPacketBody spell) { Logger.Info("Enlarge OnSpellEffect"); // print "spell.id=", spell.id // print "spell.target_list=", spell.target_list spell.duration = 10 * spell.casterLevel; var target_item = spell.Targets[0]; // HTN - 3.5, enlarge PERSON only if ((target_item.Object.IsMonsterCategory(MonsterCategory.humanoid))) { if (target_item.Object.IsFriendly(spell.caster)) { var return_val = target_item.Object.AddCondition("sp-Enlarge", spell.spellId, spell.duration, 0); // print "condition_add_with_args return_val: " + str(return_val) + "\n" if (return_val) { // size mod // print "Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) SizeUtils.IncSizeCategory(target_item.Object); // print "performed size Increase\n" // save target_list // print "new Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "new Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) target_item.ParticleSystem = AttachParticles("sp-Enlarge", target_item.Object); } } else { if (!target_item.Object.SavingThrowSpell(spell.dc, SavingThrowType.Fortitude, D20SavingThrowFlag.NONE, spell.caster, spell.spellId)) { // saving throw unsuccesful target_item.Object.FloatMesFileLine("mes/spell.mes", 30002); var return_val = target_item.Object.AddCondition("sp-Enlarge", spell.spellId, spell.duration, 0); // enemies seem to work fine? // print "Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) // size.incSizeCategory(target_item.obj) // print "new Size:" + str(target_item.obj.obj_get_int(obj_f_size)) // print "new Reach:" + str(target_item.obj.obj_get_int(obj_f_critter_reach)) if (return_val) { target_item.ParticleSystem = AttachParticles("sp-Enlarge", target_item.Object); } else { // saving throw successful target_item.Object.FloatMesFileLine("mes/spell.mes", 30001); AttachParticles("Fizzle", target_item.Object); } } } } // spell.target_list.remove_target( target_item.obj ) Logger.Info("spell.target_list={0}", spell.Targets); }
public static Rect Rect(this Size size) { return(SizeUtils.Rect(size)); }
public static double HalfHeight(this Size size) { return(SizeUtils.HalfHeight(size)); }
public static Size ExpandTo(this Size size, Size value) { return(SizeUtils.ExpandTo(size, value)); }