def __init__(self, mode): f = FileStream(Path.Combine(SCRIPTDIRECTORY, "DuplicateForm.xaml"), FileMode.Open) self.win = XamlReader.Load(XmlReader.Create(f)) f.Close() self._action = None self.RenameText = "The file you are moving will be renamed: " #Load the images and icon path = FileInfo(__file__).DirectoryName arrow = BitmapImage() arrow.BeginInit() arrow.UriSource = Uri(Path.Combine(SCRIPTDIRECTORY, "arrow.png"), UriKind.Absolute) arrow.EndInit() self.win.FindName("Arrow1").Source = arrow self.win.FindName("Arrow2").Source = arrow self.win.FindName("Arrow3").Source = arrow icon = BitmapImage() icon.BeginInit() icon.UriSource = Uri(ICON, UriKind.Absolute) icon.EndInit() self.win.Icon = icon self.win.FindName("CancelButton").Click += self.CancelClick self.win.FindName("Cancel").Click += self.CancelClick self.win.FindName("ReplaceButton").Click += self.ReplaceClick self.win.FindName("RenameButton").Click += self.RenameClick self.win.Closing += self.FormClosing #The the correct text based on what mode we are in #Mode is set by default so only change if in Copy or Simulation mode if mode == Mode.Copy: self.win.FindName("MoveHeader").Content = "Copy and Replace" self.win.FindName( "MoveText" ).Content = "Replace the file in the destination folder with the file you are copying:" self.win.FindName("DontMoveHeader").Content = "Don't Copy" self.win.FindName( "RenameHeader").Content = "Copy, but keep both files" self.RenameText = "The file you are copying will be renamed: " self.win.FindName( "RenameText" ).Text = "The file you are copying will be renamed: " if mode == Mode.Simulate: self.win.FindName( "Subtitle" ).Content = "Click the file you want to keep (simulated, no files will be deleted or moved)"
def __init__(self): wpf.LoadComponent(self, xamlfile) logo = Image() bi = BitmapImage() bi.BeginInit() bi.UriSource = Uri("/logo-portcoast.png", UriKind.Relative) bi.EndInit() logo.Source = bi
def createImage(self, grid): image = Image() bi = BitmapImage() bi.BeginInit() image_uri = os.path.join(os.path.dirname(__file__), 'image.jpg') bi.UriSource = Uri(image_uri, UriKind.RelativeOrAbsolute) bi.EndInit() image.Source = bi SetGridChild(grid, image, 1, 1, "Image")
def setImage(self, path): self.txt.Text = path try: image = BitmapImage() image.BeginInit() image.CacheOption = BitmapCacheOption.OnLoad image.CreateOptions = BitmapCreateOptions.IgnoreImageCache image.UriSource = Uri(path) image.EndInit() self.img.Source = image except: pass
def setImage(self, path): self.txt.Text = path try: image = BitmapImage() image.BeginInit() image.CacheOption = BitmapCacheOption.OnLoad image.CreateOptions = BitmapCreateOptions.IgnoreImageCache image.UriSource = Uri(path) image.EndInit() self.img.Source = image except: pass
def __init__(self, file_address): logger.debug('Creating uri from: {}'.format(file_address)) uri = Uri(file_address) logger.debug('Creating {0}x{0} bitmap from: {1}'.format( ICON_SMALL, file_address)) bitmap_image = BitmapImage() bitmap_image.BeginInit() bitmap_image.UriSource = uri bitmap_image.CacheOption = BitmapCacheOption.OnLoad bitmap_image.CreateOptions = BitmapCreateOptions.DelayCreation bitmap_image.DecodePixelHeight = ICON_SMALL # bitmap_image.DecodePixelWidth = ICON_SMALL bitmap_image.EndInit() self.smallBitmap = bitmap_image logger.debug('Creating {0}x{0} bitmap from: {1}'.format( ICON_MEDIUM, file_address)) bitmap_image = BitmapImage() bitmap_image.BeginInit() bitmap_image.UriSource = uri bitmap_image.CacheOption = BitmapCacheOption.OnLoad bitmap_image.CreateOptions = BitmapCreateOptions.DelayCreation bitmap_image.DecodePixelHeight = ICON_MEDIUM # bitmap_image.DecodePixelWidth = ICON_MEDIUM bitmap_image.EndInit() self.mediumBitmap = bitmap_image logger.debug('Creating {0}x{0} bitmap from: {1}'.format( ICON_LARGE, file_address)) bitmap_image = BitmapImage() bitmap_image.BeginInit() bitmap_image.UriSource = uri bitmap_image.CacheOption = BitmapCacheOption.OnLoad bitmap_image.CreateOptions = BitmapCreateOptions.DelayCreation bitmap_image.DecodePixelHeight = ICON_LARGE # bitmap_image.DecodePixelWidth = ICON_LARGE bitmap_image.EndInit() self.largeBitmap = bitmap_image
def image_path_to_bitmap(fname): try: if fname: bitmap = BitmapImage() bitmap.BeginInit() bitmap.UriSource = CommonUtil.path_to_uri(fname) bitmap.CacheOption = BitmapCacheOption.OnLoad bitmap.CreateOptions = BitmapCreateOptions.DelayCreation bitmap.EndInit() bitmap.Freeze() return bitmap except: pass
def showPreview(self): filename = None for extension in ["jpg", "png"]: filename = path.join(self.sModelPath, "preview." + extension) if path.exists(filename): break if filename: image = BitmapImage() image.BeginInit() imageUri = filename image.UriSource = Uri(imageUri, UriKind.RelativeOrAbsolute) image.EndInit() self.imagePreview.Source = image else: pass