Beispiel #1
0
        public AddAction Add()
        {
            var addAction = new AddAction(this);

            PrintHand();
            Console.WriteLine("Select cards to attack. Press 0 to select another action");
            var input = Console.ReadLine();

            if (string.IsNullOrEmpty(input))
            {
                return(addAction);
            }
            var selected = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var result   = new List <Card>();

            foreach (var s in selected)
            {
                int res;
                if (int.TryParse(s, out res))
                {
                    if (res <= 0 && res <= Hand.Count)
                    {
                        return(null);
                    }
                    result.Add(Hand[res - 1]);
                }
            }
            if (!addAction.AddCards(result))
            {
                Console.WriteLine("You can't select these cards");
                return(Add());
            }
            return(addAction);
        }
Beispiel #2
0
 private void AddToList(bool removeOld, object old)
 {
     if (removeOld)
     {
         RemoveAction.Invoke(Target.Value, (TElement)old);
     }
     AddAction.Invoke(Target.Value, Value.Value);
 }
Beispiel #3
0
 public MetaTriggerData(string name, List <MetaActionData> allowedActions, System.Type triggerType, GetCreator creator, AddAction addAction, GetActions getActions)
 {
     this.name           = name;
     this.triggerType    = triggerType;
     this.allowedActions = allowedActions;
     this.creator        = creator;
     this.addAction      = addAction;
     this.getActions     = getActions;
 }
        private void BtnNew_Click(object sender, RoutedEventArgs e)
        {
            AddAction addWebActionDialog = new AddAction(availableActions, availableWebBehaviours);

            addWebActionDialog.ShowDialog();
            if (addWebActionDialog.WebAction != null)
            {
                webActions.Add(addWebActionDialog.WebAction);
            }
        }
Beispiel #5
0
        public void StructCloneTest()
        {
            var original = new AddAction()
            {
                amount = 5
            };
            var cloned = original.Copy();

            Assert.AreEqual(original, cloned);
            Assert.AreNotSame(original, cloned);
        }
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            AddAction editWebActionDialog = new AddAction(availableActions, availableWebBehaviours, true);

            editWebActionDialog.WebAction = (Action)lsbWebActions.SelectedItem;
            editWebActionDialog.ShowDialog();
            if (editWebActionDialog.WebAction != null)
            {
                webActions[webActions.IndexOf((Action)lsbWebActions.SelectedItem)] = editWebActionDialog.WebAction;
            }
        }
Beispiel #7
0
            public void ShouldReturnTrue_WhenReducerFunctionIsRegistered()
            {
                var testSubject = new MultiActionReducerTestSubject();

                var addAction = new AddAction(1);

                Assert.True(testSubject.ShouldReduceStateForAction(addAction));

                var multiplyAction = new MultiplyAction(1);

                Assert.True(testSubject.ShouldReduceStateForAction(multiplyAction));
            }
Beispiel #8
0
    // Start is called before the first frame update
    void Awake()
    {
        controller = GetComponent <Controller2D>();
        sfx        = GetComponent <AudioSource>();
        if (sword)
        {
            sword.OnAttack     += AttackFreeze;
            sword.OnExitAttack += ExitAttackFreeze;
        }

        OnCollectCoin += AddCoins;
    }
        void ReleaseDesignerOutlets()
        {
            if (AddAction != null)
            {
                AddAction.Dispose();
                AddAction = null;
            }

            if (tableView != null)
            {
                tableView.Dispose();
                tableView = null;
            }
        }
Beispiel #10
0
            public void ShouldExecuteReducerFunction_WhenReducerFunctionIsRegisteredForActionType()
            {
                var testSubject = new MultiActionReducerTestSubject();

                var state     = new MultiActionReducerTestState(41);
                var addAction = new AddAction(1);

                state = testSubject.Reduce(state, addAction);
                Assert.Equal(42, state.Balance);

                state = new MultiActionReducerTestState(4);
                var multiplyAction = new MultiplyAction(10);

                state = testSubject.Reduce(state, multiplyAction);
                Assert.Equal(40, state.Balance);
            }
        private void addObject()
        {
            //Create object
            AddAction addAction = new AddAction("Prefab/Panel", new Vector3(0, 0, -8));

            base.managerListener.doAction(addAction);
            GameObject objectCreated = addAction.GameObject;

            //create tuve
            GameObject tubeObject = GameObject.Instantiate(Resources.Load("Prefab/Tube") as GameObject);
            TubeArrow  tube       = tubeObject.GetComponent <TubeArrow>();

            tube.link(select, objectCreated);

            this.nodeCourant.Add(new Node(addAction.GameObject));
        }
Beispiel #12
0
 public void AddLine(Line l)
 {
     if (!_working)
     {
         var ac = new AddAction(l);
         if (pos != _actions.Count)
         {
             if (pos < 0)
             {
                 pos = 0;
             }
             _actions.RemoveRange(pos, _actions.Count - pos);
         }
         _actions.Add(ac);
         pos = _actions.Count;
     }
 }
Beispiel #13
0
        /**
         *  Create a new text panel and a arrow to do the link with
         *  the selected object.
         */
        private void addObject()
        {
            if (objectSelected == null)
            {
                return;
            }

            //Create object
            AddAction addAction = new AddAction("Prefab/Panel", new Vector3(0, 0, -8));

            base.managerListener.doAction(addAction);
            GameObject objectCreated = addAction.GameObject;

            //create tuve
            GameObject tubeObject = GameObject.Instantiate(Resources.Load("Prefab/Tube") as GameObject);
            TubeArrow  tube       = tubeObject.GetComponent <TubeArrow>();

            tube.link(objectSelected, objectCreated);
        }
Beispiel #14
0
        public SkypeContext()
        {
            Users = new ObservableCollection <SkypeUser>();

            TestCommand = new DelegateCommand(() =>
            {
                SkypeCommandLauncher.StartCall("echo123");
            });

            AddCommand = new DelegateCommand(() =>
            {
                AddAction?.Invoke();
            });

            RemoveCommand = new DelegateCommand(() =>
            {
                RemoveAction?.Invoke();
            });
        }
Beispiel #15
0
        public JsonResult OnPostAddItem([FromBody] AddAction addAction)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                SharedResult result = new SharedResult();

                string procedureName = !addAction.Size.HasValue ? "[AddDirectory]" : "[AddFile]";

                using (SqlCommand command = new SqlCommand("[dbo]." + procedureName, connection))
                {
                    command.CommandType    = CommandType.StoredProcedure;
                    command.CommandTimeout = 300;

                    command.Parameters.Add("@Name", SqlDbType.NVarChar);
                    command.Parameters["@Name"].Value = addAction.Name;

                    if (addAction.Size.HasValue)
                    {
                        command.Parameters.Add("@Size", SqlDbType.BigInt);
                        command.Parameters["@Size"].Value = addAction.Size.Value;
                    }

                    command.Parameters.Add("@IdParentDirectory", SqlDbType.Int);
                    command.Parameters["@IdParentDirectory"].Value = addAction.IdParentDirectory;

                    command.Parameters.Add("@ErrorText", SqlDbType.NVarChar);
                    command.Parameters["@ErrorText"].Direction = ParameterDirection.Output;
                    command.Parameters["@ErrorText"].Size      = 4000;

                    command.ExecuteNonQuery();

                    result.ErrorText = command.Parameters["@ErrorText"].Value.ToString();
                }
                connection.Close();

                return(new JsonResult(JsonConvert.SerializeObject(result)));
            }
        }
Beispiel #16
0
        private void Button_SaveClicked(object sender, EventArgs e)
        {
            var model = (CreditCard)BindingContext;

            if (Common.ModelIsNull <CreditCard>(model))
            {
                DependencyService.Get <IToast>().ShortAlert("不能有空值");
                return;
            }
            if (!(model.RepaymentDate >= 1 || model.RepaymentDate <= 31))
            {
                DependencyService.Get <IToast>().ShortAlert("还款日输入错误");
                return;
            }
            if (!(model.StatementDate >= 1 || model.StatementDate <= 31))
            {
                DependencyService.Get <IToast>().ShortAlert("账单日输入错误");
                return;
            }
            model.CardNumber = model.CardNumber.Trim();
            AddAction?.Invoke(BindingContext, e);
            DependencyService.Get <IToast>().ShortAlert("添加成功");
            Navigation.PopAsync(true);
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            var repositoryManagerApi = new RepositoryManagerApi();
            var emloyeesListAction   = new ShowEmployeesAction(repositoryManagerApi.GetEmployeeApi(), repositoryManagerApi.GetPositionApi(), repositoryManagerApi.GetRuleApi(),
                                                               repositoryManagerApi.GetOwerworkApi(), repositoryManagerApi.GetPaymentApi(), repositoryManagerApi.GetHolidayApi());
            var addAction = new AddAction(repositoryManagerApi.GetEmployeeApi(), repositoryManagerApi.GetPositionApi(), repositoryManagerApi.GetRuleApi(),
                                          repositoryManagerApi.GetOwerworkApi(), repositoryManagerApi.GetPaymentApi(), repositoryManagerApi.GetHolidayApi());
            var removeAction    = new RemoveAction(repositoryManagerApi.GetEmployeeApi(), repositoryManagerApi.GetPositionApi(), repositoryManagerApi.GetRuleApi());
            var calculateAction = new CalculateAction(repositoryManagerApi.GetCalculatorApi(), repositoryManagerApi.GetEmployeeApi());
            var demo            = new DemoDataGenerator(repositoryManagerApi);

            demo.Generate();

            new MenuBuilder()
            .Title("Main menu")
            .Repeatable()
            .Item("Show", emloyeesListAction)
            .Item("Calculate money and hourse", calculateAction)
            .Item("Add", addAction)
            .Item("Remove", removeAction)
            .Exit("Exit")
            .GetMenu()
            .Run();
        }
        public void onGamePadEvent(ref Event e)
        {
            if (writeMode)
            {
                updateWriteMode(ref e);
                print("writemode");
                return;
            }
            // Rename Action
            else if (UnityEngine.Input.GetKey(KeyCode.Joystick1Button1))             // A button
            {
                textMesh     = select.GetComponentInChildren <TextMesh>();
                renameAction = new RenameAction(textMesh);
                writeMode    = true;
            }
            else if (UnityEngine.Input.GetKey(KeyCode.Joystick1Button6))               // LT button
            {
                InputLeftControlAction();
            }
            else
            {
                if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button3))                         // Y button
                {
                    AddAction addAction = new AddAction(PrimitiveType.Cube, new Vector3(0, 0, -8));
                    base.managerListener.doAction(addAction);
                    print("action: add");

                    this.nodeCourant.Add(new Node(addAction.GameObject));
                }
                else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button2) && !deleteMode)                         // B button
                {
                    RemoveAction removeAction = new RemoveAction(ref this.nodeCourant);
                    base.managerListener.doAction(removeAction);
                    print("action: remove");

                    this.nodeCourant = removeAction.NodeCourant;

                    if (this.nodeCourant == null)
                    {
                        Select(instance);
                    }
                    else
                    {
                        Select(nodeCourant.Gameobject);
                    }
                    deleteMode = true;
                }
                else if (UnityEngine.Input.GetKeyUp(KeyCode.Joystick1Button2) && deleteMode)                         // B button
                {
                    deleteMode = false;
                }
                else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button5))                         // RB button
                {
                    base.managerListener.undoAction();
                    print("action: undo");
                }
                else if (UnityEngine.Input.GetKeyDown(KeyCode.Joystick1Button4))                         // LB button
                {
                    base.managerListener.redoAction();
                    print("action: redo");
                }
                else
                {
                    InputMoveAction();
                }
            }
        }
		//the logic to emit a single particle
		public void Emit(ParticleSystem system, ParticleSystemEmitData emit, int sourceIndex, float sourceIndexF, int step)
		{
			//need more capacity?
			if (particleCapacity == particles.Length)
				Array.Resize(ref this.particles, this.particles.Length * 2);
			uint index = particleCapacity++;

			//for profiling
			maxParticleCapacity = Math.Max(maxParticleCapacity, index);

			//find the step the particle will be removed on
			int stepIndex = emit.baseLifeTimeStep;
			if (emit.varianceTimeStep != 0)
				stepIndex += system.systemRandom.Next(emit.varianceTimeStep);
			stepIndex = Math.Max(1, stepIndex);

			//lifespan in steps
			int life = stepIndex;

			//remove step
			stepIndex = (stepIndex + step) & timeStepMask;

			//create the particle
			Particle particle = new Particle();
			particle.index = particleCapacityF++;

			particle.previousParticleIndexForTimeStep = uint.MaxValue;
			particle.nextParticleIndexForTimeStep = uint.MaxValue;
			particle.addActionIndex = addActionCount;

			if (timeSteps[stepIndex].count++ != 0)
			{
				//step isn't empty?
				uint previousFirst = timeSteps[stepIndex].firstParticleIndex;

				particle.nextParticleIndexForTimeStep = previousFirst;
				particles[previousFirst].previousParticleIndexForTimeStep = index;
			}

			//start of the linked list
			timeSteps[stepIndex].firstParticleIndex = index;

			particle.timeStepIndex = (ushort)stepIndex;
			//store
			this.particles[index] = particle;

			//create the addAction
			AddAction action = new AddAction();
			action.index = index;
			action.lifeSteps = (uint)life;
			action.indexF = particle.index;

			action.cloneFromIndex = sourceIndex;
			action.cloneFromIndexF = sourceIndexF;
			action.cloneTypeIndex = emit.emitFromTypeIndex;

			//if sourceIndex is -1, then this is a root level particle,
			//so it's positin is set by the application.

			if (sourceIndex == -1)
			{
				system.GetSpawnDetails(out action.spawnDetails);
			}

			typeEmitDependancy[emit.emitFromTypeIndex + 1] = true;
		
			//cannot spawn more than 32k particles in a single frame
			if (addActionCount != (ushort)short.MaxValue)
			{
				addActions[addActionCount] = action;

				if (++addActionCount == addActions.Length)
					Array.Resize(ref addActions, addActions.Length * 2);
			}
		}
		void IParticleProcessor.Update(int particleCount, float particleCountF, float deltaTime, float[] globals, CopyAction[] copyActions, int copyActionCount, AddAction[] addActions, int addActionCount, int step)
		{
			float time = (float)(step/timeStepHz) + (float)(step%timeStepHz) * deltaTime;

			//first update all particles from the last frame...
			if (previousFrameCount > 0)
				frameMethod(previousFrameCount, time, random, deltaTime, globals, this.lifeData, this.positions, this.velocity, this.colours, this.userdata);

			//then, apply the move operations
			for (int i = 0; i < copyActionCount; i++)
			{
				CopyAction action = copyActions[i];

				action.indexFrom = action.indexFrom & countMask;
				action.indexTo = action.indexTo & countMask;

				positions[action.indexTo] = positions[action.indexFrom];
				velocity[action.indexTo] = velocity[action.indexFrom];

				if (userdata != null)	userdata[action.indexTo] = userdata[action.indexFrom];
				if (colours != null)	colours[action.indexTo] = colours[action.indexFrom];
				if (lifeData != null)	lifeData[action.indexTo] = lifeData[action.indexFrom];
			}

			if (addActionCount > 0)
			{
				//make sure the indices array is big enough
				if (addActionCount > addIndices.Length)
				{
					int count = addIndices.Length;
					while (addActionCount > count)
						count *= 2;
					Array.Resize(ref addIndices, count);
				}

				//finally, add the new particles
				for (int i = 0; i < addActionCount; i++)
				{
					AddAction action = addActions[i];

					// simply wrap if outside the expected range
					// this will produce similar glitches as the gpu processor
					action.index = action.index & countMask; 

					if (action.cloneTypeIndex == -1)
					{
						//set all particle values to their defaults
						positions[action.index] = action.spawnDetails.PositionSize;
						velocity[action.index] = action.spawnDetails.VelocityRotation;
						if (userdata != null)
							userdata[action.index] = action.spawnDetails.UserValues;
						if (colours != null)
							colours[action.index] = action.spawnDetails.Colour;
					}
					else
					{
						//copy in particle values from another particle system
						CpuParticleProcessor other = (CpuParticleProcessor)processors[action.cloneTypeIndex];
						uint fromIndex = (uint)action.cloneFromIndex & other.countMask;

						positions[action.index] = other.positions[fromIndex];
						velocity[action.index] = other.velocity[fromIndex];

						if (userdata != null)
						{
							if (other.userdata != null)
								userdata[action.index] = other.userdata[fromIndex];
							else
								userdata[action.index] = new Vector4();
						}
						if (colours != null)
						{
							if (other.colours != null)
								colours[action.index] = other.colours[fromIndex];
							else
								colours[action.index] = new Vector4();
						}
					}

					if (lifeData != null)
						this.lifeData[action.index] = new Vector2((float)action.lifeSteps * deltaTime, time);

					addIndices[i] = action.index;
				}

				//run the add logic
				onceMethod((uint)addActionCount, addIndices, time, random, deltaTime, globals, lifeData, positions, velocity, colours, userdata);
			}

			previousFrameCount = Math.Min((uint)particleCount, maxCount); // cannot process more 
		}
Beispiel #21
0
 public TransactionContainer(AddAction action)
 {
     addAction = action;
 }
Beispiel #22
0
   private void Update()
   {
      if ( UIManager.IsModalActive() )
      {
         return;
      }

      //if ( _pixelsToPopIn.Any() )
      //{
      //   _popInTimeElapsed += TimeSpan.FromSeconds( Time.deltaTime );
      //   if ( ( _popInTimeElapsed.TotalSeconds / popInDelaySeconds ) > _poppedInCount )
      //   {
      //      PopIn( _pixelsToPopIn[0] );

      //      if ( _audio )
      //      {
      //         if ( !_audio.isPlaying )
      //         {
      //            _audio.Play();
      //         }

      //         if ( !_pixelsToPopIn.Any() )
      //         {
      //            _audio.Stop();
      //         }
      //      }
      //   }
      //}

      var pointerPos = new Vector3( _pointerPosX.GetValue(), _pointerPosY.GetValue(), 0 );
      var ray = Camera.main.ScreenPointToRay( pointerPos );
      Debug.DrawRay( ray.origin, ray.direction * 100, Color.green );

      PixelConfig selectedPixel = null;
      if ( _placePixel.IsActive() )
      {
         var hits = Physics.RaycastAll( ray );
         var sortedPixels = SortClosestPixels( ConvertToPixels( hits ) );
         if ( sortedPixels.Any( p => p.Color.a > 0 ) )
         {
            var pix = sortedPixels.First( p => p.Color.a > 0 );
            if ( UIManager.SelectedTool == UIManager.Tools.Add )
            {
               var sortedSurroundingPixels = SortClosestPixels( GetSurroundingPixels( sortedPixels, pix ) );
               try
               {
                  selectedPixel = sortedSurroundingPixels.First( p => _placeablePixels.Contains( p ) );
               }
               catch { }
            }
            else if ( UIManager.SelectedTool == UIManager.Tools.Remove || UIManager.SelectedTool == UIManager.Tools.Change )
            {
               selectedPixel = pix;
            }
         }
         else if ( UIManager.SelectedTool == UIManager.Tools.Add )
         {
            try
            {
               selectedPixel = sortedPixels.First( p => _placeablePixels.Contains( p ) );
            }
            catch { }
         }


         if ( selectedPixel != null )
         {
            IEditAction action = null;
            if ( UIManager.SelectedTool == UIManager.Tools.Add )
            {
               selectedPixel.Color = UIManager.GetSelectedColor();
               RemoveFromPlaceablePixels( selectedPixel );
               action = new AddAction( this, selectedPixel );
            }
            else if ( UIManager.SelectedTool == UIManager.Tools.Remove )
            {
               action = new RemoveAction( this, selectedPixel );
               PopOut( selectedPixel );
            }
            else if ( UIManager.SelectedTool == UIManager.Tools.Change )
            {
               if ( selectedPixel.Color != UIManager.GetSelectedColor() )
               {
                  action = new ChangeAction( this, selectedPixel, UIManager.GetSelectedColor() );
                  selectedPixel.Color = UIManager.GetSelectedColor();
               }
            }

            DetectPlaceablePixels();

            if ( action != null )
            {
               _actionStack.AddAction( action );
            }
         }
      }
   }
 public TransactionContainer(AddAction action)
 {
     addAction = action;
 }
Beispiel #24
0
 public override void Revoke()
 {
     AddAction.ApplyAction(songObject);
 }
Beispiel #25
0
        void IParticleProcessor.Update(int particleCount, float particleCountF, float deltaTime, float[] globals, CopyAction[] copyActions, int copyActionCount, AddAction[] addActions, int addActionCount, int step)
        {
            float time = (float)(step / timeStepHz) + (float)(step % timeStepHz) * deltaTime;

            //first update all particles from the last frame...
            if (previousFrameCount > 0)
            {
                frameMethod(previousFrameCount, time, random, deltaTime, globals, this.lifeData, this.positions, this.velocity, this.colours, this.userdata);
            }

            //then, apply the move operations
            for (int i = 0; i < copyActionCount; i++)
            {
                CopyAction action = copyActions[i];

                action.indexFrom = action.indexFrom & countMask;
                action.indexTo   = action.indexTo & countMask;

                positions[action.indexTo] = positions[action.indexFrom];
                velocity[action.indexTo]  = velocity[action.indexFrom];

                if (userdata != null)
                {
                    userdata[action.indexTo] = userdata[action.indexFrom];
                }
                if (colours != null)
                {
                    colours[action.indexTo] = colours[action.indexFrom];
                }
                if (lifeData != null)
                {
                    lifeData[action.indexTo] = lifeData[action.indexFrom];
                }
            }

            if (addActionCount > 0)
            {
                //make sure the indices array is big enough
                if (addActionCount > addIndices.Length)
                {
                    int count = addIndices.Length;
                    while (addActionCount > count)
                    {
                        count *= 2;
                    }
                    Array.Resize(ref addIndices, count);
                }

                //finally, add the new particles
                for (int i = 0; i < addActionCount; i++)
                {
                    AddAction action = addActions[i];

                    // simply wrap if outside the expected range
                    // this will produce similar glitches as the gpu processor
                    action.index = action.index & countMask;

                    if (action.cloneTypeIndex == -1)
                    {
                        //set all particle values to their defaults
                        positions[action.index] = action.spawnDetails.PositionSize;
                        velocity[action.index]  = action.spawnDetails.VelocityRotation;
                        if (userdata != null)
                        {
                            userdata[action.index] = action.spawnDetails.UserValues;
                        }
                        if (colours != null)
                        {
                            colours[action.index] = action.spawnDetails.Colour;
                        }
                    }
                    else
                    {
                        //copy in particle values from another particle system
                        CpuParticleProcessor other = (CpuParticleProcessor)processors[action.cloneTypeIndex];
                        uint fromIndex             = (uint)action.cloneFromIndex & other.countMask;

                        positions[action.index] = other.positions[fromIndex];
                        velocity[action.index]  = other.velocity[fromIndex];

                        if (userdata != null)
                        {
                            if (other.userdata != null)
                            {
                                userdata[action.index] = other.userdata[fromIndex];
                            }
                            else
                            {
                                userdata[action.index] = new Vector4();
                            }
                        }
                        if (colours != null)
                        {
                            if (other.colours != null)
                            {
                                colours[action.index] = other.colours[fromIndex];
                            }
                            else
                            {
                                colours[action.index] = new Vector4();
                            }
                        }
                    }

                    if (lifeData != null)
                    {
                        this.lifeData[action.index] = new Vector2((float)action.lifeSteps * deltaTime, time);
                    }

                    addIndices[i] = action.index;
                }

                //run the add logic
                onceMethod((uint)addActionCount, addIndices, time, random, deltaTime, globals, lifeData, positions, velocity, colours, userdata);
            }

            previousFrameCount = Math.Min((uint)particleCount, maxCount);             // cannot process more
        }
Beispiel #26
0
        private static void HandleQueueModificationBaseAction(QueueModificationBaseAction action)
        {
            List <IDownloadableLink> matchingLinks;

            switch (action.MatchingItemType)
            {
            case ItemTypeToAddRemove.Course:
                matchingLinks = SharedVars.Courses
                                .Where((course, j) => action.MatchingItems.Contains(j))
                                .SelectMany(course => SectionExtractor.ExtractSectionsForCourse(course).Result
                                            .SelectMany(section => section.Links))
                                .ToList();
                break;

            case ItemTypeToAddRemove.Section:
                matchingLinks = SharedVars.Sections
                                .Where((section, j) => action.MatchingItems.Contains(j))
                                .SelectMany(section => section.Links)
                                .ToList();
                break;

            case ItemTypeToAddRemove.Link:
                matchingLinks = SharedVars.SelectedSection.Links
                                .Where((link, j) => action.MatchingItems.Contains(j))
                                .ToList();
                break;

            default:
                matchingLinks = Enumerable.Empty <IDownloadableLink>().ToList();
                break;
            }

            if (!matchingLinks.Any())
            {
                ConsoleUtils.WriteLine("Unfortunately downloading files using multiple naming methods at once is not possible", ConsoleIOType.Error);
                return;
            }

            do
            {
                string message;
                if (action is AddAction)
                {
                    var count = matchingLinks.Except(SharedVars.DownloadQueue).Count();
                    SharedVars.DownloadQueue.AddUnique(matchingLinks);

                    message = $"Added {count} items (to revert, " +
                              "simply call Remove like you did with Add in the same way and location";
                }
                else
                {
                    var count = SharedVars.DownloadQueue.Intersect(matchingLinks).Count();
                    SharedVars.DownloadQueue.RemoveAll(link => matchingLinks.Contains(link));

                    message = $"Removed {count} items (to revert, " +
                              "simply call Add like you did with Remove in the same way and location";
                }

                ConsoleUtils.WriteLine(message, ConsoleColor.Yellow);

                if (action is AddAction)
                {
                    action = new RemoveAction();
                }
                else
                {
                    action = new AddAction();
                }
            } while (MenuChooseItem.AskYesNoQuestion("Do you want to revert now? [Y/N] "));
        }
        public void OpenAddAction()
        {
            AddAction a = new AddAction();

            a.Show();
        }
Beispiel #28
0
 public BuildCallback(string lbl, T v, List <T> or, ListExt.Mapper <T, string> mapper, Action <SelectState <T> > os, AddAction addAction, DeleteAction delAction, MoveAction moveAction)
     : this(lbl, v, or, mapper, os, addAction, delAction)
 {
     MoveAction = moveAction;
 }
Beispiel #29
0
 public BuildCallback(string lbl, T v, List <T> or, ListExt.Mapper <T, string> mapper, Action <SelectState <T> > os, AddAction addAction, DeleteAction delAction, Action <T> prefix, Action <T> suffix)
     : this(lbl, v, or, mapper, os, addAction, delAction, prefix)
 {
     Suffix = suffix;
 }
Beispiel #30
0
 public bool Build(string lbl, T value, List <T> origins, ListExt.Mapper <T, string> mapper, Action <SelectState <T> > onSelected = null, AddAction addAction = null, DeleteAction delAction = null)
 {
     return(Build(new BuildCallback(
                      lbl,
                      value,
                      origins,
                      mapper,
                      onSelected,
                      addAction,
                      delAction
                      )));
 }
Beispiel #31
0
        public void MiddlewareEffectsShouldCompound()
        {
            MiddlewareDelegate <int> addOneMiddleware = _ => {
                return(dispatcher => action => {
                    if (action is AddAction)
                    {
                        var addAction = (AddAction)action;
                        var newAction = new AddAction()
                        {
                            amount = addAction.amount + 1
                        };
                        dispatcher.Invoke(newAction);
                        return newAction as IAction;
                    }
                    else
                    {
                        dispatcher.Invoke(action);
                        return action as IAction;
                    }
                });
            };

            MiddlewareDelegate <int> doubleMiddleware = _ => {
                return(dispatcher => action => {
                    if (action is AddAction)
                    {
                        var addAction = (AddAction)action;
                        var newAction = new AddAction()
                        {
                            amount = addAction.amount * 2
                        };
                        dispatcher.Invoke(newAction);
                        return newAction as IAction;
                    }
                    else
                    {
                        dispatcher.Invoke(action);
                        return action as IAction;
                    }
                });
            };

            MiddlewareDelegate <int> logMiddleware = _ => {
                return(dispatcher => action => {
                    Debug.Log(JsonUtility.ToJson(action));
                    dispatcher.Invoke(action);
                    return action;
                });
            };

            var store = new SimpleStore(0, addOneMiddleware, doubleMiddleware, logMiddleware);

            Assert.AreEqual(0, store.GetState());

            store.Dispatch(new CountAction());
            Assert.AreEqual(1, store.GetState());

            // AddAction +5 would be modified as +1 then x2, therefore ultimately become AddAction +12
            store.Dispatch(new AddAction()
            {
                amount = 5
            });
            Assert.AreEqual(13, store.GetState());

            // These middlewares only target AddActions
            store.Dispatch(new UnrecognizedAction());
            Assert.AreEqual(13, store.GetState());
        }