Esempio n. 1
0
        public Management.Editors.XDataBlockForm GetForm(string Path, Channel chParam, Device dvParam, DataBlock dbParam, string classname)
        {
            GetIODriver objFunctions = GetIODriver.GetFunctions();
            object      context      = objFunctions.ParseNamespace($@"\AdvancedScada.{Path}.Core.dll", classname);
            Type        t            = (Type)context;

            Management.Editors.XDataBlockForm newObject = (Management.Editors.XDataBlockForm)objFunctions.CreateInstance(t, new object[] { chParam, dvParam, dbParam });
            newObject.eventDataBlockChanged += (db, isNew) =>
            {
                eventDataBlockChanged?.Invoke(db, isNew);
                newObject.DialogResult = DialogResult.OK;
            };
            return(newObject);
        }
        public void GetForm(string Path, string classname)
        {
            if (db == null)
            {
                switch (Path)
                {
                case "LSIS":
                    newObject = new XLSIS.Core.UserEditors.XUserDataBlockForm(ch, dv, null);

                    break;

                case "Modbus":
                    newObject = new XModbus.Core.UserEditors.XUserDataBlockForm(ch, dv, null);
                    break;

                case "Panasonic":
                    newObject = new XPanasonic.Core.UserEditors.XUserDataBlockForm(ch, dv, null);
                    break;

                case "Siemens":
                    newObject = new XSiemens.Core.UserEditors.XUserDataBlockForm(ch, dv, null);
                    break;

                default:
                    break;
                }
            }

            else
            {
                switch (Path)
                {
                case "LSIS":
                    newObject = new XLSIS.Core.UserEditors.XUserDataBlockForm(ch, dv, db);

                    break;

                case "Modbus":
                    newObject = new XModbus.Core.UserEditors.XUserDataBlockForm(ch, dv, db);
                    break;

                case "Panasonic":
                    newObject = new XPanasonic.Core.UserEditors.XUserDataBlockForm(ch, dv, db);
                    break;

                case "Siemens":
                    newObject = new XSiemens.Core.UserEditors.XUserDataBlockForm(ch, dv, db);
                    break;

                default:
                    break;
                }
            }
            newObject.eventDataBlockChanged += (db, isNew) =>
            {
                eventDataBlockChanged?.Invoke(db, isNew);
                DialogResult = DialogResult.OK;
            };

            try
            {
                if (newObject != null)
                {
                    newObject.Dock = DockStyle.Fill;
                    this.Width     = newObject.Width + 25;
                    this.Height    = newObject.Height + 25;
                    newObject.BringToFront();
                    newObject.Click += NewObject_Click;
                    Controls.Add(newObject);
                }
            }
            catch
            {
            }
        }