Пример #1
0
        private void loadMedia(string id, bool edit)
        {
            RenderOptions.SetBitmapScalingMode(imgView, BitmapScalingMode.NearestNeighbor);
            if (edit)
            {
                BackgroundWorker worker = new BackgroundWorker();
                img            = Data.Media[id] as NanaManagerAPI.Types.Image;
                imgView.Source = img.GetSample();
                worker.DelegateThread(loadHiRes);
            }
            else
            {
                img = null;
                BitmapImage bmp = new BitmapImage();
                bmp.BeginInit();
                bmp.DecodePixelWidth  = 100;
                bmp.DecodePixelHeight = 100;
                bmp.CacheOption       = BitmapCacheOption.OnLoad;
                bmp.UriSource         = new Uri(id);
                bmp.EndInit();
                imgView.Source = bmp;
                toLoad         = id;

                BackgroundWorker worker = new BackgroundWorker();
                worker.DelegateThread(loadHiRes);
            }
        }
Пример #2
0
        private void page_Loaded(object sender, RoutedEventArgs e)
        {
            if (Data.Groups.Count == 0)
            {
                pgProgress.Visibility = lblStatus.Visibility = Visibility.Visible;
                waitThread            = new Thread(() => Thread.Sleep(2000));
                bgWork.DelegateThread(() =>
                {
                    if (!ContentFile.CheckValidity())
                    {
                        ContentFile.Decrypt(Login.Password);
                    }
                    else
                    {
                        ContentFile.Archive = ZipFile.Open(ContentFile.ContentPath, ZipArchiveMode.Update);
                    }

                    ContentFile.LoadData();
                    Dispatcher.Invoke(() => { pgProgress.Visibility = lblStatus.Visibility = Visibility.Collapsed; });
                    SpinWait.SpinUntil(() => !waitThread.IsAlive);
                    if (MainWindow.ImportOnLogin)
                    {
                        Paging.LoadPage(Pages.Import);
                    }
                    else
                    {
                        Paging.LoadPage(Pages.Viewer);
                    }
                });
                waitThread.Start();
            }
            else
            {
                Paging.LoadPage(Pages.Viewer);
            }
        }