예제 #1
0
 def __drawPictureThumbnail(self):
     # load original image
     origImage = Bitmap.FromFile(self.filename, False)
     # calculate
     size = ThumbnailSize
     if self.__dims is None:
         self.__dims = (origImage.Width, origImage.Height)
     width, height = self.CalcResizedDims(size)
     drawWidth, drawHeight = width, height
     width, height = max(width, size), max(height, size)
     drawXOffset, drawYOffset = (width - drawWidth) / 2, (height -
                                                          drawHeight) / 2
     # draw new image
     newImage = Bitmap(width, height)
     g = Graphics.FromImage(newImage)
     g.InterpolationMode = InterpolationMode.HighQualityBicubic
     g.FillRectangle(Brushes.GhostWhite, 0, 0, width, height)
     g.DrawRectangle(Pens.LightGray, 0, 0, width - 1, height - 1)
     g.DrawImage(origImage, drawXOffset, drawYOffset, drawWidth, drawHeight)
     imageBytes = BitmapToBytes(newImage)
     # cleanup
     g.Dispose()
     newImage.Dispose()
     origImage.Dispose()
     return imageBytes
예제 #2
0
    def __init__(self):
        ListView.__init__(self)
        self.SuspendLayout()

        # List appearance
        self.Dock = DockStyle.Fill
        self.View = View.Details
        self.GridLines = True
        self.FullRowSelect = True
        self.HeaderStyle = ColumnHeaderStyle.None
        self.ShowItemToolTips = True
        self.Columns.Add("", -2, HorizontalAlignment.Left)

        # Events
        self.Resize += self.__OnResize
        self.DoubleClick += self.__OnDoubleClick

        # Register this class as the sink for all messages.
        # The higher level passes self.Reporter to the Modules.
        self.Reporter = FTReport.FTReporter()
        self.Reporter.RegisterUIHandler(self.Report)

        # Configure icons
        self.SmallImageList = ImageList()
        images = ("information", "exclamation", "cross_circle")
        for i in images:
            self.SmallImageList.Images.Add(
                Bitmap.FromFile(i.join(UIGlobal.ReportIconParams)))
        self.ResumeLayout(False)
예제 #3
0
 def __buttonBuilder(self, buttonDetails):
     button = ToolBarButton()
     if buttonDetails:
         button.Text = buttonDetails[self.__BUTTON_Text]
         button.ToolTipText = buttonDetails[self.__BUTTON_Tooltip]
         self.ImageList.Images.Add(
             Bitmap.FromFile(buttonDetails[self.__BUTTON_Image].join(
                 UIGlobal.ToolbarIconParams)))
         button.ImageIndex = self.ImageList.Images.Count - 1
         button.Tag = buttonDetails
     else:
         button.Style = ToolBarButtonStyle.Separator
     self.Buttons.Add(button)
예제 #4
0
 def DrawResizedImage(self, size):
     # load original image
     origImage = Bitmap.FromFile(self.filename, False)
     # calculate
     if self.__dims is None: self.__dims = (origImage.Width, origImage.Height)
     width, height = self.CalcResizedDims(size)
     # draw new image
     newImage = Bitmap(width, height)
     g = Graphics.FromImage(newImage)
     g.InterpolationMode = InterpolationMode.HighQualityBicubic
     g.DrawImage(origImage, 0, 0, width, height)
     imageBytes = BitmapToBytes(newImage)
     # cleanup
     g.Dispose()
     newImage.Dispose()
     origImage.Dispose()
     return imageBytes
예제 #5
0
    def __init__(self):
        """ContextMenuStripSample class init function."""

        # set up form
        self.Text = "ContextMenuStrip control"

        # set up menu items
        sample_dir = sys.path[0]
        image_path = os.path.join(sample_dir, "apple-red.png")
        self.toolstrip_menuitem1 = ToolStripMenuItem("Apple")
        self.toolstrip_menuitem1.Click += self.cms_click
        self.toolstrip_menuitem1.Image = Bitmap.FromFile(image_path)
        self.toolstrip_menuitem1a = ToolStripMenuItem("Macintosh")
        self.toolstrip_menuitem1b = ToolStripMenuItem("Delicious")
        self.toolstrip_menuitem2 = ToolStripMenuItem("Banana")
        self.toolstrip_menuitem2.Click += self.cms_click
        self.toolstrip_menuitem3 = ToolStripMenuItem("Watermelon")
        self.toolstrip_menuitem3.Click += self.cms_click
        self.toolstrip_menuitem4 = ToolStripMenuItem("Orange")
        self.toolstrip_menuitem4.Click += self.cms_click
        self.toolstrip_menuitem5 = ToolStripMenuItem("Peach")
        self.toolstrip_menuitem5.Click += self.cms_click

        # set up context_menu_strip
        self.context_menu_strip = ContextMenuStrip()
        self.toolstrip_menuitem1.DropDownItems.Add(self.toolstrip_menuitem1a)
        self.toolstrip_menuitem1.DropDownItems.Add(self.toolstrip_menuitem1b)
        self.context_menu_strip.Items.Add(self.toolstrip_menuitem1)
        self.context_menu_strip.Items.Add(self.toolstrip_menuitem2)
        self.context_menu_strip.Items.Add(self.toolstrip_menuitem3)
        self.context_menu_strip.Items.Add(self.toolstrip_menuitem4)
        self.context_menu_strip.Items.Add(self.toolstrip_menuitem5)

        # set up label
        self.label = Label()
        self.label.Text = "Right Click on me to see ContextMenuStrip"
        self.label.Width = 200
        self.label.Height = 50
        self.label.ContextMenuStrip = self.context_menu_strip
        self.label.BackColor = Color.Cyan
        self.label.BorderStyle = BorderStyle.FixedSingle

        # add controls
        self.Controls.Add(self.label)
예제 #6
0
파일: DotNet.py 프로젝트: cdfarrow/cdfutils
    def __init__(self, buttonList, imagePathTuple):
        ToolBar.__init__(self)
        self.Appearance = ToolBarAppearance.Flat
        self.Dock = DockStyle.Top

        self.HandlerList = []
        self.ImageList = ImageList()

        for bParams in buttonList:
            button = ToolBarButton()
            if bParams:
                handler, button.Text, imageName, button.ToolTipText = bParams
                self.ImageList.Images.Add(
                    Bitmap.FromFile(imageName.join(imagePathTuple)))
                button.ImageIndex = self.ImageList.Images.Count - 1

                self.HandlerList.append(handler)
                button.Tag = len(self.HandlerList) - 1
            else:
                button.Style = ToolBarButtonStyle.Separator
            self.Buttons.Add(button)

        self.ButtonClick += self.__OnButtonClick
예제 #7
0
 def __getDimensions(self):
     if self.__dims is None:
         origImage = Bitmap.FromFile(self.filename, False)
         self.__dims = (origImage.Width, origImage.Height)
         origImage.Dispose()
     return self.__dims