Created
August 3, 2021 08:20
-
-
Save jasondown/b9a3533fd98054246abf5f74d37f0a3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultiImageAddinHostControl : WinFormsControlAddInBase | |
{ | |
private Panel _panel; // ADDED PANEL | |
private ElementHost _host; | |
private MultiImageView _view; | |
private PageableImageControlViewModel _vm; | |
private IImageRepository _imageRepository; | |
/// <summary> | |
/// Creates the Windows Forms control for the control add-in. | |
/// </summary> | |
/// <returns>Returns the Windows Forms control.</returns> | |
protected override Control CreateControl() | |
{ | |
_panel = new Panel | |
{ | |
// ADDED BORDER | |
BorderStyle = BorderStyle.FixedSingle | |
}; | |
_host = new ElementHost | |
{ | |
Dock = DockStyle.Fill | |
}; | |
// PANEL HOSTS THE ELEMENTHOST | |
_panel.Controls.Add(_host); | |
_vm = new PageableImageControlViewModel | |
{ | |
PageSize = 3 | |
}; | |
_view = new MultiImageView | |
{ | |
DataContext = _vm | |
}; | |
_view.InitializeComponent(); | |
_host.Child = _view; | |
// SET THE ELEMENTHOST SIZE TO MINWIDTH/MINHEIGHT | |
_host.Size = new Size((int) _view.MinWidth, (int) _view.MinHeight); | |
// SET THE PANEL SIZE TO SLIGHTLY LARGER TO GIVE A BIT OF PADDING | |
_panel.Size = new Size((int) _view.MinWidth + 5, (int) _view.MinHeight + 5); | |
return _panel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment