private void DoLogout() { Invoke(() => { SignOutButton.Content = "正在注销"; SignOutButton.IsEnabled = false; }); HttpClient client = new HttpClient(); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "http://msdate.monreeing.com:3000/user/logout/"); requestMessage.Content = new StringContent(logoutJson); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.SendAsync(requestMessage).GetAwaiter().GetResult(); if (response.StatusCode.ToString() == "OK") { string result = response.Content.ReadAsStringAsync().Result.ToString(); JObject jo = JObject.Parse(result); if (jo["Code"].ToString().Equals("0")) { localSettings.Values["Token"] = ""; localSettings.Values["TimeStamp"] = ""; localSettings.Values["UserName"] = ""; Invoke(() => { PopupNotice popupNotice = new PopupNotice("注销成功"); popupNotice.ShowAPopup(); SignOutButton.Content = "退出登录"; SignOutButton.IsEnabled = true; SignOutButton.Visibility = Visibility.Collapsed; SyncButton.Visibility = Visibility.Collapsed; LoginButton.Visibility = Visibility.Visible; EmailStackPanel.Visibility = Visibility.Collapsed; PersonalEmail.Text = ""; }); } else { Invoke(() => { string errorMsg = jo["Message"].ToString(); PopupNotice popupNotice = new PopupNotice("注销失败" + errorMsg); popupNotice.ShowAPopup(); }); } } else { Invoke(() => { PopupNotice popupNotice = new PopupNotice("服务器错误:未知原因"); popupNotice.ShowAPopup(); }); } Invoke(() => { SignOutButton.Content = "退出登录"; SignOutButton.IsEnabled = true; }); }
public void DoGetVCode() { try { HttpClient client = new HttpClient(); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "http://msdate.monreeing.com:3000/email/signup_code/"); requestMessage.Content = new StringContent(getVCodeJson); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.SendAsync(requestMessage).GetAwaiter().GetResult(); if (response.StatusCode.ToString() == "OK") { string r = response.Content.ReadAsStringAsync().Result.ToString(); //Console.WriteLine(r); } else { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("服务器错误:未知原因"); popupNotice.ShowAPopup(); }); } } catch (Exception e) { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("获取验证码失败:" + e.Message); popupNotice.ShowAPopup(); }); } }
private void GetVCodeButton_Click(object sender, RoutedEventArgs e) { if (UserNameTextBox0.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("邮箱不得为空"); popupNotice.ShowAPopup(); return; } if (!IsEmail(UserNameTextBox0.Text)) { PopupNotice popupNotice = new PopupNotice("邮箱格式错误"); popupNotice.ShowAPopup(); return; } try { // 请求服务器发送验证码 getVCodeJson = "{\"Email\":\"" + UserNameTextBox0.Text + "\"}"; ThreadStart threadStart = new ThreadStart(DoGetVCode); Thread thread = new Thread(threadStart); thread.Start(); } catch (Exception ex) { PopupNotice popupNotice = new PopupNotice("服务器错误:" + ex.Message); popupNotice.ShowAPopup(); } getCodeMinute = 60; timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += Timer_Tick;//每秒触发这个事件,以刷新指针 timer.Start(); GetVCodeButton.Visibility = Visibility.Collapsed; ReSendTextBlock.Visibility = Visibility.Visible; }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (EditNickName.Text != null && EditSign.Text != null && EditBirthday_Date != null && EditSex_Sex != null && EditNickName.Text != "" && EditSign.Text != "" && EditSex_Sex != "" && EditBirthday_Date != "") { Settings.Current.PersonalNickName.Text = EditNickName.Text; Settings.Current.PersonalSign.Text = EditSign.Text; Settings.Current.PersonalBirthday.Text = EditBirthday_Date; Settings.Current.PersonalSex.Text = EditSex_Sex; localSettings.Values["NickName"] = EditNickName.Text; localSettings.Values["Sign"] = EditSign.Text; localSettings.Values["PersonalSex"] = EditSex_Sex; localSettings.Values["BirthDay_Date"] = EditBirthday_Date; Frame.Navigate(typeof(Settings)); Settings.Current.ReadSettings(); PopupNotice popupNotice = new PopupNotice("个人信息已更新"); popupNotice.ShowAPopup(); } else { MessageDialog AboutDialog = new MessageDialog("请确保填入完整的信息!", "提示"); await AboutDialog.ShowAsync(); } }
private async void BirthDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (PersonalBirthday.Text == "未设置") { MessageDialog AboutDialog = new MessageDialog("您还没有设置生日哦,赶紧去设置吧。", "提示"); await AboutDialog.ShowAsync(); BirthDialog.Hide(); } else { try { DateTime birthday = Convert.ToDateTime(PersonalBirthday.Text); string Tip = ""; string _birthday = birthday.ToString("yyyy-MM-dd"); All.Current.conn.Insert(new DataTemple() { Schedule_name = "出生日", CalculatedDate = CustomData.Calculator(_birthday), Date = _birthday, BgColor = "#fffbb612", TintOpacity = 0.7, IsTop = "0", AddTime = "" }); localSettings.Values["出生日" + _birthday] = Tip; MainPage.Current.MyNav.SelectedItem = MainPage.Current.MyNav.MenuItems[0]; Frame.Navigate(typeof(All)); PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); } catch { MessageDialog AboutDialog = new MessageDialog("您已经添加过了哦。", "提示"); await AboutDialog.ShowAsync(); } } }
private async void DateDialogPrimaryButton_Click(object sender, RoutedEventArgs e) { try { var today = DateTime.Now; var count = Convert.ToInt32(DaysTextBox.Text); if (today.AddDays(count) > Convert.ToDateTime("2120/12/31")) { PopupNotice popupNotice = new PopupNotice("超出了最大范围"); popupNotice.ShowAPopup(); } var res = today.AddDays(count); Add_Picker.Date = Convert.ToDateTime(res); } catch (FormatException e0) { } catch (Exception e1) { MessageDialog message = new MessageDialog("异常类型:" + e1.ToString() + "影响使用的话请及时反馈。", "发生异常!"); await message.ShowAsync(); } DaysTextBox.Text = ""; DateDialog.Hide(); }
private void GetCloudDataButton_Click(object sender, RoutedEventArgs e) { try { if (localSettings.Values["UserName"] != null && localSettings.Values["Token"] != null) { LoadProgressBar.IsActive = true; SyncManager syncManager = new SyncManager(localSettings.Values["UserName"].ToString(), localSettings.Values["Token"].ToString()); string data = syncManager.GetCloudTaskData().Trim().Replace("\n", ""); JArray taskListJson = (JArray)JsonConvert.DeserializeObject(data); listJson = taskListJson; LoadProgressBar.IsActive = false; TaskViewModel.ToDoDatas.Clear(); foreach (var item in taskListJson) { if (item["IsDelete"].ToString().Equals("0")) { TaskViewModel.ToDoDatas.Add(new ToDoTasks() { TaskId = item["TaskId"].ToString(), Name = item["TaskName"].ToString() }); } } LoadProgressBar.IsActive = false; GetLocalDataIcon.Visibility = Visibility.Collapsed; GetCloudDataIcon.Visibility = Visibility.Visible; } } catch (Exception err) { PopupNotice popupNotice = new PopupNotice("获取云端数据错误:" + err.Message); popupNotice.ShowAPopup(); } }
private async void MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { try { All.Current.conn.Insert(new DataTemple() { Schedule_name = App.FestivalItem.Str1, CalculatedDate = App.FestivalItem.Str2, Date = App.FestivalItem.Str3, BgColor = App.FestivalItem.Str4.ToString(), TintOpacity = 0.7, IsTop = "0", AddTime = "" }); All.Current.ViewModel.CustomDatas.Add(new CustomData() { Str1 = App.FestivalItem.Str1, Str2 = App.FestivalItem.Str2, Str3 = App.FestivalItem.Str3, Str4 = All.Current.ColorfulBrush(App.FestivalItem.Str4, 0.8), BackGroundColor = App.FestivalItem.Str4 }); All.Current.NewTB.Visibility = Visibility.Collapsed; All.Current.NewTB2.Visibility = Visibility.Collapsed; } catch { MessageDialog AboutDialog = new MessageDialog("此日程已被添加,请勿重复添加~", "提示"); await AboutDialog.ShowAsync(); return; } MainPage.Current.MyNav.SelectedItem = MainPage.Current.MyNav.MenuItems[0]; Frame.Navigate(typeof(All)); PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); }
private async void Button_Click(object sender, RoutedEventArgs e) { string _event = AddEvent.Text.Trim(); _Event = _event; //All.Current.Model_event = _event; if (_Date != null && _event != "" && _Color != "" && _TintOpacity >= 0) { try { All.Current.conn.Insert(new DataTemple() { Schedule_name = _event, CalculatedDate = _Date, Date = _PickDate, BgColor = _Color, TintOpacity = _TintOpacity, IsTop = "0", AddTime = "" }); All.Current.ViewModel.CustomDatas.Add(new CustomData() { Str1 = _event, Str2 = _Date, Str3 = _PickDate, Str4 = All.Current.ColorfulBrush(GetColor(_Color), _TintOpacity), BackGroundColor = GetColor(_Color) }); localSettings.Values[_event + _PickDate] = _Tip; All.Current.NewTB.Visibility = Visibility.Collapsed; All.Current.NewTB2.Visibility = Visibility.Collapsed; } catch { MessageDialog AboutDialog = new MessageDialog("此日程已被添加,请勿重复添加~", "提示"); await AboutDialog.ShowAsync(); return; } MainPage.Current.MyNav.SelectedItem = MainPage.Current.MyNav.MenuItems[0]; Frame.Navigate(typeof(All)); PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); } else { if (_Event == "") { MessageDialog AboutDialog = new MessageDialog("你还未填写日程名哦。", "温馨提示"); await AboutDialog.ShowAsync(); } else { if (_Date == null) { MessageDialog AboutDialog = new MessageDialog("你还未选择日程的日期哦。", "温馨提示"); await AboutDialog.ShowAsync(); } else { if (_Color == "") { MessageDialog AboutDialog = new MessageDialog("你还未更改背景选项,快选择你喜欢的背景颜色吧!", "温馨提示"); await AboutDialog.ShowAsync(); } } } } }
public async Task DownloadAndInstallAllUpdatesAsync() { UpdateRing.IsActive = true; CheckUpdate.IsEnabled = false; if (context == null) { context = StoreContext.GetDefault(); } // Get the updates that are available. IReadOnlyList <StorePackageUpdate> updates = await context.GetAppAndOptionalStorePackageUpdatesAsync(); if (updates.Count > 0) { // Alert the user that updates are available and ask for their consent // to start the updates. MessageDialog dialog = new MessageDialog( "立即下载并安装更新吗? 此过程应用可能会关闭。", "发现新版本的夏日!"); dialog.Commands.Add(new UICommand("更新")); dialog.Commands.Add(new UICommand("取消")); IUICommand command = await dialog.ShowAsync(); if (command.Label.Equals("更新", StringComparison.CurrentCultureIgnoreCase)) { //downloadProgressBar.Visibility = Visibility.Visible; // Download and install the updates. IAsyncOperationWithProgress <StorePackageUpdateResult, StorePackageUpdateStatus> downloadOperation = context.RequestDownloadAndInstallStorePackageUpdatesAsync(updates); // The Progress async method is called one time for each step in the download // and installation process for each package in this request. downloadOperation.Progress = async(asyncInfo, progress) => { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { }); }; //downloadProgressBar.Visibility = Visibility.Collapsed; StorePackageUpdateResult result = await downloadOperation.AsTask(); UpdateRing.IsActive = false; CheckUpdate.IsEnabled = true; } else { UpdateRing.IsActive = false; CheckUpdate.IsEnabled = true; } } else { UpdateRing.IsActive = false; CheckUpdate.IsEnabled = true; PopupNotice popupNotice = new PopupNotice("已是最新版本!"); popupNotice.ShowAPopup(); } }
private void UnStarButton1_Click(object sender, RoutedEventArgs e) { conn.Execute("update ToDoTasks set Star = ? , UpdateTime = ? where TaskId = ?", "0", DateTime.Now.ToString(), CurrentItem.TaskId); LoadData(); PopupNotice popupNotice = new PopupNotice("标记成功"); popupNotice.ShowAPopup(); }
private void DoneButton_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; conn.Execute("update ToDoTasks set Done = ? where TaskId = ?", "0", button.Tag); conn.Execute("update ToDoTasks set UpdateTime = ? where TaskId = ?", DateTime.Now.ToString(), button.Tag); LoadData(); PopupNotice popupNotice = new PopupNotice("标记成功"); popupNotice.ShowAPopup(); }
private void DeleteStepButton_Click(object sender, RoutedEventArgs e) { string time = DateTime.Now.ToString(); conn.Execute("update ToDoTaskSteps set IsDelete = ?, UpdateTime = ? where TaskId = ? and StepId = ?", "1", time, CurrentItem.TaskId, CurrentTaskStep.StepId); conn.Execute("update ToDoTasks set UpdateTime = ? where TaskId = ?", time, CurrentItem.TaskId); ToDoTaskStepsViewModel.ToDoTaskStepsDatas.Remove(CurrentTaskStep); PopupNotice popupNotice = new PopupNotice("删除成功"); popupNotice.ShowAPopup(); }
private void DeleteTaskDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { //conn.Execute("delete from ToDoTasks where TaskId = ?", CurrentItem.TaskId); conn.Execute("update ToDoTasks set IsDelete = ?, UpdateTime = ? where TaskId = ?", "1", DateTime.Now.ToString(), CurrentItem.TaskId); //conn.Execute("delete from ToDoTaskSteps where TaskId = ?", CurrentItem.TaskId); conn.Execute("update ToDoTaskSteps set IsDelete = ?, UpdateTime = ? where TaskId = ?", "1", DateTime.Now.ToString(), CurrentItem.TaskId); ToDoTaskViewModel1.ToDoDatas.Remove(CurrentItem); ToDoTaskViewModel2.ToDoDatas.Remove(CurrentItem); PopupNotice popupNotice = new PopupNotice("删除成功"); popupNotice.ShowAPopup(); }
private void SignUpButton_Click(object sender, RoutedEventArgs e) { if (UserNameTextBox0.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("邮箱不得为空"); popupNotice.ShowAPopup(); return; } if (!IsEmail(UserNameTextBox0.Text)) { PopupNotice popupNotice = new PopupNotice("邮箱格式错误"); popupNotice.ShowAPopup(); return; } if (PasswordPB0.Password.Equals("")) { PopupNotice popupNotice = new PopupNotice("密码不得为空"); popupNotice.ShowAPopup(); return; } if (PasswordPB0.Password.Length >= 8 && PasswordPB0.Password.Length <= 17) { PopupNotice popupNotice = new PopupNotice("密码长度须大于7位少于18位"); popupNotice.ShowAPopup(); return; } if (!RePasswordPB.Password.Equals(PasswordPB0.Password)) { PopupNotice popupNotice = new PopupNotice("两次输入密码不一致"); popupNotice.ShowAPopup(); return; } if (VCodeTextBox.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("验证码不得为空"); popupNotice.ShowAPopup(); return; } try { signUpJson = "{\"User\": {\"UserName\": \"" + UserNameTextBox0.Text + "\",\"Password\": \"" + PasswordPB0.Password + "\",\"Code\": \"" + VCodeTextBox.Text + "\"}}"; ThreadStart threadStart = new ThreadStart(DoSignUp); Thread thread = new Thread(threadStart); thread.Start(); } catch (Exception ex) { LoginPageProgressBar.IsActive = false; PopupNotice popupNotice = new PopupNotice("服务器错误:" + ex.Message); popupNotice.ShowAPopup(); } }
private async void CropperDialogPrimaryButton_Click(object sender, RoutedEventArgs e) { var imageSource = EditPicture.ProfilePicture; byte[] imageBuffer; var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; var file = await localFolder.CreateFileAsync("temp.jpg", CreationCollisionOption.ReplaceExisting); try { using (var ras = await file.OpenAsync(FileAccessMode.ReadWrite, StorageOpenOptions.None)) { WriteableBitmap bitmap = imageSource as WriteableBitmap; var stream = bitmap.PixelBuffer.AsStream(); byte[] buffer = new byte[stream.Length]; await stream.ReadAsync(buffer, 0, buffer.Length); BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, ras); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)bitmap.PixelWidth, (uint)bitmap.PixelHeight, 96.0, 96.0, buffer); await encoder.FlushAsync(); var imageStream = ras.AsStream(); imageStream.Seek(0, SeekOrigin.Begin); imageBuffer = new byte[imageStream.Length]; var re = await imageStream.ReadAsync(imageBuffer, 0, imageBuffer.Length); } await file.DeleteAsync(StorageDeleteOption.Default); List <PersonPictures> datalist = conn.Query <PersonPictures>("select * from PersonPictures where pictureName = ?", "picture"); if (datalist != null) { conn.Execute("delete from PersonPictures where pictureName = ?", "picture"); } conn.Insert(new PersonPictures() { pictureName = "picture", picture = imageBuffer }); SetPersonPicture(); PopupNotice popupNotice = new PopupNotice("头像已更新"); popupNotice.ShowAPopup(); } catch { TempPicture.Visibility = Visibility.Visible; EditPicture.Visibility = Visibility.Collapsed; }; CropperDialog.Hide(); }
private void UpdateTaskStepDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (DialogStepNameTextBox.Text.Equals("")) { return; } string time = DateTime.Now.ToString(); conn.Execute("update ToDoTaskSteps set Content = ?, UpdateTime = ? where TaskId = ? and StepId = ?", DialogStepNameTextBox.Text, time, CurrentItem.TaskId, CurrentTaskStep.StepId); conn.Execute("update ToDoTasks set UpdateTime = ? where TaskId = ?", time, CurrentItem.TaskId); LoadSteps(); PopupNotice popupNotice = new PopupNotice("修改成功"); popupNotice.ShowAPopup(); }
private void AddStepButton_Click(object sender, RoutedEventArgs e) { if (StepNameTextBox.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("内容名称不能为空~"); popupNotice.ShowAPopup(); } else { List <ToDoTaskSteps> tempList = conn.Query <ToDoTaskSteps>("select * from ToDoTaskSteps where Content = ? and TaskId = ?", StepNameTextBox.Text, CurrentItem.TaskId); if (tempList.Count != 0) { string time = DateTime.Now.ToString(); if (tempList[0].IsDelete.Equals("1")) { conn.Execute("update ToDoTaskSteps set Content = ?, Finish = ?, UnFinish = ?, UpdateTime = ?, IsDelete = ? where TaskId = ? and StepId = ?", StepNameTextBox.Text, false, true, time, "0", CurrentItem.TaskId, tempList[0].StepId); conn.Execute("update ToDoTasks set UpdateTime = ? where Name = ?", time, TaskCard.Header.ToString()); ToDoTaskStepsViewModel.ToDoTaskStepsDatas.Add(new ToDoTaskSteps() { StepId = tempList[0].StepId, TaskId = CurrentItem.TaskId, Content = StepNameTextBox.Text, Finish = false, UnFinish = true }); } else { PopupNotice popupNotice0 = new PopupNotice("请勿重复添加同一内容~"); popupNotice0.ShowAPopup(); } } else { string time = DateTime.Now.ToString(); string uuid = Guid.NewGuid().ToString(); conn.Insert(new ToDoTaskSteps() { TaskId = CurrentItem.TaskId, StepId = uuid, Content = StepNameTextBox.Text, Finish = false, UnFinish = true, UpdateTime = time, IsDelete = "0" }); conn.Execute("update ToDoTasks set UpdateTime = ? where Name = ?", time, TaskCard.Header.ToString()); ToDoTaskStepsViewModel.ToDoTaskStepsDatas.Add(new ToDoTaskSteps() { TaskId = CurrentItem.TaskId, StepId = uuid, Content = StepNameTextBox.Text, Finish = false, UnFinish = true }); } PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); StepNameTextBox.Text = ""; } }
private void UpdateTastButton_Click(object sender, RoutedEventArgs e) { string date = ""; if (ToDo_Picker.Date != null) { date = Convert.ToDateTime(ToDo_Picker.Date.ToString()).ToString("yyyy-MM-dd"); } conn.Execute("update ToDoTasks set Date = ?, UpdateTime = ? where TaskId = ?", date, DateTime.Now.ToString(), CurrentItem.TaskId); conn.Execute("update ToDoTasks set Remark = ?, UpdateTime = ? where TaskId = ?", ToDoRemarkTextBox.Text, DateTime.Now.ToString(), CurrentItem.TaskId); TaskCard.IsOpen = false; LoadData(); ToDo_Picker.Date = null; ToDoRemarkTextBox.Text = ""; PopupNotice popupNotice = new PopupNotice("更新成功"); popupNotice.ShowAPopup(); }
private void AddTaskButton_Click(object sender, RoutedEventArgs e) { if (TaskNameTextBox.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("计划名称不能为空~"); popupNotice.ShowAPopup(); } else { List <ToDoTasks> tempList = conn.Query <ToDoTasks>("select * from ToDoTasks where Name = ?", TaskNameTextBox.Text); if (tempList.Count != 0) { if (tempList[0].IsDelete.Equals("1")) { conn.Execute("update ToDoTasks set Name = ?, Date = ?, Star = ?, Remark = ?, Done = ?, UpdateTime = ?, IsDelete = ? where TaskId = ?", TaskNameTextBox.Text, "", "0", "", "0", DateTime.Now.ToString(), "0", tempList[0].TaskId); ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks() { TaskId = tempList[0].TaskId, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed }); } else { PopupNotice popupNotice0 = new PopupNotice("请勿重复添加计划"); popupNotice0.ShowAPopup(); } } else { string uuid = Guid.NewGuid().ToString(); conn.Insert(new ToDoTasks() { TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Star = "0", Remark = "", Done = "0", UpdateTime = DateTime.Now.ToString(), IsDelete = "0" }); ToDoTaskViewModel1.ToDoDatas.Add(new ToDoTasks() { TaskId = uuid, Name = TaskNameTextBox.Text, Date = "", Remark = "", UpdateTime = DateTime.Now.ToString(), StarVisibility = Visibility.Collapsed, DateVisibility = Visibility.Collapsed, RemarkVisibility = Visibility.Collapsed }); } PopupNotice popupNotice = new PopupNotice("添加成功"); popupNotice.ShowAPopup(); TaskNameTextBox.Text = ""; } }
private async void Save_Click(object sender, RoutedEventArgs e) { var rtb = new RenderTargetBitmap(); await rtb.RenderAsync(RenderBorder); var saveFile = new FileSavePicker(); saveFile.SuggestedStartLocation = PickerLocationId.PicturesLibrary; saveFile.FileTypeChoices.Add("JPEG files", new List <string>() { ".jpg" }); saveFile.SuggestedFileName = "夏日:" + DetailsEvent.Text; StorageFile sFile = await saveFile.PickSaveFileAsync(); if (sFile == null) { return; } var pixels = await rtb.GetPixelsAsync(); using (IRandomAccessStream stream = await sFile.OpenAsync(FileAccessMode.ReadWrite)) { var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); byte[] bytes = pixels.ToArray(); encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)rtb.PixelWidth, (uint)rtb.PixelHeight, 200, 200, bytes); await encoder.FlushAsync(); } PopupNotice popupNotice = new PopupNotice("保存成功"); popupNotice.ShowAPopup(); }
private async void PinTaskbarButton_Click(object sender, RoutedEventArgs e) { bool isPinned1 = await TaskbarManager.GetDefault().IsCurrentAppPinnedAsync(); if (isPinned1) { PopupNotice popupNotice = new PopupNotice("应用已固定在任务栏"); popupNotice.ShowAPopup(); } else { bool isPinned = await TaskbarManager.GetDefault().RequestPinCurrentAppAsync(); if (isPinned) { PopupNotice popupNotice = new PopupNotice("固定成功"); popupNotice.ShowAPopup(); } } }
private void LoginButton_Click(object sender, RoutedEventArgs e) { if (UserNameTextBox1.Text.Equals("")) { PopupNotice popupNotice = new PopupNotice("邮箱不得为空"); popupNotice.ShowAPopup(); return; } if (!IsEmail(UserNameTextBox1.Text)) { PopupNotice popupNotice = new PopupNotice("邮箱格式错误"); popupNotice.ShowAPopup(); return; } if (PasswordPB1.Password.Equals("")) { PopupNotice popupNotice = new PopupNotice("密码不得为空"); popupNotice.ShowAPopup(); return; } if (!(bool)PolicyCheckBox.IsChecked) { PopupNotice popupNotice = new PopupNotice("请阅读并同意隐私协议"); popupNotice.ShowAPopup(); return; } try { loginJson = "{\"User\": {\"UserName\": \"" + UserNameTextBox1.Text + "\",\"Password\": \"" + PasswordPB1.Password + "\"}}"; ThreadStart threadStart = new ThreadStart(DoLogin); Thread thread = new Thread(threadStart); thread.Start(); } catch (Exception ex) { PopupNotice popupNotice = new PopupNotice("服务器错误:" + ex.Message); popupNotice.ShowAPopup(); } }
private async void PinButton_Click(object sender, RoutedEventArgs e) { // Get your own app list entry AppListEntry entry = (await Package.Current.GetAppListEntriesAsync())[0]; bool isPinned1 = await StartScreenManager.GetDefault().ContainsAppListEntryAsync(entry); // And pin it to Start bool isPinned = await StartScreenManager.GetDefault().RequestAddAppListEntryAsync(entry); if (isPinned1 == true) { PopupNotice popupNotice = new PopupNotice("应用已固定在开始菜单"); popupNotice.ShowAPopup(); } else { if (isPinned == true) { PopupNotice popupNotice = new PopupNotice("固定成功"); popupNotice.ShowAPopup(); } } }
private async void InitFaqText() { try { FaqProgressBar.IsActive = true; HttpClient client = new HttpClient(); Uri uri = new Uri("http://www.monreeing.com/notice/get_uwp_notice.xml"); HttpResponseMessage response = await client.GetAsync(uri); response.EnsureSuccessStatusCode(); string xml = await response.Content.ReadAsStringAsync(); StringBuilder sb = new StringBuilder(); if (xml != null) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var grid = doc.FirstChild.ChildNodes; for (var i = 0; i < grid.Count; i++) { var temp = grid[i]; if (temp.NodeName == "content") { sb.Append(temp.InnerText + "\n\n"); } } } FaqText.Text = sb.ToString(); FaqProgressBar.IsActive = false; } catch (Exception e) { PopupNotice popupNotice = new PopupNotice("网络异常: " + e.GetType().ToString()); popupNotice.ShowAPopup(); } }
private void DetailsDate_Tapped(object sender, TappedRoutedEventArgs e) { if (MainPage.Current.SelectedPage) { DateTime d1 = Convert.ToDateTime(All.Current.str3); DateTime d2 = DateTime.Now; DateTime d3 = Convert.ToDateTime(string.Format("{0}/{1}/{2}", d1.Year, d1.Month, d1.Day)); DateTime d4 = Convert.ToDateTime(string.Format("{0}/{1}/{2}", d2.Year, d2.Month, d2.Day)); switch (DetailsDateMode) { case "Day": DetailsDate.Text = All.Current.ConvertToWeek(All.Current.str3); DetailsDateMode = "Week"; PopupNotice popupNotice0 = new PopupNotice("周数模式"); popupNotice0.ShowAPopup(); break; case "Week": if (d4 > d3) { DetailsDate.Text = "已过" + App.Term(d3, d4); } else { if (d4 < d3) { DetailsDate.Text = "还有" + App.Term(d4, d3); } } DetailsDateMode = "Year"; PopupNotice popupNotice1 = new PopupNotice("年数模式"); popupNotice1.ShowAPopup(); break; case "Year": DetailsDate.Text = CustomData.Calculator(All.Current.str3); DetailsDateMode = "Day"; PopupNotice popupNotice2 = new PopupNotice("天数模式"); popupNotice2.ShowAPopup(); break; } dCalDate.Text = DetailsDate.Text; } else { DateTime d1 = Convert.ToDateTime(Festival.Current.str3); DateTime d2 = DateTime.Now; DateTime d3 = Convert.ToDateTime(string.Format("{0}/{1}/{2}", d1.Year, d1.Month, d1.Day)); DateTime d4 = Convert.ToDateTime(string.Format("{0}/{1}/{2}", d2.Year, d2.Month, d2.Day)); switch (FestivalDateMode) { case "Day": DetailsDate.Text = All.Current.ConvertToWeek(Festival.Current.str3); FestivalDateMode = "Week"; PopupNotice popupNotice0 = new PopupNotice("周数模式"); popupNotice0.ShowAPopup(); break; case "Week": if (d4 > d3) { DetailsDate.Text = "已过" + App.Term(d3, d4); } else { if (d4 < d3) { DetailsDate.Text = "还有" + App.Term(d4, d3); } } FestivalDateMode = "Year"; PopupNotice popupNotice1 = new PopupNotice("年数模式"); popupNotice1.ShowAPopup(); break; case "Year": DetailsDate.Text = CustomData.Calculator(Festival.Current.str3); FestivalDateMode = "Day"; PopupNotice popupNotice2 = new PopupNotice("天数模式"); popupNotice2.ShowAPopup(); break; } dCalDate.Text = DetailsDate.Text; } }
private void DoSignUp() { try { this.Invoke(() => { LoginPageProgressBar.IsActive = true; }); HttpClient client = new HttpClient(); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "http://msdate.monreeing.com:3000/user/signup/"); requestMessage.Content = new StringContent(signUpJson); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.SendAsync(requestMessage).GetAwaiter().GetResult(); if (response.StatusCode.ToString() == "OK") { string result = response.Content.ReadAsStringAsync().Result.ToString(); JObject jo = JObject.Parse(result); string responseCode = jo["Code"].ToString(); string responseMsg = jo["Message"].ToString(); if (responseCode.Equals("0")) { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("注册成功!"); popupNotice.ShowAPopup(); LoginGrid.Visibility = Visibility.Collapsed; SignUpGrid.Visibility = Visibility.Visible; }); } else { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("注册失败:" + responseMsg); popupNotice.ShowAPopup(); }); } } else { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("注册失败:服务器异常"); popupNotice.ShowAPopup(); }); } this.Invoke(() => { LoginPageProgressBar.IsActive = false; }); } catch (Exception e) { this.Invoke(() => { LoginPageProgressBar.IsActive = false; PopupNotice popupNotice = new PopupNotice("注册失败:" + e.Message); popupNotice.ShowAPopup(); }); } }
private void DoLogin() { try { this.Invoke(() => { LoginPageProgressBar.IsActive = true; }); HttpClient client = new HttpClient(); HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, "http://msdate.monreeing.com:3000/user/login/"); requestMessage.Content = new StringContent(loginJson); requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = client.SendAsync(requestMessage).GetAwaiter().GetResult(); if (response.StatusCode.ToString() == "OK") { string result = response.Content.ReadAsStringAsync().Result.ToString(); JObject jo = JObject.Parse(result); if (jo["Code"].ToString().Equals("0")) { string userInfo = jo["User"].ToString(); JObject userInfoJson = JObject.Parse(userInfo); string token = userInfoJson["Token"].ToString(); string timeStamp = userInfoJson["TimeStamp"].ToString(); localSettings.Values["Token"] = token; localSettings.Values["TimeStamp"] = timeStamp; localSettings.Values["UserName"] = userInfoJson["UserName"].ToString(); this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("登录成功"); popupNotice.ShowAPopup(); Frame.GoBack(); Settings.Current.SignOutButton.Visibility = Visibility.Visible; Settings.Current.SyncButton.Visibility = Visibility.Visible; Settings.Current.LoginButton.Visibility = Visibility.Collapsed; }); } else { this.Invoke(() => { string errorMsg = jo["Message"].ToString(); PopupNotice popupNotice = new PopupNotice("登录失败" + errorMsg); popupNotice.ShowAPopup(); }); } } else { this.Invoke(() => { PopupNotice popupNotice = new PopupNotice("服务器错误:未知原因"); popupNotice.ShowAPopup(); }); } this.Invoke(() => { LoginPageProgressBar.IsActive = false; }); } catch (Exception e) { this.Invoke(() => { LoginPageProgressBar.IsActive = false; PopupNotice popupNotice = new PopupNotice("登录失败:" + e.Message); popupNotice.ShowAPopup(); }); } }