/// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var picker = new CategoryPicker {
                ID = id, AllowMultiSelect = true
            };

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey(ENTITY_TYPE_NAME_KEY))
                {
                    string entityTypeName = configurationValues[ENTITY_TYPE_NAME_KEY].Value;
                    if (!string.IsNullOrWhiteSpace(entityTypeName) && entityTypeName != None.IdValue)
                    {
                        picker.EntityTypeName = entityTypeName;
                        if (configurationValues.ContainsKey(QUALIFIER_COLUMN_KEY))
                        {
                            picker.EntityTypeQualifierColumn = configurationValues[QUALIFIER_COLUMN_KEY].Value;
                            if (configurationValues.ContainsKey(QUALIFIER_VALUE_KEY))
                            {
                                picker.EntityTypeQualifierValue = configurationValues[QUALIFIER_VALUE_KEY].Value;
                            }
                        }
                    }
                }
            }
            return(picker);
        }
Beispiel #2
0
    protected void OnOpenQuizFileButtonClicked(object sender, EventArgs e)
    {
        string quizPath = AskForQuizFilePath();

        Console.WriteLine("Reading quiz from " + quizPath);
        using (StreamReader quizStream = new StreamReader(quizPath))
        {
            string basePath = System.IO.Path.GetDirectoryName(quizPath);
            qc = new QuizConductor(quizStream, basePath);
        }

        cp = new CategoryPicker(treeview1, qc.Categories);
    }
        void ReleaseDesignerOutlets()
        {
            if (CategoryPicker != null)
            {
                CategoryPicker.Dispose();
                CategoryPicker = null;
            }

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

            if (ItemNameField != null)
            {
                ItemNameField.Dispose();
                ItemNameField = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (CategoryPicker != null)
            {
                CategoryPicker.Dispose();
                CategoryPicker = null;
            }

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

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

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

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

            if (categoryBoarder != null)
            {
                categoryBoarder.Dispose();
                categoryBoarder = null;
            }
        }
Beispiel #5
0
        private async void btnPinOutcomeCreate_Click(object sender, RoutedEventArgs e)
        {
            IKey   categoryKey  = KeyFactory.Empty(typeof(Category));
            Color? background   = null;
            string categoryName = null;

            // Select a category.
            CategoryPicker categoryPicker = new CategoryPicker();

            categoryPicker.SelectedKey = categoryKey;

            ContentDialogResult categoryResult = await categoryPicker.ShowAsync();

            if (categoryResult == ContentDialogResult.None)
            {
                return;
            }

            if (categoryResult == ContentDialogResult.Primary)
            {
                categoryKey = categoryPicker.SelectedKey;
            }
            else if (categoryResult == ContentDialogResult.Secondary)
            {
                categoryKey = KeyFactory.Empty(typeof(Category));
            }

            if (!categoryKey.IsEmpty)
            {
                categoryName = await queryDispatcher.QueryAsync(new GetCategoryName(categoryKey));

                background = await queryDispatcher.QueryAsync(new GetCategoryColor(categoryKey));
            }

            // Select a background color.
            ColorPicker backgroundPicker = new ColorPicker();

            backgroundPicker.Title             = "Pick a tile background color";
            backgroundPicker.PrimaryButtonText = "Create";

            if (background != null)
            {
                backgroundPicker.Value = background.Value;
            }

            ContentDialogResult backgroundResult = await backgroundPicker.ShowAsync();

            if (backgroundResult == ContentDialogResult.None)
            {
                return;
            }

            // Create a tile.
            await tileService.PinOutcomeCreate(categoryKey, categoryName, backgroundPicker.Value);

            string message = "Tile created";

            if (categoryName != null)
            {
                message += $" for category '{categoryName}'";
            }

            navigator
            .Message(message)
            .Show();
        }
Beispiel #6
0
        public TaskPopup(TodoTask task, Action onCancel = null, Action onSubmit = null)
        {
            Task = task;

            SelectedDate    = task.date;
            timePicker.Time = task.date.TimeOfDay;

            BackgroundColor = StyleManager.MainColor;
            WidthRequest    = 300;

            titleLabel = new DefaultLabel {
                Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            titleEdit = new DefaultEntry {
                Text = Task.title, HorizontalOptions = LayoutOptions.CenterAndExpand, BackgroundColor = Color.Transparent
            };
            titleEdit.WidthRequest = 250;

            var editButton = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "edit_task.png"
            };
            var doneButton = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "ok.png"
            };


            titlePanel = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = 10,
                Children          = { titleLabel, editButton }
            };

            var editPanel = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(10, 0),
                Children          = { titleEdit, doneButton }
            };

            topPanel = new ContentView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Content           = titlePanel,
            };

            editButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(() => {
                    topPanel.Content = editPanel;
                    titleEdit.Focus();
                }))
            });

            doneButton.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(UpdateTitle))
            });

            if (string.IsNullOrWhiteSpace(task.title))
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    topPanel.Content = editPanel;
                    titleEdit.Focus();
                    ((Entry)editPanel.Children [0]).Focus();
                });
                ((Entry)editPanel.Children [0]).Focus();
            }

            popupFragment = new ContentView();
            datePicker    = new PopupDatePicker {
                OnItemSelected = view => {
                    if (view != null)
                    {
                        popupFragment.Content = view;
                    }
                }
            };
            datePicker.DateChanged += (sender, e) => {
                SelectedDate = datePicker.SelectedDate;
            };
            popupFragment.Content = datePicker.DefaultView;

            var categoryIcon = new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand, HeightRequest = 12, Source = task.GetCategory().IconSource
            };

            categoryPicker = new CategoryPicker();
            categoryPicker.SelectedIndex = 0;

            foreach (Category category in CategoryHelper.AllCategories)
            {
                categoryPicker.Items.Add(category.Name);
                if (task.category == category.Name)
                {
                    categoryPicker.SelectedIndex = categoryPicker.Items.Count - 1;
                }
            }

            categoryPicker.SelectedIndexChanged += (sender, args) => categoryIcon.Source = CategoryHelper.AllCategories[categoryPicker.SelectedIndex].IconSource;
            var selectCategoryArrow = new Image {
                HorizontalOptions = LayoutOptions.End, Source = "select.png", HeightRequest = 10
            };

            selectCategoryArrow.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => categoryPicker.Focus())
            });


            var categoryLayout = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    new DefaultLabel {
                        Text = "Category", TextColor = StyleManager.MainColor
                    },
                    categoryIcon,
                    categoryPicker,
                    selectCategoryArrow
                }
            };

            isFavorite = task.isFavorite;
            var starResource = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;

            var favoriteLabel = new DefaultLabel {
                Text = "Mark as favorite", TextColor = StyleManager.MainColor
            };
            var favoriteImage = new Image {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = starResource,
                HeightRequest     = 15
            };
            var favoriteLayout = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { favoriteLabel, favoriteImage }
            };

            favoriteImage.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => Device.BeginInvokeOnMainThread(() => {
                    isFavorite           = !isFavorite;
                    favoriteImage.Source = isFavorite ? FAVORITE_IMG : NOT_FAVORITE_IMG;
                }))
            });

            var actionText = "Create";

            if (!string.IsNullOrWhiteSpace(task.title))
            {
                actionText = "Update";
            }

            var buttons = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          =
                {
                    new DefaultButton {
                        Text              = "Cancel",
                        TextColor         = Color.White,
                        BackgroundColor   = Color.Silver,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command           = new Command(onCancel.Dispatch)
                    },
                    new DefaultButton {
                        Text              = actionText,
                        TextColor         = Color.White,
                        BackgroundColor   = StyleManager.MainColor,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Command           = new Command(() => Device.BeginInvokeOnMainThread(() => {
                            UpdateTask(task);
                            onSubmit.Dispatch();
                        }))
                    }
                }
            };

            var mainLayout = new StackLayout {
                Padding         = 15,
                BackgroundColor = StyleManager.AccentColor,
                Spacing         = 20,
                Children        =            // TODO time picker, pass time
                {
                    timePicker, categoryLayout, favoriteLayout, buttons
                }
            };

            Children.Add(topPanel);
            Children.Add(datePicker);
            Children.Add(popupFragment);
            Children.Add(mainLayout);
        }
        private void AddCategoryInput(bool removable = true, bool addable = false)
        {
            #region Precondizioni
            if (removable && addable)
            {
                throw new InvalidOperationException("non può essere sia removable e addable");
            }
            #endregion
            _tableLayout.RowCount++;
            PictureBox     pb    = new PictureBox();
            CategoryPicker cp    = CreateCategoryPicker();
            TextBox        value = new TextBox();
            TextBox        desc  = new TextBox();
            NumericUpDown  price = new NumericUpDown();

            cp.SelectionChanged += (obj, e) => CheckButtonStatus();

            //name init per rimozione successiva
            pb.Name    = "pb" + _tableLayout.RowCount;
            value.Name = "val" + _tableLayout.RowCount;
            cp.Name    = "cp" + _tableLayout.RowCount;
            desc.Name  = "desc" + _tableLayout.RowCount;
            price.Name = "price" + _tableLayout.RowCount;

            //picture init
            if (removable)
            {
                pb.Image  = new Bitmap(Image.FromFile("../../Icon/remove.png"), new Size(64, 64));
                pb.Tag    = new string[] { cp.Name, desc.Name, pb.Name, price.Name, value.Name };
                pb.Click += RemoveRowHandler;
            }
            if (addable)
            {
                pb.Image  = new Bitmap(Image.FromFile("../../Icon/add.png"), new Size(64, 64));
                pb.Click += AddRowHandler;
            }
            pb.Anchor = AnchorStyles.None;
            pb.Margin = new Padding(0);
            pb.Size   = new Size(IMAGE_SIZE, IMAGE_SIZE);
            pb.Click += (obj, e) => CheckButtonStatus();

            //value init
            value.Margin       = new Padding(0);
            value.Size         = new Size(Convert.ToInt32(_tableLayout.ColumnStyles[CATVALUE_INDEX].Width), cp.Height);
            value.Anchor       = AnchorStyles.None;
            value.TextAlign    = HorizontalAlignment.Center;
            value.MaxLength    = 40;
            value.TextChanged += (obj, e) => CheckButtonStatus();
            //desc init
            desc.Margin       = new Padding(0);
            desc.Size         = new Size(Convert.ToInt32(_tableLayout.ColumnStyles[CATDESC_INDEX].Width), cp.Height);
            desc.Anchor       = AnchorStyles.None;
            desc.TextAlign    = HorizontalAlignment.Center;
            desc.Multiline    = true;
            desc.MaxLength    = 100;
            desc.TextChanged += (obj, e) => CheckButtonStatus();
            //price init
            price.Margin        = new Padding(0);
            price.DecimalPlaces = 2;
            price.TextAlign     = HorizontalAlignment.Center;
            price.Size          = new Size(Convert.ToInt32(_tableLayout.ColumnStyles[PRICE_INDEX].Width), cp.Height);
            price.Anchor        = AnchorStyles.None;

            //aggiungo i controlli
            _tableLayout.Controls.Add(pb);
            _tableLayout.Controls.Add(cp);
            _tableLayout.Controls.Add(value);
            _tableLayout.Controls.Add(desc);
            _tableLayout.Controls.Add(price);
        }
Beispiel #8
0
        private async void abbPin_Click(object sender, RoutedEventArgs e)
        {
            IKey   categoryKey  = ViewModel.SelectedCategories.FirstOrDefault() ?? KeyFactory.Empty(typeof(Category));
            Color? background   = null;
            string categoryName = null;

            // Select a category.
            CategoryPicker categoryPicker = new CategoryPicker();

            categoryPicker.SelectedKey = categoryKey;

            ContentDialogResult categoryResult = await categoryPicker.ShowAsync();

            if (categoryResult == ContentDialogResult.None)
            {
                return;
            }

            if (categoryResult == ContentDialogResult.Primary)
            {
                categoryKey = categoryPicker.SelectedKey;
            }
            else if (categoryResult == ContentDialogResult.Secondary)
            {
                categoryKey = KeyFactory.Empty(typeof(Category));
            }

            if (!categoryKey.IsEmpty)
            {
                CategoryModel category = ViewModel.Categories.FirstOrDefault(c => c.Key.Equals(categoryKey));
                if (category != null)
                {
                    categoryName = category.Name;
                    background   = category.Color;
                }
            }

            // Select a background color.
            ColorPicker backgroundPicker = new ColorPicker();

            backgroundPicker.Title             = "Pick a tile background color";
            backgroundPicker.PrimaryButtonText = "Create";

            if (background != null)
            {
                backgroundPicker.Value = background.Value;
            }

            ContentDialogResult backgroundResult = await backgroundPicker.ShowAsync();

            if (backgroundResult == ContentDialogResult.None)
            {
                return;
            }

            // Create a tile.
            await tileService.PinOutcomeCreate(categoryKey, categoryName, backgroundPicker.Value);

            string message = "Tile created";

            if (categoryName != null)
            {
                message += $" for category '{categoryName}'";
            }

            navigator
            .Message(message)
            .Show();
        }