Exemplo n.º 1
0
        private void barEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            string    uid     = treeList1.FocusedNode["UID"].ToString();
            PowerLine obj     = Services.BaseService.GetOneByKey <PowerLine>(uid);
            PowerLine objCopy = new PowerLine();

            DataConverter.CopyTo <PowerLine>(obj, objCopy);

            FrmPowerLineDialog dlg = new FrmPowerLineDialog();

            dlg.Object = objCopy;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataConverter.CopyTo <PowerLine>(objCopy, obj);
            treeList1.FocusedNode.SetValue("PowerName", obj.PowerName);
            treeList1.FocusedNode.SetValue("Remark", obj.Remark);
        }
Exemplo n.º 2
0
 protected override void OnEnable()
 {
     if (PowerLine != null && PowerLine.getSimulation() == null)
     {
         GetSimulation().add(PowerLine);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            PowerLine obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //创建对象的一个副本
            PowerLine objCopy = new PowerLine();

            DataConverter.CopyTo <PowerLine>(obj, objCopy);

            //执行修改操作
            using (FrmPowerLineDialog dlg = new FrmPowerLineDialog())
            {
                dlg.Object = objCopy;                   //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <PowerLine>(objCopy, obj);
            //刷新表格
            gridControl.RefreshDataSource();
        }
        public PowerLine Create(PowerLine powerLine)
        {
            _context.PowerLinesData.Add(powerLine);
            _context.SaveChanges();

            return(powerLine);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            PowerLine obj = new PowerLine();

            //执行添加操作
            using (FrmPowerLineDialog dlg = new FrmPowerLineDialog())
            {
                dlg.IsCreate = true;                    //设置新建标志
                dlg.Object   = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //将新对象加入到链表中
            ObjectList.Add(obj);

            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
Exemplo n.º 6
0
 public void Join(PowerLine powerLine)
 {
     joined      = true;
     this.target = null;
     AddPoint(powerLine.transform.position);
     powerLine.TurnOn();
 }
Exemplo n.º 7
0
 private void Awake()
 {
     _RB          = GetComponent <Rigidbody2D>();
     _PL          = powerLine.GetComponent <PowerLine>();
     _SL          = shotLine.GetComponent <PowerLine>();
     _Animator    = GetComponent <Animator>();
     mainCam      = FindObjectOfType <Camera>();
     _InputSource = GetComponent <InputSource>();
 }
Exemplo n.º 8
0
    public int getReference(PowerLine s)
    {
        int i = 7;

        while (i >= 0 && connections[i] != s)
        {
            i--;
        }
        return(i);
    }
Exemplo n.º 9
0
 public void PowerLineJoined(PowerLine a, PowerLine b)
 {
     a.Join(b);
     joints[a] = b;
     if (CheckIfAllConnected())
     {
         allConnected = true;
         GameOver();
     }
 }
Exemplo n.º 10
0
    public override void turnOn(PowerLine first)
    {
        bool aux = true;

        foreach (PowerLine p in connections)
        {
            if (p != null)
            {
                aux &= p.on;
            }
        }

        if (aux)
        {
            turnButtonOn();
        }
    }
Exemplo n.º 11
0
 public virtual void turnOff(PowerLine first)
 {
     if (first != this)
     {
         if (on)
         {
             on = false;
             foreach (Image spr in sprs)
             {
                 spr.color = Color.clear;
             }
             foreach (PowerLine p in connections)
             {
                 if (p != null && p.gameObject.activeInHierarchy)
                 {
                     p.turnOff(first);
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            PowerLine obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Delete <PowerLine>(obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //记住当前焦点行索引
            int iOldHandle = this.gridView.FocusedRowHandle;

            //从链表中删除
            ObjectList.Remove(obj);
            //刷新表格
            gridControl.RefreshDataSource();
            //设置新的焦点行索引
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
Exemplo n.º 13
0
        private void barAdd1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string parentid = "";

            if (treeList1.FocusedNode == null)
            {
                return;
            }
            parentid = treeList1.FocusedNode["UID"].ToString();
            PowerLine obj = new PowerLine();

            obj.ParentID = parentid;
            FrmPowerLineDialog dlg = new FrmPowerLineDialog();

            dlg.Object   = obj;
            dlg.IsCreate = true;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }
Exemplo n.º 14
0
 public void refresh()
 {
     PowerManager.instance.turnOffCircuit();
     connections = new PowerLine[8];
     for (int i = 0; i < 8; i++)
     {
         if (realLinks.Contains(i))
         {
             connections[i] = allLinks[i];
             if (allLinks[i] != null)
             {
                 allLinks[i].connections[references[i]] = this;
             }
         }
         else
         {
             if (allLinks[i] != null)
             {
                 allLinks[i].connections[references[i]] = null;
             }
         }
     }
     PowerManager.instance.turnOnCircuit();
 }
 public PowerLine Post(PowerLine powerLine)
 {
     return(_repository.Create(powerLine));
 }
Exemplo n.º 16
0
 public override void turnOff(PowerLine first)
 {
     sprs[0].sprite = offSprite;
     sprs[0].color  = Color.white;
 }