Beispiel #1
0
        private void RenderKVForm(ActionInputModel item)
        {
            var form  = new ActionCustomKVForm();
            var label = GetLabel(item, true);

            //绑定数据
            BindingOperations.SetBinding(form, ActionCustomKVForm.KeyValuesProperty, new Binding()
            {
                Source = DataContext,
                Path   = new PropertyPath(item.BindingName),
                Mode   = BindingMode.TwoWay,
            });
            MultiLineContainer.Children.Add(label);
            MultiLineContainer.Children.Add(form);
            //事件处理
            form.OnAddInputBoxEvent += (e, c) =>
            {
                inputBoxes.Add(e as InputBox);
                HandleInputBoxEvent(e as InputBox);
            };
            form.OnRemoveInputBoxEvent += (e, c) =>
            {
                inputBoxes.Remove(e as InputBox);
            };
        }
Beispiel #2
0
        private void RenderInputBox(ActionInputModel item, bool isMultiLine = false)
        {
            var inputBox = new InputBox();

            inputBox.Placeholder = item.Placeholder;
            inputBoxes.Add(inputBox);
            //绑定数据
            BindingOperations.SetBinding(inputBox, TextBox.TextProperty, new Binding()
            {
                Source = DataContext,
                Path   = new PropertyPath(item.BindingName),
                Mode   = BindingMode.TwoWay,
            });
            HandleInputBoxEvent(inputBox);
            if (!isMultiLine)
            {
                //单行输入
                if (!item.IsStretch && LineInputGroups.Count > 1)
                {
                    inputBox.Width             = double.NaN;
                    inputBox.VerticalAlignment = VerticalAlignment.Center;
                    inputBox.Margin            = new Thickness(0, 0, 10, 0);
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        LineContainer.Children.Add(GetLabel(item));
                    }
                    LineContainer.Children.Add(inputBox);
                }
                else
                {
                    var grid  = GetLineGrid();
                    var label = GetLabel(item);
                    Grid.SetColumn(inputBox, 1);
                    grid.Children.Add(label);
                    grid.Children.Add(inputBox);
                    label.Loaded += (e, c) =>
                    {
                        grid.Width = LineContainer.ActualWidth;
                    };
                    LineContainer.Children.Add(grid);
                }
            }
            else
            {
                //多行输入
                var grid  = GetLineGrid();
                var label = GetLabel(item);
                Grid.SetColumn(inputBox, 1);
                grid.Children.Add(label);
                grid.Children.Add(inputBox);
                MultiLineContainer.Children.Add(grid);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 获得一个文本标签
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private TextBlock GetLabel(ActionInputModel item, bool isLabelName = false)
        {
            var lable = new TextBlock();

            lable.Text = item.Title;
            if (isLabelName)
            {
                lable.Style = FindResource("LabelName") as Style;
            }
            lable.Margin            = new Thickness(0, 0, 10, 0);
            lable.VerticalAlignment = VerticalAlignment.Center;
            return(lable);
        }
Beispiel #4
0
        private void RenderToggleBox(ActionInputModel item, bool isMultiLine = false)
        {
            var control = new Toggle.Toggle();

            //绑定数据
            BindingOperations.SetBinding(control, Toggle.Toggle.IsCheckedProperty, new Binding()
            {
                Source = DataContext,
                Path   = new PropertyPath(item.BindingName),
                Mode   = BindingMode.TwoWay,
            });
            if (!isMultiLine)
            {
                //单行
                if (!item.IsStretch && LineInputGroups.Count > 1)
                {
                    control.VerticalAlignment = VerticalAlignment.Center;
                    control.Margin            = new Thickness(0, 0, 10, 0);
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        LineContainer.Children.Add(GetLabel(item));
                    }
                    LineContainer.Children.Add(control);
                }
                else
                {
                    var grid  = GetLineGrid();
                    var label = GetLabel(item);
                    Grid.SetColumn(control, 1);
                    grid.Children.Add(label);
                    grid.Children.Add(control);
                    label.Loaded += (e, c) =>
                    {
                        grid.Width = LineContainer.ActualWidth;
                    };
                    LineContainer.Children.Add(grid);
                }
            }
            else
            {
                //多行
                var grid  = GetLineGrid();
                var label = GetLabel(item);
                Grid.SetColumn(control, 1);
                grid.Children.Add(label);
                grid.Children.Add(control);
                MultiLineContainer.Children.Add(grid);
            }
        }
Beispiel #5
0
        private void RenderSelectBox(ActionInputModel item, bool isMultiLine = false)
        {
            if (item.SelectItems != null && item.SelectItems.Count > 0)
            {
                var control = new ComboBox();
                control.ItemsSource       = item.SelectItems;
                control.SelectedValuePath = "ID";
                control.DisplayMemberPath = "DisplayName";
                //绑定数据
                BindingOperations.SetBinding(control, ComboBox.SelectedValueProperty, new Binding()
                {
                    Source = DataContext,
                    Path   = new PropertyPath(item.BindingName + ".ID"),
                    Mode   = BindingMode.TwoWay,
                });
                BindingOperations.SetBinding(control, ComboBox.SelectedItemProperty, new Binding()
                {
                    Source = DataContext,
                    Path   = new PropertyPath(item.BindingName),
                    Mode   = BindingMode.TwoWay,
                });


                if (!isMultiLine)
                {
                    //单行输入
                    control.Width             = double.NaN;
                    control.VerticalAlignment = VerticalAlignment.Center;
                    control.Margin            = new Thickness(0, 0, 10, 0);
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        LineContainer.Children.Add(GetLabel(item));
                    }
                    LineContainer.Children.Add(control);
                }
                else
                {
                    //多行输入
                    var grid  = GetLineGrid();
                    var label = GetLabel(item);
                    Grid.SetColumn(control, 1);
                    grid.Children.Add(label);
                    grid.Children.Add(control);
                    MultiLineContainer.Children.Add(grid);
                }
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Unban([FromBody] ActionInputModel model)
        {
            bool userExists = await this.profilesService.UserExistsByIdAsync(model.UserId);

            if (!userExists)
            {
                return(BadRequest(new BadRequestViewModel {
                    Message = "this user does not exist."
                }));
            }

            bool result = await this.adminService.IsAdminAsync(model.AdminId);

            if (!result)
            {
                return(Forbid());
            }

            await this.adminService.UnbanUserAsync(model.UserId);

            return(Ok());
        }