Example #1
0
        // ** ctor
        public OptionsForm()
        {
            // initialize component
            InitializeComponent();
            //
            AutoScaleMode = AutoScaleMode.None;
            Font          = MainForm.DefaultAppFont;

            if (IntPtr.Size == 4)
            {
                _chkWarn_AppIn64bitMode.Visible = false;
            }

            // Populate static option lists:

            // Grid units:
            this._cmbGridUnits.Items.Clear();
            this._cmbGridUnits.Items.Add(Strings.OptionsForm.UnitsAuto);
            this._cmbGridUnits.Items.Add(Strings.OptionsForm.UnitsEnglish);
            this._cmbGridUnits.Items.Add(Strings.OptionsForm.UnitsMetric);
            this._cmbGridUnits.Items.Add(Strings.OptionsForm.UnitsCustom);
            // Data isolation level:
            _cmbIsolationLevel.Items.Clear();
            IsolationLevel[] values = (IsolationLevel[])Enum.GetValues(typeof(IsolationLevel));
            for (int i = 0; i < values.Length; i++)
            {
                _cmbIsolationLevel.Items.Add(values[i]);
            }
            // Themes:
            _cmbThemeBuiltIn.Items.AddRange(C1ThemeController.GetThemes());
            _cmbThemeCustom.Items.AddRange(C1ThemeLocator.GetAvailableThemes(C1ThemeLocator.LocationType.ThemesFolder).ToArray());
            if (_cmbThemeCustom.Items.Count == 0)
            {
                _cmbThemeCustom.Enabled = false;
                _rbtThemeCustom.Enabled = false;
            }
            //
            _chkReload_CheckedChanged(_chkReload, EventArgs.Empty);
            //
            _btnResetLayout.Enabled = MainForm.TheMainForm.ReportDesignMode;
        }
Example #2
0
        public ScriptEditorFormEx(
            MainForm mainForm,
            C1FlexReport report,
            string scriptContextName,
            // either this:
            ITypeDescriptorContext typeDescriptorContext,
            // or these two:
            object propertyOwner,
            string propertyName,
            // if non-null, used instead of derived name for display ONLY (does not affect script item key)
            string displayName,
            //
            bool isScript)
            : this()
        {
            System.Diagnostics.Debug.Assert(typeDescriptorContext != null || (propertyOwner != null && !string.IsNullOrEmpty(propertyName)));

            AutoScaleMode       = AutoScaleMode.None;
            Font                = MainForm.DefaultAppFont;
            _mainForm           = mainForm;
            _report             = report;
            _contexts           = new EditorScriptContextCollection(this, report, _mainForm.FlexDesigner);
            _activeScriptEditor = _scriptEditor0;
            //
            rbnMain.BeginUpdate();
            //
            _scriptEditor1.TextBox.Font          = _scriptEditor0.TextBox.Font = _mainForm._scriptEditorFont;
            _scriptEditor1.EditorBackgroundColor = _scriptEditor0.EditorBackgroundColor = _mainForm._scriptEditorBackColor;
            _scriptEditor1.EditorTextColor       = _scriptEditor0.EditorTextColor = _mainForm._scriptEditorForeColor;
            _scriptEditor1.SyntaxAutoCheck       = _scriptEditor0.SyntaxAutoCheck = _mainForm._syntaxCheck;
            _scriptEditor1.AutoSaveCurrentScript = _scriptEditor0.AutoSaveCurrentScript = _mainForm._scriptEditorAutoSave;
            // init options in ribbon UI:
            rbEditorFontName.Text             = _mainForm._scriptEditorFont.Name;
            rbBackgroundColor.Color           = _mainForm._scriptEditorBackColor;
            rbTextColor.Color                 = _mainForm._scriptEditorForeColor;
            rbSyntaxHighlight.Checked         = _mainForm._syntaxColoring;
            rbSyntaxAutoCheck.Checked         = _mainForm._syntaxCheck;
            rbAutoSave.Checked                = _mainForm._scriptEditorAutoSave;
            rbDataSourceFilterWarning.Checked = _mainForm._scriptEditorDataSourceFilterWarning;
            // font size:
            for (int i = c_minFontSize; i <= c_maxFontSize; ++i)
            {
                rbFontSize.Items.Add(i.ToString());
            }
            rbFontSize.Text = ((int)Math.Round(_scriptEditor0.EditorFont.Size)).ToString();

            _scriptEditor0.TextBox.GotFocus         += ScriptEditorGotFocus;
            _scriptEditor0.CurrentScriptItemChanged += CurrentScriptItemChanged;
            _scriptEditor0.CurrentScriptTextChanged += CurrentScriptTextChanged;
            _scriptEditor0.ScriptWritten            += ScriptWritten;
            _scriptEditor0.TextSelectionChanged     += TextSelectionChanged;
            _scriptEditor0.SyntaxCheckNeeded        += SyntaxCheckNeeded;

            _scriptEditor1.TextBox.GotFocus         += ScriptEditorGotFocus;
            _scriptEditor1.CurrentScriptItemChanged += CurrentScriptItemChanged;
            _scriptEditor1.CurrentScriptTextChanged += CurrentScriptTextChanged;
            _scriptEditor1.ScriptWritten            += ScriptWritten;
            _scriptEditor1.TextSelectionChanged     += TextSelectionChanged;
            _scriptEditor1.SyntaxCheckNeeded        += SyntaxCheckNeeded;

            _scriptItems = new EditorScriptItemCollection(_report, _contexts, _mainForm.FlexDesigner);

            // initial mode we start with:
            bool splitWindowMode = _mainForm._scriptEditorSplitWindowDistance > 0;

            // script data context:
            EditorScriptContextBase context = _contexts.GetContext(scriptContextName);

            System.Diagnostics.Debug.Assert(context != null);

            // this is patchy but will do for now:
            // - if we are being called from prop grid, then we have EditContext and edit that;
            // - else, if we are called to edit an expression - this is creating a new field;
            // - else, the big "Edit Scripts" button was pressed, and we default to GlobalScripts.

            EditorScriptItem scriptItem;

            if (typeDescriptorContext != null)
            {
                scriptItem = EditorScriptItem.FromTypeDescriptorContext(typeDescriptorContext, context, isScript, displayName);
            }
            else
            {
                scriptItem = EditorScriptItem.FromObjectProperty(propertyOwner, propertyName, context, isScript, displayName);
            }

            // A script item may not be "collected" if it is a new calc field being added, or e.g. in Maps there are many expressions:
            if (!_scriptItems.ContainsKey(scriptItem.Key))
            {
                scriptItem.EnsureTopKey();
                _scriptItems.Add(scriptItem.Key, scriptItem);
            }

            _scriptEditor0.Init(mainForm, _report, _scriptItems);
            _scriptEditor1.Init(mainForm, _report, _scriptItems);

            // _scriptItemKey is used ONLY for returning the script with which we were called:
            _scriptItemKey = scriptItem.Key;
            if (splitWindowMode)
            {
                _scriptEditor1.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                if (_scriptItems.ContainsKey(_mainForm._scriptEditorLastItemKey0))
                {
                    _scriptEditor0.SetCurrentScriptItem(_mainForm._scriptEditorLastItemKey0, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                }
                else
                {
                    _scriptEditor0.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                }
            }
            else
            {
                _scriptEditor0.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                _scriptEditor1.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
            }

            // Apply main window's theme:
            var tl    = new C1ThemeLocator(_mainForm.Theme);
            var theme = tl.GetTheme();

            if (theme != null)
            {
                C1ThemeController.ApplyThemeToControlTree(this, theme);
                C1ThemeController.ApplyThemeToObject(contextMenu, theme);
            }

            // Set up script editors' glyphs - splitter and close window:
            _scriptEditor0.GlyphBox.Cursor = Cursors.HSplit;
            _scriptEditor1.GlyphBox.Image  = Properties.Resources.SplitWindowClose_16x16;

            _splitter.SplitterMoved                     += Splitter_SplitterMoved;
            _scriptEditor0.GlyphBox.MouseEnter          += GlyphBox0_MouseEnter;
            _scriptEditor0.GlyphBox.MouseLeave          += GlyphBox0_MouseLeave;
            _scriptEditor0.GlyphBox.MouseDown           += GlyphBox0_MouseDown;
            _scriptEditor0.GlyphBox.MouseMove           += GlyphBox0_MouseMove;
            _scriptEditor0.GlyphBox.MouseUp             += GlyphBox0_MouseUp;
            _scriptEditor0.GlyphBox.MouseCaptureChanged += GlyphBox0_MouseCaptureChanged;
            _scriptEditor1.GlyphBox.MouseDown           += GlyphBox1_MouseDown;

            // Ready to start:
            UpdateStatusBar();
            //
            rbnMain.EndUpdate();
            //
        }