/// <summary> /// constructor /// </summary> /// <param name="DockExtender">requires the DockExtender</param> public Floaty(DockExtender DockExtender) { _dockExtender = DockExtender; InitializeComponent(); }
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); }
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; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <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); }