private void SelectItem(object sender, RoutedEventArgs e) { var item = ((Grid)((Button)sender).Parent).DataContext; var container = (ListViewItem)ChangesList.ContainerFromItem(item); container.IsSelected = true; }
private void GridChangedFiles_SelectionChanged(object sender, EventArgs e) { if (GridChangedFiles.SelectedRows.Count == 0) { return; } var patch = (Patch)GridChangedFiles.SelectedRows[0].DataBoundItem; CurrentPatch = patch; if (patch == null) { return; } ChangesList.ViewPatch(patch.Text); /* * ChangesList.Text = ""; * * try * { * ChangesList.SetHighlighting("Patch"); * ChangesList.Refresh(); * ChangesList.IsReadOnly = true; * } * catch * { * ChangesList.Text = ""; * ChangesList.Refresh(); * } * ChangesList.Text = patch.Text; * //PatchedFileEdit.Text = changedFile.New;*/ }
/// <summary> /// Gets or sets the value associated with the specified key. /// </summary> /// <param name="key">The key of the value to get or set.</param> /// <returns>The value associated with the specified key. If the specified key is not found, a get operation throws a System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key.</returns> public new TValue this[TKey key] { get { return(base[key]); } set { if (key != null) { ChangesList changes = this.Enlist(); if (!this.ContainsKey(key)) { changes.Add( delegate { base[key] = value; }, delegate { base.Remove(key); }); } else { TValue oldValue = base[key]; changes.Add( delegate { base[key] = value; }, delegate { base[key] = oldValue; }); } } base[key] = value; } }
void IUndoRedoMember.OnUndo(object change) { ChangesList changesList = (ChangesList)change; for (int i = changesList.Count - 1; i >= 0; i--) { changesList[i].OldState(); } }
void IUndoRedoMember.OnRedo(object change) { ChangesList changesList = (ChangesList)change; for (int i = 0; i <= changesList.Count - 1; i++) { changesList[i].NewState(); } }
/// <summary>Adds the specified key and value to the dictionary.</summary> /// <param name="key">The key of the element to add.</param> /// <param name="value">The value of the element to add. The value can be null for reference types.</param> public new void Add(TKey key, TValue value) { if (key != null && !this.ContainsKey(key)) { ChangesList changes = this.Enlist(); changes.Add( delegate { base.Add(key, value); }, delegate { base.Remove(key); }); } base.Add(key, value); }
/// <summary> /// Removes all keys and values from the System.Collections.Generic.Dictionary<TKey,TValue>. /// </summary> public new void Clear() { ChangesList changes = this.Enlist(); Dictionary <TKey, TValue> copy = new Dictionary <TKey, TValue>(this); changes.Add( delegate { base.Clear(); }, delegate { foreach (TKey key in copy.Keys) { base.Add(key, copy[key]); } }); base.Clear(); }
private ChangesList Enlist() { UndoRedoManager.AssertCommand(); if (!UndoRedoManager.CurrentCommand.ContainsKey(this)) { ChangesList changes = new ChangesList(); UndoRedoManager.CurrentCommand[this] = changes; return(changes); } else { return((ChangesList)UndoRedoManager.CurrentCommand[this]); } }
private void GridChangedFiles_SelectionChanged(object sender, EventArgs e) { if (GridChangedFiles.SelectedRows.Count == 0) { return; } var patch = (Patch)GridChangedFiles.SelectedRows[0].DataBoundItem; if (patch == null) { return; } ChangesList.ViewPatch(patch.FileNameB, patch.Text ?? ""); }
ChangesList Enlist() { UndoRedoArea.AssertCommand(); Command command = UndoRedoArea.CurrentArea.CurrentCommand; if (!command.IsEnlisted(this)) { ChangesList changes = new ChangesList(); command[this] = changes; return(changes); } else { return((ChangesList)command[this]); } }
/// <summary> /// Removes the value with the specified key from the /// System.Collections.Generic.Dictionary<TKey,TValue>. /// </summary> /// <param name="key">The key of the element to remove.</param> /// <returns> /// true if the element is successfully found and removed; /// otherwise, false. This method returns false if key is not found in /// the System.Collections.Generic.Dictionary<TKey,TValue>. /// </returns> public new bool Remove(TKey key) { if (base.TryGetValue(key, out TValue value)) { ChangesList changes = Enlist(); changes.Add( delegate { base.Remove(key); }, delegate { base.Add(key, value); }); return(base.Remove(key)); } else { return(false); } }
public void UpdateConfigFile(CLogConfigurationFile newConfigFile) { // Ideally, we'd use CLogConfigurationFile.AreWeDirty, but because of the tricks // we do around serialization, we can't without a major refactor if (newConfigFile == null || ConfigFile == null) { AreDirty = true; ConfigFile = newConfigFile; return; } // Serialize old config bool old = ConfigFile.SerializeChainedConfigurations; ConfigFile.SerializeChainedConfigurations = true; string serializedOldConfig = JsonConvert.SerializeObject(ConfigFile); ConfigFile.SerializeChainedConfigurations = old; // Serialize new config old = newConfigFile.SerializeChainedConfigurations; newConfigFile.SerializeChainedConfigurations = true; string serializedNewConfig = JsonConvert.SerializeObject(newConfigFile); newConfigFile.SerializeChainedConfigurations = old; if (serializedOldConfig != serializedNewConfig) { AreDirty = true; ChangesList.Add("Configuration file or dependencies changed"); } ConfigFile = newConfigFile; }