private void listViewLUTItem_SelectedIndexChanged(object sender, EventArgs e) { RefreshItemButton(); if (this.listViewLUTItem.SelectedItems.Count > 0) { LUTItem item = this.listViewLUTItem.SelectedItems[0].Tag as LUTItem; if (item == null) { return; } this.textBoxSourceValue.Text = item.SourceValue; this.textBoxTargetValue.Text = item.TargetValue; this.buttonModifyItem.Enabled = false; this.buttonAddItem.Enabled = false; } else { this.textBoxSourceValue.Text = ""; this.textBoxTargetValue.Text = ""; this.buttonModifyItem.Enabled = false; this.buttonAddItem.Enabled = false; } }
private void ModifyItem() { string strSource = this.textBoxSourceValue.Text; string strTarget = this.textBoxTargetValue.Text; if (strSource.Length < 1 && strTarget.Length < 1) { return; } if (this.listViewLUTList.SelectedItems.Count < 1) { return; } LUTItemMgt lut = this.listViewLUTList.SelectedItems[0].Tag as LUTItemMgt; if (lut == null) { return; } if (this.listViewLUTItem.SelectedItems.Count < 1) { return; } LUTItem item = this.listViewLUTItem.SelectedItems[0].Tag as LUTItem; if (item == null) { return; } LUTItem newItem = new LUTItem(); newItem.SourceValue = strSource; newItem.TargetValue = strTarget; if (!CheckRepeat(newItem)) { return; } item.SourceValue = strSource; item.TargetValue = strTarget; if (lut.Update(item)) { lut.ReloadLUT(); RefreshItemList(lut); ListViewSelectItem(item); } else { MessageBox.Show(this, "Modify look up table item failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ListViewAddItem(LUTItem item) { if (item == null) { return; } int index = this.listViewLUTItem.Items.Count + 1; ListViewItem i = this.listViewLUTItem.Items.Add(index.ToString()); i.SubItems.Add(item.SourceValue); i.SubItems.Add(item.TargetValue); i.Tag = item; }
private void ListViewSelectItem(LUTItem item) { if (item == null) { return; } foreach (ListViewItem i in this.listViewLUTItem.Items) { LUTItem lutItem = i.Tag as LUTItem; if (lutItem.SourceValue == item.SourceValue && lutItem.TargetValue == item.TargetValue) { i.Selected = true; i.EnsureVisible(); break; } } }
private static double EmulatedLinExpConvert(double x) { //This works assuming that the LUT is in order. LUTItem minBound = _02rFaderLUT.LastOrDefault(y => y.y <= x); LUTItem maxBound = _02rFaderLUT.FirstOrDefault(y => y.y > x); //Edge case if (x >= 1) { return(minBound.x); } //Interpolate double xfrac = (x - minBound.y) / (maxBound.y - minBound.y); double interp = minBound.x * (1 - xfrac) + maxBound.x * xfrac; return(interp); }
private bool CheckRepeat(LUTItem newItem) { if (newItem == null) { return(false); } foreach (ListViewItem i in this.listViewLUTItem.Items) { LUTItem lutItem = i.Tag as LUTItem; if (lutItem.SourceValue == newItem.SourceValue && lutItem.TargetValue == newItem.TargetValue) { MessageBox.Show(this, "Item (Source=\"" + lutItem.SourceValue + "\",Target=\"" + lutItem.TargetValue + "\") has already existed in the look up table", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } return(true); }
private void DeleteItem() { if (this.listViewLUTList.SelectedItems.Count < 1) { return; } LUTItemMgt lut = this.listViewLUTList.SelectedItems[0].Tag as LUTItemMgt; if (lut == null) { return; } if (this.listViewLUTItem.SelectedItems.Count < 1) { return; } LUTItem item = this.listViewLUTItem.SelectedItems[0].Tag as LUTItem; if (item == null) { return; } if (lut.Delete(item)) { lut.ReloadLUT(); RefreshItemList(lut); RefreshItemButton(); } else { MessageBox.Show(this, "Delete look up table item failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }