コード例 #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);
            }
        }
コード例 #2
0
        public WorkPage(string s, MainPage mainPage, string[] text) // Existing page with text
        {
            InitializeComponent();
            DataContext = _vm;

            filePath = s;

            StreamWriter sw = File.CreateText(filePath);

            sw.Close();

            ItemsCollection = TXTtoObservableCollection.fillingMethod(text);

            DataGridView.ItemsSource = ItemsCollection;

            mp = mainPage;
        }