/// <summary> /// Constructor. /// </summary> public EditBitmapAnimation(Window owner, int setOffset, SortedList <int, VisualizationSet> editedList, VisualizationAnimation origAnim) { InitializeComponent(); Owner = owner; DataContext = this; mSetOffset = setOffset; mEditedList = editedList; mOrigAnim = origAnim; // this will cause initialization of the Brush properties FrameDelayTimeMsec = DEFAULT_FRAME_DELAY.ToString(); if (origAnim != null) { TagString = origAnim.Tag; mFrameDelayIntMsec = PluginCommon.Util.GetFromObjDict(origAnim.VisGenParams, VisualizationAnimation.FRAME_DELAY_MSEC_PARAM, DEFAULT_FRAME_DELAY); FrameDelayTimeMsec = mFrameDelayIntMsec.ToString(); } else { TagString = "anim" + mSetOffset.ToString("x6"); } PopulateItemLists(); }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { Visualization item = (Visualization)visualizationGrid.SelectedItem; int index = visualizationGrid.SelectedIndex; VisualizationList.RemoveAt(index); // Keep selection at same index, unless we just removed the item at the end. if (index == VisualizationList.Count) { index--; } if (index >= 0) { visualizationGrid.SelectedIndex = index; } RemovedSerials.Add(item.SerialNumber); // Update any animations in this set. Animations in other sets will be updated later. // (This is a bit awkward because we can't modify VisualizationList while iterating // through it, and there's no simple "replace entry" operation on an observable // collection. Fortunately we don't do this often and the data sets are small.) List <VisualizationAnimation> needsUpdate = new List <VisualizationAnimation>(); foreach (Visualization vis in VisualizationList) { if (vis is VisualizationAnimation) { VisualizationAnimation visAnim = (VisualizationAnimation)vis; if (visAnim.ContainsSerial(item.SerialNumber)) { needsUpdate.Add(visAnim); } } } foreach (VisualizationAnimation visAnim in needsUpdate) { VisualizationAnimation newAnim; if (VisualizationAnimation.StripEntries(visAnim, new List <int>(1) { item.SerialNumber }, out newAnim)) { if (newAnim.Count == 0) { VisualizationList.Remove(visAnim); } else { newAnim.GenerateImage(CreateEditedSetList()); index = VisualizationList.IndexOf(visAnim); VisualizationList.Remove(visAnim); VisualizationList.Insert(index, newAnim); } } } }
private void OkButton_Click(object sender, RoutedEventArgs e) { Dictionary <string, object> visGenParams = new Dictionary <string, object>(1); visGenParams.Add(VisualizationAnimation.FRAME_DELAY_MSEC_PARAM, mFrameDelayIntMsec); List <int> serials = new List <int>(VisAnimItems.Count); foreach (Visualization vis in VisAnimItems) { serials.Add(vis.SerialNumber); } NewAnim = new VisualizationAnimation(TagString, VisualizationAnimation.ANIM_VIS_GEN, new ReadOnlyDictionary <string, object>(visGenParams), serials, mOrigAnim); NewAnim.GenerateImage(mEditedList); DialogResult = true; }