private List <TreeNode> GetFormDetailNodes(AccessFormModel model) { var result = new List <TreeNode>(); if (model.HasRecordset()) { result.Add(new LazyTreeNode(RecordsetLabel).Add(GetRecordsetNode(model.Recordset.Value))); } var dynamicProperties = new Lazy <AccessDynamicPropertyCollectionModel>(() => new AccessDynamicPropertyCollectionModel(model.Form.Properties)); result.Add( new LazyTreeNode(PropertiesLabel) .Add(GetDynamicPropertyParentNode(dynamicProperties, DynamicPropertiesLabel)) .AddRange(() => CreatePropertyNodes(model.Form)) ); model.LoadControls(false); result.AddRange( model.Controls.Select( cn => new LazyTreeNode(cn).AddRange(() => GetControlNodes(cn)) ) ); return(result); }
public static T TryGetDynamicPropertyValue <T>(this AccessFormModel form, string propertyName) { try { return(GetDynamicPropertyValue <T>(form.Form.Properties, propertyName)); } catch { return(default(T)); } }
private bool ExecuteHandlerCode(AccessFormModel form, AccessControlModel control, string actionName) { var handlerCode = control.TryGetPropertyValue <string>(actionName); if (!string.IsNullOrEmpty(handlerCode)) { ExecuteCode(form, control, handlerCode); return(true); } return(false); }
public static bool TryGetDynamicPropertyValue <T>(this AccessFormModel form, string propertyName, out T value) { try { value = GetDynamicPropertyValue <T>(form.Form.Properties, propertyName); return(true); } catch { value = default(T); return(false); } }
internal AccessFormModel GetForm(string formNameOrPathToSubform, bool getFormProperties = true, bool getControls = true, bool getControlsProperties = false) { if (formNameOrPathToSubform.Contains("/")) { var control = GetControlByPath(formNameOrPathToSubform); if (!control.HasForm()) { throw new ApplicationException("Selected control does not contain a subform"); } return(new AccessFormModel(control.Control.Form, getFormProperties, getControls, getControlsProperties)); } var form = application.Forms[formNameOrPathToSubform]; var result = new AccessFormModel(form, getFormProperties, getControls, getControlsProperties); return(result); }
internal void ExecuteEvents(string path, params string[] eventNames) { var controlPath = new ControlPathModel(path); var control = accessFormControlsTreeWalker.GetAccessControlByPath(application, controlPath); var formName = controlPath.FormName; var form = new AccessFormModel(application.Forms[formName], false, false, false); foreach (var eventName in eventNames) { if (ExecuteHandlerCode(form, control, eventName)) { return; } } throw new Exception("No action to execute found"); }
private void ExecuteCode(AccessFormModel formModel, AccessControlModel control, string code) { if (code == "[Event Procedure]") { //form.SetFocus(); control.SetFocus(); RobotWin32.SetForegroundWindow((IntPtr)formModel.Hwnd); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); } else if (!string.IsNullOrEmpty(code)) { application.DoCmd.RunMacro(code); } else { throw new Exception("Code to execute is empty"); } }
public static void SetDynamicPropertyValue <T>(this AccessFormModel control, string propertyName, T value) { control.Form.Properties[propertyName].Value = value; }
private TreeNode GetLoadedFormNode(AccessFormModel model) => new LazyTreeNode(model).AddRange(() => GetFormDetailNodes(model));
private TreeNode GetLoadedFormNode(MSAccess.Application application, string formName) { var formModel = new AccessFormModel(application.Forms[formName], false, false, false); return(GetLoadedFormNode(formModel)); }