public async void DownloadImage(string url, string suggestedFilename, bool animeCover)
        {
            if (url == null)
            {
                return;
            }
            try
            {
                var sp = new FileSavePicker();
                sp.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                sp.FileTypeChoices.Add("Portable Network Graphics (*.png)", new List <string> {
                    ".png"
                });
                sp.SuggestedFileName = $"{suggestedFilename}-cover_art";

                var file = await sp.PickSaveFileAsync();

                if (file == null)
                {
                    return;
                }
                await Download(url, file, animeCover);

                UWPUtilities.GiveStatusBarFeedback("File saved successfully.");
            }
            catch (Exception)
            {
                UWPUtilities.GiveStatusBarFeedback("Error. File didn't save properly.");
            }
        }
예제 #2
0
        private void NavView_Loaded(object sender, RoutedEventArgs e)
        {
            _title = UWPUtilities.FindControlWithName <TextBlock>("tbTitle", MyNavView);

            _ellName        = UWPUtilities.FindControlWithName <Ellipse>("ellName", MyNavView);
            _ccNameGrid     = UWPUtilities.FindControlWithName <Grid>("ccNameGrid", MyNavView);
            _ccName         = UWPUtilities.FindControlWithName <ContentControl>("ccName", MyNavView);
            _txtName        = UWPUtilities.FindControlWithName <TextBlock>("txtName", MyNavView);
            _txtNameChevron = UWPUtilities.FindControlWithName <FontIcon>("txtNameChevron", MyNavView);
            _txtAsset       = UWPUtilities.FindControlWithName <TextBlock>("txtAsset", MyNavView);
            _txtAmount      = UWPUtilities.FindControlWithName <TextBlock>("txtAmount", MyNavView);

            _paneContentGrid     = UWPUtilities.FindControlWithName <Grid>("PaneContentGrid", MyNavView);
            _selectionIndicators = UWPUtilities.FindControlsWithName <Rectangle>("SelectionIndicator", MyNavView);

            _paneContentGrid.Background = _acrylicBrush;

            _txtNameChevronOriginalMargin          = _txtNameChevron.Margin;
            _txtNameChevronOriginalVisibility      = _txtNameChevron.Visibility;
            _ccNameGridOriginalHorizontalAlignment = _ccNameGrid.HorizontalAlignment;
            _ccNameOriginalHorizontalAlignment     = _ccName.HorizontalAlignment;
            _ccNameOriginalMargin        = _ccName.Margin;
            _ellNameOriginalWidth        = _ellName.Width;
            _ellNameOriginalHeight       = _ellName.Height;
            _txtNameOriginalFontSize     = _txtName.FontSize;
            _txtAssetOriginalVisibility  = _txtAsset.Visibility;
            _txtAmountOriginalVisibility = _txtAmount.Visibility;

            NavView.PaneClosing += NavView_PaneClosing;
            NavView.PaneOpening += NavView_PaneOpening;
            SetColors();
            TogglePane(!NavView.IsPaneOpen);
        }
예제 #3
0
        private void ProcessUpdate()
        {
            InitializationRoutines.InitPostUpdate();
            var dispatcher = ResourceLocator.DispatcherAdapter;

            ApplicationData.Current.LocalSettings.Values["AppVersion"] = UWPUtilities.GetAppVersion();
        }
예제 #4
0
 public SettingsPage()
 {
     InitializeComponent();
     ViewModel.NavigationRequest += ViewModelOnNavigationRequest;
     SettingsNavFrame.Navigate(typeof(SettingsHomePage), null);
     ViewModelLocator.GeneralMain.CurrentOffStatus = $"Settings - {UWPUtilities.GetAppVersion()}";
 }
        public async void ExportToCalendar(object item)
        {
            var       animeItemViewModel = item as AnimeItemViewModel;
            DayOfWeek day  = Utilities.StringToDay(animeItemViewModel.TopLeftInfoBind);
            var       date = GetNextWeekday(DateTime.Today, day);

            var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
            var startTime      = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, timeZoneOffset);

            var appointment = new Appointment();

            appointment.StartTime = startTime;
            appointment.Subject   = "Anime - " + animeItemViewModel.Title;
            appointment.AllDay    = true;

            var recurrence = new AppointmentRecurrence();

            recurrence.Unit       = AppointmentRecurrenceUnit.Weekly;
            recurrence.Interval   = 1;
            recurrence.DaysOfWeek = UWPUtilities.DayToAppointementDay(day);
            if (animeItemViewModel.EndDate != AnimeItemViewModel.InvalidStartEndDate)
            {
                var endDate = DateTime.Parse(animeItemViewModel.EndDate);
                recurrence.Until = endDate;
            }
            else if (animeItemViewModel.StartDate != AnimeItemViewModel.InvalidStartEndDate &&
                     animeItemViewModel.AllEpisodes != 0)
            {
                var weeksPassed = (DateTime.Today - DateTime.Parse(animeItemViewModel.StartDate)).Days / 7;
                if (weeksPassed < 0)
                {
                    return;
                }
                var weeks = (uint)(animeItemViewModel.AllEpisodes - weeksPassed);
                recurrence.Until = DateTime.Today.Add(TimeSpan.FromDays(weeks * 7));
            }
            else if (animeItemViewModel.AllEpisodes != 0)
            {
                var epsLeft = animeItemViewModel.AllEpisodes - animeItemViewModel.MyEpisodes;
                recurrence.Until = DateTime.Today.Add(TimeSpan.FromDays(epsLeft * 7));
            }
            else
            {
                var msg = new MessageDialog("Not enough data to create event.");
                await msg.ShowAsync();

                return;
            }
            appointment.Recurrence = recurrence;
            var rect = new Rect(new Point(Window.Current.Bounds.Width / 2, Window.Current.Bounds.Height / 2), new Size());

            try
            {
                await AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Placement.Default);
            }
            catch (Exception)
            {
                //appointpent is already being created
            }
        }
예제 #6
0
        private async void CropImage(bool wide = false)
        {
            IsCropEnabled = false;
            try
            {
                var             img           = wide ? _previewImageWide : _previewImageNormal;
                WriteableBitmap resizedBitmap = new WriteableBitmap(CropWidth, CropHeight);
                //if (img.UriSource == null)
                //await resizedBitmap.LoadAsync(_originaPickedStorageFile);
                /*else*/
                if (!img.UriSource.ToString().Contains("ms-appdata"))
                {
                    var imgFile = await SaveImage(img, wide);

                    await resizedBitmap.LoadAsync(imgFile);
                }
                else
                {
                    await resizedBitmap.LoadAsync(await StorageFile.GetFileFromApplicationUriAsync(img.UriSource));
                }

                if (wide)
                {
                    resizedBitmap = resizedBitmap.Crop(CropLeftWide, CropTopWide, CropWidthWide + CropLeftWide, CropTopWide + CropHeightWide);
                }
                else
                {
                    resizedBitmap = resizedBitmap.Crop(CropLeft, CropTop, CropWidth + CropLeft, CropTop + CropHeight);
                }

                var file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync($"_cropTemp{(wide ? "Wide" : "")}.png", CreationCollisionOption.GenerateUniqueName);

                if (wide)
                {
                    _lastCroppedFileNameWide = file.Name;
                }
                else
                {
                    _lastCroppedFileName = file.Name;
                }

                await resizedBitmap.SaveAsync(file, BitmapEncoder.PngEncoderId);

                if (wide)
                {
                    PreviewImageWide = new BitmapImage(new Uri($"ms-appdata:///temp/{file.Name}"));
                }
                else
                {
                    PreviewImageNormal = new BitmapImage(new Uri($"ms-appdata:///temp/{file.Name}"));
                    UndoCropVisibility = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                UWPUtilities.GiveStatusBarFeedback("An error occured...");
            }
            IsCropEnabled = true;
        }
예제 #7
0
        public void SetText(string text)
        {
            var dp = new DataPackage();

            dp.SetText(text);
            Clipboard.SetContent(dp);
            UWPUtilities.GiveStatusBarFeedback("Copied to clipboard...");
        }
예제 #8
0
        private void Card_Loaded(object sender, RoutedEventArgs e)
        {
            if (Application.Current.RequestedTheme == ApplicationTheme.Dark)
            {
                var appShell = UWPUtilities.FindParent <AppShell>(Parent);
                if (appShell != null)
                {
                    appShell.Background = (Brush)Application.Current.Resources["SystemControlBackgroundListLowBrush"];
                }

                CardGrid.Background      = (Brush)Application.Current.Resources["SystemControlBackgroundChromeMediumBrush"];
                CardShadow.ShadowOpacity = 0.3f;
            }
            else
            {
                CardGrid.Background      = new SolidColorBrush(Colors.White);
                CardShadow.ShadowOpacity = 0.1f;
            }

            data = new ObservableCollection <Data>();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            Random rnd = new Random();

            timer.Tick += (o, o1) =>
            {
                Add(rnd.Next(2, 100));
            };

            timer.Start();
            for (int i = 0; i <= 60; i++)
            {
                data.Add(new Data()
                {
                    Value = 0
                });
            }

            lineSeries.DataContext = data;

            sasSeries.Stroke = new SolidColorBrush(Color);

            var color1 = Color;

            color1.A = 94;

            var color2 = Color;

            color2.A = 0;

            gs1Color.Color = color1;
            gs2Color.Color = color2;

            data.CollectionChanged += Data_CollectionChanged;
        }
예제 #9
0
 public SettingsPage()
 {
     InitializeComponent();
     Loaded += (sender, args) => ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageAnimeList, null);
     ViewModel.NavigationRequest += ViewModelOnNavigationRequest;
     SettingsNavFrame.Navigate(typeof(SettingsHomePage), null);
     MobileViewModelLocator.Main.CurrentStatus = $"Settings - {UWPUtilities.GetAppVersion()}";
     _initialized = true;
 }
예제 #10
0
        private void CopyLinkToClipboardCommand(object sender, RoutedEventArgs e)
        {
            FlyoutMore.Hide();
            var dp = new DataPackage();

            dp.SetText($"http://www.myanimelist.net/{(ViewModel.AnimeMode ? "anime" : "manga")}/{ViewModel.Id}");
            Clipboard.SetContent(dp);
            UWPUtilities.GiveStatusBarFeedback("Copied to clipboard...");
        }
예제 #11
0
        private void ProcessUpdate()
        {
            if (ApplicationData.Current.LocalSettings.Values["AppVersion"] != null &&
                (string)ApplicationData.Current.LocalSettings.Values["AppVersion"] != UWPUtilities.GetAppVersion())
            {
                ChangeLogProvider.NewChangelog = true;
            }

            ApplicationData.Current.LocalSettings.Values["AppVersion"] = UWPUtilities.GetAppVersion();
        }
예제 #12
0
 private async void LaunchUri(string url)
 {
     try
     {
         ResourceLocator.SystemControlsLauncherService.LaunchUri(new Uri(url));
     }
     catch (Exception)
     {
         //wrong url provided
         UWPUtilities.GiveStatusBarFeedback("Invalid target url...");
     }
 }
        public async Task UpdateProfileImg(bool dl = true)
        {
            if (Credentials.Authenticated)
            {
                try
                {
                    var file = await ApplicationData.Current.LocalFolder.GetFileAsync("UserImg.png");

                    var props = await file.GetBasicPropertiesAsync();

                    if (props.Size == 0)
                    {
                        throw new FileNotFoundException();
                    }
                    var bitmap = new BitmapImage();
                    using (var fs = (await file.OpenStreamForReadAsync()).AsRandomAccessStream())
                    {
                        bitmap.SetSource(fs);
                    }
                    UserImage = bitmap;
                    UsrImgPlaceholderVisibility = Visibility.Collapsed;
                }
                catch (FileNotFoundException)
                {
                    UserImage = new BitmapImage();
                    if (dl)
                    {
                        await UWPUtilities.DownloadProfileImg();
                    }
                    else
                    {
                        UsrImgPlaceholderVisibility = Visibility.Visible;
                    }
                }
                catch (Exception)
                {
                    UsrImgPlaceholderVisibility = Visibility.Visible;
                    UserImage = new BitmapImage();
                }

                ProfileButtonVisibility = true;
            }
            else
            {
                UWPUtilities.RemoveProfileImg();
                ProfileButtonVisibility = false;
            }
        }
예제 #14
0
        public async void DownloadImageDefault(string url, string suggestedFilename, bool animeCover)
        {
            try
            {
                var lib = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);

                var folder = await lib.SaveFolder.CreateFolderAsync("MALCLient Images", CreationCollisionOption.OpenIfExists);

                var file = await folder.CreateFileAsync(UWPUtilities.SanitizeFileName(suggestedFilename) + ".png");
                await Download(url, file, animeCover);

                UWPUtilities.GiveStatusBarFeedback("File saved successfully.");
            }
            catch (Exception)
            {
                UWPUtilities.GiveStatusBarFeedback("Error. File didn't save properly.");
            }
        }
예제 #15
0
        private void Card_Loaded(object sender, RoutedEventArgs e)
        {
            if (Application.Current.RequestedTheme == ApplicationTheme.Dark)
            {
                var appShell = UWPUtilities.FindParent <AppShell>(Parent);
                if (appShell != null)
                {
                    appShell.Background = (Brush)Application.Current.Resources["SystemControlBackgroundListLowBrush"];
                }

                CardGrid.Background      = (Brush)Application.Current.Resources["SystemControlBackgroundChromeMediumBrush"];
                CardShadow.ShadowOpacity = 0.3f;
            }
            else
            {
                CardGrid.Background      = new SolidColorBrush(Colors.White);
                CardShadow.ShadowOpacity = 0.1f;
            }
        }
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     SetSortOrder();
     BtnDescending.IsChecked  = Settings.IsSortDescending;
     BtnMDescending.IsChecked = Settings.IsMangaSortDescending;
     SetDesiredStatus();
     ToggleSwitchSetup();
     ComboThemes.SelectedIndex       = (int)Settings.SelectedTheme;
     TxtThemeChangeNotice.Visibility = Settings.SelectedTheme != (int)Application.Current.RequestedTheme
         ? Visibility.Visible
         : Visibility.Collapsed;
     if (Settings.DefaultMenuTab == "anime")
     {
         RadioTabAnime.IsChecked = true;
     }
     else
     {
         RadioTabManga.IsChecked = true;
     }
     MobileViewModelLocator.Main.CurrentStatus = $"Settings - {UWPUtilities.GetAppVersion()}";
     _initialized = true;
 }
예제 #17
0
        private async Task <StorageFile> SaveImage(BitmapImage img, bool wide)
        {
            try
            {
                var uri = img.UriSource;

                var    http     = new HttpClient();
                byte[] response = { };
                var    file     = await ApplicationData.Current.TemporaryFolder.CreateFileAsync($"_cropTemp{(wide ? "Wide" : "")}.png", CreationCollisionOption.GenerateUniqueName);

                //get bytes
                await Task.Run(async() => response = await http.GetByteArrayAsync(uri));


                var fs = await file.OpenStreamForWriteAsync(); //get stream

                var writer = new DataWriter(fs.AsOutputStream());

                writer.WriteBytes(response); //write
                await writer.StoreAsync();

                await writer.FlushAsync();

                writer.Dispose();
                return(file);
            }
            catch (Exception)
            {
                UWPUtilities.GiveStatusBarFeedback("An error occured...");
                return(null);
            }


            //var bmp = new WriteableBitmap(img.PixelWidth, img.PixelHeight);
            //bmp = await bmp.LoadFromBitmapImageSourceAsync(img);

            //await bmp.SaveAsync(file, BitmapEncoder.PngEncoderId);
            //return file;
        }
예제 #18
0
        private async void PinThing()
        {
            IsPinEnabled = false;
            try
            {
                if (SelectedImageOptionIndex == 0)
                {
                    //if we didn't crop
                    if (string.IsNullOrEmpty(_lastCroppedFileName))
                    {
                        var file = await SaveImage(PreviewImageNormal, false);

                        _lastCroppedFileName = file.Name;
                        //if we din't crop wide either
                        if (string.IsNullOrEmpty(_lastCroppedFileNameWide))
                        {
                            _lastCroppedFileNameWide = file.Name; //set source to this
                        }
                    }
                    //if we didn't crop wide... you get the idea
                    if (string.IsNullOrEmpty(_lastCroppedFileNameWide))
                    {
                        //we may have not even opened wide pivot image -> no img loaded -> no width -> assume normal picture
                        if (PreviewImageWide.PixelWidth == 0)
                        {
                            _lastCroppedFileNameWide = _lastCroppedFileName;
                        }
                        else
                        {
                            var file = await SaveImage(PreviewImageWide, true);

                            _lastCroppedFileNameWide = file.Name;
                            if (string.IsNullOrEmpty(_lastCroppedFileName))
                            {
                                _lastCroppedFileName = file.Name;
                            }
                        }
                    }
                }
                var action = new PinTileActionSetting();
                switch (SelectedActionIndex)
                {
                case 0:
                    action.Action = TileActions.OpenUrl;
                    action.Param  = TargetUrl ?? "";
                    break;

                case 1:
                    action.Action = TileActions.OpenUrl;
                    action.Param  = Settings.SelectedApiType == ApiType.Mal
                            ? $"https://myanimelist.net/{(EntryData.ParentAbstraction.RepresentsAnime ? "anime" : "manga")}/{EntryData.Id}"
                            : $"https://hummingbird.me/{(EntryData.ParentAbstraction.RepresentsAnime ? "anime" : "manga")}/{EntryData.Id}";
                    break;

                default:
                    action.Action = TileActions.OpenDetails;
                    action.Param  =
                        $"https://myanimelist.net/{(EntryData.ParentAbstraction.RepresentsAnime ? "anime" : "manga")}/{EntryData.Id}/{EntryData.Title}";
                    break;
                }
                await LiveTilesManager.PinTile(EntryData, (SelectedImageOptionIndex == 0 ? new Uri($"ms-appdata:///temp/{_lastCroppedFileName}") : null), (SelectedImageOptionIndex == 0 ? new Uri($"ms-appdata:///temp/{_lastCroppedFileNameWide}") : null), PinSettings, action);

                GeneralVisibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                UWPUtilities.GiveStatusBarFeedback("An error occured...");
            }
            IsPinEnabled = true;
        }
예제 #19
0
        private void Card_Loaded(object sender, RoutedEventArgs e)
        {
            if (Application.Current.RequestedTheme == ApplicationTheme.Dark)
            {
                var appShell = UWPUtilities.FindParent <AppShell>(Parent);
                if (appShell != null)
                {
                    appShell.Background = (Brush)Application.Current.Resources["SystemControlBackgroundListLowBrush"];
                }

                CardGrid.Background      = (Brush)Application.Current.Resources["SystemControlBackgroundChromeMediumBrush"];
                CardShadow.ShadowOpacity = 0.3f;
            }
            else
            {
                CardGrid.Background      = new SolidColorBrush(Colors.White);
                CardShadow.ShadowOpacity = 0.1f;
            }

            data = new ObservableCollection <Data>();

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            Random rnd = new Random();

            timer.Tick += (o, o1) =>
            {
                Add(rnd.Next(1, 200), rnd.Next(1, 200), rnd.Next(2, 200));
            };

            timer.Start();

            for (int i = 0; i <= 30; i++)
            {
                data.Add(new Data()
                {
                    BarCategory = DateTime.Now,
                    BarValue1   = 1,
                    BarValue2   = 1
                });
            }

            chart.DataContext = data;

            var colorLow = UIUtility.GetAccentColorLow();
            var color    = UIUtility.GetAccentColor();

            sbLineBrush.Color = color;

            var color1 = colorLow;

            color1.A = 94;

            var color2 = colorLow;

            color2.A = 0;

            gs1Color.Color = color1;
            gs2Color.Color = color2;

            sbColor1.Color = color;
            sbColor2.Color = colorLow;
        }
예제 #20
0
        public void SetName(string publicKey)
        {
            var txtName = UWPUtilities.FindControlWithName <TextBlock>("txtName", MyNavView);

            txtName.Text = publicKey.Substring(publicKey.Length - 4);
        }
예제 #21
0
        public void SetBalanceText(string amount)
        {
            var txtAmount = UWPUtilities.FindControlWithName <TextBlock>("txtAmount", MyNavView);

            txtAmount.Text = amount;
        }
예제 #22
0
        private void ProcessUpdate()
        {
            InitializationRoutines.InitPostUpdate();

            ApplicationData.Current.LocalSettings.Values["AppVersion"] = UWPUtilities.GetAppVersion();
        }