Esempio n. 1
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
            {
                return;
            }

            IContextControl      cc      = TopLevelControl as IContextControl;
            IAnkhServiceProvider context = null;

            if (cc != null && cc.Context != null)
            {
                context = cc.Context;
            }
            else
            {
                Control c = Parent;

                while (c != null)
                {
                    cc = c as IContextControl;
                    if (cc != null)
                    {
                        context = cc.Context;
                        break;
                    }

                    context = c as IAnkhServiceProvider;
                    if (context != null)
                    {
                        break;
                    }

                    c = c.Parent;
                }
            }

            if (context == null)
            {
                return;
            }

            IVSTextEditorFactory factory = context.GetService <IVSTextEditorFactory>();

            IVSTextEditorImplementation implementation;

            if (factory != null && factory.TryInstantiateIn(this, out implementation))
            {
                implementation.HorizontalTextScroll += ImplementOnHorizontalTextScroll;
                implementation.VerticalTextScroll   += ImplementOnVerticalTextScroll;
                _implementation = implementation;
            }
        }
Esempio n. 2
0
 protected override void OnHandleDestroyed(EventArgs e)
 {
     try
     {
         if (_implementation != null)
         {
             _text = _implementation.Text;
             _implementation.HorizontalTextScroll -= ImplementOnHorizontalTextScroll;
             _implementation.VerticalTextScroll   -= ImplementOnVerticalTextScroll;
         }
         Controls.Clear();
         base.OnHandleDestroyed(e);
     }
     finally
     {
         _implementation = null;
     }
 }
Esempio n. 3
0
        public bool TryInstantiateIn(VSTextEditor editor, out IVSTextEditorImplementation implementation)
        {
            TheVSTextEditor edit = new TheVSTextEditor();
            edit.Dock = System.Windows.Forms.DockStyle.Fill;

            implementation = edit;

            implementation.ForceLanguageService = editor.ForceLanguageService;
            implementation.DisableWordWrap = editor.DisableWordWrap;
            implementation.HideHorizontalScrollBar = editor.HideHorizontalScrollBar;
            implementation.EnableSplitter = editor.EnableSplitter;
            implementation.EnableNavigationBar = editor.EnableNavigationBar;
            implementation.ReadOnly = editor.ReadOnly;
            implementation.Text = editor.Text;

            editor.Controls.Add(edit);

            return true;
        }
Esempio n. 4
0
        public bool TryInstantiateIn(VSTextEditor editor, out IVSTextEditorImplementation implementation)
        {
            TheVSTextEditor edit = new TheVSTextEditor();

            edit.Dock = System.Windows.Forms.DockStyle.Fill;

            implementation = edit;

            implementation.ForceLanguageService    = editor.ForceLanguageService;
            implementation.DisableWordWrap         = editor.DisableWordWrap;
            implementation.HideHorizontalScrollBar = editor.HideHorizontalScrollBar;
            implementation.EnableSplitter          = editor.EnableSplitter;
            implementation.EnableNavigationBar     = editor.EnableNavigationBar;
            implementation.InteractiveEditor       = editor.InteractiveEditor;
            implementation.ReadOnly = editor.ReadOnly;
            implementation.Text     = editor.Text;

            editor.Controls.Add(edit);

            return(true);
        }
Esempio n. 5
0
 protected override void OnHandleDestroyed(EventArgs e)
 {
     try
     {
         if (_implementation != null)
         {
             _text = _implementation.Text;
             _implementation.HorizontalTextScroll -= ImplementOnHorizontalTextScroll;
             _implementation.VerticalTextScroll -= ImplementOnVerticalTextScroll;
         }
         Controls.Clear();
         base.OnHandleDestroyed(e);
     }
     finally
     {
         _implementation = null;
     }
 }
Esempio n. 6
0
        protected override void OnHandleCreated(EventArgs e)
        {
            base.OnHandleCreated(e);

            if (DesignMode)
                return;

            IContextControl cc = TopLevelControl as IContextControl;
            IAnkhServiceProvider context = null;

            if (cc != null && cc.Context != null)
                context = cc.Context;
            else
            {
                Control c = Parent;

                while(c != null)
                {
                    cc = c as IContextControl;
                    if (cc != null)
                    {
                        context = cc.Context;
                        break;
                    }

                    context = c as IAnkhServiceProvider;
                    if (context != null)
                        break;

                    c = c.Parent;
                }
            }

            if (context == null)
                return;

            IVSTextEditorFactory factory = context.GetService<IVSTextEditorFactory>();

            IVSTextEditorImplementation implementation;
            if (factory != null && factory.TryInstantiateIn(this, out implementation))
            {
                implementation.HorizontalTextScroll += ImplementOnHorizontalTextScroll;
                implementation.VerticalTextScroll += ImplementOnVerticalTextScroll;
                _implementation = implementation;
            }
        }