Exemplo n.º 1
0
 private void CreateSmallFont()
 {
     FontExtensions.Clean(_smallFont);
     _smallFont       = new Font(FontName, FontSize - 1, FontStyle.Regular);
     _smallCharWidth  = _smallFont.Width();
     _smallCharHeight = _smallFont.Height();
 }
Exemplo n.º 2
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                var progress = FloatValue;

                if (float.IsNaN((float)progress))
                {
                    return;
                }

                base.DrawWithFrame(cellFrame, inView);

                string progressText = (int)(progress * 100f) + "%";
                var    str          = new NSMutableAttributedString(progressText, NSDictionary.FromObjectAndKey(ForegroundColor.ToNSUI(), NSAttributedString.ForegroundColorAttributeName));
                var    range        = new NSRange(0, str.Length);

                if (Font != null)
                {
                    str.AddAttributes(NSDictionary.FromObjectAndKey(Font, NSAttributedString.FontAttributeName), range);
                }
                var size = FontExtensions.MeasureString(str, cellFrame.Size.ToEto());
                var rect = cellFrame.ToEto();

                rect.Offset((rect.Size - size) / 2);

                str.DrawString(rect.ToNS());
            }
Exemplo n.º 3
0
 private void CreateFont()
 {
     FontExtensions.Clean(_font);
     _font       = new Font(FontName, FontSize, FontStyle.Regular);
     _charWidth  = _font.Width();
     _charHeight = _font.Height();
 }
Exemplo n.º 4
0
        public SizeF MeasureString(Font font, string text)
        {
            StartDrawing();
            var size = FontExtensions.MeasureString(text, font);

            EndDrawing();
            return(size);
        }
 private void UpdateFont()
 {
     if (this.Control == null || this.Element == null || this.Element.Font == XF.Font.Default && !this.fontApplied)
     {
         return;
     }
     FontExtensions.ApplyFont(this.Control, this.Element.Font == XF.Font.Default ? XF.Font.SystemFontOfSize(XF.NamedSize.Medium) : this.Element.Font);
     this.fontApplied = true;
 }
Exemplo n.º 6
0
        public void DrawText(Font font, SolidBrush brush, float x, float y, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            StartDrawing();
            FontExtensions.DrawString(text, new PointF(x, y), brush.Color, font);
            EndDrawing();
        }
Exemplo n.º 7
0
        public void DrawingTestLogicalFontConversion()
        {
            // Create a test font
            var font1 = new LogicalFont("Verdana", 10, (int)FontStyle.Regular);

            // Convert to string
            var font1String = font1.ToFontString();

            // Convert from string
            var font2 = FontExtensions.ToLogicalFont(font1String);

            // Validate result
            Assert.AreEqual(font1, font2);
        }
Exemplo n.º 8
0
        private void ResetFontInfo()
        {
            _charWidth       = null;
            _charHeight      = null;
            _smallCharHeight = null;
            _smallCharWidth  = null;

            if (_font != null)
            {
                FontExtensions.Clean(_font);
                _font.Dispose();
                _font = null;
            }

            if (_smallFont != null)
            {
                FontExtensions.Clean(_smallFont);
                _smallFont.Dispose();
                _smallFont = null;
            }
        }
Exemplo n.º 9
0
            public override void DrawWithFrame(CGRect cellFrame, NSView inView)
            {
                if (DrawsBackground && BackgroundColor != null && BackgroundColor.AlphaComponent > 0)
                {
                    BackgroundColor.Set();
                    NSGraphics.RectFill(cellFrame);
                }

                base.DrawWithFrame(cellFrame, inView);

                var progress = FloatValue;

                if (float.IsNaN((float)progress))
                {
                    return;
                }

                string progressText = (int)(progress * 100f) + "%";
                var    str          = new NSMutableAttributedString(progressText, NSDictionary.FromObjectAndKey(TextColor, NSStringAttributeKey.ForegroundColor));
                var    range        = new NSRange(0, str.Length);

                if (Font != null)
                {
                    str.AddAttributes(NSDictionary.FromObjectAndKey(Font, NSStringAttributeKey.Font), range);
                }
                var size   = FontExtensions.MeasureString(str, cellFrame.Size.ToEto());
                var rect   = cellFrame.ToEto();
                var offset = (rect.Size - size) / 2;

                if (!NSGraphicsContext.CurrentContext.IsFlipped)
                {
                    offset.Height = -offset.Height;
                }
                rect.Offset(offset);

                str.DrawString(rect.ToNS());
            }
Exemplo n.º 10
0
        public async Task SetSubtitles()
        {
            if (Status != SubSetStatus.Idle)
            {
                throw new Exception();
            }
            await Task.Run(() =>
            {
                Status        = SubSetStatus.Analize;
                StatusMessage = "Analizing";
                var allFiles  = Directory.GetFiles("*.*", SearchOption.AllDirectories);

                RunStatic();

                foreach (var file in allFiles)
                {
                    if (MovieExtensions.Any(e => e == file.Extension))
                    {
                        Movies.Add(new FileMovie(file));
                    }
                    if (SubExtensions.Any(e => e == file.Extension))
                    {
                        Subs.Add(new FileSubtitle(file));
                    }
                    if (FontExtensions.Any(e => e == file.Extension))
                    {
                        Fonts.Add(new FileFont(file));
                    }
                }

                if (!Setting.SearchMovieInSubdir)
                {
                    Movies = Movies.Where(movie => movie.DirectoryPath == Directory.FullName).ToList();
                }
                if (!Setting.SearchSubInSubdir)
                {
                    Subs = Subs.Where(sub => sub.DirectoryPath == Directory.FullName).ToList();
                }

                StatusPercent = 10;

                foreach (var fontFile in Fonts)
                {
                    fontFile.Install();
                }
                StatusPercent = 20;
                SetEpizodes(Subs);
                StatusPercent = 50;
                SetEpizodes(Movies);
                StatusPercent = 80;
                foreach (var sub in Subs)
                {
                    sub.Movie = Movies.FirstOrDefault(m => m.Epizode == sub.Epizode && sub.Path.Contains(m.DirectoryPath));
                }
                StatusPercent = 90;
                StatusPercent = 0;
                Status        = SubSetStatus.SettingSub;
                StatusMessage = "RenamingSubs";
                for (int i = 0; i < Subs.Count; i++)
                {
                    var sub = Subs[i];
                    if (sub.Movie == null)
                    {
                        continue;
                    }
                    var subPath = Path.Combine(sub.Movie.DirectoryPath, sub.Movie.PureName + sub.Extension);
                    if (File.Exists(subPath))
                    {
                        continue;
                    }
                    sub.Info.MoveTo(subPath);
                    StatusPercent = (byte)(i * 100 / Subs.Count);
                }
                Status        = SubSetStatus.Completed;
                StatusPercent = 100;
                StatusMessage = "Completed";
            });
        }