Skip to content

Commit

Permalink
Add Winforms screenshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Nov 1, 2023
1 parent 2628e56 commit 52b3b46
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
coverage.xml
dist
build
logs
_build
distribute-*
docs/env
Expand Down
Binary file added docs/reference/images/button-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/canvas-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/dateinput-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/detailedlist-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/divider-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/label-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/mainwindow-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/numberinput-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/passwordinput-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/progressbar-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/selection-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/slider-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/splitcontainer-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/switch-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/table-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/textinput-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/timeinput-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/webview-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/images/window-winforms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions winforms/src/toga_winforms/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def get_width(self):
def get_height(self):
return self.native.Height

def get_data(self):
stream = MemoryStream()
self.native.Save(stream, ImageFormat.Png)
return stream.ToArray()

def save(self, path):
path = Path(path)
try:
Expand Down
19 changes: 18 additions & 1 deletion winforms/src/toga_winforms/window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import System.Windows.Forms as WinForms
from System.Drawing import Point, Size
from System.Drawing import Bitmap, Graphics, Point, Size
from System.Drawing.Imaging import ImageFormat
from System.IO import MemoryStream

from toga.command import GROUP_BREAK, SECTION_BREAK

Expand Down Expand Up @@ -179,3 +181,18 @@ def resize_content(self):
self.native.ClientSize.Width,
self.native.ClientSize.Height - vertical_shift,
)

def get_image_data(self):
size = Size(self.native_content.Size.Width, self.native_content.Size.Height)
bitmap = Bitmap(size.Width, size.Height)
graphics = Graphics.FromImage(bitmap)

graphics.CopyFromScreen(
self.native_content.PointToScreen(Point.Empty),
Point(0, 0),
size,
)

stream = MemoryStream()
bitmap.Save(stream, ImageFormat.Png)
return stream.ToArray()

0 comments on commit 52b3b46

Please sign in to comment.