示例#1
0
        public void IndexField(Field field)
        {
            if(!windowManager.Ask("Are you sure want to create index?","Are you sure?"))
                return;

            field.CreateIndex();
        }
示例#2
0
        public void RenameField(Field field)
        {
            var textBox = new TextBox() { Text = field.Name, Height = 18, Width = 300};
            if (!windowManager.ShowDialog(textBox, "Rename field"))
                return;

            field.Rename(textBox.Text);
        }
        //TODO refactor this class, it's bad style
        public DataGridColumn Generate(Field field, string bindingPath, 
            Action<DbObject, string, DbObject> OnEditDbObjectField, Func<object, string, object, bool> ShowBinaryViewFired)
        {
            DataGridColumn column;

            if(field.DataType == null)
                column = new DataGridTextColumn();
            else if (field.DataType.ToLower().Contains("bool"))
                column = new DataGridCheckBoxColumn();
            else if (field.DataType.ToLower().Contains("system.object"))
                column = new DataGridDbObjectColumn(bindingPath, OnEditDbObjectField);
            else if (field.DataType.ToLower().Contains("system.datetime"))
                column = new DataGridDateTimeColumn();
            else if (field.DataType.ToLower().Contains("system.byte"))
            {
                var binaryColumn = new DataGridBinaryColumn();
                binaryColumn.ShowBinaryViewerFired += ShowBinaryViewFired;
                column = binaryColumn;
            }
            else
                column = new DataGridTextColumn();

            column.Header = field.Name;

            DataGridBoundColumn boundColumn = column as DataGridBoundColumn;

            if (boundColumn != null)
            {
                var binding = new Binding(bindingPath) { Mode = BindingMode.TwoWay };
                boundColumn.Binding = binding;
                if (field.DataType!=null && field.DataType.ToLower().Contains("system.int32"))
                    binding.Converter = new Int32Converter();

            }

            IBindableDataGridColumn bindableDataGridColumn = column as IBindableDataGridColumn;
            if (bindableDataGridColumn != null)
            {
                try
                {
                    bindableDataGridColumn.BindingPath = bindingPath;
                }
                //TODO needed for DataGridDbObjectColumn - remove
                catch (NotImplementedException e)
                {

                }
            }

            return column;
        }