public LadderDiagramReplaceNetworksCommand(
     LadderDiagramViewModel ld,
     LadderNetworkViewModel replacedNet, IEnumerable <LadderNetworkViewModel> removedNets, int index,
     NetworkChangeElementArea area = null, NetworkChangeElementArea oldarea = null)
 {
     _ladderDiagram    = ld;
     _replacedNetworks = new SortedSet <LadderNetworkViewModel>()
     {
         replacedNet
     };
     _removedNetworks = new SortedSet <LadderNetworkViewModel>(removedNets);
     _index           = index;
     _oldarea         = oldarea;
     _area            = area;
     if (_oldarea == null)
     {
         _oldarea = NetworkChangeElementArea.Create(
             _ladderDiagram, _removedNetworks);
     }
     if (_area == null)
     {
         _area = NetworkChangeElementArea.Create(
             _ladderDiagram, _replacedNetworks);
     }
 }
 public NetworkReplaceElementsCommand(
     LadderNetworkViewModel network,
     IEnumerable <BaseViewModel> elements,
     IEnumerable <BaseViewModel> oldelements,
     NetworkChangeElementArea area    = null,
     NetworkChangeElementArea oldarea = null)
 {
     _network     = network;
     _elements    = elements;
     _oldelements = oldelements;
     _vlines      = new VerticalLineViewModel[] { };
     _oldvlines   = new VerticalLineViewModel[] { };
     _area        = area;
     _oldarea     = oldarea;
     if (_area == null)
     {
         _area = NetworkChangeElementArea.Create(
             _network, _elements, _vlines);
     }
     if (_oldarea == null)
     {
         _oldarea = NetworkChangeElementArea.Create(
             _network, _oldelements, _oldvlines);
     }
 }
示例#3
0
        static private void Analyze(
            LadderNetworkViewModel lnvmodel,
            BaseViewModel bvmodel,
            ref NetworkChangeElementArea area)
        {
            int x = bvmodel.X;
            int y = bvmodel.Y;

            if (bvmodel is VerticalLineViewModel)
            {
                x++;
            }
            if (area == null)
            {
                area                    = new NetworkChangeElementArea();
                area.SU_Select          = SelectStatus.SingleSelected;
                area.SU_Cross           = CrossNetworkState.NoCross;
                area.NetworkNumberStart = lnvmodel.NetworkNumber;
                area.NetworkNumberEnd   = lnvmodel.NetworkNumber;
                area.X1                 = area.X2 = x;
                area.Y1                 = area.Y2 = y;
            }
            else
            {
                area.SU_Select = SelectStatus.MultiSelected;
                area.X1        = Math.Min(area.X1, x);
                area.X2        = Math.Max(area.X2, x);
                area.Y1        = Math.Min(area.Y1, y);
                area.Y2        = Math.Max(area.Y2, y);
            }
        }
示例#4
0
        public NetworkChangeElementArea Clone()
        {
            XElement xele = new XElement("Area");

            this.Save(xele);
            NetworkChangeElementArea that = new NetworkChangeElementArea();

            that.Load(xele);
            return(that);
        }
 public LadderDiagramReplaceNetworksCommand(
     LadderDiagramViewModel ld,
     IEnumerable <LadderNetworkViewModel> replacedNets, IEnumerable <LadderNetworkViewModel> removedNets, int index,
     NetworkChangeElementArea area = null, NetworkChangeElementArea oldarea = null)
 {
     _ladderDiagram    = ld;
     _replacedNetworks = new SortedSet <LadderNetworkViewModel>(replacedNets);
     _removedNetworks  = new SortedSet <LadderNetworkViewModel>(removedNets);
     _index            = index;
     _oldarea          = oldarea;
     _area             = area;
 }
示例#6
0
        static public NetworkChangeElementArea Create(
            LadderDiagramViewModel ldvmodel,
            IEnumerable <LadderNetworkViewModel> lnvmodels)
        {
            NetworkChangeElementArea area = null;

            foreach (LadderNetworkViewModel lnvmodel in lnvmodels)
            {
                Analyze(ldvmodel, lnvmodel, ref area);
            }
            return(area);
        }
示例#7
0
 public NetworkReplaceBreakpointCommand(
     LadderNetworkViewModel network,
     IEnumerable <BreakpointRect> oldbreakpoints,
     IEnumerable <BreakpointRect> newbreakpoints,
     NetworkChangeElementArea oldarea = null,
     NetworkChangeElementArea newarea = null)
 {
     _network        = network;
     _oldbreakpoints = new HashSet <BreakpointRect>(oldbreakpoints);
     _newbreakpoints = new HashSet <BreakpointRect>(newbreakpoints);
     _oldarea        = oldarea;
     _newarea        = newarea;
 }
 public NetworkRemoveRowCommand(LadderNetworkViewModel network, int rowNumber)
 {
     _network                    = network;
     _rowNumber                  = rowNumber;
     _oldarea                    = new NetworkChangeElementArea();
     _oldarea.SU_Select          = SelectStatus.MultiSelected;
     _oldarea.SU_Cross           = CrossNetworkState.NoCross;
     _oldarea.NetworkNumberStart = network.NetworkNumber;
     _oldarea.NetworkNumberEnd   = _oldarea.NetworkNumberStart;
     _oldarea.X1                 = 0;
     _oldarea.X2                 = 11;
     _oldarea.Y1                 = rowNumber;
     _oldarea.Y2                 = _oldarea.Y1;
 }
 public NetworkRemoveElementsCommand(
     LadderNetworkViewModel network,
     IEnumerable <BaseViewModel> elements, IEnumerable <VerticalLineViewModel> vlines,
     NetworkChangeElementArea area = null)
 {
     _network  = network;
     _elements = elements;
     _vlines   = vlines;
     _area     = area;
     if (_area == null)
     {
         _area = NetworkChangeElementArea.Create(
             _network, _elements, _vlines);
     }
 }
 public void Undo()
 {
     _ladderDiagram.AddNetwork(_removedNetworks, _index, true);
     _ladderDiagram.RemoveNetworks(_replacedNetworks);
     _ladderDiagram.IDVModel.Setup(_ladderDiagram);
     _ladderDiagram.ClearModelMessageByNetwork(_replacedNetworks);
     _ladderDiagram.UpdateModelMessageByNetwork();
     if (_removedNetworks.Count() > 0)
     {
         _oldarea = NetworkChangeElementArea.Create(
             _ladderDiagram, _removedNetworks);
         LadderNetworkViewModel lnvmodel = _removedNetworks.First();
         _oldarea.Select(lnvmodel);
     }
 }
 public NetworkRemoveRowsCommand(LadderNetworkViewModel network, int startRow, int count)
 {
     _network                    = network;
     _startRow                   = startRow;
     _count                      = count;
     _oldarea                    = new NetworkChangeElementArea();
     _oldarea.SU_Select          = SelectStatus.MultiSelected;
     _oldarea.SU_Cross           = CrossNetworkState.NoCross;
     _oldarea.NetworkNumberStart = network.NetworkNumber;
     _oldarea.NetworkNumberEnd   = _oldarea.NetworkNumberStart;
     _oldarea.X1                 = 0;
     _oldarea.X2                 = 11;
     _oldarea.Y1                 = startRow;
     _oldarea.Y2                 = startRow + count - 1;
     _isEndRow                   = _network.RowCount - 1 == _oldarea.Y2;
 }
示例#12
0
        static public NetworkChangeElementArea Create(
            LadderNetworkViewModel lnvmodel,
            IEnumerable <BaseViewModel> elements,
            IEnumerable <VerticalLineViewModel> vlines)
        {
            NetworkChangeElementArea area = null;

            foreach (BaseViewModel bvmodel in elements)
            {
                Analyze(lnvmodel, bvmodel, ref area);
            }
            foreach (VerticalLineViewModel vlvmodel in vlines)
            {
                Analyze(lnvmodel, vlvmodel, ref area);
            }
            return(area);
        }
        public LadderDiagramMoveNetworkCommand(
            LadderDiagramViewModel _ldvmodel, LadderNetworkViewModel _lnvmodel, int _number)
        {
            ldvmodel   = _ldvmodel;
            lnvmodel   = _lnvmodel;
            number_old = lnvmodel.NetworkNumber;
            number_new = _number;

            area_old                    = new NetworkChangeElementArea();
            area_old.SU_Select          = SelectStatus.MultiSelected;
            area_old.SU_Cross           = CrossNetworkState.NoCross;
            area_old.NetworkNumberStart = number_old;
            area_old.NetworkNumberEnd   = number_old;
            area_old.X1                 = 0;
            area_old.Y1                 = 0;
            area_old.X2                 = GlobalSetting.LadderXCapacity - 1;
            area_old.Y2                 = lnvmodel.RowCount - 1;
            area_new                    = area_old.Clone();
            area_new.NetworkNumberStart = number_new - (number_new > number_old ? 1 : 0);
            area_new.NetworkNumberEnd   = area_new.NetworkNumberStart;
        }
示例#14
0
 static private void Analyze(
     LadderDiagramViewModel ldvmodel,
     LadderNetworkViewModel lnvmodel,
     ref NetworkChangeElementArea area)
 {
     if (area == null)
     {
         area                    = new NetworkChangeElementArea();
         area.SU_Select          = SelectStatus.MultiSelected;
         area.SU_Cross           = CrossNetworkState.CrossDown;
         area.NetworkNumberStart = lnvmodel.NetworkNumber;
         area.NetworkNumberEnd   = lnvmodel.NetworkNumber;
     }
     else
     {
         area.NetworkNumberStart = Math.Min(
             area.NetworkNumberStart,
             lnvmodel.NetworkNumber);
         area.NetworkNumberEnd = Math.Max(
             area.NetworkNumberEnd,
             lnvmodel.NetworkNumber);
     }
 }