示例#1
0
        private static bool UpdateError(IGXDLMSView view, System.Windows.Forms.Control.ControlCollection controls,
                                        GXDLMSObject target, int index, Exception ex)
        {
            bool found = false;

            foreach (Control it in controls)
            {
                if (it is GXValueField)
                {
                    GXValueField obj = it as GXValueField;
                    if (obj.Index == index)
                    {
                        if (ex == null)
                        {
                            view.ErrorProvider.SetError(it, null);
                        }
                        else
                        {
                            view.ErrorProvider.SetError(it, ex.Message);
                        }
                        found = true;
                        break;
                    }
                }
                else if (it.Controls.Count != 0)
                {
                    found = UpdateError(view, it.Controls, target, index, ex);
                }
                if (found)
                {
                    break;
                }
            }
            return(found);
        }
示例#2
0
        public static bool UpdateDirty(IGXDLMSView view, System.Windows.Forms.Control.ControlCollection controls, GXDLMSObject target, int index, bool dirty)
        {
            bool found = false;

            foreach (Control it in controls)
            {
                if (it is GXValueField)
                {
                    GXValueField obj = it as GXValueField;
                    if (obj.Index == index)
                    {
                        if (dirty && index != 0)
                        {
                            view.ErrorProvider.SetError(it, Properties.Resources.ValueChangedTxt);
                        }
                        else
                        {
                            view.ErrorProvider.Clear();
                        }
                        found = true;
                    }
                }
                else if (it.Controls.Count != 0)
                {
                    found = UpdateDirty(view, it.Controls, target, index, dirty);
                }
                if (found)
                {
                    break;
                }
            }
            return(found);
        }
 private static bool UpdateAccessRights(IGXDLMSView view, System.Windows.Forms.Control.ControlCollection controls, GXDLMSObject target, int index, bool method, bool connected)
 {
     foreach (Control it in controls)
     {
         if (!method && it is GXValueField)
         {
             GXValueField obj = it as GXValueField;
             if (obj.Index == index)
             {
                 obj.Target = target;
                 AccessMode am = target.GetAccess(index);
                 OnUpdateAccessRights(view, obj, connected && ((am & AccessMode.Write) != 0));
                 return(!obj.NotifyChanges);
             }
         }
         else if (it is GXButton)
         {
             GXButton btn = it as GXButton;
             btn.Target = target;
             //Update custom buttons.
             if (method && index == 0 && btn.Index < 1)
             {
                 OnUpdateAccessRights(view, btn, connected);
                 continue;
             }
             if (method && btn.Index == index && btn.Action == ActionType.Action)
             {
                 MethodAccessMode ma = target.GetMethodAccess(index);
                 OnUpdateAccessRights(view, btn, connected && ma != MethodAccessMode.NoAccess);
                 return(true);
             }
             if (!method && btn.Index == index && (btn.Action == ActionType.Read || btn.Action == ActionType.Write))
             {
                 AccessMode am = target.GetAccess(index);
                 if (btn.Action == ActionType.Read)
                 {
                     OnUpdateAccessRights(view, btn, connected && ((am & AccessMode.Read) != 0));
                 }
                 else if (btn.Action == ActionType.Write)
                 {
                     OnUpdateAccessRights(view, btn, connected && ((am & AccessMode.Write) != 0));
                 }
             }
         }
         else if (it.Controls.Count != 0)
         {
             bool ret = UpdateAccessRights(view, it.Controls, target, index, method, connected);
             //If object is updated.
             if (ret)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#4
0
 private static void Init(IGXDLMSView view, System.Windows.Forms.Control.ControlCollection controls, EventHandler eventHandler)
 {
     foreach (Control it in controls)
     {
         if (it is GXButton)
         {
             GXButton btn = it as GXButton;
             btn.View   = view;
             btn.Click += eventHandler;
         }
         else if (it is GXValueField)
         {
             GXValueField vf = it as GXValueField;
             vf.DefaultType = vf.Type;
         }
         else if (it.Controls.Count != 0)
         {
             Init(view, it.Controls, eventHandler);
         }
     }
 }
示例#5
0
 private static bool UpdateAccessRights(IGXDLMSView view, GXDLMSClient client, System.Windows.Forms.Control.ControlCollection controls, GXDLMSObject target, int index, bool method, bool connected)
 {
     foreach (Control it in controls)
     {
         if (!method && it is GXValueField)
         {
             GXValueField obj = it as GXValueField;
             if (obj.Index == index)
             {
                 obj.Target = target;
                 bool access = connected;
                 if (connected)
                 {
                     if (client != null)
                     {
                         access = client.CanWrite(target, index);
                     }
                     else
                     {
                         AccessMode am = target.GetAccess(index);
                         access = (am & AccessMode.Write) != 0;
                     }
                 }
                 OnUpdateAccessRights(view, client, obj, connected && access);
                 return(!obj.NotifyChanges);
             }
         }
         else if (it is GXButton)
         {
             bool     access;
             GXButton btn = it as GXButton;
             btn.Target = target;
             //Update custom buttons.
             if (method && index == 0 && btn.Index < 1)
             {
                 OnUpdateAccessRights(view, client, btn, connected);
                 continue;
             }
             if (method && btn.Index == index && btn.Action == ActionType.Action)
             {
                 if (client != null)
                 {
                     access = client.CanInvoke(target, index);
                 }
                 else
                 {
                     access = target.GetMethodAccess(index) != MethodAccessMode.NoAccess;
                     if (!access)
                     {
                         access = target.GetMethodAccess3(index) != MethodAccessMode3.NoAccess;
                     }
                 }
                 OnUpdateAccessRights(view, client, btn, connected && access);
                 return(true);
             }
             if (!method && btn.Index == index && (btn.Action == ActionType.Read || btn.Action == ActionType.Write))
             {
                 if (btn.Action == ActionType.Read)
                 {
                     if (client != null)
                     {
                         access = client.CanRead(target, index);
                     }
                     else
                     {
                         access = (target.GetAccess(index) & AccessMode.Read) != 0;
                         if (!access)
                         {
                             access = (target.GetAccess3(index) & AccessMode3.Read) != 0;
                         }
                     }
                     OnUpdateAccessRights(view, client, btn, connected && access);
                 }
                 else if (btn.Action == ActionType.Write)
                 {
                     if (client != null)
                     {
                         access = client.CanWrite(target, index);
                     }
                     else
                     {
                         access = (target.GetAccess(index) & AccessMode.Write) != 0;
                         if (!access)
                         {
                             access = (target.GetAccess3(index) & AccessMode3.Write) != 0;
                         }
                     }
                     OnUpdateAccessRights(view, client, btn, connected && access);
                 }
             }
         }
         else if (it.Controls.Count != 0)
         {
             bool ret = UpdateAccessRights(view, client, it.Controls, target, index, method, connected);
             //If object is updated.
             if (ret)
             {
                 return(true);
             }
         }
     }
     return(false);
 }