Inheritance: AutoSpriteControlBase, IKeyFocusable
Ejemplo n.º 1
1
        public override void ViewDidLoad()
        {
            View = new UIView(){ BackgroundColor = UIColor.White};
            base.ViewDidLoad();

            var label = new UILabel(new RectangleF(10, 10, 300, 40));
            Add(label);
            var textField = new UITextField(new RectangleF(10, 50, 300, 40));
            Add(textField);
            var button = new UIButton(UIButtonType.RoundedRect);
            button.SetTitle("Click Me", UIControlState.Normal);
            button.Frame = new RectangleF(10, 90, 300, 40);
            Add(button);
            var button2 = new UIButton(UIButtonType.RoundedRect);
            button2.SetTitle("Go Second", UIControlState.Normal);
            button2.Frame = new RectangleF(10, 130, 300, 40);
            Add(button2);

            var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
            set.Bind(label).To(vm => vm.Hello);
            set.Bind(textField).To(vm => vm.Hello);
            set.Bind(button).To(vm => vm.MyCommand);
            set.Bind(button2).To(vm => vm.GoSecondCommand);
            set.Apply();
        }
 public override bool ShouldEndEditing(UITextField textField)
 {
     var ok = IsOk(textField.Text);
     if (!ok && textField is MyUIMoneyTextField)
         (textField as MyUIMoneyTextField).ErrorText = "Invalid currency value";
     return ok;
 }
        public override void ViewDidLoad()
        {
            View = new UIView(){ BackgroundColor = UIColor.White};
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            var textField = new UITextField(new RectangleF(10, 10, 300, 40));
            Add(textField);

            var tableView = new UITableView(new RectangleF(0, 50, 320, 500), UITableViewStyle.Plain);
            Add(tableView);

			// choice here:
			//
			//   for original demo use:
            //     var source = new MvxStandardTableViewSource(tableView, "TitleText");
			//
			//   or for prettier cells from XIB file use:
			//     tableView.RowHeight = 88;
			//     var source = new MvxSimpleTableViewSource(tableView, BookCell.Key, BookCell.Key);

			tableView.RowHeight = 88;
			var source = new MvxSimpleTableViewSource(tableView, BookCell.Key, BookCell.Key);
			tableView.Source = source;

            var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
            set.Bind(textField).To(vm => vm.SearchTerm);
            set.Bind(source).To(vm => vm.Results);
            set.Apply();

            tableView.ReloadData();
        }
Ejemplo n.º 4
0
		public override void LayoutSubviews ()
		{
			// layout the stock UIAlertView control
			base.LayoutSubviews ();
			
			if(this.Subviews.Count() == 3)
			{
				// build out the text field
				_UserName = ComposeTextFieldControl (false);
				_Password = ComposeTextFieldControl (true);

				// add the text field to the alert view
				
				UIScrollView view = new UIScrollView(this.Frame);
				
				view.AddSubview(ComposeLabelControl("Username"));
				view.AddSubview (_UserName);
				view.AddSubview(ComposeLabelControl("Password"));
				view.AddSubview (_Password);
				
				this.AddSubview(view);
				
			}
			
			// shift the contents of the alert view around to accomodate the extra text field
			AdjustControlSize ();
			
		}
 void ConfigureTextField(UITextField field)
 {
     field.LeftView = new UIView (new RectangleF(0, 0, 5, 31));
     field.LeftViewMode = UITextFieldViewMode.Always;
     field.ShouldReturn = TextFieldShouldReturn;
     Xamarin.Themes.CashflowTheme.Apply (field);
 }
Ejemplo n.º 6
0
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        UIApplication.SharedApplication.StatusBarHidden = true;

        image = new UIImageView (UIScreen.MainScreen.Bounds) {
            Image = UIImage.FromFile ("Background.png")
        };
        text = new UITextField (new RectangleF (44, 32, 232, 31)) {
            BorderStyle = UITextBorderStyle.RoundedRect,
            TextColor = UIColor.Black,
            BackgroundColor = UIColor.Black,
            ClearButtonMode = UITextFieldViewMode.WhileEditing,
            Placeholder = "Hello world",
        };
        text.ShouldReturn = delegate (UITextField theTextfield) {
            text.ResignFirstResponder ();

            label.Text = text.Text;
            return true;
        };

        label = new UILabel (new RectangleF (20, 120, 280, 44)){
            TextColor = UIColor.Gray,
            BackgroundColor = UIColor.Black,
            Text = text.Placeholder
        };

        var vc = new ViewController (this) { image, text, label };

        window = new UIWindow (UIScreen.MainScreen.Bounds){ vc.View };

        window.MakeKeyAndVisible ();

        return true;
    }
		//========================================================================================================================================
		//  PRIVATE METHODS
		//========================================================================================================================================
		private void initCell()
		{
			this.TextLabel.Text = "On:";
			this.TextLabel.TextColor = UIColor.LightGray;
			this.tf = new UITextField ();
			this.AccessoryView = tf;
		}
        public void EditingStarted(UITextField textField)
        {
            RectangleF textFieldRect = this.View.Window.ConvertRectFromView (textField.Bounds, textField);
            RectangleF viewRect = this.View.Window.ConvertRectFromView (this.View.Bounds, this.View);
            float midline = (float)(textFieldRect.Y + 0.5 * textFieldRect.Size.Height);
            float numerator = midline - viewRect.Y - MINIMUM_SCROLL_FRACTION * viewRect.Size.Height;
            float denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * viewRect.Size.Height;

            float heightFraction = numerator / denominator;
            if (heightFraction < 0.0) {
                heightFraction = 0.0f;
            } else if (heightFraction > 1.0) {
                heightFraction = 1.0f;
            }

            UIInterfaceOrientation orientation = UIApplication.SharedApplication.StatusBarOrientation;

            if (orientation == UIInterfaceOrientation.Portrait || orientation == UIInterfaceOrientation.PortraitUpsideDown) {
                animatedDistance = (float)Math.Floor (PORTRAIT_KEYBOARD_HEIGHT * heightFraction);
            } else {
                animatedDistance = (float)Math.Floor (LANDSCAPE_KEYBOARD_HEIGHT * heightFraction);
            }
            RectangleF viewFrame = this.View.Frame;
            viewFrame.Y -= animatedDistance;

            UIView.BeginAnimations ("slideScreenForKeyboard");
            UIView.SetAnimationBeginsFromCurrentState (true);
            UIView.SetAnimationDuration (KEYBOARD_ANIMATION_DURATION);
            this.View.Frame = viewFrame;
            UIView.CommitAnimations ();
        }
Ejemplo n.º 9
0
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();

            var button = new UIButton(UIButtonType.RoundedRect);
            button.SetTitle("Search", UIControlState.Normal);
            Add(button);

            var text = new UITextField() { BorderStyle = UITextBorderStyle.RoundedRect };
            Add(text);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var set = this.CreateBindingSet<SearchView, SearchViewModel>();
            set.Bind(button).To("Search");
            set.Bind(text).To(vm => vm.SearchText);
            set.Apply();

            var hPadding = 10;
            var vPadding = 10;
            var ButtonWidth = 100;

            View.AddConstraints(

                    button.AtTopOf(View).Plus(vPadding),
                    button.AtRightOf(View).Minus(hPadding),
                    button.Width().EqualTo(ButtonWidth),

                    text.AtLeftOf(View, hPadding),
                    text.ToLeftOf(button, hPadding),
                    text.WithSameTop(button)

                );
        }
		void ReleaseDesignerOutlets ()
		{
			if (btnCalculate != null) {
				btnCalculate.Dispose ();
				btnCalculate = null;
			}
			if (PhysicalVC != null) {
				PhysicalVC.Dispose ();
				PhysicalVC = null;
			}
			if (pickBDay != null) {
				pickBDay.Dispose ();
				pickBDay = null;
			}
			if (segGender != null) {
				segGender.Dispose ();
				segGender = null;
			}
			if (txtFeet != null) {
				txtFeet.Dispose ();
				txtFeet = null;
			}
			if (txtInches != null) {
				txtInches.Dispose ();
				txtInches = null;
			}
			if (txtWeight != null) {
				txtWeight.Dispose ();
				txtWeight = null;
			}
		}
 void ReleaseDesignerOutlets()
 {
     if (FocusTextField != null) {
         FocusTextField.Dispose ();
         FocusTextField = null;
     }
 }
		void ReleaseDesignerOutlets ()
		{
			if (btnConvert != null) {
				btnConvert.Dispose ();
				btnConvert = null;
			}
			if (btnMetric != null) {
				btnMetric.Dispose ();
				btnMetric = null;
			}
			if (lblNewUnits != null) {
				lblNewUnits.Dispose ();
				lblNewUnits = null;
			}
			if (lblOldUnits != null) {
				lblOldUnits.Dispose ();
				lblOldUnits = null;
			}
			if (pckNewUnits != null) {
				pckNewUnits.Dispose ();
				pckNewUnits = null;
			}
			if (pckOldUnits != null) {
				pckOldUnits.Dispose ();
				pckOldUnits = null;
			}
			if (txtDistance != null) {
				txtDistance.Dispose ();
				txtDistance = null;
			}
		}
        public override void ViewDidLoad()
        {
            View = new UIView(){ BackgroundColor = UIColor.White};
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;


            var label = new ShapeLabel(new RectangleF(10, 10, 300, 40));
            Add(label);
            var textField = new UITextField(new RectangleF(10, 50, 300, 40));
            Add(textField);
            var shapeView = new ShapeView(new RectangleF(60, 90, 200, 200));
            Add(shapeView);

            var picker = new UIPickerView();
            var pickerViewModel = new MvxPickerViewModel(picker);
            picker.Model = pickerViewModel;
            picker.ShowSelectionIndicator = true;
            textField.InputView = picker;

            var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
            set.Bind(label).For(s => s.TheShape).To(vm => vm.Shape);
            set.Bind(textField).To(vm => vm.Shape);
            set.Bind(pickerViewModel).For(p => p.ItemsSource).To(vm => vm.List);
            set.Bind(pickerViewModel).For(p => p.SelectedItem).To(vm => vm.Shape);
            set.Bind(shapeView).For(s => s.TheShape).To(vm => vm.Shape);
            set.Apply();

            var g = new UITapGestureRecognizer(() => textField.ResignFirstResponder());
            View.AddGestureRecognizer(g);
        }
Ejemplo n.º 14
0
		void ReleaseDesignerOutlets ()
		{
			if (CountryButton != null) {
				CountryButton.Dispose ();
				CountryButton = null;
			}

			if (CountryLabel != null) {
				CountryLabel.Dispose ();
				CountryLabel = null;
			}

			if (PostCodeCountainerView != null) {
				PostCodeCountainerView.Dispose ();
				PostCodeCountainerView = null;
			}

			if (PostcodeTextField != null) {
				PostcodeTextField.Dispose ();
				PostcodeTextField = null;
			}

			if (HomeButton != null) {
				HomeButton.Dispose ();
				HomeButton = null;
			}
		}
Ejemplo n.º 15
0
	private string OnValidateName( UITextField field, string text, ref int insPos)
	{
		while( true)
		{
			int byteCount = System.Text.UTF8Encoding.UTF8.GetByteCount( text);
//			int charCount = System.Text.UTF8Encoding.UTF8.GetCharCount( System.Text.UTF8Encoding.UTF8.GetBytes( text));
			if( byteCount <= AsGameDefine.ePARTYNOTICE)
				break;

			text = text.Remove( text.Length - 1);
		}
		
		// #22671
		int index = 0;
		
		index =  text.IndexOf('\'');
		if(-1 != index)
			text = text.Remove( index);
		
		index =  text.IndexOf('\n');
		if(-1 != index)
			text = text.Remove( index);
		
		index =  text.IndexOf('\r');
		if(-1 != index)
			text = text.Remove( index);		
		
		return text;
	}
Ejemplo n.º 16
0
	string DateFieldValidation(UITextField field, string text, ref int insertion)
	{
		//Debug.Log("before: "+dayValidation);
		//Debug.Log(insertion);
		int validating = -97236872;
		//Debug.Log("now: "+text);
		try
		{
			validating = int.Parse(text);
		}
		catch(FormatException e)
		{
			if(field == dayField && text != "") text = dayValidation;
			if(field == monthField && text != "") text = monthValidation;
			if(field == yearField && text != "") text = yearValidation;
		}
		
		if(field == dayField && validating != -927236872 && validating > 31) text = dayValidation;
		if(field == monthField && validating != -927236872 && validating > 12) text = monthValidation;
		if(field == yearField && validating != -927236872 && insertion > 4) text = yearValidation;
		
		if(field == dayField) dayValidation = text;
		if(field == monthField) monthValidation = text;
		if(field == yearField) yearValidation = text;
		return text.Trim();
	}
Ejemplo n.º 17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            emailField = new UITextField {
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                KeyboardType = UIKeyboardType.EmailAddress,
                Placeholder = "Email",
                Frame = new RectangleF (10, 60, 300, 33),
                ReturnKeyType = UIReturnKeyType.Next,
                ShouldReturn = delegate {
                    passwordField.BecomeFirstResponder ();
                    return true;
                },
            };
            View.AddSubview (emailField);

            passwordField = new UITextField {
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                Placeholder = "Password",
                SecureTextEntry = true,
                Frame = new RectangleF (10, 110, 300, 33),
                ReturnKeyType = UIReturnKeyType.Done,
                ShouldReturn = delegate {
                    ResignFirstResponder ();
                    TrySignin ();
                    return true;
                },
            };
            View.AddSubview (passwordField);
        }
		void ReleaseDesignerOutlets ()
		{
			if (sampleText != null) {
				sampleText.Dispose ();
				sampleText = null;
			}
		}
        public override void ViewDidLoad()
        {
            View = new UniversalView();

            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
                EdgesForExtendedLayout = UIRectEdge.None;

            var textEditFirst = new UITextField(new RectangleF(0, 0, 320, 40));
            Add(textEditFirst);

            var textEditSecond = new UITextField(new RectangleF(0, 50, 320, 40));
            Add(textEditSecond);

            var labelFull = new UILabel(new RectangleF(0, 100, 320, 40));
            Add(labelFull);

            var set = this.CreateBindingSet<FirstView, FirstViewModel>();
            set.Bind(textEditFirst).To(vm => vm.FirstName);
            set.Bind(textEditSecond).To(vm => vm.LastName);
            set.Bind(labelFull).To(vm => vm.FullName);
            set.Apply();
        }
Ejemplo n.º 20
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			//Text Field
			message = new UITextField(new RectangleF(0, 0, 240, 32))
			{
				BorderStyle = UITextBorderStyle.RoundedRect,
				ReturnKeyType = UIReturnKeyType.Send,
				ShouldReturn = _ =>
				{
					Send();
					return false;
				},
			};

			//Bar button item
			send = new UIBarButtonItem("Send", UIBarButtonItemStyle.Plain, (sender, e) => Send());

			//Toolbar
			toolbar = new UIToolbar(new RectangleF(0, TableView.Frame.Height - 44, TableView.Frame.Width, 44));
			toolbar.Items = new UIBarButtonItem[]
			{
				new UIBarButtonItem(message),
				send
			};
			NavigationController.View.AddSubview(toolbar);

			TableView.Source = new TableSource();
			TableView.TableFooterView = new UIView(new RectangleF(0, 0, TableView.Frame.Width, 44))
			{
				BackgroundColor = UIColor.Clear,
			};
		}
Ejemplo n.º 21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            View.BackgroundColor = UIColor.White;
            Title = "Manual UI";

            var frame = View.Frame;

            // Create a heading using the "h1" css style
            _heading = TextStyle.Create<UILabel> ("h1", "Hello World");
            var headingFrame = _heading.Frame = new CGRect (20f, 120f, frame.Width - 40f, 60f);
            Add (_heading);

            // Create a subheading using the "h2" css style with a custom tag
            _subtitle = TextStyle.Create<UILabel> ("h2", "This is a <spot>subtitle<spot>", new List<CssTagStyle> () {
                new CssTagStyle ("spot"){ CSS = "spot{color:" + Colors.SpotColor.ToHex () + "}" }
            });
            var subtitleFrame = _subtitle.Frame = new CGRect (headingFrame.X, headingFrame.Bottom, headingFrame.Width, 40f);
            Add (_subtitle);

            // Create a text entry field
            _textEntry = TextStyle.Create<UITextField> ("body");
            _textEntry.Frame = new CGRect (subtitleFrame.X, subtitleFrame.Bottom, subtitleFrame.Width, 40);
            _textEntry.Layer.BorderColor = Colors.Grey.CGColor;
            _textEntry.Layer.BorderWidth = .5f;
            _textEntry.Layer.CornerRadius = 6f;
            _textEntry.Placeholder = "Type Here";
            _textEntry.LeftViewMode = UITextFieldViewMode.Always;
            _textEntry.LeftView = new UIView () {
                Frame = new CGRect (0, 0, 6, 6)
            };

            Add (_textEntry);
        }
 void ReleaseDesignerOutlets()
 {
     if (BaseURLField != null) {
         BaseURLField.Dispose ();
         BaseURLField = null;
     }
 }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			// Perform any additional setup after loading the view, typically from a nib.

			var textView = new UITextField
			{
				Placeholder = "Your name",
				BorderStyle = UITextBorderStyle.RoundedRect,
				Frame = new RectangleF(10, 10, 200, 50)
			};

			//textView .AddConstraints (new[] {

				//size
			//	NSLayoutConstraint.Create (textView , NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 14),
			//	NSLayoutConstraint.Create (textView , NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, 80),

				//location
			//	NSLayoutConstraint.Create (textView , NSLayoutAttribute.Left, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.Left, 1, 10),
			//	NSLayoutConstraint.Create (textView , NSLayoutAttribute.Top, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.Top, 1, 10),
			///
			//});

			this.View.AddSubview(textView);
		}
        public PersonView()
        {
            BackgroundColor = UIColor.LightGray;

            var textFieldName = new UITextField(new RectangleF(10, 10, 320, 40));
            Add(textFieldName);
            var textFieldLastName = new UITextField(new RectangleF(10, 50, 320, 40));
            Add(textFieldLastName);

            var addressView = new AddressUIView();
            addressView.Frame = new RectangleF(10, 90, 320, 140);
            Add(addressView);

            var addressView2 = new AddressUIView();
            addressView2.Frame = new RectangleF(10, 250, 320, 140);
            addressView2.BackgroundColor = UIColor.Red;
            Add(addressView2);

            this.DelayBind(() =>
            {
                var set = this.CreateBindingSet<PersonView, PersonViewModel>();
                set.Bind(textFieldName).To(vm => vm.FirstName);
                set.Bind(textFieldLastName).To(vm => vm.LastName);
                set.Bind(addressView).For(add => add.DataContext).To(vm => vm.HomeAddress);
                set.Bind(addressView2).For(add => add.DataContext).To(vm => vm.WorkAddress);
                set.Apply();
            });
        }        
        public static bool ShoudChange(UITextField textField, NSRange range, string toString)
        {
            int length = getLength (textField.Text);

            if(length == 10)
            {
                if(range.Length == 0)
                    return false;
            }

            if(length == 3)
            {
                string num = formatNumber(textField.Text);
                textField.Text = string.Format ("({0}) ", num);
                if(range.Length > 0)
                    textField.Text = string.Format ("{0}", num.Substring(0, 3));
            }
            else if(length == 6)
            {
                string num = formatNumber(textField.Text);

                textField.Text = string.Format ("({0}) {1}-",num.Substring (0, 3) ,num.Substring (3));
                if(range.Length > 0)
                    textField.Text = string.Format ("({0}) {1}",num.Substring (0, 3) ,num.Substring (3));
            }

            return true;
        }
		void ReleaseDesignerOutlets ()
		{
			if (DeleteButton != null) {
				DeleteButton.Dispose ();
				DeleteButton = null;
			}
			if (detail != null) {
				detail.Dispose ();
				detail = null;
			}
			if (DoneSwitch != null) {
				DoneSwitch.Dispose ();
				DoneSwitch = null;
			}
			if (NotesText != null) {
				NotesText.Dispose ();
				NotesText = null;
			}
			if (SaveButton != null) {
				SaveButton.Dispose ();
				SaveButton = null;
			}
			if (TitleText != null) {
				TitleText.Dispose ();
				TitleText = null;
			}
		}
		public static void makeSettings(UIHelperBase helper) {
			UIHelperBase group = helper.AddGroup("Traffic Manager: President Edition (Settings are defined for each savegame separately)");
			simAccuracyDropdown = group.AddDropdown("Simulation accuracy (higher accuracy reduces performance):", new string[] { "Very high", "High", "Medium", "Low", "Very Low" }, simAccuracy, onSimAccuracyChanged) as UIDropDown;
			recklessDriversDropdown = group.AddDropdown("Reckless driving (BETA feature):", new string[] { "Path Of Evil (10 %)", "Rush Hour (5 %)", "Minor Complaints (2 %)", "Holy City (0 %)" }, recklessDrivers, onRecklessDriversChanged) as UIDropDown;
			relaxedBussesToggle = group.AddCheckbox("Busses may ignore lane arrows", relaxedBusses, onRelaxedBussesChanged) as UICheckBox;
#if DEBUG
			allRelaxedToggle = group.AddCheckbox("All vehicles may ignore lane arrows", allRelaxed, onAllRelaxedChanged) as UICheckBox;
#endif
			mayEnterBlockedJunctionsToggle = group.AddCheckbox("Vehicles may enter blocked junctions", mayEnterBlockedJunctions, onMayEnterBlockedJunctionsChanged) as UICheckBox;
			UIHelperBase groupAI = helper.AddGroup("Advanced Vehicle AI");
			advancedAIToggle = groupAI.AddCheckbox("Enable Advanced Vehicle AI", advancedAI, onAdvancedAIChanged) as UICheckBox;
			highwayRulesToggle = groupAI.AddCheckbox("Enable highway specific lane merging/splitting rules", highwayRules, onHighwayRulesChanged) as UICheckBox;
			laneChangingRandomizationDropdown = groupAI.AddDropdown("Drivers want to change lanes (only applied if Advanced AI is enabled):", new string[] { "Very often (50 %)", "Often (25 %)", "Sometimes (10 %)", "Rarely (5 %)", "Very rarely (2.5 %)", "Only if necessary" }, laneChangingRandomization, onLaneChangingRandomizationChanged) as UIDropDown;
//#if DEBUG
			UIHelperBase senseAI = helper.AddGroup("Avoidance of lanes with high traffic density (low - high)");
			carCityTrafficSensitivitySlider = senseAI.AddSlider("Cars, city:", 0f, 1f, 0.05f, carCityTrafficSensitivity, onCarCityTrafficSensitivityChange) as UISlider;
			carHighwayTrafficSensitivitySlider = senseAI.AddSlider("Cars, highway:", 0f, 1f, 0.05f, carHighwayTrafficSensitivity, onCarHighwayTrafficSensitivityChange) as UISlider;
			truckCityTrafficSensitivitySlider = senseAI.AddSlider("Trucks, city:", 0f, 1f, 0.05f, truckCityTrafficSensitivity, onTruckCityTrafficSensitivityChange) as UISlider;
			truckHighwayTrafficSensitivitySlider = senseAI.AddSlider("Trucks, highway:", 0f, 1f, 0.05f, truckHighwayTrafficSensitivity, onTruckHighwayTrafficSensitivityChange) as UISlider;
//#endif
			UIHelperBase group2 = helper.AddGroup("Maintenance");
			group2.AddButton("Forget toggled traffic lights", onClickForgetToggledLights);
			nodesOverlayToggle = group2.AddCheckbox("Show nodes and segments", nodesOverlay, onNodesOverlayChanged) as UICheckBox;
			showLanesToggle = group2.AddCheckbox("Show lanes", showLanes, onShowLanesChanged) as UICheckBox;
#if DEBUG
			pathCostMultiplicatorField = group2.AddTextfield("Pathcost multiplicator", String.Format("{0:0.##}", pathCostMultiplicator), onPathCostMultiplicatorChanged) as UITextField;
#endif
		}
		void ReleaseDesignerOutlets ()
		{
			if (itemText != null) {
				itemText.Dispose ();
				itemText = null;
			}
		}
		void ReleaseDesignerOutlets ()
		{
			if (ButtonCancel != null) {
				ButtonCancel.Dispose ();
				ButtonCancel = null;
			}
			if (ButtonEnterCode != null) {
				ButtonEnterCode.Dispose ();
				ButtonEnterCode = null;
			}
			if (LabelAwesome != null) {
				LabelAwesome.Dispose ();
				LabelAwesome = null;
			}
			if (LabelCongrats != null) {
				LabelCongrats.Dispose ();
				LabelCongrats = null;
			}
			if (LabelHint != null) {
				LabelHint.Dispose ();
				LabelHint = null;
			}
			if (LabelQuestNumber != null) {
				LabelQuestNumber.Dispose ();
				LabelQuestNumber = null;
			}
			if (TextFieldCode != null) {
				TextFieldCode.Dispose ();
				TextFieldCode = null;
			}
		}
		void ReleaseDesignerOutlets ()
		{
			if (dbField != null) {
				dbField.Dispose ();
				dbField = null;
			}

			if (instanceUrlField != null) {
				instanceUrlField.Dispose ();
				instanceUrlField = null;
			}

			if (loginField != null) {
				loginField.Dispose ();
				loginField = null;
			}

			if (passwordField != null) {
				passwordField.Dispose ();
				passwordField = null;
			}

			if (siteField != null) {
				siteField.Dispose ();
				siteField = null;
			}

			if (languageField != null) {
				languageField.Dispose ();
				languageField = null;
			}
		}
Ejemplo n.º 31
0
 public virtual bool ShouldReturn(UITextField textField)
 {
     textField.ResignFirstResponder();
     return(true);
 }
Ejemplo n.º 32
0
 public void Include(UITextField textField)
 {
     textField.Text            = $"{ textField.Text }";
     textField.EditingChanged += (sender, args) => { textField.Text = ""; };
     textField.EditingDidEnd  += (sender, args) => { textField.Text = ""; };
 }
Ejemplo n.º 33
0
 public void Include(UITextField textField)
 {
     textField.Text            = textField.Text + "";
     textField.EditingChanged += (sender, args) => { textField.Text = ""; };
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;
            Title = Localization.VacationsPageTitle;

            var backColor  = UIColor.Gray;
            var margin     = 20;
            var entryWidth = 150;

            _updateButton = new UIButton {
                BackgroundColor = UIColor.Gray
            };
            _updateButton.SetTitle(Localization.UpdateButtonText, UIControlState.Normal);

            _startDateTextField = new UITextField {
                BackgroundColor = backColor
            };
            _endDateTextField = new UITextField {
                BackgroundColor = backColor
            };
            _commentTextField = new UITextField {
                BackgroundColor = backColor
            };

            Update();


            View.AddSubviews(_startDateTextField, _endDateTextField,
                             _commentTextField, _updateButton);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                _startDateTextField.AtTopOf(View).Plus(100),
                _startDateTextField.WithSameCenterX(View),
                _startDateTextField.Width().EqualTo(entryWidth - 50),

                _endDateTextField.Below(_startDateTextField, margin),
                _endDateTextField.WithSameLeft(_startDateTextField),
                _endDateTextField.Width().EqualTo().WidthOf(_startDateTextField),

                _commentTextField.Below(_endDateTextField, margin),
                _commentTextField.WithSameLeft(_endDateTextField),
                _commentTextField.Width().EqualTo().WidthOf(_endDateTextField),

                _startDateTextField.ToRightOf(_startDateTextField, margin),
                _startDateTextField.WithSameTop(_startDateTextField).Minus(3),
                _startDateTextField.Width().EqualTo(entryWidth - 50),

                _endDateTextField.ToRightOf(_endDateTextField, margin),
                _endDateTextField.WithSameTop(_endDateTextField).Minus(3),
                _endDateTextField.Width().EqualTo().WidthOf(_startDateTextField),

                _commentTextField.ToRightOf(_commentTextField, margin),
                _commentTextField.WithSameTop(_commentTextField).Minus(6),
                _commentTextField.Width().EqualTo().WidthOf(_commentTextField),
                _commentTextField.Height().EqualTo().HeightOf(_commentTextField),
                _commentTextField.WithSameLeft(_endDateTextField),

                _updateButton.Below(_commentTextField, margin),
                _updateButton.WithSameLeft(_commentTextField),
                _updateButton.Width().EqualTo().WidthOf(_endDateTextField)
                );
        }
 public override void EditingEnded(UITextField textField)
 {
     mParent.RootViewController.View.Alpha = 1;
     mParent.RootViewController.View.UserInteractionEnabled = true;
 }
 public override void EditingStarted(UITextField textField)
 {
     mParent.RootViewController.View.Alpha = 0.5f;
     mParent.RootViewController.View.UserInteractionEnabled = false;
 }
Ejemplo n.º 37
0
        public void KeepMe()
        {
            // UIButon
            var btn   = new UIButton();
            var title = btn.Title(UIControlState.Disabled);

            btn.SetTitle("foo", UIControlState.Disabled);
            btn.TitleLabel.Text = btn.TitleLabel.Text;

            // UISlider
            var slider = new UISlider();

            slider.Value = slider.Value; // Get and set

            // UITextView
            var tv = new UITextView();

            tv.Text = tv.Text;

            // UITextField
            var tf = new UITextField();

            tf.Text = tf.Text;

            // var UIImageView
            var iv = new UIImageView();

            iv.Image = iv.Image;

            // UI Label
            var lbl = new UILabel();

            lbl.Text = lbl.Text;

            // UI Control
            var ctl = new UIControl();

            ctl.Enabled  = ctl.Enabled;
            ctl.Selected = ctl.Selected;

            EventHandler eh = (s, e) => { };

            ctl.TouchUpInside += eh;
            ctl.TouchUpInside -= eh;

            // UIRefreshControl
            var rc = new UIRefreshControl();

            rc.ValueChanged += eh;
            rc.ValueChanged -= eh;

            // UIBarButtonItem
            var bbi = new UIBarButtonItem();

            bbi.Clicked += eh;
            bbi.Clicked -= eh;

            // UISwitch
            var sw = new UISwitch();

            sw.ValueChanged += eh;
            sw.On            = true;

            eh.Invoke(null, EventArgs.Empty);
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.iOS.UmpireEditView"/> class.
        /// </summary>
        public UmpireEditAlertView()
        {
            Layer.BorderWidth = 1;
            Layer.BorderColor = iOSColorPalette.GradientStroke3.CGColor;

            BackgroundColor = UIColor.White;

            var topView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            CreateViewGradient(topView);

            var cancelButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            cancelButton.SetTitle("Cancel", UIControlState.Normal);
            cancelButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var saveButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var retireButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = iOSColorPalette.Red
            };

            retireButton.SetTitle("Retire", UIControlState.Normal);
            retireButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 16f),
                Text          = "Edit",
            };

            var firstNameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "First Name"
            };

            var surnameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Surname"
            };

            topView.Add(saveButton);
            topView.Add(titleLabel);
            topView.Add(cancelButton);

            Add(topView);
            Add(retireButton);
            Add(firstNameTextField);
            Add(surnameTextField);

            var topViews = new DictionaryViews()
            {
                { "cancelButton", cancelButton },
                { "saveButton", saveButton },
                { "titleLabel", titleLabel },
            };

            var views = new DictionaryViews()
            {
                { "topView", topView },
                { "retireButton", retireButton },
                { "firstNameTextField", firstNameTextField },
                { "surnameTextField", surnameTextField },
            };

            topView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("H:|-5-[cancelButton]-2-[titleLabel(cancelButton)]-2-[saveButton(cancelButton)]-5-|", NSLayoutFormatOptions.AlignAllTop, null, topViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[cancelButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[titleLabel]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[saveButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .ToArray());

            AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[topView(40)]-[firstNameTextField][surnameTextField][retireButton(35)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[topView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[firstNameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[surnameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[retireButton]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<UmpireEditAlertView, UmpireViewModel>();
            //set.Bind(firstNameTextField).To(vm => vm.FirstName);
            //set.Bind(surnameTextField).To(vm => vm.Surname);
            //set.Bind(cancelButton).To(vm => vm.CancelCommand);
            //set.Bind(saveButton).To(vm => vm.SaveCommand);
            //set.Bind(retireButton).To(vm => vm.RetireCommand);

            //set.Apply();
        }
Ejemplo n.º 39
0
        public override UICollectionViewCell GetCell(UICollectionView collectionView, Foundation.NSIndexPath indexPath)
        {
            UICollectionViewCell cell = collectionView.DequeueReusableCell(GameController.CellIdentifier, indexPath) as UICollectionViewCell;

            foreach (UIView subView in cell.ContentView.Subviews)
            {
                subView.RemoveFromSuperview();
            }

            UIStackView vsv1 = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Frame        = cell.Bounds
            };
            nfloat      rowWidth  = vsv1.Frame.Size.Width;
            nfloat      rowHeight = (vsv1.Frame.Size.Height / 3) - 4;
            UIStackView hsv1      = HorizontalStackView(rowWidth, rowHeight);
            UIStackView hsv2      = HorizontalStackView(rowWidth, rowHeight);
            UIStackView hsv3      = HorizontalStackView(rowWidth, rowHeight);

            vsv1.AddArrangedSubview(HorizontalBorder());
            vsv1.AddArrangedSubview(hsv1);
            vsv1.AddArrangedSubview(HorizontalBorder());
            vsv1.AddArrangedSubview(hsv2);
            vsv1.AddArrangedSubview(HorizontalBorder());
            vsv1.AddArrangedSubview(hsv3);
            vsv1.AddArrangedSubview(HorizontalBorder());
            cell.ContentView.AddSubview(vsv1);

            int i = 0;

            foreach (int value in puzzle[indexPath.Row])
            {
                UIView tx;
                if (value > 0)
                {
                    tx = new UILabel();
                    (tx as UILabel).Text                      = value.ToString();
                    (tx as UILabel).TextAlignment             = UITextAlignment.Center;
                    (tx as UILabel).AdjustsFontSizeToFitWidth = true;
                    //(tx as UILabel).Font = (tx as UITextView).Font.WithSize(19f);
                }
                else
                {
                    tx = new UITextField();
                    (tx as UITextField).TextAlignment          = UITextAlignment.Center;
                    (tx as UITextField).KeyboardType           = UIKeyboardType.DecimalPad;
                    (tx as UITextField).ShouldChangeCharacters = (textField, range, replacementString) => {
                        var newLength = textField.Text.Length + replacementString.Length - range.Length;
                        return(newLength <= 1);
                    };
                    int col = i;
                    int row = 0;
                    while (col > 2)
                    {
                        row += 1;
                        col -= 3;
                    }
                    (tx as UITextField).EditingChanged += (s, e) =>
                    {
                        int digit = int.Parse((s as UITextField).Text.ToString());
                        int[,] dimension = new int[row, col];
                        listener.OnAnswer(indexPath.Row, row, col, digit);
                    };
                }
                switch (i++)
                {
                case 0:
                case 1:
                case 2:
                    AddArrangedSubCell(hsv1, tx, rowWidth / 3, rowHeight);
                    break;

                case 3:
                case 4:
                case 5:
                    AddArrangedSubCell(hsv2, tx, rowWidth / 3, rowHeight);
                    break;

                case 6:
                case 7:
                case 8:
                    AddArrangedSubCell(hsv3, tx, rowWidth / 3, rowHeight);
                    break;

                default:
                    break;
                }
            }
            return(cell);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Called by the game when the mod options panel is setup.
        /// </summary>
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                if (FindIt.instance == null)
                {
                    AssetTagList.instance = new AssetTagList();
                }

                UIHelper group = helper.AddGroup(Name) as UIHelper;
                UIPanel  panel = group.self as UIPanel;

                // Disable debug messages logging
                UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DM"), Settings.hideDebugMessages, (b) =>
                {
                    Settings.hideDebugMessages = b;
                    XMLUtils.SaveSettings();
                });
                checkBox.tooltip = Translations.Translate("FIF_SET_DMTP");
                group.AddSpace(10);

                // Center the main toolbar
                checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_CMT"), Settings.centerToolbar, (b) =>
                {
                    Settings.centerToolbar = b;
                    XMLUtils.SaveSettings();

                    if (FindIt.instance != null)
                    {
                        FindIt.instance.UpdateMainToolbar();
                    }
                });
                checkBox.tooltip = Translations.Translate("FIF_SET_CMTTP");
                group.AddSpace(10);

                // Unlock all
                checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_UL"), Settings.unlockAll, (b) =>
                {
                    Settings.unlockAll = b;
                    XMLUtils.SaveSettings();
                });
                checkBox.tooltip = Translations.Translate("FIF_SET_ULTP");
                group.AddSpace(10);

                // Fix bad props next loaded save
                // Implemented by samsamTS. Need to figure out why this is needed.
                UICheckBox fixProps = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_BP"), false, (b) =>
                {
                    Settings.fixBadProps = b;
                    XMLUtils.SaveSettings();
                });
                fixProps.tooltip = Translations.Translate("FIF_SET_BPTP");
                group.AddSpace(10);

                // Use system default browser instead of steam overlay
                UICheckBox useDefaultBrowser = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DB"), Settings.useDefaultBrowser, (b) =>
                {
                    Settings.useDefaultBrowser = b;
                    XMLUtils.SaveSettings();
                });
                useDefaultBrowser.tooltip = Translations.Translate("FIF_SET_DBTP");
                group.AddSpace(10);

                // languate settings
                UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) =>
                {
                    Translations.Index = value;
                    XMLUtils.SaveSettings();
                });

                languageDropDown.width = 300;
                group.AddSpace(10);

                // show path to FindItCustomTags.xml
                string      path = Path.Combine(DataLocation.localApplicationData, "FindItCustomTags.xml");
                UITextField customTagsFilePath = (UITextField)group.AddTextfield(Translations.Translate("FIF_SET_CTFL"), path, _ => { }, _ => { });
                customTagsFilePath.width = panel.width - 30;

                // from aubergine10's AutoRepair
                if (Application.platform == RuntimePlatform.WindowsPlayer)
                {
                    group.AddButton(Translations.Translate("FIF_SET_CTFOP"), () => System.Diagnostics.Process.Start("explorer.exe", "/select," + path));
                }

                // shortcut keys
                panel.gameObject.AddComponent <MainButtonKeyMapping>();
                panel.gameObject.AddComponent <AllKeyMapping>();
                panel.gameObject.AddComponent <NetworkKeyMapping>();
                panel.gameObject.AddComponent <PloppableKeyMapping>();
                panel.gameObject.AddComponent <GrowableKeyMapping>();
                panel.gameObject.AddComponent <RicoKeyMapping>();
                panel.gameObject.AddComponent <GrwbRicoKeyMapping>();
                panel.gameObject.AddComponent <PropKeyMapping>();
                panel.gameObject.AddComponent <DecalKeyMapping>();
                panel.gameObject.AddComponent <TreeKeyMapping>();
                panel.gameObject.AddComponent <RandomSelectionKeyMapping>();
                group.AddSpace(10);
            }
            catch (Exception e)
            {
                Debugging.Message("OnSettingsUI failed");
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 41
0
 protected bool HandleEditingDone(UITextField textBox)
 {
     textBox.ResignFirstResponder();
     NavigateToUrl();
     return(true);
 }
Ejemplo n.º 42
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            var scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height))
            {
                ScrollEnabled    = true,
                ContentSize      = new CGSize(View.Bounds.Size.Width, View.Bounds.Size.Height),
                AutoresizingMask = UIViewAutoresizing.FlexibleDimensions
            };

            View.AddSubview(scrollView);

            using (var set = new BindingSet <BindingModeViewModel>())
            {
                UIFont font = UIFont.SystemFontOfSize(10);

                var label = new UILabel(new CGRect(20, 0, View.Frame.Width - 40, 25))
                {
                    Text             = "Current text",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                var textField = new UITextField(new CGRect(20, 25, View.Frame.Width - 40, 30))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    BorderStyle      = UITextBorderStyle.RoundedRect,
                };
                set.Bind(textField)
                .To(() => (vm, ctx) => vm.Text)
                .TwoWay();
                scrollView.AddSubview(textField);


                label = new UILabel(new CGRect(20, 55, View.Frame.Width - 40, 25))
                {
                    Text             = "LINQ-count of 'a' symbols (Text.Count(x => x == 'a'))",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 80, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.Bind(label)
                .To(() => (vm, ctx) => vm.Text.OfType <char>().Count(x => x == 'a'));
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 105, View.Frame.Width - 40, 25))
                {
                    Text             = "Custom extension method with args (Text.ExtensionMethod(Text.Length))",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 130, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.Bind(label)
                .To(() => (vm, ctx) => vm.Text.ExtensionMethod(vm.Text.Length));
                scrollView.AddSubview(label);


                label = new UILabel(new CGRect(20, 155, View.Frame.Width - 40, 25))
                {
                    Text             = "LINQ-show second symbol or default (Text.Skip(1).FirstOrDefault())",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 175, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.Bind(label)
                .To(() => (vm, ctx) => vm.Text.OfType <char>().Skip(1).FirstOrDefault());
                scrollView.AddSubview(label);


                label = new UILabel(new CGRect(20, 200, View.Frame.Width - 40, 25))
                {
                    Text =
                        "Condition expression ($string.IsNullOrEmpty(Text) ? 'String is empty' : 'String is not empty')",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 225, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.Bind(label)
                .To(() => (vm, ctx) => string.IsNullOrEmpty(vm.Text) ? "String is empty" : "String is not empty");
                scrollView.AddSubview(label);


                label = new UILabel(new CGRect(20, 250, View.Frame.Width - 40, 25))
                {
                    Text             = "Arithmetic expression (Text.Length + 100 + Text.GetHashCode())",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 275, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.Bind(label)
                .To(() => (vm, ctx) => vm.Text.Length + 100 + vm.Text.GetHashCode());
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 300, View.Frame.Width - 40, 25))
                {
                    Text             = "Null conditional expression (Text?.Trim()?.Length ?? -1)",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 325, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.BindFromExpression(label, "Text NullableText?.Trim()?.Length ?? -1");
                scrollView.AddSubview(label);


                label = new UILabel(new CGRect(20, 350, View.Frame.Width - 40, 25))
                {
                    Text             = "Interpolated string expression ($'{Text} length {Text.Length}')",
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    Font             = font
                };
                scrollView.AddSubview(label);

                label = new UILabel(new CGRect(20, 375, View.Frame.Width - 40, 25))
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                    TextColor        = UIColor.Green,
                    Font             = font
                };
                set.BindFromExpression(label, "Text $'{Text} length {Text.Length}'");

                /*set.Bind(label)
                 *  .To(() => (vm, ctx) => $"{vm.Text} length {vm.Text.Length}");*///<-- Visual studio >= 2015
                scrollView.AddSubview(label);
            }
        }
Ejemplo n.º 43
0
        public LoginView(string xamarinAccountEmail)
        {
            BackgroundColor = UIColor.White;

            Add(GravatarView = new UIImageView(new RectangleF(PointF.Empty, GravatarSize))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image = UIImage.FromBundle("user-default-avatar"),
            });

            GravatarView.Layer.CornerRadius  = GravatarSize.Width / 2;
            GravatarView.Layer.MasksToBounds = true;

            DisplayGravatar(xamarinAccountEmail);

            AddConstraint(NSLayoutConstraint.Create(
                              GravatarView,
                              NSLayoutAttribute.Top,
                              NSLayoutRelation.Equal,
                              this,
                              NSLayoutAttribute.Top,
                              1f, 90f
                              ));

            AddConstraint(NSLayoutConstraint.Create(
                              GravatarView,
                              NSLayoutAttribute.CenterX,
                              NSLayoutRelation.Equal,
                              this,
                              NSLayoutAttribute.CenterX,
                              1f, 0
                              ));

            AddConstantSizeConstraints(GravatarView, GravatarSize);

            Add(EmailField = new UITextField(new RectangleF(10, 10, 300, 30))
            {
                BorderStyle = UITextBorderStyle.RoundedRect,
                Text        = xamarinAccountEmail,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Delegate = new EmailFieldDelegate()
            });

            AddConstraint(NSLayoutConstraint.Create(
                              EmailField,
                              NSLayoutAttribute.Top,
                              NSLayoutRelation.Equal,
                              GravatarView,
                              NSLayoutAttribute.Bottom,
                              1f, 30f
                              ));

            AddConstraint(NSLayoutConstraint.Create(
                              EmailField,
                              NSLayoutAttribute.CenterX,
                              NSLayoutRelation.Equal,
                              GravatarView,
                              NSLayoutAttribute.CenterX,
                              1f, 0
                              ));

            var textSize = new NSString("hello").StringSize(UIFont.SystemFontOfSize(12f));

            AddConstantSizeConstraints(EmailField, new SizeF(260, (float)textSize.Height + 16));

            Add(PasswordField = new UITextField(new RectangleF(10, 10, 300, 30))
            {
                BorderStyle     = UITextBorderStyle.RoundedRect,
                SecureTextEntry = true,
                TranslatesAutoresizingMaskIntoConstraints = false,
                ReturnKeyType = UIReturnKeyType.Go,
                Placeholder   = "Password"
            });

            AddConstraint(NSLayoutConstraint.Create(
                              PasswordField,
                              NSLayoutAttribute.Top,
                              NSLayoutRelation.Equal,
                              EmailField,
                              NSLayoutAttribute.Bottom,
                              1f, 10f
                              ));

            AddConstraint(NSLayoutConstraint.Create(
                              PasswordField,
                              NSLayoutAttribute.CenterX,
                              NSLayoutRelation.Equal,
                              EmailField,
                              NSLayoutAttribute.CenterX,
                              1f, 0
                              ));

            AddConstantSizeConstraints(PasswordField, new SizeF(260, (float)textSize.Height + 16));

            PasswordField.ShouldReturn = field => {
                field.ResignFirstResponder();
                UserDidLogin(this);
                return(true);
            };

            PasswordField.BecomeFirstResponder();
        }
Ejemplo n.º 44
0
 public static void SetTheme(this UITextField editText, string borderColor, string textColor, int borderWidth)
 {
     editText.Layer.BorderColor = _nativeTheme.Colors[borderColor].CGColor;
     editText.TextColor         = _nativeTheme.Colors[textColor];
     editText.Layer.BorderWidth = borderWidth;
 }
Ejemplo n.º 45
0
 public void EditingEnded(UITextField textField)
 {
     selectedUser = userPickerModel.selectedModel;
 }
Ejemplo n.º 46
0
 private bool InvokeCompleted(UITextField textField)
 {
     Control.ResignFirstResponder();
     ((IEntryController)Element).SendCompleted();
     return(true);
 }
Ejemplo n.º 47
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            DownloadsNavSearchBtn.TouchUpInside += delegate {
                DownloadsNavCloseBtn.Transform  = Utilities.Hide;
                DownloadsNavSearchBar.Transform = Utilities.Hide;
                DownloadsNavCloseBtn.Hidden     = false;
                DownloadsNavSearchBar.Hidden    = false;
                DownloadsNavSearchBar.BecomeFirstResponder();
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DownloadsNavSearchBtn.Transform   = Utilities.Hide;
                    DownloadsNavOutNowBtn.Transform   = Utilities.Hide;
                    DownloadsNavUpcomingBtn.Transform = Utilities.Hide;

                    TableView.Alpha = 0;

                    DownloadsNavCloseBtn.Transform  = Utilities.Show;
                    DownloadsNavSearchBar.Transform = Utilities.Show;
                }, null);
            };

            DownloadsNavSearchBar.SearchButtonClicked += delegate {
                DownloadsNavSearchBar.ResignFirstResponder();
                DownloadsNavSearchLoadingSpinner.Transform = Utilities.Hide;
                UIView.AnimateNotify(0.4, 0, 0.65f, 0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DownloadsNavSearchLoadingSpinner.StartAnimating();
                    DownloadsNavCloseBtn.Transform             = Utilities.Hide;
                    DownloadsNavSearchLoadingSpinner.Transform = Utilities.Show;
                }, null);

                DisplaySearchResults();
            };

            DownloadsNavCloseBtn.TouchUpInside += delegate {
                UIView.AnimateNotify(0.4, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    DownloadsNavSearchBtn.Transform = Utilities.Show;
                    SetDownloadTypeButtonDisplay();

                    TableView.Alpha = 1;

                    DownloadsNavCloseBtn.Transform  = Utilities.Hide;
                    DownloadsNavSearchBar.Transform = Utilities.Hide;
                    DownloadsNavSearchBar.ResignFirstResponder();
                }, delegate {
                    DownloadsNavCloseBtn.Hidden  = true;
                    DownloadsNavSearchBar.Hidden = true;
                    RefreshTable();
                });
            };

            DownloadsNavOutNowBtn.TouchUpInside += delegate {
                selectedSegmentBtn = 0;
                TableView.Source   = null;
                TableView.ReloadData();
                GetJson();
                UIView.AnimateNotify(0.2, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    SetDownloadTypeButtonDisplay();
                }, null);
            };

            DownloadsNavUpcomingBtn.TouchUpInside += delegate {
                selectedSegmentBtn = 1;
                TableView.Source   = null;
                TableView.ReloadData();
                GetJson();
                UIView.AnimateNotify(0.2, 0, 0.65f, 0.0f, UIViewAnimationOptions.CurveEaseIn, delegate {
                    SetDownloadTypeButtonDisplay();
                }, null);
            };

            RefreshControl               = new UIRefreshControl();
            RefreshControl.TintColor     = UIColor.FromRGB(144, 199, 62);
            RefreshControl.ValueChanged += delegate {
                GetJson(true);
            };

            foreach (var subView in DownloadsNavSearchBar.Subviews)
            {
                foreach (var subView2nd in subView.Subviews)
                {
                    if (subView2nd.GetType() == typeof(UITextField))
                    {
                        UITextField searchField = (UITextField)subView2nd;
                        searchField.Font = UIFont.FromName("GillSans", 13);
                    }
                }
            }
        }
Ejemplo n.º 48
0
 public override bool ShouldBeginEditing(UITextField textField)
 {
     return(false);
 }
Ejemplo n.º 49
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;


            //
            // Configure attributes for text formatting
            //
            var firstAttributes = new UIStringAttributes {
                ForegroundColor = UIColor.Blue,
                BackgroundColor = UIColor.Yellow,
                Font            = UIFont.FromName("Courier", 18f)
            };

            var secondAttributes = new UIStringAttributes {
                ForegroundColor    = UIColor.Red,
                BackgroundColor    = UIColor.Gray,
                StrikethroughStyle = NSUnderlineStyle.Single
            };

            var thirdAttributes = new UIStringAttributes {
                ForegroundColor = UIColor.Green,
                BackgroundColor = UIColor.Black
            };

            // NOTE: UIStringAttributes are NOT the same as CTStringAttributes in Core Text.
            // Core Text is a separate framework with different use cases and capabilities!


            //
            // UITextField
            //
            textField1 = new UITextField(new CGRect(10, 110, 300, 60));
            textField1.BackgroundColor = UIColor.LightGray;
            View.Add(textField1);

            // Apply the same style to the entire control
            //textField1.AttributedText = new NSAttributedString("UITextField is pretty!", firstAttributes);

            // Apply different styles to different parts of the displayed text
            var prettyString = new NSMutableAttributedString("UITextField is not pretty!");

            prettyString.SetAttributes(firstAttributes.Dictionary, new NSRange(0, 11));
            prettyString.SetAttributes(secondAttributes.Dictionary, new NSRange(15, 3));
            prettyString.SetAttributes(thirdAttributes.Dictionary, new NSRange(19, 6));

            textField1.AttributedText = prettyString;


            //
            // UILabel
            //
            label1 = new UILabel(new CGRect(10, 60, 300, 30));
            View.Add(label1);

            // Apply the same style to the entire control
            //label1.AttributedText = new NSAttributedString("UILabel is pretty!", firstAttributes);

            // Apply different styles to different parts of the displayed text
            var myString = new NSMutableAttributedString("UILabel text formatting...");

            myString.SetAttributes(firstAttributes.Dictionary, new NSRange(0, 7));
            myString.SetAttributes(secondAttributes.Dictionary, new NSRange(8, 4));
            myString.SetAttributes(thirdAttributes.Dictionary, new NSRange(12, 11));

            label1.AttributedText = myString;
        }
Ejemplo n.º 50
0
 protected virtual void SetupTextField(UITextField textField)
 {
     textField.SetupStyle(ThemeConfig.TextField);
 }
 protected override void OnDetached()
 {
     control = null;
 }
 private bool OnShouldReturn(UITextField textField)
 {
     textField.ResignFirstResponder();
     return(true);
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Assigns a text string to the UI element.
 /// </summary>
 /// <param name="text">Text string.</param>
 public void Assign(string text)
 {
     name           = text;
     this.text.text = text;
 }
Ejemplo n.º 54
0
        public override void ViewDidLoad()
        {
            View = new UIView()
            {
                BackgroundColor = UIColor.White
            };
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            var textFieldTitle = new UITextField(new CGRect(10, 10, 300, 30));

            Add(textFieldTitle);
            var picker          = new UIPickerView();
            var pickerViewModel = new MvxPickerViewModel(picker);

            picker.Model = pickerViewModel;
            picker.ShowSelectionIndicator = true;
            textFieldTitle.InputView      = picker;

            var textFieldFirstName = new UITextField(new CGRect(10, 40, 300, 30));

            Add(textFieldFirstName);
            var textFieldLastName = new UITextField(new CGRect(10, 70, 300, 30));

            Add(textFieldLastName);
            var acceptedLabel = new UILabel(new CGRect(10, 100, 200, 30));

            acceptedLabel.Text = "Accepted?";
            Add(acceptedLabel);
            var accepted = new UISwitch(new CGRect(210, 100, 100, 30));

            Add(accepted);
            var add = new UIButton(UIButtonType.RoundedRect);

            add.SetTitle("Add", UIControlState.Normal);
            add.Frame = new CGRect(10, 130, 300, 30);
            Add(add);
            var debugView = new UILabel(new CGRect(10, 130, 300, 30));

            Add(debugView);

            var table = new UITableView(new CGRect(10, 160, 300, 300));

            Add(table);
            var source = new MvxStandardTableViewSource(table, "TitleText FirstName");

            table.Source = source;

            var set = this.CreateBindingSet <FirstView, Core.ViewModels.FirstViewModel>();

            set.Bind(textFieldFirstName).To(vm => vm.FirstName);
            set.Bind(textFieldLastName).To(vm => vm.LastName);
            set.Bind(pickerViewModel).For(p => p.ItemsSource).To(vm => vm.Titles);
            set.Bind(pickerViewModel).For(p => p.SelectedItem).To(vm => vm.Title);
            set.Bind(textFieldTitle).To(vm => vm.Title);
            set.Bind(accepted).To(vm => vm.Accepted);
            set.Bind(add).To(vm => vm.AddCommand);
            set.Bind(source).To(vm => vm.People);

            //set.Bind(debugView).To("If(Accepted, Format('{0} {1} ({2})', FirstName, LastName, Title), 'nada')");
            set.Bind(debugView).To("Strip(FirstName, 'S') + Strip(LastName,'S')");
            set.Apply();

            var tap = new UITapGestureRecognizer(() =>
            {
                foreach (var view in View.Subviews)
                {
                    var text = view as UITextField;
                    if (text != null)
                    {
                        text.ResignFirstResponder();
                    }
                }
            });

            View.AddGestureRecognizer(tap);
        }
Ejemplo n.º 55
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view

            //初始化配置信息
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string FilePath      = Path.Combine(documentsPath, MyConfig.Filename);

            MyConfig.Init(FilePath);
            MyConfig.ReadConfig();

            //一定要设置frame,否则显示空白
            this.View.Frame = UIScreen.MainScreen.Bounds;

            //如果不设置视图背景,默认是黑色
            this.View.BackgroundColor = UIColor.White;

            this.View.CreateLabel(10, 90, "服务器");

            txtWebServerUrl      = this.View.CreateTextField(10, 120, "请输入服务器地址");
            txtWebServerUrl.Text = MyConfig.Config.WebServerUrl;
            //进入页面后获取输入焦点
            txtWebServerUrl.BecomeFirstResponder();

            this.View.CreateLabel(10, 150, "用户身份");

            //用户身份列表
            RoleTypes = Enum.GetNames(typeof(UserInfo.RoleType)).ToList();
            List <UIAlertAction> alertActions = new List <UIAlertAction>();

            foreach (string roleType in RoleTypes)
            {
                //所有选项共用一个回调函数
                UIAlertAction alertAction = UIAlertAction.Create(roleType, UIAlertActionStyle.Default, SelectRoleType);
                alertActions.Add(alertAction);
            }

            btnSelectRole = this.View.CreateButton(10, 180, MyConfig.Config.CurrentUserInfo.Role.ToString());
            btnSelectRole.TouchUpInside += (s1, e1) =>
            {
                //必须沿用同一个UIAlertController,否则仅在第一次选择有效,因为ShowSheetBox每次重新创建UIAlertController
                if (RoleTypeAlertController == null)
                {
                    RoleTypeAlertController = this.ShowSheetBox("用户身份", "请选择用户身份", alertActions.ToArray());
                }
                else
                {
                    //显示弹出窗口
                    this.PresentViewController(RoleTypeAlertController, true, null);
                }
            };

            this.View.CreateLabel(10, 210, "姓名");

            txtAccount      = this.View.CreateTextField(10, 240, "请输入姓名");
            txtAccount.Text = MyConfig.Config.CurrentUserInfo.Account;

            UIButton btnLogin = this.View.CreateButton(10, 270, "登录");

            btnLogin.TouchUpInside += (s1, e1) => Login();
        }
Ejemplo n.º 56
0
        public static void Make(ExtUITabstrip tabStrip)
        {
            UIHelper panelHelper = tabStrip.AddTabPage("Subscriptions");

            UIButton   button;
            UICheckBox checkBox;

            //g.AddButton("Perform All", OnPerformAllClicked);

            button         = panelHelper.AddButton("Refresh workshop items (checks for bad items)", RequestItemDetails) as UIButton;
            button.tooltip = "checks for missing/partially downloaded/outdated items";

            button         = panelHelper.AddButton("unsubscribe from deprecated workshop items [EXPERIMENTAL] ", () => CheckSubsUtil.Instance.UnsubDepricated()) as UIButton;
            button.tooltip = "if steam does not return item path, i assume its deprecated.";

            button           = panelHelper.AddButton("Resubscribe to all broken downloads (exits game) [EXPERIMENTAL]", CheckSubsUtil.ResubcribeExternally) as UIButton;
            button.tooltip   = "less steam can hide problems. if you use less steam please click 'Refresh workshop items' to get all broken downloads";
            button.isVisible = false; //hide for now.

            checkBox = panelHelper.AddCheckbox(
                "Delete unsubscribed items on startup",
                Config.DeleteUnsubscribedItemsOnLoad,
                val => {
                ConfigUtil.Config.DeleteUnsubscribedItemsOnLoad = val;
                ConfigUtil.SaveConfig();
            }) as UICheckBox;

            button = panelHelper.AddButton("Delete Now", () => CheckSubsUtil.Instance.DeleteUnsubbed()) as UIButton;
            Settings.Pairup(checkBox, button);

            {
                var g = panelHelper.AddGroup("Broken downloads") as UIHelper;

                tfSteamPath_ = g.AddTextfield(
                    text: "Steam Path: ",
                    defaultContent: ConfigUtil.Config.SteamPath ?? "",
                    eventChangedCallback: _ => { },
                    eventSubmittedCallback : delegate(string text) {
                    if (CheckSteamPath(text))
                    {
                        ConfigUtil.Config.SteamPath = text;
                        ConfigUtil.SaveConfig();
                    }
                }) as UITextField;
                tfSteamPath_.width   = 650;
                tfSteamPath_.tooltip = "Path to steam.exe";
                g.AddButton("Redownload broken downloads [EXPERIMENTAL]", delegate() {
                    try {
                        var path = tfSteamPath_.text;
                        if (CheckSteamPath(path))
                        {
                            CheckSubsUtil.ReDownload(path);
                            Prompt.Warning("Exit",
                                           "Please exit to desktop, wait for steam download to finish, and then start Cities skylines again.\n" +
                                           "Should this not work the first time, please try again.");
                        }
                    } catch (Exception ex) {
                        ex.Log();
                    }
                });
            }

            //b = g.AddButton("delete duplicates", OnPerformAllClicked) as UIButton;
            //b.tooltip = "when excluded mod is updated, and included duplicate of it is created";
        }
Ejemplo n.º 57
0
        private float addStationToLinearMap(string stationPrefix, string stationName, Vector3 location, float offsetX, List <ushort> intersections, string airport, string harbor, string taxi, string regionalTrainStation, ushort stationNodeId, ItemClass.SubService ss, bool simple = false)//, out float intersectionPanelHeight)
        {
            ushort           lineID = lineInfoPanel.lineIdSelecionado.TransportLine;
            TransportLine    t      = lineInfoPanel.controller.tm.m_lines.m_buffer[(int)lineID];
            TransportManager tm     = Singleton <TransportManager> .instance;

            UIButton stationButton = null;

            TLMUtils.createUIElement <UIButton>(ref stationButton, lineStationsPanel.transform);
            stationButton.relativePosition = new Vector3(offsetX, 15f);
            stationButton.width            = 20;
            stationButton.height           = 20;
            stationButton.name             = "Station [" + stationName + "]";
            TLMUtils.initButton(stationButton, true, "IconPolicyBaseCircle");

            UITextField stationLabel = null;

            TLMUtils.createUIElement <UITextField>(ref stationLabel, stationButton.transform);
            stationLabel.autoSize            = true;
            stationLabel.width               = 220;
            stationLabel.height              = 20;
            stationLabel.useOutline          = true;
            stationLabel.pivot               = UIPivotPoint.MiddleLeft;
            stationLabel.horizontalAlignment = UIHorizontalAlignment.Left;
            stationLabel.verticalAlignment   = UIVerticalAlignment.Middle;
            stationLabel.name             = "Station [" + stationName + "] Name";
            stationLabel.relativePosition = new Vector3(23f, -13f);
            stationLabel.text             = (!string.IsNullOrEmpty(stationPrefix) ? stationPrefix.Trim() + " " : "") + stationName.Trim();
            stationLabel.textScale        = Math.Max(0.5f, Math.Min(1, 24f / stationLabel.text.Length));

            TLMUtils.uiTextFieldDefaults(stationLabel);
            stationLabel.color           = new Color(0.3f, 0.3f, 0.3f, 1);
            stationLabel.textColor       = Color.white;
            stationLabel.cursorWidth     = 2;
            stationLabel.cursorBlinkTime = 100;
            stationLabel.eventGotFocus  += (x, y) =>
            {
                stationLabel.text = TLMUtils.getStationName(stationNodeId, lineID, ss);
            };
            stationLabel.eventTextSubmitted += (x, y) =>
            {
                TLMUtils.setStopName(y, stationNodeId, lineID, () =>
                {
                    stationLabel.text = TLMUtils.getFullStationName(stationNodeId, lineID, ss);
                    m_autoName        = TLMUtils.calculateAutoName(lineID);
                    lineInfoPanel.autoNameLabel.text = autoName;
                });
            };

            stationButton.gameObject.transform.localPosition    = new Vector3(0, 0, 0);
            stationButton.gameObject.transform.localEulerAngles = new Vector3(0, 0, 45);
            stationButton.eventClick += (component, eventParam) =>
            {
                lineInfoPanel.cameraController.SetTarget(lineInfoPanel.lineIdSelecionado, location, false);
                lineInfoPanel.cameraController.ClearTarget();
            };
            if (!simple)
            {
                stationOffsetX.Add(stationNodeId, offsetX);
                if (showIntersections)
                {
                    var otherLinesIntersections = TLMLineUtils.SortLines(intersections, t);

                    int intersectionCount = otherLinesIntersections.Count + (airport != string.Empty ? 1 : 0) + (taxi != string.Empty ? 1 : 0) + (harbor != string.Empty ? 1 : 0) + (regionalTrainStation != string.Empty ? 1 : 0);
                    if (intersectionCount > 0)
                    {
                        UIPanel intersectionsPanel = null;
                        TLMUtils.createUIElement <UIPanel>(ref intersectionsPanel, stationButton.transform);
                        intersectionsPanel.autoSize                  = false;
                        intersectionsPanel.autoLayout                = false;
                        intersectionsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                        intersectionsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                        intersectionsPanel.relativePosition          = new Vector3(-20, 10);
                        intersectionsPanel.wrapLayout                = false;
                        intersectionsPanel.autoFitChildrenVertically = true;

                        TLMLineUtils.PrintIntersections(airport, harbor, taxi, regionalTrainStation, intersectionsPanel, otherLinesIntersections);

                        intersectionsPanel.autoLayout = true;
                        intersectionsPanel.wrapLayout = true;
                        intersectionsPanel.width      = 55;
                        //
                        return(42f);
                    }
                    else
                    {
                        return(25f);
                    }
                }
                else if (showExtraStopInfo)
                {
                    float normalWidth = 42.5f;

                    NetNode stopNode = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)stationNodeId];

                    int residents, tourists;
                    TLMLineUtils.GetQuantityPassengerWaiting(stationNodeId, out residents, out tourists);

                    UIPanel stationInfoStatsPanel = null;
                    TLMUtils.createUIElement <UIPanel>(ref stationInfoStatsPanel, stationButton.transform);
                    stationInfoStatsPanel.autoSize   = false;
                    stationInfoStatsPanel.autoLayout = false;
                    stationInfoStatsPanel.autoFitChildrenVertically = true;
                    stationInfoStatsPanel.autoLayoutStart           = LayoutStart.TopLeft;
                    stationInfoStatsPanel.autoLayoutDirection       = LayoutDirection.Horizontal;
                    stationInfoStatsPanel.relativePosition          = new Vector3(-20, 10);
                    stationInfoStatsPanel.autoLayout = true;
                    stationInfoStatsPanel.wrapLayout = true;
                    stationInfoStatsPanel.width      = normalWidth;

                    UILabel residentsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref residentsWaiting, stationInfoStatsPanel.transform);
                    residentsWaiting.autoSize         = false;
                    residentsWaiting.useOutline       = true;
                    residentsWaiting.text             = residents.ToString();
                    residentsWaiting.tooltipLocaleID  = "TLM_RESIDENTS_WAITING";
                    residentsWaiting.backgroundSprite = "EmptySprite";
                    residentsWaiting.color            = new Color32(0x12, 0x68, 0x34, 255);
                    residentsWaiting.width            = normalWidth;
                    residentsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    residentsWaiting.height           = 20;
                    residentsWaiting.textScale        = 0.7f;
                    residentsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    residentCounters[stationNodeId]   = residentsWaiting;

                    UILabel touristsWaiting = null;
                    TLMUtils.createUIElement <UILabel>(ref touristsWaiting, stationInfoStatsPanel.transform);
                    touristsWaiting.autoSize         = false;
                    touristsWaiting.text             = tourists.ToString();
                    touristsWaiting.tooltipLocaleID  = "TLM_TOURISTS_WAITING";
                    touristsWaiting.useOutline       = true;
                    touristsWaiting.width            = normalWidth;
                    touristsWaiting.height           = 20;
                    touristsWaiting.padding          = new RectOffset(0, 0, 4, 2);
                    touristsWaiting.textScale        = 0.7f;
                    touristsWaiting.backgroundSprite = "EmptySprite";
                    touristsWaiting.color            = new Color32(0x1f, 0x25, 0x68, 255);
                    touristsWaiting.textAlignment    = UIHorizontalAlignment.Center;
                    touristCounters[stationNodeId]   = touristsWaiting;
                    //
                    return(normalWidth);
                }
                else
                {
                    return(25f);
                }
            }
            else
            {
                return(30f);
            }
        }
 private void EditingEnded(UITextField textField)
 {
     textField.ResignFirstResponder();
 }
 public void SetValueChangedView(UIView textField)
 {
     _textField = (UITextField)textField;
 }
Ejemplo n.º 60
0
        private void CreateVehicleOptionsPanel()
        {
            UIPanel uiPanel1 = this.AddUIComponent <UIPanel>();

            uiPanel1.name   = "RightSidePanel";
            uiPanel1.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            uiPanel1.transform.localPosition = Vector3.zero;
            uiPanel1.width               = 246f;
            uiPanel1.height              = 304f;
            uiPanel1.autoLayout          = true;
            uiPanel1.autoLayoutDirection = LayoutDirection.Vertical;
            uiPanel1.autoLayoutPadding   = new RectOffset(3, 3, 0, 0);
            uiPanel1.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel1.backgroundSprite    = "InfoviewPanel";
            uiPanel1.relativePosition    = new Vector3(60f, 50f);
            this._rightSidePanel         = uiPanel1;
            UIPanel uiPanel2 = uiPanel1.AddUIComponent <UIPanel>();

            uiPanel2.name             = "CaptionPanel";
            uiPanel2.width            = uiPanel2.parent.width - 6f;
            uiPanel2.height           = 30f;
            uiPanel2.backgroundSprite = "InfoviewPanel";
            UILabel uiLabel1 = uiPanel2.AddUIComponent <UILabel>();

            uiLabel1.name          = "CaptionLabel";
            uiLabel1.font          = UIUtils.Font;
            uiLabel1.textColor     = (Color32)Color.white;
            uiLabel1.textScale     = 0.95f;
            uiLabel1.textAlignment = UIHorizontalAlignment.Center;
            uiLabel1.useOutline    = true;
            uiLabel1.autoSize      = false;
            uiLabel1.height        = 18f;
            uiLabel1.width         = uiPanel2.width;
            uiLabel1.position      = new Vector3((float)((double)uiPanel2.width / 2.0 - (double)uiPanel2.width / 2.0), (float)((double)uiPanel2.height / 2.0 - 20.0));
            UIPanel uiPanel3 = uiPanel1.AddUIComponent <UIPanel>();
            string  str1     = "RowContainer";

            uiPanel3.name = str1;
            double num1 = (double)uiPanel3.parent.width - 6.0;

            uiPanel3.width = (float)num1;
            double num2 = 271.0;

            uiPanel3.height = (float)num2;
            int num3 = 1;

            uiPanel3.autoLayoutDirection = (LayoutDirection)num3;
            int num4 = 0;

            uiPanel3.autoLayoutStart = (LayoutStart)num4;
            RectOffset rectOffset1 = new RectOffset(8, 0, 0, 0);

            uiPanel3.autoLayoutPadding = rectOffset1;
            int num5 = 1;

            uiPanel3.autoLayout = num5 != 0;
            string str2 = "GenericPanelWhite";

            uiPanel3.backgroundSprite = str2;
            Color32 color32 = new Color32((byte)91, (byte)97, (byte)106, byte.MaxValue);

            uiPanel3.color = color32;
            UIPanel uiPanel4 = uiPanel3.AddUIComponent <UIPanel>();
            double  num6     = (double)uiPanel4.parent.width - 8.0;

            uiPanel4.width = (float)num6;
            double num7 = 4.0;

            uiPanel4.height = (float)num7;
            int num8 = 0;

            uiPanel4.autoLayoutDirection = (LayoutDirection)num8;
            int num9 = 0;

            uiPanel4.autoLayoutStart = (LayoutStart)num9;
            RectOffset rectOffset2 = new RectOffset(0, 6, 0, 0);

            uiPanel4.autoLayoutPadding = rectOffset2;
            int num10 = 1;

            uiPanel4.autoLayout = num10 != 0;
            UIPanel uiPanel5 = uiPanel3.AddUIComponent <UIPanel>();
            double  num11    = (double)uiPanel5.parent.width - 8.0;

            uiPanel5.width = (float)num11;
            double num12 = 30.0;

            uiPanel5.height = (float)num12;
            int num13 = 0;

            uiPanel5.autoLayoutDirection = (LayoutDirection)num13;
            int num14 = 0;

            uiPanel5.autoLayoutStart = (LayoutStart)num14;
            RectOffset rectOffset3 = new RectOffset(0, 6, 0, 0);

            uiPanel5.autoLayoutPadding = rectOffset3;
            int num15 = 1;

            uiPanel5.autoLayout = num15 != 0;
            DropDown dropDown = DropDown.Create((UIComponent)uiPanel5);
            string   str3     = "AssetDropDown";

            dropDown.name = str3;
            double num16 = 27.0;

            dropDown.height = (float)num16;
            double num17 = (double)dropDown.parent.width - 6.0;

            dropDown.width = (float)num17;
            dropDown.DropDownPanelAlignParent = (UIComponent)this;
            UIFont font = UIUtils.Font;

            dropDown.Font = font;
            PropertyChangedEventHandler <ushort> changedEventHandler1 = new PropertyChangedEventHandler <ushort>(this.OnSelectedItemChanged);

            dropDown.eventSelectedItemChanged += changedEventHandler1;
            UIPanel uiPanel6 = uiPanel3.AddUIComponent <UIPanel>();
            double  num18    = (double)uiPanel6.parent.width - 8.0;

            uiPanel6.width = (float)num18;
            double num19 = 30.0;

            uiPanel6.height = (float)num19;
            int num20 = 0;

            uiPanel6.autoLayoutDirection = (LayoutDirection)num20;
            int num21 = 0;

            uiPanel6.autoLayoutStart = (LayoutStart)num21;
            RectOffset rectOffset4 = new RectOffset(0, 3, 0, 0);

            uiPanel6.autoLayoutPadding = rectOffset4;
            int num22 = 1;

            uiPanel6.autoLayout = num22 != 0;
            UILabel uiLabel2 = uiPanel6.AddUIComponent <UILabel>();

            uiLabel2.name              = "CapacityLabel";
            uiLabel2.text              = Localization.Get("VEHICLE_EDITOR_CAPACITY");
            uiLabel2.font              = UIUtils.Font;
            uiLabel2.textColor         = (Color32)Color.white;
            uiLabel2.textScale         = 0.8f;
            uiLabel2.autoSize          = false;
            uiLabel2.height            = 30f;
            uiLabel2.width             = 115f;
            uiLabel2.wordWrap          = true;
            uiLabel2.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField1 = uiPanel6.AddUIComponent <UITextField>();
            string      str4         = "Capacity";

            uiTextField1.name = str4;
            string str5 = "0";

            uiTextField1.text = str5;
            uiLabel2.tooltip  = "";
            Color32 black1 = (Color32)Color.black;

            uiTextField1.textColor = black1;
            string str6 = "EmptySprite";

            uiTextField1.selectionSprite = str6;
            string str7 = "TextFieldPanelHovered";

            uiTextField1.normalBgSprite = str7;
            string str8 = "TextFieldPanel";

            uiTextField1.focusedBgSprite = str8;
            int num23 = 1;

            uiTextField1.builtinKeyNavigation = num23 != 0;
            int num24 = 1;

            uiTextField1.submitOnFocusLost = num24 != 0;
            PropertyChangedEventHandler <string> changedEventHandler2 = new PropertyChangedEventHandler <string>(this.OnCapacitySubmitted);

            uiTextField1.eventTextSubmitted += changedEventHandler2;
            double num25 = 45.0;

            uiTextField1.width = (float)num25;
            double num26 = 22.0;

            uiTextField1.height = (float)num26;
            int num27 = 4;

            uiTextField1.maxLength = num27;
            int num28 = 1;

            uiTextField1.numericalOnly = num28 != 0;
            int num29 = 1;

            uiTextField1.verticalAlignment = (UIVerticalAlignment)num29;
            RectOffset rectOffset5 = new RectOffset(0, 0, 4, 0);

            uiTextField1.padding = rectOffset5;
            UIPanel uiPanel7 = uiPanel3.AddUIComponent <UIPanel>();
            string  str9     = "MaintenanceRow";

            uiPanel7.name = str9;
            double num30 = (double)uiPanel7.parent.width - 8.0;

            uiPanel7.width = (float)num30;
            double num31 = 30.0;

            uiPanel7.height = (float)num31;
            int num32 = 0;

            uiPanel7.autoLayoutDirection = (LayoutDirection)num32;
            int num33 = 0;

            uiPanel7.autoLayoutStart = (LayoutStart)num33;
            RectOffset rectOffset6 = new RectOffset(0, 3, 0, 0);

            uiPanel7.autoLayoutPadding = rectOffset6;
            int num34 = 1;

            uiPanel7.autoLayout = num34 != 0;
            UILabel uiLabel3 = uiPanel7.AddUIComponent <UILabel>();

            uiLabel3.text              = Localization.Get("VEHICLE_EDITOR_MAINTENANCE");
            uiLabel3.font              = UIUtils.Font;
            uiLabel3.textColor         = (Color32)Color.white;
            uiLabel3.textScale         = 0.8f;
            uiLabel3.autoSize          = false;
            uiLabel3.height            = 30f;
            uiLabel3.width             = 115f;
            uiLabel3.wordWrap          = true;
            uiLabel3.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField2 = uiPanel7.AddUIComponent <UITextField>();
            string      str10        = "MaintenanceCost";

            uiTextField2.name = str10;
            string str11 = "0";

            uiTextField2.text = str11;
            Color32 black2 = (Color32)Color.black;

            uiTextField2.textColor = black2;
            string str12 = "EmptySprite";

            uiTextField2.selectionSprite = str12;
            string str13 = "TextFieldPanelHovered";

            uiTextField2.normalBgSprite = str13;
            string str14 = "TextFieldPanel";

            uiTextField2.focusedBgSprite = str14;
            int num35 = 1;

            uiTextField2.builtinKeyNavigation = num35 != 0;
            int num36 = 1;

            uiTextField2.submitOnFocusLost = num36 != 0;
            double num37 = 45.0;

            uiTextField2.width = (float)num37;
            double num38 = 22.0;

            uiTextField2.height = (float)num38;
            int num39 = 6;

            uiTextField2.maxLength = num39;
            int num40 = 1;

            uiTextField2.numericalOnly = num40 != 0;
            int num41 = 1;

            uiTextField2.verticalAlignment = (UIVerticalAlignment)num41;
            RectOffset rectOffset7 = new RectOffset(0, 0, 4, 0);

            uiTextField2.padding = rectOffset7;
            UILabel uiLabel4 = uiPanel7.AddUIComponent <UILabel>();

            uiLabel4.name              = "MaintenanceCostLabel";
            uiLabel4.text              = "0";
            uiLabel4.font              = UIUtils.Font;
            uiLabel4.textColor         = (Color32)Color.white;
            uiLabel4.textScale         = 0.8f;
            uiLabel4.textAlignment     = UIHorizontalAlignment.Right;
            uiLabel4.autoSize          = false;
            uiLabel4.height            = 30f;
            uiLabel4.width             = 60f;
            uiLabel4.verticalAlignment = UIVerticalAlignment.Middle;
            UIPanel uiPanel8 = uiPanel3.AddUIComponent <UIPanel>();
            double  num42    = (double)uiPanel8.parent.width - 8.0;

            uiPanel8.width = (float)num42;
            double num43 = 30.0;

            uiPanel8.height = (float)num43;
            int num44 = 0;

            uiPanel8.autoLayoutDirection = (LayoutDirection)num44;
            int num45 = 0;

            uiPanel8.autoLayoutStart = (LayoutStart)num45;
            RectOffset rectOffset8 = new RectOffset(0, 3, 0, 0);

            uiPanel8.autoLayoutPadding = rectOffset8;
            int num46 = 1;

            uiPanel8.autoLayout = num46 != 0;
            UILabel uiLabel5 = uiPanel8.AddUIComponent <UILabel>();

            uiLabel5.name              = "TicketPriceLabel2";
            uiLabel5.text              = Localization.Get("VEHICLE_EDITOR_TICKET_PRICE");
            uiLabel5.font              = UIUtils.Font;
            uiLabel5.textColor         = (Color32)Color.white;
            uiLabel5.textScale         = 0.8f;
            uiLabel5.autoSize          = false;
            uiLabel5.height            = 30f;
            uiLabel5.width             = 115f;
            uiLabel5.wordWrap          = true;
            uiLabel5.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField3 = uiPanel8.AddUIComponent <UITextField>();
            string      str15        = "TicketPrice";

            uiTextField3.name = str15;
            string str16 = "0";

            uiTextField3.text = str16;
            Color32 black3 = (Color32)Color.black;

            uiTextField3.textColor = black3;
            string str17 = "EmptySprite";

            uiTextField3.selectionSprite = str17;
            string str18 = "TextFieldPanelHovered";

            uiTextField3.normalBgSprite = str18;
            string str19 = "TextFieldPanel";

            uiTextField3.focusedBgSprite = str19;
            int num47 = 1;

            uiTextField3.builtinKeyNavigation = num47 != 0;
            int num48 = 1;

            uiTextField3.submitOnFocusLost = num48 != 0;
            double num49 = 45.0;

            uiTextField3.width = (float)num49;
            double num50 = 22.0;

            uiTextField3.height = (float)num50;
            int num51 = 4;

            uiTextField3.maxLength = num51;
            int num52 = 1;

            uiTextField3.numericalOnly = num52 != 0;
            int num53 = 1;

            uiTextField3.verticalAlignment = (UIVerticalAlignment)num53;
            RectOffset rectOffset9 = new RectOffset(0, 0, 4, 0);

            uiTextField3.padding = rectOffset9;
            UILabel uiLabel6 = uiPanel8.AddUIComponent <UILabel>();

            uiLabel6.name              = "TicketPriceLabel";
            uiLabel6.text              = "0";
            uiLabel6.font              = UIUtils.Font;
            uiLabel6.textColor         = (Color32)Color.white;
            uiLabel6.textScale         = 0.8f;
            uiLabel6.textAlignment     = UIHorizontalAlignment.Right;
            uiLabel6.autoSize          = false;
            uiLabel6.height            = 30f;
            uiLabel6.width             = 60f;
            uiLabel6.verticalAlignment = UIVerticalAlignment.Middle;
            UIPanel uiPanel9 = uiPanel3.AddUIComponent <UIPanel>();
            double  num54    = (double)uiPanel9.parent.width - 8.0;

            uiPanel9.width = (float)num54;
            double num55 = 30.0;

            uiPanel9.height = (float)num55;
            int num56 = 0;

            uiPanel9.autoLayoutDirection = (LayoutDirection)num56;
            int num57 = 0;

            uiPanel9.autoLayoutStart = (LayoutStart)num57;
            RectOffset rectOffset10 = new RectOffset(0, 3, 0, 0);

            uiPanel9.autoLayoutPadding = rectOffset10;
            int num58 = 1;

            uiPanel9.autoLayout = num58 != 0;
            UILabel uiLabel7 = uiPanel9.AddUIComponent <UILabel>();

            uiLabel7.text              = Localization.Get("VEHICLE_EDITOR_MAX_SPEED");
            uiLabel7.font              = UIUtils.Font;
            uiLabel7.textColor         = (Color32)Color.white;
            uiLabel7.textScale         = 0.8f;
            uiLabel7.autoSize          = false;
            uiLabel7.height            = 30f;
            uiLabel7.width             = 115f;
            uiLabel7.wordWrap          = true;
            uiLabel7.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField4 = uiPanel9.AddUIComponent <UITextField>();
            string      str20        = "MaxSpeed";

            uiTextField4.name = str20;
            string str21 = "0";

            uiTextField4.text = str21;
            Color32 black4 = (Color32)Color.black;

            uiTextField4.textColor = black4;
            string str22 = "EmptySprite";

            uiTextField4.selectionSprite = str22;
            string str23 = "TextFieldPanelHovered";

            uiTextField4.normalBgSprite = str23;
            string str24 = "TextFieldPanel";

            uiTextField4.focusedBgSprite = str24;
            int num59 = 1;

            uiTextField4.builtinKeyNavigation = num59 != 0;
            int num60 = 1;

            uiTextField4.submitOnFocusLost = num60 != 0;
            double num61 = 45.0;

            uiTextField4.width = (float)num61;
            double num62 = 22.0;

            uiTextField4.height = (float)num62;
            int num63 = 3;

            uiTextField4.maxLength = num63;
            int num64 = 1;

            uiTextField4.numericalOnly = num64 != 0;
            int num65 = 1;

            uiTextField4.verticalAlignment = (UIVerticalAlignment)num65;
            RectOffset rectOffset11 = new RectOffset(0, 0, 4, 0);

            uiTextField4.padding = rectOffset11;
            UILabel uiLabel8 = uiPanel9.AddUIComponent <UILabel>();

            uiLabel8.name              = "MaxSpeedLabel";
            uiLabel8.text              = "0";
            uiLabel8.font              = UIUtils.Font;
            uiLabel8.textColor         = (Color32)Color.white;
            uiLabel8.textScale         = 0.8f;
            uiLabel8.textAlignment     = UIHorizontalAlignment.Right;
            uiLabel8.autoSize          = false;
            uiLabel8.height            = 30f;
            uiLabel8.width             = 60f;
            uiLabel8.verticalAlignment = UIVerticalAlignment.Middle;
            UIPanel uiPanel10 = uiPanel3.AddUIComponent <UIPanel>();
            string  str25     = "EngineRow";

            uiPanel10.name = str25;
            double num66 = (double)uiPanel10.parent.width - 8.0;

            uiPanel10.width = (float)num66;
            double num67 = 30.0;

            uiPanel10.height = (float)num67;
            int num68 = 0;

            uiPanel10.autoLayoutDirection = (LayoutDirection)num68;
            int num69 = 0;

            uiPanel10.autoLayoutStart = (LayoutStart)num69;
            RectOffset rectOffset12 = new RectOffset(0, 3, 0, 0);

            uiPanel10.autoLayoutPadding = rectOffset12;
            int num70 = 1;

            uiPanel10.autoLayout = num70 != 0;
            UICheckBox checkBox = UIUtils.CreateCheckBox((UIComponent)uiPanel10);
            string     str26    = "EngineOnBothEnds";

            checkBox.name = str26;
            string str27 = Localization.Get("VEHICLE_EDITOR_ENGINE_ON_BOTH_ENDS_TOOLTIP");

            checkBox.tooltip    = str27;
            checkBox.label.text = Localization.Get("VEHICLE_EDITOR_ENGINE_ON_BOTH_ENDS");
            UIPanel uiPanel11 = uiPanel3.AddUIComponent <UIPanel>();
            string  str28     = "ButtonRow";

            uiPanel11.name = str28;
            double num71 = (double)uiPanel11.parent.width - 8.0;

            uiPanel11.width = (float)num71;
            double num72 = 30.0;

            uiPanel11.height = (float)num72;
            int num73 = 0;

            uiPanel11.autoLayoutDirection = (LayoutDirection)num73;
            int num74 = 0;

            uiPanel11.autoLayoutStart = (LayoutStart)num74;
            RectOffset rectOffset13 = new RectOffset(0, 6, 4, 0);

            uiPanel11.autoLayoutPadding = rectOffset13;
            int num75 = 1;

            uiPanel11.autoLayout = num75 != 0;
            UIButton button1 = UIUtils.CreateButton((UIComponent)uiPanel11);
            string   str29   = "Apply";

            button1.name = str29;
            string str30 = Localization.Get("VEHICLE_EDITOR_APPLY");

            button1.text = str30;
            double num76 = 0.800000011920929;

            button1.textScale = (float)num76;
            double num77 = 110.0;

            button1.width = (float)num77;
            double num78 = 22.0;

            button1.height = (float)num78;
            MouseEventHandler mouseEventHandler1 = new MouseEventHandler(this.OnApplyButtonClick);

            button1.eventClick += mouseEventHandler1;
            UIButton button2 = UIUtils.CreateButton((UIComponent)uiPanel11);
            string   str31   = "Default";

            button2.name = str31;
            string str32 = Localization.Get("VEHICLE_EDITOR_DEFAULT");

            button2.text = str32;
            double num79 = 0.800000011920929;

            button2.textScale = (float)num79;
            double num80 = 110.0;

            button2.width = (float)num80;
            double num81 = 22.0;

            button2.height = (float)num81;
            MouseEventHandler mouseEventHandler2 = new MouseEventHandler(this.OnDefaultButtonClick);

            button2.eventClick += mouseEventHandler2;
        }