Ejemplo n.º 1
0
        private void panel1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
            var primTypeName = e.Data.GetData(typeof(string)) as string;
            var primCreator  = DevPrimsFactoryManager.Instance.FindCreator(primTypeName);

            if (primCreator == null)
            {
                MessageBox.Show("未找到该设备创建器ICreator,请重新加载该设备Dll!");
            }
            else
            {
                var primDisplay = new PrimDisplay();
                primDisplay.UIPrimIcon      = primCreator.PrimProps.Icon;
                primDisplay.UIPrimName      = primCreator.PrimProps.DisplayName + _createIdx;
                primDisplay.UIPrimGroup     = primCreator.PrimProps.DisplayGroup;
                primDisplay.UIPrimType      = primCreator.PrimProps.DisplayName;
                primDisplay.panel1.AutoSize = false;
                primDisplay.panel1.Size     = new Size(56, 52);
                var pPoint = PointToClient(MousePosition);
                primDisplay.Location = new Point(pPoint.X - 26, pPoint.Y - 26);
                _curPrimDisplay      = primDisplay;
                splitContainer1.Panel1.Controls.Add(primDisplay);
            }
        }
Ejemplo n.º 2
0
        public void CreatePrimDisplay(IPrim prim)
        {
            var primCreator = DevPrimsFactoryManager.Instance.FindCreator(prim.PrimTypeName);

            if (primCreator == null)
            {
                MessageBox.Show($"未找到该设备{prim.PrimTypeName}创建器ICreator,请重新加载该设备Dll!");
                return;
            }

            var primDisplay = new PrimDisplay();

            primDisplay.UIPrimIcon                  = primCreator.PrimProps.Icon;
            primDisplay.UIPrimName                  = prim.Name;
            primDisplay.UIPrimGroup                 = primCreator.PrimProps.DisplayGroup;
            primDisplay.UIPrimType                  = primCreator.PrimProps.DisplayName;
            primDisplay.panel1.AutoSize             = false;
            primDisplay.panel1.Size                 = new Size(56, 52);
            primDisplay.UIPrimID                    = prim.PrimId;
            primDisplay.UIPrim                      = prim;
            primDisplay.PrimDisplayMenuClickEvent  += OnPrimDisplayMenuClickEvent;
            primDisplay.PrimDisplayPropertyChanged += OnPrimDisplayPropertyChanged;
            primDisplay.Dock = DockStyle.Top;
            splitContainer1.Panel1.Controls.Add(primDisplay);
            _primDisplayList.Add(primDisplay);

            if (OnAddPrim != null)
            {
                OnAddPrim(primDisplay.UIPrimGroup, primDisplay.UIPrimType, primDisplay.UIPrimName, primDisplay.UIPrimID);
            }
        }
Ejemplo n.º 3
0
        public void OnCreatePrim(string primName)
        {
            var primCreator = DevPrimsFactoryManager.Instance.FindCreator(primName);

            if (primCreator == null)
            {
                MessageBox.Show("未找到该设备创建器ICreator,请重新加载该设备Dll!");
                return;
            }

            var prim = DevPrimsFactoryManager.Instance.InvokeCreator(primName);

            if (prim == null)
            {
                MessageBox.Show("未找到该基元Prim,请重新加载该设备Dll!");
                return;
            }

            prim.PrimId = Guid.NewGuid();


            var primDisplay = new PrimDisplay();

            primDisplay.UIPrimIcon                  = primCreator.PrimProps.Icon;
            primDisplay.UIPrimName                  = primCreator.PrimProps.Name + _createIdx;
            primDisplay.UIPrimGroup                 = primCreator.PrimProps.DisplayGroup;
            primDisplay.UIPrimType                  = primCreator.PrimProps.DisplayName;
            primDisplay.panel1.AutoSize             = false;
            primDisplay.panel1.Size                 = new Size(56, 52);
            primDisplay.UIPrimID                    = prim.PrimId;
            primDisplay.UIPrim                      = prim;
            primDisplay.PrimDisplayMenuClickEvent  += OnPrimDisplayMenuClickEvent;
            primDisplay.PrimDisplayPropertyChanged += OnPrimDisplayPropertyChanged;
            primDisplay.Dock = DockStyle.Top;
            splitContainer1.Panel1.Controls.Add(primDisplay);
            _primDisplayList.Add(primDisplay);

            prim.Name         = primDisplay.UIPrimName;
            prim.PrimTypeName = primCreator.PrimProps.Name;
            DevPrimsManager.Instance.Prims.Add(prim);


            OnAddPrim?.Invoke(primDisplay.UIPrimGroup, primDisplay.UIPrimType, primDisplay.UIPrimName, primDisplay.UIPrimID);
            _createIdx++;
        }
Ejemplo n.º 4
0
 private void panel1_DragLeave(object sender, EventArgs e)
 {
     _curPrimDisplay = null;
 }