Example #1
0
        private async Task FavListView_LoadItem(FavViewModel vm)
        {
            if (vm.VideoList.Count > 0)
            {
                return;
            }
            var fav = await BiliFavHelper.GetBiliFavAsync(vm.Id, 1, Settings.SESSDATA);

            if (fav.Id == 0)
            {
                var dialog = new NoticeDialog("提示", "已经没有更多了", "确定");
                await dialog.ShowAsync();

                return;
            }
            var list = new List <FavVideoViewModel>();

            foreach (var video in fav.VideoMasters)
            {
                list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.CoverUrl));
            }
            list.ForEach(v => vm.VideoList.Add(v));
            vm.VideoList.Add(new FavVideoViewModel()
            {
                Bv       = "加载更多",
                Title    = "加载更多",
                CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png"))
            });
        }
Example #2
0
        private async void FavVideoGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if ((e.ClickedItem as FavVideoViewModel).Bv == "加载更多")
            {
                var vm = FavListView.SelectedItem as FavViewModel;
                await vm.GetMoreVideoAsync();
            }
            else if (!Regex.IsMatch((e.ClickedItem as FavVideoViewModel).Bv, "[B|b][V|v][0-9]*"))
            {
                return;
            }
            else
            {
                try
                {
                    var info   = e.ClickedItem as FavVideoViewModel;
                    var master = await BiliVideoHelper.GetVideoMasterAsync(info.Bv, Settings.SESSDATA);

                    NavigationHelper.NavigateToPage(ContentPage.Search);
                    SearchPage.Current.HandleMaster <BiliVideoMasterResultPage, BiliVideoMaster>(master);
                }
                catch (ParsingVideoException)
                {
                    var dialog = new NoticeDialog("提示", "该视频已失效");
                    await dialog.ShowAsync();
                }
                catch (Exception ex)
                {
                    _logger.Info(ex, ex.Message);
                }
            }
        }
Example #3
0
 private void CalcAmounts()
 {
     try
     {
         decimal iamount;
         if (!decimal.TryParse(SendAmountTextBox.Text.Trim(), out iamount))
         {
             return;
         }
         if (iamount < 0)
         {
             SendAmountTextBox.Text = "0.1";
         }
         var act = (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                    where a.FriendlyName == AppViewModel.SelectedAccountFriendlyName
                    select a).First();
         AvailableBalanceTextBox.Text = (act.Balance - 0.000000005m).ToString("F8");
         var ttl = iamount + Properties.Settings.Default.SendFee;
         TotalAmountTextBox.Text = ttl.ToString("F8");
         if (ttl > act.Balance)
         {
             var nd = new NoticeDialog("Invalid Amount", "Total amount exceeds available balance.");
             nd.ShowDialog();
         }
     }
     catch
     {
     }
 }
 private static async void App_AppServiceDisconnected(object sender, EventArgs e)
 {
     await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async() =>
     {
         var dialog = new NoticeDialog("警告", "视频合并辅助进程被关闭,这将无法进行视频合并,请重启程序", "关闭程序", "忽略(不推荐)");
         if (await dialog.ShowAsync() == Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
         {
             App.Current.Exit();
         }
     });
 }
Example #5
0
        private async void AddServerButton_Click(object sender, RoutedEventArgs e)
        {
            var serverurl = NewServerTextBox.Text.ToLower().Trim();

            if (string.IsNullOrEmpty(serverurl))
            {
                return;
            }
            if (!serverurl.StartsWith("https://"))
            {
                var nd = new NoticeDialog("Server Address Error",
                                          "Error: Server must start with \"https://\".\r\nPlease correct the address and try again.");
                nd.ShowDialog();
                ;
                return;
            }
            var pingtime = AppHelpers.GetServerResponseTime(serverurl);

            if (pingtime <= 0 || pingtime > 120)
            {
                var nd = new NoticeDialog("Server Connection Error",
                                          "Error: Server connection failed or did not respond fast enough (" + pingtime +
                                          " ms).\r\nPlease try a different server.");
                nd.ShowDialog();
                return;
            }

            try
            {
                var api = new LiskAPI(serverurl);
                var ss  = await api.Loader_Status();

                if (!ss.loaded)
                {
                    var nd = new NoticeDialog("Server Sync Error",
                                              "Error: Server failed sync status test.\r\nPlease try a different server.");
                    nd.ShowDialog();
                    return;
                }
            }
            catch
            {
                var nd = new NoticeDialog("Server API Error",
                                          "Error: Server failed api test.\r\nPlease try a different server.");
                nd.ShowDialog();
                return;
            }

            Properties.Settings.Default.Servers.Add(serverurl);
            Properties.Settings.Default.Save();
            NewServerTextBox.Text = "";
            UpdateServersListView();
        }
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     //检查有没有设置下载目录
     if (string.IsNullOrWhiteSpace(Settings.DownloadPath))
     {
         var dialog = new NoticeDialog("请设置下载目录", "使用前必须设置下载目录", "转到“设置”");
         if (await dialog.ShowAsync() == ContentDialogResult.Primary)
         {
             NavigationHelper.NavigateToPage(ContentPage.Settings);
         }
         return;
     }
 }
Example #7
0
        private void AcceptButton_OnClick(object sender, RoutedEventArgs e)
        {
            var pwh = (from p in Globals.DbContext.UserSettings select p.MasterPasswordHash).First();
            var vpr = AppHelpers.ValidateHash(MasterPasswordTextBox.Password.Trim(), pwh);

            if (!vpr)
            {
                var nd = new NoticeDialog("Master Password", "Incorrect master password.\r\nPlease try again.");
                nd.ShowDialog();
                return;
            }

            var avm = (AuthViewModel)DataContext;

            avm.Password = MasterPasswordTextBox.Password.Trim();
            avm.Accepted = true;
        }
Example #8
0
        public async Task GetMoreVideoAsync()
        {
            var count = this.VideoList.Count - 1;

            if ((count < 20) || (count % 20 != 0))
            {
                var dialog = new NoticeDialog("提示", "已经没有更多了", "确定");
                await dialog.ShowAsync();

                return;
            }

            var fav = await BiliFavHelper.GetBiliFavAsync(this.Id, (count / 20) + 1, Settings.SESSDATA);

            if (fav.Id == 0)
            {
                var dialog = new NoticeDialog("提示", "已经没有更多了", "确定");
                await dialog.ShowAsync();

                return;
            }

            var list = new List <FavVideoViewModel>();

            foreach (var video in fav.VideoMasters)
            {
                list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.CoverUrl));
            }

            this.VideoList.Remove(this.VideoList.TakeLast(1).Single());
            list.ForEach(v => this.VideoList.Add(v));

            this.VideoList.Add(new FavVideoViewModel()
            {
                Bv       = "加载更多",
                Title    = "加载更多",
                CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png"))
            });
        }
Example #9
0
 //修改通知
 private void toolStripButton14_Click(object sender, EventArgs e)
 {
     if (dataGridView5.CurrentRow == null)
     {
         return;
     }
     if (Convert.ToInt32(dataGridView5.CurrentRow.Cells[2].Value) != Utilities.TeaIdConvertToDbId(teacher.Id))
     {
         MessageBox.Show("不能修改其他教师发布的通知!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         DataTable tab = MessageManager.ReturnBody(Convert.ToInt32(dataGridView5.CurrentRow.Cells[0].Value));
         var       r   = dataGridView5.CurrentRow.Cells;
         using (NoticeDialog modifyDialog = new NoticeDialog(teacher,
                                                             Convert.ToInt32(r[0].Value),
                                                             r[1].Value as string,
                                                             tab.Rows[0][0].ToString()))
             modifyDialog.ShowDialog();
         RefreshClassTable();
     }
 }
Example #10
0
        private async void ModernButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(AccountSecretTextBox.Text.Trim()))
            {
                return;
            }
            var sec        = AccountSecretTextBox.Text;
            var issecvalid = await AppHelpers.IsSecretValid(sec);

            if (!issecvalid)
            {
                var nd = new NoticeDialog("Invalid Account Secret",
                                          "Invalid account secret.\r\nPlease correct and try again.");
                nd.ShowDialog();
                return;
            }
            AccountSecretTextBox.Text = "";
            var act = await Globals.API.Accounts_Open(sec);

            var fn = AccountFriendlyNameTextBox.Text.Trim();

            AccountFriendlyNameTextBox.Text = "";
            if (string.IsNullOrEmpty(fn))
            {
                var dg = await Globals.API.Delegates_Get(act.account.publicKey);

                if (dg != null && dg.success && dg.@delegate != null && !string.IsNullOrEmpty([email protected]))
                {
                    fn = [email protected];
                }
            }

            var hasrecord = (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                             where a.Address == act.account.address || a.FriendlyName == fn
                             select a).Any();

            if (hasrecord)
            {
                var nd = new NoticeDialog("Account Record Exists",
                                          "A record for this account secret or friendly name already exists.\r\nPlease use a different secret or friendly name and try again");
                nd.ShowDialog();
                return;
            }

            using (var avm = new AuthViewModel {
                ActionDescription = "Add / Import new account " + fn
            })
            {
                var rmpw = new AuthRequestDialog(avm);
                rmpw.ShowDialog();
                if (!avm.Accepted)
                {
                    return;
                }
                if (rmpw.DialogResult == null || rmpw.DialogResult == false || string.IsNullOrEmpty(avm.Password))
                {
                    return;
                }

                var ssece = AppHelpers.EncryptString(sec, avm.Password);
                var ni    = new Account
                {
                    Address      = act.account.address,
                    PublicKey    = act.account.publicKey,
                    FriendlyName = fn,
                    SecretHash   = ssece,
                    Balance      = LiskAPI.LSKLongToDecimal(act.account.balance)
                };
                await AccountsViewModel.AddAccountAsync(ni);

                NavigationCommands.BrowseBack.Execute(null, null);
            }
        }
Example #11
0
        private async void BulkImportButton_OnClick(object sender, RoutedEventArgs e)
        {
            var fd = new OpenFileDialog();

            fd.Multiselect = false;
            fd.Filter      = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
            var showDialog = fd.ShowDialog();
            var res        = showDialog != null && (bool)showDialog;

            if (!res || string.IsNullOrEmpty(fd.FileName) || !File.Exists(fd.FileName))
            {
                return;
            }

            string[] secrets;
            try
            {
                secrets = File.ReadAllText(fd.FileName).Split(',');
            }
            catch (Exception)
            {
                var nd = new NoticeDialog("Bulk Account Import",
                                          "Error: CSV file could not be parsed.\r\nPlease correct the file and try again.");
                nd.ShowDialog();
                return;
            }

            using (var avm = new AuthViewModel {
                ActionDescription = "Bulk Import Accounts "
            })
            {
                var rmpw = new AuthRequestDialog(avm);
                rmpw.ShowDialog();
                if (!avm.Accepted)
                {
                    return;
                }
                if (rmpw.DialogResult == null || rmpw.DialogResult == false || string.IsNullOrEmpty(avm.Password))
                {
                    return;
                }
                var i  = 0;
                var ii = 1;
                var pd = new ProcessingDialog("Importing Accounts",
                                              "Please wait while your accounts are imported. This may take some time depending on the number of accounts.");
                pd.Show();
                foreach (var sec in secrets)
                {
                    ii++;
                    pd.ProgressTextBlock.Text = ii + " of " + secrets.Length;
                    var act = await Globals.API.Accounts_Open(sec);

                    if (!act.success)
                    {
                        continue;
                    }

                    var hasrecord = (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                                     where a.Address == act.account.address
                                     select a).Any();
                    if (hasrecord)
                    {
                        continue;
                    }

                    var ssece = AppHelpers.EncryptString(sec, avm.Password);
                    var bal   = LiskAPI.LSKLongToDecimal(act.account.balance);
                    var ni    = new Account
                    {
                        Address      = act.account.address,
                        PublicKey    = act.account.publicKey,
                        FriendlyName = act.account.address,
                        SecretHash   = ssece,
                        Balance      = bal,
                        LastUpdate   = DateTime.UtcNow
                    };
                    try
                    {
                        await AccountsViewModel.AddAccountAsync(ni);

                        i++;
                    }
                    catch (Exception crap)
                    {
                        Console.WriteLine("Error saving imported account " + act.account.address + " | " + crap.Message);
                    }
                }
                pd.Hide();
                var nd = new NoticeDialog("Bulk Account Import",
                                          "Bulk account import complete.\r\n" + i + " of " + secrets.Length + " accounts imported.");
                nd.ShowDialog();
                NavigationCommands.BrowseBack.Execute(null, null);
            }
        }
Example #12
0
        private async void BangumiListGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var info = e.ClickedItem as BangumiViewModel;

            if (info.SeasonId == 0)
            {
                var list  = BangumiListGridView.ItemsSource as ObservableCollection <BangumiViewModel>;
                var count = list.Count - 1;

                async Task NoticeNoMore()
                {
                    var dialog = new NoticeDialog("提示", "已经没有更多了");
                    await dialog.ShowAsync();
                }

                if ((count < 15) || (count % 15 != 0))
                {
                    await NoticeNoMore();

                    return;
                }
                var newList = await BiliFavHelper.GetFavBangumiMasterListAsync((count / 15) + 1, Settings.Uid, Settings.SESSDATA);

                if (newList == null)
                {
                    await NoticeNoMore();

                    return;
                }
                var toAddList = new List <BangumiViewModel>();
                list.Remove(list.Last());
                foreach (var bangumi in newList)
                {
                    var model = new BangumiViewModel()
                    {
                        Title    = bangumi.Title,
                        SeasonId = bangumi.SeasonId
                    };
                    try
                    {
                        model.CoverImg = new BitmapImage(new Uri(bangumi.CoverUrl));
                    }
                    catch (Exception ex)
                    {
                        _logger.Info(ex, ex.Message);
                    }
                    toAddList.Add(model);
                }
                toAddList.ForEach(b => list.Add(b));
                list.Add(new BangumiViewModel()
                {
                    Title    = "加载更多",
                    SeasonId = 0,
                    //CoverImg = ???
                });
            }
            else
            {
                var master = await BiliBangumiHelper.GetBangumiMasterAsync(info.SeasonId, Settings.SESSDATA);

                NavigationHelper.NavigateToPage(ContentPage.Search);
                SearchPage.Current.HandleMaster <BiliBangumiMasterResultPage, BiliBangumiMaster>(master);
            }
        }
Example #13
0
        private async void SendLSKButton_OnClick(object sender, RoutedEventArgs e)
        {
            var act = (from a in Globals.AppViewModel.AccountsViewModel.Accounts
                       where a.FriendlyName == AppViewModel.SelectedAccountFriendlyName
                       select a).First();
            var     avail = act.Balance;
            decimal iamount;

            if (!decimal.TryParse(SendAmountTextBox.Text.Trim(), out iamount))
            {
                ShowNotice("Send LSK", "Please enter a valid send amount and try again.");
                return;
            }
            if (iamount + Properties.Settings.Default.SendFee > avail || iamount < 0.1m)
            {
                ShowNotice("Send LSK",
                           "Sorry the amount specified exceeds your available balance.\r\nPlease enter a valid send amount and try again.");
                return;
            }
            //verify the toaddress is valid by checking the length and format
            if (ToAddressTextBox.Text.Trim().Length < 20 || ToAddressTextBox.Text.Trim().Length > 21 ||
                !ToAddressTextBox.Text.Trim().EndsWith("l"))
            {
                ShowNotice("Send LSK",
                           "Sorry the address specified does not apear to be valid.\r\nPlease check the address for errors and try again.");
                return;
            }
            transactions_send_response res;

            using (
                var avm = new AuthViewModel
            {
                ActionDescription =
                    "Send " + iamount + " LSK from " + act.FriendlyName + " to " + ToAddressTextBox.Text.Trim()
            })
            {
                var rmpw = new AuthRequestDialog(avm);
                rmpw.ShowDialog();
                if (!avm.Accepted)
                {
                    return;
                }
                if (rmpw.DialogResult == null || rmpw.DialogResult == false || string.IsNullOrEmpty(avm.Password))
                {
                    return;
                }
                var actsec = AppHelpers.DecryptString(act.SecretHash, avm.Password);
                res = await Globals.API.Transactions_Send(actsec, (long)LiskAPI.LSKDecimalToLong(iamount),
                                                          ToAddressTextBox.Text.Trim(), act.PublicKey, "");
            }
            if (res == null || !res.success || string.IsNullOrEmpty(res.transactionId))
            {
                if (res != null && !string.IsNullOrEmpty(res.error))
                {
                    Console.WriteLine("Send transaction failed or did not return a transaction id, " + res.error);
                    var nd = new NoticeDialog("Send LSK Failed",
                                              "Sending of " + iamount + " LSK from " + act.FriendlyName + " to " +
                                              ToAddressTextBox.Text.Trim() + " failed.\r\nError: " + res.error);
                    nd.ShowDialog();
                }
                else
                {
                    Console.WriteLine("Send transaction failed or did not return a transaction id, no additional data");
                    var nd = new NoticeDialog("Send LSK Failed",
                                              "Sending of " + iamount + " LSK from " + act.FriendlyName + " to " +
                                              ToAddressTextBox.Text.Trim() + " failed.\r\nError: no error data available.");
                    nd.ShowDialog();
                }
            }
            else
            {
                Console.WriteLine("Send transaction id " + res.transactionId + " sent " + iamount + " LSK from " +
                                  act.FriendlyName + " to " + ToAddressTextBox.Text.Trim());
                var nd = new NoticeDialog("Send LSK",
                                          "Sent " + iamount + " LSK from " + act.FriendlyName + " to " + ToAddressTextBox.Text.Trim());
                nd.ShowDialog();
            }
            try
            {
                Send_OnLoaded(null, null);
            }
            catch
            {
            }
        }
Example #14
0
        private bool?ShowNotice(string title, string message)
        {
            var nd = new NoticeDialog(title, message);

            return(nd.ShowDialog());
        }
Example #15
0
 //发布通知
 private void toolStripButton13_Click(object sender, EventArgs e)
 {
     using (NoticeDialog addNoticeDialog = new NoticeDialog(teacher))
         addNoticeDialog.ShowDialog();
     RefreshClassTable();
 }