Ejemplo n.º 1
0
        private void Radio_Reco_Click(object sender, EventArgs e)
        {
            var radio = sender as BindableRadioButton <Tuple <Type, string, string> >;

            if (radio == null)
            {
                return;
            }
            else
            {
                label3.Text = radio.Data.Second;
                label4.Text = radio.Data.Third;

                SelectedRecognizeSingle = Activator.CreateInstance(radio.Data.First) as IRecognizeSingle;
            }
        }
Ejemplo n.º 2
0
        private void initRecos()
        {
            Assembly asm   = Assembly.GetAssembly(typeof(IRecognizeSingle));
            var      types = asm.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IRecognizeSingle))).ToList();
            var      list  = types.Select(t => {
                var name = t.GetCustomAttributes(typeof(ProcessorNameAttribute), false)
                           .Cast <ProcessorNameAttribute>().First();
                var description = t.GetCustomAttributes(typeof(ProcessorDescriptionAttribute), false)
                                  .Cast <ProcessorDescriptionAttribute>().First();
                return(new Tuple <Type, string, string> {
                    First = t,
                    Second = name.Name,
                    Third = description.Description
                });
            }).ToList();

            int  offset_y = 0;
            bool first    = true;

            foreach (var reco in list)
            {
                var radio = new BindableRadioButton <Tuple <Type, string, string> >();
                radio.Data = reco;

                radio.Text   = reco.Second;
                radio.Left   = 5;
                radio.Top    = offset_y;
                offset_y    += radio.Height;
                radio.Click += new EventHandler(Radio_Reco_Click);

                splitContainer2.Panel1.Controls.Add(radio);
                if (first)
                {
                    radio.Checked = true;
                    this.SelectedRecognizeSingle = Activator.CreateInstance(reco.First) as IRecognizeSingle;
                    first = false;
                }
            }
        }