Esempio n. 1
0
        private void MainWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var w2 = new Window2
            {
                Title = "Sticky Note",
                Tag   = ArrayPos
            };

            WindowArray[ArrayPos] = w2;
            ArrayPos++;
        }
        public MailSettingsDialog()
        {
            WindowStyle     = WindowStyle.None;
            Height          = 250;
            Width           = 600;
            Title           = "SetUp Email Server";
            BorderBrush     = Brushes.Transparent;
            BorderThickness = new Thickness(0);
            Background      = Brushes.Transparent;


            var sp = new StackPanel {
                Background = Brushes.Transparent
            };

            var b = new Button
            {
                Background = Window2.ChangeBackgroundColor(Colors.SkyBlue),
                Height     = 245
            };

            var tb = new TextBlock
            {
                Background   = Brushes.Transparent,
                TextWrapping = TextWrapping.Wrap,
                FontFamily   = new FontFamily("Bickham Script Pro")
            };

            tb.Typography.StylisticSet1 = true;
            tb.FontSize            = 50;
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.TextAlignment       = TextAlignment.Center;
            tb.Text = "Enter Mail Server Info In \r\nPreferences Window";

            b.Content = tb;
            b.Click  += b_Click;

            sp.Children.Add(b);

            _timerClock           = _timerClock = new DispatcherTimer();
            _timerClock.Interval  = new TimeSpan(0, 0, 5);
            _timerClock.IsEnabled = true;
            _timerClock.Tick     += TimerClock_Tick;

            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            Content  = sp;
            Closing += MailSettingsDialog_Closing;
            ShowDialog();
        }
Esempio n. 3
0
 private void InitializeComboBox(ComboBox combo)
 {
     for (var i = 0; i < ColorArray.Length; i++)
     {
         var c         = ColorArray[i];
         var comboItem = new ComboBoxItem();
         var l         = new Label
         {
             Background = Window2.ChangeBackgroundColor(c),
             MinHeight  = 20,
             MinWidth   = 20
         };
         comboItem.Background = Window2.ChangeBackgroundColor(c);
         comboItem.Tag        = i;
         comboItem.Content    = l;
         combo.Items.Add(comboItem);
     }
 }
Esempio n. 4
0
        public EmailDialog(string message)
        {
            WindowStyle = WindowStyle.ToolWindow;
            Height      = Width = 600;
            Title       = "Email";
            Background  = Window2.ChangeBackgroundColor(Colors.BlanchedAlmond);


            if (File.Exists("MailServerInfo"))
            {
                CreateMailUi(message);
                ShowDialog();
            }
            else
            {
                var msd = new MailSettingsDialog();
                msd.Show();
            }
        }
Esempio n. 5
0
        private static void CreateDialog(string msg)
        {
            var w  = new Window();
            var sp = new StackPanel {
                Background = Brushes.Transparent
            };
            var tb = new TextBlock
            {
                Background   = sp.Background,
                TextWrapping = TextWrapping.Wrap,
                Text         = msg
            };

            sp.Children.Add(tb);

            w.Content     = sp;
            w.WindowStyle = WindowStyle.ToolWindow;
            w.Background  = Window2.ChangeBackgroundColor(Colors.Wheat);
            w.Height      = 250;
            w.Width       = 600;
            w.ShowDialog();
        }
Esempio n. 6
0
        private void ok_Click(object sender, RoutedEventArgs e)
        {
            var server       = LogicalTreeHelper.FindLogicalNode(this, "server") as TextBox;
            var account      = LogicalTreeHelper.FindLogicalNode(this, "account") as TextBox;
            var date         = LogicalTreeHelper.FindLogicalNode(this, "date") as TextBox;
            var time         = LogicalTreeHelper.FindLogicalNode(this, "time") as TextBox;
            var repeatNumber = LogicalTreeHelper.FindLogicalNode(this, "repeat") as TextBox;
            var daysCheck    = LogicalTreeHelper.FindLogicalNode(this, "daysCheck") as CheckBox;
            var weeksCheck   = LogicalTreeHelper.FindLogicalNode(this, "weeksCheck") as CheckBox;

            var str = (daysCheck.IsChecked == true) ? "D" : "";

            str += (weeksCheck.IsChecked == true) ? "W" : "";
            if (str != string.Empty)
            {
                str += repeatNumber.Text;
            }
            else
            {
                str = "null";
            }

            if ((date.Text != string.Empty) && (date.Text != "/2006") &&
                (!(date.Text.Contains(Alarm.Date.ToShortDateString())) ||
                 !(AlarmRepetition.Contains(str)) ||
                 !(Alarm.TimeOfDay.ToString().Contains(time.Text))))
            {
                var dateString = date.Text;
                var arr        = new int[3];
                var timeString = time.Text;
                var arr1       = new int[3];

                var tail = 0;
                var head = dateString.IndexOf('/');
                head = (head >= 0) ? head : 0;

                try
                {
                    for (var i = 0; i < 3; i++)
                    {
                        head   = (i == (arr.Length - 1)) ? (dateString.Length) : head;
                        arr[i] = int.Parse(dateString.Substring(tail, head - tail));
                        if (head == dateString.Length)
                        {
                            break;
                        }
                        tail = head + 1;
                        head = dateString.IndexOf('/', tail);
                    }
                    tail = 0;
                    head = timeString.IndexOf(':');
                    head = (head >= 0) ? head : 0;
                    for (var i = 0; i < 3; i++)
                    {
                        head    = (i == (arr1.Length - 1)) ? (timeString.Length) : head;
                        arr1[i] = int.Parse(timeString.Substring(tail, head - tail));
                        if (head == timeString.Length)
                        {
                            break;
                        }
                        tail = head + 1;
                        head = timeString.IndexOf(':', tail);
                    }

                    var dt = new DateTime(arr[2], arr[0], arr[1], arr1[0], arr1[1], arr1[2]);
                    if (dt.CompareTo(DateTime.Now) >= 0)
                    {
                        Alarm = dt;
                        PropertyArray[(int)PropNames.Alarm] = dt;
                        if (repeatNumber.Text != string.Empty)
                        {
                            AlarmRepetition  = (daysCheck.IsChecked == true) ? "D" : "";
                            AlarmRepetition += (weeksCheck.IsChecked == true) ? "W" : "";
                            if (AlarmRepetition != string.Empty)
                            {
                                AlarmRepetition += repeatNumber.Text;
                            }
                            else
                            {
                                AlarmRepetition = "null";
                            }
                        }
                        Tag = "OK";
                        Close();
                    }
                    else
                    {
                        Title = "AlarmSettings Error";
                        var l = LogicalTreeHelper.FindLogicalNode(this, "statusThirdTab") as Label;
                        l.Content    = "Alarm can be set if the event is after Current time";
                        l.Foreground = Brushes.Red;
                    }
                }
                catch (Exception e1)
                {
                    var l = LogicalTreeHelper.FindLogicalNode(this, "statusThirdTab") as Label;
                    l.Content    = e1.Message;
                    l.Foreground = Brushes.Red;
                    Title        = "AlarmSettings Error";
                }
            }
            else
            {
                if (((server.Text == string.Empty) && (account.Text == string.Empty)) ||
                    ((server.Text != string.Empty) && (account.Text != string.Empty)))
                {
                    if (((server.Text != string.Empty) && (account.Text != string.Empty)))
                    {
                        var port = LogicalTreeHelper.FindLogicalNode(this, "port") as TextBox;
                        var cb   = LogicalTreeHelper.FindLogicalNode(this, "sslCheck") as CheckBox;


                        var fs     = new FileStream("MailServerInfo", FileMode.OpenOrCreate);
                        var writer = new StreamWriter(fs);
                        writer.WriteLine(server.Text);
                        writer.WriteLine(account.Text);
                        port.Text = (port.Text != string.Empty) ? port.Text : "25";
                        writer.WriteLine(port.Text);
                        var check = (cb.IsChecked == true) ? "true" : "false";
                        writer.WriteLine(check);

                        writer.Close();
                        fs.Close();
                    }
                    Tag = "OK";
                    Close();
                }
                else
                {
                    Title             = "Mail settings are incomplete";
                    server.Background = account.Background = Window2.ChangeBackgroundColor(Colors.Red);
                    var status = LogicalTreeHelper.FindLogicalNode(this, "status") as Label;
                    status.Content    = "Fill in highlighted fields";
                    status.Foreground = Brushes.Red;
                }
            }
        }
Esempio n. 7
0
        private void LoadNotes()
        {
            var count = 0;
            if (File.Exists("NotesFile"))
            {
                var fs = new FileStream("NotesFile", FileMode.Open);
                if (fs != null)
                {
                    int contentIndicator;
                    double height;
                    double width;
                    double x;
                    double y;
                    bool topmost;
                    int backgroundColorIndex;
                    int foregroundColorIndex;
                    DateTime alarmTime;
                    string loadRepeatNumber;

                    var reader = new StreamReader(fs);
                    var str = reader.ReadLine();
                    ExtractValues(out contentIndicator, str, out height, out width, out x, out y, out topmost,
                        out backgroundColorIndex,
                        out foregroundColorIndex, out alarmTime, out loadRepeatNumber);
                    AppWindow.Height = height;
                    AppWindow.Width = width;
                    AppWindow.Top = y;
                    AppWindow.Left = x;
                    AppWindow.Topmost = topmost;

                    count = contentIndicator;
                    for (var i = 0; i < count; i++)
                    {
                        var line = reader.ReadLine();

                        ExtractValues(out contentIndicator, line, out height, out width, out x, out y, out topmost,
                            out backgroundColorIndex, out foregroundColorIndex, out alarmTime, out loadRepeatNumber);

                        var filename = i.ToString();
                        filename = filename.Trim();

                        var w2 = new Window2
                        {
                            Title = "Sticky Note",
                            Tag = ArrayPos,
                            Height = height,
                            Width = width,
                            Left = x,
                            Top = y,
                            ShowInTaskbar = false,
                            Topmost = topmost,
                            TopmostWindow = topmost
                        };

                        if (w2.Topmost)
                        {
                            try
                            {
                                var m = LogicalTreeHelper.FindLogicalNode(w2, "AlwaysOnTop") as MenuItem;
                                m.IsChecked = true;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        if (backgroundColorIndex > -1)
                        {
                            w2.Background = Window2.ChangeBackgroundColor(Dialog.ColorArray[backgroundColorIndex]);
                            w2.BackgroundColorIndex = backgroundColorIndex;
                        }
                        if (foregroundColorIndex > -1)
                        {
                            w2.Foreground = Dialog.ColorArrayForeground[foregroundColorIndex];
                            w2.ForegroundColorIndex = foregroundColorIndex;
                        }
                        w2.Alarm = alarmTime;
                        w2.RepetitionNumber = loadRepeatNumber.Contains("null") ? "null" : loadRepeatNumber;


                        CheckIfAlarmFires(w2);

                        WindowArray[ArrayPos] = w2;
                        ArrayPos++;

                        var noteFiles = new FileStream(filename, FileMode.Open);

                        var rtb = ((RichTextBox) ((StackPanel) (w2.Content)).Children[1]);
                        var tr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
                        try
                        {
                            tr.Load(noteFiles, contentIndicator == 0 ? DataFormats.XamlPackage : DataFormats.Xaml);
                        }
                        catch (Exception)
                        {
                        }
                        noteFiles.Close();
                    }
                    fs.Close();
                }
            }
            for (var i = ++count; i < 100; i++)
            {
                if (File.Exists(i.ToString()))
                {
                    File.Delete(i.ToString());
                }
            }
        }
Esempio n. 8
0
 private void MainWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     var w2 = new Window2
     {
         Title = "Sticky Note",
         Tag = ArrayPos
     };
     WindowArray[ArrayPos] = w2;
     ArrayPos++;
 }
Esempio n. 9
0
        private static void CheckIfAlarmFires(Window2 w)
        {
            var current = DateTime.Now;
            var m = LogicalTreeHelper.FindLogicalNode(w, "AlwaysOnTop") as MenuItem;
            var m1 = LogicalTreeHelper.FindLogicalNode(w, "alarm") as MenuItem;
            var m3 = LogicalTreeHelper.FindLogicalNode(w, "DismissAlarm") as MenuItem;
            var alarm = w.Alarm;

            var m2 =
                LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as Image;
            m2.Visibility = (alarm.CompareTo(DateTime.Now) >= 0) ? (Visibility.Visible) : (Visibility.Hidden);

            if (w.RepetitionNumber.Contains("null") == false)
            {
                if ((alarm.CompareTo(current) < 0) &&
                    (!(((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) < 8) &&
                       ((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) >= 0))
                     || !(current.Date.ToShortDateString().Contains(alarm.Date.ToShortDateString()))))
                {
                    var chArr = w.RepetitionNumber.ToCharArray(0, 1);
                    var val = w.RepetitionNumber.Substring(1);
                    var repetitionValue = int.Parse(val);
                    switch (chArr[0])
                    {
                        case 'W':
                            while (w.Alarm.Date.CompareTo(current.Date) < 0)
                            {
                                w.Alarm = w.Alarm.AddDays(7*repetitionValue);
                            }

                            break;

                        case 'D':
                            while (w.Alarm.Date.CompareTo(current.Date) < 0)
                            {
                                w.Alarm = w.Alarm.AddDays(repetitionValue);
                            }
                            break;

                        default:
                            break;
                    }
                    alarm = w.Alarm;
                }
            }

            if (alarm.Date == current.Date)
            {
                var temp1 = alarm;
                var temp2 = current;
                temp1 = temp1.AddMinutes(30);
                temp2 = temp2.AddMinutes(30);

                if ((temp2.CompareTo(alarm) >= 0) && (temp1.CompareTo(current) >= 0) && (w.AlarmDismissed == false))
                {
                    w.Topmost = true;
                    m.IsChecked = true;
                    m1.IsEnabled = true;
                    m3.IsEnabled = true;
                    m2.Visibility = Visibility.Visible;

                    w.BorderBrush = Brushes.Black;
                    w.BorderThickness = new Thickness(5);
                }
                else if (((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) < 8) &&
                         ((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) >= 0))
                {
                    w.Topmost = w.TopmostWindow;
                    m.IsChecked = w.Topmost;
                    m1.IsEnabled = (!w.RepetitionNumber.Contains("null"));
                    m2.Visibility = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                    m3.IsEnabled = false;
                    w.BorderBrush = Brushes.Tomato;
                    w.BorderThickness = new Thickness(3);
                }
                else
                {
                    w.AlarmDismissed = false;
                    m3.IsEnabled = false;
                    m1.IsEnabled = (!w.RepetitionNumber.Contains("null"));
                    m2.Visibility = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                }
            }
            else
            {
                w.Topmost = w.TopmostWindow;
                m.IsChecked = w.Topmost;
                m1.IsEnabled = (!w.RepetitionNumber.Contains("null"));
                m2.Visibility = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                m3.IsEnabled = false;

                w.BorderBrush = Brushes.Transparent;
                w.BorderThickness = new Thickness(0);
            }
        }
Esempio n. 10
0
        private void LoadNotes()
        {
            var count = 0;

            if (File.Exists("NotesFile"))
            {
                var fs = new FileStream("NotesFile", FileMode.Open);
                if (fs != null)
                {
                    int      contentIndicator;
                    double   height;
                    double   width;
                    double   x;
                    double   y;
                    bool     topmost;
                    int      backgroundColorIndex;
                    int      foregroundColorIndex;
                    DateTime alarmTime;
                    string   loadRepeatNumber;

                    var reader = new StreamReader(fs);
                    var str    = reader.ReadLine();
                    ExtractValues(out contentIndicator, str, out height, out width, out x, out y, out topmost,
                                  out backgroundColorIndex,
                                  out foregroundColorIndex, out alarmTime, out loadRepeatNumber);
                    AppWindow.Height  = height;
                    AppWindow.Width   = width;
                    AppWindow.Top     = y;
                    AppWindow.Left    = x;
                    AppWindow.Topmost = topmost;

                    count = contentIndicator;
                    for (var i = 0; i < count; i++)
                    {
                        var line = reader.ReadLine();

                        ExtractValues(out contentIndicator, line, out height, out width, out x, out y, out topmost,
                                      out backgroundColorIndex, out foregroundColorIndex, out alarmTime, out loadRepeatNumber);

                        var filename = i.ToString();
                        filename = filename.Trim();

                        var w2 = new Window2
                        {
                            Title         = "Sticky Note",
                            Tag           = ArrayPos,
                            Height        = height,
                            Width         = width,
                            Left          = x,
                            Top           = y,
                            ShowInTaskbar = false,
                            Topmost       = topmost,
                            TopmostWindow = topmost
                        };

                        if (w2.Topmost)
                        {
                            try
                            {
                                var m = LogicalTreeHelper.FindLogicalNode(w2, "AlwaysOnTop") as MenuItem;
                                m.IsChecked = true;
                            }
                            catch (Exception)
                            {
                            }
                        }
                        if (backgroundColorIndex > -1)
                        {
                            w2.Background           = Window2.ChangeBackgroundColor(Dialog.ColorArray[backgroundColorIndex]);
                            w2.BackgroundColorIndex = backgroundColorIndex;
                        }
                        if (foregroundColorIndex > -1)
                        {
                            w2.Foreground           = Dialog.ColorArrayForeground[foregroundColorIndex];
                            w2.ForegroundColorIndex = foregroundColorIndex;
                        }
                        w2.Alarm            = alarmTime;
                        w2.RepetitionNumber = loadRepeatNumber.Contains("null") ? "null" : loadRepeatNumber;


                        CheckIfAlarmFires(w2);

                        WindowArray[ArrayPos] = w2;
                        ArrayPos++;

                        var noteFiles = new FileStream(filename, FileMode.Open);

                        var rtb = ((RichTextBox)((StackPanel)(w2.Content)).Children[1]);
                        var tr  = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
                        try
                        {
                            tr.Load(noteFiles, contentIndicator == 0 ? DataFormats.XamlPackage : DataFormats.Xaml);
                        }
                        catch (Exception)
                        {
                        }
                        noteFiles.Close();
                    }
                    fs.Close();
                }
            }
            for (var i = ++count; i < 100; i++)
            {
                if (File.Exists(i.ToString()))
                {
                    File.Delete(i.ToString());
                }
            }
        }
Esempio n. 11
0
        private static void CheckIfAlarmFires(Window2 w)
        {
            var current = DateTime.Now;
            var m       = LogicalTreeHelper.FindLogicalNode(w, "AlwaysOnTop") as MenuItem;
            var m1      = LogicalTreeHelper.FindLogicalNode(w, "alarm") as MenuItem;
            var m3      = LogicalTreeHelper.FindLogicalNode(w, "DismissAlarm") as MenuItem;
            var alarm   = w.Alarm;

            var m2 =
                LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as Image;

            m2.Visibility = (alarm.CompareTo(DateTime.Now) >= 0) ? (Visibility.Visible) : (Visibility.Hidden);

            if (w.RepetitionNumber.Contains("null") == false)
            {
                if ((alarm.CompareTo(current) < 0) &&
                    (!(((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) < 8) &&
                       ((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) >= 0)) ||
                     !(current.Date.ToShortDateString().Contains(alarm.Date.ToShortDateString()))))
                {
                    var chArr           = w.RepetitionNumber.ToCharArray(0, 1);
                    var val             = w.RepetitionNumber.Substring(1);
                    var repetitionValue = int.Parse(val);
                    switch (chArr[0])
                    {
                    case 'W':
                        while (w.Alarm.Date.CompareTo(current.Date) < 0)
                        {
                            w.Alarm = w.Alarm.AddDays(7 * repetitionValue);
                        }

                        break;

                    case 'D':
                        while (w.Alarm.Date.CompareTo(current.Date) < 0)
                        {
                            w.Alarm = w.Alarm.AddDays(repetitionValue);
                        }
                        break;

                    default:
                        break;
                    }
                    alarm = w.Alarm;
                }
            }

            if (alarm.Date == current.Date)
            {
                var temp1 = alarm;
                var temp2 = current;
                temp1 = temp1.AddMinutes(30);
                temp2 = temp2.AddMinutes(30);

                if ((temp2.CompareTo(alarm) >= 0) && (temp1.CompareTo(current) >= 0) && (w.AlarmDismissed == false))
                {
                    w.Topmost     = true;
                    m.IsChecked   = true;
                    m1.IsEnabled  = true;
                    m3.IsEnabled  = true;
                    m2.Visibility = Visibility.Visible;

                    w.BorderBrush     = Brushes.Black;
                    w.BorderThickness = new Thickness(5);
                }
                else if (((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) < 8) &&
                         ((current.TimeOfDay.Hours - alarm.TimeOfDay.Hours) >= 0))
                {
                    w.Topmost         = w.TopmostWindow;
                    m.IsChecked       = w.Topmost;
                    m1.IsEnabled      = (!w.RepetitionNumber.Contains("null"));
                    m2.Visibility     = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                    m3.IsEnabled      = false;
                    w.BorderBrush     = Brushes.Tomato;
                    w.BorderThickness = new Thickness(3);
                }
                else
                {
                    w.AlarmDismissed = false;
                    m3.IsEnabled     = false;
                    m1.IsEnabled     = (!w.RepetitionNumber.Contains("null"));
                    m2.Visibility    = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                }
            }
            else
            {
                w.Topmost     = w.TopmostWindow;
                m.IsChecked   = w.Topmost;
                m1.IsEnabled  = (!w.RepetitionNumber.Contains("null"));
                m2.Visibility = m1.IsEnabled ? (Visibility.Visible) : (Visibility.Hidden);
                m3.IsEnabled  = false;

                w.BorderBrush     = Brushes.Transparent;
                w.BorderThickness = new Thickness(0);
            }
        }