示例#1
0
        private void SetGitHubIcon(VisualizerDialogColourTable colourTable)
        {
            var imageResourceName = typeof(VisualizerDialog)
                                    .Assembly
                                    .GetManifestResourceNames()
                                    .First(resourceName => Path
                                           .GetFileNameWithoutExtension(resourceName)
                                           .EndsWith($"GitHubIcon{colourTable.IconSuffix}", Ordinal));

            var imageStream = typeof(VisualizerDialog)
                              .Assembly
                              .GetManifestResourceStream(imageResourceName);

            using (imageStream)

                // ReSharper disable once AssignNullToNotNullAttribute
                using (var image = Image.FromStream(imageStream))
                {
                    var scaleFactor = _imageHeight / image.Height;
                    var newWidth    = (int)(image.Width * scaleFactor);
                    var newHeight   = (int)(image.Height * scaleFactor);

                    var newImage = new Bitmap(newWidth, newHeight);

                    using (var graphics = Graphics.FromImage(newImage))
                    {
                        graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                        graphics.DrawImage(image, new Rectangle(0, 0, newWidth, newHeight));
                    }

                    Image = newImage;
                }
        }
        public VisualizerDialog(Func <object> translationFactory)
        {
            _translationFactory = translationFactory;
            ColourTable         = new VisualizerDialogColourTable(this);
            _renderer           = new VisualizerDialogRenderer(this);
            _themeableControls  = new List <Control>();

            base.Text     = "ReadableExpressions v" + VersionNumber.FileVersion;
            StartPosition = FormStartPosition.CenterScreen;
            MinimizeBox   = false;
            AutoSizeMode  = AutoSizeMode.GrowAndShrink;

            var screenRectangle = RectangleToScreen(ClientRectangle);

            _titleBarHeight = screenRectangle.Top - Top;

            using (var graphics = CreateGraphics())
            {
                WidthFactor  = graphics.DpiX / 72;
                HeightFactor = graphics.DpiY / 72;
            }

            ViewModel = new TranslationViewModel();

            ToolTip    = AddToolTip();
            Viewer     = AddViewer();
            _menuStrip = AddMenuStrip();
            _toolbar   = AddToolbar();

            SetViewerSizeLimits();
            SetTranslation();

            Application.Idle += LazyLoadMenus;

            Shown += (sender, args) =>
            {
                var dialog = (VisualizerDialog)sender;
                dialog.Viewer.HandleShown(dialog.ViewModel.Translation);
            };

            Resize += (sender, args) => ((VisualizerDialog)sender).HandleResize();
        }
示例#3
0
 void IThemeable.Apply(VisualizerDialogColourTable colourTable)
 => SetGitHubIcon(colourTable);