Пример #1
0
        protected static DataGridMultiLineTextColumn Getc1MultiLineTextColumn(string header, string binding)
        {
            var col = new DataGridMultiLineTextColumn {
                Header = header, Binding = new Binding(binding)
            };

            return(col);
        }
Пример #2
0
        public static void AddColumns(C1.WPF.DataGrid.C1DataGrid dg, List <ColumnDescription> cList)
        {
            StaticData.DataTypeList.Clear();
            foreach (var cd in cList)
            {
                string buf = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                if (buf.ToLower() != "id")
                {
                    StaticData.DataTypeList.Add(buf, cd.DataType);
                }



                if (cd.TypeEnum == enumType.Date)
                {
                    C1.WPF.DataGrid.DataGridTextColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1TextColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1TextColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name   = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    col.Format = "dd.MM.yyyy";
                    col.HorizontalAlignment = HorizontalAlignment.Right;
                    col.VerticalAlignment   = VerticalAlignment.Top;
                    dg.Columns.Add(col);
                }

                else if (cd.TypeEnum == enumType.Currency)
                {
                    C1.WPF.DataGrid.DataGridTextColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1TextColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1TextColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name   = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    col.Format = "{0:f}";
                    col.HorizontalAlignment = HorizontalAlignment.Right;
                    col.VerticalAlignment   = VerticalAlignment.Top;
                    dg.Columns.Add(col);
                }



                else if (cd.TypeEnum == enumType.Checkbox)
                {
                    C1.WPF.DataGrid.DataGridCheckBoxColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1CheckBoxColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1CheckBoxColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;

                    col.HorizontalAlignment = HorizontalAlignment.Right;

                    dg.Columns.Add(col);
                }

                else if (cd.TypeEnum == enumType.MultiLineText)
                {
                    DataGridMultiLineTextColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1MultiLineTextColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1MultiLineTextColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    //col.Name = cd.binding;

                    dg.Columns.Add(col);
                }



                else if (cd.TypeEnum == enumType.Hyperlink)
                {
                    C1.WPF.DataGrid.DataGridHyperlinkColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1HyperlinkColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1HyperlinkColumn(cd.header, cd.binding);



                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    //col.Name = cd.binding;

                    dg.Columns.Add(col);
                }



                else if (cd.TypeEnum == enumType.Image)
                {
                    C1.WPF.DataGrid.DataGridImageColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1ImageColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1ImageColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name    = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    col.Stretch = System.Windows.Media.Stretch.None;


                    // col.HorizontalAlignment = HorizontalAlignment.Right;

                    dg.Columns.Add(col);
                }

                else if (cd.TypeEnum == enumType.Text)
                {
                    C1.WPF.DataGrid.DataGridTextColumn col =
                        cd.oBinding != null?TemplateHelper.Getc1TextColumn(cd.header, cd.oBinding)
                            : TemplateHelper.Getc1TextColumn(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }



                    if (cd.SetFilterPath)
                    {
                        if (cd.oBinding != null)
                        {
                            if (cd.oBinding.Path.PathParameters.Count == 1)
                            {
                                col.FilterMemberPath = cd.oBinding.Path.PathParameters[0].ToString();
                            }
                            else
                            {
                                col.FilterMemberPath = cd.oBinding.Path.Path;
                            }
                        }
                        else
                        {
                            col.FilterMemberPath = cd.binding;
                        }
                    }



                    if (cd.SetSortPath)
                    {
                        if (cd.oBinding != null)
                        {
                            if (cd.oBinding.Path.PathParameters.Count == 1)
                            {
                                col.SortMemberPath = cd.oBinding.Path.PathParameters[0].ToString();
                            }
                            else
                            {
                                col.SortMemberPath = cd.oBinding.Path.Path;
                            }
                        }
                        else
                        {
                            col.SortMemberPath = cd.binding;
                        }
                    }


                    col.Name = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;



                    dg.Columns.Add(col);
                }
                else if (cd.TypeEnum == enumType.TemplateBackground)
                {
                    string binding = string.Empty;
                    if (cd.binding == null)
                    {
                        binding = cd.oBinding.Path.Path;
                    }
                    else
                    {
                        binding = cd.binding;
                    }

                    C1.WPF.DataGrid.DataGridTemplateColumn col = TemplateHelper.Getc1TextTemplate(cd.header, binding, cd.BackGroundBinding);


                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;

                    dg.Columns.Add(col);
                }



                else
                {
                    C1.WPF.DataGrid.DataGridTemplateColumn col = TemplateHelper.Getc1TextTemplate(cd.header, cd.binding);

                    if (cd.WidthAuto)
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width, C1.WPF.DataGrid.DataGridUnitType.Auto);
                    }
                    else
                    {
                        col.Width = new C1.WPF.DataGrid.DataGridLength(cd.width);
                    }

                    if (cd.SetFilterPath)
                    {
                        col.FilterMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }
                    if (cd.SetSortPath)
                    {
                        col.SortMemberPath = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;
                    }

                    col.Name = cd.oBinding != null ? cd.oBinding.Path.Path : cd.binding;

                    dg.Columns.Add(col);
                }
            }
        }