コード例 #1
0
        private void addEditor()
        {
            Editor = new BrutallyKillableTextBox(delegate { deactivate(); editor.invalidateView(); });
//            Editor = new RichTextBox();
            ViewParameters p = editor.CurrentViewParameters;
            Rectangle      r = ShapeView.getShapeRectangle(Handles["start"], Handles["end"], p);

            Editor.Location    = new Point(r.Location.X + p.Scrolls.X, r.Location.Y + p.Scrolls.Y);
            Editor.Size        = r.Size;
            Editor.BorderStyle = BorderStyle.None;
            Editor.ScrollBars  = RichTextBoxScrollBars.None;
            Editor.DetectUrls  = false;
            Editor.Font        = new Font(sp.buttonFont.Font.FontFamily, REL_SIZE * ShapeView.scaledThickness(this, p),
                                          sp.buttonFont.Font.Style, GraphicsUnit.Pixel, 0);
            Editor.ForeColor     = editorColor;
            Editor.BackColor     = getPerceivedBrightness(editorColor) > 0x80 ? Color.DarkGray : Color.LightGray;
            Editor.HideSelection = false;
            // bug #52 - max length of the text input no longer makes sense for multi-line editors
//            Editor.MaxLength = 100;

            Editor.Multiline  = true;
            Editor.AcceptsTab = true;
            Editor.WordWrap   = false;

            Editor.Name     = "editor";
            Editor.TabIndex = 0;
            Editor.TabStop  = false;
            Editor.Text     = Text ?? "";
            Editor.Anchor   = AnchorStyles.None;
            editor.addControl(Editor);

            TextView v = (TextView)getView();

            v.setTextChangeHandler(Editor);
        }
コード例 #2
0
    public void Apply()
    {
        CVShape.IData data = null;
        switch (ShapeView.CurState)
        {
        case CVShape.State.DivideLine:
            var firstField  = divideMenu.transform.Find("FirstPart").GetComponent <InputField>();
            var secondField = divideMenu.transform.Find("SecondPart").GetComponent <InputField>();
            try {
                float first  = (float)Convert.ToInt32(firstField.text);
                float second = (float)Convert.ToInt32(secondField.text);
                data = new CVShape.LineDividingData(first / (first + second));
            } catch (FormatException) {
                firstField.text = secondField.text = "";
                return;
            }
            break;

        case CVShape.State.SetAngle:
            var angleValueField = angleMenu.transform.Find("AngleValue").GetComponent <InputField>();
            int result          = 0;
            if (!int.TryParse(angleValueField.text, out result))
            {
                return;
            }
            data = new CVShape.AngleSettingData(result);
            break;
        }
        ShapeView.Apply(data);
    }
コード例 #3
0
        public MyPage()
        {
            Label l = new Label()
            {
                Text = "Press the icon", VerticalOptions = LayoutOptions.Center, FontSize = 40
            };

            IconImage iconImage = new IconImage()
            {
                IconColor = Color.White, IconSize = 40, VerticalOptions = LayoutOptions.Center
            };

            iconImage.Icon = Iconize.FindIconForKey("ion-information").Key;


            var circle = new ShapeView
            {
                ShapeType       = ShapeType.Circle,
                HeightRequest   = 50,
                WidthRequest    = 50,
                Color           = Color.Green,
                VerticalOptions = LayoutOptions.Center,
                CornerRadius    = 5,
                BorderColor     = Color.Red,
                BorderWidth     = 1f,
                Content         = iconImage
            };

            StackLayout sl = new StackLayout()
            {
                VerticalOptions = LayoutOptions.Center, Orientation = StackOrientation.Horizontal, Children = { l, circle }, Margin = new Thickness(0, 20, 0, 0)
            };

            Content = sl;
        }
コード例 #4
0
        ShapeView CreateBackgroundCircleShape()
        {
            ShapeView BackgroundCircleShape = new ShapeView()
            {
                ShapeType   = ShapeType.Circle,
                BorderWidth = 0,
                BorderColor = Color.Transparent,
            };

            DataTrigger BackgroundCircleShapeSelectedTrigger = new DataTrigger(typeof(ShapeView))
            {
                Value   = true,
                Binding = new Binding()
                {
                    Source = DataContext,
                    Path   = "IsSelected"
                },
            };

            BackgroundCircleShapeSelectedTrigger.Setters.Add(new Setter()
            {
                Property = ShapeView.ColorProperty,
                Value    = new Binding()
                {
                    Source = DataContext, Path = "CalendarHighlightColor"
                },
            });

            BackgroundCircleShape.Triggers.Add(BackgroundCircleShapeSelectedTrigger);

            return(BackgroundCircleShape);
        }
コード例 #5
0
        private void GenerateShape(bool[,] shape, ShapeView shapeView, Color shapeColor)
        {
            var height = shape.GetLength(0);
            var width  = shape.GetLength(1);

            var blockViews = new IBlockView[height, width];

            shapeView.Shape = shape;

            for (var i = 0; i < height; i++)
            {
                for (var j = 0; j < width; j++)
                {
                    if (shape[i, j])
                    {
                        var blockView = BlockPool.Pop();
                        blockView.SetParent(shapeView.BlockContainer);
                        blockView.SetLocalPosition(new Vector3(j - width / 2f + 0.5f, height / 2f - i - 0.5f));
                        blockViews[i, j] = blockView;
                        blockView.SetColor(shapeColor);
                    }
                }
            }
            shapeView.BlockViews = blockViews;
            shapeView.MininimazeScale();
        }
コード例 #6
0
ファイル: Shape.cs プロジェクト: iphoneusermobile/mazio
 public ShapeView getView()
 {
     if (view == null)
     {
         view = createView();
     }
     return(view);
 }
コード例 #7
0
        public Shape(float density, Context context, ShapeView shapeView) : base(context)
        {
            if (shapeView == null)
            {
                throw new ArgumentNullException(nameof(shapeView));
            }

            this._density   = density;
            this._shapeView = shapeView;
        }
コード例 #8
0
        private void UpdateView(BasePageableItem item, bool selected, ShapeView view)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var style = item.CustomPagerStyle ?? this.PagerStyle;
            var color = selected ? item.CustomSelectedColor ?? this.CustomSelectedColor ?? Color.White : item.CustomUnselectedColor ?? this.CustomUnselectedColor ?? Color.FromRgba(1, 1, 1, 0.5);
            var size  = this.GetApplicableSize(item, style);

            view.Color         = color;
            view.HeightRequest = size.Height;
            view.WidthRequest  = size.Width;
            view.ClassId       = selected.ToString();

            switch (style)
            {
            case PagerStyle.Rectangle:
            case PagerStyle.Square:
                view.ShapeType = ShapeType.Box;
                break;

            case PagerStyle.RoundedRectangle:
            case PagerStyle.RoundedSquare:
                view.CornerRadius = (float)(size.Height + size.Width) / 10f;
                break;

            case PagerStyle.Star:
                view.ShapeType = ShapeType.Star;
                break;

            case PagerStyle.Triangle:
                view.ShapeType = ShapeType.Triangle;
                break;

            case PagerStyle.Oval:
                view.ShapeType = ShapeType.Oval;
                break;

            case PagerStyle.Diamond:
                view.ShapeType = ShapeType.Diamond;
                break;

            case PagerStyle.Heart:
                view.ShapeType = ShapeType.Heart;
                break;

            case PagerStyle.Circle:
            default:
                view.ShapeType = ShapeType.Circle;
                break;
            }
        }
コード例 #9
0
    private void Start()
    {
        _scoreTitle = _scoreText.text;
        UpdateScore();

        _gameRunning = true;

        _boardView = GetComponent <BoardView>();
        _board     = new Board(_boardView.Rows, _boardView.Columns);

        _shapeView = GetComponent <ShapeView>();

        _shape = SpawnShape(_gameSettings.ShapeStartSpeed);
    }
コード例 #10
0
ファイル: GameManager.cs プロジェクト: Stexxe/TetrisUnity
    void Start()
    {
        settings = GetComponent <GameSettings>();

        scoreTitle = Score.text;
        UpdateScore();

        gameRunning = true;

        boardView = GetComponent <BoardView>();
        board     = new Board(boardView.Rows, boardView.Columns);

        shapeView = GetComponent <ShapeView>();

        shape = SpawnShape(settings.ShapeStartSpeed);
    }
コード例 #11
0
        private View ListItemView(string text)
        {
            var padding = (Sizes.TextSmall / 2) - 1;
            var circle  = new ShapeView()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                ShapeType         = ShapeType.Circle,
                Color             = Color.Black,
                HeightRequest     = Sizes.TextSmall - padding,
                WidthRequest      = Sizes.TextSmall - padding,
                Margin            = new Thickness(0, padding, 0, 0),
            };

            var lblText = new Label()
            {
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalOptions         = LayoutOptions.Start,
                TextColor = Colors.TextInverted,
                FontSize  = Sizes.TextSmall,
                Text      = text,
            };

            return(new Grid()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Start,
                ColumnSpacing = 10,
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition()
                    {
                        Width = GridLength.Star
                    },
                },
                Children =
                {
                    { circle,  0, 0 },
                    { lblText, 1, 0 },
                }
            });
        }
コード例 #12
0
        private ShapeView GetApplicableView(BasePageableItem item, bool selected)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var result = new ShapeView
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center
            };

            this.UpdateView(item, selected, result);

            return(result);
        }
コード例 #13
0
ファイル: AchievementDetailView.cs プロジェクト: hdir/ga10
        private View HealthBoxContainer(View content)
        {
            const int heartIconSize = 40;

            var heartIcon = new SvgCachedImage
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -heartIconSize / 2f, 0, 0),
                HeightRequest     = heartIconSize,
                WidthRequest      = heartIconSize,
                Source            = Images.HealthHeart,
            };

            heartIcon.SetBinding(IsVisibleProperty, nameof(AchievementViewModel.HasBeenAchieved));

            var roundedBottom = new ShapeView()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Color             = Colors.AchievementHealthBackground,
                CornerRadius      = Sizes.CornerRadius,
                HeightRequest     = Sizes.CornerRadius * 2f,
                Margin            = new Thickness(0, 0, 0, -Sizes.CornerRadius),
            };

            var contentContainer = new ShapeView()
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Colors.AchievementHealthBackground,
                Content           = content,
            };

            return(new Grid()
            {
                RowSpacing = 0,
                Children =
                {
                    roundedBottom,
                    contentContainer,
                    heartIcon,
                }
            });
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public void Add_Outer_Border(RelativeLayout layout)
        {
            ShapeView outerPanel = new ShapeView
            {
                ShapeType    = ShapeType.Box,
                StrokeColor  = Color.LightGray,
                StrokeWidth  = 1,
                CornerRadius = 3
            };

            layout.Children.Add(outerPanel, Constraint.Constant(20), Constraint.Constant(20), Constraint.RelativeToParent((p) =>
            {
                return(p.Width - 40);
            }), Constraint.RelativeToParent((p) =>
            {
                return(p.Height - 40);
            }));
        }
コード例 #16
0
ファイル: SortTaskFactory.cs プロジェクト: yuva2achieve/dot42
        private List <ShapeView> ParseXml(Context context)
        {
            var s = new ShapeView(context, ShapeView.ShapeEnum.RectangleShape, 100, 100, Color.DKGRAY);
            //var d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") };
            //s.SetOnDragListener(d);
            //s.SetOnLongClickListener(d);
            //s.SetOnTouchListener(d);
            //s.SetLayoutParams(p);
            //result.Add(s);

            //List<ShapeView> shapeList = new List<ShapeView>();

            List <ShapeView> shapeList =
                (
                    from e in XDocument.Parse(strXml).Root.Elements("Shape")
                    select new ShapeView(context)
            {
                Shape = (ShapeView.ShapeEnum)Enum.Parse(typeof(ShapeView.ShapeEnum), (string)e.Element("shapeType").ToString()),
                Color = int.Parse(e.Element("color").ToString()),
                ShapeWidth = int.Parse(e.Element("width").ToString()),
                ShapeHeight = int.Parse(e.Element("heigth").ToString())
                              //EmployeeID = (int)e.Element("id"),
                              //EmployeeName = (string)e.Element("name"),
                              //EmployeePosition = (string)e.Element("position"),
                              //EmployeeCountry = (string)e.Element("country"),
                              //Projects =
                              //(
                              //    from p in e.Elements("projects").Elements("project")
                              //    select new Project
                              //    {
                              //      ProjectCode = (string)p.Element("code"),
                              //      ProjectBudget = (int)p.Element("budget")
                              //    }).ToArray()
            }).ToList();


            return(shapeList);
        }
コード例 #17
0
ファイル: OnboardingPage.cs プロジェクト: hdir/ga10
        private View Indicator(int pageNumber)
        {
            const int size = 6;

            var bg = new ShapeView()
            {
                HeightRequest = size,
                WidthRequest  = size,
                Margin        = .5,
                ShapeType     = ShapeType.Circle,
                Color         = Colors.Border,
            };

            var fg = new ShapeView()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = size,
                WidthRequest      = size,
                ShapeType         = ShapeType.Circle,
                Color             = Colors.TextSpecial,
            };

            fg.SetBinding(IsVisibleProperty, nameof(ViewModel.CarouselPosition),
                          BindingMode.OneWay, new IntToBooleanConverter(pageNumber));

            return(new Grid()
            {
                HeightRequest = size,
                WidthRequest = size,
                Children =
                {
                    { bg, 0, 0 },
                    { fg, 0, 0 }
                }
            });
        }
コード例 #18
0
 static void BuildCard(CardViewModel card)
 {
     var box = new ShapeView
     {
         //ShapeType = ShapeType.Box,
         //HeightRequest = 75,
         //WidthRequest = 75,
         //Color = Color.Navy,
         //HorizontalOptions = LayoutOptions.Center,
         //CornerRadius = 5,
         //BorderColor = Color.Red,
         //BorderWidth = 1f,
         //Content = new Label
         //{
         //    Text = "Touch me!",
         //    FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
         //    TextColor = Color.White,
         //    HorizontalOptions = LayoutOptions.Fill,
         //    VerticalOptions = LayoutOptions.Fill,
         //    VerticalTextAlignment = TextAlignment.Center,
         //    HorizontalTextAlignment = TextAlignment.Center,
         //},
     };
 }
コード例 #19
0
        public override HomeViewModel Return_Model()
        {
            RelativeLayout relativeLayout = new RelativeLayout();

            Label pageLayout = new Label
            {
                Text = "Profile",
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize       = 20,
                FontAttributes = FontAttributes.Bold,
                Opacity        = 0.8,
                TextColor      = Color.LightBlue,
            };

            relativeLayout.Children.Add(pageLayout, Constraint.Constant(0), Constraint.Constant(25),
                                        Constraint.RelativeToParent((p) =>
            {
                return(p.Width);
            }), Constraint.Constant(30));

            Add_Outer_Border(relativeLayout);

            ShapeView profileBorder = new ShapeView()
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightBlue,
                StrokeWidth = 1,
            };
            ShapeView profileAccent = new ShapeView()
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightGray,
                StrokeWidth = 1
            };

            relativeLayout.Children.Add(profileAccent, Constraint.Constant(26), Constraint.Constant(62), Constraint.Constant(128), Constraint.Constant(128));
            relativeLayout.Children.Add(profileAccent, Constraint.Constant(25), Constraint.Constant(61), Constraint.Constant(128), Constraint.Constant(128));
            relativeLayout.Children.Add(profileBorder, Constraint.Constant(24), Constraint.Constant(60), Constraint.Constant(128), Constraint.Constant(128));

            StackLayout profileInfoLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.Center
            };

            Label playerNameLabel = new Label
            {
                Text           = TextUtil.FirstLetterToUpperCase((string)Get_Player_Dict()["name"]),
                TextColor      = Color.LightSkyBlue,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 16,
            };

            profileInfoLayout.Children.Add(playerNameLabel);

            StackLayout notorietyLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };
            Label notorietyLevel = new Label
            {
                Text           = "notoriety",
                TextColor      = Color.LightGray,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 14,
            };
            Label notorietyValue = new Label
            {
                Text           = Get_Player_Dict()["level"].ToString(),
                TextColor      = Color.LightSkyBlue,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 16
            };

            notorietyLayout.Children.Add(notorietyLevel);
            notorietyLayout.Children.Add(notorietyValue);
            profileInfoLayout.Children.Add(notorietyLayout);

            StackLayout iiqLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal
            };
            Label iiqTitle = new Label
            {
                Text           = "iiq",
                TextColor      = Color.LightGray,
                FontAttributes = FontAttributes.None,
                FontSize       = 14
            };
            Label iiqValue = new Label
            {
                Text           = Get_Player_Dict()["iiq"].ToString(),
                TextColor      = Color.LightSkyBlue,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 16
            };

            iiqLayout.Children.Add(iiqTitle);
            iiqLayout.Children.Add(iiqValue);
            profileInfoLayout.Children.Add(iiqLayout);

            StackLayout gramsLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
            };
            Label gramsTitle = new Label()
            {
                Text           = "grams",
                TextColor      = Color.LightGray,
                FontAttributes = FontAttributes.None,
                FontSize       = 14
            };

            Label gramsValue = new Label()
            {
                Text           = Get_Player_Dict()["grams"].ToString(),
                TextColor      = Color.LightSkyBlue,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 16,
            };

            gramsLayout.Children.Add(gramsTitle);
            gramsLayout.Children.Add(gramsValue);
            profileInfoLayout.Children.Add(gramsLayout);

            StackLayout scoinLayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
            };
            Label scoinTitle = new Label()
            {
                Text           = "star-coins",
                TextColor      = Color.LightGray,
                FontAttributes = FontAttributes.None,
                FontSize       = 14
            };
            Label scoinValue = new Label()
            {
                Text           = Get_Player_Dict()["scoins"].ToString(),
                TextColor      = Color.LightSkyBlue,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 16
            };

            scoinLayout.Children.Add(scoinTitle);
            scoinLayout.Children.Add(scoinValue);
            profileInfoLayout.Children.Add(scoinLayout);

            relativeLayout.Children.Add(profileInfoLayout, Constraint.Constant(26 + 128 + 10), Constraint.Constant(62), Constraint.RelativeToParent((p) => { return(p.Width - (26 + 128 + 10)); }), Constraint.Constant(128));

            StackLayout queueMatchLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.Center
            };

            queuePicker = new Picker()
            {
                SelectedIndex       = 0,
                HorizontalOptions   = LayoutOptions.StartAndExpand,
                MinimumWidthRequest = 150,
                WidthRequest        = 150
            };
            Add_Items_For_Queue(queuePicker);
            queueMatchLayout.Children.Add(queuePicker);

            Button doQueue = new Button()
            {
                Text            = "Queue",
                BackgroundColor = Color.WhiteSmoke,
                BorderColor     = Color.PowderBlue,
                TextColor       = Color.DimGray,
                BorderWidth     = (Double)1.5,
                BorderRadius    = 5,
                Font            = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            doQueue.Clicked += (sender, e) =>
            {
                App.Get_Data_Store().Store("queue_for", queuePicker.SelectedItem.ToString());

                App.GetNavigation().PushAsync
                    (new Function.QueueExperience());
                return;
            };
            queueMatchLayout.Children.Add(doQueue);

            relativeLayout.Children.Add(queueMatchLayout, Constraint.Constant(26), Constraint.RelativeToParent((p) =>
            {
                return(p.Height / 2);
            }), Constraint.RelativeToParent((p) =>
            {
                return(p.Width - 40);
            }), Constraint.Constant(40));

            return(new HomeViewModel
            {
                Background = Color.WhiteSmoke,
                ImageSource = "Isogramd.Images.Cursor.png",                  // The tab icon
                Content = relativeLayout,
                TabText = "Profile"
            });
        }
コード例 #20
0
        private View LockedView(float iconSize, out View statusIcon)
        {
            statusIcon = new ShapeView()
            {
                ShapeType     = ShapeType.Circle,
                WidthRequest  = iconSize,
                HeightRequest = iconSize,
                BorderColor   = Color.FromHex("#9ca5a6"),
                Color         = Colors.Background,
                BorderWidth   = 1,
                Content       = new SvgCachedImage()
                {
                    Source = Images.AchievementProgressLocked,
                    Aspect = Aspect.AspectFit,
                }
            };

            var previousTier = new Span()
            {
                TextColor  = Colors.TextFaded,
                FontSize   = Sizes.TextMicro,
                FontFamily = Fonts.Normal,
            };

            previousTier.SetBinding(Span.TextProperty, nameof(AchievementTierProgressViewModel.Tier),
                                    converter: new TierToNameConverter(-1, true));

            var currentTier = new Span()
            {
                TextColor  = Colors.TextFaded,
                FontSize   = Sizes.TextMicro,
                FontFamily = Fonts.Normal,
            };

            currentTier.SetBinding(Span.TextProperty, nameof(AchievementTierProgressViewModel.Tier),
                                   converter: new TierToNameConverter(toLower: true));

            var receivedText = new FormattedString()
            {
                Spans =
                {
                    new Span()
                    {
                        Text       = "Du må klare ",
                        TextColor  = Colors.TextFaded,
                        FontSize   = Sizes.TextMicro,
                        FontFamily = Fonts.Normal,
                    },
                    previousTier,
                    new Span()
                    {
                        Text       = " før du kan starte på ",
                        TextColor  = Colors.TextFaded,
                        FontSize   = Sizes.TextMicro,
                        FontFamily = Fonts.Normal,
                    },
                    currentTier,
                }
            };

            return(new StackLayout()
            {
                Spacing = 10,
                Children =
                {
                    statusIcon,
                    new Label()
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        FormattedText = receivedText,
                    },
                }
            });
        }
コード例 #21
0
        private View CompletedView(float iconSize, out View statusIcon)
        {
            var receivedDateSpan = new Span()
            {
                TextColor  = Colors.TextFaded,
                FontSize   = Sizes.TextMicro,
                FontFamily = Fonts.Normal,
            };

            receivedDateSpan.SetBinding(Span.TextProperty,
                                        nameof(AchievementTierProgressViewModel.DateCompleted),
                                        converter: new DateToStringConverter("dd.MM.yyyy"));

            var receivedText = new FormattedString()
            {
                Spans =
                {
                    new Span()
                    {
                        Text       = AppText.achievement_time_received + " ",
                        TextColor  = Colors.TextFaded,
                        FontSize   = Sizes.TextMicro,
                        FontFamily = Fonts.Normal,
                    },
                    receivedDateSpan
                }
            };

            statusIcon = new ShapeView()
            {
                WidthRequest  = iconSize,
                HeightRequest = iconSize,
                ShapeType     = ShapeType.Circle,
                Content       = new SvgCachedImage()
                {
                    Source           = Images.AchievementProgressCheckmark,
                    ReplaceStringMap = new Dictionary <string, string>()
                    {
                        { "#FF5737", "#00000000" }
                    },
                    Margin = 2,
                }
            };
            statusIcon.SetBinding(ShapeView.ColorProperty, nameof(AchievementTierProgressViewModel.Tier),
                                  converter: new TierToColorConverter());

            var lblCompleted = new Label()
            {
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                Margin         = new Thickness(40, 0),
                TextColor      = Colors.Text,
                FontSize       = Sizes.TextSmall,
                FontAttributes = FontAttributes.Bold,
                LineHeight     = 1.3,
            };

            lblCompleted.SetBinding(Label.TextProperty, nameof(AchievementTierProgressViewModel.UnlockedText));

            return(new StackLayout()
            {
                Spacing = 20,
                Children =
                {
                    statusIcon,
                    new Label()
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        FormattedText = receivedText,
                    },
                    new BorderCanvasView()
                    {
                        BorderColor = Colors.Border,
                        Margin = new Thickness(0,   3, 0, 0),
                        Border = new Thickness(0,   1, 0, 0),
                        HeightRequest = 15,
                    },
                    lblCompleted,
                }
            });
        }
コード例 #22
0
        private View DescriptionView()
        {
            var icon = new SvgCachedImage()
            {
                HeightRequest        = 130,
                Aspect               = Aspect.AspectFit,
                FadeAnimationEnabled = false,
            };

            icon.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.Icon));
            icon.SetBinding(SvgCachedImage.ReplaceStringMapProperty, nameof(ViewModel.Tier),
                            converter: new TierToReplacementStringMapConverter());

            var lblCongratulations = new Label()
            {
                VerticalOptions         = LayoutOptions.Center,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor      = Colors.Text,
                FontSize       = Sizes.TextSmall,
                FontAttributes = FontAttributes.Bold,
                LineHeight     = 1.2,
                Text           = $"Gratulerer {Settings.UserName}!",
            };

            lblCongratulations.SetBinding(IsVisibleProperty, nameof(ViewModel.IsCompleted));

            var lblDescription = new Label()
            {
                VerticalOptions         = LayoutOptions.Center,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor  = Colors.Text,
                FontSize   = Sizes.TextSmall,
                LineHeight = 1.2,
            };

            lblDescription.SetBinding(Label.TextProperty, nameof(ViewModel.Description));
            lblDescription.SetBinding(IsVisibleProperty, nameof(ViewModel.IsCompleted),
                                      converter: new InvertedBooleanConverter());

            var lblDescriptionCompleted = new Label()
            {
                VerticalOptions         = LayoutOptions.Center,
                HorizontalOptions       = LayoutOptions.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor  = Colors.Text,
                FontSize   = Sizes.TextSmall,
                LineHeight = 1.2,
            };

            lblDescriptionCompleted.SetBinding(Label.TextProperty, nameof(ViewModel.CompletedDescription));
            lblDescriptionCompleted.SetBinding(IsVisibleProperty, nameof(ViewModel.IsCompleted));

            var lblContainer = new ShapeView()
            {
                CornerRadius = Sizes.CornerRadius,
                BorderWidth  = 1,
                BorderColor  = Colors.Border,
                Color        = Colors.AchievementDescriptionBackground,
                Content      = new StackLayout()
                {
                    Spacing  = 20,
                    Margin   = new Thickness(30, 70, 30, 50),
                    Children =
                    {
                        lblCongratulations,
                        lblDescription,
                        lblDescriptionCompleted,
                    }
                },
                Margin = new Thickness(10, 0),
            };

            return(new Grid()
            {
                RowSpacing = -50,
                RowDefinitions = new RowDefinitionCollection()
                {
                    new RowDefinition()
                    {
                        Height = GridLength.Auto
                    },
                    new RowDefinition()
                    {
                        Height = GridLength.Auto
                    },
                },
                Children =
                {
                    { lblContainer, 0, 1 },
                    { icon,         0, 0 },
                }
            });
        }
コード例 #23
0
        private async Task Finalize_Queue()
        {
            var currentPosY = 200;
            // Get the relevant information from the data store. This should have been filled out
            // While we were waiting for a queue.
            string pid     = (string)App.Get_Data_Store().Fetch("pid");
            string server  = (string)App.Get_Data_Store().Fetch("server");
            string game_id = (string)App.Get_Data_Store().Fetch("game_id");
            //Fetch any pregame elements that need-be filled out
            Dictionary <string, object> elements = await Get_Pregame(server, pid, game_id);

            // Pregame layout
            StackLayout pregameLayout = new StackLayout()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            //Add a black screen over the page for pregame information. If none is needed, then continue on.
            StackLayout blackScreen = new StackLayout
            {
                BackgroundColor = Color.Black,
                Opacity         = 0.4,
            };

            ((RelativeLayout)this.Content).Children.Add(blackScreen, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.RelativeToParent((p) => { return(p.Height); }));

            if (elements.Count == 0)
            {
                //There is no needed pre-game. Continue on as if there isn't one.
                await App.GetNavigation().PushAsync(new Isogramd.Function.GameIntroExperience());

                return;
            }

            foreach (KeyValuePair <string, object> entry in elements)
            {
                string key = entry.Key;
                Dictionary <string, object> element_json = (Dictionary <string, object>)entry.Value;

                // Get information about this type of pre-game item.
                string title       = (string)element_json["title"];
                string description = (string)element_json["description"];
                string type        = (string)element_json["type"];
                Dictionary <string, object> attributes = (Dictionary <string, object>)element_json["attributes"];

                /*
                 * "attributes": {
                 * "length": 1,
                 * "allowed_char_types": ["Integer"],
                 * "allowed_values": game_util.range_inclusive(3,11)
                 * }
                 */

                StackLayout labelLayout = new StackLayout()
                {
                    Padding     = 10,
                    Orientation = StackOrientation.Vertical
                };

                Label desc = new Label
                {
                    Text              = description,
                    FontSize          = 18,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                labelLayout.Children.Add(desc);

                pregameLayout.Children.Add(labelLayout);

                switch (type)
                {
                case "text_field":
                    Entry item_entry = new Entry
                    {
                        Placeholder             = "",
                        FontSize                = 24,
                        HorizontalTextAlignment = TextAlignment.Center,
                    };
                    if (attributes.ContainsKey("length"))
                    {
                        //Add a length listener
                        item_entry.TextChanged += (sender, args) =>
                        {
                            string _text        = item_entry.Text;
                            string lengthString = attributes["length"].ToString();
                            int    lengthValue  = int.Parse(lengthString);
                            if (_text.Length > lengthValue)
                            {
                                _text           = _text.Remove(_text.Length - 1);
                                item_entry.Text = _text;
                            }
                        };
                    }
                    if (attributes.ContainsKey("allowed_char_types"))
                    {
                        String typesAllowed = (string)attributes["allowed_char_types"];
                        if (typesAllowed.Equals("Integer"))
                        {
                            item_entry.Keyboard = Keyboard.Numeric;
                        }
                    }
                    if (attributes.ContainsKey("allowed_values"))
                    {
                        String   allowedValues = (string)attributes["allowed_values"];
                        String[] values        = allowedValues.Split(',');
                        item_entry.TextChanged += (sender, args) =>
                        {
                            string _text = item_entry.Text;

                            if (String.IsNullOrWhiteSpace(_text))
                            {
                                return;
                            }

                            Boolean found = false;
                            foreach (String val in values)
                            {
                                if (val.Equals(_text))
                                {
                                    found = true;
                                    break;
                                }
                            }
                            if (!found)
                            {
                                //We could not find a matching value
                                _text           = _text.Remove(_text.Length - 1);
                                item_entry.Text = _text;
                            }
                        };
                    }
                    pregameLayout.Children.Add(item_entry);
                    key_pregame_dict.Add(key, item_entry);
                    break;
                }
                currentPosY += 32;
            }

            StackLayout buttonLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Padding           = 10
            };

            Button clear_all = new Button
            {
                Text              = "Clear",
                BackgroundColor   = Color.WhiteSmoke,
                BorderColor       = Color.PowderBlue,
                TextColor         = Color.DimGray,
                BorderWidth       = (Double)1.5,
                BorderRadius      = 5,
                Font              = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            clear_all.Clicked += (sender, e) =>
            {
                foreach (KeyValuePair <string, View> entry in key_pregame_dict)
                {
                    View view = entry.Value;
                    if (view.GetType() == typeof(Entry))
                    {
                        Entry ef = (Entry)view;
                        ef.Text = "";
                    }
                    else if (view.GetType() == typeof(Picker))
                    {
                        Picker pick = (Picker)view;
                        pick.SelectedIndex = 0;
                    }
                }
            };
            buttonLayout.Children.Add(clear_all);

            Button send_all = new Button
            {
                Text              = "Send Pregame",
                BackgroundColor   = Color.WhiteSmoke,
                BorderColor       = Color.PowderBlue,
                TextColor         = Color.DimGray,
                BorderWidth       = (Double)1.5,
                BorderRadius      = 5,
                Font              = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
            };

            send_all.Clicked += (sender, e) =>
            {
                Dictionary <string, string> to_send = new Dictionary <string, string>();
                foreach (KeyValuePair <string, View> entry in key_pregame_dict)
                {
                    View view = entry.Value;
                    if (view.GetType() == typeof(Entry))
                    {
                        Entry ef = (Entry)view;
                        if (String.IsNullOrWhiteSpace(ef.Text))
                        {
                            //Don't send, but alert the player.
                            DisplayAlert("Oops!", "You haven't filled out a value", "Okay");
                            return;
                        }
                        to_send.Add(entry.Key, ef.Text);
                    }
                    else if (view.GetType() == typeof(Picker))
                    {
                        Picker pick = (Picker)view;
                        if (String.IsNullOrWhiteSpace(pick.SelectedItem.ToString()))
                        {
                            //Don't send, but alert the player.
                            DisplayAlert("Oops!", "You haven't filled out a value", "Okay");
                            return;
                        }
                        to_send.Add(entry.Key, pick.SelectedItem.ToString());
                    }
                }
                Send_Pregame(server, pid, game_id, to_send);
            };
            buttonLayout.Children.Add(send_all);

            pregameLayout.Children.Add(buttonLayout);

            StackLayout whiteScreen = new StackLayout
            {
                BackgroundColor = Color.White,
            };

            ((RelativeLayout)this.Content).Children.Add(whiteScreen, Constraint.Constant(19), Constraint.Constant(19), Constraint.RelativeToParent((p) => { return(p.Width - 38); }), Constraint.RelativeToParent((p) => { return(p.Height - 38); }));

            ShapeView outerPanel = new ShapeView
            {
                ShapeType    = ShapeType.Box,
                StrokeColor  = Color.Black,
                StrokeWidth  = 1,
                CornerRadius = 3
            };

            ((RelativeLayout)this.Content).Children.Add(outerPanel, Constraint.Constant(20), Constraint.Constant(20), Constraint.RelativeToParent((p) =>
            {
                return(p.Width - 40);
            }), Constraint.RelativeToParent((p) =>
            {
                return(p.Height - 40);
            }));

            ((RelativeLayout)this.Content).Children.Add(pregameLayout, Constraint.Constant(20), Constraint.Constant(20), Constraint.RelativeToParent((p) => { return(p.Width - 40); }), Constraint.RelativeToParent((p) => { return(p.Height - 40); }));

            this.ForceLayout();
        }
コード例 #24
0
 public void Back()
 {
     menuStack.Pop().SetActive(false);
     menuStack.Peek().SetActive(true);
     ShapeView.Abort();
 }
コード例 #25
0
 public ShapeController(Shape model, ShapeView view)
 {
     _model = model;
     _view  = view;
 }
コード例 #26
0
        /// <inheritdoc/>
        public override IDock CreateDefaultLayout()
        {
            // Dashboard

            var dashboardView = new DashboardView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Dashboard"
            };

            // Page

            var pageView = new PageView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Page"
            };

            // Left / Top

            var projectView = new ProjectView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Project"
            };

            var optionsView = new OptionsView
            {
                Dock   = "",
                Width  = 200,
                Height = 200,
                Title  = "Options"
            };

            var imagesView = new ImagesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Images"
            };

            // Left / Bottom

            var groupsView = new GroupsView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Groups"
            };

            var databasesView = new DatabasesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Databases"
            };

            // Right / Top

            var stylesView = new StylesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Styles"
            };

            var templatesView = new TemplatesView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Templates"
            };

            var containerView = new ContainerView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Container"
            };

            var zoomView = new ZoomView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Zoom"
            };

            // Right / Bottom

            var toolsView = new ToolsView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Tools"
            };

            var shapeView = new ShapeView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Shape"
            };

            var dataView = new DataView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Data"
            };

            var styleView = new StyleView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Style"
            };

            var templateView = new TemplateView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Template"
            };

            // Left

            var leftPane = new DockLayout
            {
                Dock        = "Left",
                Width       = 200,
                Height      = double.NaN,
                Title       = "EditorLeft",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    new DockStrip
                    {
                        Dock        = "Top",
                        Width       = double.NaN,
                        Height      = 340,
                        Title       = "EditorLeftTop",
                        CurrentView = projectView,
                        Views       = new ObservableCollection <IDock>
                        {
                            projectView,
                            optionsView,
                            imagesView
                        }
                    },
                    new DockSplitter()
                    {
                        Dock = "Top", Title = "LeftTopSplitter"
                    },
                    new DockStrip
                    {
                        Dock        = "Bottom",
                        Width       = double.NaN,
                        Height      = double.NaN,
                        Title       = "EditorLeftBottom",
                        CurrentView = groupsView,
                        Views       = new ObservableCollection <IDock>
                        {
                            groupsView,
                            databasesView
                        }
                    }
                }
            };

            // Right

            var rightPane = new DockLayout
            {
                Dock        = "Right",
                Width       = 240,
                Height      = double.NaN,
                Title       = "EditorRight",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    new DockStrip
                    {
                        Dock        = "Top",
                        Width       = double.NaN,
                        Height      = 340,
                        Title       = "EditorRightTop",
                        CurrentView = stylesView,
                        Views       = new ObservableCollection <IDock>
                        {
                            stylesView,
                            templatesView,
                            containerView,
                            zoomView
                        }
                    },
                    new DockSplitter()
                    {
                        Dock = "Top", Title = "RightTopSplitter"
                    },
                    new DockStrip
                    {
                        Dock        = "Bottom",
                        Width       = double.NaN,
                        Height      = double.NaN,
                        Title       = "EditorRightBottom",
                        CurrentView = toolsView,
                        Views       = new ObservableCollection <IDock>
                        {
                            toolsView,
                            shapeView,
                            dataView,
                            styleView,
                            templateView
                        }
                    }
                }
            };

            // Editor

            var editorLayout = new DockLayout
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "EditorLayout",
                CurrentView = null,
                Views       = new ObservableCollection <IDock>
                {
                    leftPane,
                    new DockSplitter()
                    {
                        Dock = "Left", Title = "LeftSplitter"
                    },
                    rightPane,
                    new DockSplitter()
                    {
                        Dock = "Right", Title = "RightSplitter"
                    },
                    pageView
                }
            };

            var editorView = new EditorView
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "Editor",
                CurrentView = editorLayout,
                Views       = new ObservableCollection <IDock>
                {
                    editorLayout
                }
            };

            // About

            var aboutView = new AboutView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "About"
            };

            // Browser

            var browserView = new BrowserView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Browser"
            };

            // Document

            var documentView = new DocumentView
            {
                Dock   = "",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Document"
            };

            // Main

            var layout = new DockRoot
            {
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                CurrentView = dashboardView,
                Views       = new ObservableCollection <IDock>
                {
                    dashboardView,
                    editorView,
                    aboutView,
                    browserView,
                    documentView
                }
            };

            return(layout);
        }
コード例 #27
0
ファイル: Gauge.cs プロジェクト: johnjore/Kala
        private static void Create_Gauge(Grid t_grid, int i, Models.Sitemap.Widget3 item, int x, int y)
        {
            try
            {
                Dictionary <string, string> widgetKeyValuePairs = Helpers.SplitCommand(item.Label);
                var digits = Digits(widgetKeyValuePairs, item.Item.State);

                #region Center unit
                t_grid.Children.Add(new Label
                {
                    Text              = widgetKeyValuePairs["unit"],
                    FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    TextColor         = App.Config.TextColor,
                    BackgroundColor   = App.Config.CellColor,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    TranslationY      = 5
                }, x, y);
                #endregion Center unit

                #region Image
                string strSource = widgetKeyValuePairs["icon"];

                t_grid.Children.Add(new Image
                {
                    Source            = strSource,
                    Aspect            = Aspect.AspectFill,
                    BackgroundColor   = App.Config.CellColor,
                    VerticalOptions   = LayoutOptions.End,
                    HorizontalOptions = LayoutOptions.Center
                }, x, y);
                #endregion Image

                #region Center Text / Value
                string s_value = "N/A";
                if (!(digits.Item1.ToLower().Equals("uninitialized")))
                {
                    s_value = digits.Item1;
                }

                ItemLabel l_value = new ItemLabel
                {
                    Text              = s_value,
                    FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    TextColor         = App.Config.TextColor,
                    BackgroundColor   = App.Config.CellColor,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    TranslationY      = -20,
                    Name              = item.Item.Name,
                    Digits            = digits.Item2
                };
                App.Config.Itemlabels.Add(l_value);
                t_grid.Children.Add(l_value, x, y);

                float.TryParse(widgetKeyValuePairs["min"].Replace(".", CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator), out float min);
                float.TryParse(widgetKeyValuePairs["max"].Replace(".", CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator), out float max);
                float.TryParse(digits.Item1.Replace(".", CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator), out float value);

                if (value > max)
                {
                    max = value;
                }
                if (value < min)
                {
                    min = value;
                }

                //Handle negative ranges
                if (min < 0)
                {
                    max   += Math.Abs(min);
                    value += Math.Abs(min);
                    min    = 0;
                }

                t_grid.Children.Add(new ShapeView()
                {
                    ShapeType           = ShapeType.Arc,
                    StrokeColor         = App.Config.BackGroundColor,
                    StrokeWidth         = 1.0f,
                    Scale               = 3.0,
                    Padding             = 1,
                    IndicatorPercentage = 100,
                    HorizontalOptions   = LayoutOptions.Center,
                    VerticalOptions     = LayoutOptions.Center
                }, x, y);

                ShapeView progressArc = new ShapeView
                {
                    ShapeType           = ShapeType.Arc,
                    StrokeColor         = App.Config.ValueColor,
                    StrokeWidth         = 1.0f,
                    Scale               = 3.0,
                    Padding             = 1,
                    IndicatorPercentage = ((value - min) / (max - min) * 100.0f),
                    HorizontalOptions   = LayoutOptions.Center,
                    VerticalOptions     = LayoutOptions.Center,
                    Name = item.Item.Name,
                    Min  = min,
                    Max  = max
                };
                App.Config.ItemShapeViews.Add(progressArc);
                t_grid.Children.Add(progressArc, x, y);
                #endregion Arc

                //Button must be last to be added to work
                Button dummyButton = new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Transparent,
                };
                t_grid.Children.Add(dummyButton, x, y);
                dummyButton.Clicked += OnDummyButtonClicked;
            }
            catch (Exception ex)
            {
                CrossLogger.Current.Error("Gauge", "Crashed: " + ex.ToString());
                Error(t_grid, i, 1, 1, 1, ex.ToString());
            }
        }
コード例 #28
0
        public TabbedGameExperience(TabbedGameExperience previousContext)
        {
            System.Diagnostics.Debug.WriteLine("Doing previous init");
            _indicatorStyle = CarouselLayout.IndicatorStyleEnum.Tabs;

            List <HomeViewModel> pages = CreatePages().Result;

            viewModel             = new SwitcherPageViewModel(pages);
            viewModel.CurrentPage = previousContext.Get_Current_Page(); //Line to duplicate current page selection.
            BindingContext        = viewModel;

            Title = _indicatorStyle.ToString();

            relativeLayout = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            System.Diagnostics.Debug.WriteLine("Pre-Carousel");
            var pagesCarousel = CreatePagesCarousel();

            System.Diagnostics.Debug.WriteLine("Post-Carousel");
            _tabs = CreateTabs();

            var tabsHeight   = 50;
            var offsetTabsUp = 15;

            relativeLayout.Children.Add(_tabs,
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight - offsetTabsUp); }),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.Constant(tabsHeight)
                                        );

            relativeLayout.Children.Add(pagesCarousel,
                                        Constraint.RelativeToParent((parent) => { return(parent.X); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Y); }),
                                        Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                                        Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height) - offsetTabsUp); })
                                        );

            ShapeView navigationBarBottom = new ShapeView
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightGray,
                StrokeWidth = 1
            };

            relativeLayout.Children.Add(navigationBarBottom, Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Height - offsetTabsUp + 1); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.Constant(1));

            ShapeView navigationBarTop = new ShapeView
            {
                ShapeType   = ShapeType.Box,
                StrokeColor = Color.LightGray,
                StrokeWidth = 1
            };

            relativeLayout.Children.Add(navigationBarTop, Constraint.Constant(0), Constraint.RelativeToParent((p) => { return(p.Height - offsetTabsUp - _tabs.Height - 1); }), Constraint.RelativeToParent((p) => { return(p.Width); }), Constraint.Constant(1));

            System.Diagnostics.Debug.WriteLine("Content loaded");
            this.Content = relativeLayout;
        }
コード例 #29
0
ファイル: SortTaskFactory.cs プロジェクト: yuva2achieve/dot42
        private List <View> CreateSortObjects(Context context, Text2Speech tts)
        {
            var result = new List <View>();

            var x = ParseXml(context);
            //var p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            //p.SetMargins(5, 5, 5, 5);

            //for (int i = 1; i < 15; ++i)
            //{
            //  var s = new TextView(context);
            //  s.SetText("View " + i.ToString());
            //  s.SetLayoutParams(p);
            //  result.Add(s);
            //}

            var s = new ShapeView(context, ShapeView.ShapeEnum.RectangleShape, 100, 100, Color.DKGRAY);
            //var d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") };
            //s.SetOnDragListener(d);
            //s.SetOnLongClickListener(d);
            //s.SetOnTouchListener(d);
            //s.SetLayoutParams(p);
            //result.Add(s);

            //s = new ShapeView(context, ShapeView.ShapeEnum.OvalShape, 100, 75, Color.WHITE);
            //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") };
            //s.SetOnDragListener(d);
            //s.SetOnLongClickListener(d);
            //s.SetOnTouchListener(d);
            //s.SetLayoutParams(p);
            //result.Add(s);

            //s = new ShapeView(context, ShapeView.ShapeEnum.TriangleShape, 100, 100, Color.MAGENTA);
            //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("1") };
            //s.SetOnDragListener(d);
            //s.SetOnLongClickListener(d);
            //s.SetOnTouchListener(d);
            //s.SetLayoutParams(p);
            //result.Add(s);

            //s = new ShapeView(context, ShapeView.ShapeEnum.RoundedRectShape, 100, 100, Color.YELLOW);
            //d = new DragHandler { CheckerData = sortObjects.ResultChecker.CreateCheckerData("2") };
            //s.SetOnDragListener(d);
            //s.SetOnLongClickListener(d);
            //s.SetOnTouchListener(d);
            //s.SetLayoutParams(p);
            //result.Add(s);

            var p = new LinearLayout.LayoutParams(120, 120);

            p.SetMargins(5, 5, 5, 5);

            var i = new ImageView(context);

            i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE);
            i.SetImageResource(R.Drawables.Laura);
            //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png"));
            i.SetLayoutParams(p);
            var d = new MoveDragHandler {
                CheckerData = sortObjects.ResultChecker.CreateCheckerData("1")
            };
            var t = new SpeechDropHandler {
                Tts = tts, Text = "This is Laura"
            };

            d.Successor = t;
            i.SetOnDragListener(d);
            i.SetOnTouchListener(d);
            result.Add(i);

            i = new ImageView(context);
            i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE);
            i.SetImageResource(R.Drawables.Inge);
            //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png"));
            i.SetLayoutParams(p);
            d = new MoveDragHandler {
                CheckerData = sortObjects.ResultChecker.CreateCheckerData("1")
            };
            t = new SpeechDropHandler {
                Tts = tts, Text = "This is Inge"
            };
            d.Successor = t;
            i.SetOnDragListener(d);
            i.SetOnTouchListener(d);
            result.Add(i);

            i = new ImageView(context);
            i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE);
            i.SetImageResource(R.Drawables.Emma);
            //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png"));
            i.SetLayoutParams(p);
            d = new MoveDragHandler {
                CheckerData = sortObjects.ResultChecker.CreateCheckerData("2")
            };
            t = new SpeechDropHandler {
                Tts = tts, Text = "This is Emma"
            };
            d.Successor = t;
            i.SetOnDragListener(d);
            i.SetOnTouchListener(d);
            result.Add(i);

            i = new ImageView(context);
            i.SetScaleType(Android.Widget.ImageView.ScaleType.CENTER_INSIDE);
            i.SetImageResource(R.Drawables.Thor);
            //- i.SetImageDrawable(Drawable.CreateFromPath("res/drawable/laura.png"));
            i.SetLayoutParams(p);
            d = new MoveDragHandler {
                CheckerData = sortObjects.ResultChecker.CreateCheckerData("2")
            };
            t = new SpeechDropHandler {
                Tts = tts, Text = "This is Thor"
            };
            d.Successor = t;
            i.SetOnDragListener(d);
            i.SetOnTouchListener(d);
            result.Add(i);

            sortObjects.ResultChecker.NrAccepts = result.Count();

            return(result);
        }
コード例 #30
0
 void Awake()
 {
     shapeView = GetComponent <ShapeView>();
 }