diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Category.vb b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Category.vb new file mode 100644 index 0000000..206d13a --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Category.vb @@ -0,0 +1,12 @@ +Imports System +Imports System.Collections.Generic +Imports System.Linq + +Namespace DevExpress.CRUD.Northwind + Public Class Category + Public Property Id() As Long + Public Property Name() As String + Public Property Description() As String + Public Overridable Property Products() As ICollection(Of Product) + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContext.vb b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContext.vb new file mode 100644 index 0000000..797f794 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContext.vb @@ -0,0 +1,21 @@ +Imports System +Imports System.Collections.Generic +Imports System.Data.Entity +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace DevExpress.CRUD.Northwind + Public Class NorthwindContext + Inherits DbContext + + Shared Sub New() + Database.SetInitializer(New NorthwindContextInitializer()) + End Sub + Protected Overrides Sub OnModelCreating(ByVal modelBuilder As DbModelBuilder) + modelBuilder.Entity(Of Product)().Property(Function(x) x.Name).IsRequired() + End Sub + Public Property Categories() As DbSet(Of Category) + Public Property Products() As DbSet(Of Product) + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContextInitializer.vb b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContextInitializer.vb new file mode 100644 index 0000000..4b6ff3f --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/NorthwindContextInitializer.vb @@ -0,0 +1,97 @@ +Imports System.Collections.Generic +Imports System.Data.Entity + +Namespace DevExpress.CRUD.Northwind + Public Class NorthwindContextInitializer + Inherits DropCreateDatabaseIfModelChanges(Of NorthwindContext) + + Protected Overrides Sub Seed(ByVal context As NorthwindContext) + MyBase.Seed(context) + + Dim categories = New List(Of Category) _ + From { + New Category With { + .Name = "Beverages", + .Description = "Soft drinks, coffees, teas, beers, and ales", + .Products = New List(Of Product) From { + New Product With { + .Name = "Chai", + .QuantityPerUnit = "10 boxes x 20 bags", + .UnitPrice = CDec(18), + .UnitsInStock = 39, + .UnitsOnOrder = 0, + .ReorderLevel = 10, + .Discontinued = False, + .EAN13 = "070684900001" + }, + New Product With { + .Name = "Ipoh Coffee", + .QuantityPerUnit = "16 - 500 g tins", + .UnitPrice = CDec(46), + .UnitsInStock = 17, + .UnitsOnOrder = 10, + .ReorderLevel = 25, + .Discontinued = False, + .EAN13 = "070684900043" + } + } + }, + New Category With { + .Name = "Condiments", + .Description = "Sweet and savory sauces, relishes, spreads, and seasonings", + .Products = New List(Of Product) From { + New Product With { + .Name = "Aniseed Syrup", + .QuantityPerUnit = "12 - 550 ml bottles", + .UnitPrice = CDec(10), + .UnitsInStock = 13, + .UnitsOnOrder = 70, + .ReorderLevel = 25, + .Discontinued = False, + .EAN13 = "070684900003" + }, + New Product With { + .Name = "Louisiana Fiery Hot Pepper Sauce", + .QuantityPerUnit = "32 - 8 oz bottles", + .UnitPrice = CDec(21.05), + .UnitsInStock = 76, + .UnitsOnOrder = 0, + .ReorderLevel = 0, + .Discontinued = False, + .EAN13 = "070684900065" + } + } + }, + New Category With { + .Name = "Grains/Cereals", + .Description = "Breads, crackers, pasta, and cereal", + .Products = New List(Of Product) From { + New Product With { + .Name = "Singaporean Hokkien Fried Mee", + .QuantityPerUnit = "32 - 1 kg pkgs.", + .UnitPrice = CDec(14), + .UnitsInStock = 26, + .UnitsOnOrder = 0, + .ReorderLevel = 0, + .Discontinued = True, + .EAN13 = "070684900042" + }, + New Product With { + .Name = "Ravioli Angelo", + .QuantityPerUnit = "24 - 250 g pkgs.", + .UnitPrice = CDec(19.5), + .UnitsInStock = 36, + .UnitsOnOrder = 0, + .ReorderLevel = 20, + .Discontinued = False, + .EAN13 = "070684900057" + } + } + } + } + + context.Categories.AddRange(categories) + context.SaveChanges() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Product.vb b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Product.vb new file mode 100644 index 0000000..422f001 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind - VB/Product.vb @@ -0,0 +1,18 @@ +Imports System +Imports System.Linq + +Namespace DevExpress.CRUD.Northwind + Public Class Product + Public Property Id() As Long + Public Property Name() As String + Public Property CategoryId() As Long + Public Overridable Property Category() As Category + Public Property QuantityPerUnit() As String + Public Property UnitPrice() As Decimal? + Public Property UnitsInStock() As Short? + Public Property UnitsOnOrder() As Short? + Public Property ReorderLevel() As Short? + Public Property Discontinued() As Boolean + Public Property EAN13() As String + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/CategoryInfo.vb b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/CategoryInfo.vb new file mode 100644 index 0000000..5def298 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/CategoryInfo.vb @@ -0,0 +1,9 @@ +Imports System +Imports System.Linq + +Namespace DevExpress.CRUD.Northwind.DataModel + Public Class CategoryInfo + Public Property Name() As String + Public Property Id() As Long + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorage.vb b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorage.vb new file mode 100644 index 0000000..f94d489 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorage.vb @@ -0,0 +1,12 @@ +Imports DevExpress.CRUD.DataModel + +Namespace DevExpress.CRUD.Northwind.DataModel + Public Class NorthwindDataStorage + Public Sub New(ByVal categories As IDataProvider(Of CategoryInfo), ByVal products As IDataProvider(Of ProductInfo)) + Me.Categories = categories + Me.Products = products + End Sub + Public ReadOnly Property Categories() As IDataProvider(Of CategoryInfo) + Public ReadOnly Property Products() As IDataProvider(Of ProductInfo) + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorageFactory.vb b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorageFactory.vb new file mode 100644 index 0000000..c988a22 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/NorthwindDataStorageFactory.vb @@ -0,0 +1,30 @@ +Imports DevExpress.CRUD.DataModel.EntityFramework +Imports DevExpress.CRUD.DataModel + +Namespace DevExpress.CRUD.Northwind.DataModel + Public Module NorthwindDataStorageFactory + Public Function Create(ByVal isInDesignMode As Boolean) As NorthwindDataStorage + If isInDesignMode Then + Return New NorthwindDataStorage(New DesignTimeDataProvider(Of CategoryInfo)(Function(id) New CategoryInfo With { + .Id = id, + .Name = "Category " & id + }), New DesignTimeDataProvider(Of ProductInfo)(Function(id) New ProductInfo With { + .Id = id, + .Name = "Product " & id, + .CategoryId = id + })) + End If + Return New NorthwindDataStorage(New EntityFrameworkDataProvider(Of NorthwindContext, Category, CategoryInfo)(createContext:= Function() New NorthwindContext(), getDbSet:= Function(context) context.Categories, getEnityExpression:= Function(category) New CategoryInfo With { + .Id = category.Id, + .Name = category.Name + }, keyProperty:= NameOf(Category.Id)), New EntityFrameworkDataProvider(Of NorthwindContext, Product, ProductInfo)(createContext:= Function() New NorthwindContext(), getDbSet:= Function(context) context.Products, getEnityExpression:= Function(product) New ProductInfo With { + .Id = product.Id, + .Name = product.Name, + .CategoryId = product.CategoryId + }, getKey:= Function(productInfo) productInfo.Id, getEntityKey:= Function(product) product.Id, setKey:= Sub(productInfo, id) productInfo.Id = CLng(Math.Truncate(id)), applyProperties:= Sub(productInfo, product) + product.Name = productInfo.Name + product.CategoryId = productInfo.CategoryId + End Sub, keyProperty:= NameOf(Category.Id))) + End Function + End Module +End Namespace diff --git a/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/ProductInfo.vb b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/ProductInfo.vb new file mode 100644 index 0000000..c035e53 --- /dev/null +++ b/VB/GridControlCRUD.Common.Northwind/Northwind.DataModel - VB/ProductInfo.vb @@ -0,0 +1,10 @@ +Imports System +Imports System.Linq + +Namespace DevExpress.CRUD.Northwind.DataModel + Public Class ProductInfo + Public Property Name() As String + Public Property Id() As Long + Public Property CategoryId() As Long + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/DataModel - VB/DataProviderAsyncExtensions.vb b/VB/GridControlCRUD.Common/DataModel - VB/DataProviderAsyncExtensions.vb new file mode 100644 index 0000000..d2f2e3e --- /dev/null +++ b/VB/GridControlCRUD.Common/DataModel - VB/DataProviderAsyncExtensions.vb @@ -0,0 +1,40 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.Xpf.Data +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Linq.Expressions +Imports System.Threading.Tasks + +Namespace DevExpress.CRUD.ViewModel + Public Module DataProviderAsyncExtensions + _ + Public Async Function ReadAsync(Of T As Class)(ByVal dataProvider As IDataProvider(Of T)) As Task(Of IList(Of T)) +#If DEBUG Then + Await Task.Delay(500) +#End If + Return Await Task.Run(Function() dataProvider.Read()) + End Function + _ + Public Async Function GetQueryableResultAsync(Of T As Class, TResult)(ByVal dataProvider As IDataProvider(Of T), ByVal getResult As Func(Of IQueryable(Of T), TResult)) As Task(Of TResult) +#If DEBUG Then + Await Task.Delay(500) +#End If + Return Await Task.Run(Function() dataProvider.GetQueryableResult(getResult)) + End Function + _ + Public Async Function UpdateAsync(Of T As Class)(ByVal dataProvider As IDataProvider(Of T), ByVal entity As T) As Task +#If DEBUG Then + Await Task.Delay(500) +#End If + Await Task.Run(Sub() dataProvider.Update(entity)) + End Function + _ + Public Async Function CreateAsync(Of T As Class)(ByVal dataProvider As IDataProvider(Of T), ByVal entity As T) As Task +#If DEBUG Then + Await Task.Delay(500) +#End If + Await Task.Run(Sub() dataProvider.Create(entity)) + End Function + End Module +End Namespace diff --git a/VB/GridControlCRUD.Common/DataModel - VB/DesignTimeDataProvider.vb b/VB/GridControlCRUD.Common/DataModel - VB/DesignTimeDataProvider.vb new file mode 100644 index 0000000..4faf3fe --- /dev/null +++ b/VB/GridControlCRUD.Common/DataModel - VB/DesignTimeDataProvider.vb @@ -0,0 +1,46 @@ +Imports DevExpress.Xpf.Data +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Linq.Expressions + +Namespace DevExpress.CRUD.DataModel + Public Class DesignTimeDataProvider(Of T As Class) + Implements IDataProvider(Of T) + + Private ReadOnly createEntity As Func(Of Integer, T) + Private ReadOnly count As Integer + + Public Sub New(ByVal createEntity As Func(Of Integer, T), Optional ByVal count As Integer = 5) + Me.createEntity = createEntity + Me.count = count + End Sub + + Private Function IDataProviderGeneric_Read() As IList(Of T) Implements IDataProvider(Of T).Read + Return Enumerable.Range(0, count).Select(createEntity).ToList() + End Function + + Private Function IDataProviderGeneric_GetQueryableResult(Of TResult)(ByVal getResult As Func(Of IQueryable(Of T), TResult)) As TResult Implements IDataProvider(Of T).GetQueryableResult + Dim queryable = DirectCast(Me, IDataProvider(Of T)).Read().AsQueryable() + Return getResult(queryable) + End Function + + Private Sub IDataProviderGeneric_Create(ByVal obj As T) Implements IDataProvider(Of T).Create + Throw New NotSupportedException() + End Sub + Private Sub IDataProviderGeneric_Delete(ByVal obj As T) Implements IDataProvider(Of T).Delete + Throw New NotSupportedException() + End Sub + Private Sub IDataProviderGeneric_Update(ByVal obj As T) Implements IDataProvider(Of T).Update + Throw New NotSupportedException() + End Sub + + Private ReadOnly Property IDataProviderGeneric_KeyProperty() As String Implements IDataProvider(Of T).KeyProperty + Get +'INSTANT VB TODO TASK: Throw expressions are not converted by Instant VB: +'ORIGINAL LINE: return throw new NotSupportedException(); + Return throw New NotSupportedException() + End Get + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/DataModel - VB/EntityFrameworkDataProvider.vb b/VB/GridControlCRUD.Common/DataModel - VB/EntityFrameworkDataProvider.vb new file mode 100644 index 0000000..255ff2b --- /dev/null +++ b/VB/GridControlCRUD.Common/DataModel - VB/EntityFrameworkDataProvider.vb @@ -0,0 +1,133 @@ +Imports DevExpress.Xpf.Data +Imports System +Imports System.Collections.Generic +Imports System.Data.Entity +Imports System.Data.Entity.Validation +Imports System.Linq +Imports System.Linq.Expressions +Imports System.Text + +Namespace DevExpress.CRUD.DataModel.EntityFramework + Public Class EntityFrameworkDataProvider(Of TContext As DbContext, TEntity As Class, T As Class) + Implements IDataProvider(Of T) + + Protected ReadOnly createContext As Func(Of TContext) + Protected ReadOnly getDbSet As Func(Of TContext, DbSet(Of TEntity)) + Protected ReadOnly getEntityExpression As Expression(Of Func(Of TEntity, T)) +'INSTANT VB NOTE: The field keyProperty was renamed since Visual Basic does not allow fields to have the same name as other class members: + Private ReadOnly keyProperty_Conflict As String + + Private ReadOnly getKey As Func(Of T, Object) + Private ReadOnly getEntityKey As Func(Of TEntity, Object) + Private ReadOnly setKey As Action(Of T, Object) + Private ReadOnly applyProperties As Action(Of T, TEntity) + + Public Sub New(ByVal createContext As Func(Of TContext), ByVal getDbSet As Func(Of TContext, DbSet(Of TEntity)), ByVal getEnityExpression As Expression(Of Func(Of TEntity, T)), Optional ByVal keyProperty As String = Nothing, Optional ByVal getKey As Func(Of T, Object) = Nothing, Optional ByVal getEntityKey As Func(Of TEntity, Object) = Nothing, Optional ByVal setKey As Action(Of T, Object) = Nothing, Optional ByVal applyProperties As Action(Of T, TEntity) = Nothing) + Me.createContext = createContext + Me.getDbSet = getDbSet + Me.getEntityExpression = getEnityExpression + + Me.keyProperty_Conflict = keyProperty +'INSTANT VB TODO TASK: Throw expressions are not converted by Instant VB: +'ORIGINAL LINE: this.getKey = getKey ?? (underscore => throw new NotSupportedException()); +'INSTANT VB TODO TASK: Underscore 'discards' are not converted by Instant VB: + Me.getKey = If(getKey, (Function(underscore) throw New NotSupportedException())) +'INSTANT VB TODO TASK: Throw expressions are not converted by Instant VB: +'ORIGINAL LINE: this.getEntityKey = getEntityKey ?? (underscore => throw new NotSupportedException()); +'INSTANT VB TODO TASK: Underscore 'discards' are not converted by Instant VB: + Me.getEntityKey = If(getEntityKey, (Function(underscore) throw New NotSupportedException())) +'INSTANT VB TODO TASK: Throw expressions are not converted by Instant VB: +'ORIGINAL LINE: this.setKey = setKey ?? ((underscore, __) => throw new NotSupportedException()); +'INSTANT VB TODO TASK: Underscore 'discards' are not converted by Instant VB: + Me.setKey = If(setKey, (Function(underscore, __) throw New NotSupportedException())) +'INSTANT VB TODO TASK: Throw expressions are not converted by Instant VB: +'ORIGINAL LINE: this.applyProperties = applyProperties ?? ((underscore, __) => throw new NotSupportedException()); +'INSTANT VB TODO TASK: Underscore 'discards' are not converted by Instant VB: + Me.applyProperties = If(applyProperties, (Function(underscore, __) throw New NotSupportedException())) + End Sub + + Private Function IDataProviderGeneric_Read() As IList(Of T) Implements IDataProvider(Of T).Read + Using context = createContext() + Dim query = getDbSet(context).Select(getEntityExpression) + Return query.ToList() + End Using + End Function + + Private Sub IDataProviderGeneric_Delete(ByVal obj As T) Implements IDataProvider(Of T).Delete + Using context = createContext() + Dim entity = getDbSet(context).Find(getKey(obj)) + If entity Is Nothing Then + Throw New NotImplementedException("The modified row no longer exists in the database. Handle this case according to your requirements.") + End If + getDbSet(context).Remove(entity) + SaveChanges(context) + End Using + End Sub + + Private Sub IDataProviderGeneric_Create(ByVal obj As T) Implements IDataProvider(Of T).Create + Using context = createContext() + Dim entity = getDbSet(context).Create() + getDbSet(context).Add(entity) + applyProperties(obj, entity) + SaveChanges(context) + setKey(obj, getEntityKey(entity)) + End Using + End Sub + + Private Sub IDataProviderGeneric_Update(ByVal obj As T) Implements IDataProvider(Of T).Update + Using context = createContext() + Dim entity = getDbSet(context).Find(getKey(obj)) + If entity Is Nothing Then + Throw New NotImplementedException("The modified row does not exist in a database anymore. Handle this case according to your requirements.") + End If + applyProperties(obj, entity) + SaveChanges(context) + End Using + End Sub + + Private Function IDataProviderGeneric_GetQueryableResult(Of TResult)(ByVal getResult As Func(Of IQueryable(Of T), TResult)) As TResult Implements IDataProvider(Of T).GetQueryableResult + Using context = createContext() + Dim queryable = getDbSet(context).Select(getEntityExpression) + Return getResult(queryable) + End Using + End Function + + Private ReadOnly Property IDataProviderGeneric_KeyProperty() As String Implements IDataProvider(Of T).KeyProperty + Get + Return keyProperty_Conflict + End Get + End Property + + Private Shared Sub SaveChanges(ByVal context As TContext) + Try + context.SaveChanges() + Catch e As Exception + Throw ConvertException(e) + End Try + End Sub + + Private Shared Function ConvertException(ByVal e As Exception) As DbException + Dim entityValidationException = TryCast(e, DbEntityValidationException) + If entityValidationException IsNot Nothing Then + Dim stringBuilder As New StringBuilder() + For Each validationResult In entityValidationException.EntityValidationErrors + For Each [error] In validationResult.ValidationErrors + If stringBuilder.Length > 0 Then + stringBuilder.AppendLine() + End If + stringBuilder.Append([error].PropertyName & ": " & [error].ErrorMessage) + Next [error] + Next validationResult + Return New DbException(stringBuilder.ToString(), entityValidationException) + End If + Return New DbException("An error has occurred while updating the database.", entityValidationException) + End Function + End Class + Public Class DbException + Inherits Exception + + Public Sub New(ByVal message As String, ByVal innerException As Exception) + MyBase.New(message, innerException) + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/DataModel - VB/IDataProvider.vb b/VB/GridControlCRUD.Common/DataModel - VB/IDataProvider.vb new file mode 100644 index 0000000..7e1785c --- /dev/null +++ b/VB/GridControlCRUD.Common/DataModel - VB/IDataProvider.vb @@ -0,0 +1,16 @@ +Imports DevExpress.Xpf.Data +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Linq.Expressions + +Namespace DevExpress.CRUD.DataModel + Public Interface IDataProvider(Of T As Class) + Function Read() As IList(Of T) + Sub Create(ByVal obj As T) + Sub Update(ByVal obj As T) + Sub Delete(ByVal obj As T) + Function GetQueryableResult(Of TResult)(ByVal getResult As Func(Of IQueryable(Of T), TResult)) As TResult 'used for virtual sources + ReadOnly Property KeyProperty() As String + End Interface +End Namespace diff --git a/VB/GridControlCRUD.Common/View - VB/GridControlDeleteRefreshBehavior.vb b/VB/GridControlCRUD.Common/View - VB/GridControlDeleteRefreshBehavior.vb new file mode 100644 index 0000000..b2049de --- /dev/null +++ b/VB/GridControlCRUD.Common/View - VB/GridControlDeleteRefreshBehavior.vb @@ -0,0 +1,152 @@ +Imports DevExpress.CRUD.ViewModel +Imports DevExpress.Mvvm +Imports DevExpress.Mvvm.UI.Interactivity +Imports DevExpress.Xpf.Core +Imports DevExpress.Xpf.Data +Imports DevExpress.Xpf.Grid +Imports System +Imports System.ComponentModel +Imports System.Threading.Tasks +Imports System.Windows +Imports System.Windows.Input + +Namespace DevExpress.CRUD.View + Public Class GridControlDeleteRefreshBehavior + Inherits Behavior(Of TableView) + + Public Property OnDeleteCommand() As ICommand(Of RowDeleteArgs) + Get + Return DirectCast(GetValue(OnDeleteCommandProperty), ICommand(Of RowDeleteArgs)) + End Get + Set(ByVal value As ICommand(Of RowDeleteArgs)) + SetValue(OnDeleteCommandProperty, value) + End Set + End Property + Public Shared ReadOnly OnDeleteCommandProperty As DependencyProperty = DependencyProperty.Register("OnDeleteCommand", GetType(ICommand(Of RowDeleteArgs)), GetType(GridControlDeleteRefreshBehavior), New PropertyMetadata(Nothing)) + + Public Property OnRefreshCommand() As ICommand(Of RefreshArgs) + Get + Return DirectCast(GetValue(OnRefreshCommandProperty), ICommand(Of RefreshArgs)) + End Get + Set(ByVal value As ICommand(Of RefreshArgs)) + SetValue(OnRefreshCommandProperty, value) + End Set + End Property + Public Shared ReadOnly OnRefreshCommandProperty As DependencyProperty = DependencyProperty.Register("OnRefreshCommand", GetType(ICommand(Of RefreshArgs)), GetType(GridControlDeleteRefreshBehavior), New PropertyMetadata(Nothing)) + + Public Property NoRecordsErrorMessage() As String + Get + Return CStr(GetValue(NoRecordsErrorMessageProperty)) + End Get + Set(ByVal value As String) + SetValue(NoRecordsErrorMessageProperty, value) + End Set + End Property + Public Shared ReadOnly NoRecordsErrorMessageProperty As DependencyProperty = DependencyProperty.Register("NoRecordsErrorMessage", GetType(String), GetType(GridControlDeleteRefreshBehavior), New PropertyMetadata(Nothing, Sub(d, e) + CType(d, GridControlDeleteRefreshBehavior).UpdateErrorText() + End Sub)) + + + Public ReadOnly Property DeleteCommand() As ICommand + Public ReadOnly Property RefreshCommand() As ICommand + + Private ReadOnly Property View() As TableView + Get + Return AssociatedObject + End Get + End Property + Private ReadOnly Property VirtualSource() As VirtualSourceBase + Get + Return TryCast(View?.DataControl?.ItemsSource, VirtualSourceBase) + End Get + End Property + + Public Sub New() + DeleteCommand = New DelegateCommand(AddressOf DoDelete, AddressOf CanDelete) + RefreshCommand = New AsyncCommand(AddressOf DoRefresh, AddressOf CanRefresh) + End Sub + + Protected Overrides Sub OnAttached() + MyBase.OnAttached() + AddHandler View.PreviewKeyDown, AddressOf OnPreviewKeyDown + UpdateErrorText() + End Sub + + Protected Overrides Sub OnDetaching() + RemoveHandler View.PreviewKeyDown, AddressOf OnPreviewKeyDown + UpdateErrorText() + MyBase.OnDetaching() + End Sub + + Private Sub UpdateErrorText() + If View Is Nothing Then + Return + End If + If NoRecordsErrorMessage IsNot Nothing Then + View.ShowEmptyText = True + View.RuntimeLocalizationStrings = New GridRuntimeStringCollection() From {New RuntimeStringIdInfo(GridControlRuntimeStringId.NoRecords, NoRecordsErrorMessage)} + Else + View.ShowEmptyText = False + View.RuntimeLocalizationStrings = Nothing + End If + End Sub + + Private Async Sub OnPreviewKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) + If e.Key = Key.Delete AndAlso CanDelete() Then + e.Handled = True + DoDelete() + End If + If e.Key = Key.F5 AndAlso CanRefresh() Then + e.Handled = True + Await DoRefresh() + End If + End Sub + + Private isRefreshInProgress As Boolean + Private Async Function DoRefresh() As Task + VirtualSource?.RefreshRows() + Dim args = New RefreshArgs() + OnRefreshCommand.Execute(args) + If args.Result IsNot Nothing Then + isRefreshInProgress = True + Try + Await args.Result + Finally + isRefreshInProgress = False + End Try + End If + End Function + Private Function CanRefresh() As Boolean + Dim canRefreshVirtualSource = VirtualSource Is Nothing OrElse (TryCast(VirtualSource, InfiniteAsyncSource)?.IsResetting <> True AndAlso Not VirtualSource.AreRowsFetching) + Return canRefreshVirtualSource AndAlso OnRefreshCommand IsNot Nothing AndAlso Not IsEditingRowState() AndAlso Not isRefreshInProgress AndAlso (View?.Grid.ItemsSource IsNot Nothing OrElse NoRecordsErrorMessage IsNot Nothing) + End Function + + Private Sub DoDelete() + Dim row = View.Grid.SelectedItem + If row Is Nothing Then + Return + End If + If DXMessageBox.Show(View, "Are you sure you want to delete this row?", "Delete Row", MessageBoxButton.OKCancel) = MessageBoxResult.Cancel Then + Return + End If + Try + OnDeleteCommand.Execute(New RowDeleteArgs(row)) + If VirtualSource IsNot Nothing Then + VirtualSource?.RefreshRows() + Else + View.Commands.DeleteFocusedRow.Execute(Nothing) + End If + Catch ex As Exception + DXMessageBox.Show(ex.Message) + End Try + End Sub + + Private Function CanDelete() As Boolean + Return OnDeleteCommand IsNot Nothing AndAlso Not IsEditingRowState() AndAlso Not isRefreshInProgress AndAlso View?.Grid.CurrentItem IsNot Nothing + End Function + + Private Function IsEditingRowState() As Boolean + Return View?.AreUpdateRowButtonsShown = True + End Function + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/View - VB/VirtualSourceEditFormBehavior.vb b/VB/GridControlCRUD.Common/View - VB/VirtualSourceEditFormBehavior.vb new file mode 100644 index 0000000..5166bf9 --- /dev/null +++ b/VB/GridControlCRUD.Common/View - VB/VirtualSourceEditFormBehavior.vb @@ -0,0 +1,119 @@ +Imports DevExpress.CRUD.ViewModel +Imports DevExpress.Mvvm +Imports DevExpress.Mvvm.UI.Interactivity +Imports DevExpress.Xpf.Core +Imports DevExpress.Xpf.Data +Imports DevExpress.Xpf.Grid +Imports System +Imports System.ComponentModel +Imports System.Windows +Imports System.Windows.Input + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class VirtualSourceEditFormBehavior + Inherits Behavior(Of TableView) + + Public Property OnUpdateCommand() As ICommand + Get + Return DirectCast(GetValue(OnUpdateCommandProperty), ICommand) + End Get + Set(ByVal value As ICommand) + SetValue(OnUpdateCommandProperty, value) + End Set + End Property + Public Shared ReadOnly OnUpdateCommandProperty As DependencyProperty = DependencyProperty.Register("OnUpdateCommand", GetType(ICommand), GetType(VirtualSourceEditFormBehavior), New PropertyMetadata(Nothing)) + + Public Property OnCreateCommand() As ICommand + Get + Return DirectCast(GetValue(OnCreateCommandProperty), ICommand) + End Get + Set(ByVal value As ICommand) + SetValue(OnCreateCommandProperty, value) + End Set + End Property + Public Shared ReadOnly OnCreateCommandProperty As DependencyProperty = DependencyProperty.Register("OnCreateCommand", GetType(ICommand), GetType(VirtualSourceEditFormBehavior), New PropertyMetadata(Nothing)) + + Private ReadOnly Property Source() As VirtualSourceBase + Get + Return CType(AssociatedObject?.DataControl?.ItemsSource, VirtualSourceBase) + End Get + End Property + + Public ReadOnly Property CreateCommand() As ICommand + Public ReadOnly Property UpdateCommand() As ICommand + Public Sub New() + CreateCommand = New DelegateCommand(AddressOf DoCreate) + UpdateCommand = New DelegateCommand(Sub() DoUpdate(), AddressOf CanUpdate) + End Sub + + Protected Overrides Sub OnAttached() + MyBase.OnAttached() + AddHandler AssociatedObject.PreviewKeyDown, AddressOf OnKeyDown + AddHandler AssociatedObject.MouseDoubleClick, AddressOf OnMouseDoubleClick + End Sub + + Protected Overrides Sub OnDetaching() + RemoveHandler AssociatedObject.PreviewKeyDown, AddressOf OnKeyDown + RemoveHandler AssociatedObject.MouseDoubleClick, AddressOf OnMouseDoubleClick + MyBase.OnDetaching() + End Sub + + Private Sub OnMouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs) + Dim row = EventArgsToDataRowConverter.GetDataRow(e) + If row IsNot Nothing Then + DoUpdate(row) + End If + End Sub + + Private Sub OnKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) + If e.Key = Key.F2 Then + DoUpdate() + e.Handled = True + End If + If e.Key = Key.N AndAlso (Keyboard.Modifiers And ModifierKeys.Control) <> 0 Then + DoCreate() + e.Handled = True + End If + End Sub + + Private Sub DoUpdate(Optional ByVal entity As Object = Nothing) + entity = If(entity, AssociatedObject.DataControl.CurrentItem) + Dim args = New EntityUpdateArgs(entity) + OnUpdateCommand.Execute(args) + If args.Updated Then + ReloadRow(GetKey(entity)) + End If + End Sub + Private Sub ReloadRow(ByVal key As Object) + If TypeOf Source Is InfiniteAsyncSource Then + CType(Source, InfiniteAsyncSource).ReloadRows(key) + ElseIf TypeOf Source Is PagedAsyncSource Then + CType(Source, PagedAsyncSource).ReloadRows(key) + Else + Throw New InvalidOperationException() + End If + End Sub + + Private Function CanUpdate() As Boolean + Return OnUpdateCommand IsNot Nothing AndAlso CanChangeCurrentItem() + End Function + + Private Function CanChangeCurrentItem() As Boolean + Return AssociatedObject?.DataControl?.CurrentItem IsNot Nothing + End Function + + Private Sub DoCreate() + Dim args = New EntityCreateArgs() + OnCreateCommand.Execute(args) + If args.Entity IsNot Nothing Then + Source.RefreshRows() + End If + End Sub + + Private Function GetKey(Of T)(ByVal entity As T) As Object + Dim typedList As ITypedList = Source + Dim keyProperty = typedList.GetItemProperties(Nothing)(Source.KeyProperty) + Return keyProperty.GetValue(entity) + End Function + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel - VB/AsyncCollectionViewModel.vb b/VB/GridControlCRUD.Common/ViewModel - VB/AsyncCollectionViewModel.vb new file mode 100644 index 0000000..a4cbd02 --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel - VB/AsyncCollectionViewModel.vb @@ -0,0 +1,91 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.Mvvm +Imports DevExpress.Mvvm.DataAnnotations +Imports DevExpress.Mvvm.Xpf +Imports System.Collections.Generic +Imports System.Threading.Tasks + +Namespace DevExpress.CRUD.ViewModel + Public MustInherit Class AsyncCollectionViewModel(Of T As Class) + Inherits ViewModelBase + + Private ReadOnly dataProvider As IDataProvider(Of T) + + Protected Sub New(ByVal dataProvider As IDataProvider(Of T)) + Me.dataProvider = dataProvider + StartRefresh() + End Sub + + Public Property Entities() As IList(Of T) + Get + Return GetValue(Of IList(Of T))() + End Get + Private Set(ByVal value As IList(Of T)) + SetValue(value) + End Set + End Property + Public Property EntitiesErrorMessage() As String + Get + Return GetValue(Of String)() + End Get + Private Set(ByVal value As String) + SetValue(value) + End Set + End Property + Public Property IsLoading() As Boolean + Get + Return GetValue(Of Boolean)() + End Get + Private Set(ByVal value As Boolean) + SetValue(value) + End Set + End Property + + Private Async Sub StartRefresh() + Await OnRefreshAsync() + End Sub + + + Public Sub OnRefresh(ByVal args As RefreshArgs) + args.Result = OnRefreshAsync() + End Sub + Private Async Function OnRefreshAsync() As Task + IsLoading = True + Try + Await Task.WhenAll(RefreshEntities(), OnRefreshCoreAsync()) + Finally + IsLoading = False + End Try + End Function + Private Async Function RefreshEntities() As Task + Try + Entities = Await dataProvider.ReadAsync() + EntitiesErrorMessage = Nothing + Catch + Entities = Nothing + EntitiesErrorMessage = "An error has occurred while establishing a connection to the database. Press F5 to retry the connection." + End Try + End Function + Protected Overridable Function OnRefreshCoreAsync() As Task + Return Task.CompletedTask + End Function + + + Public Sub OnUpdateRow(ByVal args As RowValidationArgs) + args.ResultAsync = OnUpdateRowAsync(CType(args.Item, T), args.IsNewItem) + End Sub + Private Async Function OnUpdateRowAsync(ByVal entity As T, ByVal isNew As Boolean) As Task(Of ValidationErrorInfo) + If isNew Then + Await dataProvider.CreateAsync(entity) + Else + Await dataProvider.UpdateAsync(entity) + End If + Return Nothing + End Function + + + Public Sub OnDelete(ByVal args As RowDeleteArgs) + dataProvider.Delete(DirectCast(args.Row, T)) + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel - VB/CollectionViewModel.vb b/VB/GridControlCRUD.Common/ViewModel - VB/CollectionViewModel.vb new file mode 100644 index 0000000..7c2bda2 --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel - VB/CollectionViewModel.vb @@ -0,0 +1,70 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.Mvvm +Imports DevExpress.Mvvm.DataAnnotations +Imports DevExpress.Mvvm.Xpf +Imports System.Collections.Generic + +Namespace DevExpress.CRUD.ViewModel + Public MustInherit Class CollectionViewModel(Of T As Class) + Inherits ViewModelBase + + Private ReadOnly dataProvider As IDataProvider(Of T) + + Protected Sub New(ByVal dataProvider As IDataProvider(Of T)) + Me.dataProvider = dataProvider + OnRefresh() + End Sub + + Public Property Entities() As IList(Of T) + Get + Return GetValue(Of IList(Of T))() + End Get + Private Set(ByVal value As IList(Of T)) + SetValue(value) + End Set + End Property + Public Property EntitiesErrorMessage() As String + Get + Return GetValue(Of String)() + End Get + Private Set(ByVal value As String) + SetValue(value) + End Set + End Property + +'INSTANT VB NOTE: An underscore by itself is not a valid identifier in VB: +'ORIGINAL LINE: public void OnRefresh(RefreshArgs _) + + Public Sub OnRefresh(ByVal underscore As RefreshArgs) + OnRefresh() + End Sub + Private Sub OnRefresh() + Try + Entities = dataProvider.Read() + EntitiesErrorMessage = Nothing + Catch + Entities = Nothing + EntitiesErrorMessage = "An error has occurred while establishing a connection to the database. Press F5 to retry the connection." + End Try + OnRefreshCore() + End Sub + + Protected Overridable Sub OnRefreshCore() + End Sub + + + Public Sub OnUpdateRow(ByVal args As RowValidationArgs) + Dim entity = CType(args.Item, T) + If args.IsNewItem Then + dataProvider.Create(entity) + Else + dataProvider.Update(entity) + End If + End Sub + + + Public Sub OnDelete(ByVal args As RowDeleteArgs) + dataProvider.Delete(DirectCast(args.Row, T)) + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel - VB/VirtualCollectionViewModel.vb b/VB/GridControlCRUD.Common/ViewModel - VB/VirtualCollectionViewModel.vb new file mode 100644 index 0000000..03dc76d --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel - VB/VirtualCollectionViewModel.vb @@ -0,0 +1,114 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.Mvvm +Imports DevExpress.Mvvm.DataAnnotations +Imports DevExpress.Xpf.Data +Imports DevExpress.Mvvm.Xpf +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Linq.Expressions +Imports System.Threading.Tasks +Imports System.ComponentModel +Imports DevExpress.Xpf.Core + +Namespace DevExpress.CRUD.ViewModel + Public MustInherit Class VirtualCollectionViewModel(Of T As {Class, New}) + Inherits ViewModelBase + + Private ReadOnly dataProvider As IDataProvider(Of T) + + Protected Sub New(ByVal dataProvider As IDataProvider(Of T)) + Me.dataProvider = dataProvider + StartRefresh() + End Sub + + Public ReadOnly Property FilterType() As Type + Get + Return GetType(Expression(Of Func(Of T, Boolean))) + End Get + End Property + Private ReadOnly Property DialogService() As IDialogService + Get + Return GetService(Of IDialogService)() + End Get + End Property + + + Public Sub Fetch(ByVal args As FetchRowsAsyncArgs) + args.Result = dataProvider.GetQueryableResultAsync(Of T, FetchRowsResult)(Function(queryable) + Return queryable.SortBy(args.SortOrder, defaultUniqueSortPropertyName:= dataProvider.KeyProperty).Where(CType(args.Filter, Expression(Of Func(Of T, Boolean)))).Skip(args.Skip).Take(If(args.Take, 30)).ToArray() + End Function) + End Sub + + + Public Sub GetTotalSummaries(ByVal args As GetSummariesAsyncArgs) + args.Result = dataProvider.GetQueryableResultAsync(Function(queryable) + Return queryable.Where(CType(args.Filter, Expression(Of Func(Of T, Boolean)))).GetSummaries(args.Summaries) + End Function) + End Sub + + + Public Sub GetUniqueValues(ByVal args As GetUniqueValuesAsyncArgs) + args.ResultWithCounts = dataProvider.GetQueryableResultAsync(Function(queryable) + Return queryable.Where(CType(args.Filter, Expression(Of Func(Of T, Boolean)))).DistinctWithCounts(args.PropertyName) + End Function) + End Sub + + + Public Sub OnUpdate(ByVal args As EntityUpdateArgs) + Dim entity = DirectCast(args.Entity, T) + Dim commands = CreateCommands(Sub() + dataProvider.Update(entity) + args.Updated = True + End Sub) + DialogService.ShowDialog(commands, "Edit " & GetType(T).Name, CreateEntityViewModel(entity)) + End Sub + + + Public Sub OnCreate(ByVal args As EntityCreateArgs) + Dim entity = New T() + Dim commands = CreateCommands(Sub() + dataProvider.Create(entity) + args.Entity = entity + End Sub) + DialogService.ShowDialog(commands, "New " & GetType(T).Name, CreateEntityViewModel(entity)) + End Sub + + Private Function CreateCommands(ByVal saveAction As Action) As UICommand() + Return { New UICommand(Nothing, "Save", New DelegateCommand(Of CancelEventArgs)(Function(cancelArgs) + Try + saveAction() + Catch e As Exception + GetService(Of IMessageBoxService)().ShowMessage(e.Message, "Error", MessageButton.OK) + cancelArgs.Cancel = True + End Try + End Function), isDefault:= True, isCancel:= False), New UICommand(Nothing, "Cancel", Nothing, isDefault:= False, isCancel:= True)} + End Function + + Protected MustOverride Function CreateEntityViewModel(ByVal entity As T) As EntityViewModel(Of T) + + + Public Sub OnDelete(ByVal args As RowDeleteArgs) + Me.dataProvider.Delete(DirectCast(args.Row, T)) + End Sub + + + Public Sub OnRefresh(ByVal args As RefreshArgs) + args.Result = OnRefreshCoreAsync() + End Sub + Private Async Sub StartRefresh() + Await OnRefreshCoreAsync() + End Sub + Protected Overridable Function OnRefreshCoreAsync() As Task + Return Task.CompletedTask + End Function + End Class + Public Class EntityViewModel(Of T) + Inherits ViewModelBase + + Public Sub New(ByVal entity As T) + Me.Entity = entity + End Sub + Public ReadOnly Property Entity() As T + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityCreateArgs.vb b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityCreateArgs.vb new file mode 100644 index 0000000..a2ece31 --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityCreateArgs.vb @@ -0,0 +1,8 @@ +Imports System +Imports System.Linq + +Namespace DevExpress.CRUD.ViewModel + Public Class EntityCreateArgs + Public Property Entity() As Object + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityUpdateArgs.vb b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityUpdateArgs.vb new file mode 100644 index 0000000..ee19a6c --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/EntityUpdateArgs.vb @@ -0,0 +1,12 @@ +Imports System +Imports System.Linq + +Namespace DevExpress.CRUD.ViewModel + Public Class EntityUpdateArgs + Public Sub New(ByVal entity As Object) + Me.Entity = entity + End Sub + Public ReadOnly Property Entity() As Object + Public Property Updated() As Boolean + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RefreshArgs.vb b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RefreshArgs.vb new file mode 100644 index 0000000..dfd6197 --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RefreshArgs.vb @@ -0,0 +1,7 @@ +Imports System.Threading.Tasks + +Namespace DevExpress.CRUD.ViewModel + Public Class RefreshArgs + Public Property Result() As Task + End Class +End Namespace diff --git a/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RowDeleteArgs.vb b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RowDeleteArgs.vb new file mode 100644 index 0000000..ed8f3b9 --- /dev/null +++ b/VB/GridControlCRUD.Common/ViewModel/CommandArgs - VB/RowDeleteArgs.vb @@ -0,0 +1,8 @@ +Namespace DevExpress.CRUD.ViewModel + Public Class RowDeleteArgs + Public Sub New(ByVal row As Object) + Me.Row = row + End Sub + Public ReadOnly Property Row() As Object + End Class +End Namespace diff --git a/VB/GridControlCRUD.sln b/VB/GridControlCRUD.sln new file mode 100644 index 0000000..80a36aa --- /dev/null +++ b/VB/GridControlCRUD.sln @@ -0,0 +1,42 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDSimple", "GridControlCRUDSimple\GridControlCRUDSimple.vbproj", "{9E2883B9-744A-48BF-B25A-EA4B2D435C9D}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVM", "GridControlCRUDMVVM\GridControlCRUDMVVM.vbproj", "{69E85A61-E7D4-4C9D-A433-13E742AE30BC}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVMAsync", "GridControlCRUDMVVMAsync\GridControlCRUDMVVMAsync.vbproj", "{659194A7-745D-4A56-A683-B150B9170F53}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVMInfiniteAsyncSource", "GridControlCRUDMVVMInfiniteAsyncSource\GridControlCRUDMVVMInfiniteAsyncSource.vbproj", "{99F77CC9-A05A-4064-B0A9-63E0B93ED156}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Release|Any CPU.Build.0 = Release|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Release|Any CPU.Build.0 = Release|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.Build.0 = Release|Any CPU + {99F77CC9-A05A-4064-B0A9-63E0B93ED156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99F77CC9-A05A-4064-B0A9-63E0B93ED156}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99F77CC9-A05A-4064-B0A9-63E0B93ED156}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99F77CC9-A05A-4064-B0A9-63E0B93ED156}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51597E69-ADA1-4945-9493-FC7C9FB65AD2} + EndGlobalSection +EndGlobal diff --git a/VB/GridControlCRUDMVVM/App.config b/VB/GridControlCRUDMVVM/App.config new file mode 100644 index 0000000..2484a16 --- /dev/null +++ b/VB/GridControlCRUDMVVM/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + diff --git a/VB/GridControlCRUDMVVM/Application.xaml b/VB/GridControlCRUDMVVM/Application.xaml new file mode 100644 index 0000000..6e24603 --- /dev/null +++ b/VB/GridControlCRUDMVVM/Application.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/VB/GridControlCRUDMVVM/Application.xaml.vb b/VB/GridControlCRUDMVVM/Application.xaml.vb new file mode 100644 index 0000000..5af5832 --- /dev/null +++ b/VB/GridControlCRUDMVVM/Application.xaml.vb @@ -0,0 +1,14 @@ +Imports DevExpress.Mvvm +Imports DevExpress.Xpf.Core +Imports System.Windows + +Namespace GridControlCRUDMVVM + Partial Public Class App + Inherits Application + + Public Sub New() + ApplicationThemeHelper.UpdateApplicationThemeName() + DevExpress.Internal.DbEngineDetector.PatchConnectionStringsAndConfigureEntityFrameworkDefaultConnectionFactory() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.sln b/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.sln new file mode 100644 index 0000000..2e089b5 --- /dev/null +++ b/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVM", "GridControlCRUDMVVM.vbproj", "{69E85A61-E7D4-4C9D-A433-13E742AE30BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51597E69-ADA1-4945-9493-FC7C9FB65AD2} + EndGlobalSection +EndGlobal diff --git a/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.vbproj b/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.vbproj new file mode 100644 index 0000000..b1712e8 --- /dev/null +++ b/VB/GridControlCRUDMVVM/GridControlCRUDMVVM.vbproj @@ -0,0 +1,230 @@ + + + + + + Debug + AnyCPU + {69E85A61-E7D4-4C9D-A433-13E742AE30BC} + WinExe + + GridControlCRUDMVVM + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + true + true + + On + Binary + Off + On + + + AnyCPU + true + full + false + bin\Debug\ + true + true + prompt + true + + + AnyCPU + pdbonly + true + bin\Release\ + false + true + prompt + true + + + + + + + + + + + + + + + + + + + + + + + + C:\DXDlls\21.1.2\DevExpress.Data.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Data.Desktop.v21.1.dll + True + + + True + C:\DXDlls\21.1.2\DevExpress.Images.v21.1.dll + + + C:\DXDlls\21.1.2\DevExpress.Mvvm.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Printing.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Core.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Printing.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Extensions.dll + True + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + DataModel\DesignTimeDataProvider.vb + + + DataModel\EntityFrameworkDataProvider.vb + + + DataModel\IDataProvider.vb + + + Northwind.DataModel\CategoryInfo.vb + + + Northwind.DataModel\NorthwindDataStorage.vb + + + Northwind.DataModel\NorthwindDataStorageFactory.vb + + + Northwind.DataModel\ProductInfo.vb + + + Nothwind\Category.vb + + + Nothwind\NorthwindContext.vb + + + Nothwind\Product.vb + + + Nothwind\NorthwindContextInitializer.vb + + + Common.ViewModel\CollectionViewModel.vb + + + Common.ViewModel\CommandArgs\RefreshArgs.vb + + + Common.ViewModel\CommandArgs\RowDeleteArgs.vb + + + View\GridControlDeleteRefreshBehavior.vb + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + + SettingsSingleFileGenerator + Settings.Designer.vb + My + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVM/MainWindow.xaml b/VB/GridControlCRUDMVVM/MainWindow.xaml new file mode 100644 index 0000000..1ff4877 --- /dev/null +++ b/VB/GridControlCRUDMVVM/MainWindow.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VB/GridControlCRUDMVVM/MainWindow.xaml.vb b/VB/GridControlCRUDMVVM/MainWindow.xaml.vb new file mode 100644 index 0000000..d182ba6 --- /dev/null +++ b/VB/GridControlCRUDMVVM/MainWindow.xaml.vb @@ -0,0 +1,11 @@ +Imports DevExpress.Xpf.Core + +Namespace GridControlCRUDMVVM + Partial Public Class MainWindow + Inherits ThemedWindow + + Public Sub New() + InitializeComponent() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVM/My Project/AssemblyInfo.vb b/VB/GridControlCRUDMVVM/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..427be76 --- /dev/null +++ b/VB/GridControlCRUDMVVM/My Project/AssemblyInfo.vb @@ -0,0 +1,48 @@ +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + + + + + + + + +' Setting ComVisible to false makes the types in this assembly not visible +' to COM components. If you need to access a type in this assembly from +' COM, set the ComVisible attribute to true on that type. + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .csproj file +'inside a . For example, if you are using US english +'in your source files, set the to en-US. Then uncomment +'the NeutralResourceLanguage attribute below. Update the "en-US" in +'the line below to match the UICulture setting in the project file. + +'[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' [assembly: AssemblyVersion("1.0.*")] + + diff --git a/VB/GridControlCRUDMVVM/My Project/Resources.Designer.vb b/VB/GridControlCRUDMVVM/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff4afc2 --- /dev/null +++ b/VB/GridControlCRUDMVVM/My Project/Resources.Designer.vb @@ -0,0 +1,65 @@ +Imports System + +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My.Resources + + + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + ' This class was auto-generated by the StronglyTypedResourceBuilder + ' class via a tool like ResGen or Visual Studio. + ' To add or remove a member, edit your .ResX file then rerun ResGen + ' with the /str option, or rebuild your VS project. + + + + Friend Module Resources + + Private resourceMan As System.Resources.ResourceManager + + Private resourceCulture As System.Globalization.CultureInfo + +' internal Resources() +' { +' } + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As New System.Resources.ResourceManager("Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/VB/GridControlCRUDMVVM/My Project/Resources.resx b/VB/GridControlCRUDMVVM/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/VB/GridControlCRUDMVVM/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVM/My Project/Settings.Designer.vb b/VB/GridControlCRUDMVVM/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5b4f12c --- /dev/null +++ b/VB/GridControlCRUDMVVM/My Project/Settings.Designer.vb @@ -0,0 +1,27 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My + + + + + Friend NotInheritable Partial Class Settings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = (CType(System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings)) + + Public Shared ReadOnly Property [Default]() As Settings + Get + Return defaultInstance + End Get + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVM/My Project/Settings.settings b/VB/GridControlCRUDMVVM/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/VB/GridControlCRUDMVVM/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVM/ProductCollectionViewModel.vb b/VB/GridControlCRUDMVVM/ProductCollectionViewModel.vb new file mode 100644 index 0000000..4d55c57 --- /dev/null +++ b/VB/GridControlCRUDMVVM/ProductCollectionViewModel.vb @@ -0,0 +1,41 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.CRUD.Northwind.DataModel +Imports DevExpress.CRUD.ViewModel +Imports System.Collections.Generic + +Namespace DevExpress.CRUD.Northwind.ViewModel + Public Class ProductCollectionViewModel + Inherits CollectionViewModel(Of ProductInfo) + + Public Property Categories() As IList(Of CategoryInfo) + Get + Return GetValue(Of IList(Of CategoryInfo))() + End Get + Private Set(ByVal value As IList(Of CategoryInfo)) + SetValue(value) + End Set + End Property + + Private ReadOnly categoriesDataProvider As IDataProvider(Of CategoryInfo) + + Public Sub New() + Me.New(NorthwindDataStorageFactory.Create(IsInDesignMode)) + End Sub + + Public Sub New(ByVal dataStorage As NorthwindDataStorage) + MyBase.New(dataStorage.Products) + categoriesDataProvider = dataStorage.Categories + OnRefreshCore() + End Sub + + Protected Overrides Sub OnRefreshCore() + If categoriesDataProvider IsNot Nothing Then + Try + Categories = categoriesDataProvider.Read() + Catch + Categories = Nothing + End Try + End If + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVM/packages.config b/VB/GridControlCRUDMVVM/packages.config new file mode 100644 index 0000000..9985587 --- /dev/null +++ b/VB/GridControlCRUDMVVM/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMAsync/App.config b/VB/GridControlCRUDMVVMAsync/App.config new file mode 100644 index 0000000..2484a16 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + diff --git a/VB/GridControlCRUDMVVMAsync/Application.xaml b/VB/GridControlCRUDMVVMAsync/Application.xaml new file mode 100644 index 0000000..0f16619 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/Application.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/VB/GridControlCRUDMVVMAsync/Application.xaml.vb b/VB/GridControlCRUDMVVMAsync/Application.xaml.vb new file mode 100644 index 0000000..815ef72 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/Application.xaml.vb @@ -0,0 +1,14 @@ +Imports DevExpress.Mvvm +Imports DevExpress.Xpf.Core +Imports System.Windows + +Namespace GridControlCRUDMVVMAsync + Partial Public Class App + Inherits Application + + Public Sub New() + ApplicationThemeHelper.UpdateApplicationThemeName() + DevExpress.Internal.DbEngineDetector.PatchConnectionStringsAndConfigureEntityFrameworkDefaultConnectionFactory() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.sln b/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.sln new file mode 100644 index 0000000..cd39696 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVMAsync", "GridControlCRUDMVVMAsync.vbproj", "{659194A7-745D-4A56-A683-B150B9170F53}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51597E69-ADA1-4945-9493-FC7C9FB65AD2} + EndGlobalSection +EndGlobal diff --git a/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.vbproj b/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.vbproj new file mode 100644 index 0000000..390049d --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/GridControlCRUDMVVMAsync.vbproj @@ -0,0 +1,233 @@ + + + + + + Debug + AnyCPU + {659194A7-745D-4A56-A683-B150B9170F53} + WinExe + + GridControlCRUDMVVMAsync + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + true + true + + On + Binary + Off + On + + + AnyCPU + true + full + false + bin\Debug\ + true + true + prompt + true + + + AnyCPU + pdbonly + true + bin\Release\ + false + true + prompt + true + + + + + + + + + + + + + + + + + + + + + + + + C:\DXDlls\21.1.2\DevExpress.Data.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Data.Desktop.v21.1.dll + True + + + True + C:\DXDlls\21.1.2\DevExpress.Images.v21.1.dll + + + C:\DXDlls\21.1.2\DevExpress.Mvvm.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Printing.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Core.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Printing.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Extensions.dll + True + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Common.DataModel\DataProviderAsyncExtensions.vb + + + Common.DataModel\DesignTimeDataProvider.vb + + + Common.DataModel\EntityFrameworkDataProvider.vb + + + Common.DataModel\IDataProvider.vb + + + Northwind.DataModel\CategoryInfo.vb + + + Northwind.DataModel\NorthwindDataStorage.vb + + + Northwind.DataModel\NorthwindDataStorageFactory.vb + + + Northwind.DataModel\ProductInfo.vb + + + Nothwind\Category.vb + + + Nothwind\NorthwindContext.vb + + + Nothwind\Product.vb + + + Nothwind\NorthwindContextInitializer.vb + + + Common.ViewModel\AsyncCollectionViewModel.vb + + + Common.ViewModel\CommandArgs\RefreshArgs.vb + + + Common.ViewModel\CommandArgs\RowDeleteArgs.vb + + + Common.View\GridControlDeleteRefreshBehavior.vb + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + + SettingsSingleFileGenerator + Settings.Designer.vb + My + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMAsync/MainWindow.xaml b/VB/GridControlCRUDMVVMAsync/MainWindow.xaml new file mode 100644 index 0000000..3497121 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/MainWindow.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VB/GridControlCRUDMVVMAsync/MainWindow.xaml.vb b/VB/GridControlCRUDMVVMAsync/MainWindow.xaml.vb new file mode 100644 index 0000000..ce023ac --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/MainWindow.xaml.vb @@ -0,0 +1,11 @@ +Imports DevExpress.Xpf.Core + +Namespace GridControlCRUDMVVMAsync + Partial Public Class MainWindow + Inherits ThemedWindow + + Public Sub New() + InitializeComponent() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMAsync/My Project/AssemblyInfo.vb b/VB/GridControlCRUDMVVMAsync/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..58cb13c --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/My Project/AssemblyInfo.vb @@ -0,0 +1,48 @@ +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + + + + + + + + +' Setting ComVisible to false makes the types in this assembly not visible +' to COM components. If you need to access a type in this assembly from +' COM, set the ComVisible attribute to true on that type. + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .csproj file +'inside a . For example, if you are using US english +'in your source files, set the to en-US. Then uncomment +'the NeutralResourceLanguage attribute below. Update the "en-US" in +'the line below to match the UICulture setting in the project file. + +'[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' [assembly: AssemblyVersion("1.0.*")] + + diff --git a/VB/GridControlCRUDMVVMAsync/My Project/Resources.Designer.vb b/VB/GridControlCRUDMVVMAsync/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff4afc2 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/My Project/Resources.Designer.vb @@ -0,0 +1,65 @@ +Imports System + +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My.Resources + + + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + ' This class was auto-generated by the StronglyTypedResourceBuilder + ' class via a tool like ResGen or Visual Studio. + ' To add or remove a member, edit your .ResX file then rerun ResGen + ' with the /str option, or rebuild your VS project. + + + + Friend Module Resources + + Private resourceMan As System.Resources.ResourceManager + + Private resourceCulture As System.Globalization.CultureInfo + +' internal Resources() +' { +' } + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As New System.Resources.ResourceManager("Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/VB/GridControlCRUDMVVMAsync/My Project/Resources.resx b/VB/GridControlCRUDMVVMAsync/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMAsync/My Project/Settings.Designer.vb b/VB/GridControlCRUDMVVMAsync/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0d979bc --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/My Project/Settings.Designer.vb @@ -0,0 +1,27 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My + + + + + Friend NotInheritable Partial Class Settings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = (CType(System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings)) + + Public Shared ReadOnly Property [Default]() As Settings + Get + Return defaultInstance + End Get + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMAsync/My Project/Settings.settings b/VB/GridControlCRUDMVVMAsync/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMAsync/ProductCollectionViewModel.vb b/VB/GridControlCRUDMVVMAsync/ProductCollectionViewModel.vb new file mode 100644 index 0000000..2b2731c --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/ProductCollectionViewModel.vb @@ -0,0 +1,45 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.CRUD.Northwind.DataModel +Imports DevExpress.CRUD.ViewModel +Imports System.Collections.Generic +Imports System.Threading.Tasks + +Namespace DevExpress.CRUD.Northwind.ViewModel + Public Class ProductCollectionViewModel + Inherits AsyncCollectionViewModel(Of ProductInfo) + + Public Property Categories() As IList(Of CategoryInfo) + Get + Return GetValue(Of IList(Of CategoryInfo))() + End Get + Private Set(ByVal value As IList(Of CategoryInfo)) + SetValue(value) + End Set + End Property + + Private ReadOnly categoriesDataProvider As IDataProvider(Of CategoryInfo) + + Public Sub New() + Me.New(NorthwindDataStorageFactory.Create(IsInDesignMode)) + End Sub + + Public Sub New(ByVal dataStorage As NorthwindDataStorage) + MyBase.New(dataStorage.Products) + categoriesDataProvider = dataStorage.Categories + RefreshCategories() + End Sub + + Private Async Sub RefreshCategories() + Await OnRefreshCoreAsync() + End Sub + Protected Overrides Async Function OnRefreshCoreAsync() As Task + If categoriesDataProvider IsNot Nothing Then + Try + Categories = Await categoriesDataProvider.ReadAsync() + Catch + Categories = Nothing + End Try + End If + End Function + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMAsync/packages.config b/VB/GridControlCRUDMVVMAsync/packages.config new file mode 100644 index 0000000..9985587 --- /dev/null +++ b/VB/GridControlCRUDMVVMAsync/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/App.config b/VB/GridControlCRUDMVVMInfiniteAsyncSource/App.config new file mode 100644 index 0000000..2484a16 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml b/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml new file mode 100644 index 0000000..6d50737 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml.vb new file mode 100644 index 0000000..d42c812 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/Application.xaml.vb @@ -0,0 +1,14 @@ +Imports DevExpress.Mvvm +Imports DevExpress.Xpf.Core +Imports System.Windows + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Partial Public Class App + Inherits Application + + Public Sub New() + ApplicationThemeHelper.UpdateApplicationThemeName() + DevExpress.Internal.DbEngineDetector.PatchConnectionStringsAndConfigureEntityFrameworkDefaultConnectionFactory() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.sln b/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.sln new file mode 100644 index 0000000..2b5ad6f --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDMVVMInfiniteAsyncSource", "GridControlCRUDMVVMInfiniteAsyncSource.vbproj", "{659194A7-745D-4A56-A683-B150B9170F53}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {659194A7-745D-4A56-A683-B150B9170F53}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51597E69-ADA1-4945-9493-FC7C9FB65AD2} + EndGlobalSection +EndGlobal diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.vbproj b/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.vbproj new file mode 100644 index 0000000..786477d --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/GridControlCRUDMVVMInfiniteAsyncSource.vbproj @@ -0,0 +1,231 @@ + + + + + + Debug + AnyCPU + {99F77CC9-A05A-4064-B0A9-63E0B93ED156} + WinExe + + GridControlCRUDMVVMInfiniteAsyncSource + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + true + true + + On + Binary + Off + On + + + AnyCPU + true + full + false + bin\Debug\ + true + true + prompt + true + + + AnyCPU + pdbonly + true + bin\Release\ + false + true + prompt + true + + + + + + + + + + + + + + + + + + + + + + + + C:\DXDlls\21.1.2\DevExpress.Data.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Data.Desktop.v21.1.dll + True + + + True + C:\DXDlls\21.1.2\DevExpress.Images.v21.1.dll + + + C:\DXDlls\21.1.2\DevExpress.Mvvm.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Printing.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Core.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Printing.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.LayoutControl.v21.1.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Core.dll + True + + + C:\DXDlls\21.1.2\DevExpress.Xpf.Grid.v21.1.Extensions.dll + True + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Common.DataModel\DataProviderAsyncExtensions.vb + + + Common.DataModel\DesignTimeDataProvider.vb + + + Common.DataModel\EntityFrameworkDataProvider.vb + + + Common.DataModel\IDataProvider.vb + + + Common.ViewModel\CommandArgs\EntityCreateArgs.vb + + + Common.ViewModel\CommandArgs\EntityUpdateArgs.vb + + + Common.ViewModel\VirtualCollectionViewModel.vb + + + Common.ViewModel\CommandArgs\RefreshArgs.vb + + + Common.ViewModel\CommandArgs\RowDeleteArgs.vb + + + Common.View\GridControlDeleteRefreshBehavior.vb + + + Common.View\VirtualSourceEditFormBehavior.vb + + + + + + + + + + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + + SettingsSingleFileGenerator + Settings.Designer.vb + My + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueCollectionViewModel.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueCollectionViewModel.vb new file mode 100644 index 0000000..0bedfbd --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueCollectionViewModel.vb @@ -0,0 +1,71 @@ +Imports DevExpress.CRUD.DataModel +Imports DevExpress.CRUD.ViewModel +Imports GridControlCRUDMVVMInfiniteAsyncSource +Imports System.Collections.Generic +Imports System.Threading.Tasks + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssueCollectionViewModel + Inherits VirtualCollectionViewModel(Of IssueData) + + Public Property Users() As IList(Of User) + Get + Return GetValue(Of IList(Of User))() + End Get + Private Set(ByVal value As IList(Of User)) + SetValue(value) + End Set + End Property + + Private ReadOnly usersDataProvider As IDataProvider(Of User) + + Public Sub New() + Me.New(IssuesDataStorageFactory.Create(IsInDesignMode)) + End Sub + + Public Sub New(ByVal dataStorage As IssuesDataStorage) + MyBase.New(dataStorage.Issues) + usersDataProvider = dataStorage.Users + RefreshUsers() + End Sub + + Private Async Sub RefreshUsers() + Await OnRefreshCoreAsync() + End Sub + Protected Overrides Async Function OnRefreshCoreAsync() As Task + If usersDataProvider IsNot Nothing Then + Try + Users = Await usersDataProvider.ReadAsync() + Catch + Users = Nothing + End Try + End If + End Function + Protected Overrides Function CreateEntityViewModel(ByVal entity As IssueData) As EntityViewModel(Of IssueData) + Return New IssueDataViewModel(entity, usersDataProvider.ReadAsync()) + End Function + End Class + Public Class IssueDataViewModel + Inherits EntityViewModel(Of IssueData) + + Public Sub New(ByVal entity As IssueData, ByVal usersTask As Task(Of IList(Of User))) + MyBase.New(entity) + AssignUsers(usersTask) + End Sub + Private Async Sub AssignUsers(ByVal usersTask As Task(Of IList(Of User))) + Try + Users = Await usersTask + Catch + Users = Nothing + End Try + End Sub + Public Property Users() As IList(Of User) + Get + Return GetValue(Of IList(Of User))() + End Get + Private Set(ByVal value As IList(Of User)) + SetValue(value) + End Set + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueDataFilterConverter.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueDataFilterConverter.vb new file mode 100644 index 0000000..e73e8d1 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssueDataFilterConverter.vb @@ -0,0 +1,20 @@ +Imports DevExpress.Data.Filtering +Imports DevExpress.Xpf.Data + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssueDataFilterConverter + Inherits ExpressionFilterConverter(Of IssueData) + + Protected Overrides Sub SetUpConverter(ByVal converter As GridFilterCriteriaToExpressionConverter(Of IssueData)) + converter.RegisterFunctionExpressionFactory(operatorType:= FunctionOperatorType.StartsWith, factory:= Function(value As String) + Dim toLowerValue = value.ToLower() + Return x + If True Then + Get + Return x.ToLower().StartsWith(toLowerValue) + End Get + End If + End Function) + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssueData.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssueData.vb new file mode 100644 index 0000000..90bc203 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssueData.vb @@ -0,0 +1,16 @@ +Imports System +Imports System.Linq + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssueData + Public Sub New() + Created = DateTime.Today + End Sub + Public Property Id() As Integer + Public Property Subject() As String + Public Property Created() As DateTime + Public Property Votes() As Integer + Public Property Priority() As Priority + Public Property UserId() As Integer + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorage.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorage.vb new file mode 100644 index 0000000..801d2a1 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorage.vb @@ -0,0 +1,12 @@ +Imports DevExpress.CRUD.DataModel + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssuesDataStorage + Public Sub New(ByVal issues As IDataProvider(Of IssueData), ByVal users As IDataProvider(Of User)) + Me.Users = users + Me.Issues = issues + End Sub + Public ReadOnly Property Users() As IDataProvider(Of User) + Public ReadOnly Property Issues() As IDataProvider(Of IssueData) + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorageFactory.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorageFactory.vb new file mode 100644 index 0000000..d8916cc --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext.DataModel/IssuesDataStorageFactory.vb @@ -0,0 +1,33 @@ +Imports System +Imports DevExpress.CRUD.DataModel.EntityFramework +Imports DevExpress.CRUD.DataModel + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Module IssuesDataStorageFactory + Public Function Create(ByVal isInDesignMode As Boolean) As IssuesDataStorage + If isInDesignMode Then + Return New IssuesDataStorage(New DesignTimeDataProvider(Of IssueData)(Function(id) New IssueData With { + .Id = id, + .Subject = "Subject " & id + }), New DesignTimeDataProvider(Of User)(Function(id) New User With { + .Id = id, + .FirstName = "FirstName " & id + })) + End If + Return New IssuesDataStorage(New EntityFrameworkDataProvider(Of IssuesContext, Issue, IssueData)(createContext:= Function() New IssuesContext(), getDbSet:= Function(context) context.Issues, getEnityExpression:= Function(x) New IssueData() With { + .Id = x.Id, + .Subject = x.Subject, + .UserId = x.UserId, + .Created = x.Created, + .Votes = x.Votes, + .Priority = x.Priority + }, getKey:= Function(ussueData) ussueData.Id, getEntityKey:= Function(ussue) ussue.Id, setKey:= Sub(ussueData, id) ussueData.Id = CInt(Math.Truncate(id)), applyProperties:= Sub(ussueData, issue) + issue.Subject = ussueData.Subject + issue.UserId = ussueData.UserId + issue.Created = ussueData.Created + issue.Votes = ussueData.Votes + issue.Priority = ussueData.Priority + End Sub, keyProperty:= NameOf(IssueData.Id)), New EntityFrameworkDataProvider(createContext:= Function() New IssuesContext(), getDbSet:= Function(context) context.Users, getEnityExpression:= Function(user) user, keyProperty:= NameOf(User.Id))) + End Function + End Module +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/Issue.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/Issue.vb new file mode 100644 index 0000000..8cd2fdd --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/Issue.vb @@ -0,0 +1,20 @@ +Imports System + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class Issue + Public Property Id() As Integer + Public Property Subject() As String + Public Property UserId() As Integer + Public Overridable Property User() As User + Public Property Created() As DateTime + Public Property Votes() As Integer + Public Property Priority() As Priority + End Class + Public Enum Priority + Low + BelowNormal + Normal + AboveNormal + High + End Enum +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContext.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContext.vb new file mode 100644 index 0000000..03e68fe --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContext.vb @@ -0,0 +1,24 @@ +Imports System.Data.Entity + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssuesContext + Inherits DbContext + + Shared Sub New() + Database.SetInitializer(New IssuesContextInitializer()) + End Sub + Public Sub New() + End Sub + + Protected Overrides Sub OnModelCreating(ByVal modelBuilder As DbModelBuilder) + MyBase.OnModelCreating(modelBuilder) + + modelBuilder.Entity(Of Issue)().HasIndex(Function(x) x.Created) + + modelBuilder.Entity(Of Issue)().HasIndex(Function(x) x.Votes) + End Sub + + Public Property Issues() As DbSet(Of Issue) + Public Property Users() As DbSet(Of User) + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContextInitializer.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContextInitializer.vb new file mode 100644 index 0000000..d336a04 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/IssuesContextInitializer.vb @@ -0,0 +1,36 @@ +Imports System +Imports System.Data.Entity +Imports System.Linq + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class IssuesContextInitializer + Inherits DropCreateDatabaseIfModelChanges(Of IssuesContext) + + ': DropCreateDatabaseAlways { + + Protected Overrides Sub Seed(ByVal context As IssuesContext) + MyBase.Seed(context) + Dim users = OutlookDataGenerator.Users.Select(Function(x) + Dim split = x.Split(" "c) + Return New User() With { + .FirstName = split(0), + .LastName = split(1) + } + End Function).ToArray() + context.Users.AddRange(users) + context.SaveChanges() + + Dim rnd = New Random() + Dim issues = Enumerable.Range(0, 1000).Select(Function(i) New Issue() With { + .Subject = OutlookDataGenerator.GetSubject(), + .UserId = users(rnd.Next(users.Length)).Id, + .Created = DateTime.Today.AddDays(-rnd.Next(30) - 1), + .Priority = OutlookDataGenerator.GetPriority(), + .Votes = rnd.Next(100) + }).ToArray() + context.Issues.AddRange(issues) + + context.SaveChanges() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/OutlookDataGenerator.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/OutlookDataGenerator.vb new file mode 100644 index 0000000..c6327f9 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/OutlookDataGenerator.vb @@ -0,0 +1,21 @@ +Imports System + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Module OutlookDataGenerator + Private rnd As New Random() + Private Subjects() As String = { "Developer Express MasterView. Integrating the control into an Accounting System.", "Web Edition: Data Entry Page. There is an issue with date validation.", "Payables Due Calculator is ready for testing.", "Web Edition: Search Page is ready for testing.", "Main Menu: Duplicate Items. Somebody has to review all menu items in the system.", "Receivables Calculator. Where can I find the complete specs?", "Ledger: Inconsistency. Please fix it.", "Receivables Printing module is ready for testing.", "Screen Redraw. Somebody has to look at it.", "Email System. What library are we going to use?", "Cannot add new vendor. This module doesn't work!", "History. Will we track sales history in our system?", "Main Menu: Add a File menu. File menu item is missing.", "Currency Mask. The current currency mask in completely unusable.", "Drag & Drop operations are not available in the scheduler module.", "Data Import. What database types will we support?", "Reports. The list of incomplete reports.", "Data Archiving. We still don't have this features in our application.", "Email Attachments. Is it possible to add multiple attachments? I haven't found a way to do this.", "Check Register. We are using different paths for different modules.", "Data Export. Our customers asked us for export to Microsoft Excel"} + + Public ReadOnly Users() As String = { "Peter Dolan", "Ryan Fischer", "Richard Fisher", "Tom Hamlett", "Mark Hamilton", "Steve Lee", "Jimmy Lewis", "Jeffrey McClain", "Andrew Miller", "Dave Murrel", "Bert Parkins", "Mike Roller", "Ray Shipman", "Paul Bailey", "Brad Barnes", "Carl Lucas", "Jerry Campbell"} + + Public Function GetSubject() As String + Return Subjects(rnd.Next(Subjects.Length - 1)) + End Function + + Public Function GetFrom() As String + Return Users(rnd.Next(Users.Length)) + End Function + Public Function GetPriority() As Priority + Return CType(rnd.Next(5), Priority) + End Function + End Module +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/User.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/User.vb new file mode 100644 index 0000000..a47addd --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/IssuesContext/User.vb @@ -0,0 +1,15 @@ +Imports System.Collections.Generic + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Public Class User + Public Property Id() As Integer + Public Property FirstName() As String + Public Property LastName() As String + Public ReadOnly Property FullName() As String + Get + Return FirstName & " " & LastName + End Get + End Property + Public Overridable Property Issues() As ICollection(Of Issue) + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml b/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml new file mode 100644 index 0000000..51e5492 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml.vb new file mode 100644 index 0000000..de6b269 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/MainWindow.xaml.vb @@ -0,0 +1,11 @@ +Imports DevExpress.Xpf.Core + +Namespace GridControlCRUDMVVMInfiniteAsyncSource + Partial Public Class MainWindow + Inherits ThemedWindow + + Public Sub New() + InitializeComponent() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/AssemblyInfo.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..58cb13c --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/AssemblyInfo.vb @@ -0,0 +1,48 @@ +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + + + + + + + + +' Setting ComVisible to false makes the types in this assembly not visible +' to COM components. If you need to access a type in this assembly from +' COM, set the ComVisible attribute to true on that type. + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .csproj file +'inside a . For example, if you are using US english +'in your source files, set the to en-US. Then uncomment +'the NeutralResourceLanguage attribute below. Update the "en-US" in +'the line below to match the UICulture setting in the project file. + +'[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' [assembly: AssemblyVersion("1.0.*")] + + diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.Designer.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff4afc2 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.Designer.vb @@ -0,0 +1,65 @@ +Imports System + +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My.Resources + + + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + ' This class was auto-generated by the StronglyTypedResourceBuilder + ' class via a tool like ResGen or Visual Studio. + ' To add or remove a member, edit your .ResX file then rerun ResGen + ' with the /str option, or rebuild your VS project. + + + + Friend Module Resources + + Private resourceMan As System.Resources.ResourceManager + + Private resourceCulture As System.Globalization.CultureInfo + +' internal Resources() +' { +' } + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As New System.Resources.ResourceManager("Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.resx b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.Designer.vb b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.Designer.vb new file mode 100644 index 0000000..0d979bc --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.Designer.vb @@ -0,0 +1,27 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My + + + + + Friend NotInheritable Partial Class Settings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = (CType(System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings)) + + Public Shared ReadOnly Property [Default]() As Settings + Get + Return defaultInstance + End Get + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.settings b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDMVVMInfiniteAsyncSource/packages.config b/VB/GridControlCRUDMVVMInfiniteAsyncSource/packages.config new file mode 100644 index 0000000..9985587 --- /dev/null +++ b/VB/GridControlCRUDMVVMInfiniteAsyncSource/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDSimple/App.config b/VB/GridControlCRUDSimple/App.config new file mode 100644 index 0000000..2484a16 --- /dev/null +++ b/VB/GridControlCRUDSimple/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + diff --git a/VB/GridControlCRUDSimple/Application.xaml b/VB/GridControlCRUDSimple/Application.xaml new file mode 100644 index 0000000..7812804 --- /dev/null +++ b/VB/GridControlCRUDSimple/Application.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/VB/GridControlCRUDSimple/Application.xaml.vb b/VB/GridControlCRUDSimple/Application.xaml.vb new file mode 100644 index 0000000..8d7f138 --- /dev/null +++ b/VB/GridControlCRUDSimple/Application.xaml.vb @@ -0,0 +1,13 @@ +Imports DevExpress.Xpf.Core +Imports System.Windows + +Namespace GridControlCRUDSimple + Partial Public Class App + Inherits Application + + Public Sub New() + ApplicationThemeHelper.UpdateApplicationThemeName() + DevExpress.Internal.DbEngineDetector.PatchConnectionStringsAndConfigureEntityFrameworkDefaultConnectionFactory() + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDSimple/GridControlCRUDSimple.sln b/VB/GridControlCRUDSimple/GridControlCRUDSimple.sln new file mode 100644 index 0000000..43b7e16 --- /dev/null +++ b/VB/GridControlCRUDSimple/GridControlCRUDSimple.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GridControlCRUDSimple", "GridControlCRUDSimple.vbproj", "{9E2883B9-744A-48BF-B25A-EA4B2D435C9D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {51597E69-ADA1-4945-9493-FC7C9FB65AD2} + EndGlobalSection +EndGlobal diff --git a/VB/GridControlCRUDSimple/GridControlCRUDSimple.vbproj b/VB/GridControlCRUDSimple/GridControlCRUDSimple.vbproj new file mode 100644 index 0000000..6cc5b54 --- /dev/null +++ b/VB/GridControlCRUDSimple/GridControlCRUDSimple.vbproj @@ -0,0 +1,198 @@ + + + + + + Debug + AnyCPU + {9E2883B9-744A-48BF-B25A-EA4B2D435C9D} + WinExe + + GridControlCRUDSimple + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + true + true + + On + Binary + Off + On + + + AnyCPU + true + full + false + bin\Debug\ + true + true + prompt + true + + + AnyCPU + pdbonly + true + bin\Release\ + false + true + prompt + true + + + + + + + + + + + + + + + + + + + + + + + + + True + + + + True + + + + True + + + + True + + + + True + + + + True + + + + True + + + + True + + + + True + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + Nothwind\Category.vb + + + Nothwind\NorthwindContext.vb + + + Nothwind\Product.vb + + + Nothwind\NorthwindContextInitializer.vb + + + Northwind.DataModel\CategoryInfo.vb + + + Northwind.DataModel\ProductInfo.vb + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + + SettingsSingleFileGenerator + Settings.Designer.vb + My + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/VB/GridControlCRUDSimple/MainWindow.xaml b/VB/GridControlCRUDSimple/MainWindow.xaml new file mode 100644 index 0000000..f7b8f40 --- /dev/null +++ b/VB/GridControlCRUDSimple/MainWindow.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/VB/GridControlCRUDSimple/MainWindow.xaml.vb b/VB/GridControlCRUDSimple/MainWindow.xaml.vb new file mode 100644 index 0000000..f47568b --- /dev/null +++ b/VB/GridControlCRUDSimple/MainWindow.xaml.vb @@ -0,0 +1,76 @@ +Imports DevExpress.Xpf.Core +Imports DevExpress.Xpf.Grid +Imports DevExpress.CRUD.Northwind +Imports System +Imports System.Linq +Imports System.Windows +Imports System.Windows.Input +Imports DevExpress.CRUD.Northwind.DataModel + +Namespace GridControlCRUDSimple + Partial Public Class MainWindow + Inherits ThemedWindow + + Public Sub New() + InitializeComponent() + Using context = New NorthwindContext() + grid.ItemsSource = context.Products.Select(Function(product) New ProductInfo With { + .Id = product.Id, + .Name = product.Name, + .CategoryId = product.CategoryId + }).ToList() + categoriesLookup.ItemsSource = context.Categories.Select(Function(category) New CategoryInfo With { + .Id = category.Id, + .Name = category.Name + }).ToList() + End Using + End Sub + + Private Sub tableView_ValidateRow(ByVal sender As Object, ByVal e As GridRowValidationEventArgs) + Dim productInfo As ProductInfo = CType(e.Row, ProductInfo) + Using context = New NorthwindContext() + Dim product As Product + If view.FocusedRowHandle = DataControlBase.NewItemRowHandle Then + product = New Product() + context.Products.Add(product) + Else + product = context.Products.SingleOrDefault(Function(p) p.Id = productInfo.Id) + If product Is Nothing Then + Throw New NotImplementedException("The modified row no longer exists in the database. Handle this case according to your requirements.") + End If + End If + product.Name = productInfo.Name + product.CategoryId = productInfo.CategoryId + context.SaveChanges() + If view.FocusedRowHandle = DataControlBase.NewItemRowHandle Then + productInfo.Id = product.Id + End If + End Using + End Sub + + Private Sub grid_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) + If e.Key = Key.Delete Then + Dim productInfo As ProductInfo = CType(grid.SelectedItem, ProductInfo) + If productInfo Is Nothing Then + Return + End If + If DXMessageBox.Show(Me, "Are you sure you want to delete this row?", "Delete Row", MessageBoxButton.OKCancel) = MessageBoxResult.Cancel Then + Return + End If + Try + Using context = New NorthwindContext() + Dim result = context.Products.Find(productInfo.Id) + If result Is Nothing Then + Throw New NotImplementedException("The modified row no longer exists in the database. Handle this case according to your requirements.") + End If + context.Products.Remove(result) + context.SaveChanges() + view.Commands.DeleteFocusedRow.Execute(Nothing) + End Using + Catch ex As Exception + DXMessageBox.Show(ex.Message) + End Try + End If + End Sub + End Class +End Namespace diff --git a/VB/GridControlCRUDSimple/My Project/AssemblyInfo.vb b/VB/GridControlCRUDSimple/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2df644f --- /dev/null +++ b/VB/GridControlCRUDSimple/My Project/AssemblyInfo.vb @@ -0,0 +1,48 @@ +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.CompilerServices +Imports System.Runtime.InteropServices +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + + + + + + + + + +' Setting ComVisible to false makes the types in this assembly not visible +' to COM components. If you need to access a type in this assembly from +' COM, set the ComVisible attribute to true on that type. + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .csproj file +'inside a . For example, if you are using US english +'in your source files, set the to en-US. Then uncomment +'the NeutralResourceLanguage attribute below. Update the "en-US" in +'the line below to match the UICulture setting in the project file. + +'[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' [assembly: AssemblyVersion("1.0.*")] + + diff --git a/VB/GridControlCRUDSimple/My Project/Resources.Designer.vb b/VB/GridControlCRUDSimple/My Project/Resources.Designer.vb new file mode 100644 index 0000000..ff4afc2 --- /dev/null +++ b/VB/GridControlCRUDSimple/My Project/Resources.Designer.vb @@ -0,0 +1,65 @@ +Imports System + +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My.Resources + + + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + ' This class was auto-generated by the StronglyTypedResourceBuilder + ' class via a tool like ResGen or Visual Studio. + ' To add or remove a member, edit your .ResX file then rerun ResGen + ' with the /str option, or rebuild your VS project. + + + + Friend Module Resources + + Private resourceMan As System.Resources.ResourceManager + + Private resourceCulture As System.Globalization.CultureInfo + +' internal Resources() +' { +' } + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + + Friend ReadOnly Property ResourceManager() As System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As New System.Resources.ResourceManager("Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + + Friend Property Culture() As System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/VB/GridControlCRUDSimple/My Project/Resources.resx b/VB/GridControlCRUDSimple/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/VB/GridControlCRUDSimple/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/VB/GridControlCRUDSimple/My Project/Settings.Designer.vb b/VB/GridControlCRUDSimple/My Project/Settings.Designer.vb new file mode 100644 index 0000000..5b4f12c --- /dev/null +++ b/VB/GridControlCRUDSimple/My Project/Settings.Designer.vb @@ -0,0 +1,27 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Namespace My + + + + + Friend NotInheritable Partial Class Settings + Inherits System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As Settings = (CType(System.Configuration.ApplicationSettingsBase.Synchronized(New Settings()), Settings)) + + Public Shared ReadOnly Property [Default]() As Settings + Get + Return defaultInstance + End Get + End Property + End Class +End Namespace diff --git a/VB/GridControlCRUDSimple/My Project/Settings.settings b/VB/GridControlCRUDSimple/My Project/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/VB/GridControlCRUDSimple/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/VB/GridControlCRUDSimple/packages.config b/VB/GridControlCRUDSimple/packages.config new file mode 100644 index 0000000..9985587 --- /dev/null +++ b/VB/GridControlCRUDSimple/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file