private void FilterSetSelectorComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     var cb = (ComboBox)sender;
     var list = sets.GetSet(cb.SelectedText);
     if (list != null) {
         // make a local copy here
         currentBinding = AForgeFunction.Clone(list); 
     }
 }
 public void LoadAll()
 {
     list.Clear();
     names.Clear();
     // add empty list at top
     names.Add("");
     list.Add(new BindingList <AForgeFunction>());
     string[] files = Directory.GetFiles(dir, "*.aforge" + type);
     foreach (var file in files)
     {
         list.Add(AForgeFunction.LoadList(file));
         names.Add(Path.GetFileNameWithoutExtension(file));
     }
 }
        public static BindingList <AForgeFunction> GetFunctionsFromDisk(string name)
        {
            var filename = Global.BaseDirectory + @"\" + name + ".aforge" + "UP";

            if (File.Exists(filename))
            {
                return(AForgeFunction.LoadList(filename));
            }
            filename = Global.BaseDirectory + @"\" + name + ".aforge" + "DOWN";
            if (File.Exists(filename))
            {
                return(AForgeFunction.LoadList(filename));
            }
            return(null);
        }
 public void SaveAll()
 {
     if (list.Count != names.Count)
     {
         throw new Exception("FunctionSet missmatch");
     }
     for (int i = 0; i < list.Count; i++)
     {
         if (names[i].Length == 0)
         {
             continue;
         }
         AForgeFunction.SaveList(list[i], dir + @"\" + names[i] + ".aforge" + type);
     }
 }
        public void Save(string name, BindingList <AForgeFunction> l)
        {
            int i;

            for (i = 0; i < names.Count; i++)
            {
                if (names[i].Equals(name))
                {
                    list[i] = l;
                    break;
                }
            }
            if (i == names.Count)
            {
                //add it because it doesn't exist
                names.Add(name);
                list.Add(l);
            }
            // save it
            AForgeFunction.SaveList(l, dir + @"\" + names[i] + ".aforge" + type);
        }
Пример #6
0
        private List<AForgeFunction> BuildFunctionsList(DataGridView Grid)
        {
            List<AForgeFunction> NewList = new List<AForgeFunction>();
            int temp_i;
            double temp_d;
            int FunctionCol = (int)DataGridViewColumns.Function;
            int ActiveCol = (int)DataGridViewColumns.Active;
            int IntCol = (int)DataGridViewColumns.Int;
            int DoubleCol = (int)DataGridViewColumns.Double;
            int R_col = (int)DataGridViewColumns.R;
            int G_col = (int)DataGridViewColumns.G;
            int B_col = (int)DataGridViewColumns.B;

            NewList.Clear();
            MainForm.DisplayText("BuildFunctionsList:");

            foreach (DataGridViewRow Row in Grid.Rows)
            {
                AForgeFunction f = new AForgeFunction();
                // newly created rows are not complete yet
                if (Row.Cells[FunctionCol].Value == null)
                {
                    continue;
                }
                if (Row.Cells[ActiveCol].Value == null)
                {
                    continue;
                }
                // skip inactive rows
                if (Row.Cells[ActiveCol].Value.ToString() == "False")
                {
                    continue;
                }

                if (Row.Cells[ActiveCol].Value.ToString() == "false")
                {
                    continue;
                }

                switch (Row.Cells[FunctionCol].Value.ToString())
                {
                    case "Grayscale":
                        f.func = GrayscaleFunc;
                        break;

                    case "Contrast scretch":
                        f.func = Contrast_scretchFunc;
                        break;

                    case "Kill color":
                        f.func = KillColor_Func;
                        break;

                    case "Keep color":
                        f.func = KeepColor_Func;
                        break;

                    case "Invert":
                        f.func = InvertFunct;
                        break;

                    case "Meas. zoom":
                        f.func = Meas_ZoomFunc;
                        break;

                    case "Edge detect":
                        f.func = Edge_detectFunc;
                        break;

                    case "Noise reduction":
                        f.func = NoiseReduction_Funct;
                        break;

                    case "Threshold":
                        f.func = ThresholdFunct;
                        break;

                    case "Histogram":
                        f.func = HistogramFunct;
                        break;

                    default:
                        continue;
                    // break;
                }
                string msg= Row.Cells[FunctionCol].Value.ToString();
                msg += " / ";
                if (Row.Cells[IntCol].Value != null)
                {
                    int.TryParse(Row.Cells[IntCol].Value.ToString(), out temp_i);
                    f.parameter_int = temp_i;
                    msg += temp_i.ToString();
                }
                msg += " / ";
                if (Row.Cells[DoubleCol].Value != null)
                {
                    double.TryParse(Row.Cells[DoubleCol].Value.ToString(), out temp_d);
                    f.parameter_double = temp_d;
                    msg += temp_d.ToString();
                }
                msg += " / ";
                if (Row.Cells[R_col].Value != null)
                {
                    int.TryParse(Row.Cells[R_col].Value.ToString(), out temp_i);
                    f.R = temp_i;
                    msg += temp_i.ToString();
                }
                msg += " / ";
                if (Row.Cells[G_col].Value != null)
                {
                    int.TryParse(Row.Cells[G_col].Value.ToString(), out temp_i);
                    f.G = temp_i;
                    msg += temp_i.ToString();
                }
                msg += " / ";
                if (Row.Cells[B_col].Value != null)
                {
                    int.TryParse(Row.Cells[B_col].Value.ToString(), out temp_i);
                    f.B = temp_i;
                    msg += temp_i.ToString();
                }
                msg += " / ";
                NewList.Add(f);
                MainForm.DisplayText(msg);
            };
            return NewList;
        }
        public static BindingList <AForgeFunction> GetFunctionsFromDisk(string name, bool UpCamera)
        {
            var filename = Global.BaseDirectory + @"\" + name + ".aforge" + ((UpCamera) ? "UP" : "DOWN");

            return(AForgeFunction.LoadList(filename));
        }