Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Executes in two distinct scenarios.
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        /// ------------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");

            if (disposing)
            {
                // NOTE: don't dispose m_gridControl, m_draftView and m_treeContainer here.
                // They all got added to a Controls collection and will be disposed when the
                // base class disposes below.

                // This should only be null when running tests.
                if (m_mainWnd != null && m_mainWnd.Mediator != null)
                {
                    m_mainWnd.Mediator.RemoveColleague(this);
                }

                if (m_dockExtender != null)
                {
                    m_dockExtender.Dispose();
                }
            }

            m_dockExtender  = null;
            m_draftView     = null;
            m_treeContainer = null;
            m_gridControl   = null;

            base.Dispose(disposing);
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected virtual void Initialize()
        {
            if (m_fShownBefore)
            {
                return;
            }

            // Create a FwSplitContainer with two draft views.
            Control draftView = ControlCreator.Create(this, m_rightView.Tag);

            draftView.Dock = DockStyle.Fill;
            m_draftView    = draftView as IRootSite;
            if (draftView is ISelectableView)
            {
                ((ISelectableView)draftView).BaseInfoBarCaption = m_baseInfoBarCaption;
            }

            // Create a draft view of Scripture in the project.
            m_rightView.Panel2.Controls.Add(draftView);

            // Create a view for the list of renderings for the selected key term
            m_gridControl      = CreateGridControl(m_mainWnd);
            m_gridControl.Dock = DockStyle.Fill;

            if (m_gridControl is ISelectableView)
            {
                ((ISelectableView)m_gridControl).BaseInfoBarCaption = m_baseInfoBarCaption;
            }

            if (m_gridControl is IChecksViewWrapperView)
            {
                ((IChecksViewWrapperView)m_gridControl).Persistence = m_persistence;
            }

            m_rightView.Panel1.Controls.Add(m_gridControl);

            // Create a key terms control (containing the tool strip and tree).
            // Subscribe to events so that the enabled status of the tool strip buttons can be updated.
            m_treeContainer      = CreateCheckControl();
            m_treeContainer.Dock = DockStyle.Left;

            if (m_treeContainer is IChecksViewWrapperView)
            {
                ((IChecksViewWrapperView)m_treeContainer).Persistence = m_persistence;
            }

            Controls.Add(m_treeContainer);

            m_dockExtender           = new DockExtender(this);
            m_floaty                 = m_dockExtender.Attach(m_treeContainer, m_treeContainer.ToolStrip, true, m_persistence);
            m_floaty.DockOnInside    = false;          // outside
            m_floaty.HideHandle      = false;
            m_floaty.AllowedDocking  = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            m_floaty.ShowCloseButton = false;
            m_treeContainer.Floaty   = m_floaty;
            m_fShownBefore           = true;
        }
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Install the control.
        /// </summary>
        /// <param name="dockHost">The control that hosts the browser</param>
        /// <param name="cache">The cache (needed in case we have to create the English LDS file
        /// on the fly)</param>
        /// <param name="normalStyle">The normal style (needed in case we have to create the
        /// English LDS file on the fly)</param>
        /// <returns>
        ///     <c>true</c> if the browser was installed successfully; <c>false</c>
        /// otherwise.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public bool Install(Control dockHost, FdoCache cache, IStStyle normalStyle)
        {
            while (true)
            {
                try
                {
                    RegistrationInfo.AllowP6RegistrationCode = true;
                    RegistrationInfo.AllowAccessToResources();
                    string paratextProjectDir = ScrImportP6Project.ProjectDir;

                    if (!String.IsNullOrEmpty(paratextProjectDir))
                    {
                        string englishLdsPathname = Path.Combine(paratextProjectDir, "English.lds");
                        if (!File.Exists(englishLdsPathname))
                        {
                            ParatextLdsFileAccessor ldsAccessor     = new ParatextLdsFileAccessor(cache);
                            UsfmStyEntry            normalUsfmStyle = new UsfmStyEntry();
                            StyleInfoTable          styleTable      = new StyleInfoTable(normalStyle.Name,
                                                                                         cache.LanguageWritingSystemFactoryAccessor);
                            normalUsfmStyle.SetPropertiesBasedOnStyle(normalStyle);
                            styleTable.Add(normalStyle.Name, normalUsfmStyle);
                            styleTable.ConnectStyles();
                            ldsAccessor.WriteParatextLdsFile(englishLdsPathname,
                                                             cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"), normalUsfmStyle);
                        }
                    }
                    ScrTextCollection.Initialize();
                    break;
                }
                catch (Exception e)
                {
                    try
                    {
                        ReflectionHelper.SetField(typeof(ScrTextCollection), "initialized", false);
                    }
                    catch (Exception reflectionHelperException)
                    {
                        throw new ContinuableErrorException("Paratext resource browser failed to initialize." +
                                                            Environment.NewLine + reflectionHelperException.Message, e);
                    }
                    if (MessageBox.Show(dockHost.FindForm(), String.Format(
                                            Properties.Resources.kstidCannotDisplayResourcePane,
                                            Application.ProductName, e.Message), Application.ProductName,
                                        MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button2) != DialogResult.Retry)
                    {
                        return(false);
                    }
                }
            }
            m_toolStrip.Text = "USFM Resource Browser";
            m_extender       = new DockExtender(dockHost);
            dockHost.Controls.Add(this);
            m_floaty = m_extender.Attach(this, m_toolStrip, true);
            this.SendToBack();
            return(true);
        }
Esempio n. 4
0
        public bool Install(Control dockHost, IApp app)
        {
            while (true)
            {
                try
                {
                    RegistrationInfo.AllowParatext6Code = true;
                    RegistrationInfo.AllowAccessToResources();
                    break;
                }
                catch (Exception e)
                {
                    try
                    {
                        ReflectionHelper.SetField(typeof(ScrTextCollection), "initialized", false);
                    }
                    catch (Exception reflectionHelperException)
                    {
                        throw new ContinuableErrorException("Paratext resource browser failed to initialize." +
                                                            Environment.NewLine + reflectionHelperException.Message, e);
                    }
                    if (MessageBox.Show(dockHost.FindForm(), String.Format(
                                            Properties.Resources.kstidCannotDisplayResourcePane,
                                            app.ApplicationName, e.Message), app.ApplicationName,
                                        MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button2) != DialogResult.Retry)
                    {
                        return(false);
                    }
                }
            }

            m_toolStrip.Text = "USFM Resource Browser";
            m_extender       = new DockExtender(dockHost);
            dockHost.Controls.Add(this);
            m_floaty = m_extender.Attach(this, m_toolStrip, true);
            this.SendToBack();
            return(true);
        }
Esempio n. 5
0
        public DemoForm()
        {
            // initialization
            InitializeComponent();
            label1.Text = someText;
            someWords   = someText.Split(' ');
            rnd         = new Random(-1);
            SetupTree();
            SetupList();


            //start docking here
            dockExtender = new DockExtender(this);

            IFloaty floaty;

            floaty = dockExtender.Attach(toolStrip1, toolStrip1, null);
            floaty.DockOnInside = false; // dock to outside
            floaty.Docking     += new EventHandler(floaty_Docking);

            floaty          = dockExtender.Attach(panelBottom, labelBottom, splitterBottom);
            floaty.Docking += new EventHandler(floaty_Docking);

            floaty          = dockExtender.Attach(panelLeft, labelLeft, splitterLeft);
            floaty.Text     = "Left Panel";
            floaty.Docking += new EventHandler(floaty_Docking);
            // that's it, docking has been setup for the 2 panels and the toolstrip!


            // setup a menu dynamically to show the panel again (if it was closed)
            foreach (Floaty f in dockExtender.Floaties)
            {
                ToolStripItem item = menuView.DropDownItems.Add(f.Text);
                item.MouseUp += new MouseEventHandler(item_MouseUp);
                item.Tag      = f;
            }
        }
Esempio n. 6
0
        public MainForm()
        {
            InitializeComponent();

            appNotifyIcon.Text = AboutForm.AssemblyTitle;

            levelComboBox.SelectedIndex = 0;

            Minimized += OnMinimized;

            // Init Log Manager Singleton
            LogManager.Instance.Initialize(new TreeViewLoggerView(loggerTreeView), logListView);


            _dockExtender = new DockExtender(this);

            // Dockable Log Detail View
            _logDetailsPanelFloaty = _dockExtender.Attach(logDetailPanel, logDetailToolStrip, logDetailSplitter);
            _logDetailsPanelFloaty.DontHideHandle = true;
            _logDetailsPanelFloaty.Docking       += OnFloatyDocking;

            // Dockable Logger Tree
            _loggersPanelFloaty = _dockExtender.Attach(loggerPanel, loggersToolStrip, loggerSplitter);
            _loggersPanelFloaty.DontHideHandle = true;
            _loggersPanelFloaty.Docking       += OnFloatyDocking;

            // Settings
            _firstStartup = !UserSettings.Load();
            if (_firstStartup)
            {
                // Initialize default layout
                UserSettings.Instance.Layout.Set(DesktopBounds, WindowState, logDetailPanel, loggerPanel);

                // Force panel to visible
                UserSettings.Instance.Layout.ShowLogDetailView = true;
                UserSettings.Instance.Layout.ShowLoggerTree    = true;
                UserSettings.Instance.DefaultFont = Environment.OSVersion.Version.Major >= 6 ? new Font("Segoe UI", 9F) : new Font("Tahoma", 8.25F);
            }

            Font = UserSettings.Instance.DefaultFont ?? Font;

            _windowRestorer = new WindowRestorer(this, UserSettings.Instance.Layout.WindowPosition,
                                                 UserSettings.Instance.Layout.WindowState);

            // Windows 7 CodePack (Taskbar icons and progress)
            _isWin7orLater = TaskbarManager.IsPlatformSupported;

            if (_isWin7orLater)
            {
                try
                {
                    // Taskbar Progress
                    TaskbarManager.Instance.ApplicationId = Text;
                    _taskbarProgressTimer = new Timer(OnTaskbarProgressTimer, null, _taskbarProgressTimerPeriod, _taskbarProgressTimerPeriod);

                    // Pause Btn
                    _pauseWinbarBtn        = new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)pauseBtn.Image).GetHicon()), pauseBtn.ToolTipText);
                    _pauseWinbarBtn.Click += pauseBtn_Click;

                    // Auto Scroll Btn
                    _autoScrollWinbarBtn =
                        new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)autoLogToggleBtn.Image).GetHicon()), autoLogToggleBtn.ToolTipText);
                    _autoScrollWinbarBtn.Click += autoLogToggleBtn_Click;

                    // Clear All Btn
                    _clearAllWinbarBtn =
                        new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)clearLoggersBtn.Image).GetHicon()), clearLoggersBtn.ToolTipText);
                    _clearAllWinbarBtn.Click += clearAll_Click;

                    // Add Btns
                    TaskbarManager.Instance.ThumbnailToolbars.AddButtons(Handle, _pauseWinbarBtn, _autoScrollWinbarBtn, _clearAllWinbarBtn);
                }
                catch (Exception)
                {
                    // Not running on Win 7?
                    _isWin7orLater = false;
                }
            }

            ApplySettings(true);

            _eventQueue = new Queue <LogMessage>();

            // Initialize Receivers
            foreach (IReceiver receiver in UserSettings.Instance.Receivers)
            {
                InitializeReceiver(receiver);
            }

            // Start the timer to process event logs in batch mode
            _logMsgTimer = new Timer(OnLogMessageTimer, null, 1000, 100);
        }
Esempio n. 7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            headerEvaluator.Activate(textInput);
            headerEvaluator.CloseClick += new EventHandler(headerEvaluator_CloseClick);
            headerOutput.Activate(tabOutput);
            headerOutput.CloseClick += new EventHandler(headerOutput_CloseClick);

            DockExtender = new DockExtender(this);
            inputFloaty  = DockExtender.Attach(panelInput, headerEvaluator, splitterBottom);
            outputFloaty = DockExtender.Attach(panelOutput, headerOutput, splitterRight);

            inputFloaty.Docking  += new EventHandler(inputFloaty_Docking);
            outputFloaty.Docking += new EventHandler(inputFloaty_Docking);
            inputFloaty.Hide();
            outputFloaty.Hide();

            textOutput.Text  = AssemblyInfo.ProductName + " v" + Application.ProductVersion + "\r\n";
            textOutput.Text += AssemblyInfo.CopyRightsDetail + "\r\n\r\n";


            marker  = new TextMarker(textEditor);
            checker = new SyntaxChecker(marker); // run the syntax checker on seperate thread

            // create the syntax update checker event handler and remember its reference
            syntaxUpdateChecker   = new EventHandler(checker_UpdateSyntax);
            checker.UpdateSyntax += syntaxUpdateChecker; // listen for events
            System.Threading.Thread thread = new System.Threading.Thread(checker.Start);
            thread.Start();

            TextChangedTimer       = new Timer();
            TextChangedTimer.Tick += new EventHandler(TextChangedTimer_Tick);

            // assign the auto completion function to this editor
            // autocomplete form will take care of the rest
            codecomplete              = new AutoComplete(textEditor);
            codecomplete.Enabled      = false;
            directivecomplete         = new AutoComplete(textEditor);
            directivecomplete.Enabled = false;
            directivecomplete.WordList.Items.Add("@ParseTree");
            directivecomplete.WordList.Items.Add("@Parser");
            directivecomplete.WordList.Items.Add("@Scanner");
            directivecomplete.WordList.Items.Add("@TextHighlighter");
            directivecomplete.WordList.Items.Add("@TinyPG");
            directivecomplete.WordList.Items.Add("Generate");
            directivecomplete.WordList.Items.Add("Language");
            directivecomplete.WordList.Items.Add("Namespace");
            directivecomplete.WordList.Items.Add("OutputPath");
            directivecomplete.WordList.Items.Add("TemplatePath");

            // setup the text highlighter (= text coloring)
            highlighterScanner             = new TinyPG.Highlighter.Scanner();
            textHighlighter                = new TinyPG.Highlighter.TextHighlighter(textEditor, highlighterScanner, new TinyPG.Highlighter.Parser(highlighterScanner));
            textHighlighter.SwitchContext += new TinyPG.Highlighter.ContextSwitchEventHandler(TextHighlighter_SwitchContext);

            LoadConfig();

            if (GrammarFile == null)
            {
                NewGrammar();
            }
        }
Esempio n. 8
0
        //methods

        private void ProcessInitialization()
        {
            if (Settings.Default.FontSize < 6)
            {
                Settings.Default.FontSize = 6;
                this.Font = new Font(Form.DefaultFont.FontFamily, 6);
            }
            else if (Settings.Default.FontSize > 18)
            {
                Settings.Default.FontSize = 18;
                this.Font = new Font(Form.DefaultFont.FontFamily, 18);
            }
            else
            {
                this.Font = new Font(Form.DefaultFont.FontFamily, Settings.Default.FontSize);
            }

            #region docking and debug panel

            // declare dockExtender as a member of the form
            DockExtender dockExtender;
            dockExtender = new DockExtender(toolStripContainer1); // 'this' is Form1
            // on for the 'dockHost'
            this.debugDockPanelUserControl1.AttachToDockExtender(dockExtender, splitter_main);
            this.debugDockPanelUserControl1.Floaty.Docking += new EventHandler(Floaty_Docking);
            this.windowsToolStripMenuItem.DropDownItems.AddRange(dockExtender.GetListOfToolStripMenuItem());
            foreach (ToolStripMenuItem _menuItem in this.windowsToolStripMenuItem.DropDownItems)
            {
                _menuItem.ToolTipText = "Show/hide " + _menuItem.Text;
            }

            #endregion docking and debug panel

            #region toolstrip (toolbars) show/hide context menus

            // Show and hide toolstrip menus
            this.toolStripContainerHelper = new ToolStripContainerHelper(toolStripContainer1);
            this.toolbarsToolStripMenuItem.DropDownItems.AddRange(toolStripContainerHelper.GetListOfToolStripMenuItem());
            foreach (ToolStripMenuItem tsmi in this.toolbarsToolStripMenuItem.DropDownItems)
            {
                tsmi.ToolTipText = "Show/hide " + tsmi.Text + " tool-bar";
            }
            if (toolStripContainer1.TopToolStripPanel.ContextMenuStrip == null)
            {
                toolStripContainer1.TopToolStripPanel.ContextMenuStrip = new ContextMenuStrip();
            }
            toolStripContainer1.TopToolStripPanel.ContextMenuStrip.Items.AddRange(toolStripContainerHelper.GetListOfToolStripMenuItem());
            if (toolStripContainer1.BottomToolStripPanel.ContextMenuStrip == null)
            {
                toolStripContainer1.BottomToolStripPanel.ContextMenuStrip = new ContextMenuStrip();
            }
            toolStripContainer1.BottomToolStripPanel.ContextMenuStrip.Items.AddRange(toolStripContainerHelper.GetListOfToolStripMenuItem());
            if (toolStripContainer1.LeftToolStripPanel.ContextMenuStrip == null)
            {
                toolStripContainer1.LeftToolStripPanel.ContextMenuStrip = new ContextMenuStrip();
            }
            toolStripContainer1.LeftToolStripPanel.ContextMenuStrip.Items.AddRange(toolStripContainerHelper.GetListOfToolStripMenuItem());
            if (toolStripContainer1.RightToolStripPanel.ContextMenuStrip == null)
            {
                toolStripContainer1.RightToolStripPanel.ContextMenuStrip = new ContextMenuStrip();
            }
            toolStripContainer1.RightToolStripPanel.ContextMenuStrip.Items.AddRange(toolStripContainerHelper.GetListOfToolStripMenuItem());

            #endregion toolstrip (toolbars) show/hide context menus

            goToToolStripMenuItem.DropDownOpening   += new EventHandler(goToToolStripMenuItem_DropDownOpening);
            m_EditToolStripMenuItem.DropDownOpening += new EventHandler(editToolStripMenuItem_DropDownOpening);
            if (SetAfterInstallationFlag)
            {
                helpUserControl.SetUrl(Resources.MainForm_ReadmePage_mainframe);
                tabControl_Main.SelectedIndex = tabControl_Main.Controls.IndexOf(tabPage_help);
                debugDockPanelUserControl1.Hide();
                this.WindowState = FormWindowState.Maximized;
            }
            else
            {
                this.WindowState = FormWindowState.Normal;
            }
        }