Ejemplo n.º 1
0
        protected void OnCurrentInfoChanged()
        {
            nativePropertyGrid.SelectedObject = CurrentInfo;

            dumpButton.Enabled = CurrentInfo != null;
            if (CurrentInfo == null) return; // nope

            hwndBox.Text = CurrentInfo.ToShortString();

            // Inject ourself if possible
            if (HawkeyeApplication.CanInject(CurrentInfo))
            {
                HawkeyeApplication.Inject(CurrentInfo);
                return;
            }

            // Injection was not needed.

            CurrentInfo.DetectDotNetProperties();
            var controlInfo = CurrentInfo.ControlInfo;
            if (controlInfo != null)
            {
                if (!tabs.TabPages.Contains(dotNetTabPage))
                    tabs.TabPages.Add(dotNetTabPage);
                FillControlInfo(controlInfo);
                tabs.SelectedTab = dotNetTabPage;
                if (!tabs.TabPages.Contains(scriptTabPage))
                    tabs.TabPages.Add(scriptTabPage);

                scriptBox1.ControlInfo = controlInfo;
            }
            else
            {
                if (tabs.TabPages.Contains(dotNetTabPage))
                    tabs.TabPages.Remove(dotNetTabPage);
                tabs.SelectedTab = nativeTabPage;
                if (tabs.TabPages.Contains(scriptTabPage))
                    tabs.TabPages.Remove(scriptTabPage);
                scriptBox1.ControlInfo = null;
            }

            // Update the hwnd box in case we detected .NET properties.
            hwndBox.Text = CurrentInfo.ToShortString();

            if (CurrentInfoChanged != null)
                CurrentInfoChanged(this, EventArgs.Empty);
        }