Exemplo n.º 1
0
 public void AddDeleT3 <T, K>(Action2 <T, K> dele)
 {
     if (dele is Action2 <int, string> )
     {
         onUpdate3 += dele as Action2 <int, string>;
     }
 }
Exemplo n.º 2
0
        protected override void OnPointerReleaseInternal(IPointer cursor, uint button)
        {
            base.OnPointerReleaseInternal(cursor, button);

            if (button != 0 || !enabled)
            {
                return;
            }

            dragController.End(cursor);

            // No need for event if nothing dragged.
            if (selectedRange.Y < selectedRange.X)
            {
                return;
            }

            // We also fire selection event.
            Action2 <Label, Vector2i> t = onTextSelected;

            if (t != null)
            {
                t(this, this.selectedRange);
            }
        }
Exemplo n.º 3
0
    public override void OnShow(params object[] parameters)
    {
        InputManager.Instance.Mode = InputMode.Inventory;

        InventoryType type = (InventoryType)parameters[0];
        Inventory     inv  = parameters[1] as Inventory;

        toolbar.UpdateInput(type);
        tooltip.UpdateTooltip(selectedButton);
        firstInput  = null;
        secondInput = null;

        OpenInventory(inv, type);

        if (type == InventoryType.PLAYER)
        {
            playerEquipement = parameters[2] as Equipement;
            playerEquipement.myButtonList = myButtonList;
            FindAllButtonEquip();
        }
        else if (type == InventoryType.PLAYER_SHOP)
        {
            FindAllButtonEquip();
        }
        else if (type == InventoryType.PLAYER_STORE)
        {
            FindAllButtonEquip();
        }
    }
 protected virtual void VisitList <T>(ReadOnlyCollection <T> list, Action2 <T> visitor)
 {
     foreach (T element in list)
     {
         visitor(element);
     }
 }
Exemplo n.º 5
0
        private void GetResult()
        {
            List <double> srcData = new List <double>();

            resultList.Clear();
            Stopwatch sw = new Stopwatch();

            sw.Start();

            foreach (var value in srcInputTextbox.Lines)
            {
                if (value == "")
                {
                    continue;
                }
                srcData.Add(Convert.ToDouble(value));
            }
            figuredata.GetGatherResult(srcData, ref resultList, Convert.ToDouble(dataWant.Text), Convert.ToDouble(rangeTextbox.Text));
            Action2 <List <List <double> >, string> a = new Action2 <List <List <double> >, string>(updateGridViewResult);

            Invoke(a, resultList, dataWant.Text.ToString());
            sw.Stop();
            TimeSpan dt = sw.Elapsed;

            Console.WriteLine("程序耗时:'{0}'秒", dt);
            double time = dt.TotalSeconds;

            MessageBox.Show("程序耗时:" + time.ToString() + "s,一共找到 " +
                            resultList.Count.ToString() + " 个组合");
            click_enable = true;
        }
Exemplo n.º 6
0
 protected override void DispatchToMainThread(Action2 <object, object> action, object arg1, object arg2)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         action(arg1, arg2);
     });
 }
        static DeserializerDelegate RetrieveDeserializer2_IList(Type type, Type ga0)
        {
            Func0 create = Accelerator.CreateStandardConstructor(type);

            MethodInfo m = type.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { ga0 }, null);

            if (m == null)
            {
                throw new InvalidOperationException();
            }

            Action2 a = Accelerator.CreateAction2(m);

            return((JsonDeserializer deserializer, JsonTokenizer tokenizer, out object value) =>
            {
                if (tokenizer.BeginReadArray())
                {
                    object list = create();
                    deserializer.DeserializeCollection(tokenizer, ga0, x => a(list, x));
                    value = list;
                    return true;
                }
                else
                {
                    value = null;
                    return false;
                }
            });
        }
Exemplo n.º 8
0
 /// <summary>Initializes the <see cref="Progress{T}"/> with the specified callback.</summary>
 /// <param name="handler">
 /// A handler to invoke for each reported progress value.  This handler will be invoked
 /// in addition to any delegates registered with the <see cref="ProgressChanged"/> event.
 /// Depending on the <see cref="SynchronizationContext"/> instance captured by
 /// the <see cref="Progress{T}"/> at construction, it's possible that this handler instance
 /// could be invoked concurrently with itself.
 /// </param>
 /// <exception cref="ArgumentNullException">The <paramref name="handler"/> is null (Nothing in Visual Basic).</exception>
 public Progress(Action2 <T> handler) : this()
 {
     if (handler == null)
     {
         throw new ArgumentNullException(nameof(handler));
     }
     _handler = handler;
 }
Exemplo n.º 9
0
        internal void AddAction_2(double id, string content)
        {
            Action2 action2 = new Action2();

            action2.ID      = id;
            action2.Content = content;
            _actions_2.Add(action2);
        }
Exemplo n.º 10
0
            public ConsoleMethod_Action2(Action2 method, MethodDescription description) : base(description)
            {
                if (method == null)
                {
                    throw new ArgumentNullException(nameof(method));
                }

                this.method = method;
            }
Exemplo n.º 11
0
 public Command2(CommandEntity commandEntity)
 {
     this.commandEntity = commandEntity;
     var action = ActionParser.ParseToSingle(commandEntity.actionPattern);
     if (!string.IsNullOrEmpty(commandEntity.motion))
     {
         action = new ActionMotion2(commandEntity.motion, action);
     }
     this.action = action;
 }
Exemplo n.º 12
0
        private static void ContrvarianceDelegates()
        {
            Action1 <BaseExample> baseClassAction = ActionOnBaseClass;
            // contrvariance
            Action1 <DerivedExample> derivedClassAction = baseClassAction;

            Action2 <BaseExample> baseClassAction2 = ActionOnBaseClass;
            // error
            //Action2<DerivedExample> derivedClassAction2 = baseClassAction2;
        }
Exemplo n.º 13
0
 private void dataGridView2_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         Action2.Show(dataGridView2, e.Location);
     }
     foreach (DataGridViewRow row in dataGridView2.SelectedRows)
     {
         selectedcatID = row.Cells[0].Value.ToString();
     }
 }
Exemplo n.º 14
0
        public Signalling(string serverUrl, string name, string sessionId, Function1 <PeerClient, Connection> createConnection, Action2 <string, string> onReceivedText)
        {
            ServerUrl        = serverUrl;
            SessionId        = sessionId;
            UserName         = name;
            CreateConnection = createConnection;
            UserId           = Guid.NewGuid().ToString();
            OnReceivedText   = onReceivedText;

            DefineChannels();
        }
Exemplo n.º 15
0
        void IUserInteractive.OnPointerLeave(IPointer cursor)
        {
            OnPointerLeaveInternal(cursor);

            // We fire event.
            Action2 <Area, IPointer> t = onMouseLeave;

            if (t != null)
            {
                t(this, cursor);
            }
        }
Exemplo n.º 16
0
 public void go()
 {
     try
     {
         Action2 action = new Action2();
         action.LancerPlanification();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        public JsonTypeMemberEntry(string jsonName, FieldInfo fieldInfo)
        {
            IsEscapingRequired = JsonWriter.IsEscapingRequired(jsonName);
            MemberType         = fieldInfo.FieldType;

            ReadValue = Accelerator.CreateInstanceGetter(fieldInfo);

            if (!fieldInfo.IsInitOnly)
            {
                WriteValue = Accelerator.CreateInstanceSetter(fieldInfo);
            }
        }
Exemplo n.º 18
0
        protected override void VisitList <T>(ReadOnlyCollection <T> list, Action2 <T> visitor)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (i > 0)
                {
                    Print(ListSeparator);
                }

                visitor(list[i]);
            }
        }
Exemplo n.º 19
0
        public void TestCreateInstanceSetter1()
        {
            string  n        = nameof(ClassWithInstanceFields.InstanceValueField);
            Action2 setValue = typeof(ClassWithInstanceFields).CreateInstanceSetter(n);

            var e = new ClassWithInstanceFields();

            Assert.AreEqual(0, e.InstanceValueField);
            setValue(e, 123);
            Assert.AreEqual(123, e.InstanceValueField);
            setValue(e, 0);
            Assert.AreEqual(0, e.InstanceValueField);
        }
Exemplo n.º 20
0
        public void TestCreateInstanceSetter3()
        {
            string  n       = nameof(ClassWithInstanceFields.InstanceEnumField);
            Action2 setText = typeof(ClassWithInstanceFields).CreateInstanceSetter(n);

            var e = new ClassWithInstanceFields();

            Assert.AreEqual(EnumForTest.None, e.InstanceEnumField);
            setText(e, EnumForTest.Example);
            Assert.AreEqual(EnumForTest.Example, e.InstanceEnumField);
            setText(e, EnumForTest.None);
            Assert.AreEqual(EnumForTest.None, e.InstanceEnumField);
        }
Exemplo n.º 21
0
        public void TestCreateInstanceSetter2()
        {
            string  n       = nameof(ClassWithInstanceFields.InstanceTextField);
            Action2 setText = typeof(ClassWithInstanceFields).CreateInstanceSetter(n);

            var e = new ClassWithInstanceFields();

            Assert.AreEqual(null, e.InstanceTextField);
            setText(e, "ABC");
            Assert.AreEqual("ABC", e.InstanceTextField);
            setText(e, null);
            Assert.AreEqual(null, e.InstanceTextField);
        }
        public void TestCreateAction2a()
        {
            string  n   = nameof(ExampleClass1.Increment);
            Action2 inc = Accelerator.CreateAction2(typeof(ExampleClass1).GetMethod(n, new[] { typeof(int) }));

            var o = new ExampleClass1();

            o.Increment(1);
            Assert.AreEqual(1, o.Value);
            inc(o, 3);
            Assert.AreEqual(4, o.Value);
            inc(o, 11);
            Assert.AreEqual(15, o.Value);
        }
Exemplo n.º 23
0
        /// <summary>Reports a progress change.</summary>
        /// <param name="value">The value of the updated progress.</param>
        protected virtual void OnReport(T value)
        {
            // If there's no handler, don't bother going through the sync context.
            // Inside the callback, we'll need to check again, in case
            // an event handler is removed between now and then.
            Action2 <T>       handler      = _handler;
            EventHandler2 <T> changedEvent = ProgressChanged;

            if (handler != null || changedEvent != null)
            {
                // Post the processing to the sync context.
                // (If T is a value type, it will get boxed here.)
                _synchronizationContext.Post(_invokeHandlers, value);
            }
        }
Exemplo n.º 24
0
 public void StartEvent()
 {
     if (Condition1.ConditionResult() && Condition2.ConditionResult())
     {
         Action3.Execute();
     }
     else if (Condition1.ConditionResult())
     {
         Action1.Execute();
     }
     else if (Condition2.ConditionResult())
     {
         Action2.Execute();
     }
 }
        public JsonTypeMemberEntry(string jsonName, Type propertyType, MethodInfo getMethod, MethodInfo setMethod)
        {
            IsEscapingRequired = JsonWriter.IsEscapingRequired(jsonName);
            MemberType         = propertyType;

            if (getMethod != null)
            {
                ReadValue = Accelerator.CreateFunction1(getMethod);
            }

            if (setMethod != null)
            {
                WriteValue = Accelerator.CreateAction2(setMethod);
            }
        }
Exemplo n.º 26
0
        /// <summary>Invokes the action and event callbacks.</summary>
        /// <param name="state">The progress value.</param>
        private void InvokeHandlers(object state)
        {
            T value = (T)state;

            Action2 <T>       handler      = _handler;
            EventHandler2 <T> changedEvent = ProgressChanged;

            if (handler != null)
            {
                handler(value);
            }
            if (changedEvent != null)
            {
                changedEvent(this, value);
            }
        }
Exemplo n.º 27
0
        public static void ForEach <T>(IEnumerable <T> items, Action2 <int, T> action)
        {
            if (items == null)
            {
                throw new ArgumentNullException("items");
            }

            using (IEnumerator <T> enumerator = items.GetEnumerator())
            {
                int index = 0;
                while (enumerator.MoveNext())
                {
                    action(index++, enumerator.Current);
                }
            }
        }
Exemplo n.º 28
0
        public void TestAccessClassProperty()
        {
            string       n        = nameof(ClassWithProperties.Value);
            PropertyInfo pi       = typeof(ClassWithProperties).GetProperty(n);
            Func1        getValue = Accelerator.CreateFunction1(pi.GetMethod);
            Action2      setValue = Accelerator.CreateAction2(pi.SetMethod);

            var o = new ClassWithProperties(123);

            Assert.AreEqual(123, o.Value);
            Assert.AreEqual(123, getValue(o));

            setValue(o, 456);
            Assert.AreEqual(456, o.Value);
            Assert.AreEqual(456, getValue(o));
        }
Exemplo n.º 29
0
 // コンストラクタ
 public SupplyData(DateTime time, int value, Action1 action1, Action2 action2)
 {
     // 数値を記録する
     oldTime  = Utility.GetTimeStrSQLite(time);
     Time     = new ReactiveProperty <string>(oldTime);
     oldValue = value;
     Value    = new ReactiveProperty <int>(oldValue);
     // コマンドを作成する
     // つまり、「Time != oldTime または Value != oldValue」なら
     // EditCommandが有効になる
     EditCommand = Time.Select(x => (x != oldTime)).CombineLatest(
         Value.Select(y => (y != oldValue)), (x, y) => x | y).ToReactiveCommand();
     // コマンドを登録する
     EditCommand.Subscribe(_ => action1(oldTime, oldValue, Time.Value, Value.Value));
     DeleteCommand.Subscribe(_ => action2(oldTime, oldValue));
 }
Exemplo n.º 30
0
        private bool Context(IClient client, object state, Action2 <IClientConnection, object> action)
        {
            var succeed = client.Context(state)(action);

            if (!succeed)
            {
                if (g_traceInfo.IsVerboseEnabled)
                {
                    TraceHelper.TraceVerbose(g_traceInfo, "Removing - {0}", client);
                }

                AddToIdle(Pool.Take(client));
            }

            return(succeed);
        }
Exemplo n.º 31
0
        public void TestAccessValueProperty()
        {
            string       n       = nameof(ClassWithProperties.Text);
            PropertyInfo pi      = typeof(ClassWithProperties).GetProperty(n);
            Func1        getText = Accelerator.CreateFunction1(pi.GetMethod);
            Action2      setText = Accelerator.CreateAction2(pi.SetMethod);

            var o = new ClassWithProperties("ABC");

            Assert.AreEqual("ABC", o.Text);
            Assert.AreEqual("ABC", getText(o));

            setText(o, "XYZ");
            Assert.AreEqual("XYZ", o.Text);
            Assert.AreEqual("XYZ", getText(o));
        }
Exemplo n.º 32
0
 public ActionMotion2(string motionName, Action2 action)
 {
     this.motionName = motionName;
     this.action = action;
 }
Exemplo n.º 33
0
 protected void InitAction(Action2 action)
 {
     this.action = action;
 }
Exemplo n.º 34
0
    public ProjectileCustom(GameInstance parent, float initX, float initY, FieldObjectEntity objectField, ProjectileEntity objectProjectile, Action2 action)
        : base(parent, initX, initY, objectField, objectProjectile)
    {
        List<VectorEntity> pattern = VectorGenerator.Custom(objectProjectile.speed, objectProjectile.speedY, objectProjectile.gravity, parent.ToLeft);
        //pattern.Add(new LinearVelocity(parent.Velocity));
        SetMove(pattern);

        InitAction(action);
    }
Exemplo n.º 35
0
    public void CreateProjectile(int objectCode, Action2 action, Vector2 offsetFromBC)
    {
        if (ToLeft)
        {
            float xMin = -Rect.width / 2f;
            xMin += 0.1f;
            offsetFromBC.x = Mathf.Max(offsetFromBC.x, xMin);
        }
        else
        {
            float xMax = Rect.width / 2f;
            xMax -= 0.1f;
            offsetFromBC.x = Mathf.Min(offsetFromBC.x, xMax);
        }

        Rect parentRect = Rect.ObjectRectInLayer;
        Vector2 parentBC = new Vector2(parentRect.x, parentRect.y - parentRect.height / 2);
        Vector2 startPos = parentBC + offsetFromBC;
        FieldObjectEntity objectField = TableLoader.GetTable<FieldObjectEntity>().Get(objectCode);
        ProjectileEntity objectProjectile = TableLoader.GetTable<ProjectileEntity>().Get(objectCode);
        Projectile instance = new ProjectileCustom(this, startPos.x, startPos.y, objectField, objectProjectile, action);

        CreateChild(instance, startPos.x, startPos.y);
    }
Exemplo n.º 36
0
 public ActionIfElse(Action2 condition, Action2 statement1, Action2 statement2)
 {
     this.condition = condition;
     this.statement1 = statement1;
     this.statement2 = statement2;
 }
Exemplo n.º 37
0
 public ActionIf(Action2 condition, Action2 statement)
 {
     this.condition = condition;
     this.statement = statement;
 }
Exemplo n.º 38
0
 public ActionIfElse(string condition, Action2 statement1, Action2 statement2)
 {
     // not implemented
 }
Exemplo n.º 39
0
 public ActionIf(string condition, Action2 statement)
     : this(ParseCondition(condition), statement)
 {
 }
Exemplo n.º 40
0
 public ActionProjectile2(int objectCode, Action2 action)
 {
     this.objectCode = objectCode;
     this.action = action;
 }