-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinApplication.cs
65 lines (63 loc) · 3.17 KB
/
WinApplication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.ComponentModel;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win;
using System.Collections.Generic;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Win.Utils;
using DevExpress.ExpressApp.Xpo;
namespace ExtendModel.Win {
// For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/DevExpressExpressAppWinWinApplicationMembersTopicAll.aspx
public partial class ExtendModelWindowsFormsApplication : WinApplication {
#region Default XAF configuration options (https://www.devexpress.com/kb=T501418)
static ExtendModelWindowsFormsApplication() {
DevExpress.Persistent.Base.PasswordCryptographer.EnableRfc2898 = true;
DevExpress.Persistent.Base.PasswordCryptographer.SupportLegacySha512 = false;
DevExpress.ExpressApp.Utils.ImageLoader.Instance.UseSvgImages = true;
}
private void InitializeDefaults() {
LinkNewObjectToParentImmediately = false;
OptimizedControllersCreation = true;
UseLightStyle = true;
SplashScreen = new DXSplashScreen(typeof(XafSplashScreen), new DefaultOverlayFormOptions());
ExecuteStartupLogicBeforeClosingLogonWindow = true;
}
#endregion
public ExtendModelWindowsFormsApplication() {
InitializeComponent();
InitializeDefaults();
}
protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
args.ObjectSpaceProviders.Add(new XPObjectSpaceProvider(XPObjectSpaceProvider.GetDataStoreProvider(args.ConnectionString, args.Connection, true), false));
args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null));
}
private void ExtendModelWindowsFormsApplication_CustomizeLanguagesList(object sender, CustomizeLanguagesListEventArgs e) {
string userLanguageName = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
if(userLanguageName != "en-US" && e.Languages.IndexOf(userLanguageName) == -1) {
e.Languages.Add(userLanguageName);
}
}
private void ExtendModelWindowsFormsApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
#if EASYTEST
e.Updater.Update();
e.Handled = true;
#else
if(System.Diagnostics.Debugger.IsAttached) {
e.Updater.Update();
e.Handled = true;
}
else {
string message = "The application cannot connect to the specified database, " +
"because the database doesn't exist, its version is older " +
"than that of the application or its schema does not match " +
"the ORM data model structure. To avoid this error, use one " +
"of the solutions from the https://www.devexpress.com/kb=T367835 KB Article.";
if(e.CompatibilityError != null && e.CompatibilityError.Exception != null) {
message += "\r\n\r\nInner exception: " + e.CompatibilityError.Exception.Message;
}
throw new InvalidOperationException(message);
}
#endif
}
}
}