// note: MonoTouch addition - not fully compatible with "getHue:saturation:brightness:alpha:" wrt alpha void RoundtripHSB(UIColor c) { nfloat h, s, b, a; c.GetHSBA(out h, out s, out b, out a); UIColor r = UIColor.FromHSB(h, s, b); Assert.That(r.ToString(), Is.EqualTo(c.ToString()), c.ToString()); }
public static UIColor GetRandomColor() { var random = new Random(); var hue = (nfloat)(random.Next(0, 256) / 256.0f); var saturation = (nfloat)(random.Next(0, 128) / 256.0f) + 0.5f; var brightness = (nfloat)(random.Next(0, 128) / 256.0f) + 0.5f; return(UIColor.FromHSB(hue, saturation, brightness)); }
public NSAttributedString AttributedStringForParagraph(XElement paragraph) { var returnValue = new NSMutableAttributedString(); // TODO: find stage directions and format them differently if (ParagraphIsStageDirection(paragraph)) { var stageDirection = new NSAttributedString(TextForParagraph(paragraph), font: UIFont.FromName("Helvetica-LightOblique", 24), paragraphStyle: new NSMutableParagraphStyle() { Alignment = UITextAlignment.Center, LineSpacing = 10 }); returnValue.Append(stageDirection); } else { var speaker = new NSAttributedString(SpeakerForParagraph(paragraph), font: UIFont.FromName("HoeflerText-Black", 24), foregroundColor: UIColor.Brown ); var text = new NSAttributedString(TextForParagraph(paragraph), font: UIFont.FromName("HoeflerText-Regular", 24.0f), foregroundColor: UIColor.Black #if TEST_OTHER_ATTRIBUTES , backgroundColor: UIColor.Yellow, ligatures: NSLigatureType.None, kerning: 10, underlineStyle: NSUnderlineStyle.Single, shadow: new NSShadow() { ShadowColor = UIColor.Red, ShadowOffset = new System.Drawing.SizeF(5, 5) }, strokeWidth: 5 #endif ); returnValue.Append(speaker, " ", text); } if (Paragraphs.IndexOf(paragraph) == SelectedParagraph) { returnValue.AddAttribute(UIStringAttributeKey.ForegroundColor, UIColor.White, new NSRange(0, returnValue.Length)); returnValue.AddAttribute(UIStringAttributeKey.BackgroundColor, UIColor.FromHSB(.6f, .6f, .7f), new NSRange(0, returnValue.Length)); } returnValue.EnumerateAttribute(UIStringAttributeKey.ParagraphStyle, new NSRange(0, returnValue.Length), NSAttributedStringEnumeration.LongestEffectiveRangeNotRequired, (NSObject value, NSRange range, ref bool stop) => { var style = value == null ? new NSMutableParagraphStyle() : (NSMutableParagraphStyle)value.MutableCopy(); style.MinimumLineHeight = LineHeight; style.MaximumLineHeight = LineHeight; returnValue.AddAttribute(UIStringAttributeKey.ParagraphStyle, style, range); }); return(returnValue); }
public static UIColor Random() { var rand = new Random(); var hue = new nfloat((rand.Next(0, 25600) % 256) / 256.0); var saturation = new nfloat((rand.Next(0, 25600) % 128) / 256.0 + .5); var brightness = new nfloat((rand.Next(0, 25600) % 128) / 256.0 + .5); return(UIColor.FromHSB(hue, saturation, brightness)); }
public ColorPickerViewController() { satbrightview.hue = .5984375f; satbrightview.saturation = .5f; satbrightview.brightness = .7482993f; huewView.Hue = satbrightview.hue; selPrevView.BackgroundColor = UIColor.FromHSB(satbrightview.hue, satbrightview.saturation, satbrightview.brightness); }
void HandleColorPicked() { PositionSatBrightIndicatorView(); selPrevView.BackgroundColor = UIColor.FromHSB(satbrightview.hue, satbrightview.saturation, satbrightview.brightness); if (ColorPicked != null) { ColorPicked(); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var rnd = new Random(); this._colors = Enumerable .Range(0, _numberOfColors) .Select(x => UIColor.FromHSB((nfloat)rnd.NextDouble(), (nfloat)Math.Min(1.0, rnd.NextDouble() + 0.5), (nfloat)Math.Min(1.0, rnd.NextDouble() + 0.5))) .ToArray(); }
public override void Draw(CoreGraphics.CGRect rect) { UIColor.FromHSB(80.0f / 360.0f, 0.1f, 0.9f).SetFill(); UIGraphics.RectFill(rect); UIColor.Black.SetColor(); var text = new NSString($"Drag {Name}"); var b = Bounds; b.Inflate(-22, -22); text.DrawString(b, UIFont.BoldSystemFontOfSize(24)); }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var cell = collectionView.DequeueReusableCell(APLCollectionViewCell.Key, indexPath) as APLCollectionViewCell; #if NO_IMAGES float hue = indexPath.Item / (float)MAX_COUNT; UIColor cellColor = UIColor.FromHSB(hue, 1.0f, 1.0f); cell.ContentView.BackgroundColor = cellColor; #else cell.ImageView.Image = UIImage.FromFile("Images/sa" + indexPath.Item + ".jpg"); #endif return(cell); }
// If finger moved on screen public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; var locationc = touch.LocationInNode(this); // get the node at touched location var nodeAtLocation = GetNodeAtPoint(locationc); // Release the info text if cancel icon is clicked if (nodeAtLocation.Name == "cancelSpark") { ReleaseInfoText(); } else { // If the info icon is not clicked and the info text box is not visible get the location of touch and update the background color if (touch != null && infoTouch == false && nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel") { // Enable the Physics field fieldNode.Enabled = true; // Get the latest X and Y coordinates // 0 of X i on top float offsetX = (float)(touch.LocationInView(View).X); // other coordinate system // 0 of Y is bottom var checkX_Location = touch.LocationInNode(this).X; var checkY_Location = touch.LocationInNode(this).Y; fieldNode.Position = new CGPoint(checkX_Location, checkY_Location); var manipulate = (checkY_Location / (Frame.Height + 100)) + 0.15f; if (manipulate > 1) { manipulate = manipulate - 1; } // Background Calculating BackgroundColor = UIColor.FromHSB(manipulate, 0.35f, 0.7f); // Check to which part the finger is moved to and update the sparks globalCenter = new CGPoint(checkX_Location, checkY_Location); UpdateCenter(offsetX); } } }
public override void ViewDidLoad() { base.ViewDidLoad(); nextButton = UIButton.FromType(UIButtonType.RoundedRect); nextButton.SetTitle("Next", UIControlState.Normal); nextButton.SetTitleColor(UIColor.FromHSB(60.0f / 360.0f, 0.5f, 1.0f), UIControlState.Normal); nextButton.Font = UIFont.SystemFontOfSize(24); nextButton.TouchUpInside += delegate { Begin(); }; View.AddSubview(nextButton); View.ConstrainLayout(() => nextButton.Frame.GetCenterX() == View.Frame.GetCenterX() && nextButton.Frame.GetCenterY() == View.Frame.GetCenterY() && nextButton.Frame.Width == 200 && nextButton.Frame.Height == 88 && true); Begin(); }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); var touch = touches.AnyObject as UITouch; if (touch != null) { var locationc = touch.LocationInNode(this); // Check Location nfloat checkX = touch.LocationInNode(this).X; nfloat checkY = touch.LocationInNode(this).Y; lastY = checkY; // Game Mode in Edit Mode and no Navigation Drag and do only if sprite is not moving to another game mode if (gameMode != 0 && startDragMenu == false && !spriteTop.HasActions && !spriteBelow.HasActions) { // Game Mode 2=EditTop, and click in field not navigation, do Draw if (gameMode == 2 && checkY > 0 + 70) { // Match Background to color range background manipulate = (checkY / Frame.Height) + 0.2; if (manipulate > 1) { manipulate = manipulate - 1; } // Show Color Range spriteTop.Alpha = 0f; spriteTopBg.Alpha = 1f; // Set Color values to read each separate hueTop = (nfloat)(manipulate); satTop = 0.5f; briTop = (((checkX / Frame.Width) / 3) * 2 + ((0.3333333f))); // Set Color as Background lastColor = UIColor.FromHSB((nfloat)(manipulate), 0.5f, (((checkX / Frame.Width) / 3) * 2 + ((0.3333333f)))); spriteTop.Color = lastColor; // Show Circle as color lense followDragNode.FillColor = lastColor; followDragNode.StrokeColor = lastColor; followDragNode.Alpha = 0.8f; followDragNode.Position = locationc; } else if (gameMode == 1 && checkY < Frame.Height - 70) { // Match Background to color range background manipulate = (checkY / Frame.Height) + 0.37; if (manipulate > 1) { manipulate = manipulate - 1; } // Show Color Range spriteBelow.Alpha = 0f; spriteBelowBg.Alpha = 1f; // Set Color values to read each separate hueBel = (nfloat)(manipulate); satBel = 0.5f; briBel = (((checkX / Frame.Width) / 3) * 2 + ((0.3333333f))); // Set Color as Background lastColor = UIColor.FromHSB((nfloat)(manipulate), 0.5f, (((checkX / Frame.Width) / 3) * 2 + ((0.3333333f)))); spriteBelow.Color = lastColor; // Show Circle as color lense followDragNode.FillColor = lastColor; followDragNode.StrokeColor = lastColor; followDragNode.Alpha = 0.8f; followDragNode.Position = locationc; } } // Drag Menu Bar Below if (gameMode == 2 && checkY <= 0 + 100 && startDragMenu == true && actionStarted == true) { spriteTopBg.Position = new CGPoint(spriteTopBg.Position.X, ((View.Frame.Height * 0.5f) + 60) + checkY); spriteBelowBg.Position = new CGPoint(spriteBelowBg.Position.X, -View.Frame.Height / 2 + 60 + checkY); spriteTop.Position = new CGPoint(spriteTop.Position.X, ((View.Frame.Height * 0.5f) + 60) + checkY); spriteBelow.Position = new CGPoint(spriteBelowBg.Position.X, -View.Frame.Height / 2 + 60 + checkY); navLabelTop.Position = new CGPoint(navLabelBottom.Position.X, checkY + 80); navLabelBottom.Position = new CGPoint(navLabelTop.Position.X, checkY + 20); navSpriteTop.Position = new CGPoint(navSpriteTop.Position.X, checkY + 80); navSpriteBottom.Position = new CGPoint(navSpriteBottom.Position.X, checkY + 20); } // Activate move when menu is dragged over threashold else if (gameMode == 2 && checkY > 0 + 100 && startDragMenu == true && actionStarted == true) { MoveToCenterFromDown(); } // Drag Menu Bar Top else if (gameMode == 1 && checkY >= Frame.Height - 100 && startDragMenu == true && actionStarted == true) { spriteTopBg.Position = new CGPoint(spriteTopBg.Position.X, ((View.Frame.Height * 1.5f) - Frame.Height - 60) + checkY); spriteBelowBg.Position = new CGPoint(spriteBelowBg.Position.X, View.Frame.Height / 2 - Frame.Height - 60 + checkY); spriteTop.Position = new CGPoint(spriteTop.Position.X, ((View.Frame.Height * 1.5f) - Frame.Height - 60) + checkY); spriteBelow.Position = new CGPoint(spriteBelowBg.Position.X, View.Frame.Height / 2 - Frame.Height - 60 + checkY); navLabelTop.Position = new CGPoint(navLabelBottom.Position.X, checkY - 40); navLabelBottom.Position = new CGPoint(navLabelTop.Position.X, checkY - 100); navSpriteTop.Position = new CGPoint(navSpriteTop.Position.X, checkY - 40); navSpriteBottom.Position = new CGPoint(navSpriteBottom.Position.X, checkY - 100); } // Activate move when menu is dragged over threashold else if (gameMode == 1 && checkY < Frame.Height - 100 && startDragMenu == true && actionStarted == true) { MoveToCenterFromUp(); } if (gameMode == 0 && startDragMenu == true && actionStarted == true) { // Drag Menu Bar in Center in Start Game above if (checkY <= (Frame.Height / 2) + 70 && checkY >= (Frame.Height / 2) - 70) { spriteTopBg.Position = new CGPoint(spriteTopBg.Position.X, View.Frame.Height / 2 + checkY); spriteBelowBg.Position = new CGPoint(spriteBelowBg.Position.X, checkY - View.Frame.Height / 2); spriteTop.Position = new CGPoint(spriteTop.Position.X, View.Frame.Height / 2 + checkY); spriteBelow.Position = new CGPoint(spriteBelow.Position.X, checkY - View.Frame.Height / 2); navLabelTop.Position = new CGPoint(navLabelBottom.Position.X, checkY + 20); navLabelBottom.Position = new CGPoint(navLabelTop.Position.X, checkY - 40); navSpriteTop.Position = new CGPoint(navSpriteTop.Position.X, checkY + 20); navSpriteBottom.Position = new CGPoint(navSpriteBottom.Position.X, checkY - 40); } else if (checkY > (Frame.Height / 2 + 70)) { MoveToUpFromCenter(); } else if (checkY < Frame.Height / 2 - 70) { MoveToDownFromCenter(); } } } }
public override void DidMoveToView(SKView view) { // Setup Scene with SKNodes and call the sparks generator Proto1Dim1 = 0; Proto1Dim2 = 0; Proto1Dim3 = 0; switchInfo = false; infoTouch = false; // Set inital bgcolor BackgroundColor = UIColor.FromRGBA(100, 200, 150, 120); // Background Sprite backgroundSprite = new SKSpriteNode("spark"); backgroundSprite.ScaleTo(Frame.Size); backgroundSprite.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2); backgroundSprite.ZPosition = 0; backgroundSprite.Alpha = 0.1f; AddChild(backgroundSprite); // Add Gravity Field fieldNode = SKFieldNode.CreateSpringField(); fieldNode.Enabled = false; fieldNode.Position = new CGPoint(Frame.Size.Width / 2, Frame.Size.Height / 2); fieldNode.Strength = 0.5f; fieldNode.Region = new SKRegion(Frame.Size); AddChild(fieldNode); // Change color, child not added only in test env mySave = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "next >", FontSize = 18, Position = new CGPoint(Frame.Width - 65, (Frame.Height - 53)) }; mySave.Name = "next"; mySave.FontColor = UIColor.FromHSB(0, 0, 3f); mySave.Alpha = 0.9f; mySave.ZPosition = 10; // AddChild(mySave); // Invisible sprite node to change to Info Mode, on the right top side infront of the info sprite navSprite = new SKSpriteNode(); navSprite.Name = "navSprite"; navSprite.Alpha = 0.0000001f; navSprite.ZPosition = 10; navSprite.Color = UIColor.FromHSB(0, 1, 0.0f); navSprite.Size = new CGSize(100, 70); navSprite.Position = new CGPoint((View.Frame.Width - (50)), (View.Frame.Height - (35))); AddChild(navSprite); // Container field to fill different background (Info Mode) container = new SKSpriteNode("background_newcolor"); container.Size = new CGSize(Frame.Width, Frame.Height); container.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2); container.ZPosition = 0; container.Alpha = 0f; AddChild(container); // Sprite Node with the info icon infoSprite = new SKSpriteNode("info"); infoSprite.Name = "navSprite"; infoSprite.Position = new CGPoint(Frame.Width - 40, Frame.Height - 40); infoSprite.ZPosition = 10; infoSprite.XScale = 0.6f; infoSprite.YScale = 0.6f; infoSprite.Alpha = 0.8f; infoSprite.Name = "info"; AddChild(infoSprite); // Start with the info text SetInfoText(); // Generate Sparks GenerateSparks(); }
private void SetInfoText() { int tempFontSize = 18; int tempInfoSize = 40; int tempInfoPos = 40; // Check which iOS device, change infobox text and size if (UIScreen.MainScreen.Bounds.Width < 375) { tempFontSize = 16; tempInfoSize = 20; tempInfoPos = 30; } // Define and add Label 1 infoLabel1 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "Hier kannst du gleich deine Emotion", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10) }; infoLabel1.Alpha = 0.0f; infoLabel1.Name = "infoLabel"; infoLabel1.ZPosition = 100; AddChild(infoLabel1); // Define and add Label 2 infoLabel2 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "erfassen indem du den Bildschirm berührst", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20) }; infoLabel2.Alpha = 0.0f; infoLabel2.Name = "infoLabel"; infoLabel2.ZPosition = 100; AddChild(infoLabel2); // Define and add Label 3 infoLabel3 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "navigiere die Kreise mit dem Finger", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10), }; infoLabel3.Alpha = 0.0f; infoLabel3.ZPosition = 100; infoLabel3.Name = "infoLabel"; AddChild(infoLabel3); // Define and add Label 4 infoLabel4 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "die Farbe und Bewegung verändert sich", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20), }; infoLabel4.Alpha = 0.0f; infoLabel4.ZPosition = 100; infoLabel4.Name = "infoLabel"; AddChild(infoLabel4); // Define and add Label 5 infoLabel5 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "wenn Farbe und Emotion übereinstimmen", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10), }; infoLabel5.Alpha = 0.0f; infoLabel5.ZPosition = 100; infoLabel5.Name = "infoLabel"; AddChild(infoLabel5); // Define and add Label 6 infoLabel6 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "hebe den Finger ab dem Bildschirm", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20), }; infoLabel6.Alpha = 0.0f; infoLabel6.Name = "infoLabel"; infoLabel6.ZPosition = 100; AddChild(infoLabel6); // Define and add Label 7 infoLabel7 = new SKLabelNode("AppleSDGothicNeo-Bold") { Text = "TEATIME", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 60), }; infoLabel7.Alpha = 0.0f; infoLabel7.Name = "infoLabel"; infoLabel7.ZPosition = 100; AddChild(infoLabel7); // Do Actions on the Label Nodes (wait, fade in, wait, fade out) DoActionSequenceOnNode(infoLabel1, 1, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel2, 2, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel3, 6, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel4, 7, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel5, 11, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel6, 12, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel7, 0, 1, 16, 1, 0.7f); // Define and add Info Box rect infoNode = new SKSpriteNode(); infoNode.Size = new CGSize(Frame.Width, Frame.Height); infoNode.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2); infoNode.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode.ZPosition = 99; infoNode.Name = "infoNode"; infoNode.Alpha = 0.0f; AddChild(infoNode); // Define and add Info Box rect 2 infoNode2 = new SKSpriteNode(); infoNode2.Size = new CGSize(Frame.Width - 60, 130); infoNode2.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 25); infoNode2.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode2.ZPosition = 98; infoNode2.Name = "infoNode"; infoNode2.Alpha = 0.0f; AddChild(infoNode2); // Define and add Info Box rect 3 infoNode3 = new SKSpriteNode(); infoNode3.Size = new CGSize(Frame.Width - tempInfoSize, 130); infoNode3.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 25); infoNode3.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode3.ZPosition = 98; infoNode3.Name = "infoNode"; infoNode3.Alpha = 0.0f; AddChild(infoNode3); // Define and add Cancel Icon for the Info Box cancelSpark = new SKSpriteNode("sparkx"); cancelSpark.Name = "cancelSpark"; cancelSpark.ZPosition = 1000; cancelSpark.Alpha = 0.0f; cancelSpark.SetScale(0.6f); cancelSpark.Color = UIColor.FromHSB(0, 0, 0.0f); cancelSpark.Position = new CGPoint((View.Frame.Width - (tempInfoPos)), (View.Frame.Height / 2 + (70))); AddChild(cancelSpark); // Define and add Teatime Icon for the Info Box teatimeSprite = new SKSpriteNode("*****@*****.**"); teatimeSprite.Name = "infoNode"; teatimeSprite.ZPosition = 1000; teatimeSprite.Alpha = 0.0f; teatimeSprite.SetScale(0.35f); teatimeSprite.Color = UIColor.FromHSB(0, 0, 0.0f); teatimeSprite.Position = new CGPoint((0 + (tempInfoPos)), (View.Frame.Height / 2 + (70))); AddChild(teatimeSprite); // Actions and Sequence for Info Nodes DoActionSequenceOnNode(infoNode, 0, 1, 16, 1, 0.3f); DoActionSequenceOnNode(infoNode3, 0, 1, 16, 1, 0.3f); DoActionSequenceOnNode(cancelSpark, 0, 1, 16, 1, 0.3f); DoActionSequenceOnNode(teatimeSprite, 0, 1, 16, 1, 0.3f); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Login"; View.BackgroundColor = UIColor.FromHSB(UIConstants.BackgroundColorHue, UIConstants.BackgroundColorSaturation, UIConstants.BackgroundColorBrightness); var username = new UITextField { Placeholder = "Username", BorderStyle = UITextBorderStyle.RoundedRect, }; View.AddSubview(username); username.Layer.BorderColor = UIColor.Gray.CGColor; username.Layer.BorderWidth = UIConstants.BorderWidth; username.Layer.CornerRadius = UIConstants.CornerRadius; var password = new UITextField { Placeholder = "Password", BorderStyle = UITextBorderStyle.RoundedRect, SecureTextEntry = true, }; View.AddSubview(password); password.Layer.BorderColor = UIColor.Gray.CGColor; password.Layer.BorderWidth = UIConstants.BorderWidth; password.Layer.CornerRadius = UIConstants.CornerRadius; var loginButton = new UIButton(UIButtonType.System) { BackgroundColor = UIColor.FromHSB(UIConstants.BackgroundColorHue + 0.08f, UIConstants.BackgroundColorSaturation + 0.1f, UIConstants.BackgroundColorBrightness), Font = UIFont.FromName("Helvetica-Bold", UIConstants.NormalFontSize), }; View.AddSubview(loginButton); loginButton.SetTitle("Login", UIControlState.Normal); loginButton.SetTitleColor(UIColor.White, UIControlState.Normal); loginButton.Layer.CornerRadius = UIConstants.CornerRadius; loginButton.TouchUpInside += (sender, e) => { NavigationController.PushViewController(new AbcViewController(), true); }; var signUpButton = new UIButton(UIButtonType.System) { BackgroundColor = UIColor.White, Font = UIFont.FromName("Helvetica-Bold", UIConstants.NormalFontSize), }; View.AddSubview(signUpButton); signUpButton.SetTitle("Sign Up", UIControlState.Normal); signUpButton.SetTitleColor(UIColor.FromHSB(UIConstants.BackgroundColorHue, UIConstants.BackgroundColorSaturation, UIConstants.BackgroundColorBrightness), UIControlState.Normal); signUpButton.Layer.CornerRadius = UIConstants.CornerRadius; #region UI Layout var topPad = (float)NavigationController.NavigationBar.Frame.Size.Height + UIConstants.VerticalPad + 30f; View.ConstrainLayout(() => username.Frame.Top == View.Frame.Top + topPad && username.Frame.Left >= View.Frame.Left + UIConstants.HorizontalPad && username.Frame.Right >= View.Frame.Right - UIConstants.HorizontalPad && username.Frame.Height == UIConstants.ControlsHeight && username.Frame.GetCenterX() == View.Frame.GetCenterX() && username.Frame.Width <= UIConstants.MaximumControlsWidth && password.Frame.Top == username.Frame.Bottom + 20f && password.Frame.Left >= View.Frame.Left + UIConstants.HorizontalPad && password.Frame.Right >= View.Frame.Right - UIConstants.HorizontalPad && password.Frame.Height == UIConstants.ControlsHeight && password.Frame.GetCenterX() == View.Frame.GetCenterX() && password.Frame.Width <= UIConstants.MaximumControlsWidth && loginButton.Frame.Top == password.Frame.Bottom + 40f && loginButton.Frame.Left >= View.Frame.Left + UIConstants.HorizontalPad && loginButton.Frame.Right >= View.Frame.Right - UIConstants.HorizontalPad && loginButton.Frame.Height == UIConstants.ControlsHeight && loginButton.Frame.GetCenterX() == View.Frame.GetCenterX() && loginButton.Frame.Width <= UIConstants.MaximumControlsWidth && signUpButton.Frame.Top == loginButton.Frame.Bottom + 20f && signUpButton.Frame.Left >= View.Frame.Left + UIConstants.HorizontalPad && signUpButton.Frame.Right >= View.Frame.Right - UIConstants.HorizontalPad && signUpButton.Frame.Height == UIConstants.ControlsHeight && signUpButton.Frame.GetCenterX() == View.Frame.GetCenterX() && signUpButton.Frame.Width <= UIConstants.MaximumControlsWidth ); #endregion }
public override void TouchesBegan(NSSet touches, UIEvent evt) { // Called when a touch begins foreach (var touch in touches) { var touchc = touches.AnyObject as UITouch; // Check location nfloat checkX = touchc.LocationInNode(this).X; nfloat checkY = touchc.LocationInNode(this).Y; // Get the first touch if (nextTouch == false) { nextTouch = true; } // Wait with interaction until first cycle is done if (waitWithInteraction) { // Update Lines depending on the location of click, animate button if (checkY > (Frame.Height / 2)) { if (checkX > (Frame.Width / 2)) { speedVal = speedVal - 0.1f; SKAction act1 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 1f), 1f, 0); SKAction act2 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 0f), 0f, 1); SKAction seq = SKAction.Sequence(act1, act2); rightUpperSprite.RunAction(seq); } else { sizeVal = sizeVal + 0.1f; SKAction act1 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 1f), 1f, 0); SKAction act2 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 0f), 0f, 1); SKAction seq = SKAction.Sequence(act1, act2); leftUpperSprite.RunAction(seq); } } else { if (checkX > (Frame.Width / 2)) { speedVal = speedVal + 0.1f; SKAction act1 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 1f), 1f, 0); SKAction act2 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 0f), 0f, 1); SKAction seq = SKAction.Sequence(act1, act2); rightLowerSprite.RunAction(seq); } else { sizeVal = sizeVal - 0.1f; SKAction act1 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 1f), 1f, 0); SKAction act2 = SKAction.ColorizeWithColor(UIColor.FromHSB(0, 0, 0f), 0f, 1); SKAction seq = SKAction.Sequence(act1, act2); leftLowerSprite.RunAction(seq); } } // Min Speed if (speedVal < 0.1f) { speedVal = 0.1f; } // Max Speed if (speedVal > 2.0f) { speedVal = 2.0f; } // Max Size if (sizeVal > 8.0f) { sizeVal = 8.0f; } // Min Size if (sizeVal < 0.1f) { sizeVal = 0.1f; } lineCounterUpdate = 0; } } }
/// <summary> /// Initializes a new instance of the <see cref="ColorPickerViewController"/> class /// with the specified initial selected hue, saturation and brightness. /// </summary> /// <param name="hue">The initial selected hue.</param> /// <param name="saturation">The initial selected saturation.</param> /// <param name="brightness">The initial selected brightness.</param> public ColorPickerViewController(nfloat hue, nfloat saturation, nfloat brightness) { Initialize(UIColor.FromHSB(hue, saturation, brightness)); }
/// <summary> /// Initializes a new instance of the <see cref="ColorPickerViewController"/> class. /// </summary> public ColorPickerViewController() { Initialize(UIColor.FromHSB(0.5984375f, 0.5f, 0.7482993f)); }
public override void DidMoveToView(SKView view) { // Setup Sprite Scene Proto4Dim1 = 0; Proto4Dim2 = 0; Proto4Dim3 = 0; waitWithInteraction = true; nextTouch = false; lineCounter = 0; lineCounterUpdate = 0; // Define four labels and sprite nodes which act as buttons // Left Upper Sprite and Label leftUpperSprite = new SKSpriteNode(); leftUpperSprite.Color = UIColor.FromHSB(0, 0, 0.0f); leftUpperSprite.Size = new CGSize(Frame.Width / 2, Frame.Height / 2); leftUpperSprite.Position = new CGPoint(Frame.Width / 4, (Frame.Height / 4) * 3); leftUpperSprite.ZPosition = 3; AddChild(leftUpperSprite); myLabelSizePlus = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "grösser", FontSize = 20, Position = leftUpperSprite.Position, ZPosition = 5 }; myLabelSizePlus.Alpha = 0.9f; myLabelSizePlus.FontColor = UIColor.FromHSB(0, 0, 0.0f); AddChild(myLabelSizePlus); // Right Upper Sprite and Label rightUpperSprite = new SKSpriteNode(); rightUpperSprite.Color = UIColor.FromHSB(0, 0, 0.0f); rightUpperSprite.Size = new CGSize(Frame.Width / 2, Frame.Height / 2); rightUpperSprite.Position = new CGPoint(((Frame.Width / 4) * 3), ((Frame.Height / 4) * 3)); rightUpperSprite.ZPosition = 3; AddChild(rightUpperSprite); myLabelSpeedPlus = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "schneller", FontSize = 20, Position = rightUpperSprite.Position, ZPosition = 5 }; myLabelSpeedPlus.Alpha = 0.9f; myLabelSpeedPlus.FontColor = UIColor.FromHSB(0, 0, 0.0f); AddChild(myLabelSpeedPlus); // Left Lower Sprite and Label leftLowerSprite = new SKSpriteNode(); leftLowerSprite.Color = UIColor.FromHSB(0, 0, 0.0f); leftLowerSprite.Size = new CGSize(Frame.Width / 2, Frame.Height / 2); leftLowerSprite.Position = new CGPoint((Frame.Width / 4), (Frame.Height / 4)); leftLowerSprite.ZPosition = 3; AddChild(leftLowerSprite); myLabelSizeMinus = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "kleiner", FontSize = 20, Position = leftLowerSprite.Position, ZPosition = 5 }; myLabelSizeMinus.Alpha = 0.9f; myLabelSizeMinus.FontColor = UIColor.FromHSB(0, 0, 0.0f); AddChild(myLabelSizeMinus); // Right Lower Sprite and Label rightLowerSprite = new SKSpriteNode(); rightLowerSprite.Color = UIColor.FromHSB(0, 0, 0.0f); rightLowerSprite.Size = new CGSize(Frame.Width / 2, Frame.Height / 2); rightLowerSprite.Position = new CGPoint(((Frame.Width / 4) * 3), (Frame.Height / 4)); rightLowerSprite.ZPosition = 3; AddChild(rightLowerSprite); myLabelSpeedMinus = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "langsamer", FontSize = 20, Position = rightLowerSprite.Position, ZPosition = 5 }; myLabelSpeedMinus.Alpha = 0.9f; myLabelSpeedMinus.FontColor = UIColor.FromHSB(0, 0, 0.0f); AddChild(myLabelSpeedMinus); // Set Background of Scene to black BackgroundColor = UIColor.FromHSB(0, 0, 0); aTimer = new Timer(); aTimer.Elapsed += OnTimedEvent; aTimer.Interval = 140; aTimer.Enabled = true; aTimerCounter = 0; bTimerCounter = 0; // Default Value sizeVal = 1.5f; speedVal = 0.8f; }
public static UIColor GetRandomColor(bool dark = false) => UIColor.FromHSB((dark ? Random.Next(180, 255) : Random.Next(255)) / 255.0f, 1.0f, 1.0f);
private UIColor GetColorTempLow(float _min, float _max, float _value) { return(UIColor.FromHSB(((maxHlow - minHlow) * (_max + _min - _value) + _max * minHlow - _min * maxHlow) / (360 * (_max - _min)), hsb_S, hsb_B)); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Login"; View.BackgroundColor = Constants.MainColor; // var logoImageView = new UIImageView(); // View.AddSubview(logoImageView); // logoImageView.Image = UIImage.FromBundle("logo.png"); // logo.Layer.BorderColor = new CGColor(255, 255, 255); // logo.Layer.BorderWidth = 1f; // logo.Layer.CornerRadius = 25f; var usernameTextField = new UITextField { Placeholder = "Email", BorderStyle = UITextBorderStyle.RoundedRect, AutocapitalizationType = UITextAutocapitalizationType.None, KeyboardType = UIKeyboardType.EmailAddress, }; View.AddSubview(usernameTextField); usernameTextField.Layer.BorderColor = UIColor.Gray.CGColor; usernameTextField.Layer.BorderWidth = Constants.BorderWidth; usernameTextField.Layer.CornerRadius = Constants.CornerRadius; var passwordTextField = new UITextField { Placeholder = "Password", BorderStyle = UITextBorderStyle.RoundedRect, SecureTextEntry = true, }; View.AddSubview(passwordTextField); passwordTextField.Layer.BorderColor = UIColor.Gray.CGColor; passwordTextField.Layer.BorderWidth = Constants.BorderWidth; passwordTextField.Layer.CornerRadius = Constants.CornerRadius; var loginButton = new UIButton(UIButtonType.System) { BackgroundColor = UIColor.FromHSB(Constants.MainColorHue + 0.08f, Constants.MainColorSaturation + 0.1f, Constants.MainColorBrightness), Font = UIFont.BoldSystemFontOfSize(Constants.NormalFontSize), }; View.AddSubview(loginButton); loginButton.SetTitle("Login", UIControlState.Normal); loginButton.SetTitleColor(UIColor.White, UIControlState.Normal); loginButton.Layer.CornerRadius = Constants.CornerRadius; loginButton.TouchUpInside += async(sender, e) => { Tuple <string, string> response = null; try { loginButton.Enabled = false; response = await UserUtil.AuthenticateUserAsync(usernameTextField.Text, passwordTextField.Text); } catch (Exception ex) { var alert = UIAlertController.Create("Something goes wrong", String.Format("Please check your Internet connection and try again.{0} Details: {1}", Environment.NewLine, ex.Message), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); loginButton.Enabled = true; } if (!String.IsNullOrEmpty(response.Item2)) { UIApplication.SharedApplication.Windows[0].RootViewController = new TabViewController(); } else { var alert = UIAlertController.Create("Error", response.Item1, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Retry", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } loginButton.Enabled = true; }; var signUpButton = new UIButton(UIButtonType.System) { BackgroundColor = UIColor.White, Font = UIFont.BoldSystemFontOfSize(Constants.NormalFontSize), }; View.AddSubview(signUpButton); signUpButton.SetTitle("Sign Up", UIControlState.Normal); signUpButton.SetTitleColor(UIColor.FromHSB(Constants.MainColorHue, Constants.MainColorSaturation, Constants.MainColorBrightness), UIControlState.Normal); signUpButton.Layer.CornerRadius = Constants.CornerRadius; signUpButton.TouchUpInside += (sender, e) => { signUpButton.Enabled = false; NavigationController.PushViewController(new RegistrationViewController(), true); signUpButton.Enabled = true; }; #region UI Layout var topPad = View.Frame.GetCenterY() - (Constants.ControlsHeight * 4 / 2) - Constants.ControlsHeight; // Half the total heights of all controls: the controls will be centered then go up a bit View.ConstrainLayout(() => // logoImageView.Frame.Top == View.Frame.Top + topPad && // logoImageView.Frame.Left >= View.Frame.Left + UIConstants.HorizontalPad && // logoImageView.Frame.Right >= View.Frame.Right - UIConstants.HorizontalPad && // logoImageView.Frame.GetCenterX() == View.Frame.GetCenterX() && // logoImageView.Frame.Width == 500f && usernameTextField.Frame.Top == View.Frame.Top + topPad && usernameTextField.Frame.GetCenterX() == View.Frame.GetCenterX() && usernameTextField.Frame.Left >= View.Frame.Left + Constants.HorizontalPad && usernameTextField.Frame.Right >= View.Frame.Right - Constants.HorizontalPad && usernameTextField.Frame.Width <= Constants.MaximumControlsWidth && usernameTextField.Frame.Height == Constants.ControlsHeight && passwordTextField.Frame.Top == usernameTextField.Frame.Bottom + Constants.SmallGap && passwordTextField.Frame.GetCenterX() == View.Frame.GetCenterX() && passwordTextField.Frame.Left >= View.Frame.Left + Constants.HorizontalPad && passwordTextField.Frame.Right >= View.Frame.Right - Constants.HorizontalPad && passwordTextField.Frame.Width <= Constants.MaximumControlsWidth && passwordTextField.Frame.Height == Constants.ControlsHeight && loginButton.Frame.Top == passwordTextField.Frame.Bottom + Constants.BigGap && loginButton.Frame.GetCenterX() == View.Frame.GetCenterX() && loginButton.Frame.Left >= View.Frame.Left + Constants.HorizontalPad && loginButton.Frame.Right >= View.Frame.Right - Constants.HorizontalPad && loginButton.Frame.Width <= Constants.MaximumControlsWidth && loginButton.Frame.Height == Constants.ControlsHeight && signUpButton.Frame.Top == loginButton.Frame.Bottom + Constants.SmallGap && signUpButton.Frame.GetCenterX() == View.Frame.GetCenterX() && signUpButton.Frame.Left >= View.Frame.Left + Constants.HorizontalPad && signUpButton.Frame.Right >= View.Frame.Right - Constants.HorizontalPad && signUpButton.Frame.Width <= Constants.MaximumControlsWidth && signUpButton.Frame.Height == Constants.ControlsHeight ); #endregion View.AddGestureRecognizer(new UITapGestureRecognizer(() => { View.EndEditing(true); })); }
private UIColor GetColorTempHigh(float _min, float _max, float _value) { return(UIColor.FromHSB(((maxHhgh - minHhgh) * (_max + _min - _value) + _max * minHhgh - _min * maxHhgh) / (360 * (_max - _min)), hsb_S, hsb_B)); }
NSDictionary Options() { var keys = new NSString[] { Constants.kCRToastNotificationTypeKey, Constants.kCRToastNotificationPresentationTypeKey, Constants.kCRToastUnderStatusBarKey, Constants.kCRToastTextKey, Constants.kCRToastTextAlignmentKey, Constants.kCRToastTimeIntervalKey, Constants.kCRToastAnimationInTypeKey, Constants.kCRToastAnimationOutTypeKey, Constants.kCRToastAnimationInDirectionKey, Constants.kCRToastAnimationOutDirectionKey, Constants.kCRToastNotificationPreferredPaddingKey }; var objects = new NSObject[] { NSNumber.FromInt64((long)(coverNavBarSwitch.On ? CRToastType.NavigationBar : CRToastType.StatusBar)), NSNumber.FromInt64((long)(SlideOverSwitch.On ? CRToastPresentationType.Cover : CRToastPresentationType.Push)), NSNumber.FromBoolean(SlideUnderSwitch.On), (NSString)TxtNotificationMessage.Text, NSNumber.FromInt64((long)_TextAlignment), NSNumber.FromDouble(SliderDuration.Value), NSNumber.FromInt64(InAnimationTypeSegmentedControl.SelectedSegment), NSNumber.FromInt64(OutAnimationTypeSegmentedControl.SelectedSegment), NSNumber.FromInt64(SegFromDirection.SelectedSegment), NSNumber.FromInt64(SegToDirection.SelectedSegment), NSNumber.FromDouble(SliderPadding.Value) }; var options = NSMutableDictionary.FromObjectsAndKeys(objects, keys); if (ShowImageSwitch.On) { options.Add(Constants.kCRToastImageKey, UIImage.FromFile("alert_icon.png")); options.Add(Constants.kCRToastImageAlignmentKey, NSNumber.FromInt64(ImageAlignmentSegmentedControl.SelectedSegment)); } if (ImageTintEnabledSwitch.On) { options.Add(Constants.kCRToastImageTintKey, UIColor.FromHSB(ImageTintSlider.Value, 1.0f, 1.0f)); } if (ShowActivityIndicatorSwitch.On) { options.Add(Constants.kCRToastShowActivityIndicatorKey, NSNumber.FromBoolean(true)); options.Add(Constants.kCRToastActivityIndicatorAlignmentKey, NSNumber.FromInt64(ActivityIndicatorAlignmentSegementControl.SelectedSegment)); } if (ForceUserInteractionSwitch.On) { options.Add(Constants.kCRToastForceUserInteractionKey, NSNumber.FromBoolean(true)); } if (!string.IsNullOrEmpty(TxtNotificationMessage.Text)) { options.Add(Constants.kCRToastIdentifierKey, (NSString)TxtNotificationMessage.Text); } if (!string.IsNullOrEmpty(TxtSubtitleMessage.Text)) { options.Add(Constants.kCRToastSubtitleTextKey, (NSString)TxtSubtitleMessage.Text); options.Add(Constants.kCRToastSubtitleTextAlignmentKey, NSNumber.FromInt64(SegSubtitleAlignment.SelectedSegment)); } if (DismissibleWithTapSwitch.On) { options.Add(Constants.kCRToastInteractionRespondersKey, CRToastInteractionResponder.InteractionResponderWithInteractionType(CRToastInteractionType.Tap, true, (interactionType) => { System.Diagnostics.Debug.WriteLine($"Dismissed with {interactionType} interaction"); }) ); } return(NSDictionary.FromDictionary(options)); }
private void UpdateImageTintSwitch() { ImageTintEnabledSwitch.OnTintColor = UIColor.FromHSB(ImageTintSlider.Value, 1.0f, 1.0f); }
private UIColor GetColorPressure(float _min, float _max, float _value) { return(UIColor.FromHSB(((maxHpre - minHpre) * _value + _max * minHpre - _min * maxHpre) / (360 * (_max - _min)), hsb_S, hsb_B)); }
// Generate Sprite fields private void GenerateSprites() { var locationTop = new CGPoint(); locationTop.X = (View.Frame.Width / 2); locationTop.Y = (View.Frame.Height); var locationBelow = new CGPoint(); locationBelow.X = (View.Frame.Width / 2); locationBelow.Y = 0; // Define Spark with location and alpha spriteTop = new FieldNode() { Position = locationTop, Name = "TopBg", XScale = 1, YScale = 1, Alpha = 1f, Color = UIColor.FromHSB(0.8f, 0.5f, 0.5f) }; spriteTopBg = new FieldNode() { Position = locationTop, Name = "Top", XScale = 1, YScale = 1, Alpha = 0f, Texture = SKTexture.FromImageNamed(("background")) }; spriteBelow = new FieldNode() { Position = locationBelow, Name = "Below", XScale = 1, YScale = 1, Alpha = 1f, Color = UIColor.FromHSB(0.5f, 0.5f, 0.5f) }; spriteBelowBg = new FieldNode() { Position = locationBelow, Name = "BelowBg", XScale = 1, YScale = 1, Alpha = 0f, Texture = SKTexture.FromImageNamed(("background")) }; // Create Circle var tempPath = new UIBezierPath(); tempPath.MoveTo(new CGPoint(0, 0)); tempPath.AddArc(new CGPoint(0, 0), 60, 0, 2.0f * (float)Math.PI, true); CGPath convertedPath = tempPath.CGPath; followDragNode = new SKShapeNode() { Position = locationTop, Path = convertedPath, Name = "follow", XScale = 1, YScale = 1, Alpha = 0f, FillColor = UIColor.FromHSB(0, 0, 1f), }; // Position in comparsion to other SpriteNodes spriteTop.ZPosition = 1; spriteBelow.ZPosition = 1; spriteTopBg.ZPosition = 0; spriteBelowBg.ZPosition = 0; followDragNode.ZPosition = 0.5f; // Update Sizes spriteTopBg.Size = new CGSize(Frame.Width / 1, Frame.Height / 1); spriteBelowBg.Size = new CGSize(Frame.Width / 1, Frame.Height / 1); spriteTop.Size = new CGSize(Frame.Width / 1, Frame.Height / 1); spriteBelow.Size = new CGSize(Frame.Width / 1, Frame.Height / 1); // Add nodes AddChild(spriteTopBg); AddChild(spriteBelowBg); AddChild(spriteTop); AddChild(spriteBelow); AddChild(followDragNode); }
public override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = Constants.MainColor; var stackView = new UIStackView { Axis = UILayoutConstraintAxis.Vertical, Alignment = UIStackViewAlignment.Fill, Distribution = UIStackViewDistribution.EqualSpacing, Spacing = Constants.SmallGap, TranslatesAutoresizingMaskIntoConstraints = false, }; View.AddSubview(stackView); var barHeight = Constants.StatusBarHeight + (float)NavigationController.NavigationBar.Frame.Size.Height; var topPad = barHeight + Constants.VerticalPad * 2; View.ConstrainLayout(() => stackView.Frame.Top == View.Frame.Top + topPad && stackView.Frame.Left == View.Frame.Left + Constants.HorizontalPad && stackView.Frame.Right == View.Frame.Right - Constants.VerticalPad ); var firstNameTextField = new UITextField { Placeholder = "First Name", BorderStyle = UITextBorderStyle.RoundedRect, }; stackView.AddArrangedSubview(firstNameTextField); firstNameTextField.Layer.BorderColor = UIColor.Gray.CGColor; firstNameTextField.Layer.BorderWidth = Constants.BorderWidth; firstNameTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => firstNameTextField.Frame.Height == Constants.ControlsHeight ); var lastNameTextField = new UITextField { Placeholder = "Last Name", BorderStyle = UITextBorderStyle.RoundedRect, }; stackView.AddArrangedSubview(lastNameTextField); lastNameTextField.Layer.BorderColor = UIColor.Gray.CGColor; lastNameTextField.Layer.BorderWidth = Constants.BorderWidth; lastNameTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => lastNameTextField.Frame.Height == Constants.ControlsHeight ); var emailTextField = new UITextField { Placeholder = "Email", BorderStyle = UITextBorderStyle.RoundedRect, AutocapitalizationType = UITextAutocapitalizationType.None, KeyboardType = UIKeyboardType.EmailAddress, }; stackView.AddArrangedSubview(emailTextField); emailTextField.Layer.BorderColor = UIColor.Gray.CGColor; emailTextField.Layer.BorderWidth = Constants.BorderWidth; emailTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => emailTextField.Frame.Height == Constants.ControlsHeight ); var phoneTextField = new UITextField { Placeholder = "Phone Number", BorderStyle = UITextBorderStyle.RoundedRect, KeyboardType = UIKeyboardType.NumberPad, }; stackView.AddArrangedSubview(phoneTextField); phoneTextField.Layer.BorderColor = UIColor.Gray.CGColor; phoneTextField.Layer.BorderWidth = Constants.BorderWidth; phoneTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => phoneTextField.Frame.Height == Constants.ControlsHeight ); var passwordTextField = new UITextField { Placeholder = "Password", SecureTextEntry = true, AutocapitalizationType = UITextAutocapitalizationType.None, BorderStyle = UITextBorderStyle.RoundedRect, }; stackView.AddArrangedSubview(passwordTextField); passwordTextField.Layer.BorderColor = UIColor.Gray.CGColor; passwordTextField.Layer.BorderWidth = Constants.BorderWidth; passwordTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => passwordTextField.Frame.Height == Constants.ControlsHeight ); var confirmPasswordTextField = new UITextField { Placeholder = "Confirm Password", SecureTextEntry = true, BorderStyle = UITextBorderStyle.RoundedRect, }; stackView.AddArrangedSubview(confirmPasswordTextField); confirmPasswordTextField.Layer.BorderColor = UIColor.Gray.CGColor; confirmPasswordTextField.Layer.BorderWidth = Constants.BorderWidth; confirmPasswordTextField.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => confirmPasswordTextField.Frame.Height == Constants.ControlsHeight ); var submitButton = new UIButton(UIButtonType.System) { BackgroundColor = UIColor.FromHSB(Constants.MainColorHue + 0.08f, Constants.MainColorSaturation + 0.1f, Constants.MainColorBrightness), Font = UIFont.BoldSystemFontOfSize(Constants.NormalFontSize), }; stackView.AddArrangedSubview(submitButton); submitButton.SetTitle("Submit", UIControlState.Normal); submitButton.SetTitleColor(UIColor.White, UIControlState.Normal); submitButton.Layer.CornerRadius = Constants.CornerRadius; View.ConstrainLayout(() => submitButton.Frame.Height == Constants.ControlsHeight ); submitButton.TouchUpInside += async(sender, e) => { submitButton.Enabled = false; var valid = ValidateInfo(firstNameTextField.Text, lastNameTextField.Text, emailTextField.Text, phoneTextField.Text, passwordTextField.Text, confirmPasswordTextField.Text); if (valid.Item1) { var user = new User { FirstName = firstNameTextField.Text, LastName = lastNameTextField.Text, Email = emailTextField.Text, Password = passwordTextField.Text, Phone = phoneTextField.Text, // Not a required field }; Tuple <bool, string> registrationResult = null; try { // registrationResult = await UserUtil.RegisterUserThenLoginAsync(user); Can't use right now!! registrationResult = await UserUtil.RegisterUserAsync(user); if (registrationResult.Item1) { // UIApplication.SharedApplication.Windows[0].RootViewController = new TabViewController(); Can't use right now!! var alert = UIAlertController.Create("Success", "Registration successful", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } else { var alert = UIAlertController.Create("Something goes wrong", registrationResult.Item2, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } } catch (Exception ex) { var alert = UIAlertController.Create("Something goes wrong", String.Format("Please try again.{0} Details: {1}", Environment.NewLine, ex.Message), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); submitButton.Enabled = true; } } else { var alert = UIAlertController.Create("Error", valid.Item2, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Retry", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } submitButton.Enabled = true; }; View.AddGestureRecognizer(new UITapGestureRecognizer(() => { View.EndEditing(true); })); }
public override void DidMoveToView(SKView view) { Proto3Dim1 = 0; Proto3Dim2 = 0; Proto3Dim3 = 0; gameMode = 0; hueTop = 0; hueBel = 0; satTop = 0; satBel = 0; briTop = 0.3f; briBel = 0.6f; GenerateSprites(); // Generate Label 1 navLabelTop = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "Wie fühlst du dich?", FontSize = 20, Position = new CGPoint(Frame.Width / 2, (Frame.Height / 2) + 20) }; navLabelTop.FontColor = UIColor.FromHSB(0, 0, 3f); navLabelTop.Alpha = 0.9f; navLabelTop.ZPosition = 2; AddChild(navLabelTop); // Generate Label 2 navLabelBottom = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "Wie möchtest du dich fühlen?", FontSize = 20, Position = new CGPoint(Frame.Width / 2, (Frame.Height / 2) - 40) }; navLabelBottom.FontColor = UIColor.FromHSB(0, 0, 6f); navLabelBottom.ZPosition = 2; navLabelBottom.Alpha = 0.9f; AddChild(navLabelBottom); // Cover the labels with a sprite node for better navigation covering of touch navSpriteTop = new SKSpriteNode(); navSpriteTop.Name = "navSpriteTop"; navSpriteTop.Alpha = 0.0000001f; navSpriteTop.ZPosition = 1.1f; navSpriteTop.Color = UIColor.FromHSB(0, 1, 0.0f); navSpriteTop.Size = new CGSize(Frame.Width, 70); navSpriteTop.Position = new CGPoint((View.Frame.Width / 2), (View.Frame.Height / 2 + (35))); AddChild(navSpriteTop); // Cover the labels with a sprite node for better navigation covering of touch navSpriteBottom = new SKSpriteNode(); navSpriteBottom.Name = "navSpriteBottom"; navSpriteBottom.Alpha = 0.0000001f; navSpriteBottom.ZPosition = 1.1f; navSpriteBottom.Color = UIColor.FromHSB(1, 0, 0.0f); navSpriteBottom.Size = new CGSize(Frame.Width, 70); navSpriteBottom.Position = new CGPoint((View.Frame.Width / 2), (View.Frame.Height / 2 - (35))); AddChild(navSpriteBottom); // No Drag, no Action, used to block different actions at the same time // Start used is active until touch from menu is released startDragMenu = false; actionStarted = false; }
private void SetInfoText() { int tempFontSize = 18; int tempInfoSize = 40; int tempInfoPos = 40; // Check which iOS device, change infobox text and size if (UIScreen.MainScreen.Bounds.Width < 375) { tempFontSize = 16; tempInfoSize = 20; tempInfoPos = 30; } // Define and add Label 1 infoLabel1 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "Hier kannst du deine Emotion erfassen", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10) }; infoLabel1.Alpha = 0.0f; infoLabel1.Name = "infoLabel"; infoLabel1.ZPosition = 100; AddChild(infoLabel1); // Define and add Label 2 infoLabel2 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "suche eine passende Farbe", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20) }; infoLabel2.Alpha = 0.0f; infoLabel2.Name = "infoLabel"; infoLabel2.ZPosition = 100; AddChild(infoLabel2); // Define and add Label 3 infoLabel3 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "Berühre den Bildschirm", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10) }; infoLabel3.Alpha = 0.0f; infoLabel3.ZPosition = 100; infoLabel3.Name = "infoLabel"; AddChild(infoLabel3); // Define and add Label 4 infoLabel4 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "und navigiere die Punkte", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20) }; infoLabel4.Alpha = 0.0f; infoLabel4.ZPosition = 100; infoLabel4.Name = "infoLabel"; AddChild(infoLabel4); // Define and add Label 5 infoLabel5 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "so dass diese schlussendlich", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10) }; infoLabel5.Alpha = 0.0f; infoLabel5.ZPosition = 100; infoLabel5.Name = "infoLabel"; AddChild(infoLabel5); // Define and add Label 6 infoLabel6 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "deiner aktuellen Gefühlslage entsprechen", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20) }; infoLabel6.Alpha = 0.0f; infoLabel6.Name = "infoLabel"; infoLabel6.ZPosition = 100; AddChild(infoLabel6); // Define and add Label 7 infoLabel7 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "wenn du die Punkte lange drückst", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 10) }; infoLabel7.Alpha = 0.0f; infoLabel7.ZPosition = 100; infoLabel7.Name = "infoLabel"; AddChild(infoLabel7); // Define and add Label 8 infoLabel8 = new SKLabelNode("AppleSDGothicNeo-UltraLight") { Text = "kannst du diese verändern", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 - 20) }; infoLabel8.Alpha = 0.0f; infoLabel8.Name = "infoLabel"; infoLabel8.ZPosition = 100; AddChild(infoLabel8); // Define and add Label 9 infoLabel9 = new SKLabelNode("AppleSDGothicNeo-Bold") { Text = "TEATIME", FontSize = tempFontSize, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 60) }; infoLabel9.Alpha = 0.0f; infoLabel9.Name = "infoLabel"; infoLabel9.ZPosition = 100; AddChild(infoLabel9); // Do Actions on the Label Nodes (wait, fade in, wait, fade out) DoActionSequenceOnNode(infoLabel1, 1, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel2, 2, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel3, 6, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel4, 7, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel5, 11, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel6, 12, 1, 2, 1, 0.8f); DoActionSequenceOnNode(infoLabel7, 16, 1, 2, 1, 0.7f); DoActionSequenceOnNode(infoLabel8, 17, 1, 2, 1, 0.7f); DoActionSequenceOnNode(infoLabel9, 0, 1, 20, 1, 0.7f); // Define and add Info Box rect infoNode = new SKSpriteNode(); infoNode.Size = new CGSize(Frame.Width, Frame.Height); infoNode.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2); infoNode.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode.ZPosition = 99; infoNode.Name = "infoNode"; infoNode.Alpha = 0.0f; AddChild(infoNode); // Define and add Info Box rect 2 infoNode2 = new SKSpriteNode(); infoNode2.Size = new CGSize(Frame.Width - 60, 130); infoNode2.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 25); infoNode2.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode2.ZPosition = 98; infoNode2.Name = "infoNode"; infoNode2.Alpha = 0.0f; AddChild(infoNode2); // Define and add Info Box rect 3 infoNode3 = new SKSpriteNode(); infoNode3.Size = new CGSize(Frame.Width - tempInfoSize, 130); infoNode3.Position = new CGPoint(Frame.Width / 2, Frame.Height / 2 + 25); infoNode3.Color = UIColor.FromHSB(0, 0, 0.3f); infoNode3.ZPosition = 98; infoNode3.Name = "infoNode"; infoNode3.Alpha = 0.0f; AddChild(infoNode3); // Define and add Cancel Icon for the Info Box cancelSpark = new SKSpriteNode("sparkx"); cancelSpark.Name = "cancelSpark"; cancelSpark.ZPosition = 1000; cancelSpark.Alpha = 0.0f; cancelSpark.SetScale(0.6f); cancelSpark.Color = UIColor.FromHSB(0, 0, 0.0f); cancelSpark.Position = new CGPoint((View.Frame.Width - (tempInfoPos)), (View.Frame.Height / 2 + (70))); AddChild(cancelSpark); // Define and add Teatime Icon for the Info Box teatimeSprite = new SKSpriteNode("*****@*****.**"); teatimeSprite.Name = "infoNode"; teatimeSprite.ZPosition = 1000; teatimeSprite.Alpha = 0.0f; teatimeSprite.SetScale(0.35f); teatimeSprite.Color = UIColor.FromHSB(0, 0, 0.0f); teatimeSprite.Position = new CGPoint((0 + (tempInfoPos)), (View.Frame.Height / 2 + (70))); AddChild(teatimeSprite); // Actions and Sequence for Info Nodes DoActionSequenceOnNode(infoNode, 0, 1, 20, 1, 0.3f); DoActionSequenceOnNode(infoNode3, 0, 1, 20, 1, 0.3f); DoActionSequenceOnNode(cancelSpark, 0, 1, 20, 1, 0.3f); DoActionSequenceOnNode(teatimeSprite, 0, 1, 20, 1, 0.3f); }