Esempio n. 1
0
        // begin with the list of functions of forms
        public void HandlerDispatcher(object sender, EventArgs e)
        {
            // used to create GUIElements
            string GUIObjectName = ((dynamic)sender).Name;

            // Get Handlers for the OnKeyUp Event
            if (e is KeyEventArgs)
            {
                WriteFieldValueToDataSetRecord(sender, e);
                return;
            }

            //System.Windows.Forms.MouseEventArgs e
            MouseEventArgs me = e as MouseEventArgs;

            if (e == null)
            {
                return;
            }

            // Get Handlers (functions) for this Event
            string HandlersToBind = "(Event = 'all'";

            // handle the Events
            if (me.Button == MouseButtons.Left)
            {
                HandlersToBind = HandlersToBind + " OR Event = 'MouseClick'";
            }

            // Get Handlers (functions) for this Event
            HandlersToBind = HandlersToBind + ")";

            // Get Handlers (functions) for this Field
            HandlersToBind = HandlersToBind + " AND GUIElementType + '_' + GUIElementId = '" + GUIObjectName + "'";

            // Use the Select method to find all Handlers to bind
            DataRow[] RowsToBind = GlobalVar.DataSet.Tables["GUIEventToHandler"].Select(HandlersToBind);

            // Get GUIObject
            dynamic GUIObject = null;

            poolManager.GetObject(GUIObjectName, ref GUIObject);

            // Invoke all assigned Mouse handlers
            foreach (DataRow row in RowsToBind) // Loop over the rows.
            {
                // bind method
                System.Reflection.MethodInfo method = this.GetType().GetMethod(row["Handler"].ToString(), new[]
                {
                    typeof(object),
                    typeof(EventArgs)
                });
                method.Invoke(this, new object[] { sender, e });

                // always call this function to write Log
                TraceEvent(sender, e, row["Handler"].ToString());
            }
        }
Esempio n. 2
0
        public void WriteFieldToDataSetRecord(string GUIObjectName,string TextValue)
        {
        // scompose GUIObjectName (field_[fieldID] )
        int FoundAt = GUIObjectName.IndexOf("_", 0)+1;
        string FieldID = GUIObjectName.Substring(FoundAt, GUIObjectName.Length - FoundAt);

        // Get GUIObject
        dynamic GUIObject = null;
        poolManager.GetObject(GUIObjectName, ref GUIObject);

        // Find the Table & Column of Fields
        DataRow[] fieldRows = GlobalVar.DataSet.Tables["field"].Select("id = " + FieldID);

        // Get Table and Column to update
        string Table = fieldRows[0]["table"].ToString();
        string Column = fieldRows[0]["column"].ToString();

        // Update DataSet
        int PKsToRender = Int32.Parse(DataExplorer.GetPKsToRender(FieldID));

        // Find the Table & Column of Fields
        DataRow[] UpdateTableRows = GlobalVar.DataSet.Tables[Table].Select("id = " + PKsToRender);  
                
        // Update Rows
        foreach(DataRow UpdateTableRow in UpdateTableRows)
            {
                UpdateTableRow[Column] = TextValue;
            }         
        }
Esempio n. 3
0
        public void Render(string TableName)
        {
            if (TableName != "GUIEventToHandler")
            {
                return;
            }

            // used to create GUIElements
            dynamic GUIObject = null;

            foreach (string GUIObjectName in poolManager.objPool.Keys)
            {
                // Get GUIObject
                poolManager.GetObject(GUIObjectName, ref GUIObject);

                // Get run-time type of the GUIElement instance
                Type currentType = GUIObject.GetType();

                // prepare to list all Events for trigger
                ArrayList AllEvents = new ArrayList(new string[] { "MouseClick", "KeyUp" }); // , "MouseHover"

                // add all Events to every GUIElement
                foreach (string Event in AllEvents) // Loop over all Events
                {
                    // Get from GUIElement the Event you want to tring
                    EventInfo eventInfo = currentType.GetEvent(Event);

                    // if the GUIElement support the event
                    if (eventInfo != null)
                    {
                        // Get the Action (functions) from EventHandler object to Run when event is trigged
                        EventHandler EventHandlers = new EventHandler();
                        MethodInfo   methodInfo    = EventHandlers.GetType().GetMethod("HandlerDispatcher",
                                                                                       new[]
                        {
                            typeof(object),
                            typeof(EventArgs)
                        }
                                                                                       );

                        // Use Delegate to hook the Action (function) to the GUIElement
                        Type     tDelegate = eventInfo.EventHandlerType;
                        Delegate del       = Delegate.CreateDelegate(tDelegate, EventHandlers, methodInfo);

                        //Add the Delegate to GUIElement
                        eventInfo.AddEventHandler(GUIObject, del);
                    }
                } // end AllEvents loop
            }     // end Object loop
        }         // end eventTrigger
Esempio n. 4
0
        private void UdpdateFieldsTextes(string TableName)
        {
            // Get all Fields with data of this table
            string expression = "table = '" + TableName + "'";

            // Use the Select method to find all Fields that use matching the filter.
            DataRow[] foundRows = GlobalVar.DataSet.Tables["field"].Select(expression);

            // Elaborate the Fields
            foreach (DataRow FieldToUpdate in foundRows)
            {
                // Get ID of Form
                string FieldID = FieldToUpdate["id"].ToString();

                //Get GUIObject
                dynamic GUIObject = null;
                poolManager.GetObject("field_" + FieldID, ref GUIObject);

                // Get the Column of the table that are rendered into the fields
                string ColName = FieldToUpdate["column"].ToString();

                // Render data onto the screen to each DataGridView
                if (ColName == "")
                {
                    GUIObject.DataSource = GlobalVar.DataSet.Tables[TableName];
                    continue;
                }

                // See whether it contains this string.
                if (DataExplorer.GetPKsToRender(FieldID) == "0")
                {
                    continue;
                }

                // Get all Records with PrimaryKey for this Field from Field_PrimaryKesyToRender
                string DataToDisplay = "id IN (" + DataExplorer.GetPKsToRender(FieldID) + ")";

                // Use the Select method to find all Fields that use matching the filter.
                DataRow[] RowsToDisplay = GlobalVar.DataSet.Tables[TableName].Select(DataToDisplay);

                // Update the Field.Text attribute with the correct UniquePrimaryKey UPK_ID
                foreach (DataRow row in RowsToDisplay) // Loop over the rows.
                {
                    GUIObject.Text = row[ColName].ToString();
                    //PropertyInfo cntrlProperty = GUIObject.GetType().GetProperty("Text");
                    //cntrlProperty.SetValue(GUIObject, row[ColName].ToString());
                } // end loop
            }     //end loop
        }         // end function
Esempio n. 5
0
        private void BuildGuiElements(String TableName)
        {
            // used to create GUIElements
            string  GUIObjectName;
            dynamic GUIObject = null;

            // create all Forms, tabs and fields
            foreach (DataRow row in GlobalVar.DataSet.Tables[TableName].Rows) // Loop over the rows.
            {
                // compose GUIObjectName (field_[fieldID] )
                GUIObjectName = TableName + "_" + row["id"].ToString();

                // get Object to manage
                poolManager.GetObject(GUIObjectName, ref GUIObject);

                // check if objct need to be created
                if (null == GUIObject)
                {
                    // create the object of correct class-type
                    switch (TableName)
                    {
                    case "form":
                    {
                        GUIObject = new Form1();
                        break;
                    }

                    case "tab":
                    {
                        GUIObject = new TabPage();
                        break;
                    }

                    case "field":
                    {
                        switch (row["type"].ToString())
                        {
                        case "Text":
                        {
                            GUIObject = new TextBox1();
                            break;
                        }

                        case "Button":
                        {
                            GUIObject = new Button1();
                            break;
                        }

                        case "Label":
                        {
                            GUIObject = new Label1();
                            break;
                        }

                        case "DataGridView":
                        {
                            GUIObject = new DataGridView1();
                            break;
                        }

                        default:
                        {
                            // column "type" has undefined Field Type
                            break;
                        }
                        }
                        break;
                    }
                    } // end switch

                    // Add the new generated object to pool
                    poolManager.AddObject(GUIObjectName, GUIObject);
                    //MessageBox.Show(poolManager.CurrentObjectsInPool.ToString());
                } //endif
            }     // end loop
        }