コード例 #1
0
ファイル: CellFactory.cs プロジェクト: GJian/UWP-master
        void CreateCellContent(DataGrid grid, DataGridPanel panel, Border bdr, CellRange rng)
        {
            // get row and column
            var r = panel.Rows[rng.Row];
            var c = panel.Columns[rng.Column];
            //var gr = r as GroupRow;

            // honor user templates (if the row has a backing data item)
            if (r.DataItem != null && c.CellTemplate != null && panel.CellType == CellType.Cell)
            {
                bdr.Padding = GetTemplatePadding(bdr.Padding);
                bdr.Child = GetTemplatedCell(grid, c.CellTemplate);
                return;
            }

            // get binding, unbound value for the cell
            var b = r.DataItem != null ? c.Binding : null;
            var ubVal = r.DataItem != null ? null : panel[rng.Row, rng.Column];

            // get foreground brush taking selected state into account
            var fore = GetForegroundBrush(grid, r, rng, grid.Foreground);

            // handle non-text types
            var type = c.DataType;
            TextBlock tb = null;
            CheckBox chk = null;
            if (// not a group, or hierarchical
                panel.CellType == CellType.Cell &&
                (type == typeof(bool) || type == typeof(bool?))) // and bool
            {
                // Boolean cells: use CheckBox
                chk = new CheckBox();
                chk.IsThreeState = type == typeof(bool?);
                chk.HorizontalAlignment = HorizontalAlignment.Center;
                chk.VerticalAlignment = VerticalAlignment.Center;
                chk.MinWidth = 32;

                chk.HorizontalAlignment = HorizontalAlignment.Stretch;
                chk.VerticalAlignment = VerticalAlignment.Stretch;
                chk.Margin = new Thickness(0, -10, 0, -10);

                chk.IsHitTestVisible = false;
                chk.IsTabStop = false;
                if (fore != null)
                {
                    chk.Foreground = fore;
                }

                bdr.Child = chk;
                if (b != null)
                {
                    chk.SetBinding(CheckBox.IsCheckedProperty, b);
                }
                else
                {
                    var value = ubVal as bool?;
                    chk.IsChecked = value;
                }
            }
            else
            {
                // use TextBlock for everything else (even empty cells)
                tb = new TextBlock();
                tb.VerticalAlignment = VerticalAlignment.Center;
                if (fore != null)
                {
                    tb.Foreground = fore;
                }
                bdr.Child = tb;

                // bound values
                if (b != null)
                {
                    // apply binding
                    tb.SetBinding(TextBlock.TextProperty, b);
                }
                else if (ubVal != null) // unbound values
                {
                    // get column format from column and/or binding
                    tb.Text = r.GetDataFormatted(c);
                }
            }

        }
コード例 #2
0
        public async void listarTratas()
        {
            
            DateTime fecha = DateTime.Now;
            
            tratas1 = new ObservableCollection<Tratamiento>();
            var query = from UsuarioSelected in ParseObject.GetQuery("Tratamiento")
                        where UsuarioSelected.Get<string>("paciente") == usu.Id
                        select UsuarioSelected;
            var final = await query.FindAsync();
            Tratamiento trata;
            foreach (var obj in final)
            {
             
                trata = new Tratamiento();
                trata.Id = obj.ObjectId;
                trata.Medico = obj.Get<string>("MedicoId");
                trata.Fechainicio = (DateTime)obj.CreatedAt;
                trata.Fechafin = obj.Get<DateTime>("FechaFin");
                trata.Fechacontrol = obj.Get<DateTime>("FechaControl");
                trata.NomTratamiento = obj.Get<string>("Nomtratamiento");
                trata.Descripcion = obj.Get<string>("Descripcion");
                tratas1.Add(trata);
                if (trata.Fechacontrol.Month == fecha.Month && trata.Fechacontrol.Year == fecha.Year && trata.Fechacontrol.Day == fecha.Day)
                {
                    cb = new CheckBox
                    {
                        Content = "¿Entendido?"
                    };
                    var panel = new StackPanel();

                    panel.Children.Add(new TextBlock
                    {
                        Text = "Tienes control medico del tratamiento " + trata.Fechacontrol.Date,
                        TextWrapping = TextWrapping.Wrap,
                    });
                    
                    var dialog = new ContentDialog()
                    {
                        Title = "TIENES CONTROL",
                        MaxWidth = this.MaxWidth
                    };
                    
                    cb.SetBinding(CheckBox.IsCheckedProperty, new Binding
                    {
                        Source = dialog,
                    });
                    panel.Children.Add(cb);
                    dialog.Content = panel;
                    dialog.PrimaryButtonText = "OK";
                    dialog.IsPrimaryButtonEnabled = true;
                    dialog.PrimaryButtonClick += delegate {
                        notificar(cb,trata);
                    };
                    dialog.ShowAsync();



                }
                
        }
        }
コード例 #3
0
        private async void EditCardPopupShow(Card Card)
        {
            if (Card != null)
            {
                var panel = new StackPanel
                {
                    MaxWidth = 300,
                };

                var txtbxTitle = new TextBox
                {
                    Name = "txtbxTitle",
                    Margin = new Thickness(0, 0, 0, 10),
                    Text = Card.Name,
                    PlaceholderText = "Card Title:",
                };

                var txtbxDesc = new TextBox
                {
                    Name = "txtbxDesc",
                    Height = 100,
                    Margin = new Thickness(0, 0, 0, 10),
                    AcceptsReturn = true,
                    TextWrapping = TextWrapping.Wrap,
                    Text = Card.Description,
                    PlaceholderText = "Card Description:"
                };

                var dtpckrDueDate = new DatePicker
                {
                    Name = "dtpckrDueDate",
                    Margin = new Thickness(0, 0, 0, 10),
                    Date = Card.DueDate.ToLocalTime()
                };


                var cmbbxColors = new ComboBox
                {
                    Name = "cmbbxColors",
                    Margin = new Thickness(0, 0, 0, 10),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    PlaceholderText = "Color",
                };

                var colors = typeof(Colors).GetTypeInfo().DeclaredProperties;
                foreach (PropertyInfo color in colors)
                {
                    ComboBoxItem _item = new ComboBoxItem();
                    _item.Content = color.Name;
                    _item.Background = new SolidColorBrush((Color)color.GetValue(null, null));
                    cmbbxColors.Items.Add(_item);
                }

                var cb = new CheckBox
                {
                    Content = "Agree"
                };

                var dialog = new ContentDialog()
                {
                    Title = Card.Name,
                    Content = panel,
                    MaxWidth = this.ActualWidth
                };

                panel.Children.Add(txtbxTitle);
                panel.Children.Add(txtbxDesc);
                panel.Children.Add(dtpckrDueDate);
                panel.Children.Add(cmbbxColors);
                panel.Children.Add(cb);

                cb.SetBinding(CheckBox.IsCheckedProperty, new Binding
                {
                    Source = dialog,
                    Path = new PropertyPath("IsPrimaryButtonEnabled"),
                    Mode = BindingMode.TwoWay,
                });

                dialog.PrimaryButtonText = "Save";
                dialog.IsPrimaryButtonEnabled = false;
                dialog.PrimaryButtonClick += delegate
                {
                    var _selectedItem = cmbbxColors.SelectedItem as ComboBoxItem;

                    SolidColorBrush _selectedBackground;
                    if (_selectedItem != null)
                        _selectedBackground = _selectedItem.Background as SolidColorBrush;
                    else
                        _selectedBackground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

                    Color SelectedColor = _selectedBackground.Color;
                    String color = ColorsHelper.GetHexFromColor(SelectedColor);

                    Card = EditCardCheck(Card, txtbxTitle, txtbxDesc, color);
                    Helpers.CardsHelper.EditCard(Card, dtpckrDueDate, CurrentJob);
                };
                dialog.SecondaryButtonText = "Cancel";
                dialog.SecondaryButtonClick += delegate { };

                var result = await dialog.ShowAsync();
            }

            //RefreshUI();
        }