private void openButton_Click(object sender, RoutedEventArgs e)
        {
            StringNode operatedNode = (StringNode)listView1.SelectedItem; //new ListViewClass(value1, value2);

            if (operatedNode != null)
            {
                try
                {
                    DateTime    workDate          = DateTime.Parse(operatedNode.Date);
                    string      workTitle         = operatedNode.Title;
                    string      workDescription   = operatedNode.Description;
                    EventNode   workNode          = new EventNode(workDate, workTitle, workDescription);
                    ReadingPage basicDateReadPage = new ReadingPage();
                    ReadingPage.workNodeTransfer = workNode;
                    NavigationService.Navigate(basicDateReadPage);
                }
                catch (Exception)
                {
                    try
                    {
                        throw new Exception("Error occured, please try againg.\nClick on details for more information.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.ShowError(ex);
                    }
                    //MessageBox.Show("Please try againg");
                }
            }
        }
        private void listView1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            StringNode operatedNode = (StringNode)listView1.SelectedItem;

            if (operatedNode != null)
            {
                stopRefreshControls     = true;
                dateTextBox.Text        = operatedNode.Date;
                titleTextBox.Text       = operatedNode.Title;
                descriptionTextBox.Text = operatedNode.Description;
                stopRefreshControls     = false;
            }
        }
        private void ShowData()
        {
            if (MainWindow.remindScheduler.scheduleStructure != null)
            {
                MainWindow.remindScheduler.scheduleStructure.Clear();
            }
            MyData md = new MyData();

            listView1.Items.Clear();

            foreach (var row in md.GetRows())
            {
                listView1.Items.Add(row);
            }


            if (MainWindow.mainScheduler.scheduleStructure != null && MainWindow.mainScheduler.scheduleStructure.Count > 0)
            {
                foreach (var eventNode in MainWindow.mainScheduler.scheduleStructure)
                {
                    listView1.Items.Add(new StringNode(eventNode.DatetimeEvent.ToString(), eventNode.Title, eventNode.Description));
                }
                SaveCurrentContent();
            }

            MainWindow.mainScheduler.scheduleStructure.Clear();

            foreach (var node in listView1.Items)
            {
                try
                {
                    StringNode operatedNode = (StringNode)node;
                    DateTime   workDate     = DateTime.Parse(operatedNode.Date);
                    MainWindow.remindScheduler.scheduleStructure.Add(new EventNode(workDate, operatedNode.Title, operatedNode.Description));
                }
                catch (Exception)
                {
                    try
                    {
                        throw new Exception("The remainder may not working correctly!\nPlease check your events` dates.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.ShowError(ex);
                    }
                    //MessageBox.Show("The remainder may not working correctly!\nPlease check your events` dates.");
                }
            }
        }
        private void RefreshListView(string value1, string value2, string value3)
        {
            StringNode operatedNode = (StringNode)listView1.SelectedItem; //new ListViewClass(value1, value2);

            if (operatedNode != null && !stopRefreshControls)
            {
                setDataChanged(true);

                operatedNode.Date        = value1;
                operatedNode.Title       = value2;
                operatedNode.Description = value3;

                listView1.Items.Refresh();
            }
        }
Exemple #5
0
        /// <summary>
        /// Saves items to MyData.xml file in bin folder.
        /// </summary>
        /// <param name="items"></param>
        public void Save(System.Windows.Data.CollectionView items)
        {
            XDocument xdoc = new XDocument();

            XElement xeRoot    = new XElement("Data");
            XElement xeSubRoot = new XElement("Rows");

            foreach (var item in items)
            {
                StringNode operatedNode = (StringNode)item;

                XElement xRow = new XElement("Row");
                xRow.Add(new XElement("col1", operatedNode.Date));
                xRow.Add(new XElement("col2", operatedNode.Title));
                xRow.Add(new XElement("col3", operatedNode.Description));

                xeSubRoot.Add(xRow);
            }
            xeRoot.Add(xeSubRoot);
            xdoc.Add(xeRoot);

            xdoc.Save("MyData.xml");
        }