Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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; }
 }
Ejemplo n.º 3
0
 public string GetFormattedTotal()
 {
     if (_sizeLevel == SizeLevel.None)
     {
         _sizeLevel = SizeUtils.GetProperSizeLevel(DiskTotalSize - DiskFreeSize);
     }
     return($"Total: {SizeUtils.GetPrettySize(DiskTotalSize, _sizeLevel)}");
 }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        private static ListViewItem CreateListViewItem(string path)
        {
            var di = new DirectoryInfo(path);

            return(new ListViewItem(di.Name)
            {
                SubItems =
                {
                    SizeUtils.DirectorySize(di).ToFileSize()
                },
                Tag = path
            });
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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));
            }
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
0
    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);
    }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
 public static OrientedSize AsOriented(this Size size, Orientation orientation)
 {
     return(SizeUtils.AsOriented(size, orientation));
 }
Ejemplo n.º 12
0
 public static Size Truncate(this Size size)
 {
     return(SizeUtils.Truncate(size));
 }
Ejemplo n.º 13
0
 internal static Size Round(this Size size, RoundingMode roundingMode, int digits = 0)
 {
     return(SizeUtils.Round(size, roundingMode, digits));
 }
Ejemplo n.º 14
0
 public static Size Ceiling(this Size size)
 {
     return(SizeUtils.Ceiling(size));
 }
Ejemplo n.º 15
0
 public static OrientedSize ExpandTo(this OrientedSize size, OrientedSize value)
 {
     return(SizeUtils.ExpandTo(size, value));
 }
Ejemplo n.º 16
0
 public static Size Round(this Size size, int digits = 0)
 {
     return(SizeUtils.Round(size, digits));
 }
Ejemplo n.º 17
0
 public static bool IsCloseTo(this Size a, Size b)
 {
     return(SizeUtils.AreClose(a, b));
 }
Ejemplo n.º 18
0
        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());
        }
Ejemplo n.º 19
0
 public static double HalfIndirect(this OrientedSize orientedSize)
 {
     return(SizeUtils.HalfIndirect(orientedSize));
 }
Ejemplo n.º 20
0
 public static double HalfWidth(this Size size)
 {
     return(SizeUtils.HalfWidth(size));
 }
Ejemplo n.º 21
0
 public static Size Clamp(this Size value, Size min, Size max)
 {
     return(SizeUtils.Clamp(value, min, max));
 }
Ejemplo n.º 22
0
 public static double GetIndirect(this Size size, Orientation orientation)
 {
     return(SizeUtils.GetIndirect(size, orientation));
 }
Ejemplo n.º 23
0
 public static Size Floor(this Size size)
 {
     return(SizeUtils.Floor(size));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// get formatted size
 /// </summary>
 /// <returns></returns>
 public string GetFormatSize()
 {
     CheckSize();
     return(SizeUtils.GetPrettySize(Length));
 }
Ejemplo n.º 25
0
 internal static Size LayoutRound(this Size size, RoundingMode roundingMode)
 {
     return(SizeUtils.LayoutRound(size, roundingMode));
 }
Ejemplo n.º 26
0
    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);
    }
Ejemplo n.º 27
0
 public static Rect Rect(this Size size)
 {
     return(SizeUtils.Rect(size));
 }
Ejemplo n.º 28
0
 public static double HalfHeight(this Size size)
 {
     return(SizeUtils.HalfHeight(size));
 }
Ejemplo n.º 29
0
 public static Size ExpandTo(this Size size, Size value)
 {
     return(SizeUtils.ExpandTo(size, value));
 }