Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        partial void saveButtonClick(EventArgs e)
        {
            if (fileLoaded == String.Empty)
            {
                //first we get a filename
                using (var fileDialog = new SaveFileDialog())
                {
                    fileDialog.Filter           = "MVCMAP Files|*.mvcmap";
                    fileDialog.InitialDirectory = Environment.CurrentDirectory;
                    fileDialog.OverwritePrompt  = true;
                    fileDialog.Title            = "Save file as...";
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        fileLoaded = fileDialog.FileName;
                    }
                    else
                    {
                        UIBridge.Alert("File save aborted");
                    }
                }
            }

            //we just overwrite... should this be an option?

            ViewActionMap.Save(data, fileLoaded, true);

            modified = false;
        }
Ejemplo n.º 2
0
 partial void button1Click(EventArgs e)
 {
     if (Core.ValidateAccountNumber(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)) == ValidationResult.Valid)
     {
         UIBridge.Alert("Valid");
     }
     else
     {
         UIBridge.Alert("Invalid");
     }
 }
Ejemplo n.º 3
0
        private void LoadClassData()
        {
            var registeredTypes = new List <Store>();

            Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
            foreach (Assembly a in assemblies)
            {
                foreach (Type t in a.GetExportedTypes())
                {
                    // Ignore type if not a public class
                    if (!t.IsClass || !t.IsPublic)
                    {
                        continue;
                    }

                    //skip non controls
                    if (!(t == typeof(Control) || t.IsSubclassOf(typeof(Control))) && !(t == typeof(Component) || t.IsSubclassOf(typeof(Component))))
                    {
                        continue;
                    }

                    //register the type...
                    try
                    {
                        if (registeredTypes.Where(x => x.ClassName == t.FullName).Count() <= 0)
                        {
                            registeredTypes.Add(new Store()
                            {
                                ClassName = t.Name, ClassType = t
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(String.Format("{0} - {1}", ex.GetType().Name, ex.Message));
                        System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                    }
                }
            }

            //find the control
            var control = registeredTypes.Where(x => x.ClassName == controlName).SingleOrDefault();

            if (control != null)
            {
                EventInfo[] eia = control.ClassType.GetEvents();

                eventCombo.BeginUpdate();
                eventCombo.DataSource = null;

                foreach (var ei in eia)
                {
                    //get the event name

                    ParameterInfo[] epia = ei.EventHandlerType.GetMethod("Invoke").GetParameters();

                    string eventarg = String.Empty;

                    if (epia != null)
                    {
                        foreach (var pi in epia)
                        {
                            if (pi.ParameterType == typeof(EventArgs) || pi.ParameterType.IsSubclassOf(typeof(EventArgs)))
                            {
                                eventarg = pi.ParameterType.FullName; //because we otherwise get a lot of issues building stuff when the class is not in the standard System.Windows.Forms namespace

                                //System.Console.WriteLine(ei.Name + " : " + ei.EventHandlerType + " :: " + "" + eventarg);
                                actions.Add(new Tools.ViewAction()
                                {
                                    EventName = ei.Name, EventHandlerName = ei.EventHandlerType.FullName, EventArgsName = eventarg
                                });

                                break;
                            }
                        }
                    }
                }
                eventCombo.DataSource    = actions;
                eventCombo.DisplayMember = "EventName";
                eventCombo.EndUpdate();
            }
            else
            {
                UIBridge.Alert("Control was not found!");
                View.DialogResult = DialogResult.Cancel;
                View.Close();
            }
        }