private async void windowLoaded(object sender, RoutedEventArgs e)
        {
            Tx.LoadFromEmbeddedResource("osu_rank.Translation.osu_rank.txd");
            if (Settings.Default.apikey == "" && Settings.Default.RippleOnly == false)
            {
                osuExpander.IsEnabled = true;
                hasApiKey             = false;
                apiDialog.IsOpen      = true;
            }
            else if (Settings.Default.RippleOnly == true)
            {
                osuExpander.IsEnabled = false;
                hasApiKey             = false;
                drawerUnbold();
                goRippleOnePlayer.FontWeight = FontWeights.SemiBold;
                actionBar_Text.Content       = "Ripple!rank - " + Tx.T("osu rank.One player");
                WindowContent.Navigate(new RipplePages.OneUser());
            }
            else if (Settings.Default.apikey != "" && Settings.Default.RippleOnly == false)
            {
                osuExpander.IsEnabled = true;
                hasApiKey             = true;
            }
            await checkForDictUpdate();

            if (Convert.ToInt32(File.ReadAllText(osuRankAppdata + @"\txdVersion.txt")) > App.minTxdVersionRequired)
            {
                Tx.LoadFromXmlFile(osuRankAppdata + @"\osu_rank.txd");
            }
            if (App.HasCheckedForUpdates == false)
            {
                App.HasCheckedForUpdates = true;
                try
                {
                    string webVersion = await new HttpClient().GetStringAsync("https://raw.githubusercontent.com/Jeremiidesu/osu-rank/master/osu-rank/osu-rank/version.txt");
                    if (Convert.ToInt32(webVersion) > App.version)
                    { // New release available
                        var updateYesNo = MessageBox.Show(Tx.T("update.text"), Tx.T("update.Title"), MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (updateYesNo == MessageBoxResult.Yes)
                        {
                            Process.Start("https://github.com/Jeremiidesu/osu-rank/releases");
                        }
                    }
                }
                catch (Exception) { }
            }
            Ping   myPing = new Ping();
            string host   = "osu.ppy.sh";

            byte[]      buffer      = new byte[32];
            int         timeout     = 5000;
            PingOptions pingOptions = new PingOptions();
            PingReply   reply       = myPing.Send(host, timeout, buffer, pingOptions);

            if (reply.Status != IPStatus.Success)
            {
                MessageBox.Show(Tx.T("osu rank.Servers unavailable"), Tx.T("errors.Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            WindowFlyoutContent Content = e.Parameter as WindowFlyoutContent;

            IconTitle.Text = Content.WindowIcon;
            TextTitle.Text = Content.WindowTitle;
            WindowContent.Navigate(Content.Content);
        }
        private void goCompare_Click(object sender, MouseButtonEventArgs e)
        {
            drawerUnbold();
            Label lbl = sender as Label;

            lbl.FontWeight         = FontWeights.SemiBold;
            actionBar_Text.Content = "osu!rank - " + Tx.T("osu rank.Compare");
            WindowContent.Navigate(new osuPages.Compare());
            closeDrawer();
        }
        private void goRippleOneUser_Click(object sender, MouseButtonEventArgs e)
        {
            drawerUnbold();
            Label lbl = sender as Label;

            lbl.FontWeight         = FontWeights.SemiBold;
            actionBar_Text.Content = "Ripple!rank - " + Tx.T("osu rank.One player");
            WindowContent.Navigate(new RipplePages.OneUser());
            closeDrawer();
        }
        private void goAbout_MouseDown(object sender, MouseButtonEventArgs e)
        {
            drawerUnbold();
            Label lbl = sender as Label;

            lbl.FontWeight         = FontWeights.SemiBold;
            actionBar_Text.Content = "osu!rank - " + Tx.T("osu rank.About");
            WindowContent.Navigate(new About());
            closeDrawer();
        }
Beispiel #6
0
 private void Return_To_MainPage(object sender, RoutedEventArgs e)
 {
     if (WindowContent.Content is SalesProducts sale)
     {
         sale.resetFilter();
     }
     else
     {
         WindowContent.Navigate(new SalesProducts());
     }
 }
        private async void apiDialog_DialogClosing(object sender, MaterialDesignThemes.Wpf.DialogClosingEventArgs eventArgs)
        {
            if ((Int16)eventArgs.Parameter == 1)
            {
                if (keyBox.Text == "")
                {
                    MessageBox.Show(Tx.T("errors.No key entered"), Tx.T("errors.Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                    eventArgs.Cancel();
                }
                else
                {
                    string test;
                    try
                    {
                        using (HttpClient wc = new HttpClient())
                        {
                            test = await wc.GetStringAsync("https://osu.ppy.sh/api/get_user?k=" + keyBox.Text + "&u=Cookiezi&m=3");

                            Settings.Default.apikey = keyBox.Text;
                        }
                        hasApiKey                   = true;
                        osuExpander.IsEnabled       = true;
                        Settings.Default.RippleOnly = false;
                        Settings.Default.Save();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(Tx.T("errors.Invalid key"), Tx.T("errors.Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                        eventArgs.Cancel();
                    }
                }
            }
            else if ((Int16)eventArgs.Parameter == 0)
            {
                MessageBox.Show(Tx.T("errors.You need a key"), Tx.T("errors.Error"), MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
            }
            else if ((Int16)eventArgs.Parameter == -1)
            {
                osuExpander.IsEnabled       = false;
                hasApiKey                   = false;
                Settings.Default.RippleOnly = true;
                Settings.Default.Save();
                drawerUnbold();
                goRippleOnePlayer.FontWeight = FontWeights.SemiBold;
                actionBar_Text.Content       = "Ripple!rank - " + Tx.T("osu rank.One player");
                WindowContent.Navigate(new RipplePages.OneUser());
            }
        }
        public MainWindowView()
        {
            InitializeComponent();

            // Reference for this application
            curApp = (App)Application.Current;

            // Initialize views for Window
            mappingSetView = new MappingSetView();

            // Initialize ViewModel and assign to DataContext for window/page
            mappingSetView.DataContext = new ViewModel.MappingSetViewModel(curApp.FileDialog, curApp.StandardMappingSetRepository, curApp.ErrorHandler);

            //Only one view for now
            WindowContent.Navigate(mappingSetView);
        }
Beispiel #9
0
 private void Cart_Click(object sender, RoutedEventArgs e)
 {
     WindowContent.Navigate(new Cart());
 }