public ImageListOptions(ImageListOptions other) { this.Name = other.Name ?? string.Empty; this.ColorDepth = other.ColorDepth; this.ImageSize = other.ImageSize; this.TransparentColor = other.TransparentColor; this.ImageSources.AddRange(other.ImageSources); }
void InitializeFrom(ImageListOptions options) { Name = options.Name; HeightVM.Value = options.ImageSize.Height; WidthVM.Value = options.ImageSize.Width; TransparentColorVM.Value = options.TransparentColor; ColorDepthVM.SelectedItem = options.ColorDepth; ImageListStreamerVM.InitializeFrom(options.ImageSources); }
ImageListOptions CopyTo(ImageListOptions options) { options.Name = Name; options.ImageSize = new Size(WidthVM.Value, HeightVM.Value); options.TransparentColor = TransparentColorVM.Value; options.ColorDepth = (ColorDepth)ColorDepthVM.SelectedItem; options.ImageSources.Clear(); options.ImageSources.AddRange(ImageListStreamerVM.Collection.Select(a => a.ImageSource)); return(options); }
public ImageListVM(ImageListOptions options) { this.origOptions = options; this.imageListStreamerVM = new ImageListStreamerVM(); ImageListStreamerVM.Collection.CollectionChanged += (s, e) => HasErrorUpdated(); this.widthVM = new Int32VM(a => HasErrorUpdated(), true) { Min = 1, Max = 256, }; this.heightVM = new Int32VM(a => HasErrorUpdated(), true) { Min = 1, Max = 256, }; this.transparentColorVM = new DefaultConverterVM<Color>(a => HasErrorUpdated()); Reinitialize(); }
public ImageListVM(ImageListOptions options) { this.origOptions = options; this.ImageListStreamerVM = new ImageListStreamerVM(); ImageListStreamerVM.Collection.CollectionChanged += (s, e) => HasErrorUpdated(); this.WidthVM = new Int32VM(a => HasErrorUpdated(), true) { Min = 1, Max = 256, }; this.HeightVM = new Int32VM(a => HasErrorUpdated(), true) { Min = 1, Max = 256, }; this.TransparentColorVM = new DefaultConverterVM <Color>(a => HasErrorUpdated()); Reinitialize(); }
static void Execute(ILSpyTreeNode[] nodes) { if (!CanExecute(nodes)) return; var imgNode = (SerializedImageListStreamerResourceElementTreeNode)nodes[0]; var options = new ImageListOptions(imgNode.ImageListOptions); var data = new ImageListVM(options); var win = new ImageListDlg(); win.Title = CMD_NAME; win.DataContext = data; win.Owner = MainWindow.Instance; if (win.ShowDialog() != true) return; var listOpts = data.CreateImageListOptions(); if (listOpts.ImageSources.Count == 0) { MainWindow.Instance.ShowMessageBox("It's not possible to create an empty image list"); return; } ResourceElementOptions opts = null; string error; try { opts = new ResourceElementOptions(SerializedImageListStreamerResourceElementTreeNode.Serialize(listOpts)); error = imgNode.CheckCanUpdateData(opts.Create()); } catch (Exception ex) { error = string.Format("Couldn't serialize the images. Error: {0}", ex.Message); } if (!string.IsNullOrEmpty(error)) { MainWindow.Instance.ShowMessageBox(error); return; } UndoCommandManager.Instance.Add(new SerializedImageListStreamerResourceElementSettingsCommand(imgNode, opts)); }
ImageListOptions CopyTo(ImageListOptions options) { options.Name = Name; options.ImageSize.Height = HeightVM.Value; options.ImageSize.Width = WidthVM.Value; options.TransparentColor = TransparentColorVM.Value; options.ColorDepth = (ColorDepth)ColorDepthVM.SelectedItem; options.ImageSources.Clear(); options.ImageSources.AddRange(ImageListStreamerVM.Collection.Select(a => a.ImageSource)); return options; }