Beispiel #1
0
 void HandleAppArgs2(IAppCommandLineArgs appArgs)
 {
     foreach (var handler in appCommandLineArgsHandlers.OrderBy(a => a.Value.Order))
     {
         handler.Value.OnNewArgs(appArgs);
     }
 }
Beispiel #2
0
        public void OnNewArgs(IAppCommandLineArgs args)
        {
            bool show = false;

            var loc = GetSearchLocation(args.SearchIn);
            var typ = GetSearchType(args.SearchFor);

            if (loc != null)
            {
                show = true;
                searchService.Value.SearchLocation = loc.Value;
            }

            if (typ != null)
            {
                show = true;
                searchService.Value.SearchType = typ.Value;
            }

            if (args.SearchText != null)
            {
                show = true;
                searchService.Value.SearchText = args.SearchText;
            }

            if (show)
            {
                toolWindowService.Show(SearchToolWindowContent.THE_GUID);
            }
        }
Beispiel #3
0
        bool SelectMember(IAppCommandLineArgs args)
        {
            if (string.IsNullOrEmpty(args.SelectMember))
            {
                return(false);
            }

            string error;
            uint   token = NumberVMUtils.ParseUInt32(args.SelectMember, uint.MinValue, uint.MaxValue, out error);

            if (string.IsNullOrEmpty(error))
            {
                var mod    = GetLoadedFiles(args).FirstOrDefault();
                var member = mod == null ? null : mod.ResolveToken(token);
                if (member == null)
                {
                    return(false);
                }
                fileTabManager.FollowReference(member);
                return(true);
            }

            foreach (var mod in GetLoadedFiles(args))
            {
                var member = XmlDocKeyProvider.FindMemberByKey(mod, args.SelectMember);
                if (member != null)
                {
                    fileTabManager.FollowReference(member);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
 void HandleAppArgs2(IAppCommandLineArgs appArgs)
 {
     foreach (var handler in exportProvider.GetExports <IAppCommandLineArgsHandler>().OrderBy(a => a.Value.Order))
     {
         handler.Value.OnNewArgs(appArgs);
     }
 }
		public IEnumerable<object> Load(ISettingsService settingsService, IAppCommandLineArgs args) {
			var section = settingsService.GetOrCreateSection(SETTINGS_GUID);

			foreach (var o in documentListLoader.Load(section.GetOrCreateSection(DOCUMENT_LISTS_SECTION), args.LoadFiles))
				yield return o;

			if (args.LoadFiles) {
				var tgws = new List<SerializedTabGroupWindow>();
				var tgwsHash = new HashSet<string>(StringComparer.Ordinal);
				foreach (var tgwSection in section.SectionsWithName(TABGROUPWINDOW_SECTION)) {
					var tgw = SerializedTabGroupWindow.Load(tgwSection);
					yield return null;
					if (tgwsHash.Contains(tgw.Name))
						continue;
					tgws.Add(tgw);
				}

				// The documents are added to the treeview with a slight delay. Make sure the documents
				// have been added to the TV or the node lookup code will fail to find the nodes it needs.
				yield return LoaderConstants.Delay;

				foreach (var o in documentTabSerializer.Restore(tgws))
					yield return o;
			}

			documentTabService.OnTabsLoaded();
		}
		public void OnNewArgs(IAppCommandLineArgs args) {
			if (string.IsNullOrEmpty(args.Theme))
				return;

			Guid guid;
			bool isGuid = Guid.TryParse(args.Theme, out guid);
			var theme = themeService.AllThemes.FirstOrDefault(a => isGuid ? a.Guid == guid : !string.IsNullOrEmpty(a.Name) && StringComparer.InvariantCulture.Equals(a.Name, args.Theme));
			if (theme != null)
				themeService.Theme = theme;
		}
Beispiel #7
0
        public void Initialize(IDsLoaderContentProvider content, Window window, IAppCommandLineArgs appArgs)
        {
            this.window     = window;
            this.appArgs    = appArgs;
            dsLoaderControl = new DsLoaderControl();
            this.content    = content;
            this.content.SetLoadingContent(dsLoaderControl);

            this.window.ContentRendered += Window_ContentRendered;
            this.window.IsEnabled        = false;
        }
        public void Initialize(IDnSpyLoaderContentProvider content, Window window, IAppCommandLineArgs appArgs)
        {
            this.window             = window;
            this.appArgs            = appArgs;
            this.dnSpyLoaderControl = new DnSpyLoaderControl();
            this.dnSpyLoaderControl.Image.Source = imageManager.GetImage(new ImageReference(GetType().Assembly, "dnSpy-Big"), ((SolidColorBrush)themeManager.Theme.GetColor(ColorType.EnvironmentBackground).Background).Color);
            this.content = content;
            this.content.SetLoadingContent(this.dnSpyLoaderControl);

            this.window.ContentRendered += Window_ContentRendered;
            this.window.IsEnabled        = false;
        }
		public void OnNewArgs(IAppCommandLineArgs args) {
			if (!args.HasArgument(ARG_NAME))
				return;
			Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
				var guidString = args.GetArgumentValue(ARG_NAME);
				var guid = TryParse(guidString);
				if (guid != null)
					appSettingsService.Value.Show(guid.Value);
				else
					appSettingsService.Value.Show();
			}));
		}
        bool SelectMember(IAppCommandLineArgs args)
        {
            if (string.IsNullOrEmpty(args.SelectMember))
            {
                return(false);
            }

            string error;
            uint   token = NumberVMUtils.ParseUInt32(args.SelectMember, uint.MinValue, uint.MaxValue, out error);

            if (string.IsNullOrEmpty(error))
            {
                var mod    = GetLoadedFiles(args).FirstOrDefault();
                var member = mod == null ? null : mod.ResolveToken(token);
                if (member == null)
                {
                    return(false);
                }
                fileTabManager.FollowReference(member);
                return(true);
            }

            foreach (var mod in GetLoadedFiles(args))
            {
                const string XMLDOC_NS_PREFIX = "N:";
                bool         isNamespace      = args.SelectMember.StartsWith(XMLDOC_NS_PREFIX);
                if (isNamespace)
                {
                    var ns      = args.SelectMember.Substring(XMLDOC_NS_PREFIX.Length);
                    var modNode = fileTabManager.FileTreeView.FindNode(mod);
                    var nsNode  = modNode == null ? null : fileTabManager.FileTreeView.FindNamespaceNode(modNode.DnSpyFile, ns);
                    if (nsNode != null)
                    {
                        fileTabManager.FollowReference(nsNode);
                        return(true);
                    }
                }
                else
                {
                    var member = XmlDocKeyProvider.FindMemberByKey(mod, args.SelectMember);
                    if (member != null)
                    {
                        fileTabManager.FollowReference(member);
                        return(true);
                    }
                }
            }

            return(false);
        }
		public void OnNewArgs(IAppCommandLineArgs args) {
			foreach (var info in GetToolWindowInfos(args.HideToolWindow))
				mainToolWindowManager.Close(info.Guid);
			foreach (var info in GetToolWindowInfos(args.ShowToolWindow)) {
				var content = mainToolWindowManager.Show(info.Guid, info.Location);
				Debug.Assert(content != null);
				if (content == null)
					continue;
				if (info.Location == null)
					continue;
				if (mainToolWindowManager.CanMove(content, info.Location.Value))
					mainToolWindowManager.Move(content, info.Location.Value);
			}
		}
        public void OnNewArgs(IAppCommandLineArgs args)
        {
            if (string.IsNullOrEmpty(args.Theme))
            {
                return;
            }

            Guid guid;
            bool isGuid = Guid.TryParse(args.Theme, out guid);
            var  theme  = themeManager.AllThemesSorted.FirstOrDefault(a => isGuid ? a.Guid == guid : !string.IsNullOrEmpty(a.Name) && StringComparer.InvariantCulture.Equals(a.Name, args.Theme));

            if (theme != null)
            {
                themeManager.Theme = theme;
            }
        }
		public void OnNewArgs(IAppCommandLineArgs args) {
			if (!SelectMember(args)) {
				var mod = GetLoadedFiles(args).FirstOrDefault();
				if (mod != null)
					fileTabManager.FollowReference((object)mod.Assembly ?? mod);
				else {
					foreach (var filename in args.Filenames) {
						var key = new FilenameKey(filename);
						var file = fileTabManager.FileTreeView.FileManager.GetFiles().FirstOrDefault(a => a.Key.Equals(key));
						if (file != null) {
							fileTabManager.FollowReference(file);
							break;
						}
					}
				}
			}
		}
		public void OnNewArgs(IAppCommandLineArgs args) {
			if (!SelectMember(args)) {
				var mod = GetLoadedFiles(args).FirstOrDefault();
				if (mod != null)
					documentTabService.FollowReference((object)mod.Assembly ?? mod);
				else {
					foreach (var filename in args.Filenames) {
						var key = new FilenameKey(filename);
						var document = documentTabService.DocumentTreeView.DocumentService.GetDocuments().FirstOrDefault(a => a.Key.Equals(key));
						if (document != null) {
							documentTabService.FollowReference(document);
							break;
						}
					}
				}
			}
		}
Beispiel #15
0
        public App(bool readSettings)
        {
            this.args = new AppCommandLineArgs();
            if (args.SingleInstance)
            {
                SwitchToOtherInstance();
            }

            InitializeComponent();
            UIFixes();

            InitializeMEF(readSettings);
            compositionContainer.ComposeParts(this);
            this.pluginManager.LoadedPlugins = this.loadedPlugins;
            this.appWindow.CommandLineArgs   = this.args;

            this.Exit += App_Exit;
        }
Beispiel #16
0
        public App(bool readSettings, Stopwatch startupStopwatch)
        {
            // PERF: Init MEF on a BG thread. Results in slightly faster startup, eg. InitializeComponent() becomes a 'free' call on this UI thread
            initializeMEFTask     = Task.Run(() => InitializeMEF(readSettings, useCache: readSettings));
            this.startupStopwatch = startupStopwatch;

            resourceManagerTokenCacheImpl = new ResourceManagerTokenCacheImpl();
            resourceManagerTokenCacheImpl.TokensUpdated += ResourceManagerTokenCacheImpl_TokensUpdated;
            ResourceHelper.SetResourceManagerTokenCache(resourceManagerTokenCacheImpl);
            args = new AppCommandLineArgs();
            AppDirectories.SetSettingsFilename(args.SettingsFilename);

            AddAppContextFixes();
            InstallExceptionHandlers();
            InitializeComponent();
            UIFixes();

            Exit += App_Exit;
        }
Beispiel #17
0
 public void OnNewArgs(IAppCommandLineArgs args)
 {
     if (!args.HasArgument(ARG_NAME))
     {
         return;
     }
     Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
         var guidString = args.GetArgumentValue(ARG_NAME);
         var guid       = TryParse(guidString);
         if (guid != null)
         {
             appSettingsService.Value.Show(guid.Value);
         }
         else
         {
             appSettingsService.Value.Show();
         }
     }));
 }
Beispiel #18
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
            {
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);
            }

            var lang = GetLanguage(appArgs.Language);

            if (lang != null)
            {
                languageManager.Value.Language = lang;
            }

            if (appArgs.FullScreen != null)
            {
                appWindow.MainWindow.IsFullScreen = appArgs.FullScreen.Value;
            }

            if (appArgs.NewTab)
            {
                fileTabManager.Value.OpenEmptyTab();
            }

            var files = appArgs.Filenames.ToArray();

            if (files.Length > 0)
            {
                OpenFileInit.OpenFiles(fileTabManager.Value.FileTreeView, appWindow.MainWindow, files, false);
            }

            // The files were lazily added to the treeview. Make sure they've been added to the TV
            // before we process the remaining command line args.
            if (files.Length > 0)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => HandleAppArgs2(appArgs)));
            }
            else
            {
                HandleAppArgs2(appArgs);
            }
        }
Beispiel #19
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
            {
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);
            }

            var decompiler = GetDecompiler(appArgs.Language);

            if (decompiler != null)
            {
                decompilerService.Value.Decompiler = decompiler;
            }

            if (appArgs.FullScreen != null)
            {
                appWindow.MainWindow.IsFullScreen = appArgs.FullScreen.Value;
            }

            if (appArgs.NewTab)
            {
                documentTabService.Value.OpenEmptyTab();
            }

            var files = appArgs.Filenames.ToArray();

            if (files.Length > 0)
            {
                OpenDocumentsHelper.OpenDocuments(documentTabService.Value.DocumentTreeView, appWindow.MainWindow, files, false);
            }

            // The files were lazily added to the treeview. Make sure they've been added to the TV
            // before we process the remaining command line args.
            if (files.Length > 0)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => HandleAppArgs2(appArgs)));
            }
            else
            {
                HandleAppArgs2(appArgs);
            }
        }
Beispiel #20
0
        public App(bool readSettings)
        {
            this.args = new AppCommandLineArgs();
            if (args.SingleInstance)
            {
                SwitchToOtherInstance();
            }

            InitializeComponent();
            UIFixes();

            var asms = new List <Assembly>();

            asms.Add(typeof(EnumVM).Assembly);                                  // dnSpy.Shared
            compositionContainer = AppCreator.Create(asms, "*.Plugin.dll", readSettings);
            compositionContainer.ComposeParts(this);
            this.appWindow.CommandLineArgs = this.args;

            this.Exit += App_Exit;
        }
Beispiel #21
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
            {
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);
            }

            var lang = GetLanguage(appArgs.Language);

            if (lang != null)
            {
                languageManager.Value.SelectedLanguage = lang;
            }

            var files = appArgs.Filenames.ToArray();

            if (files.Length > 0)
            {
                OpenFileInit.OpenFiles(fileTreeView.Value, appWindow.MainWindow, files);
            }
        }
Beispiel #22
0
        public App(bool readSettings)
        {
            args = new AppCommandLineArgs();
            AppDirectories.SetSettingsFilename(args.SettingsFilename);
            if (args.SingleInstance)
            {
                SwitchToOtherInstance();
            }

            AddAppContextFixes();

            InitializeComponent();
            UIFixes();

            InitializeMEF(readSettings);
            compositionContainer.ComposeParts(this);
            extensionService.LoadedExtensions = loadedExtensions;
            appWindow.CommandLineArgs         = args;

            Exit += App_Exit;
        }
		bool SelectMember(IAppCommandLineArgs args) {
			if (string.IsNullOrEmpty(args.SelectMember))
				return false;

			string error;
			uint token = NumberVMUtils.ParseUInt32(args.SelectMember, uint.MinValue, uint.MaxValue, out error);
			if (string.IsNullOrEmpty(error)) {
				var mod = GetLoadedFiles(args).FirstOrDefault();
				var member = mod == null ? null : mod.ResolveToken(token);
				if (member == null)
					return false;
				fileTabManager.FollowReference(member);
				return true;
			}

			foreach (var mod in GetLoadedFiles(args)) {
				const string XMLDOC_NS_PREFIX = "N:";
				bool isNamespace = args.SelectMember.StartsWith(XMLDOC_NS_PREFIX);
				if (isNamespace) {
					var ns = args.SelectMember.Substring(XMLDOC_NS_PREFIX.Length);
					var modNode = fileTabManager.FileTreeView.FindNode(mod);
					var nsNode = modNode == null ? null : fileTabManager.FileTreeView.FindNamespaceNode(modNode.DnSpyFile, ns);
					if (nsNode != null) {
						fileTabManager.FollowReference(nsNode);
						return true;
					}
				}
				else {
					var member = XmlDocKeyProvider.FindMemberByKey(mod, args.SelectMember);
					if (member != null) {
						fileTabManager.FollowReference(member);
						return true;
					}
				}
			}

			return false;
		}
 IEnumerable <ModuleDef> GetLoadedFiles(IAppCommandLineArgs args)
 {
     foreach (var filename in args.Filenames)
     {
         var key      = new FilenameKey(filename);
         var document = documentTabService.DocumentTreeView.DocumentService.GetDocuments().FirstOrDefault(a => key.Equals(a.Key));
         if (document?.ModuleDef == null)
         {
             continue;
         }
         if (document.AssemblyDef != null)
         {
             foreach (var mod in document.AssemblyDef.Modules)
             {
                 yield return(mod);
             }
         }
         else
         {
             yield return(document.ModuleDef);
         }
     }
 }
 IEnumerable <ModuleDef> GetLoadedFiles(IAppCommandLineArgs args)
 {
     foreach (var filename in args.Filenames)
     {
         var key  = new FilenameKey(filename);
         var file = fileTabManager.FileTreeView.FileManager.GetFiles().FirstOrDefault(a => key.Equals(a.Key));
         if (file == null || file.ModuleDef == null)
         {
             continue;
         }
         if (file.AssemblyDef != null)
         {
             foreach (var mod in file.AssemblyDef.Modules)
             {
                 yield return(mod);
             }
         }
         else
         {
             yield return(file.ModuleDef);
         }
     }
 }
Beispiel #26
0
        public IEnumerable <object> Load(ISettingsManager settingsManager, IAppCommandLineArgs args)
        {
            var section = settingsManager.GetOrCreateSection(SETTINGS_GUID);

            foreach (var o in fileListLoader.Load(section.GetOrCreateSection(FILE_LISTS_SECTION), args.LoadFiles))
            {
                yield return(o);
            }

            if (args.LoadFiles)
            {
                var tgws     = new List <SerializedTabGroupWindow>();
                var tgwsHash = new HashSet <string>();
                foreach (var tgwSection in section.SectionsWithName(TABGROUPWINDOW_SECTION))
                {
                    var tgw = SerializedTabGroupWindow.Load(tgwSection);
                    yield return(null);

                    if (tgwsHash.Contains(tgw.Name))
                    {
                        continue;
                    }
                    tgws.Add(tgw);
                }

                // The files are added to the treeview with a slight delay. Make sure the files have
                // been added to the TV or the node lookup code will fail to find the nodes it needs.
                yield return(LoaderConstants.Delay);

                foreach (var o in fileTabSerializer.Restore(tgws))
                {
                    yield return(o);
                }
            }

            fileTabManager.OnTabsLoaded();
        }
 public void OnNewArgs(IAppCommandLineArgs args)
 {
     if (!SelectMember(args))
     {
         var mod = GetLoadedFiles(args).FirstOrDefault();
         if (mod != null)
         {
             documentTabService.FollowReference((object)mod.Assembly ?? mod);
         }
         else
         {
             foreach (var filename in args.Filenames)
             {
                 var key      = new FilenameKey(filename);
                 var document = documentTabService.DocumentTreeView.DocumentService.GetDocuments().FirstOrDefault(a => a.Key.Equals(key));
                 if (document != null)
                 {
                     documentTabService.FollowReference(document);
                     break;
                 }
             }
         }
     }
 }
 public void OnNewArgs(IAppCommandLineArgs args)
 {
     if (!SelectMember(args))
     {
         var mod = GetLoadedFiles(args).FirstOrDefault();
         if (mod != null)
         {
             fileTabManager.FollowReference((object)mod.Assembly ?? mod);
         }
         else
         {
             foreach (var filename in args.Filenames)
             {
                 var key  = new FilenameKey(filename);
                 var file = fileTabManager.FileTreeView.FileManager.GetFiles().FirstOrDefault(a => a.Key.Equals(key));
                 if (file != null)
                 {
                     fileTabManager.FollowReference(file);
                     break;
                 }
             }
         }
     }
 }
 public void OnNewArgs(IAppCommandLineArgs args)
 {
     foreach (var info in GetToolWindowInfos(args.HideToolWindow))
     {
         mainToolWindowManager.Close(info.Guid);
     }
     foreach (var info in GetToolWindowInfos(args.ShowToolWindow))
     {
         var content = mainToolWindowManager.Show(info.Guid, info.Location);
         Debug.Assert(content != null);
         if (content == null)
         {
             continue;
         }
         if (info.Location == null)
         {
             continue;
         }
         if (mainToolWindowManager.CanMove(content, info.Location.Value))
         {
             mainToolWindowManager.Move(content, info.Location.Value);
         }
     }
 }
		public void OnNewArgs(IAppCommandLineArgs args) {
			bool show = false;

			var loc = GetSearchLocation(args.SearchIn);
			var typ = GetSearchType(args.SearchFor);

			if (loc != null) {
				show = true;
				searchManager.Value.SearchLocation = loc.Value;
			}

			if (typ != null) {
				show = true;
				searchManager.Value.SearchType = typ.Value;
			}

			if (args.SearchText != null) {
				show = true;
				searchManager.Value.SearchText = args.SearchText;
			}

			if (show)
				mainToolWindowManager.Show(SearchToolWindowContent.THE_GUID);
		}
Beispiel #31
0
 public void Initialize(IDsLoaderContentProvider content, Window window, IAppCommandLineArgs args)
 {
     Debug.Assert(!(windowLoader is null));
     windowLoader.Initialize(content, window, args);
 }
Beispiel #32
0
		void HandleAppArgs(IAppCommandLineArgs appArgs) {
			if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
				WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);

			var decompiler = GetDecompiler(appArgs.Language);
			if (decompiler != null)
				decompilerService.Value.Decompiler = decompiler;

			if (appArgs.FullScreen != null)
				appWindow.MainWindow.IsFullScreen = appArgs.FullScreen.Value;

			if (appArgs.NewTab)
				documentTabService.Value.OpenEmptyTab();

			var files = appArgs.Filenames.ToArray();
			if (files.Length > 0)
				OpenDocumentsHelper.OpenDocuments(documentTabService.Value.DocumentTreeView, appWindow.MainWindow, files, false);

			// The files were lazily added to the treeview. Make sure they've been added to the TV
			// before we process the remaining command line args.
			if (files.Length > 0)
				Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => HandleAppArgs2(appArgs)));
			else
				HandleAppArgs2(appArgs);
		}
Beispiel #33
0
		public App(bool readSettings) {
			args = new AppCommandLineArgs();
			AppDirectories.SetSettingsFilename(args.SettingsFilename);
			if (args.SingleInstance)
				SwitchToOtherInstance();

			AddAppContextFixes();

			InitializeComponent();
			UIFixes();

			InitializeMEF(readSettings);
			compositionContainer.ComposeParts(this);
			extensionService.LoadedExtensions = loadedExtensions;
			appWindow.CommandLineArgs = args;

			Exit += App_Exit;
		}
Beispiel #34
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);

            var lang = GetLanguage(appArgs.Language);
            if (lang != null)
                languageManager.Value.Language = lang;

            if (appArgs.FullScreen != null)
                appWindow.MainWindow.IsFullScreen = appArgs.FullScreen.Value;

            if (appArgs.NewTab)
                fileTabManager.Value.OpenEmptyTab();

            var files = appArgs.Filenames.ToArray();
            if (files.Length > 0)
                OpenFileInit.OpenFiles(fileTabManager.Value.FileTreeView, appWindow.MainWindow, files, false);

            // The files were lazily added to the treeview. Make sure they've been added to the TV
            // before we process the remaining command line args.
            if (files.Length > 0)
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => HandleAppArgs2(appArgs)));
            else
                HandleAppArgs2(appArgs);
        }
Beispiel #35
0
		public void Initialize(IDsLoaderContentProvider content, Window window, IAppCommandLineArgs appArgs) {
			this.window = window;
			this.appArgs = appArgs;
			dsLoaderControl = new DsLoaderControl();
			this.content = content;
			this.content.SetLoadingContent(dsLoaderControl);

			this.window.ContentRendered += Window_ContentRendered;
			this.window.IsEnabled = false;
		}
Beispiel #36
0
		public void Initialize(IDnSpyLoaderContentProvider content, Window window, IAppCommandLineArgs appArgs) {
			this.window = window;
			this.appArgs = appArgs;
			this.dnSpyLoaderControl = new DnSpyLoaderControl();
			this.dnSpyLoaderControl.Image.Source = imageManager.GetImage(GetType().Assembly, "dnSpy-Big", ((SolidColorBrush)themeManager.Theme.GetColor(ColorType.EnvironmentBackground).Background).Color);
			this.content = content;
			this.content.SetLoadingContent(this.dnSpyLoaderControl);

			this.window.ContentRendered += Window_ContentRendered;
			this.window.IsEnabled = false;
		}
Beispiel #37
0
        public App(bool readSettings)
        {
            this.args = new AppCommandLineArgs();
            if (args.SingleInstance)
                SwitchToOtherInstance();

            InitializeComponent();
            UIFixes();

            InitializeMEF(readSettings);
            compositionContainer.ComposeParts(this);
            this.pluginManager.LoadedPlugins = this.loadedPlugins;
            this.appWindow.CommandLineArgs = this.args;

            this.Exit += App_Exit;
        }
Beispiel #38
0
 public void Initialize(IAppCommandLineArgs args)
 {
     InitializeCulture(TryCreateCultureInfo(args.Culture));
 }
Beispiel #39
0
        void HandleAppArgs(IAppCommandLineArgs appArgs)
        {
            if (appArgs.Activate && appWindow.MainWindow.WindowState == WindowState.Minimized)
                WindowUtils.SetState(appWindow.MainWindow, WindowState.Normal);

            var lang = GetLanguage(appArgs.Language);
            if (lang != null)
                languageManager.Value.SelectedLanguage = lang;

            var files = appArgs.Filenames.ToArray();
            if (files.Length > 0)
                OpenFileInit.OpenFiles(fileTreeView.Value, appWindow.MainWindow, files);
        }
 IEnumerable<ModuleDef> GetLoadedFiles(IAppCommandLineArgs args)
 {
     foreach (var filename in args.Filenames) {
         var key = new FilenameKey(filename);
         var file = fileTabManager.FileTreeView.FileManager.GetFiles().FirstOrDefault(a => key.Equals(a.Key));
         if (file == null || file.ModuleDef == null)
             continue;
         if (file.AssemblyDef != null) {
             foreach (var mod in file.AssemblyDef.Modules)
                 yield return mod;
         }
         else
             yield return file.ModuleDef;
     }
 }
        bool SelectMember(IAppCommandLineArgs args)
        {
            if (string.IsNullOrEmpty(args.SelectMember))
                return false;

            string error;
            uint token = NumberVMUtils.ParseUInt32(args.SelectMember, uint.MinValue, uint.MaxValue, out error);
            if (string.IsNullOrEmpty(error)) {
                var mod = GetLoadedFiles(args).FirstOrDefault();
                var member = mod == null ? null : mod.ResolveToken(token);
                if (member == null)
                    return false;
                fileTabManager.FollowReference(member);
                return true;
            }

            foreach (var mod in GetLoadedFiles(args)) {
                var member = XmlDocKeyProvider.FindMemberByKey(mod, args.SelectMember);
                if (member != null) {
                    fileTabManager.FollowReference(member);
                    return true;
                }
            }

            return false;
        }
Beispiel #42
0
 public void Initialize(IAppCommandLineArgs args) => InitializeCulture(TryCreateCultureInfo(args.Culture));
		IEnumerable<ModuleDef> GetLoadedFiles(IAppCommandLineArgs args) {
			foreach (var filename in args.Filenames) {
				var key = new FilenameKey(filename);
				var document = documentTabService.DocumentTreeView.DocumentService.GetDocuments().FirstOrDefault(a => key.Equals(a.Key));
				if (document?.ModuleDef == null)
					continue;
				if (document.AssemblyDef != null) {
					foreach (var mod in document.AssemblyDef.Modules)
						yield return mod;
				}
				else
					yield return document.ModuleDef;
			}
		}
Beispiel #44
0
 void HandleAppArgs2(IAppCommandLineArgs appArgs)
 {
     foreach (var handler in appCommandLineArgsHandlers.OrderBy(a => a.Value.Order))
         handler.Value.OnNewArgs(appArgs);
 }
Beispiel #45
0
		public void Initialize(IDnSpyLoaderContentProvider content, Window window, IAppCommandLineArgs args) {
			Debug.Assert(windowLoader != null);
			windowLoader.Initialize(content, window, args);
		}
Beispiel #46
0
        public App(bool readSettings)
        {
            this.args = new AppCommandLineArgs();
            if (args.SingleInstance)
                SwitchToOtherInstance();

            InitializeComponent();
            UIFixes();

            var asms = new List<Assembly>();
            asms.Add(typeof(EnumVM).Assembly);			// dnSpy.Shared
            compositionContainer = AppCreator.Create(asms, "*.Plugin.dll", readSettings);
            compositionContainer.ComposeParts(this);
            this.appWindow.CommandLineArgs = this.args;

            this.Exit += App_Exit;
        }