Exemplo n.º 1
0
 private void Populate(string searchTerm = "")
 {
     GalleryWrapper.Children.Clear();
     foreach (var block in LevelDataBlock.LoadAllFromDB())
     {
         if (searchTerm == "" || block.Name.ToLower().Contains(searchTerm.ToLower()))
         {
             var stack = new StackPanel();
             stack.Children.Add(new Image()
             {
             });
             stack.Children.Add(new TextBlock()
             {
                 Text         = block.Name,
                 TextWrapping = TextWrapping.Wrap,
                 //Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF343434"))
             });
             var button = new Button()
             {
                 Content    = stack,
                 Tag        = block,
                 Padding    = new Thickness(10),
                 Margin     = new Thickness(5, 5, 0, 0),
                 Background = new SolidColorBrush(AppResources.S_ColorConvert(block.Color))
             };
             button.Click += delegate
             {
                 OnDataSelected?.Invoke(this, button.Tag as LevelDataBlock);
             };
             GalleryWrapper.Children.Add(button);
         }
     }
 }
Exemplo n.º 2
0
        public async Task FindDifferences()
        {
            if (Path1 == null || Path2 == null)
            {
                throw new Exception("None of the paths submitted can be null.");
            }
            var oldDBPath = LevelDataBlock.BlockDatabasePath;

            LevelDataBlock.BlockDatabasePath = Path1;
            DB1_BlockData = LevelDataBlock.LoadAllFromDB();
            LevelDataBlock.BlockDatabasePath = Path2;
            DB2_BlockData = LevelDataBlock.LoadAllFromDB();
            AddedBlocks   = new Dictionary <string, LevelDataBlock>();
            RemovedBlocks = new Dictionary <string, LevelDataBlock>();
            double total = DB1_BlockData.Length + DB2_BlockData.Length, current = 0;
            await Task.Run(delegate
            {
                foreach (var entry in DB1_BlockData)
                {
                    current++;
                    PercentUpdated?.Invoke(this, current / total);
                    if (!RemovedBlocks.ContainsKey(entry.GUID))
                    {
                        if (!DB2_BlockData.Where(x => x.GUID == entry.GUID).Any())
                        {
                            RemovedBlocks.Add(entry.GUID, entry);
                            continue;
                        }
                    }
                }
                foreach (var entry in DB2_BlockData)
                {
                    current++;
                    PercentUpdated?.Invoke(this, current / total);
                    if (!AddedBlocks.ContainsKey(entry.GUID))
                    {
                        if (!DB1_BlockData.Where(x => x.GUID == entry.GUID).Any())
                        {
                            AddedBlocks.Add(entry.GUID, entry);
                            continue;
                        }
                    }
                }
            });
        }