// TODO: FIX private void ImagePanel_SelectedIconsChanged(object sender, EventArgs e) { IImagePanel imagePanel = (IImagePanel)sender; string imageKey = View.ImagePanels[imagePanel]; if (LastSelectedFrames.ContainsKey(imageKey) && Originals.ContainsKey(imageKey)) { foreach (int frame in LastSelectedFrames[imageKey].Except(imagePanel.SelectedIcons)) { if (frame < Repository[imageKey].Count && frame < Originals[imageKey].Count) { Originals[imageKey][frame].EndPixelWorking(); Originals[imageKey][frame].CloneTo(Repository[imageKey][frame]); } } } if (LastSelectedFrames.ContainsKey(imageKey)) { LastSelectedFrames[imageKey] = imagePanel.SelectedIcons; } else { LastSelectedFrames.Add(imageKey, imagePanel.SelectedIcons); } IToolPanel toolPanel = View.ToolPanels.SelectedPanel; object selectedTool = toolPanel?.SelectedTool; if (selectedTool is ICustomFramesSupport && TuningCondition()) { ToolPanel_Tuning(toolPanel, e); } }
private void ImagePanel_StartSlideshow(object sender, EventArgs e) { IImagePanel imagePanel = (IImagePanel)sender; string imageKey = View.ImagePanels[imagePanel]; SlideshowService.StartSlideshow(imageKey, (o) => imagePanel.SetImage(o.ToBitmapSource()), 0); }
private void MenuPanel_PlayAnimation(object sender, EventArgs e) { IImagePanel imagePanel = View.ImagePanels.SelectedPanel; string imageKey = View.ImagePanels.SelectedPanelKey; SlideshowService.StartSlideshow(imageKey, (o) => imagePanel.SetImage(o.ToBitmapSource()), 0); }
private void ImagePanel_StopSlideshow(object sender, EventArgs e) { IImagePanel imagePanel = (IImagePanel)sender; string imageKey = View.ImagePanels[imagePanel]; SlideshowService.StopSlideshow(imageKey); }
private void ImagePanel_SelectedIconsChanged(object sender, EventArgs e) { IImagePanel imagePanel = (IImagePanel)sender; IImageList image = Repository[View.ImagePanels[imagePanel]]; int[] icons = imagePanel.SelectedIcons; int iconIndex = icons.Length > 0 ? icons[0] : -1; imagePanel.SetImage(image.ElementAtOrDefault(iconIndex)?.ToBitmapSource()); }
private void Repository_ItemAdded(object sender, string e) { IImageList image = Repository[e]; IImagePanel imagePanel = View.ImagePanels.AddPanel(e, Path.GetFileName(e)); imagePanel.SetImage(null); imagePanel.SetIcons(image.ToBitmapSources()); AppController.EventController .Subscribe(imagePanel, nameof(imagePanel.SelectedIconsChanged), ImagePanel_SelectedIconsChanged); }
private void Repository_ItemAdded(object sender, string e) { IImagePanel imagePanel = View.ImagePanels[e]; object selectedTool = View.ToolPanels.SelectedPanel.SelectedTool; imagePanel.AreaSelection = selectedTool is ICustomAreaSupport; imagePanel.MultiSelection = selectedTool is ICustomFramesSupport; AppController.EventController .Subscribe(imagePanel, nameof(imagePanel.SelectedAreaChanged), ImagePanel_SelectedAreaChanged) .Subscribe(imagePanel, nameof(imagePanel.SelectedIconsChanged), ImagePanel_SelectedIconsChanged); }
private void Repository_ItemChanged(object sender, string e) { IImageList image = Repository[e]; IImagePanel imagePanel = View.ImagePanels[e]; int[] icons = imagePanel.SelectedIcons; int iconIndex = icons.Length > 0 ? icons[0] : -1; if (!SlideshowService.IsRunning(e)) { imagePanel.SetImage(image.ElementAtOrDefault(iconIndex)?.ToBitmapSource()); } imagePanel.SetIcons(image.ToBitmapSources()); }
private void ToolPanel_Tuning(object sender, EventArgs e) { IImagePanel imagePanel = View.ImagePanels.SelectedPanel; string imageKey = View.ImagePanels.SelectedPanelKey; object tool = ((IToolPanel)sender).SelectedTool; ICustomFramesSupport framesSupport = tool as ICustomFramesSupport; ICustomAreaSupport areaSupport = tool as ICustomAreaSupport; IAsyncApplyingSupport asyncSupport = tool as IAsyncApplyingSupport; if (framesSupport != null) { framesSupport.CustomFrames = imagePanel.SelectedIcons; } if (areaSupport != null) { areaSupport.CustomArea = imagePanel.SelectedArea; } if (asyncSupport != null) { asyncSupport.AllowMultipleTasks = false; asyncSupport.ApplyAsync = Settings.Default.UseAsyncMode; AppController.EventController.UnsubscribeAll(asyncSupport, nameof(asyncSupport.AsyncApplyingCompleted)); AppController.EventController.Subscribe(asyncSupport, nameof(asyncSupport.AsyncApplyingCompleted), delegate { Repository.OnItemChanged(imageKey); }); } IImageListSupport imageListSupport = tool as IImageListSupport; IImageSupport imageSupport = tool as IImageSupport; try { if (!Originals.ContainsKey(imageKey)) { Originals.Add(imageKey, Repository[imageKey].Clone()); } if (imageListSupport != null) { imageListSupport.Apply(Originals[imageKey], Repository[imageKey]); if (!Settings.Default.UseAsyncMode) { Repository.OnItemChanged(imageKey); } } else if (imageSupport != null) { int frame = imagePanel.SelectedIcons.ElementAtOrDefault(0); imageSupport.Apply(Originals[imageKey][frame], Repository[imageKey][frame]); if (!Settings.Default.UseAsyncMode) { Repository.OnItemChanged(imageKey); } } else { throw new Exception("Unsupported tool type"); } } catch (OutOfMemoryException ex) { GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); MessageService.ShowError(ex.Message); } #if !DEBUG catch (Exception ex) { MessageService.ShowError(Resources.ApplyToolError); LogService.LogError(ex); } #endif }