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");
                }
            }
        }
Exemple #2
0
        //private void CloseBubbleSearch(object sender, RoutedEventArgs e) // this could be removed- always close
        //{
        //    //startColorSearch = false;
        //    //FindListViewItem(listview);
        //}

        private void OpenOpenButton(object sender, RoutedEventArgs e)
        {
            Bubble operateBubble = (Bubble)listview.SelectedItem;

            if (operateBubble != null)
            {
                try
                {
                    DisplayPage tempPage = new DisplayPage();
                    DisplayPage.dBubble = operateBubble;
                    NavigationService.Navigate(tempPage);
                }
                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 saveButton_Click(object sender, RoutedEventArgs e)
        {
            saveButton.IsEnabled = false;

            try
            {
                if (dataChanged)
                {
                    SaveCurrentContent();
                    MessageBox.ShowInformation(String.Format("The schedule has been successfully saved!", titleTextBox.Text));
                }
            }
            catch (Exception)
            {
                try
                {
                    throw new Exception("Error occured, please try again!\nPlease check your events` dates.");
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError(ex);
                }
            }


            ShowData();
            // saveButton.IsEnabled = true;
        }
Exemple #4
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml");

            try
            {
                // here grid is cleared
                dataGrid.ItemsSource = null;
                dataGrid.Items.Clear();
                dataSet.Clear();

                // loading to grid data from .xml file
                dataSet.ReadXml(@pathFileXml);
                DataView dataView = new DataView(dataSet.Tables[0]);
                dataGrid.ItemsSource = dataView;

                // button is disabled after erase it added row
                cancel_button.IsEnabled = false;

                MessageBox.ShowInformation("Canceled Changes!");
            }
            catch (Exception ex)
            {
                MessageBox.ShowError(ex, "Cancel was't sucessful!");
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets data from MyData.xml as rows.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <object> GetRows()
        {
            List <StringNode> rows = new List <StringNode>();

            if (File.Exists("MyData.xml"))
            {
                try
                {
                    // Create the query
                    var rowsFromFile = from c in XDocument.Load(
                        "MyData.xml").Elements(
                        "Data").Elements("Rows").Elements("Row")
                                       select c;

                    // Execute the query
                    foreach (var row in rowsFromFile)
                    {
                        rows.Add(new StringNode(row.Element("col1").Value, row.Element("col2").Value, row.Element("col3").Value));
                    }
                }
                catch (Exception)
                {
                    try
                    {
                        throw new Exception("Error occured while reading the events archive.\nClick on details for more information.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.ShowError(ex);
                    }
                    //MessageBox.Show("Error occured while reading the events archive");
                }
            }
            return(rows);
        }
 private void ShowException_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         throw new Exception("FUUUUUUUUUUUU!!!!!!!");
     }
     catch (Exception ex)
     {
         MessageBox.ShowError(ex);
     }
 }
        private void OnExitButtonClick(object sender, RoutedEventArgs e)
        {
            MessageBoxResult askResult = MessageBox.ShowQuestion("Do you want to Exit?", "The scheduler cannot remind you during offline mode!\nYes: Exit (offline mode)\nNo: Minimize to tray (working reminder)\nCancel: Cancel command", true);

            if (askResult == MessageBoxResult.Yes)
            {
                Environment.Exit(0);
            }
            if (askResult == MessageBoxResult.No)
            {
                WindowState = WindowState.Minimized;
            }
        }
        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.");
                }
            }
        }
            public void Execute(IJobExecutionContext context)
            {
                if (MainWindow.raisedEvent.Count > 0)
                {
                    EventNode savedDate    = MainWindow.raisedEvent.Dequeue();
                    DateTime  nowTime      = DateTime.Now;
                    string    remindString = String.Format("Alarm:\nLast reminding about Event: {0} is raising at the moment!)", savedDate.Title);
                    MessageBox.ShowInformation(remindString);
                    //MessageBox.ShowInformation(new Form() { TopMost = true }, "I'm still on top, YEAH");
                    //growlNotifications.AddNotification(new Notification { Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString });

                    SimpleDelegate d = new SimpleDelegate(TestMethod);
                    d(remindString);
                }
                //DoMoreWork();
            }
        private void CheckDates()
        {
            if (MainWindow.remindScheduler.scheduleStructure != null && MainWindow.remindScheduler.scheduleStructure.Count > 0)
            {
                DateTime nowTime      = DateTime.Now;
                DateTime plusHourTime = nowTime.AddMinutes(60);

                DateTime dayPlusMax = nowTime.AddMinutes(1470);
                DateTime dayPlusMin = nowTime.AddMinutes(1410);

                foreach (var savedDate in MainWindow.remindScheduler.scheduleStructure)
                {
                    if (savedDate.DatetimeEvent > nowTime && savedDate.DatetimeEvent < plusHourTime)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise in {1:mm} minutes", savedDate.Title, savedDate.DatetimeEvent - nowTime);
                        //MessageBox.Show(remindString);
                        MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });

                        MainWindow.raisedEvent.Enqueue(savedDate);
                    }

                    if (savedDate.DatetimeEvent > dayPlusMin && savedDate.DatetimeEvent < dayPlusMax)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise tomorrow ({1:dd/MM/yyyy})", savedDate.Title, dayPlusMax);
                        //MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });
                    }
                }

                foreach (var eventNod in MainWindow.raisedEvent)
                {
                    counterAlarms++;
                    int               transferMins = (int)(eventNod.DatetimeEvent - nowTime).Minutes;
                    IMyJob            myJob        = new MyJob();
                    JobDetailImpl     jobDetail    = new JobDetailImpl(counterAlarms.ToString(), null, myJob.GetType());
                    SimpleTriggerImpl trigger2     = new SimpleTriggerImpl("Trigger" + counterAlarms.ToString(), null, DateTime.Now.AddSeconds(transferMins * 60), null, 0, TimeSpan.Zero);
                    RaiseReminder(myJob, jobDetail, trigger2);
                }
            }
        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            //base.OnClosing(e);
            e.Cancel = true;
            //Environment.Exit(0);
            MessageBoxResult askResult = MessageBox.ShowQuestion("Do you want to Exit?", "The scheduler cannot remind you during offline mode!\nYes: Exit (offline mode)\nNo: Minimize to tray (working reminder)\nCancel: Cancel command", true);

            if (askResult == MessageBoxResult.Yes)
            {
                Environment.Exit(0);
            }
            if (askResult == MessageBoxResult.No)
            {
                WindowState = WindowState.Minimized;
            }
            //this.Hide();
            //
        }
 private void OpenAddToSchedule(object sender, RoutedEventArgs e)
 {
     try
     {
         DateTime eventDate = DateTime.Parse(dateTextBox.Text);
         MainWindow.mainScheduler.Add(new EventNode(eventDate, titleTextBox.Text, descriptionTextBox.Text));
         //MessageBox.Show("The event has been added successfully to the scheduler");
         MessageBox.ShowInformation(String.Format("The event {0} has been added successfully to the scheduler!", titleTextBox.Text));
         OpenSchedulePage(sender, e);
     }
     catch (Exception)
     {
         try
         {
             throw new Exception("The event can not be added to the scheduler.\nClick on details for more information.");
         }
         catch (Exception ex)
         {
             MessageBox.ShowError(ex);
         }
         //MessageBox.Show("The event can not be added to the scheduler due to invalid date format");
     }
 }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (dataChanged)
     {
         string           message = "Your changes are not saved. Do you want to save it now?";
         MessageBoxResult result  = MessageBox.Show(message,
                                                    this.Title,
                                                    MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             MyData md = new MyData();
             md.Save(listView1.Items);
             setDataChanged(false);
         }
         else if (result == MessageBoxResult.Cancel)
         {
             e.Cancel = true;
         }
         else if (result == MessageBoxResult.No)
         {
             // do nothing
         }
     }
 }
 private void ShowInfo_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.ShowInformation("Hello World!");
 }
 private void ShowError_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.ShowError("!World Hello");
 }
 private void ShowWarning_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.ShowWarning("This is a very long message which you should not read through. It has nothing important to tell you, it's just here to test the message box's behavior with long texts.", showCancel: true);
 }
 private void ShowQuestion_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.ShowQuestion("Hello World?", "Is it?");
 }
Exemple #18
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // it is path to xml file
            string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml");

            // it is to check empty cell, after error with save
            ableToSave = true;

            try
            {
                foreach (DataRowView row in dataGrid.Items)
                {
                    if (row.Row.ItemArray[0].ToString() == "" || row.Row.ItemArray[0] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[1].ToString() == "" || row.Row.ItemArray[1] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[2].ToString() == "" || row.Row.ItemArray[2] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[3].ToString() == "" || row.Row.ItemArray[3] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[5].ToString() == "" || row.Row.ItemArray[5] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[6].ToString() == "" || row.Row.ItemArray[6] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[7].ToString() == "" || row.Row.ItemArray[7] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
            }


            try
            {
                if (ableToSave == true)
                {
                    // after press Save button, grid will be saved
                    dataSet.AcceptChanges();
                    dataSet.WriteXml(@pathFileXml);

                    MessageBox.ShowInformation("Grid is saved!", "Success of save!");
                }
                else
                {
                    MessageBox.ShowError("Grid has empty cell!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.ShowError(ex, "It was error with exception!");
            }
        }