CustomChrome.VisualStudioFormChrome.GetFormIcon C# (CSharp) Method

GetFormIcon() private method

private GetFormIcon ( ) : Image
return Image
        private Image GetFormIcon()
        {
            if (Form.Icon != _lastFormIcon)
            {
                _lastFormIcon = Form.Icon;

                if (_formImage != null)
                {
                    _formImage.Dispose();
                    _formImage = null;
                }

                if (Form.Icon != null)
                {
                    using (var icon = new Icon(Form.Icon, IconSize))
                    {
                        _formImage = icon.ToBitmap();
                    }
                }
            }

            return _formImage;
        }

Usage Example

            public ButtonStates(VisualStudioFormChrome parent)
            {
                bool drawMinimize = false;
                bool drawMaximizeRestore = false;
                bool drawClose = false;
                bool enableMinimize = false;
                bool enableMaximizeRestore = false;
                bool enableClose = false;

                if (parent.Form.ControlBox)
                {
                    DrawIcon = parent.GetFormIcon() != null && parent.Form.ShowIcon;
                    drawClose = true;
                    drawMinimize = drawMaximizeRestore = parent.Form.MinimizeBox || parent.Form.MaximizeBox;
                    enableMinimize = parent.Form.MinimizeBox;
                    enableMaximizeRestore = parent.Form.MaximizeBox;
                    enableClose = CanClose(parent);
                }

                var rightOffset =
                    parent.Form.Width -
                    parent.FormChrome.AdjustedResizeBorderThickness.Left;

                if (drawClose)
                    Close = GetButtonState(parent, ref rightOffset, ChromeButton.Close, enableClose);
                else
                    Close = new ButtonState(ChromeButton.Close);
                if (drawMaximizeRestore)
                    MaximizeRestore = GetButtonState(parent, ref rightOffset, ChromeButton.MaximizeRestore, enableMaximizeRestore);
                if (drawMinimize)
                    Minimize = GetButtonState(parent, ref rightOffset, ChromeButton.Minimize, enableMinimize);

                RightOffset = rightOffset;
            }
All Usage Examples Of CustomChrome.VisualStudioFormChrome::GetFormIcon