Exemple #1
0
        /////<summary>注册可用项,注:已不使用,改为自动获取</summary>
        //public void regCanCreateItem(Type type, string dbopkey)
        //{
        //    pLayer tmplayer = new pLayer(null);
        //    DNDesc dn = new DNDesc() { type = type };
        //    PowerBasicObject o = dn.CreateByType(tmplayer);
        //    DescData dd = o.busiDesc as DescData;
        //    dn.sort = dd.objCategory.ToString();
        //    dn.name = type.Name;
        //    dn.dbopkey = dbopkey;
        //    dn.icon = dd.icon;

        //    dn.info = string.Format("{0}({1})", dbopkey, dn.name);
        //    dndescs.Add(dn);

        //}


        void reg(string fulltypename, string dbopkey)
        {
            pLayer tmplayer = new pLayer(null);
            DNDesc dn       = new DNDesc()
            {
                typefullname = fulltypename
            };
            PowerBasicObject o  = dn.CreateByTypeName(tmplayer);
            DescData         dd = o.busiDesc as DescData;

            dn.sort    = dd.objCategory.ToString();
            dn.type    = o.GetType();
            dn.name    = dbopkey; //dn.type.Name;
            dn.dbopkey = dbopkey;
            dn.icon    = dd.icon;

            dn.info = string.Format("{0}({1})", dbopkey, dn.type.Name);//dn.name);
            dndescs.Add(dn);
        }
Exemple #2
0
        ///<summary>创建新对象</summary>
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (tree.SelectedItem != null)
            {
                DNDesc dnd = tree.SelectedItem as DNDesc;

                //处理对象的层
                pLayer           nlayer = distnet.addLayer(dnd.sort);
                PowerBasicObject obj    = dnd.CreateByType(nlayer);
                obj.id   = MyClassLibrary.helper.getGUID();
                obj.name = "新对象";

                //Point? pnttmp = distnet.scene.camera.getScreenCenterGeo();
                Point?pnttmp = distnet.scene.camera.getScreenCenter();

                if (pnttmp != null)
                {
                    Point pnt = (Point)pnttmp;
                    if (obj is pSymbolObject) //新增的图元
                    {
                        (obj as pSymbolObject).location = pnt.ToString();
                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());
                        if (refobj != null)
                        {
                            (obj as pSymbolObject).scaleX = (refobj as pSymbolObject).scaleX;
                            (obj as pSymbolObject).scaleY = (refobj as pSymbolObject).scaleY;
                            (obj as pSymbolObject).scaleZ = (refobj as pSymbolObject).scaleZ;
                            (obj as pSymbolObject).color  = (refobj as pSymbolObject).color;
                            (obj as pSymbolObject).isH    = true;
                        }
                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else if (obj is pPowerLine)                     //新增的线路
                    {
                        if (distnet.scene.coordinateManager.Enable) //启用了坐标转换
                        {
                            (obj as pPowerLine).strPoints = String.Format("{0} {1}", pnt, new Point(pnt.X - 50, pnt.Y - 50));
                        }
                        else  //缺省的经纬坐标
                        {
                            (obj as pPowerLine).strPoints = String.Format("{0} {1}", pnt, new Point(pnt.X - 0.005, pnt.Y - 0.005));
                        }

                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());

                        if (refobj != null)
                        {
                            (obj as pPowerLine).thickness  = (refobj as pPowerLine).thickness;
                            (obj as pPowerLine).color      = (refobj as pPowerLine).color;
                            (obj as pPowerLine).arrowColor = (refobj as pPowerLine).arrowColor;
                            (obj as pPowerLine).arrowSize  = (refobj as pPowerLine).arrowSize;
                        }
                        else
                        {
                            (obj as pPowerLine).thickness  = 0.1f;
                            (obj as pPowerLine).color      = Colors.Red;;
                            (obj as pPowerLine).arrowColor = Colors.Blue;
                            (obj as pPowerLine).arrowSize  = 0.2f;
                        }

                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else if (obj is pArea) //新增的区域
                    {
                        (obj as pArea).strPoints = String.Format("{0} {1} {2}", pnt, new Point(pnt.X - 0.005, pnt.Y - 0.005), new Point(pnt.X, pnt.Y - 0.005));
                        PowerBasicObject refobj = distnet.findFirstObj(obj.GetType());
                        if (refobj != null)
                        {
                            (obj as pArea).color = (refobj as pArea).color;
                        }
                        obj.DBOPKey = dnd.dbopkey;
                        obj.createAcntData();
                        (obj.busiAccount as AcntDataBase).id   = obj.id;
                        (obj.busiAccount as AcntDataBase).name = obj.name;
                        nlayer.AddObject(obj);
                        //(obj as pSymbolObject).aniTwinkle.doCount = 10;
                        //(obj as pSymbolObject).aniTwinkle.isDoAni = true;
                        //(obj as pSymbolObject).AnimationBegin(pSymbolObject.EAnimationType.闪烁);
                        distnet.scene.UpdateModel();
                    }
                    else
                    {
                        return; //提前返回
                    }
                    // 置界面
                    editobj               = obj;
                    obj.modifyStatus      = EModifyStatus.新增;
                    obj.color             = Colors.White;
                    isNewObject           = true;
                    pgAcnt.SelectedObject = editobj.busiAccount;

                    //btnCreate.IsEnabled = false;
                    btnDelete.IsEnabled = true;
                    btnSave.IsEnabled   = isModify = true;
                    //btnExit.IsEnabled = true;
                }
            }
        }