//----------------------------------------------------------------------------
// OptionsForm.cs
//
// Options form for C1ReportDesigner application
//
// This is a part of the C1ReportDesigner package.
// Copyright (C) GrapeCity, Inc
// All rights reserved.
//
// This source code is intended as a supplement to the
// C1ReportDesigner control and related documentation 
// provided with the product.
// See these sources for detailed information regarding the
// C1ReportDesigner product.
//----------------------------------------------------------------------------
using System;
using System.Reflection;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

using C1.Win.C1ReportDesigner;
using C1.Win.Localization;
using C1.Win.C1Themes;

namespace ReportDesignerApp
{
    /// <summary>
    /// Summary description for OptionsForm.
    /// </summary>
    public class OptionsForm : System.Windows.Forms.Form
    {
        // ** fields
        private System.Windows.Forms.Button _btnOK;
        private System.Windows.Forms.Button _btnCancel;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.CheckBox _chkReload;
        private System.Windows.Forms.ComboBox _cmbUnits;
        private System.Windows.Forms.ComboBox _cmbExport;
        private System.Windows.Forms.CheckBox _chkEmbed;
        private System.Windows.Forms.CheckBox _chkUndo;
        private System.Windows.Forms.CheckBox _chkAutoSave;
        private System.Windows.Forms.CheckBox _chkCategorize;
        private System.Windows.Forms.CheckBox _chkFilterField;
        private System.Windows.Forms.CheckBox _chkShowGrid;
        private System.Windows.Forms.CheckBox _chkSnapToGrid;
        private System.Windows.Forms.CheckBox _chkShowSubreportContent;
        private System.Windows.Forms.CheckBox _chkSyntaxColoring;
        private System.Windows.Forms.CheckBox _chkSyntaxCheck;
        private System.Windows.Forms.Button _btnFont;
        private System.Windows.Forms.Label label3;
        private Font _scriptEditorFont = new Font("Courier New", 9);
        private CheckBox _chkSortReportList;
        private NumericUpDown _numSpacing;
        private Label label4;
        private C1.Design.ColorPickerControl _cpicGridColorMajor;
        private C1.Design.ColorPickerControl _cpicFieldEdgeColor;
        private Label label5;
        private Label label6;
        private Label label7;
        private C1.Design.ColorPickerControl _cpicGridColorMinor;
        private CheckBox _chkShowExportOptions;
        private ComboBox _cmbIsolationLevel;
        private Label label8;
        private TabControl tabControl1;
        private TabPage General;
        private TabPage DesignPane;
        private TabPage SaveLoad;
        private TabPage Connection;
        private TabPage ScriptEditor;
        private CheckBox _chkUseCreationGraphicsToRenderFields;
        private ComboBox _cmbThemeBuiltIn;
        private GroupBox _gbTheme;
        private RadioButton _rbtThemeCustom;
        private RadioButton _rbtThemeBuiltIn;
        private ComboBox _cmbThemeCustom;
        private Button _btnThemeApply;
        private TabPage Warnings;
        private CheckBox _chkWarn_ImportCrystalRASNotAvailable;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        // ** ctor
        public OptionsForm()
        {
            // initialize component
            InitializeComponent();



            //
            this._cmbUnits.Items.Clear();
            this._cmbUnits.Items.Add(Strings.OptionsForm.UnitsAuto);
            this._cmbUnits.Items.Add(Strings.OptionsForm.UnitsEnglish);
            this._cmbUnits.Items.Add(Strings.OptionsForm.UnitsMetric);
            this._cmbUnits.Items.Add(Strings.OptionsForm.UnitsCustom);

            //
            AutoScaleMode = AutoScaleMode.None;
            Font = MainForm.DefaultAppFont;

            // populate export options combo with main app's filter options
            _cmbExport.Items.Clear();
            string[] exportOptions = MainForm._exportFilter.Split('|');
            for (int i = 0; i < exportOptions.Length; i += 2)
                _cmbExport.Items.Add(exportOptions[i]);

            _cmbIsolationLevel.Items.Clear();
            IsolationLevel[] values = (IsolationLevel[])Enum.GetValues(typeof(IsolationLevel));
            for (int i = 0; i < values.Length; i++)
                _cmbIsolationLevel.Items.Add(values[i]);

            // populate themes:
            _cmbThemeBuiltIn.Items.AddRange(C1.Win.C1Themes.C1ThemeController.GetThemes());
            _cmbThemeCustom.Items.AddRange(C1ThemeLocator.GetAvailableThemes(C1ThemeLocator.LocationType.ThemesFolder).ToArray());
            if (_cmbThemeCustom.Items.Count == 0)
            {
                _cmbThemeCustom.Enabled = false;
                _rbtThemeCustom.Enabled = false;
            }
        }

        // ** dispose
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        //-----------------------------------------------------------------------
        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this._btnOK = new System.Windows.Forms.Button();
            this._btnCancel = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this._chkReload = new System.Windows.Forms.CheckBox();
            this._cmbUnits = new System.Windows.Forms.ComboBox();
            this._cmbExport = new System.Windows.Forms.ComboBox();
            this._chkEmbed = new System.Windows.Forms.CheckBox();
            this._chkUndo = new System.Windows.Forms.CheckBox();
            this._chkAutoSave = new System.Windows.Forms.CheckBox();
            this._chkCategorize = new System.Windows.Forms.CheckBox();
            this._chkFilterField = new System.Windows.Forms.CheckBox();
            this._chkSortReportList = new System.Windows.Forms.CheckBox();
            this._numSpacing = new System.Windows.Forms.NumericUpDown();
            this.label4 = new System.Windows.Forms.Label();
            this._chkShowSubreportContent = new System.Windows.Forms.CheckBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this._chkShowGrid = new System.Windows.Forms.CheckBox();
            this._chkSnapToGrid = new System.Windows.Forms.CheckBox();
            this._chkShowExportOptions = new System.Windows.Forms.CheckBox();
            this._btnFont = new System.Windows.Forms.Button();
            this._chkSyntaxColoring = new System.Windows.Forms.CheckBox();
            this._chkSyntaxCheck = new System.Windows.Forms.CheckBox();
            this.label3 = new System.Windows.Forms.Label();
            this._cmbIsolationLevel = new System.Windows.Forms.ComboBox();
            this.label8 = new System.Windows.Forms.Label();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.General = new System.Windows.Forms.TabPage();
            this._gbTheme = new System.Windows.Forms.GroupBox();
            this._btnThemeApply = new System.Windows.Forms.Button();
            this._rbtThemeCustom = new System.Windows.Forms.RadioButton();
            this._rbtThemeBuiltIn = new System.Windows.Forms.RadioButton();
            this._cmbThemeCustom = new System.Windows.Forms.ComboBox();
            this._cmbThemeBuiltIn = new System.Windows.Forms.ComboBox();
            this.DesignPane = new System.Windows.Forms.TabPage();
            this._chkUseCreationGraphicsToRenderFields = new System.Windows.Forms.CheckBox();
            this._cpicFieldEdgeColor = new C1.Design.ColorPickerControl();
            this._cpicGridColorMinor = new C1.Design.ColorPickerControl();
            this._cpicGridColorMajor = new C1.Design.ColorPickerControl();
            this.SaveLoad = new System.Windows.Forms.TabPage();
            this.Connection = new System.Windows.Forms.TabPage();
            this.ScriptEditor = new System.Windows.Forms.TabPage();
            this.Warnings = new System.Windows.Forms.TabPage();
            this._chkWarn_ImportCrystalRASNotAvailable = new System.Windows.Forms.CheckBox();
            ((System.ComponentModel.ISupportInitialize)(this._numSpacing)).BeginInit();
            this.tabControl1.SuspendLayout();
            this.General.SuspendLayout();
            this._gbTheme.SuspendLayout();
            this.DesignPane.SuspendLayout();
            this.SaveLoad.SuspendLayout();
            this.Connection.SuspendLayout();
            this.ScriptEditor.SuspendLayout();
            this.Warnings.SuspendLayout();
            this.SuspendLayout();
            // 
            // _btnOK
            // 
            this._btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this._btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._btnOK.Location = new System.Drawing.Point(350, 322);
            this._btnOK.Name = "_btnOK";
            this._btnOK.Size = new System.Drawing.Size(88, 24);
            this._btnOK.TabIndex = 5;
            this._btnOK.Text = "&OK";
            this._btnOK.Click += new System.EventHandler(this._btnOK_Click);
            // 
            // _btnCancel
            // 
            this._btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this._btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this._btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._btnCancel.Location = new System.Drawing.Point(446, 322);
            this._btnCancel.Name = "_btnCancel";
            this._btnCancel.Size = new System.Drawing.Size(88, 24);
            this._btnCancel.TabIndex = 6;
            this._btnCancel.Text = "&Cancel";
            this._btnCancel.Click += new System.EventHandler(this._btnCancel_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label1.Location = new System.Drawing.Point(11, 114);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(54, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Grid uni&ts:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label2.Location = new System.Drawing.Point(11, 110);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(108, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Default e&xport format:";
            // 
            // _chkReload
            // 
            this._chkReload.AutoSize = true;
            this._chkReload.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkReload.Location = new System.Drawing.Point(11, 11);
            this._chkReload.Name = "_chkReload";
            this._chkReload.Size = new System.Drawing.Size(151, 18);
            this._chkReload.TabIndex = 0;
            this._chkReload.Text = "&Reload last file on startup";
            // 
            // _cmbUnits
            // 
            this._cmbUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cmbUnits.Location = new System.Drawing.Point(176, 111);
            this._cmbUnits.Name = "_cmbUnits";
            this._cmbUnits.Size = new System.Drawing.Size(160, 21);
            this._cmbUnits.TabIndex = 5;
            this._cmbUnits.SelectedIndexChanged += new System.EventHandler(this._cmbUnits_SelectedIndexChanged);
            // 
            // _cmbExport
            // 
            this._cmbExport.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cmbExport.Location = new System.Drawing.Point(195, 107);
            this._cmbExport.Name = "_cmbExport";
            this._cmbExport.Size = new System.Drawing.Size(258, 21);
            this._cmbExport.TabIndex = 5;
            // 
            // _chkEmbed
            // 
            this._chkEmbed.AutoSize = true;
            this._chkEmbed.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkEmbed.Location = new System.Drawing.Point(11, 83);
            this._chkEmbed.Name = "_chkEmbed";
            this._chkEmbed.Size = new System.Drawing.Size(204, 18);
            this._chkEmbed.TabIndex = 4;
            this._chkEmbed.Text = "&Embed images into Xml when saving";
            // 
            // _chkUndo
            // 
            this._chkUndo.AutoSize = true;
            this._chkUndo.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkUndo.Location = new System.Drawing.Point(11, 35);
            this._chkUndo.Name = "_chkUndo";
            this._chkUndo.Size = new System.Drawing.Size(118, 18);
            this._chkUndo.TabIndex = 1;
            this._chkUndo.Text = "Enable &undo/redo";
            // 
            // _chkAutoSave
            // 
            this._chkAutoSave.AutoSize = true;
            this._chkAutoSave.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkAutoSave.Location = new System.Drawing.Point(11, 35);
            this._chkAutoSave.Name = "_chkAutoSave";
            this._chkAutoSave.Size = new System.Drawing.Size(181, 18);
            this._chkAutoSave.TabIndex = 2;
            this._chkAutoSave.Text = "&Save changes before rendering";
            // 
            // _chkCategorize
            // 
            this._chkCategorize.AutoSize = true;
            this._chkCategorize.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkCategorize.Location = new System.Drawing.Point(11, 11);
            this._chkCategorize.Name = "_chkCategorize";
            this._chkCategorize.Size = new System.Drawing.Size(143, 18);
            this._chkCategorize.TabIndex = 0;
            this._chkCategorize.Text = "&Categorize property grid";
            // 
            // _chkFilterField
            // 
            this._chkFilterField.AutoSize = true;
            this._chkFilterField.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkFilterField.Location = new System.Drawing.Point(11, 59);
            this._chkFilterField.Name = "_chkFilterField";
            this._chkFilterField.Size = new System.Drawing.Size(125, 18);
            this._chkFilterField.TabIndex = 2;
            this._chkFilterField.Text = "&Filter field properties";
            // 
            // _chkSortReportList
            // 
            this._chkSortReportList.AutoSize = true;
            this._chkSortReportList.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkSortReportList.Location = new System.Drawing.Point(11, 83);
            this._chkSortReportList.Name = "_chkSortReportList";
            this._chkSortReportList.Size = new System.Drawing.Size(96, 18);
            this._chkSortReportList.TabIndex = 3;
            this._chkSortReportList.Text = "Sor&t report list";
            // 
            // _numSpacing
            // 
            this._numSpacing.Enabled = false;
            this._numSpacing.Location = new System.Drawing.Point(176, 138);
            this._numSpacing.Maximum = new decimal(new int[] {
            32000,
            0,
            0,
            0});
            this._numSpacing.Name = "_numSpacing";
            this._numSpacing.Size = new System.Drawing.Size(160, 20);
            this._numSpacing.TabIndex = 7;
            this._numSpacing.Value = new decimal(new int[] {
            1440,
            0,
            0,
            0});
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label4.Location = new System.Drawing.Point(11, 140);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(69, 13);
            this.label4.TabIndex = 6;
            this.label4.Text = "Grid s&pacing:";
            // 
            // _chkShowSubreportContent
            // 
            this._chkShowSubreportContent.AutoSize = true;
            this._chkShowSubreportContent.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkShowSubreportContent.Location = new System.Drawing.Point(11, 59);
            this._chkShowSubreportContent.Name = "_chkShowSubreportContent";
            this._chkShowSubreportContent.Size = new System.Drawing.Size(145, 18);
            this._chkShowSubreportContent.TabIndex = 2;
            this._chkShowSubreportContent.Text = "Show su&breport content";
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label7.Location = new System.Drawing.Point(11, 194);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(83, 13);
            this.label7.TabIndex = 10;
            this.label7.Text = "Grid &minor color:";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label6.Location = new System.Drawing.Point(11, 221);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(90, 13);
            this.label6.TabIndex = 12;
            this.label6.Text = "Fiel&d edges color:";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label5.Location = new System.Drawing.Point(11, 167);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(83, 13);
            this.label5.TabIndex = 8;
            this.label5.Text = "Grid ma&jor color:";
            // 
            // _chkShowGrid
            // 
            this._chkShowGrid.AutoSize = true;
            this._chkShowGrid.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkShowGrid.Location = new System.Drawing.Point(11, 11);
            this._chkShowGrid.Name = "_chkShowGrid";
            this._chkShowGrid.Size = new System.Drawing.Size(79, 18);
            this._chkShowGrid.TabIndex = 0;
            this._chkShowGrid.Text = "Show &grid";
            // 
            // _chkSnapToGrid
            // 
            this._chkSnapToGrid.AutoSize = true;
            this._chkSnapToGrid.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkSnapToGrid.Location = new System.Drawing.Point(11, 35);
            this._chkSnapToGrid.Name = "_chkSnapToGrid";
            this._chkSnapToGrid.Size = new System.Drawing.Size(89, 18);
            this._chkSnapToGrid.TabIndex = 1;
            this._chkSnapToGrid.Text = "S&nap to grid";
            // 
            // _chkShowExportOptions
            // 
            this._chkShowExportOptions.AutoSize = true;
            this._chkShowExportOptions.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkShowExportOptions.Location = new System.Drawing.Point(11, 59);
            this._chkShowExportOptions.Name = "_chkShowExportOptions";
            this._chkShowExportOptions.Size = new System.Drawing.Size(171, 18);
            this._chkShowExportOptions.TabIndex = 3;
            this._chkShowExportOptions.Text = "Sho&w options when exporting";
            // 
            // _btnFont
            // 
            this._btnFont.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._btnFont.Location = new System.Drawing.Point(101, 59);
            this._btnFont.Name = "_btnFont";
            this._btnFont.Size = new System.Drawing.Size(285, 24);
            this._btnFont.TabIndex = 3;
            this._btnFont.Text = "Courier New, 9pt";
            this._btnFont.Click += new System.EventHandler(this._btnFont_Click);
            // 
            // _chkSyntaxColoring
            // 
            this._chkSyntaxColoring.AutoSize = true;
            this._chkSyntaxColoring.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkSyntaxColoring.Location = new System.Drawing.Point(11, 35);
            this._chkSyntaxColoring.Name = "_chkSyntaxColoring";
            this._chkSyntaxColoring.Size = new System.Drawing.Size(104, 18);
            this._chkSyntaxColoring.TabIndex = 1;
            this._chkSyntaxColoring.Text = "S&yntax coloring";
            // 
            // _chkSyntaxCheck
            // 
            this._chkSyntaxCheck.AutoSize = true;
            this._chkSyntaxCheck.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkSyntaxCheck.Location = new System.Drawing.Point(11, 11);
            this._chkSyntaxCheck.Name = "_chkSyntaxCheck";
            this._chkSyntaxCheck.Size = new System.Drawing.Size(134, 18);
            this._chkSyntaxCheck.TabIndex = 0;
            this._chkSyntaxCheck.Text = "&Auto syntax checking";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.label3.Location = new System.Drawing.Point(11, 65);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(31, 13);
            this.label3.TabIndex = 2;
            this.label3.Text = "F&ont:";
            // 
            // _cmbIsolationLevel
            // 
            this._cmbIsolationLevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cmbIsolationLevel.FormattingEnabled = true;
            this._cmbIsolationLevel.Location = new System.Drawing.Point(14, 42);
            this._cmbIsolationLevel.Name = "_cmbIsolationLevel";
            this._cmbIsolationLevel.Size = new System.Drawing.Size(200, 21);
            this._cmbIsolationLevel.TabIndex = 1;
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(11, 14);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(398, 13);
            this.label8.TabIndex = 0;
            this.label8.Text = "Transaction isolation level for newly created reports (the default is ReadCommitt" +
    "ed):";
            // 
            // tabControl1
            // 
            this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tabControl1.Controls.Add(this.General);
            this.tabControl1.Controls.Add(this.DesignPane);
            this.tabControl1.Controls.Add(this.SaveLoad);
            this.tabControl1.Controls.Add(this.Connection);
            this.tabControl1.Controls.Add(this.ScriptEditor);
            this.tabControl1.Controls.Add(this.Warnings);
            this.tabControl1.Location = new System.Drawing.Point(12, 12);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(522, 301);
            this.tabControl1.TabIndex = 7;
            // 
            // General
            // 
            this.General.Controls.Add(this._gbTheme);
            this.General.Controls.Add(this._chkSortReportList);
            this.General.Controls.Add(this._chkFilterField);
            this.General.Controls.Add(this._chkCategorize);
            this.General.Controls.Add(this._chkUndo);
            this.General.Location = new System.Drawing.Point(4, 22);
            this.General.Name = "General";
            this.General.Padding = new System.Windows.Forms.Padding(8);
            this.General.Size = new System.Drawing.Size(514, 275);
            this.General.TabIndex = 0;
            this.General.Text = "General";
            this.General.UseVisualStyleBackColor = true;
            // 
            // _gbTheme
            // 
            this._gbTheme.Controls.Add(this._btnThemeApply);
            this._gbTheme.Controls.Add(this._rbtThemeCustom);
            this._gbTheme.Controls.Add(this._rbtThemeBuiltIn);
            this._gbTheme.Controls.Add(this._cmbThemeCustom);
            this._gbTheme.Controls.Add(this._cmbThemeBuiltIn);
            this._gbTheme.Location = new System.Drawing.Point(11, 107);
            this._gbTheme.Name = "_gbTheme";
            this._gbTheme.Size = new System.Drawing.Size(393, 104);
            this._gbTheme.TabIndex = 4;
            this._gbTheme.TabStop = false;
            this._gbTheme.Text = "Designer Theme";
            // 
            // _btnThemeApply
            // 
            this._btnThemeApply.Location = new System.Drawing.Point(228, 72);
            this._btnThemeApply.Name = "_btnThemeApply";
            this._btnThemeApply.Size = new System.Drawing.Size(159, 23);
            this._btnThemeApply.TabIndex = 4;
            this._btnThemeApply.Text = "Apply (cannot be undone)";
            this._btnThemeApply.UseVisualStyleBackColor = true;
            this._btnThemeApply.Click += new System.EventHandler(this._btnThemeApply_Click);
            // 
            // _rbtThemeCustom
            // 
            this._rbtThemeCustom.AutoSize = true;
            this._rbtThemeCustom.Location = new System.Drawing.Point(6, 46);
            this._rbtThemeCustom.Name = "_rbtThemeCustom";
            this._rbtThemeCustom.Size = new System.Drawing.Size(95, 17);
            this._rbtThemeCustom.TabIndex = 2;
            this._rbtThemeCustom.TabStop = true;
            this._rbtThemeCustom.Text = "Themes folder:";
            this._rbtThemeCustom.UseVisualStyleBackColor = true;
            // 
            // _rbtThemeBuiltIn
            // 
            this._rbtThemeBuiltIn.AutoSize = true;
            this._rbtThemeBuiltIn.Location = new System.Drawing.Point(6, 19);
            this._rbtThemeBuiltIn.Name = "_rbtThemeBuiltIn";
            this._rbtThemeBuiltIn.Size = new System.Drawing.Size(59, 17);
            this._rbtThemeBuiltIn.TabIndex = 0;
            this._rbtThemeBuiltIn.TabStop = true;
            this._rbtThemeBuiltIn.Text = "Built in:";
            this._rbtThemeBuiltIn.UseVisualStyleBackColor = true;
            // 
            // _cmbThemeCustom
            // 
            this._cmbThemeCustom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cmbThemeCustom.FormattingEnabled = true;
            this._cmbThemeCustom.Location = new System.Drawing.Point(129, 46);
            this._cmbThemeCustom.Name = "_cmbThemeCustom";
            this._cmbThemeCustom.Size = new System.Drawing.Size(258, 21);
            this._cmbThemeCustom.TabIndex = 3;
            this._cmbThemeCustom.SelectedIndexChanged += new System.EventHandler(this._cmbThemeCustom_SelectedIndexChanged);
            // 
            // _cmbThemeBuiltIn
            // 
            this._cmbThemeBuiltIn.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cmbThemeBuiltIn.FormattingEnabled = true;
            this._cmbThemeBuiltIn.Location = new System.Drawing.Point(129, 19);
            this._cmbThemeBuiltIn.Name = "_cmbThemeBuiltIn";
            this._cmbThemeBuiltIn.Size = new System.Drawing.Size(258, 21);
            this._cmbThemeBuiltIn.TabIndex = 1;
            this._cmbThemeBuiltIn.SelectedIndexChanged += new System.EventHandler(this._cmbThemeBuiltIn_SelectedIndexChanged);
            // 
            // DesignPane
            // 
            this.DesignPane.Controls.Add(this._chkUseCreationGraphicsToRenderFields);
            this.DesignPane.Controls.Add(this._numSpacing);
            this.DesignPane.Controls.Add(this._chkShowGrid);
            this.DesignPane.Controls.Add(this._chkSnapToGrid);
            this.DesignPane.Controls.Add(this.label4);
            this.DesignPane.Controls.Add(this._chkShowSubreportContent);
            this.DesignPane.Controls.Add(this.label7);
            this.DesignPane.Controls.Add(this._cmbUnits);
            this.DesignPane.Controls.Add(this.label6);
            this.DesignPane.Controls.Add(this.label1);
            this.DesignPane.Controls.Add(this.label5);
            this.DesignPane.Controls.Add(this._cpicFieldEdgeColor);
            this.DesignPane.Controls.Add(this._cpicGridColorMinor);
            this.DesignPane.Controls.Add(this._cpicGridColorMajor);
            this.DesignPane.Location = new System.Drawing.Point(4, 22);
            this.DesignPane.Name = "DesignPane";
            this.DesignPane.Padding = new System.Windows.Forms.Padding(8);
            this.DesignPane.Size = new System.Drawing.Size(514, 275);
            this.DesignPane.TabIndex = 1;
            this.DesignPane.Text = "Design Pane";
            this.DesignPane.UseVisualStyleBackColor = true;
            // 
            // _chkUseCreationGraphicsToRenderFields
            // 
            this._chkUseCreationGraphicsToRenderFields.AutoSize = true;
            this._chkUseCreationGraphicsToRenderFields.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this._chkUseCreationGraphicsToRenderFields.Location = new System.Drawing.Point(11, 83);
            this._chkUseCreationGraphicsToRenderFields.Name = "_chkUseCreationGraphicsToRenderFields";
            this._chkUseCreationGraphicsToRenderFields.Size = new System.Drawing.Size(360, 18);
            this._chkUseCreationGraphicsToRenderFields.TabIndex = 3;
            this._chkUseCreationGraphicsToRenderFields.Text = "Use C1Report.CreationGraphics as reference graphics to render fields";
            // 
            // _cpicFieldEdgeColor
            // 
            this._cpicFieldEdgeColor.Color = System.Drawing.Color.Transparent;
            this._cpicFieldEdgeColor.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            this._cpicFieldEdgeColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cpicFieldEdgeColor.FormattingEnabled = true;
            this._cpicFieldEdgeColor.Items.AddRange(new object[] {
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""});
            this._cpicFieldEdgeColor.Location = new System.Drawing.Point(176, 218);
            this._cpicFieldEdgeColor.Name = "_cpicFieldEdgeColor";
            this._cpicFieldEdgeColor.Size = new System.Drawing.Size(160, 21);
            this._cpicFieldEdgeColor.TabIndex = 13;
            // 
            // _cpicGridColorMinor
            // 
            this._cpicGridColorMinor.Color = System.Drawing.Color.Transparent;
            this._cpicGridColorMinor.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            this._cpicGridColorMinor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cpicGridColorMinor.FormattingEnabled = true;
            this._cpicGridColorMinor.Items.AddRange(new object[] {
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""});
            this._cpicGridColorMinor.Location = new System.Drawing.Point(176, 191);
            this._cpicGridColorMinor.Name = "_cpicGridColorMinor";
            this._cpicGridColorMinor.Size = new System.Drawing.Size(160, 21);
            this._cpicGridColorMinor.TabIndex = 11;
            // 
            // _cpicGridColorMajor
            // 
            this._cpicGridColorMajor.Color = System.Drawing.Color.Transparent;
            this._cpicGridColorMajor.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
            this._cpicGridColorMajor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._cpicGridColorMajor.FormattingEnabled = true;
            this._cpicGridColorMajor.Items.AddRange(new object[] {
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            "",
            ""});
            this._cpicGridColorMajor.Location = new System.Drawing.Point(176, 164);
            this._cpicGridColorMajor.Name = "_cpicGridColorMajor";
            this._cpicGridColorMajor.Size = new System.Drawing.Size(160, 21);
            this._cpicGridColorMajor.TabIndex = 9;
            // 
            // SaveLoad
            // 
            this.SaveLoad.Controls.Add(this._cmbExport);
            this.SaveLoad.Controls.Add(this.label2);
            this.SaveLoad.Controls.Add(this._chkEmbed);
            this.SaveLoad.Controls.Add(this._chkShowExportOptions);
            this.SaveLoad.Controls.Add(this._chkAutoSave);
            this.SaveLoad.Controls.Add(this._chkReload);
            this.SaveLoad.Location = new System.Drawing.Point(4, 22);
            this.SaveLoad.Name = "SaveLoad";
            this.SaveLoad.Padding = new System.Windows.Forms.Padding(8);
            this.SaveLoad.Size = new System.Drawing.Size(514, 275);
            this.SaveLoad.TabIndex = 2;
            this.SaveLoad.Text = "Save/Load";
            this.SaveLoad.UseVisualStyleBackColor = true;
            // 
            // Connection
            // 
            this.Connection.Controls.Add(this.label8);
            this.Connection.Controls.Add(this._cmbIsolationLevel);
            this.Connection.Location = new System.Drawing.Point(4, 22);
            this.Connection.Name = "Connection";
            this.Connection.Padding = new System.Windows.Forms.Padding(8);
            this.Connection.Size = new System.Drawing.Size(514, 275);
            this.Connection.TabIndex = 3;
            this.Connection.Text = "Connection ";
            this.Connection.UseVisualStyleBackColor = true;
            // 
            // ScriptEditor
            // 
            this.ScriptEditor.Controls.Add(this.label3);
            this.ScriptEditor.Controls.Add(this._btnFont);
            this.ScriptEditor.Controls.Add(this._chkSyntaxColoring);
            this.ScriptEditor.Controls.Add(this._chkSyntaxCheck);
            this.ScriptEditor.Location = new System.Drawing.Point(4, 22);
            this.ScriptEditor.Name = "ScriptEditor";
            this.ScriptEditor.Padding = new System.Windows.Forms.Padding(8);
            this.ScriptEditor.Size = new System.Drawing.Size(514, 275);
            this.ScriptEditor.TabIndex = 4;
            this.ScriptEditor.Text = "Script Editor";
            this.ScriptEditor.UseVisualStyleBackColor = true;
            // 
            // Warnings
            // 
            this.Warnings.Controls.Add(this._chkWarn_ImportCrystalRASNotAvailable);
            this.Warnings.Location = new System.Drawing.Point(4, 22);
            this.Warnings.Name = "Warnings";
            this.Warnings.Padding = new System.Windows.Forms.Padding(3);
            this.Warnings.Size = new System.Drawing.Size(514, 275);
            this.Warnings.TabIndex = 5;
            this.Warnings.Text = "Warnings";
            this.Warnings.UseVisualStyleBackColor = true;
            // 
            // _chkWarn_ImportCrystalRASNotAvailable
            // 
            this._chkWarn_ImportCrystalRASNotAvailable.AutoSize = true;
            this._chkWarn_ImportCrystalRASNotAvailable.Location = new System.Drawing.Point(11, 35);
            this._chkWarn_ImportCrystalRASNotAvailable.Name = "_chkWarn_ImportCrystalRASNotAvailable";
            this._chkWarn_ImportCrystalRASNotAvailable.Size = new System.Drawing.Size(301, 17);
            this._chkWarn_ImportCrystalRASNotAvailable.TabIndex = 2;
            this._chkWarn_ImportCrystalRASNotAvailable.Text = "Import from Crystal Reports: warn if &RAS API is unavailable";
            this._chkWarn_ImportCrystalRASNotAvailable.UseVisualStyleBackColor = true;
            // 
            // OptionsForm
            // 
            this.AcceptButton = this._btnOK;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this._btnCancel;
            this.ClientSize = new System.Drawing.Size(544, 353);
            this.Controls.Add(this.tabControl1);
            this.Controls.Add(this._btnOK);
            this.Controls.Add(this._btnCancel);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "OptionsForm";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "C1ReportDesigner Options";
            ((System.ComponentModel.ISupportInitialize)(this._numSpacing)).EndInit();
            this.tabControl1.ResumeLayout(false);
            this.General.ResumeLayout(false);
            this.General.PerformLayout();
            this._gbTheme.ResumeLayout(false);
            this._gbTheme.PerformLayout();
            this.DesignPane.ResumeLayout(false);
            this.DesignPane.PerformLayout();
            this.SaveLoad.ResumeLayout(false);
            this.SaveLoad.PerformLayout();
            this.Connection.ResumeLayout(false);
            this.Connection.PerformLayout();
            this.ScriptEditor.ResumeLayout(false);
            this.ScriptEditor.PerformLayout();
            this.Warnings.ResumeLayout(false);
            this.Warnings.PerformLayout();
            this.ResumeLayout(false);

        }
        #endregion

        //-----------------------------------------------------------------------
        #region ** event handlers

        private void _btnOK_Click(object sender, System.EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
        private void _btnCancel_Click(object sender, System.EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
        private void _btnFont_Click(object sender, System.EventArgs e)
        {
            using (FontDialog dlg = new FontDialog())
            {
                dlg.Font = _scriptEditorFont;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ScriptEditorFont = dlg.Font;
                }
            }
        }
        private void _cmbUnits_SelectedIndexChanged(object sender, EventArgs e)
        {
            _numSpacing.Enabled = _cmbUnits.SelectedIndex == 3; // Custom
        }

        #endregion

        //-----------------------------------------------------------------------
        #region ** object model
        public MainForm MainForm { get; set; }

        public string StartTabName
        {
            get { return tabControl1.SelectedTab.Name; }
            set
            {
                try
                {
                    tabControl1.SelectedTab = tabControl1.TabPages[value];
                }
                catch
                {
                    tabControl1.SelectedIndex = 0;
                }
            }
        }
        
        public string Theme
        {
            get
            {
                if (_rbtThemeCustom.Checked)
                    return new C1ThemeLocator(C1ThemeLocator.LocationType.ThemesFolder, _cmbThemeCustom.Text);
                else
                    return new C1ThemeLocator(C1ThemeLocator.LocationType.Builtin, _cmbThemeBuiltIn.Text);
            }
            set
            {
                C1ThemeLocator.LocationType locType;
                string themeName = new C1ThemeLocator(value).GetThemeName(out locType);
                bool custom = locType == C1ThemeLocator.LocationType.ThemesFolder;

                // try to set custom theme
                if (custom)
                {
                    _cmbThemeCustom.SelectedItem = themeName;
                    custom = _cmbThemeCustom.SelectedIndex != -1;
                }
                // set theme for good:
                if (custom)
                {
                    _rbtThemeCustom.Checked = true;
                    _cmbThemeBuiltIn.SelectedIndex = -1;
                }
                else
                {
                    _rbtThemeBuiltIn.Checked = true;
                    _cmbThemeBuiltIn.SelectedItem = themeName;
                    _cmbThemeCustom.SelectedIndex = -1;
                }
            }
        }

        public GridUnitsEnum GridUnits
        {
            get
            {
                switch (_cmbUnits.SelectedIndex)
                {
                    case 0: return GridUnitsEnum.Auto;
                    case 1: return GridUnitsEnum.English;
                    case 2: return GridUnitsEnum.Metric;
                    case 3: return GridUnitsEnum.Custom;
                }
                return GridUnitsEnum.Auto;
            }
            set
            {
                if (value == GridUnitsEnum.Auto) _cmbUnits.SelectedIndex = 0;
                if (value == GridUnitsEnum.English) _cmbUnits.SelectedIndex = 1;
                if (value == GridUnitsEnum.Metric) _cmbUnits.SelectedIndex = 2;
                if (value == GridUnitsEnum.Custom) _cmbUnits.SelectedIndex = 3;
            }
        }

        public int GridSpacing
        {
            get { return (int)_numSpacing.Value; }
            set { _numSpacing.Value = value; }
        }
        
        public bool ShowGrid
        {
            get { return _chkShowGrid.Checked; }
            set { _chkShowGrid.Checked = value; }
        }
        
        public bool SnapToGrid
        {
            get { return _chkSnapToGrid.Checked; }
            set { _chkSnapToGrid.Checked = value; }
        }
        
        public Color GridColorMajor
        {
            get { return _cpicGridColorMajor.Color; }
            set { _cpicGridColorMajor.Color = value; }
        }
        
        public Color GridColorMinor
        {
            get { return _cpicGridColorMinor.Color; }
            set { _cpicGridColorMinor.Color = value; }
        }
        
        public Color FieldEdgeColor
        {
            get { return _cpicFieldEdgeColor.Color; }
            set { _cpicFieldEdgeColor.Color = value; }
        }
        
        public int DefaultExportFormat
        {
            get { return _cmbExport.SelectedIndex + 1; }
            set
            {
                value--;
                if (value >= 0 && value < _cmbExport.Items.Count)
                    _cmbExport.SelectedIndex = value;
            }
        }
        
        public bool LoadOnStartup
        {
            get { return _chkReload.Checked; }
            set { _chkReload.Checked = value; }
        }
        
        
        public bool EmbedImages
        {
            get { return _chkEmbed.Checked; }
            set { _chkEmbed.Checked = value; }
        }
        
        public bool EnableUndo
        {
            get { return _chkUndo.Checked; }
            set { _chkUndo.Checked = value; }
        }
        
        public bool SortReportList
        {
            get { return _chkSortReportList.Checked; }
            set { _chkSortReportList.Checked = value; }
        }
        
        public bool AutoSave
        {
            get { return _chkAutoSave.Checked; }
            set { _chkAutoSave.Checked = value; }
        }
        
        public bool ShowExportOptions
        {
            get { return _chkShowExportOptions.Checked; }
            set { _chkShowExportOptions.Checked = value; }
        }
        
        public bool CategorizeProperties
        {
            get { return _chkCategorize.Checked; }
            set { _chkCategorize.Checked = value; }
        }
        
        public bool UseFieldWrappers
        {
            get { return _chkFilterField.Checked; }
            set { _chkFilterField.Checked = value; }
        }
        
        public bool ShowSubreportContent
        {
            get { return _chkShowSubreportContent.Checked; }
            set { _chkShowSubreportContent.Checked = value; }
        }
        
        public bool SyntaxCheck
        {
            get { return _chkSyntaxCheck.Checked; }
            set { _chkSyntaxCheck.Checked = value; }
        }
        
        public bool SyntaxColoring
        {
            get { return _chkSyntaxColoring.Checked; }
            set { _chkSyntaxColoring.Checked = value; }
        }
        
        public Font ScriptEditorFont
        {
            get { return _scriptEditorFont; }
            set
            {
                if (value != null)
                {
                    _scriptEditorFont = value;
                    _btnFont.Text = string.Format(Strings.OptionsForm.FontFmt, value.Name, Math.Round(value.Size));
                }
            }
        }
        
        public IsolationLevel IsolationLevel
        {
            get { return (IsolationLevel)_cmbIsolationLevel.SelectedItem; }
            set { _cmbIsolationLevel.SelectedItem = value; }
        }
        
        public bool UseCreationGraphicsToRenderFields
        {
            get { return _chkUseCreationGraphicsToRenderFields.Checked; }
            set { _chkUseCreationGraphicsToRenderFields.Checked = value; }
        }
        
        public bool WarnImportCrystalRASNotAvailable
        {
            get { return  _chkWarn_ImportCrystalRASNotAvailable.Checked; }
            set { _chkWarn_ImportCrystalRASNotAvailable.Checked = value; }
        }
        #endregion

        private void _cmbThemeBuiltIn_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_cmbThemeBuiltIn.SelectedIndex != -1)
            {
                _rbtThemeBuiltIn.Checked = true;
                _cmbThemeCustom.SelectedIndex = -1;
            }
        }

        private void _cmbThemeCustom_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_cmbThemeCustom.SelectedIndex != -1)
            {
                _rbtThemeCustom.Checked = true;
                _cmbThemeBuiltIn.SelectedIndex = -1;
            }
        }

        private void _btnThemeApply_Click(object sender, EventArgs e)
        {
            if (MainForm != null)
            {
                // NOTE: when switching between "modern" and "visual style" based themes, C1RibbonForm
                // recreates its handle, which leads to MainForm starting to react to mouse input etc
                // while the modal options form is still on. To avoid this, we use HandleCreated event
                // to disable MainForm via EnableWindow - which does not visually disables the controls
                // on it.
                MainForm.HandleCreated += MainForm_HandleCreated;
                MainForm.Theme = this.Theme;
                this.BringToFront();
                MainForm.HandleCreated -= MainForm_HandleCreated;
            }
        }

        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
        public static extern int EnableWindow(
            IntPtr hWnd,
            int bEnable);

        private void MainForm_HandleCreated(object sender, EventArgs e)
        {
            // SetWindowLong(this.Handle, -8, MainForm.Handle);
            EnableWindow(MainForm.Handle, 0);
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
            if (!e.Cancel)
                EnableWindow(MainForm.Handle, 1);
        }
    }
}
