Exemple #1
0
        private void NewFileCopy_Click(object sender, RoutedEventArgs e)
        {
            if (CheckItemsListContent() == false)
            {
                MessageBox.Show("List is empty");
            }
            else
            {
                string[] tempText = TXTtoObservableCollection.ReturnOnlyLines(filePath);
                string   tempName = CreateFileName.Method();

                string tempPath = "saves/" + tempName + ".txt";

                WorkPage workPage = new WorkPage(tempPath, mp, tempText);

                workPage.ItemsCollection = TXTtoObservableCollection.fillingMethod(tempText);

                mp._mainWindow.Main.Content = workPage;

                string textToFile = ObservableCollectionToTXT.Method(workPage.ItemsCollection);

                using (StreamWriter sw = File.CreateText(tempPath))
                {
                    sw.Write(textToFile);
                    sw.Close();
                }

                DataGridView.ItemsSource = ItemsCollection;

                MessageBox.Show("Successfully created new list named: " + tempName);
            }
        }
Exemple #2
0
        // 保存照片
        private string SavePhoto(string photo)
        {
            string photoName = CreateFileName.CreatePhotoName(photo);

            if (!Directory.Exists(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }
            photoName = "./img/" + photoName;

            Bitmap photoBit = new Bitmap(pbEditPhoto.BackgroundImage);

            photoBit.Save(photoName, pbEditPhoto.BackgroundImage.RawFormat);
            photoBit.Dispose();
            return(photoName);
        }
Exemple #3
0
        public WorkPage(MainPage mainPage) // New page
        {
            InitializeComponent();
            DataContext = _vm;

            filePath = "saves/" + CreateFileName.Method() + ".txt";

            StreamWriter sw = File.CreateText(filePath);

            sw.Close();

            ItemsCollection = TXTtoObservableCollection.Method(filePath);

            DataGridView.ItemsSource = ItemsCollection;

            mp = mainPage;
        }