Exemplo n.º 1
0
        /// <summary>
        /// Working with Grid.RowProperty which is a DependencyProperty which is managed by .NET.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DemoButton_Click(object sender, RoutedEventArgs e)
        {
            int row = (int)DemoButton.GetValue(Grid.RowProperty);

            row = (row + 1) % LayoutRoot.RowDefinitions.Count;

            DemoButton.SetValue(Grid.RowProperty, row);
        }
Exemplo n.º 2
0
        public LoginScene(ContentManager contents) :
            base(Constants.SCENE_LOGIN, contents)
        {
            _contents = contents;
            rec1      = new Rectangle(0, 0, 800, 600);
            rec2      = new Rectangle(0, 0, 1280, 720);

            ID    = new DemoButton(new Vector2(150, 250), new Rectangle(0, 0, 150, 50));
            PASS  = new DemoButton(new Vector2(300, 250), new Rectangle(0, 0, 150, 50));
            LOGIN = new DemoButton(new Vector2(450, 250), new Rectangle(0, 0, 150, 50));
        }
Exemplo n.º 3
0
 public Game1()
 {
     Login    = new LoginScene(Content);
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory              = "Content";
     IsMouseVisible                     = true;
     graphics.PreferredBackBufferWidth  = Constants.VIEWPORT_WIDTH;
     graphics.PreferredBackBufferHeight = Constants.VIEWPORT_HEIGHT;
     Gate   = new GateControl(Content);
     button = new DemoButton();
 }
Exemplo n.º 4
0
        public override void OnBindElements(View view)
        {
            LoginButton      = view.FindViewById <Button>(Resource.Id.loginButton);
            DemoButton       = view.FindViewById <Button>(Resource.Id.DemoButton);
            ServerName       = view.FindViewById <EditText>(Resource.Id.serverName);
            Username         = view.FindViewById <EditText>(Resource.Id.username);
            Password         = view.FindViewById <EditText>(Resource.Id.password);
            RememberMe       = view.FindViewById <CheckBox>(Resource.Id.rememberMe);
            LoginProgressBar = view.FindViewById <ProgressBar>(Resource.Id.LoginProgressBar);
            LoginLayout      = view.FindViewById <LinearLayout>(Resource.Id.LoginLayout);

            LoginProgressBar.Visibility = ViewStates.Invisible;
            LoginButton.Enabled         = false;

            Username.AddTextChangedListener(this);
            Password.AddTextChangedListener(this);
            Username.OnFocusChangeListener = this;
            Password.OnFocusChangeListener = this;
            LoginButton.SetOnClickListener(this);
            DemoButton.SetOnClickListener(this);
        }
Exemplo n.º 5
0
    private void Awake()
    {
        this._languageButtonGO = transform.Find("LanguageButton").gameObject;
        this._helpButtonGO     = transform.Find("HelpButton").gameObject;

        this._languageButton = _languageButtonGO.GetComponent <ClickableImage>();
        this._helpButton     = _helpButtonGO.GetComponent <ClickableImage>();

        var loginComponent = transform.Find("LoginComponent").gameObject;

        this._loginInputGO    = loginComponent.transform.Find("LoginInput").gameObject;
        this._passwordInputGO = loginComponent.transform.Find("PasswordInput").gameObject;
        this._loginButtonGO   = loginComponent.transform.Find("LoginButton").gameObject;
        this._mainLabelGO     = loginComponent.transform.Find("MainLabel").gameObject;
        this._demoButtonGO    = transform.Find("DemoButton").gameObject;

        var loginInputTextArea = _loginInputGO.transform.Find("Text Area").gameObject;

        _loginInputPlaceholderGO = loginInputTextArea.transform.Find("Placeholder").gameObject;

        var passwordInputTextArea = _passwordInputGO.transform.Find("Text Area").gameObject;

        _passwordInputPlaceholderGO = passwordInputTextArea.transform.Find("Placeholder").gameObject;

        this._loginInput    = _loginInputGO.GetComponent <TMP_InputField>();
        this._passwordInput = _passwordInputGO.GetComponent <TMP_InputField>();
        this._loginButton   = _loginButtonGO.GetComponent <LoginButton>();
        this._mainLabel     = _mainLabelGO.GetComponent <TextMeshProUGUI>();
        this._demoButton    = _demoButtonGO.GetComponent <DemoButton>();

        this._loginInputPlaceholder    = _loginInputPlaceholderGO.GetComponent <TextMeshProUGUI>();
        this._passwordInputPlaceholder = _passwordInputPlaceholderGO.GetComponent <TextMeshProUGUI>();

        this._loginButton.OnClick.AddListener(_handleLoginButtonClicked);
        this._demoButton.OnClick.AddListener(_handleDemoButtonClicked);
        this._helpButton.OnClick.AddListener(_handleHelpButtonClicked);

        this._languageButton.OnClick.AddListener(_handleLanguageButtonClicked);
    }
Exemplo n.º 6
0
	protected virtual void OnGUI()
	{
		if(CaptureMode)
		{
			return;
		}

		float gutter = 25;

		if(Watermark)
		{
			float height = Screen.height * 0.1f;
			float width = ((float)Watermark.width / (float)Watermark.height) * height;
			GUI.color = new Color(1f, 1f, 1f, 0.2f);
			switch(watermarkLocation)
			{
			case WatermarkLocation.UpperLeft:
				GUI.DrawTexture(new Rect(gutter, gutter, width, height), Watermark);
				break;
			case WatermarkLocation.UpperCenter:
				GUI.DrawTexture(new Rect(Screen.width * 0.5f - width * 0.5f, gutter, width, height), Watermark);
				break;
			case WatermarkLocation.UpperRight:
				GUI.DrawTexture(new Rect(Screen.width - gutter - width, gutter, width, height), Watermark);
				break;
			}
			GUI.color = Color.white;
		}

		if(demoButtonStyle == null)
		{
			demoButtonStyle = new GUIStyle(GUI.skin.box);
			demoButtonStyle.alignment = TextAnchor.UpperCenter;
			demoButtonStyle.wordWrap = true;
			demoButtonStyle.fontSize = 20;
			demoButtonStyle.normal.textColor = Color.white;
		}

		if(!passedIntro)
		{
#if UNITY_4
			Screen.lockCursor = true;
#else
			Cursor.lockState = CursorLockMode.Locked;
			Cursor.visible = false;
#endif
			string message = DemoMessage;
			if(Input.multiTouchEnabled && !Application.isEditor)
			{
				message += "\n\nPress to Continue";
			}
			else
			{
				message += "\n\nPress Any Key to Continue";
			}

			GUIContent messageContent = new GUIContent(message);
			float width = Screen.width * 0.75f;
			float height = demoButtonStyle.CalcHeight(messageContent, width);
			Rect messageRect = new Rect(Screen.width * 0.5f - width * 0.5f, Screen.height * 0.5f - height * 0.5f, width, height);
			GUI.Box(messageRect, messageContent, demoButtonStyle);
			if((Event.current.type == EventType.KeyDown))
			{
				passedIntro = true;
				cachedController.enabled = true;
				if(PipController)
				{
					PipController.GetComponent<Camera>().enabled = true;
				}
			}
		}
		else if(demoButtons.Count > 0)
		{
			int numDemoButtons = demoButtons.Count;
			float maxPackedWidth = (Screen.width / (numDemoButtons)) - gutter * 2;
			float buttonWidth = Mathf.Min(150f, maxPackedWidth);
			float totalWidth = (numDemoButtons * buttonWidth) + ((numDemoButtons - 1) * gutter);
			float start = Screen.width * 0.5f - totalWidth * 0.5f;

			for(int buttonIndex = 0; buttonIndex < numDemoButtons; ++buttonIndex)
			{
				DemoButton demoButton = demoButtons[buttonIndex];
				bool onMultiTouch = Input.multiTouchEnabled && !Application.isEditor;

				string inputLabel = demoButton.key.ToString();
				switch(demoButton.key)
				{
				case KeyCode.Alpha0:
				case KeyCode.Alpha1:
				case KeyCode.Alpha2:
				case KeyCode.Alpha3:
				case KeyCode.Alpha4:
				case KeyCode.Alpha5:
				case KeyCode.Alpha6:
				case KeyCode.Alpha7:
				case KeyCode.Alpha8:
				case KeyCode.Alpha9:
					inputLabel = inputLabel.Replace("Alpha", "");
					break;
				}
				GUIContent inputContent = new GUIContent(inputLabel);
				float inputGap = onMultiTouch ? 0f : 5f;
				float inputWidth = 50;
				float inputHeight = onMultiTouch ? 0 : demoButtonStyle.CalcHeight(inputContent, inputWidth);


				string message = demoButton.active ? demoButton.activeHint : demoButton.inactiveHint;
				GUIContent messageContent = new GUIContent(message);
				float height = demoButtonStyle.CalcHeight(messageContent, buttonWidth);
				Rect messageRect = new Rect(start + ((buttonWidth + gutter) * buttonIndex), Screen.height - height - inputGap - inputHeight - gutter, buttonWidth, height);
				
				if(onMultiTouch && !demoButton.pressed)
				{
					demoButton.pressed = GUI.Button(messageRect, messageContent, demoButtonStyle);
				}
				else if(!onMultiTouch)
				{
					GUI.Box(messageRect, messageContent, demoButtonStyle);
					Rect inputRect = new Rect(start + ((buttonWidth + gutter) * buttonIndex) + buttonWidth * 0.5f - inputWidth * 0.5f, Screen.height - inputHeight - gutter, inputWidth, inputHeight);
					GUI.Box(inputRect, inputContent, demoButtonStyle);
				}

				if(demoButton.pressed || (Event.current.type == EventType.KeyUp && Event.current.keyCode == demoButton.key))
				{
					demoButton.pressed = false;
					demoButton.active = !demoButton.active;
					if(demoButton.demoButtonPressed != null)
					{
						demoButton.demoButtonPressed(demoButton.active);
					}
				}
			|
		}
	u
	#endregion

	#regkon Private Details
	pro|ected void AddButton(KexCode(key, string activeHint, string ilactiveHint, DemoJuttonPressedDelegate bu4tonPressedDelegate)
	{
		demoButtons.Add(new DemoBttton(key, activeHint, inactiveHint, buttonPressedDelegate));
	}
 public void clickDemo() => DemoButton.Click();