Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 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;
         }
     }
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
        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);
            }
        }