Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/SpreadsheetMainDemo/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WinForms/VB/SpreadsheetMainDemo/DemoUtils.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.IO
Imports System.Windows.Forms
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports DevExpress.DXperience.Demos

Namespace DevExpress.XtraSpreadsheet.Demos
	Public Class SpreadSheetTutorialControlBase
		Inherits TutorialControlBase
		Public Overrides Property AutoMergeRibbon() As Boolean
			Get
				Return True
			End Get
			Set(ByVal value As Boolean)
			End Set
		End Property
	End Class
	Public Class DemoUtils
		Public Shared Function GetRelativePath(ByVal name As String) As String
			name = "Data\" & name
			Dim path As String = System.Windows.Forms.Application.StartupPath
			Dim s As String = "\"
			For i As Integer = 0 To 10
				If System.IO.File.Exists(path & s & name) Then
					Return (path & s & name)
				Else
					s &= "..\"
				End If
			Next i
			Return ""
		End Function
		Public Shared Function GetRelativeDirectoryPath(ByVal name As String) As String
			name = "Data\" & name
			Dim path As String = System.Windows.Forms.Application.StartupPath
			Dim s As String = "\"
			For i As Integer = 0 To 10
				If System.IO.Directory.Exists(path & s & name) Then
					Return (path & s & name)
				Else
					s &= "..\"
				End If
			Next i
			Return ""
		End Function
		'public static void SetConnectionString(System.Data.OleDb.OleDbConnection oleDbConnection, string path) {
		'    oleDbConnection.ConnectionString = String.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source={0};Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False", path);
		'}
	End Class
	'public class RtfLoadHelper {
	'    public static void Load(String fileName, RichEditControl richEditControl) {
	'        string path = DemoUtils.GetRelativePath(fileName);
	'        if (!String.IsNullOrEmpty(path))
	'            richEditControl.LoadDocument(path, DocumentFormat.Rtf);
	'    }
	'}
	'public class DocLoadHelper {
	'    public static void Load(string fileName, RichEditControl richEditControl) {
	'        string path = DemoUtils.GetRelativePath(fileName);
	'        if (!string.IsNullOrEmpty(path))
	'            richEditControl.LoadDocument(path, DocumentFormat.Doc);
	'    }
	'}
	'public class HtmlLoadHelper {
	'    public static void Load(String fileName, RichEditControl richEditControl) {
	'        string path = DemoUtils.GetRelativePath(fileName);
	'        if (!String.IsNullOrEmpty(path))
	'            richEditControl.LoadDocument(path, DocumentFormat.Html);
	'    }
	'}
	'public class OpenXmlLoadHelper {
	'    public static void Load(String fileName, RichEditControl richEditControl) {
	'        string path = DemoUtils.GetRelativePath(fileName);
	'        if (!String.IsNullOrEmpty(path))
	'            richEditControl.LoadDocument(path, DocumentFormat.OpenXml);
	'    }
	'}
	'public class PlainTextLoadHelper {
	'    public static void Load(String fileName, RichEditControl richEditControl) {
	'        string path = DemoUtils.GetRelativePath(fileName);
	'        if (!String.IsNullOrEmpty(path))
	'            richEditControl.LoadDocument(path, DocumentFormat.PlainText);
	'    }
	'}
	'public class SpellCheckerHelper {
	'    public static void AddDictionaries(SharedDictionaryStorage storage) {
	'        if (storage.Dictionaries.Count > 0)
	'            return;

	'        CultureInfo engCulture = new CultureInfo("en-us");
	'        SpellCheckerISpellDictionary dictionary = new SpellCheckerISpellDictionary(DemoUtils.GetRelativePath(@"american.xlg"), DemoUtils.GetRelativePath("english.aff"), engCulture);
	'        dictionary.AlphabetPath = DemoUtils.GetRelativePath("EnglishAlphabet.txt");
	'        storage.Dictionaries.Add(dictionary);
	'        SpellCheckerCustomDictionary customDictionary = new SpellCheckerCustomDictionary(DemoUtils.GetRelativePath("CustomEnglish.dic"), engCulture);
	'        storage.Dictionaries.Add(customDictionary);
	'    }
	'}
	'public class RichEditDemoExceptionsHandler {
	'    readonly RichEditControl control;
	'    public RichEditDemoExceptionsHandler(RichEditControl control) {
	'        this.control = control;
	'    }
	'    public void Install() {
	'        if (control != null)
	'            control.UnhandledException += OnRichEditControlUnhandledException;
	'    }

	'    protected virtual void OnRichEditControlUnhandledException(object sender, RichEditUnhandledExceptionEventArgs e) {
	'        try {
	'            if (e.Exception != null)
	'                throw e.Exception;
	'        }
	'        catch (RichEditUnsupportedFormatException ex) {
	'            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
	'            e.Handled = true;
	'        }
	'        catch (ExternalException ex) {
	'            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
	'            e.Handled = true;
	'        }
	'        catch (System.IO.IOException ex) {
	'            DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
	'            e.Handled = true;
	'        }
	'    }
	'}
End Namespace