private void MethodButton(MethodInfo methodInfo, object[] args)
        {
            var win = new ConsoleToolWindow(CommandHost, methodInfo.Name);

            var button = CreateButton(methodInfo, args);
            win.StackPanel.Children.Add(button);
            win.Show(Console);
        }
Exemple #2
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ISolution solution = context.GetData <ISolution>(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);

            if (solution == null)
            {
                return;
            }

            var assemblyExplorerManager = SolutionEx.GetComponent <IAssemblyExplorerManager>(solution);
            var assemblyExplorer        = assemblyExplorerManager.Opened;

            if (assemblyExplorer == null)
            {
                return;
            }

#if DP10
            Assembly asm        = Assembly.GetExecutingAssembly();
            Stream   iconStream = asm.GetManifestResourceStream("JetBrains.DotPeek.Plugins.Console.Console.png");
            var      decoder    = new PngBitmapDecoder(iconStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            var      icon       = decoder.Frames[0];

            //var icon = new BitmapImage(new Uri(@"pack://application:,,,/JetBrains.DotPeek.Plugins.Console.1.0;Console.png", UriKind.RelativeOrAbsolute));
            //Assembly asm = Assembly.GetExecutingAssembly();
            //Stream iconStream = asm.GetManifestResourceStream("Console.png");
            //BitmapImage bitmap = new BitmapImage();
            //bitmap.BeginInit();
            //bitmap.StreamSource = iconStream;
            //bitmap.EndInit();
            //icon.Source = bitmap;
#elif DP11 || DP12
            IThemedIconManager themedIconManager = SolutionEx.GetComponent <IThemedIconManager>(solution);
            var icon = themedIconManager.GetIcon <ConsoleThemedIcons.Console>().CurrentImageSource;
#endif

            var console       = new ConsoleToolWindow(assemblyExplorerManager);
            var consoleWindow = new Window
            {
                Title   = "Console",
                Icon    = icon,
                Content = console,
                Width   = 640,
                Height  = 520,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                ResizeMode            = ResizeMode.CanResize
            };
            consoleWindow.Show();

            // Do we have an assembly node selected somewhere? If so, load the assembly in the console
            var data = context.GetData(TreeModelBrowser.TREE_MODEL_NODES);
            if (data != null)
            {
                var node = data.FirstOrDefault();
                if (node != null)
                {
                    IAssemblyFile     assemblyFile     = null;
                    IAssemblyFileNode assemblyFileNode = node.DataValue as IAssemblyFileNode;
                    if (assemblyFileNode != null)
                    {
                        assemblyFile = ExplorerNodeEx.GetAssemblyFile(assemblyFileNode);
                    }
                    else
                    {
                        AssemblyReferenceNode assemblyReferenceNode = node.DataValue as AssemblyReferenceNode;
                        if (assemblyReferenceNode != null)
                        {
#if DP10
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.ResolveResult(assemblyReferenceNode.Reference);
#elif DP11 || DP12
                            IAssembly assemblyResolveResult = ModuleReferencesResolveStoreEx.GetModuleToAssemblyResolveResult(assemblyReferenceNode.Reference);
#endif
                            if (assemblyResolveResult != null)
                            {
                                assemblyFile = Enumerable.FirstOrDefault(assemblyResolveResult.GetFiles());
                            }
                        }
                    }

                    AssemblyInfoCache component = SolutionEx.TryGetComponent <AssemblyInfoCache>(solution);
#if DP10
                    if (component != null && assemblyFile.Location.ExistsFile)
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#elif DP11 || DP12
                    if (component != null && assemblyFile.Location.ExistsFile && !AssemblyExplorerUtil.AssemblyIsBroken(assemblyFile.Location, component))
                    {
                        console.LoadAssemblies(new[] { assemblyFile.Location.FullPath });
                    }
#endif
                }
            }
        }
        private void Slider(SliderParams sliderParams)
        {
            var intialValue = GetInitialValue(sliderParams);
            var range = GetRange(intialValue, sliderParams.Minimum, sliderParams.Maximum);

            var toolWindow = new ConsoleToolWindow(CommandHost, sliderParams.PropertyToControl.Name);

            var textBlock = CreateTextBoxShowingCurrentValue(intialValue);
            var slider = CreateSlider(sliderParams.PropertyToControl, sliderParams.AutoCall, intialValue, range, SetTextBoxValue(textBlock));

            toolWindow.StackPanel.Children.Add(slider);
            toolWindow.StackPanel.Children.Add(textBlock);

            toolWindow.Show(Console);
        }