Example #1
0
        public ImageDataProvider(IAppSettings settings, IResourceDataProvider resourceDataProvider)
        {
            _settings             = settings;
            _resourceDataProvider = resourceDataProvider;

            Ratio = _settings.IsLowMemory ? 2 : 1;
        }
Example #2
0
        public static void Save(IResourceDataProvider[] nodes, bool useSubDirs, ResourceDataType resourceDataType, Window ownerWindow = null)
        {
            if (nodes == null)
                return;

            Tuple<ResourceData, string>[] files;
            try {
                files = GetFiles(GetResourceData(nodes, resourceDataType), useSubDirs).ToArray();
            }
            catch (Exception ex) {
                App.MsgBox.Instance.Show(ex);
                return;
            }
            if (files.Length == 0)
                return;

            var data = new ProgressVM(Dispatcher.CurrentDispatcher, new ResourceSaver(files));
            var win = new ProgressDlg();
            win.DataContext = data;
            win.Owner = ownerWindow ?? Application.Current.MainWindow;
            win.Title = files.Length == 1 ? dnSpy_Shared_Resources.SaveResource : dnSpy_Shared_Resources.SaveResources;
            var res = win.ShowDialog();
            if (res != true)
                return;
            if (!data.WasError)
                return;
            App.MsgBox.Instance.Show(string.Format(dnSpy_Shared_Resources.AnErrorOccurred, data.ErrorMessage));
        }
Example #3
0
 public ResourceProviderReader(IResourceDataProvider provider, string baseName, CultureInfo cultureInfo)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     providerFunc = () => provider.Get(baseName, cultureInfo);
 }
Example #4
0
        public ResourceProviderWriter(IResourceDataProvider provider, string baseName, CultureInfo cultureInfo)
        {
            if (provider == null) throw new ArgumentNullException("provider");

            hasBeenSaved = false;
            resources = new Dictionary<string, object>();

            saveFunc = () => provider.Save(resources, baseName, cultureInfo);
        }
Example #5
0
 string ToString(IResourceDataProvider resource)
 {
     try {
         return(resource.ToString(options.CancellationToken, options.SearchDecompiledData));
     }
     catch (OperationCanceledException) {
         throw;
     }
     catch {
     }
     return(string.Empty);
 }
Example #6
0
 protected override void Dispose(bool disposing)
 {
     if (_dataProvider != null)
     {
         _dataProvider.Dispose();
         _dataProvider = null;
     }
     if (disposing)
     {
         _keyNavigationTimer.Dispose();
     }
     base.Dispose(disposing);
 }
Example #7
0
        /// <summary>
        /// Writes the offset
        /// </summary>
        /// <param name="output">Output</param>
        /// <param name="node">Node</param>
        /// <param name="showOffsetComment">true if the offset and comment should be written</param>
        public static void WriteOffsetComment(this IDecompilerOutput output, IResourceDataProvider node, bool showOffsetComment)
        {
            if (!showOffsetComment)
            {
                return;
            }

            ulong fo = node.FileOffset;

            if (fo == 0)
            {
                return;
            }

            var mod      = (node as IDocumentTreeNodeData).GetModule();
            var filename = mod == null ? null : mod.Location;

            output.Write($"0x{fo:X8}", new AddressReference(filename, false, fo, node.Length), DecompilerReferenceFlags.None, BoxedTextColor.Comment);
            output.Write(": ", BoxedTextColor.Comment);
        }
Example #8
0
        public static void WriteOffsetComment(this ITextOutput output, IResourceDataProvider node, bool showOffsetComment)
        {
            if (!showOffsetComment)
            {
                return;
            }

            ulong fo = node.FileOffset;

            if (fo == 0)
            {
                return;
            }

            var mod      = (node as IFileTreeNodeData).GetModule();
            var filename = mod == null ? null : mod.Location;

            output.WriteReference(string.Format("0x{0:X8}", fo), new AddressReference(filename, false, fo, node.Length), TextTokenKind.Comment);
            output.Write(": ", TextTokenKind.Comment);
        }
Example #9
0
		/// <summary>
		/// Writes the offset
		/// </summary>
		/// <param name="output">Output</param>
		/// <param name="node">Node</param>
		/// <param name="showOffsetComment">true if the offset and comment should be written</param>
		public static void WriteOffsetComment(this IDecompilerOutput output, IResourceDataProvider node, bool showOffsetComment) {
			if (!showOffsetComment)
				return;

			ulong fo = node.FileOffset;
			if (fo == 0)
				return;

			var mod = (node as DocumentTreeNodeData).GetModule();
			var filename = mod == null ? null : mod.Location;
			output.Write($"0x{fo:X8}", new AddressReference(filename, false, fo, node.Length), DecompilerReferenceFlags.None, BoxedTextColor.Comment);
			output.Write(": ", BoxedTextColor.Comment);
		}
Example #10
0
 string ToString(IResourceDataProvider resource)
 {
     try {
         return resource.ToString(options.CancellationToken, options.SearchDecompiledData);
     }
     catch (OperationCanceledException) {
         throw;
     }
     catch {
     }
     return string.Empty;
 }
Example #11
0
        public ResourceListView2TestForm(IResourceDataProvider provider, bool isTree)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            _resourceListView             = new ResourceListView2();
            _resourceListView.Dock        = DockStyle.Fill;
            _resourceListView.AllowDrop   = true;
            _resourceListView.InPlaceEdit = true;
            if (isTree)
            {
                _resourceListView.AddTreeStructureColumn();
                _resourceListView.HideSelection = true;
            }
            else
            {
                //_resourceListView.AddCheckBoxColumn();
                _resourceListView.HeaderStyle        = ColumnHeaderStyle.Clickable;
                _resourceListView.AllowColumnReorder = true;
            }
            _resourceListView.AddIconColumn();
            if (isTree)
            {
                RichTextColumn rtCol = new RichTextColumn();
                rtCol.AddNodeDecorator(new UnreadNodeDecorator());
                rtCol.SizeToContent = true;
                _resourceListView.Columns.Add(rtCol);
            }
            else
            {
                /*
                 * DisplayColumnManager dcm = (DisplayColumnManager) Core.DisplayColumnManager;
                 * ColumnDescriptor[] columns = dcm.GetDefaultColumns( Core.ResourceBrowser.VisibleResources );
                 * foreach( ColumnDescriptor colDesc in columns )
                 * {
                 *  int[] propIds = dcm.PropNamesToIDs( colDesc.PropNames, true );
                 *  bool isCustom = false;
                 *  for( int i=0; i<propIds.Length; i++ )
                 *  {
                 *      if ( dcm.GetCustomColumn( propIds [i] ) != null )
                 *      {
                 *          isCustom = true;
                 *          break;
                 *      }
                 *  }
                 *
                 *  if ( isCustom )
                 *  {
                 *      AddCustomColumn( dcm, propIds );
                 *  }
                 *  else
                 *  {
                 *      ResourceListView2Column column = _resourceListView.AddColumn( propIds [0] );
                 *      column.Width = colDesc.Width;
                 *  }
                 * }
                 */
                _resourceListView.FullRowSelect = true;
            }


            /*
             * int propId = Core.ResourceStore.GetPropId( "Annotation" );
             * ICustomColumn col = (Core.DisplayColumnManager as DisplayColumnManager).GetCustomColumn( propId );
             * _resourceListView.AddCustomColumn( col );
             */

            _resourceListView.DataProvider = provider;
            Controls.Add(_resourceListView);
            Controls.SetChildIndex(_resourceListView, 0);

            _nameFilter = new ResourceNameJetFilter("");
        }
Example #12
0
        public MainMV(INavigationService navigationService, IDialogService dialogService, IResourceDataProvider resourceDataProvider, IAppSettings settings)
            : base(settings)
        {
            _navigationService    = navigationService;
            _dialogService        = dialogService;
            _settings             = settings;
            _resourceDataProvider = resourceDataProvider;

            IsSoundOn = _settings.IsSoundOn;

            _correctAnswerSound   = LoadSound("Assets/CorrectAnswer.wav");
            _incorrectAnswerSound = LoadSound("Assets/IncorrectAnswer.wav");

            NewGameCommand = new RelayCommand(() => _navigationService.NavigateTo("GameSelectionV"));

            ToggleSoundCommand = new RelayCommand(() =>
            {
                var sound           = !IsSoundOn;
                _settings.IsSoundOn = sound;
                IsSoundOn           = sound;
            });

            AboutCommand = new RelayCommand(() => _navigationService.NavigateTo("AboutV"));

            RateAppCommand = new RelayCommand(() =>
            {
                MarketplaceReviewTask task = new MarketplaceReviewTask();
                task.Show();
            });

            MessengerInstance.Register <GamePreparedNotification>(this, n =>
            {
                var game = n.Game;

                if (game is IMapGame)
                {
                    _navigationService.NavigateTo("MapGameV");
                }
                else if (game is IQuizGame)
                {
                    _navigationService.NavigateTo("QuizGameV");
                }
            });

            MessengerInstance.Register <EndGameNotification>(this, n => _navigationService.NavigateTo("EndGameV"));
            MessengerInstance.Register <PauseGameNotification>(this, n => _navigationService.NavigateTo("PausedGameV"));
            MessengerInstance.Register <ResumeGameNotification>(this, n => _navigationService.GoBack());
            MessengerInstance.Register <RestartGameNotification>(this, n => _navigationService.GoBack());
            MessengerInstance.Register <StopGameNotification>(this, n => _navigationService.NavigateTo("MainPage"));

            MessengerInstance.Register <AnswerNotification>(this, n =>
            {
                if (IsSoundOn)
                {
                    FrameworkDispatcher.Update();
                    (n.IsCorrect ? _correctAnswerSound : _incorrectAnswerSound).Play();
                }
            });

            MessengerInstance.Register <GameGenerationFailedNotification>(this, n =>
                                                                          _dialogService.ShowMessage("We're unable to generate game with given options. Please try again with different options.", "Game cannot be generated!"));

            MessengerInstance.Register <WebNavigateNotification>(this, n =>
            {
                WebBrowserTask webBrowserTask = new WebBrowserTask();
                webBrowserTask.Uri            = n.Location;
                webBrowserTask.Show();
            });
        }
Example #13
0
 public CountryCollection(IAppSettings settings, IResourceDataProvider resourceDataProvider)
 {
     _settings             = settings;
     _resourceDataProvider = resourceDataProvider;
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceController"/> class.
 /// </summary>
 /// <param name="resourceDataProvider">The resource data provider.</param>
 public ResourceController(IResourceDataProvider resourceDataProvider)
 {
     this.resourceDataProvider = resourceDataProvider;
 }
 public ResourceProviderSet(IResourceDataProvider provider, string baseName, CultureInfo cultureInfo)
     : base(new ResourceProviderReader(provider, baseName, cultureInfo))
 {
     resourceWriter = new Lazy <IResourceWriter>(() => new ResourceProviderWriter(provider, baseName, cultureInfo));
 }
Example #16
0
		protected ResourceData[] GetResourceData(IResourceDataProvider[] nodes) {
			return SaveResources.GetResourceData(nodes, resourceDataType);
		}
Example #17
0
		IResourceDataProvider[] Filter(IResourceDataProvider[] nodes) {
			nodes = nodes.Where(a => a.GetResourceData(resourceDataType).Any()).ToArray();
			return nodes.Length == 0 ? null : nodes;
		}
Example #18
0
 public static ResourceData[] GetResourceData(IResourceDataProvider[] nodes, ResourceDataType resourceDataType)
 {
     if (nodes == null)
         return new ResourceData[0];
     return nodes.SelectMany(a => a.GetResourceData(resourceDataType)).ToArray();
 }
Example #19
0
 public void AddResourceDataProvider(IResourceDataProvider resourceDataProvider)
 {
     ThrowIfDisposed();
     _resourceDataProviders.Add(resourceDataProvider);
 }
Example #20
0
        public static void WriteOffsetComment(this ITextOutput output, IResourceDataProvider node, bool showOffsetComment)
        {
            if (!showOffsetComment)
                return;

            ulong fo = node.FileOffset;
            if (fo == 0)
                return;

            var mod = (node as IFileTreeNodeData).GetModule();
            var filename = mod == null ? null : mod.Location;
            output.WriteReference(string.Format("0x{0:X8}", fo), new AddressReference(filename, false, fo, node.Length), TextTokenKind.Comment);
            output.Write(": ", TextTokenKind.Comment);
        }