private async void initInfomation() { await DBmanager.ConnectDatabase(); Windows.Storage.StorageFolder storageFolder = Windows.Storage.KnownFolders.PicturesLibrary; Windows.Storage.StorageFile dataFile = await storageFolder.CreateFileAsync("dat.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(dataFile, Windows.Storage.ApplicationData.Current.LocalFolder.Path); }
public MainPage() { DBmanager.ConnectDatabase(); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 50); this.InitializeComponent(); infoListMenu = StaticVariable.listMenu.FindAll(x => x.IdParent == 0); if (StaticVariable.EditMode == 1) { add_Btn.Visibility = Visibility.Visible; editTheme_Btn.Visibility = Visibility.Visible; ExitEditMode_Btn.Visibility = Visibility.Visible; delItem.Children.Clear(); for (int i = 0; i < infoListMenu.Count; i++) { Button tmp = createBtn("ms-appx:///Assets/image/x.png", 20, 20); tmp.Margin = new Thickness((Math.Cos(i * 2 * Math.PI / infoListMenu.Count + Math.PI / 2) + 1) * (menuItem.Width - tmp.Width - 80) / 2 - 30, (Math.Sin(i * 2 * Math.PI / infoListMenu.Count + Math.PI / 2) + 1) * (menuItem.Height - tmp.Height - 80) / 2, 0, 0); tmp.Click += (s, e) => { DBmanager.connection.Delete(StaticVariable.listMenu.Find(x => x.Id == infoListMenu[delItem.Children.IndexOf(s as Button)].Id)); Frame.Navigate(typeof(MainPage)); }; delItem.Children.Add(tmp); } editItem.Children.Clear(); for (int i = 0; i < infoListMenu.Count; i++) { Button tmp = createBtn("ms-appx:///Assets/image/edit.png", 20, 20); tmp.Margin = new Thickness((Math.Cos(i * 2 * Math.PI / infoListMenu.Count + Math.PI / 2) + 1) * (menuItem.Width - tmp.Width - 80) / 2 - 30, (Math.Sin(i * 2 * Math.PI / infoListMenu.Count + Math.PI / 2) + 1) * (menuItem.Height - tmp.Height - 80) / 2 + 80, 0, 0); tmp.Click += (s, e) => { menuObj = StaticVariable.listMenu.Find(x => x.Id == infoListMenu[editItem.Children.IndexOf(s as Button)].Id); TenNut.Text = menuObj.Name; comboBox.SelectedIndex = menuObj.Theme; image.Source = new BitmapImage(new Uri(menuObj.Background)); Rect.Visibility = Visibility.Visible; BtnDetail.Visibility = Visibility.Visible; // DBmanager.connection.Delete(StaticVariable.listMenu.Find(x => x.Id == infoListMenu[editItem.Children.IndexOf(s as Button)].Id)); // Frame.Navigate(typeof(MainPage)); }; editItem.Children.Add(tmp); } } rootGrid.Background = imgSource("ms-appx:///Assets/image/imgTest.jpg"); createListBtn(); }