Exemplo n.º 1
0
        public void SetTextSize(float textSize)
        {
            if (ctx.InvokeRequired)
            {
                FloatDelegate c = new FloatDelegate(SetTextSize);
                ctx.Invoke(c, new object[] { textSize });
                return;
            }
            supressEvent = true;
            System.Drawing.Font f = new System.Drawing.Font(input.Font.FontFamily, textSize);
            int inputX            = input.Size.Width;
            int inputY            = input.Size.Height;

            output.Font = f;

            System.Drawing.Size nSize = TextRenderer.MeasureText("T", f);
            input.Size = new System.Drawing.Size(input.Size.Width, nSize.Height + 4); //+4 for the cursor to display
            if (sync != SyncMode.syncWindow)
            {
                SyncMode backup = sync;
                sync = SyncMode.syncWindow;
                SyncUI(input.Size.Width - inputX, nSize.Height - inputY, false);
                sync = backup;
            }

            input.Font   = f;
            supressEvent = false;
        }
Exemplo n.º 2
0
        public SliderControl(string text, float initialValue, Vector2 position, FloatDelegate onValueChanged)
        {
            action = onValueChanged;

            BackingPlate = new pSprite(TextureManager.Load(OsuTexture.sliderbar), position)
            {
                Colour = new Color4(50, 50, 50, 255)
            };
            Add(BackingPlate);

            FrontPlate = new pSprite(TextureManager.Load(OsuTexture.sliderbar), position)
            {
                DrawDepth = BackingPlate.DrawDepth + 0.01f,
                Colour    = new Color4(97, 159, 0, 255),
                Additive  = true
            };
            Add(FrontPlate);

            Vector2 offset = new Vector2(-BackingPlate.DisplayRectangle.Width / 2, -BackingPlate.DisplayRectangle.Height / 2);

            BackingPlate.Offset = offset;
            FrontPlate.Offset   = offset;

            Text = new pText(text, 24, position, BackingPlate.DrawDepth + 0.02f, true, Color4.White)
            {
                Origin     = OriginTypes.Centre,
                TextShadow = true
            };
            Add(Text);

            BackingPlate.OnClick += SliderControl_OnClick;

            UpdateValue(initialValue);
        }
Exemplo n.º 3
0
 public static void DoFloatDelegate(FloatDelegate func, GameObject arg, float delta)
 {
     try {
         func(arg, delta);
     } catch (Exception ex) {
         //TopTip.addTip(a.Method.Name + "执行出错" + ex.ToString());
         FuncUtil.ShowError(func.Method.Name + "执行出错" + ex.ToString());
     }
 }
        static void Main(string[] args)
        {
            // Assign type Method1Delegate to variable delegate1 and point it to Method1.
            Method1Delegate delegate1 = Method1;

            delegate1();

            // Assign type Method2Delegate to variable delegate2 and point it to Method2.
            Method2Delegate delegate2 = Method2;

            Console.WriteLine("Method 2 float value " + delegate2());

            // Assign type Method3Delegate to variable delegate3 and point it to Method3.
            Method3Delegate delegate3 = Method3;

            delegate3("Andreas", 25, 1.82f);

            // Create a new instance of Math class.
            Math mathObject = new Math();
            // Assign type MathDelegate to variable math and point it to Addition method in Math class.
            MathDelegate math = mathObject.Addition;

            Console.WriteLine("Addition 17 + 18 = " + math(17, 18));
            // Assign math variable to Multiplication method in Math class.
            math = mathObject.Multiplication;
            Console.WriteLine("Multiplication 3 * 7 = " + math(3, 7));

            // Assign type MyDelegate to variable myDelegate and point it to Method4.
            MyDelegate myDelegate = Method4;

            // Assign another method to myDelegate
            myDelegate += Method5;
            // Invoke myDelegate, it will call both Method4 and Method5.
            myDelegate();

            // Assign type IntDelegate to variable addition and point it to Lambda Expression
            IntDelegate addition = (num1, num2) => num1 + num2;

            Console.WriteLine("Addition 13 + 4 = " + addition(13, 4));
            // Assign type IntDelegate to variable subtraction and point it to Lambda Expression
            IntDelegate subtraction = (num1, num2) => num1 - num2;

            Console.WriteLine("Subtraction 8 - 2 = " + subtraction(8, 2));
            // Assign type IntDelegate to variable subtraction and point it to Lambda Expression
            FloatDelegate multiplication = (num1, num2) => num1 * num2;

            Console.WriteLine("Multiplication 4.2 * 3.1 = " + multiplication(4.2f, 3.1f));
            // Assign type IntDelegate to variable division and point it to Lambda Expression
            FloatDelegate division = (num1, num2) => num1 / num2;

            Console.WriteLine("Multiplication 4 / 32 = " + division(4, 32));
        }
Exemplo n.º 5
0
 public void RemoveOneShotDelegate(FloatDelegate function)
 {
     if (oneShotDelegates.Contains(function))
     {
         oneShotDelegates.Remove(function);
         FloatEvent -= function;
     }
     else
     {
         Diglbug.LogError("Unexpected call to RemoveOneShotDelegate");
     }
     Diglbug.Log("Removed oneShotDelegate, total: " + oneShotDelegates.Count, PrintStream.DELEGATES);
 }
Exemplo n.º 6
0
 public void OnDestroy()
 {
     onSubmit            = null;
     onHover             = null;
     onClick             = null;
     onToggleChanged     = null;
     onDragStart         = null;
     onDragEnd           = null;
     onSliderChanged     = null;
     onScrollbarChanged  = null;
     onDrag              = null;
     onDrapDownChanged   = null;
     onInputFieldChanged = null;
 }
Exemplo n.º 7
0
 public void Clear()
 {
     onSubmit      = null;
     onClick       = null;
     onDoubleClick = null;
     onHover       = null;
     onPress       = null;
     onSelect      = null;
     onScroll      = null;
     onDragStart   = null;
     onDrag        = null;
     onDragOver    = null;
     onDragOut     = null;
     onDragEnd     = null;
     onDrop        = null;
     onKey         = null;
     onTooltip     = null;
 }
Exemplo n.º 8
0
 public Attribute(float v, FloatDelegate callBack = null)
 {
     mBaseValue = v;
     OnChanged  = callBack;
 }
Exemplo n.º 9
0
 public AttackDuration(float v, FloatDelegate callBack = null)
     : base(v, callBack)
 {
 }
Exemplo n.º 10
0
 public DistanceAttribute(float v, FloatDelegate callBack = null) : base(v, callBack)
 {
 }
 protected void OnDisable()
 {
     myProgressDelegate -= DefaultProgressEventHandler;
 }
 protected void OnEnable()
 {
     myProgressDelegate += DefaultProgressEventHandler;
 }
Exemplo n.º 13
0
	public static int test_56_float () {
		FloatDelegate l = new FloatDelegate (float_delegate);

		return (int)l (55);
	}
Exemplo n.º 14
0
 public void RemovePermanentDelegate(FloatDelegate function)
 {
     FloatEvent -= function;
 }
Exemplo n.º 15
0
        public static int test_56_float()
        {
            FloatDelegate l = new FloatDelegate(float_delegate);

            return((int)l(55));
        }
Exemplo n.º 16
0
 protected void OnDisable()
 {
     myProgressDelegate -= DefaultProgressDelegate;
 }
Exemplo n.º 17
0
 protected void OnEnable()
 {
     myProgressDelegate += DefaultProgressDelegate;
 }
Exemplo n.º 18
0
 public void AddPermanentDelegate(FloatDelegate function)
 {
     FloatEvent += function;
 }
Exemplo n.º 19
0
 public void AddOneShotDelegate(FloatDelegate function)
 {
     FloatEvent += function;
     oneShotDelegates.Add(function);
     Diglbug.Log("Added oneShotDelegate, total: " + oneShotDelegates.Count, PrintStream.DELEGATES);
 }