Mini Kabibi Habibi

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

using System;
using System.Data;
using System.IO;
using System.Windows.Forms;
using System.Globalization;
using System.Runtime.InteropServices;
using DevExpress.DXperience.Demos;

namespace DevExpress.XtraSpreadsheet.Demos {
    public class SpreadSheetTutorialControlBase : TutorialControlBase {
        public override bool AutoMergeRibbon {
            get { return true; }
            set { }
        }
    }
    public class DemoUtils {
        public static string GetRelativePath(string name) {
            name = "Data\\" + name;
            string path = System.Windows.Forms.Application.StartupPath;
            string s = "\\";
            for(int i = 0; i <= 10; i++) {
                if(System.IO.File.Exists(path + s + name))
                    return (path + s + name);
                else
                    s += "..\\";
            }
            return "";
        }
        public static string GetRelativeDirectoryPath(string name) {
            name = "Data\\" + name;
            string path = System.Windows.Forms.Application.StartupPath;
            string s = "\\";
            for(int i = 0; i <= 10; i++) {
                if(System.IO.Directory.Exists(path + s + name))
                    return (path + s + name);
                else
                    s += "..\\";
            }
            return "";
        }
        //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);
        //}
    }
    //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;
    //        }
    //    }
    //}
}