public void Execute()
 {
     _network.RemoveElements(_elements);
     _network.RemoveVerticalLines(_vlines);
     InstructionCommentManager.RaiseMappedMessageChangedEvent();
     //_network.INVModel.Setup(_network);
 }
        public void Undo()
        {
            _network.RowCount = _oldRowCount;
            var movedElements = _network.GetElements().Where(e => e.Y >= _startRow).ToList().OrderBy(x => { return(x.Y); }).Reverse();
            var movedVLines   = _network.GetVerticalLines().Where(e => e.Y >= _startRow).ToList().OrderBy(x => { return(x.Y); }).Reverse();

            foreach (var ele in movedElements)
            {
                _network.RemoveEle(ele.X, ele.Y);
                ele.Y += _count;
                _network.ReplaceEle(ele);
            }
            foreach (var vline in movedVLines)
            {
                _network.RemoveVLine(vline.X, vline.Y);
                vline.Y += _count;
                _network.ReplaceVLine(vline);
            }
            _network.ReplaceElements(_removedElements);
            _network.ReplaceVerticalLines(_removedVerticalLines);
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
            if (_oldarea != null)
            {
                _oldarea.Select(_network);
            }
        }
예제 #3
0
        public static LadderNetworkViewModel CreateLadderNetworkByXElement(XElement xEle, LadderDiagramViewModel parent)
        {
            LadderNetworkViewModel result = new LadderNetworkViewModel(parent, int.Parse(xEle.Attribute("Number").Value));

            result.RowCount = int.Parse(xEle.Attribute("RowCount").Value);
            if (xEle.Attribute("IsMasked") != null)
            {
                result.IsMasked = bool.Parse(xEle.Attribute("IsMasked").Value);
            }
            else
            {
                result.IsMasked = false;
            }
            result.NetworkBrief       = xEle.Element("Brief").Value;
            result.NetworkDescription = xEle.Element("Description").Value;

            XElement contentNode = xEle.Element("LadderContent");

            foreach (var instEle in CreateLadderElementsByXElement(contentNode))
            {
                result.ReplaceElement(instEle);
            }
            foreach (var vline in CreateLadderVertialLineByXElement(contentNode))
            {
                result.ReplaceVerticalLine(vline);
            }
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
            return(result);
        }
 public void Undo()
 {
     _network.ReplaceElements(_elements);
     _network.ReplaceVerticalLines(_vlines);
     InstructionCommentManager.RaiseMappedMessageChangedEvent();
     if (_area != null)
     {
         _area.Select(_network);
     }
 }
 public virtual void Undo()
 {
     _network.RowCount = _oldRowCount;
     _network.RemoveElements(_elements);
     _network.RemoveVerticalLines(_vlines);
     _network.ReplaceElements(_oldelements);
     _network.ReplaceVerticalLines(_oldvlines);
     InstructionCommentManager.RaiseMappedMessageChangedEvent();
     _oldarea?.Select(_network);
     if (_oldarea == null)
     {
         _area?.Select(_network);
     }
 }
        public virtual void Execute()
        {
            _oldRowCount = _network.RowCount;
            int tempRowCount = ComputeRowCount();

            if (_network.RowCount < tempRowCount)
            {
                _network.RowCount = tempRowCount;
            }
            _network.RemoveElements(_oldelements);
            _network.RemoveVerticalLines(_oldvlines);
            _network.ReplaceElements(_elements);
            _network.ReplaceVerticalLines(_vlines);
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
            if (_area != null)
            {
                _area.Select(_network);
            }
        }
        public void Redo()
        {
            _network.RemoveElements(_removedElements);
            _network.RemoveVerticalLines(_removedVerticalLines);
            var movedElements = _network.GetElements().Where(e => e.Y > _startRow + _count - 1).ToList().OrderBy(x => { return(x.Y); });
            var movedVLines   = _network.GetVerticalLines().Where(e => e.Y > _startRow + _count - 1).ToList().OrderBy(x => { return(x.Y); });

            foreach (var ele in movedElements)
            {
                _network.RemoveEle(ele.X, ele.Y);
                ele.Y -= _count;
                _network.ReplaceEle(ele);
            }
            foreach (var vline in movedVLines)
            {
                _network.RemoveVLine(vline.X, vline.Y);
                vline.Y -= _count;
                _network.ReplaceVLine(vline);
            }
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
            _oldRowCount = _network.RowCount;
            if (_count == _network.RowCount)
            {
                _network.RowCount = 1;
            }
            else
            {
                _network.RowCount -= _count;
            }
            _network.AcquireSelectRect();
            LadderDiagramViewModel ldvmodel = _network.LDVModel;

            ldvmodel.SelectionRect.X = 0;
            ldvmodel.SelectionRect.Y = (_startRow < _network.RowCount ? _startRow : _startRow - 1);
            ldvmodel.ProjectModel.IFacade.NavigateToNetwork(
                new NavigateToNetworkEventArgs(
                    _network.NetworkNumber,
                    ldvmodel.ProgramName,
                    ldvmodel.SelectionRect.X,
                    ldvmodel.SelectionRect.Y));
        }
예제 #8
0
        public static ErrorMessage Execute(LadderDiagramViewModel ladderDiagram)
        {
            ErrorType error = ErrorType.None;

            foreach (var network in ladderDiagram.GetNetworks().Where(x => { return(!x.IsMasked); }))
            {
                if (!network.ladderExpander.IsExpand)
                {
                    network.ladderExpander.IsExpand = true;
                }
                error = CheckNetwork(network);
                if (error != ErrorType.None)
                {
                    List <LadderNetworkViewModel> templist = new List <LadderNetworkViewModel>();
                    templist.Add(network);
                    InstructionCommentManager.RaiseMappedMessageChangedEvent();
                    return(new ErrorMessage(error, templist));
                }
                else
                {
                    network.InitializeLadderLogicModules();
                    if (network.IsSingleSelected())
                    {
                        network.ReleaseSelectRect();
                    }
                    LadderGraphRelocationModule.Execute(network);
                }
            }
            //ladderDiagram.IsModify = false;
            if (!CheckProgramControlInstructions(ladderDiagram))
            {
                error = ErrorType.InstPair;
            }
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
            return(new ErrorMessage(error, null));
        }
예제 #9
0
        static private void Read(LadderNetworkViewModel lnvmodel)
        {
            int sz = ReadE32();

            sz += eid;
            if ((option & OPTION_COMMENT) != 0)
            {
                lnvmodel.NetworkBrief = ReadTextE8();
            }
            lnvmodel.RowCount = edata[eid++];
            int le = (lnvmodel.RowCount * GlobalSetting.LadderXCapacity) >> 2;

            for (int y = 0; y < lnvmodel.RowCount; y++)
            {
                for (int x = 0; x < GlobalSetting.LadderXCapacity; x++)
                {
                    int p  = y * GlobalSetting.LadderXCapacity + x;
                    int p1 = p >> 2;
                    int p2 = (p & 3) * 2;
                    if ((edata[eid + p1] & (1 << p2)) != 0)
                    {
                        HorizontalLineViewModel hlvmodel = new HorizontalLineViewModel();
                        hlvmodel.X = x; hlvmodel.Y = y;
                        lnvmodel.ReplaceElement(hlvmodel);
                    }
                    if ((edata[eid + p1] & (1 << (p2 + 1))) != 0)
                    {
                        VerticalLineViewModel vlvmodel = new VerticalLineViewModel();
                        vlvmodel.X = x; vlvmodel.Y = y;
                        lnvmodel.ReplaceVerticalLine(vlvmodel);
                    }
                }
            }
            while (eid < sz)
            {
                BaseViewModel bvmodel = null;
                int           x       = edata[eid++];
                int           y       = edata[eid++];
                int           catalog = LadderInstViewModelPrototype.GetCatalogFromOrder(edata[eid++]);
                bvmodel   = LadderInstViewModelPrototype.Clone(catalog);
                bvmodel.X = x;
                bvmodel.Y = y;
                for (int i = 0; i < bvmodel.Model.ParaCount; i++)
                {
                    IValueModel ivmold = bvmodel.Model.GetPara(i);
                    IValueModel ivmnew = regs[ReadE16()];
                    if (ivmnew is DWordValue || ivmnew is DDoubleWordValue || ivmnew is DFloatValue)
                    {
                        if (ivmold is WordValue)
                        {
                            ivmnew = new DWordValue(ivmnew.Index, ivmnew.Offset);
                        }
                        if (ivmold is DoubleWordValue)
                        {
                            ivmnew = new DDoubleWordValue(ivmnew.Index, ivmnew.Offset);
                        }
                        if (ivmold is FloatValue)
                        {
                            ivmnew = new DFloatValue(ivmnew.Index, ivmnew.Offset);
                        }
                    }
                    bvmodel.Model.SetPara(i, ivmnew);
                }
                lnvmodel.ReplaceElement(bvmodel);
            }
            InstructionCommentManager.RaiseMappedMessageChangedEvent();
        }
예제 #10
0
 /// <summary>
 /// 撤销
 /// </summary>
 public void Undo()
 {
     lnvmodel.ReplaceElement(BVM_old);
     Element.BVModel = BVM_old;
     InstructionCommentManager.RaiseMappedMessageChangedEvent();
 }
예제 #11
0
 /// <summary>
 /// 执行
 /// </summary>
 public void Execute()
 {
     lnvmodel.ReplaceElement(BVM_new);
     Element.BVModel = BVM_new;
     InstructionCommentManager.RaiseMappedMessageChangedEvent();
 }