Esempio n. 1
0
        public void Add(ToolStrip toolStrip_1, BarDockStyle barDockStyle_0)
        {
            toolStrip_1.RenderMode = ToolStripRenderMode.ManagerRenderMode;
            this.ilist_0.Add(toolStrip_1);
            if (toolStrip_1 != this.toolStrip_0)
            {
                IFloaty floaty = this.dockExtender_0.Attach(toolStrip_1, toolStrip_1, null);
                floaty.Docking += new EventHandler(this.method_2);
                ToolStripMenuItem item = this.method_1(toolStrip_1);
                item.Tag = floaty;
                this.contextMenuStrip_0.Items.Insert(this.contextMenuStrip_0.Items.Count - 1, item);
            }
            switch (barDockStyle_0)
            {
            case BarDockStyle.Top:
                base.TopToolStripPanel.Controls.Add(toolStrip_1);
                break;

            case BarDockStyle.Bottom:
                base.BottomToolStripPanel.Controls.Add(toolStrip_1);
                break;

            case BarDockStyle.Right:
                base.RightToolStripPanel.Controls.Add(toolStrip_1);
                break;

            case BarDockStyle.Left:
                base.LeftToolStripPanel.Controls.Add(toolStrip_1);
                break;
            }
        }
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>
        /// this will gracefully hide the container control
        /// making sure that the floating window is also closed
        /// </summary>
        /// <param name="container"></param>
        public void Hide(Control container)
        {
            IFloaty f = _floaties.Find(container);

            if (f != null)
            {
                f.Hide();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// display the container control that is either floating or docked
        /// </summary>
        /// <param name="container"></param>
        public void Show(Control container)
        {
            IFloaty f = _floaties.Find(container);

            if (f != null)
            {
                f.Show();
            }
        }
Esempio n. 5
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. 6
0
        public void Hide(Control control_1)
        {
            IFloaty floaty = this.floaties_0.Find(control_1);

            if (floaty != null)
            {
                floaty.Hide();
            }
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            headerMessage.Activate(tabOutput);
            headerMessage.CloseClick += new EventHandler(headerMessage_CloseClick);

            DockExtender = new DockExtender(this);
            outputFloaty = DockExtender.Attach(panelOutput, headerMessage, splitterRight);
            outputFloaty.Docking += new EventHandler(outputFloaty_Docking);
            outputFloaty.Hide();
        }
Esempio n. 8
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. 9
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. 10
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
              this._clearLogWinbarBtn =
              new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)clearBtn.Image).GetHicon()), clearBtn.ToolTipText);
              this._clearLogWinbarBtn.Click += clearBtn_Click;

              // Add Btns
              TaskbarManager.Instance.ThumbnailToolbars.AddButtons(Handle, _pauseWinbarBtn, _autoScrollWinbarBtn, this._clearLogWinbarBtn);
            }
            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. 11
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. 12
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. 13
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. 14
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. 15
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;
		}