Example #1
0
        /// <summary>
        /// Sets the text alignment.
        /// </summary>
        /// <param name="view">The view.</param>
        private void SetTextAlignment(ExtendedEditor view)
        {
            try
            {
                switch (view.XAlign)
                {
                case TextAlignment.Center:
                    Control.TextAlignment = UITextAlignment.Center;
                    break;

                case TextAlignment.End:
                    Control.TextAlignment = UITextAlignment.Right;
                    break;

                case TextAlignment.Start:
                    Control.TextAlignment = UITextAlignment.Left;
                    break;
                }
            }
            catch (Exception ex)
            {
                Control.TextAlignment = UITextAlignment.Left;
                System.Diagnostics.Debug.WriteLine(ex.Message + " " + ex.StackTrace);
            }
        }
 private void SetBorder(ExtendedEditor view)
 {
     if (!view.HasBorder)
     {
         Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
     }
 }
Example #3
0
 private void SetDefaultSettingColor(ExtendedEditor extendedEditor)
 {
     Control.Layer.CornerRadius  = extendedEditor.CornerRadius;
     Control.Layer.BorderColor   = extendedEditor.BorderColor.ToCGColor();
     Control.Layer.BorderWidth   = extendedEditor.BorderWidth;
     Control.Layer.MasksToBounds = true;
     Control.TextContainerInset  = new UIEdgeInsets(extendedEditor.PaddingTop, extendedEditor.PaddingLeft, extendedEditor.PaddingBottom, extendedEditor.PaddingRight);
     Control.ClipsToBounds       = true;
 }
 public ExtendedAssets( ExtendedEditor editor )
 {
     textures = new Dictionary<string, Texture2D>();
     var type = editor.GetType();
     var files = Directory.GetFiles( Application.dataPath, string.Format( "*{0}.cs", type.Name ), SearchOption.AllDirectories );
     if ( files.Length == 1 ) {
         var f = files[0];
         var fi = new FileInfo( f );
         Path = System.IO.Path.Combine( fi.DirectoryName, "Assets/" );
     }
 }
Example #5
0
        /// <summary>
        /// Sets the font.
        /// </summary>
        /// <param name="view">The view.</param>
        private void SetFont(ExtendedEditor view)
        {
            UIFont uiFont;

            if (view.Font != Font.Default && (uiFont = view.Font.ToUIFont()) != null)
            {
                Control.Font = uiFont;
            }
            else if (view.Font == Font.Default)
            {
                Control.Font = UIFont.SystemFontOfSize(12f);
            }
        }
Example #6
0
        private void SetCharacterSpacing(ExtendedEditor element)
        {
            var stringAttributes = new UIStringAttributes
            {
                Font = Control.Font,
                KerningAdjustment = (float)element.CharacterSpacing,
                ParagraphStyle    = new NSMutableParagraphStyle()
                {
                    LineSpacing = (float)element.LineSpacing,
                    Alignment   = Control.TextAlignment
                }
            };

            if (!string.IsNullOrEmpty(element.Text))
            {
                var attributedText = new NSMutableAttributedString(element.Text);
                attributedText.AddAttributes(stringAttributes, new NSRange(0, element.Text.Length));
                Control.AttributedText = attributedText;
            }
        }
Example #7
0
        public commentPage(int item_id)
        {
            this.item_id = item_id;
            Title        = "View Comments";

            commentListView = new commentListView();

            ExtendedEditor commentEditor = new ExtendedEditor
            {
                //BackgroundColor = Color.FromRgb(64, 64, 64),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text = "Enter comment.."
            };

            commentEditor.Focused += (s, e) => {
                commentEditor.Text = commentEditor.Text.Replace("Enter comment..", "");
            };


            Button btnAddComment = new Button
            {
                Text      = "Log in to add a comment.",
                IsEnabled = false,
                Command   = new Command(() =>
                {
                    Title   = "Add a comment";
                    Content = postStack;
                })
            };

            Button btnPostComment = new Button
            {
                Text    = "Post Comment",
                Command = new Command(async() =>
                {
                    if (string.IsNullOrWhiteSpace(commentEditor.Text))
                    {
                        await DisplayAlert("Enter Comment", "Enter a comment before posting", "OK");
                        return;
                    }

                    bool sucess = await App.MANAGER.YSSI.AddComment(new comment(-1, item_id, App.CredManager.GetAccountValue("G_id"), App.CredManager.GetAccountValue("G_name"), commentEditor.Text, DateTime.Now));
                    if (sucess)
                    {
                        comments.Insert(0, new myDataTypes.comment(-1, item_id, App.CredManager.GetAccountValue("G_id"), App.CredManager.GetAccountValue("G_name"), commentEditor.Text, DateTime.Now));
                        commentListView.ItemsSource = comments;
                        Title   = "View Comments";
                        Content = viewStack;
                        Navigation.InsertPageBefore(new commentPage(item_id), this);
                        Navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlert("Error adding Comment", "There was an error adding your comment. Please try again", "OK");
                    }
                })
            };

            viewStack = new StackLayout
            {
                Padding  = new Thickness(25),
                Children =
                {
                    commentListView,
                    btnAddComment
                }
            };

            postStack = new StackLayout
            {
                Padding  = new Thickness(25),
                Children =
                {
                    commentEditor,
                    btnPostComment
                }
            };

            //enabling add comment button if user is logged in
            if (App.CredManager.IsLoggedIn())
            {
                btnAddComment.Text      = "Add a comment";
                btnAddComment.IsEnabled = true;
            }
            else
            {
                btnAddComment.Text      = "Log in to add a comment.";
                btnAddComment.IsEnabled = false;
            }

            Content = viewStack;
        }
Example #8
0
        public newItemPage(int fbla_id)
        {
            Title = "New Item For sale";

            this.fbla_id = fbla_id;

            Button postBtn = new Button
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text            = "Put item for sale!",
                VerticalOptions = LayoutOptions.End
            };

            postBtn.Clicked += postBtnClicked;


            Button cameraBtn = new Button
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End,
                Text = "Add A picture",
            };

            cameraBtn.Clicked += cameraBtnClicked;

            name = new ExtendedEntry
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Placeholder       = "Enter item Name"
            };

            desc = new ExtendedEditor
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HeightRequest     = 50
            };

            condition = new Label
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.End,
                HorizontalTextAlignment = TextAlignment.Center,
                BackgroundColor         = Constants.palette.primary_variant,
                Text          = "Select Condition",
                FontSize      = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                HeightRequest = 30
            };
            condition.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(async() =>
                {
                    var action = await DisplayActionSheet("Select Condition", "Cancel", null, "\u2605", "\u2605\u2605", "\u2605\u2605\u2605", "\u2605\u2605\u2605\u2605", "\u2605\u2605\u2605\u2605\u2605");
                    switch (action)
                    {
                    case "Cancel":
                        condition.Text = "\u2605\u2605\u2605";
                        break;

                    default:
                        condition.Text = action;
                        break;
                    }
                }),
            });

            image = new CustomImageView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HeightRequest     = 100,
                //Aspect = Aspect.AspectFit,
            };

            price = new ExtendedEntry
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End,
                Placeholder       = "Enter Price",
                Keyboard          = Keyboard.Numeric
            };

            baseStack = new StackLayout
            {
                Padding           = new Thickness(25),
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Children          =
                {
                    name,

                    new Label {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Text = "Item Description"
                    },

                    desc,
                    image,
                    price,
                    condition,
                    cameraBtn,
                    postBtn
                }
            };

            Content = baseStack;
        }
Example #9
0
 private void SetColor(ExtendedEditor element)
 {
     Control.TextColor = element.TextColor.ToUIColor();
 }