Exemple #1
0
        /// <summary>
        /// Adds a unit to the undo manager without executing it
        /// </summary>
        /// <param name="unit">The UndoUnit to add</param>
        void Add(UndoUnit <T> unit)
        {
            if (IsBlocked)
            {
                throw new InvalidOperationException("Attempt to add undo operation while blocked");
            }

            if (CurrentGroup != null)
            {
                CurrentGroup.Add(unit);
            }
            else
            {
                RemoveAllRedoUnits();
                _units.Add(unit);

                // Limit undo stack size
                if (_units.Count > _maxUnits)
                {
                    // Update unmodified index
                    if (_unmodifiedPos >= 0)
                    {
                        _unmodifiedPos--;
                    }

                    // Remove
                    _units.RemoveAt(0);
                }
                else
                {
                    _currentPos++;
                }
            }
        }
Exemple #2
0
        public void AddRawFileJobsToCurrentGroup(string file)
        {
            ProcessItem item = new IdNamePairProcessItem()
            {
                Name = file
            };

            CurrentGroup.Add(item);
        }
        private void RefreshCurrentGroup()
        {
            CurrentGroup.Clear();
            int startIndex = _pageIndex * PAGE_SIZE;

            for (int i = 0; i < PAGE_SIZE; i++)
            {
                if (startIndex + i < _itemList.Count)
                {
                    CurrentGroup.Add(_itemList[startIndex + i]);
                    if (startIndex + i == _selectedIndex)
                    {
                        _itemList[startIndex + i].Selected = true;
                    }
                }
            }
        }
Exemple #4
0
        public void AddJobToCurrentGroup()
        {
            int count = 0;

            for (int i = 0; i < 1000; i++)
            {
                {
                    string newName = "Job" + "_" + count;
                    if (CurrentGroup.FirstOrDefault(n => n.Name.Equals(newName)) == null)
                    {
                        CurrentGroup.Add(new IdNamePairProcessItem()
                        {
                            Name = newName
                        });
                        break;
                    }
                }
                count++;
            }
        }
Exemple #5
0
 public void AddRawFileJobsToCurrentGroup(IdNamePairProcessItem item)
 {
     if (item.CrtDepthLevel == 3)
     {
         ProcessItem addedItem = new IdNamePairProcessItem()
         {
             Name          = item.Name,
             MeasurementId = item.MeasurementId
         };
         CurrentGroup.Add(addedItem);
     }
     else if (item.CrtDepthLevel == 2)
     {
         foreach (IdNamePairProcessItem projectItem in item.Children)
         {
             ProcessItem addedItem = new IdNamePairProcessItem()
             {
                 Name          = projectItem.Name,
                 MeasurementId = projectItem.MeasurementId
             };
             CurrentGroup.Add(addedItem);
         }
     }
     else if (item.CrtDepthLevel == 1)
     {
         foreach (IdNamePairProcessItem projectItem in item.Children)
         {
             foreach (IdNamePairProcessItem chilIten in projectItem.Children)
             {
                 ProcessItem addedItem = new IdNamePairProcessItem()
                 {
                     Name          = chilIten.Name,
                     MeasurementId = chilIten.MeasurementId
                 };
                 CurrentGroup.Add(addedItem);
             }
         }
     }
 }
Exemple #6
0
 public void AddTweener(Tweener tweener)
 {
     CurrentGroup.Add(tweener);
 }
Exemple #7
0
        public static bool FixByComplexAdjust(List <Airline> airlineList)
        {
            //将所有的航班分组(假设没有从台风飞到台风的航班,如果有的话,暂时不处理)
            //分组的规则为,第一个是起飞是台风关联航班,最后一个结尾是台风关联航班
            var            airlinegrpList = new List <List <Airline> >();
            var            IsGroupStarted = false;
            List <Airline> CurrentGroup   = null;

            for (int i = 0; i < airlineList.Count; i++)
            {
                if (CheckCondition.TyphoonAirport.Contains(airlineList[i].StartAirPort))
                {
                    //起飞是台风航班
                    CurrentGroup = new List <Airline>();
                    airlinegrpList.Add(CurrentGroup);
                    CurrentGroup.Add(airlineList[i]);
                    IsGroupStarted = true;
                }
                else
                {
                    if (CheckCondition.TyphoonAirport.Contains(airlineList[i].EndAirPort))
                    {
                        //降落是台风航班
                        if (IsGroupStarted)
                        {
                            //分组开始状态
                            CurrentGroup.Add(airlineList[i]);
                            IsGroupStarted = false;
                        }
                        else
                        {
                            //分组未开始状态(第一个航班降落在台风机场的情况)
                            CurrentGroup = new List <Airline>();
                            airlinegrpList.Add(CurrentGroup);
                            CurrentGroup.Add(airlineList[i]);
                        }
                    }
                    else
                    {
                        //起飞降落都是台风航班
                        if (IsGroupStarted)
                        {
                            //分组开始状态
                            CurrentGroup.Add(airlineList[i]);
                        }
                        else
                        {
                            //普通航班
                            CurrentGroup = new List <Airline>();
                            airlinegrpList.Add(CurrentGroup);
                            CurrentGroup.Add(airlineList[i]);
                        }
                    }
                }
            }
            var firstTyphoonGroupId = -1;

            for (int i = 0; i < airlinegrpList.Count; i++)
            {
                foreach (var airline in airlinegrpList[i])
                {
                    //判断被台风影响的航班
                    var Problem = CheckCondition.IsExistTyphoon(airline);
                    if (Problem.DetailType == ProblemType.TyphoonLand)
                    {
                        firstTyphoonGroupId = i;
                        break;
                    }
                }
                if (firstTyphoonGroupId != -1)
                {
                    break;
                }
            }
            //索引检查
            if (firstTyphoonGroupId >= airlinegrpList.Count - 1)
            {
                return(false);
            }
            if (firstTyphoonGroupId <= 0)
            {
                return(false);
            }
            // Console.WriteLine("台风开始组号:[" + firstTyphoonGroupId + "]");
            var firstAirline = airlinegrpList[firstTyphoonGroupId + 1].First();
            var lastAirline  = airlinegrpList[firstTyphoonGroupId - 1].Last();

            //台风上一组的结束和台风下一组的开始能否衔接?
            if (lastAirline.EndAirPort != firstAirline.StartAirPort)
            {
                return(false);
            }
            //下一组的第一个航班是否可以通过提早飞行而成功?
            firstAirline.Problem = GetProblem(firstAirline);
            //检查之前,需要正确设置上一个航班的信息!
            firstAirline.PreviousAirline = lastAirline;
            if (firstAirline.Problem.DetailType == ProblemType.None || firstAirline.Problem.DetailType == ProblemType.TyphoonStay)
            {
                return(false);
            }
            if (!FixTyphoonTakeOffByChangeTakeOffTime(firstAirline))
            {
                return(false);
            }
            //尝试将第一组台风影响航班取消
            foreach (var item in airlinegrpList[firstTyphoonGroupId])
            {
                item.FixMethod = enmFixMethod.Cancel;
            }
            return(CoreAlgorithm.AdjustAirLineList(airlineList));
        }