private void tsmiLoadImageFromFile_Click(object sender, EventArgs e) { string filePath = ImageHelpers.OpenImageFileDialog(); if (!string.IsNullOrEmpty(filePath)) { if (PreviewImage != null) { PreviewImage.Dispose(); } PreviewImage = ImageHelpers.LoadImage(filePath); FilePath = filePath; UpdatePreview(); } }
private void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e) { Image img = ClipboardHelpers.GetImage(); if (img != null) { if (PreviewImage != null) { PreviewImage.Dispose(); } PreviewImage = img; FilePath = null; UpdatePreview(); } }
protected override void OnExecute(object param) { if (Directory.Exists(OutputDir)) { Directory.Delete(OutputDir, true); } Directory.CreateDirectory(OutputDir); var builder = new ImageBuilder(); for (int i = 0; i < _main.StickerItems.Count; i++) { var item = _main.StickerItems[i]; var outName = item.Emoji; foreach (var c in Path.GetInvalidPathChars()) { outName = outName.Replace(c.ToString(), ""); } foreach (var c in Path.GetInvalidFileNameChars()) { outName = outName.Replace(c.ToString(), ""); } outName = outName.Replace(" ", "_"); var path = Path.Combine(OutputDir, $"{i}_{outName}.png"); var preview = new PreviewImage(); preview.DataContext = new { SelectedStickerItem = item, SelectedTextFill = _main.SelectedTextFill, }; Application.Current.Dispatcher.Invoke( DispatcherPriority.Background, new Action(() => { builder.BuildImageFile(new ImageBuilder.Settings { Surface = preview.ImageCanvas, OutputPath = path, TransparentBackground = _main.TransparentBackground, }); }) ); } }
private void GeneratePreviewImage(int padding) { if (pbResult.ClientSize.Width > 0 && pbResult.ClientSize.Height > 0) { int horizontalPadding = padding, verticalPadding = padding; int minSizePadding = 300; if (pbResult.ClientSize.Width < (horizontalPadding * 2) + minSizePadding) { horizontalPadding = 0; } if (pbResult.ClientSize.Height < (verticalPadding * 2) + minSizePadding) { verticalPadding = 0; } if (PreviewImage != null) { PreviewImage.Dispose(); } PreviewImage = new Bitmap(pbResult.ClientSize.Width - (horizontalPadding * 2), pbResult.ClientSize.Height - (verticalPadding * 2)); Color backgroundColor; if (ShareXResources.UseCustomTheme) { backgroundColor = ShareXResources.Theme.BackgroundColor; } else { backgroundColor = Color.DarkGray; } using (Graphics g = Graphics.FromImage(PreviewImage)) { g.Clear(backgroundColor); if (PreviewImage.Width > 260 && PreviewImage.Height > 260) { using (Image logo = ShareXResources.Logo) { g.DrawImage(logo, (PreviewImage.Width / 2) - (logo.Width / 2), (PreviewImage.Height / 2) - (logo.Height / 2)); } } } } }
private void PreviewImage_Click(object sender, RoutedEventArgs e) { if (_selectedImage != null) { _selectedImage.IsSelected = false; } _selectedImage = sender as PreviewImage; _selectedImage.IsSelected = true; _selectedImageIndex = imageItems.Items.IndexOf(_selectedImage.MainImage); double p = (_selectedImage.Width + _selectedImage.Margin.Right) * _selectedImageIndex; p -= imagesScrollViewer.ActualWidth / 2 - _selectedImage.Width / 2; imagesScrollViewer.ScrollToHorizontalOffset(p); _viewModel.MainImage = _selectedImage.MainImage; }
private void GeneratePreviewImage(int padding) { if (pbResult.ClientSize.Width > 0 && pbResult.ClientSize.Height > 0) { int size = Math.Min(pbResult.ClientSize.Width, pbResult.ClientSize.Height); int minSizePadding = 300; if (size < minSizePadding + (padding * 2)) { padding = 0; } size -= padding * 2; if (PreviewImage != null) { PreviewImage.Dispose(); } PreviewImage = new Bitmap(size, size); Color backgroundColor; if (ShareXResources.UseCustomTheme) { backgroundColor = ShareXResources.Theme.BackgroundColor; } else { backgroundColor = Color.DarkGray; } using (Graphics g = Graphics.FromImage(PreviewImage)) { g.Clear(backgroundColor); if (PreviewImage.Width > 260 && PreviewImage.Height > 260) { using (Bitmap logo = ShareXResources.Logo) { g.DrawImage(logo, (PreviewImage.Width / 2) - (logo.Width / 2), (PreviewImage.Height / 2) - (logo.Height / 2)); } } } } }
private static async Task <PreviewImage> GrabPreviewImage(CC0Asset value, int previewImageSize) { string preview = value.PreviewSphere[$"{previewImageSize}-PNG"]; if (preview == null) { preview = value.PreviewSphere[$"{previewImageSize}-JPG"]; } if (preview == null) { preview = value.PreviewSphere.Last().Value; } if (preview != null) { return(await PreviewImage.LoadUri(preview)); } return(null); }
public BitmapSource GeneratePreviewImage(ColorRamp ramp, bool useStdDevStretch, int quality) { //if (m_pixelGridSet == null) // GeneratePreviewGrid(); if (Preview == null || Preview.ColorHandler != ramp || Preview.UseStdDevStretch != useStdDevStretch || Preview.Quality != quality) { var source = GeneratePreviewImage(m_pixelGridSet.GridQuantized, ramp, useStdDevStretch, quality); Preview = new PreviewImage(source, ramp, useStdDevStretch, quality); //using (var fileStream = new FileStream(Path.Combine(Cache.APP_CACHE_DIR, "preview.jpg"), FileMode.Create)) //{ // var encoder = new JpegBitmapEncoder(); // encoder.Frames.Add(BitmapFrame.Create(source)); // encoder.QualityLevel = 100; // encoder.Save(fileStream); //} } return(Preview.Image); }
private UploadMedia(string filePath) { var ext = Path.GetExtension(filePath).ToLower(); if (ext.Equals(".gif") && IsAnimatedGif(ext)) { MediaType = MediaType.AnimatedGifFile; PreviewImage = new BitmapImage(new Uri(filePath)); } else if (VideoExtensions.Contains(ext)) { MediaType = MediaType.VideoFile; UseChunkedUpload = true; } else if (ImageExtensions.Contains(ext)) { MediaType = MediaType.ImageFile; if (ext != ".webp") { PreviewImage = new BitmapImage(new Uri(filePath)); } } else { throw new NotSupportedException(); } FilePath = filePath; filePath = Path.GetFileName(filePath); ViewExtension = ext.Substring(1).ToUpper(); SourceStream = File.OpenRead(FilePath); if (PreviewImage?.CanFreeze ?? false) { PreviewImage.Freeze(); } }
//Click on Preview Changes public static void VerifyPreviewChanges() { log4net.Config.XmlConfigurator.Configure(); ILog logger = LogManager.GetLogger(typeof(CreateDesignPage)); try { Wait.WaitVisible(PreviewChanges, 20); PreviewChanges.Click(); Wait.WaitVisible(PreviewImage, 20); bool status_of_previewimage = PreviewImage.IsElementDisplayed(); logger.Info("Status of Preview Image is " + status_of_previewimage); Console.WriteLine("Status of Preview Image is " + status_of_previewimage); //Wait.WaitVisible(SaveDesign); } catch (Exception e) { logger.Error("Preview Changes failed due to : " + e); test.Fail("Preview Changes failed."); //**Closing browser Driver.Quit(); throw e; } }
void ReleaseDesignerOutlets() { if (borderSubmit != null) { borderSubmit.Dispose(); borderSubmit = null; } if (bottomButtonsContainer != null) { bottomButtonsContainer.Dispose(); bottomButtonsContainer = null; } if (btnSubmitChallenge != null) { btnSubmitChallenge.Dispose(); btnSubmitChallenge = null; } if (btnSubmitPictureWithDescription != null) { btnSubmitPictureWithDescription.Dispose(); btnSubmitPictureWithDescription = null; } if (CameraButton != null) { CameraButton.Dispose(); CameraButton = null; } if (CameraButtonCenter != null) { CameraButtonCenter.Dispose(); CameraButtonCenter = null; } if (CollectionView != null) { CollectionView.Dispose(); CollectionView = null; } if (CollectionViewAttach != null) { CollectionViewAttach.Dispose(); CollectionViewAttach = null; } if (CountContainer != null) { CountContainer.Dispose(); CountContainer = null; } if (DescriptionText != null) { DescriptionText.Dispose(); DescriptionText = null; } if (lblChallengeName != null) { lblChallengeName.Dispose(); lblChallengeName = null; } if (lblUpload != null) { lblUpload.Dispose(); lblUpload = null; } if (NeedUploadCountText != null) { NeedUploadCountText.Dispose(); NeedUploadCountText = null; } if (PreviewImage != null) { PreviewImage.Dispose(); PreviewImage = null; } if (submitContainer != null) { submitContainer.Dispose(); submitContainer = null; } if (UploadedCountText != null) { UploadedCountText.Dispose(); UploadedCountText = null; } if (vCameraCenter != null) { vCameraCenter.Dispose(); vCameraCenter = null; } if (vDescriptionContainer != null) { vDescriptionContainer.Dispose(); vDescriptionContainer = null; } }
void ReleaseDesignerOutlets() { if (AddPosterButton != null) { AddPosterButton.Dispose(); AddPosterButton = null; } if (CameraButton != null) { CameraButton.Dispose(); CameraButton = null; } if (CheckBoxsView != null) { CheckBoxsView.Dispose(); CheckBoxsView = null; } if (CollectionFullView != null) { CollectionFullView.Dispose(); CollectionFullView = null; } if (CollectionView != null) { CollectionView.Dispose(); CollectionView = null; } if (DeleteButton != null) { DeleteButton.Dispose(); DeleteButton = null; } if (DescriptionText != null) { DescriptionText.Dispose(); DescriptionText = null; } if (PreviewImage != null) { PreviewImage.Dispose(); PreviewImage = null; } if (StepOneImage != null) { StepOneImage.Dispose(); StepOneImage = null; } if (StepOneText != null) { StepOneText.Dispose(); StepOneText = null; } if (StepTwoImage != null) { StepTwoImage.Dispose(); StepTwoImage = null; } if (StepTwoText != null) { StepTwoText.Dispose(); StepTwoText = null; } if (UploadCountText != null) { UploadCountText.Dispose(); UploadCountText = null; } }
private async Task SynchronizeAsync(CancellationToken cancellationToken) { var flickr = Singleton <FlickrService> .Instance.FlickrNet; var functionMode = Singleton <SettingsService> .Instance.Mode; try { CurrentOperationDescription = string.Format("Sync_ParsingFolderStatus".GetLocalized(), SyncFolder.Path); var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, extensions) { FolderDepth = FolderDepth.Deep }; queryOptions.SetThumbnailPrefetch(ThumbnailModeSingle, ThumbnailSize, ThumbnailOptionResize); var queryResult = SyncFolder.CreateFileQueryWithOptions(queryOptions); var files = await queryResult.GetFilesAsync(); cancellationToken.ThrowIfCancellationRequested(); ProgressMax = files.Count; var photosetsList = await flickr.RetryOnFailureAsync(f => f.PhotosetsGetListAsync()); cancellationToken.ThrowIfCancellationRequested(); var photosets = photosetsList.Where(ps => !string.IsNullOrWhiteSpace(ps.Description) && ps.Description[0] == '`') .Distinct(new GenericEqualityComparer <Photoset>(ps => ps.Description)).ToDictionary(ps => ps.Description); var groupedFiles = files.GroupBy(f => Path.GetDirectoryName(f.Path)); foreach (var group in groupedFiles) { var photosetName = Path.GetFileName(group.Key); var photosetDescription = "`" + group.Key.Replace(SyncFolder.Path, "."); Dictionary <string, Photo> photos; if (photosets.TryGetValue(photosetDescription, out Photoset photoset)) { var photosCollection = await flickr.RetryOnFailureAsync(f => f.PhotosetsGetPhotosAsync(photoset.PhotosetId)); photos = photosCollection.Distinct(new GenericEqualityComparer <Photo>(p => p.Title)).ToDictionary(p => p.Title); } else { photos = new Dictionary <string, Photo>(); } foreach (var file in group) { if (photos.Remove(file.Name)) { ProgressValue++; continue; } if (functionMode != FunctionMode.DownloadOnly) { CurrentOperationDescription = string.Format("Sync_UploadingFileStatus".GetLocalized(), file.Path); var thumbnail = await file.GetThumbnailAsync(ThumbnailModeSingle, ThumbnailSize, ThumbnailOptionResize); using (var stream = thumbnail.AsStreamForRead().AsRandomAccessStream()) { await PreviewImage.SetSourceAsync(stream); } try { string photoId = null; using (var stream = (await file.OpenSequentialReadAsync()).AsStreamForRead()) { photoId = await flickr.RetryOnFailureAsync(f => f.UploadPictureAsync(stream, file.Name, file.Name, file.Path.Replace(SyncFolder.Path, "."), "", false, false, false, ContentType.Photo, SafetyLevel.None, HiddenFromSearch.Hidden)); } if (photoset == null) { CurrentOperationDescription = string.Format("Sync_CreatingPhotoSetStatus".GetLocalized(), photosetName); photoset = await flickr.RetryOnFailureAsync(f => f.PhotosetsCreateAsync(photosetName, photosetDescription, photoId)); } else { CurrentOperationDescription = string.Format("Sync_AddingFileToPhotoSet".GetLocalized(), file.Name, photosetName); await flickr.RetryOnFailureAsync(f => f.PhotosetsAddPhotoAsync(photoset.PhotosetId, photoId)); } } catch (FlickrException exception) { if (!exception.Message.Contains("Filetype was not recognised")) { throw; } } } cancellationToken.ThrowIfCancellationRequested(); ProgressValue++; } if (photos.Count > 0 && functionMode != FunctionMode.UploadOnly) { var folder = await StorageFolder.GetFolderFromPathAsync(group.Key); await DownloadPhotosAsync(flickr, folder, photos.Values, cancellationToken); } photosets.Remove(photosetDescription); } if (functionMode != FunctionMode.UploadOnly) { foreach (var photoset in photosets.Values) { var folder = await CreateFolderRecursivelyAsync(SyncFolder, photoset.Description.Substring(1), cancellationToken); var photos = await flickr.RetryOnFailureAsync(f => f.PhotosetsGetPhotosAsync(photoset.PhotosetId)); await DownloadPhotosAsync(flickr, folder, photos, cancellationToken); } } ProgressValue = ProgressMax; CurrentOperationDescription = "Sync_FinishedStatus".GetLocalized(); } catch (Exception exception) { if (!cancellationToken.IsCancellationRequested) { var msg = new MessageDialog(exception.Message, "Error"); await msg.ShowAsync(); throw; } } }
/// <summary> /// Release mouse capture /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PreviewImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { PreviewImage.ReleaseMouseCapture(); }
private void LoadFile(string fileName) { FileErrorDetails.Clear(); _asfObjects.Clear(); TimeToImageConverter.EmptyCache(); var asfItems = AsfInfo.GetHeaderObjects(fileName); if (asfItems == null) //invalid file { FileErrorDetails.Add(new FileErrorInfo() { ErrorType = "Invalid ASF file", ErrorDetails = "No Header Object found" }); Dispatcher.DelayInvoke(TimeSpan.FromMilliseconds(500), new Action(() => { ErrorDetailsVisible = true; IsBusy = false; RaisePropertyChanged("IsBusy"); RaisePropertyChanged("ErrorDetailsVisible"); })); } else { foreach (AsfHeaderItem asfItem in asfItems) { _asfObjects.Add(asfItem); } double fileLength = AsfHeaderItem.Configuration.Duration; HasVideoStream = AsfHeaderItem.Configuration.ImageWidth > 0; _previewImagesLoadedCount = 0; _previewImages.Clear(); _loadingImages = new List <PreviewImage>(); if (HasVideoStream) { for (int i = 0; i < _thumbCount; i++) { double startOffset = ((double)i / _thumbCount) * fileLength; PreviewImage pi = new PreviewImage() { FileName = fileName, TimeOffset = startOffset, DisplayTime = (uint)(startOffset * 1000), PresentationTime = (uint)(startOffset * 1000) + AsfHeaderItem.Configuration.AsfPreroll }; Action a = new Action(pi.GenerateSource); _loadingImages.Add(pi); a.BeginInvoke(new AsyncCallback(PreviewImageLoaded), a); } } RaisePropertyChanged("Title"); Dispatcher.DelayInvoke(TimeSpan.FromMilliseconds(500), new Action(() => { IsBusy = false; IsFileLoaded = true; PreviewVisible = HasVideoStream; RaisePropertyChanged("IsBusy"); RaisePropertyChanged("PreviewVisible"); RaisePropertyChanged("HasVideoStream"); })); } }
public override void ViewDidLoad() { base.ViewDidLoad(); CompletedCountInitial = Challenge.CompletedCount ?? 0; TargetCount = (Challenge.TargetCount ?? 0) == 0 ? MAX_IMAGES : Challenge.TargetCount.Value; IsSingleImage = TargetCount == 1; IsUnlimitedImages = TargetCount == MAX_IMAGES; AllowUserCompletion = (Challenge.AllowUserCompletion ?? false) || IsUnlimitedImages; SetupFonts(); if (CompletedCount == 0) { ShowNoImageView(); } else if (CompletedCount > 0) { ShowImagesCollectionView(); } CountContainer.Layer.BorderColor = UIColor.FromRGB(238, 238, 238).CGColor; CountContainer.Layer.BorderWidth = 1; CountContainer.Layer.CornerRadius = 2; CameraButtonCenter.TouchUpInside += (e, s) => TakePicture(true); btnSubmitPictureWithDescription.TouchUpInside += (e, s) => { if (IsSingleImage) { Spinner = new UIImageView(UIImage.FromBundle("loading-indicator")); PreviewImage.AddSubview(Spinner); Platform.AnimateRotation(Spinner); PosteringOverlay = Platform.AddOverlay(View, View.Frame, UIColor.Clear, true); CountContainer.AddConstraint(NSLayoutConstraint.Create(CountContainer, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 0)); } else { ShowImagesCollectionView(); } SubmitChallenge(btnSubmitChallenge); }; CameraButton.TouchUpInside += (e, s) => TakePicture(true); btnSubmitChallenge.TouchUpInside += (e, s) => { UIAlertController alertController = UIAlertController.Create(null, $"You have submitted {CompletedCount}/{(IsUnlimitedImages ? "∞" : TargetCount.ToString())} pieces of content - would you like to complete this challenge now, or leave it open to submit more later?", UIAlertControllerStyle.ActionSheet); alertController.AddAction(UIAlertAction.Create("COMPLETE NOW", UIAlertActionStyle.Destructive, (a) => SL.Manager.PostSubmitCollateral(Challenge.ID, (resp) => SubmitChallengeComplete(btnSubmitChallenge, resp)))); alertController.AddAction(UIAlertAction.Create("LEAVE OPEN", UIAlertActionStyle.Cancel, (a) => { NavigationController.PopViewController(true); NavigationController.PopViewController(false); })); NavigationController.PresentViewController(alertController, true, null); }; DescriptionText.ReturnKeyType = UIReturnKeyType.Done; DescriptionText.ShouldChangeText += DescriptionText_ShouldChangeText; DescriptionText.ShouldBeginEditing += (UITextView textView) => { if (textView.Text == placeholder) { textView.Text = ""; textView.TextColor = UIColor.Black; // Text Color } return(true); }; DescriptionText.ShouldEndEditing += (UITextView textView) => { if (textView.Text == "") { textView.Text = placeholder; textView.TextColor = UIColor.LightGray; // Placeholder Color } return(true); }; lblChallengeName.Text = Challenge.Name; NeedUploadCountText.Text = "/ " + (IsUnlimitedImages ? "∞" : TargetCount.ToString()); CollectionView.RegisterNibForCell(CollateralCollectionViewCell.Nib, CollateralCollectionViewCell.ClassName); CollectionViewAttach.RegisterNibForCell(CollateralCollectionViewCell.Nib, CollateralCollectionViewCell.ClassName); }
public void UnloadAll() { PreviewImage.Unload(); Icon.Unload(); }
void IDisposable.Dispose() { PreviewImage.Dispose(); }
private void PreviewImageButton_Click(object sender, RoutedEventArgs e) { PreviewImage.Show(Window.GetWindow(this), this.BackdropImage.Source as ImageSource); }
public bool Equals(ContentTypeDescription input) { if (input == null) { return(false); } return (( CType == input.CType || (CType != null && CType.Equals(input.CType)) ) && ( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( ContentDescription == input.ContentDescription || (ContentDescription != null && ContentDescription.Equals(input.ContentDescription)) ) && ( PreviewImage == input.PreviewImage || (PreviewImage != null && PreviewImage.Equals(input.PreviewImage)) ) && ( Priority == input.Priority || (Priority.Equals(input.Priority)) ) && ( Reminder == input.Reminder || (Reminder != null && Reminder.Equals(input.Reminder)) ) && ( Properties == input.Properties || (Properties != null && Properties.SequenceEqual(input.Properties)) ) && ( TagMetadata == input.TagMetadata || (TagMetadata != null && TagMetadata.SequenceEqual(input.TagMetadata)) ) && ( TagMetadataItems == input.TagMetadataItems || (TagMetadataItems != null && TagMetadataItems.SequenceEqual(input.TagMetadataItems)) ) && ( UsageExamples == input.UsageExamples || (UsageExamples != null && UsageExamples.SequenceEqual(input.UsageExamples)) ) && ( ShowInContentEditor == input.ShowInContentEditor || (ShowInContentEditor != null && ShowInContentEditor.Equals(input.ShowInContentEditor)) ) && ( TypeOf == input.TypeOf || (TypeOf != null && TypeOf.Equals(input.TypeOf)) ) && ( BindIdentifierToProperty == input.BindIdentifierToProperty || (BindIdentifierToProperty != null && BindIdentifierToProperty.Equals(input.BindIdentifierToProperty)) ) && ( BoundRegex == input.BoundRegex || (BoundRegex != null && BoundRegex.Equals(input.BoundRegex)) ) && ( ForceIdentifierBinding == input.ForceIdentifierBinding || (ForceIdentifierBinding != null && ForceIdentifierBinding.Equals(input.ForceIdentifierBinding)) ) && ( AllowComments == input.AllowComments || (AllowComments != null && AllowComments.Equals(input.AllowComments)) ) && ( AutoEnglishPropertyFallback == input.AutoEnglishPropertyFallback || (AutoEnglishPropertyFallback != null && AutoEnglishPropertyFallback.Equals(input.AutoEnglishPropertyFallback)) ) && ( BulkUploadable == input.BulkUploadable || (BulkUploadable != null && BulkUploadable.Equals(input.BulkUploadable)) ) && ( Previews == input.Previews || (Previews != null && Previews.SequenceEqual(input.Previews)) ) && ( SuppressCmsPath == input.SuppressCmsPath || (SuppressCmsPath != null && SuppressCmsPath.Equals(input.SuppressCmsPath)) ) && ( PropertySections == input.PropertySections || (PropertySections != null && PropertySections.SequenceEqual(input.PropertySections)) )); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PreviewImage obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }