コード例 #1
0
ファイル: CheckBox.cs プロジェクト: jeske/agg-sharp
        public CheckBox(double x, double y, GuiWidget checkBoxButtonView)
            : base(x, y)
        {
            Margin = DefaultMargin;

            OriginRelativeParent = new Vector2(x, y);

            if (checkBoxButtonView != null)
            {
                checkBoxButtonView.Selectable = false;

                AddChild(checkBoxButtonView);

                SetBoundsToEncloseChildren();

                if (LocalBounds.Left != 0 || LocalBounds.Bottom != 0)
                {
                    // let's make sure that a button has 0, 0 at the lower left
                    // move the children so they will fit with 0, 0 at the lower left
                    foreach (GuiWidget child in Children)
                    {
                        child.OriginRelativeParent = child.OriginRelativeParent + new Vector2(-LocalBounds.Left, -LocalBounds.Bottom);
                    }

                    SetBoundsToEncloseChildren();
                }

                MinimumSize = new Vector2(Width, Height);
            }

            Click += new ButtonEventHandler(CheckBox_Click);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: jeske/agg-sharp
 // If max height is > 0 it will limit the height of the menu
 public Menu(Direction direction = Direction.Down, double maxHeight = 0)
 {
     this.maxHeight = maxHeight;
     this.menuDirection = direction;
     Click += new ButtonEventHandler(ListMenu_Click);
     VAnchor = UI.VAnchor.FitToChildren;
     HAnchor = UI.HAnchor.FitToChildren;
 }
コード例 #3
0
ファイル: RadioButton.cs プロジェクト: jeske/agg-sharp
        public RadioButton(double x, double y, GuiWidget view)
        {
            Margin = defaultMargin;

            OriginRelativeParent = new Vector2(x, y);

            if (view != null)
            {
                view.Selectable = false;

                SuspendLayout();
                AddChild(view);
                ResumeLayout();

                FixBoundsAndChildrenPositions();

                MinimumSize = new Vector2(Width, Height);
            }

            Click += new ButtonEventHandler(RadioButton_Click);
        }
コード例 #4
0
 //UnSubscribte to the event
 public static void removeButtonEventListener(ButtonEventHandler handler)
 {
     OuyaButtonEvent.ButtonsEvent -= handler;
 }
コード例 #5
0
	public void RemoveButtonEventHandler(int instId,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		if (instId < 0 || instId >= m_instances.Length)
			return;

		ButtonEventHandlers handlers = m_buttonEventHandlers[instId];
		if (handlers == null)
			return;

		handlers.Remove(load, unload, enterFrame, update, render,
			press, release, rollOver, rollOut, keyPress);

		Button button = SearchButtonInstanceByInstanceId(instId);
		if (button != null)
			button.SetHandlers(handlers);
	}
コード例 #6
0
	public void Remove(
		ButtonEventHandler l = null, ButtonEventHandler u = null,
		ButtonEventHandler e = null, ButtonEventHandler up = null,
		ButtonEventHandler r = null, ButtonEventHandler p = null,
		ButtonEventHandler rl = null, ButtonEventHandler rOver = null,
		ButtonEventHandler rOut = null, ButtonKeyPressHandler k = null)
	{
		if (l != null)
			load.RemoveAll(h => h == l);
		if (u != null)
			unload.RemoveAll(h => h == u);
		if (e != null)
			enterFrame.RemoveAll(h => h == e);
		if (up != null)
			update.RemoveAll(h => h == up);
		if (r != null)
			render.RemoveAll(h => h == r);
		if (p != null)
			press.RemoveAll(h => h == p);
		if (rl != null)
			release.RemoveAll(h => h == rl);
		if (rOver != null)
			rollOver.RemoveAll(h => h == rOver);
		if (rOut != null)
			rollOut.RemoveAll(h => h == rOut);
		if (k != null)
			keyPress.RemoveAll(h => h == k);
	}
コード例 #7
0
 //UnSubscribte to the event
 public static void removeButtonEventListener(ButtonEventHandler handler)
 {
     OuyaButtonEvent.ButtonsEvent -= handler;
 }
コード例 #8
0
ファイル: PushButton.cs プロジェクト: semurr/ChickenRanch
 public void setHoverEventHandlers(ButtonEventHandler _hoverInEventHandler, ButtonEventHandler _hoverOutEventHandler)
 {
     hoverInEventHandler += _hoverInEventHandler;
     hoverOutEventHandler += _hoverOutEventHandler;
 }
コード例 #9
0
ファイル: lwf_event.cs プロジェクト: DelSystem32/lwf
	public int SetButtonEventHandler(int instId,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		ClearButtonEventHandler(instId);
		return AddButtonEventHandler(instId, load, unload, enterFrame, update,
			render, press, release, rollOver, rollOut, keyPress);
	}
コード例 #10
0
 public ButtonEventHandlers(ButtonEventHandler l, ButtonEventHandler u,
                            ButtonEventHandler e, ButtonEventHandler up, ButtonEventHandler r,
                            ButtonEventHandler rOver, ButtonEventHandler rOut, ButtonEventHandler p,
                            ButtonEventHandler rl, ButtonKeyPressHandler k)
 {
     load       = l;
     unload     = u;
     enterFrame = e;
     update     = up;
     render     = r;
     rollOver   = rOver;
     rollOut    = rOut;
     press      = p;
     release    = rl;
     keyPress   = k;
 }
コード例 #11
0
ファイル: lwf_button.cs プロジェクト: DelSystem32/lwf
	public int AddEventHandler(string eventName, ButtonEventHandler handler)
	{
		int id = m_lwf.GetEventOffset();
		switch (eventName) {
		case "load": m_handler.Add(id, l:handler); return id;
		case "unload": m_handler.Add(id, u:handler); return id;
		case "enterFrame": m_handler.Add(id, e:handler); return id;
		case "update": m_handler.Add(id, up:handler); return id;
		case "render": m_handler.Add(id, r:handler); return id;
		case "press": m_handler.Add(id, p:handler); return id;
		case "release": m_handler.Add(id, rl:handler); return id;
		case "rollOver": m_handler.Add(id, rOver:handler); return id;
		case "rollOut": m_handler.Add(id, rOut:handler); return id;
		default: return -1;
		}
	}
コード例 #12
0
        public PopupMessageView(string Title, string Message, MessageBoxButtons DisplayButtons, MessageBoxIcon DisplayIcon)
        {
            var labTitle = new Label
            {
                Text   = Title,
                Margin = new Thickness(24, 12, 12, 12),
                HorizontalTextAlignment = TextAlignment.Start
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                labTitle.TextColor = ColorConstants.AlertDangerText;
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                labTitle.TextColor = ColorConstants.AlertInfoText;
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                labTitle.TextColor = ColorConstants.AlertSuccessText;
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                labTitle.TextColor = ColorConstants.AlertWarningText;
            }

            var boxLine = new BoxView
            {
                HeightRequest   = 3,
                VerticalOptions = LayoutOptions.Center,
                Opacity         = 0.5,
                Color           = Color.DarkBlue
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                boxLine.Color = ColorConstants.AlertDangerBar;
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                boxLine.Color = ColorConstants.AlertInfoBar;
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                boxLine.Color = ColorConstants.AlertSuccessBar;
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                boxLine.Color = ColorConstants.AlertWarningBar;
            }

            var imgSign = new Image
            {
                HeightRequest     = 50,
                WidthRequest      = 50,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                imgSign.Source = ImageSource.FromFile("error.png");
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                imgSign.Source = ImageSource.FromFile("info.png");
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                imgSign.Source = ImageSource.FromFile("success.png");
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                imgSign.Source = ImageSource.FromFile("warning.png");
            }

            var labMsg = new Label
            {
                Text = Message,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.Center
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                labMsg.TextColor = ColorConstants.AlertDangerText;
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                labMsg.TextColor = ColorConstants.AlertInfoText;
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                labMsg.TextColor = ColorConstants.AlertSuccessText;
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                labMsg.TextColor = ColorConstants.AlertWarningText;
            }


            var stMsg = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Margin      = new Thickness(24, 12, 24, 12)
            };

            stMsg.Children.Add(imgSign);
            stMsg.Children.Add(labMsg);

            var btnAbort = new Button
            {
                WidthRequest = 100,
                Text         = "Abort"
            };

            var btnCancel = new Button
            {
                WidthRequest = 100,
                Text         = "Cancel"
            };

            var btnIgnore = new Button
            {
                WidthRequest = 100,
                Text         = "Ignore"
            };

            var btnNo = new Button
            {
                WidthRequest = 100,
                Text         = "No"
            };

            var btnNone = new Button
            {
                WidthRequest = 100,
                Text         = "None"
            };

            var btnOK = new Button
            {
                WidthRequest = 100,
                Text         = "OK"
            };

            var btnRetry = new Button
            {
                WidthRequest = 100,
                Text         = "Retry"
            };

            var btnYes = new Button
            {
                WidthRequest = 100,
                Text         = "Yes"
            };

            var gridButtons = new Grid
            {
                //BackgroundColor = Color.Honeydew
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                gridButtons.BackgroundColor = ColorConstants.AlertDangerBorder;
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                gridButtons.BackgroundColor = ColorConstants.AlertInfoBorder;
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                gridButtons.BackgroundColor = ColorConstants.AlertSuccessBorder;
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                gridButtons.BackgroundColor = ColorConstants.AlertWarningBorder;
            }

            switch (DisplayButtons)
            {
            case MessageBoxButtons.AbortRetryIgnore:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnAbort, 2, 0);
                gridButtons.Children.Add(btnRetry, 3, 0);
                gridButtons.Children.Add(btnIgnore, 4, 0);
                break;

            case MessageBoxButtons.OK:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnOK, 1, 0);
                break;

            case MessageBoxButtons.OKCancel:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnOK, 2, 0);
                gridButtons.Children.Add(btnCancel, 3, 0);
                break;

            case MessageBoxButtons.RetryCancel:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnRetry, 2, 0);
                gridButtons.Children.Add(btnCancel, 3, 0);
                break;

            case MessageBoxButtons.YesNo:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnYes, 2, 0);
                gridButtons.Children.Add(btnNo, 3, 0);
                break;

            case MessageBoxButtons.YesNoCancel:
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.ColumnDefinitions.Add(new ColumnDefinition());
                gridButtons.Children.Add(btnYes, 2, 0);
                gridButtons.Children.Add(btnNo, 3, 0);
                gridButtons.Children.Add(btnCancel, 4, 0);
                break;
            }


            var stMain = new StackLayout
            {
                BackgroundColor   = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center
            };

            if (DisplayIcon == MessageBoxIcon.Danger)
            {
                stMain.BackgroundColor = ColorConstants.AlertDangerBackground;
            }
            else if (DisplayIcon == MessageBoxIcon.Info)
            {
                stMain.BackgroundColor = ColorConstants.AlertInfoBackground;
            }
            else if (DisplayIcon == MessageBoxIcon.Success)
            {
                stMain.BackgroundColor = ColorConstants.AlertSuccessBackground;
            }
            else if (DisplayIcon == MessageBoxIcon.Warning)
            {
                stMain.BackgroundColor = ColorConstants.AlertWarningBackground;
            }

            stMain.Children.Add(labTitle);
            stMain.Children.Add(boxLine);
            stMain.Children.Add(stMsg);
            stMain.Children.Add(gridButtons);

            Content = stMain;

            btnAbort.Clicked += (s, e) =>
            {
                // invoke the event handler if its being subscribed
                Result = DialogResult.Abort;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnCancel.Clicked += (s, e) =>
            {
                Result = DialogResult.Cancel;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnIgnore.Clicked += (s, e) =>
            {
                Result = DialogResult.Ignore;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnNo.Clicked += (s, e) =>
            {
                Result = DialogResult.No;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnNone.Clicked += (s, e) =>
            {
                Result = DialogResult.None;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnOK.Clicked += (s, e) =>
            {
                Result = DialogResult.OK;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnRetry.Clicked += (s, e) =>
            {
                Result = DialogResult.Retry;
                ButtonEventHandler?.Invoke(this, e);
            };

            btnYes.Clicked += (s, e) =>
            {
                Result = DialogResult.Yes;
                ButtonEventHandler?.Invoke(this, e);
            };
        }
コード例 #13
0
ファイル: Config.cs プロジェクト: otakup0pe/sifteo4devops
 public SetupCube()
 {
     OnButton = new ButtonEventHandler(DoButton);
       OnTilt = new TiltEventHandler(DoTilt);
 }
コード例 #14
0
	public void SetButtonEventHandler(string instanceName,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		ClearButtonEventHandler(instanceName);
		AddButtonEventHandler(instanceName,
			load, unload, enterFrame, update, render,
			press, release, rollOver, rollOut, keyPress);
	}
コード例 #15
0
ファイル: lwf_event.cs プロジェクト: DelSystem32/lwf
	public int AddButtonEventHandler(string instanceName,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		interactive = true;

		int instId = SearchInstanceId(GetStringId(instanceName));
		if (instId >= 0) {
			return AddButtonEventHandler(instId,
				load, unload, enterFrame, update, render,
				press, release, rollOver, rollOut, keyPress);
		}

		if (!instanceName.Contains("."))
			return -1;

		if (m_buttonEventHandlersByFullName == null)
			m_buttonEventHandlersByFullName =
				new ButtonEventHandlersDictionary();

		ButtonEventHandlers handlers;
		if (!m_buttonEventHandlersByFullName.TryGetValue(
				instanceName, out handlers)) {
			handlers = new ButtonEventHandlers();
			m_buttonEventHandlersByFullName[instanceName] = handlers;
		}

		int id = GetEventOffset();
		handlers.Add(id, load, unload, enterFrame, update, render,
			press, release, rollOver, rollOut, keyPress);

		Button button = SearchButtonInstance(instanceName);
		if (button != null)
			button.SetHandlers(handlers);
		return id;
	}
コード例 #16
0
 public ButtonEventHandlers(ButtonEventHandler press = null, ButtonEventHandler down = null, ButtonEventHandler up = null)
 {
     ButtonPress = press;
     ButtonDown = down;
     ButtonUp = up;
 }
コード例 #17
0
ファイル: lwf_event.cs プロジェクト: DelSystem32/lwf
	public int AddButtonEventHandler(int instId,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		interactive = true;

		if (instId < 0 || instId >= m_instances.Length)
			return -1;

		ButtonEventHandlers handlers = m_buttonEventHandlers[instId];
		if (handlers == null) {
			handlers = new ButtonEventHandlers();
			m_buttonEventHandlers[instId] = handlers;
		}

		int id = GetEventOffset();
		handlers.Add(id, load, unload, enterFrame, update, render,
			press, release, rollOver, rollOut, keyPress);

		Button button = SearchButtonInstanceByInstanceId(instId);
		if (button != null)
			button.SetHandlers(handlers);
		return id;
	}
コード例 #18
0
 public override void Setup()
 {
     SetupCube = new SetupCube();
       Displays = new Dictionary<Cube, Object>();
       CubeDooms = new Dictionary<Cube, DoomGuy>();
       FlippedCubes = new List<string>();
       ButtonPressed = new Dictionary<string, DateTime>();
       OnButton = new ButtonEventHandler(DoButton);
       OnFlip = new FlipEventHandler(DoFlip);
       OnTilt = new TiltEventHandler(DoTilt);
       for ( int i = 0 ; i < this.CubeSet.Count ; i ++ )
     {
       this.CubeSet[i].ButtonEvent += OnButton;
       this.CubeSet[i].TiltEvent += OnTilt;
       this.CubeSet[i].FlipEvent += OnFlip;
       CubeDooms.Add(this.CubeSet[i], new DoomGuy());
       this.CubeSet[i].FillScreen(Color.White);
     }
 }
コード例 #19
0
ファイル: PushButton.cs プロジェクト: semurr/ChickenRanch
 public void setClickEventHandler(ButtonEventHandler _clickEventHandler)
 {
     clickEventHandler += _clickEventHandler;
 }
コード例 #20
0
 public static PopupDialogView PopupAB(PopupDialogType t, AssetBundle bundle, string richPath, object[] richPs, ButtonEventHandler callback, params object[] ps)
 {
     return(PopupAB(t, bundle, null, richPath, richPs, callback, ps));
 }
コード例 #21
0
 public static PopupDialogView Popup(PopupDialogType t, ButtonEventHandler callback, params object[] ps)
 {
     return(Popup(t, null, callback, ps));
 }
コード例 #22
0
 public static PopupDialogView PopupAB(PopupDialogType t, AssetBundle bundle, GameObject parent, ButtonEventHandler callback, params object[] ps)
 {
     return(PopupAB(t, bundle, parent, "", new object[] { }, callback, ps));
 }
コード例 #23
0
 //Subscribte to the event
 public static void addButtonEventListener(ButtonEventHandler handler)
 {
     OuyaButtonEvent.ButtonsEvent += handler;
 }
コード例 #24
0
        public static PopupDialogView PopupAB(PopupDialogType t, AssetBundle bundle, GameObject parent, string richPath, object[] richPs, ButtonEventHandler callback, params object[] ps)
        {
            if (null == NGUI2DRootPanel.Inst)
            {
                return(null);
            }
#if SDK_HM
            PlatformSDKInterface.LoginLocked = false;
#endif
            for (int i = 0; i < mShowDialogs.Count; ++i)
            {
                if ((t == mShowDialogs[i].DialogType || mShowDialogs[i].关联类型.Contains(t)) && mShowDialogs[i].唯一)
                {
                    if (mShowDialogs[i].唯一等待)
                    {
                        mWaitShowDialogs.Add(new object[] { t, parent, richPath, richPs, callback, ps });
                    }
                    return(mShowDialogs[i]);
                }
            }
            if (null == parent)
            {
                parent = NGUI2DRootPanel.Inst.gameObject;
            }
            PopupDialogView dialog     = null;
            string          dialogName = "Popup_" + t.ToString();
            dialogName = dialogName.ToLower();
            GameObject dialogObj = bundle.LoadAsset <GameObject>(dialogName);
            if (null == dialogObj)
            {
                return(null);
            }
            GameObject dlg = Instantiate(dialogObj);
            dialog = dlg.GetComponent <PopupDialogView>();
            if (null != dialog)
            {
                OnDialogLoadOvered(t, dialog, parent.transform, richPath, richPs, callback, ps);
            }
            //bundle.Unload(false);
            //bundle = null;
            dialogObj = null;
            Resources.UnloadUnusedAssets();
            dialog.FadeIn();
            return(dialog);
        }
コード例 #25
0
	public void Add(
		ButtonEventHandler l = null, ButtonEventHandler u = null,
		ButtonEventHandler e = null, ButtonEventHandler up = null,
		ButtonEventHandler r = null, ButtonEventHandler p = null,
		ButtonEventHandler rl = null, ButtonEventHandler rOver = null,
		ButtonEventHandler rOut = null, ButtonKeyPressHandler k = null)
	{
		if (l != null)
			load.Add(l);
		if (u != null)
			unload.Add(u);
		if (e != null)
			enterFrame.Add(e);
		if (up != null)
			update.Add(up);
		if (r != null)
			render.Add(r);
		if (p != null)
			press.Add(p);
		if (rl != null)
			release.Add(rl);
		if (rOver != null)
			rollOver.Add(rOver);
		if (rOut != null)
			rollOut.Add(rOut);
		if (k != null)
			keyPress.Add(k);
	}
コード例 #26
0
 //Subscribte to the event
 public static void addButtonEventListener(ButtonEventHandler handler)
 {
     OuyaButtonEvent.ButtonsEvent += handler;
 }
コード例 #27
0
ファイル: MAX31865_42.cs プロジェクト: ianlee74/RTD01-Module
        /// <summary>
        /// Raises the <see cref="ButtonPressed"/> or <see cref="ButtonReleased"/> event.
        /// </summary>
        /// <param name="sender">The <see cref="MAX31865"/> that raised the event.</param>
        /// <param name="buttonState">The state of the button.</param>
        protected virtual void OnButtonEvent(MAX31865 sender, ButtonState buttonState)
        {
            if (this.onButton == null)
            {
                this.onButton = new ButtonEventHandler(this.OnButtonEvent);
            }

            if (buttonState == ButtonState.Pressed)
            {
                // Program.CheckAndInvoke helps event callers get onto the Dispatcher thread.
                // If the event is null then it returns false.
                // If it is called while not on the Dispatcher thread, it returns false but also re-invokes this method on the Dispatcher.
                // If on the thread, it returns true so that the caller can execute the event.
                if (Program.CheckAndInvoke(ButtonPressed, this.onButton, sender, buttonState))
                {
                    this.ButtonPressed(sender, buttonState);
                }
            }
            else
            {
                if (Program.CheckAndInvoke(ButtonReleased, this.onButton, sender, buttonState))
                {
                    this.ButtonReleased(sender, buttonState);
                }
            }
        }
コード例 #28
0
	public void RemoveButtonEventHandler(string instanceName,
		ButtonEventHandler load = null, ButtonEventHandler unload = null,
		ButtonEventHandler enterFrame = null, ButtonEventHandler update = null,
		ButtonEventHandler render = null, ButtonEventHandler press = null,
		ButtonEventHandler release = null, ButtonEventHandler rollOver = null,
		ButtonEventHandler rollOut = null,
		ButtonKeyPressHandler keyPress = null)
	{
		int instId = SearchInstanceId(GetStringId(instanceName));
		if (instId >= 0) {
			RemoveButtonEventHandler(instId,
				load, unload, enterFrame, update, render,
				press, release, rollOver, rollOut, keyPress);
			return;
		}

		if (m_buttonEventHandlersByFullName == null)
			return;

		ButtonEventHandlers handlers;
		if (!m_buttonEventHandlersByFullName.TryGetValue(
				instanceName, out handlers))
			return;

		handlers.Remove(load, unload, enterFrame, update, render,
			press, release, rollOver, rollOut, keyPress);

		Button button = SearchButtonInstance(instanceName);
		if (button != null)
			button.SetHandlers(handlers);
	}