Ejemplo n.º 1
0
        void Window2_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Window2 w2 = sender as Window2;
            Window1 w1 = Application.Current.MainWindow as Window1;

            object[] arr   = w1.WindowArray;
            int      index = ((int)(w2.Tag));

            arr[index] = null;
            if (dialog != null)
            {
                dialog.Close();
            }
        }
Ejemplo n.º 2
0
 private void InitializeComboBox(ComboBox combo)
 {
     for (int i = 0; i < colorArray.Length; i++)
     {
         Color        c         = colorArray[i];
         ComboBoxItem comboItem = new ComboBoxItem();
         Label        l         = new Label();
         l.Background         = Window2.ChangeBackgroundColor(c);
         l.MinHeight          = 20;
         l.MinWidth           = 20;
         comboItem.Background = Window2.ChangeBackgroundColor(c);
         comboItem.Tag        = i;
         comboItem.Content    = l;
         combo.Items.Add(comboItem);
     }
 }
Ejemplo n.º 3
0
        void AlarmTimer_Tick(object sender, EventArgs e)
        {
            int index = 0;

            windowContents = new string[ArrayPos];
            for (int i = 0; i < ArrayPos; i++)
            {
                if (windowArray[i] != null)
                {
                    Window2 w = ((Window2)(windowArray[i]));
                    StoreContents(index++);
                    CheckIfAlarmFires(w);
                }
            }

            WriteNotesFile(index);
        }
Ejemplo n.º 4
0
        public MailSettingsDialog()
        {
            this.WindowStyle     = WindowStyle.None;
            this.Height          = 250;
            this.Width           = 600;
            this.Title           = "SetUp Email Server";
            this.BorderBrush     = Brushes.Transparent;
            this.BorderThickness = new Thickness(0);
            this.Background      = Brushes.Transparent;


            StackPanel sp = new StackPanel();

            sp.Background = Brushes.Transparent;

            Button b = new Button();

            b.Background = Window2.ChangeBackgroundColor(Colors.SkyBlue);
            b.Height     = 245;

            TextBlock tb = new TextBlock();

            tb.Background               = Brushes.Transparent;
            tb.TextWrapping             = TextWrapping.Wrap;
            tb.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  += new RoutedEventHandler(b_Click);

            sp.Children.Add(b);

            TimerClock           = TimerClock = new System.Windows.Threading.DispatcherTimer();
            TimerClock.Interval  = new TimeSpan(0, 0, 5);
            TimerClock.IsEnabled = true;
            TimerClock.Tick     += new EventHandler(TimerClock_Tick);

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.Content  = sp;
            this.Closing += new System.ComponentModel.CancelEventHandler(MailSettingsDialog_Closing);
            this.ShowDialog();
        }
Ejemplo n.º 5
0
        void m1_Click(object sender, RoutedEventArgs e)
        {
            Menu    m = ((Menu)(((MenuItem)(((MenuItem)(sender as MenuItem)).Parent as MenuItem)).Parent as Menu));
            Window2 w = ((Window2)(((StackPanel)((WrapPanel)(m.Parent as WrapPanel)).Parent as StackPanel).Parent as Window));

            _windowHeight = w.ActualHeight;
            _windowWidth  = w.ActualWidth;
            w.Height      = 20;
            w.Width       = 20;

            foreGround = w.Foreground;
            backGround = w.Background;

            w.Cursor          = System.Windows.Input.Cursors.Hand;
            w.BorderThickness = new Thickness(2);
            w.WindowStyle     = WindowStyle.None;
            w.ResizeMode      = ResizeMode.NoResize;
            w.Background      = System.Windows.Media.Brushes.GreenYellow;
        }
Ejemplo n.º 6
0
        void m4_Click(object sender, RoutedEventArgs e)
        {
            Menu    m = ((Menu)(((MenuItem)(((MenuItem)(sender as MenuItem)).Parent as MenuItem)).Parent as Menu));
            Window2 w = ((Window2)(((StackPanel)((WrapPanel)(m.Parent as WrapPanel)).Parent as StackPanel).Parent as Window));

            if (w.Topmost == false)
            {
                w.Topmost     = true;
                TopmostWindow = true;
                ((MenuItem)(sender)).IsChecked = true;
                w.UpdateLayout();
                w.BringIntoView();
            }
            else
            {
                TopmostWindow = w.Topmost = false;
                ((MenuItem)(sender)).IsChecked = false;
            }
        }
Ejemplo n.º 7
0
        public EmailDialog(string message)
        {
            this.WindowStyle = WindowStyle.ToolWindow;
            this.Height      = this.Width = 600;
            this.Title       = "Email";
            this.Background  = Window2.ChangeBackgroundColor(Colors.BlanchedAlmond);



            if (File.Exists("MailServerInfo"))
            {
                CreateMailUI(message);
                this.ShowDialog();
            }
            else
            {
                MailSettingsDialog msd = new MailSettingsDialog();
                msd.Show();
            }
        }
Ejemplo n.º 8
0
        private static void CreateDialog(string msg)
        {
            Window     w  = new Window();
            StackPanel sp = new StackPanel();

            sp.Background = Brushes.Transparent;
            TextBlock tb = new TextBlock();

            tb.Background   = sp.Background;
            tb.TextWrapping = TextWrapping.Wrap;
            tb.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();
        }
Ejemplo n.º 9
0
        void dialog_Closed(object sender, EventArgs e)
        {
            Dialog dia = sender as Dialog;

            if (dia.Tag != null)
            {
                dia.Tag = null;
                object[] arr = dia.PropertyArray;
                if (arr[0] != null)
                {
                    _windowBackground = (int)(arr[0]);
                    if (this.WindowStyle.ToString() == WindowStyle.None.ToString())
                    {
                        backGround = ChangeBackgroundColor(Dialog.colorArray[_windowBackground]);
                    }
                    else
                    {
                        this.Background = ChangeBackgroundColor(Dialog.colorArray[_windowBackground]);
                        backGround      = this.Background;
                    }
                }
                else
                {
                    _windowBackground = (_windowBackground != -1) ? _windowBackground : -1;
                }
                if (arr[1] != null)
                {
                    _windowForeground = (int)(arr[1]);
                    RichTextBox rtb = LogicalTreeHelper.FindLogicalNode(this, "NoteBox") as RichTextBox;
                    rtb.SelectAll();
                    rtb.Selection.ApplyPropertyValue(RichTextBox.ForegroundProperty, Dialog.colorArrayForeground[_windowForeground]);
                    rtb.Selection.Select(rtb.Document.ContentStart, rtb.Document.ContentStart);
                    foreGround = this.Foreground;
                }
                else
                {
                    _windowForeground = (_windowForeground != -1) ? _windowForeground : -1;
                }
                if (arr[2] != null)
                {
                    NoteAlarm = dia.Alarm;


                    Window2  w  = this;
                    MenuItem m  = LogicalTreeHelper.FindLogicalNode(w, "AlwaysOnTop") as MenuItem;
                    MenuItem m1 = LogicalTreeHelper.FindLogicalNode(w, "alarm") as MenuItem;
                    MenuItem m3 = LogicalTreeHelper.FindLogicalNode(w, "DismissAlarm") as MenuItem;
                    System.Windows.Controls.Image m2 = LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as System.Windows.Controls.Image;
                    DateTime alarm   = w.Alarm;
                    DateTime current = DateTime.Now;
                    m2.Visibility = (alarm.CompareTo(DateTime.Now) >= 0) ? (Visibility.Visible) : (Visibility.Hidden);

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

                        if ((temp2.CompareTo(alarm) >= 0) && (temp1.CompareTo(current) >= 0))
                        {
                            w.Topmost         = true;
                            m.IsChecked       = true;
                            m1.IsEnabled      = true;
                            w.BorderBrush     = System.Windows.Media.Brushes.Black;
                            w.BorderThickness = new Thickness(5);
                            m3.IsEnabled      = true;
                        }
                    }
                    else
                    {
                        w.Topmost    = w.TopmostWindow;
                        m.IsChecked  = w.Topmost;
                        m1.IsEnabled = (alarm.CompareTo(DateTime.Now) >= 0) ? true : false;
                        m3.IsEnabled = false;

                        w.BorderBrush     = System.Windows.Media.Brushes.Transparent;
                        w.BorderThickness = new Thickness(0);
                    }
                }
                repetitionNumber = dia.AlarmRepetition;
            }
        }
Ejemplo n.º 10
0
        void ok_Click(object sender, RoutedEventArgs e)
        {
            TextBox  server       = LogicalTreeHelper.FindLogicalNode(this, "server") as TextBox;
            TextBox  account      = LogicalTreeHelper.FindLogicalNode(this, "account") as TextBox;
            TextBox  date         = LogicalTreeHelper.FindLogicalNode(this, "date") as TextBox;
            TextBox  time         = LogicalTreeHelper.FindLogicalNode(this, "time") as TextBox;
            TextBox  repeatNumber = LogicalTreeHelper.FindLogicalNode(this, "repeat") as TextBox;
            CheckBox daysCheck    = LogicalTreeHelper.FindLogicalNode(this, "daysCheck") as CheckBox;
            CheckBox weeksCheck   = LogicalTreeHelper.FindLogicalNode(this, "weeksCheck") as CheckBox;

            string 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))))
            {
                string dateString = date.Text;
                int[]  arr        = new int[3];
                string timeString = time.Text;
                int[]  arr1       = new int[3];

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

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

                    DateTime dt = new DateTime(arr[2], arr[0], arr[1], arr1[0], arr1[1], arr1[2]);
                    if (dt.CompareTo(DateTime.Now) >= 0)
                    {
                        this.alarm = dt;
                        PropArray[(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";
                            }
                        }
                        this.Tag = "OK";
                        this.Close();
                    }
                    else
                    {
                        this.Title = "AlarmSettings Error";
                        Label 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)
                {
                    Label l = LogicalTreeHelper.FindLogicalNode(this, "statusThirdTab") as Label;
                    l.Content    = e1.Message;
                    l.Foreground = Brushes.Red;
                    this.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)))
                    {
                        TextBox  port = LogicalTreeHelper.FindLogicalNode(this, "port") as TextBox;
                        CheckBox cb   = LogicalTreeHelper.FindLogicalNode(this, "sslCheck") as CheckBox;


                        FileStream   fs      = new FileStream("MailServerInfo", FileMode.OpenOrCreate);
                        StreamWriter _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);
                        string check = (cb.IsChecked == true) ? "true" : "false";
                        _writer.WriteLine(check);

                        _writer.Close();
                        fs.Close();
                    }
                    this.Tag = "OK";
                    this.Close();
                }
                else
                {
                    this.Title        = "Mail settings are incomplete";
                    server.Background = account.Background = Window2.ChangeBackgroundColor(Colors.Red);
                    Label status = LogicalTreeHelper.FindLogicalNode(this, "status") as Label;
                    status.Content    = "Fill in highlighted fields";
                    status.Foreground = Brushes.Red;
                }
            }
        }
Ejemplo n.º 11
0
        private void LoadNotes()
        {
            int count = 0;

            if (File.Exists("NotesFile"))
            {
                FileStream 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;

                    StreamReader reader = new StreamReader(fs);
                    string       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);
                    MainWindow.Height  = height;
                    MainWindow.Width   = Width;
                    MainWindow.Top     = y;
                    MainWindow.Left    = x;
                    MainWindow.Topmost = topmost;

                    count = contentIndicator;
                    for (int i = 0; i < count; i++)
                    {
                        string 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);

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

                        Window2 w2 = new Window2();
                        w2.Title = "Sticky Note";
                        w2.Tag   = _arraySize;

                        w2.Height        = height;
                        w2.Width         = Width;
                        w2.Left          = x;
                        w2.Top           = y;
                        w2.ShowInTaskbar = false;
                        w2.Topmost       = topmost;
                        w2.TopmostWindow = topmost;
                        if (w2.Topmost)
                        {
                            try
                            {
                                MenuItem 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;
                        if (loadRepeatNumber.Contains("null"))
                        {
                            w2.RepetitionNumber = "null";
                        }
                        else
                        {
                            w2.RepetitionNumber = loadRepeatNumber;
                        }


                        CheckIfAlarmFires(w2);

                        windowArray[_arraySize] = w2;
                        ArrayPos++;

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

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

            System.Windows.Controls.Image m2 = LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as System.Windows.Controls.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()))))
                {
                    char[] chArr           = w.RepetitionNumber.ToCharArray(0, 1);
                    string val             = w.RepetitionNumber.Substring(1);
                    int    repetitionValue = Int32.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)
            {
                DateTime temp1 = alarm;
                DateTime 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     = System.Windows.Media.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")) ? false : true;
                    m2.Visibility     = (m1.IsEnabled == true)?(Visibility.Visible):(Visibility.Hidden);
                    m3.IsEnabled      = false;
                    w.BorderBrush     = System.Windows.Media.Brushes.Tomato;
                    w.BorderThickness = new Thickness(3);
                }
                else
                {
                    w.AlarmDismissed = false;
                    m3.IsEnabled     = false;
                    m1.IsEnabled     = (w.RepetitionNumber.Contains("null")) ? false : true;
                    m2.Visibility    = (m1.IsEnabled == true) ? (Visibility.Visible) : (Visibility.Hidden);
                }
            }
            else
            {
                w.Topmost     = w.TopmostWindow;
                m.IsChecked   = w.Topmost;
                m1.IsEnabled  = (w.RepetitionNumber.Contains("null")) ? false : true;
                m2.Visibility = (m1.IsEnabled == true) ? (Visibility.Visible) : (Visibility.Hidden);
                m3.IsEnabled  = false;

                w.BorderBrush     = System.Windows.Media.Brushes.Transparent;
                w.BorderThickness = new Thickness(0);
            }
        }
Ejemplo n.º 13
0
        private static void CheckIfAlarmFires(Window2 w)
        {
            DateTime current = DateTime.Now;
            MenuItem m = LogicalTreeHelper.FindLogicalNode(w, "AlwaysOnTop") as MenuItem;
            MenuItem m1 = LogicalTreeHelper.FindLogicalNode(w, "alarm") as MenuItem;
            MenuItem m3 = LogicalTreeHelper.FindLogicalNode(w, "DismissAlarm") as MenuItem;
            DateTime alarm = w.Alarm;

            System.Windows.Controls.Image m2 = LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as System.Windows.Controls.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()))))
                {
                    char[] chArr = w.RepetitionNumber.ToCharArray(0, 1);
                    string val = w.RepetitionNumber.Substring(1);
                    int repetitionValue = Int32.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)
            {
                DateTime temp1 = alarm;
                DateTime 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 = System.Windows.Media.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")) ? false : true;
                    m2.Visibility = (m1.IsEnabled==true)?(Visibility.Visible):(Visibility.Hidden);
                    m3.IsEnabled = false;
                    w.BorderBrush = System.Windows.Media.Brushes.Tomato;
                    w.BorderThickness = new Thickness(3);
                }
                else
                {
                    w.AlarmDismissed = false;
                    m3.IsEnabled = false;
                    m1.IsEnabled = (w.RepetitionNumber.Contains("null")) ? false : true;
                    m2.Visibility = (m1.IsEnabled == true) ? (Visibility.Visible) : (Visibility.Hidden);
                }

            }
            else
            {
                w.Topmost = w.TopmostWindow;
                m.IsChecked = w.Topmost;
                m1.IsEnabled = (w.RepetitionNumber.Contains("null")) ? false : true;
                m2.Visibility = (m1.IsEnabled == true) ? (Visibility.Visible) : (Visibility.Hidden);
                m3.IsEnabled = false;

                w.BorderBrush = System.Windows.Media.Brushes.Transparent;
                w.BorderThickness = new Thickness(0);
            }
        }
Ejemplo n.º 14
0
 void MainWindow_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     Window2 w2 = new Window2();
     w2.Title = "Sticky Note";
     w2.Tag = _arraySize;
     windowArray[_arraySize] = w2;
     ArrayPos++;
 }
Ejemplo n.º 15
0
        private void LoadNotes()
        {
            int count = 0;
            if(File.Exists("NotesFile"))
            {
                FileStream 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;

                    StreamReader reader = new StreamReader(fs);
                    string 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);
                    MainWindow.Height = height;
                    MainWindow.Width = Width;
                    MainWindow.Top = y;
                    MainWindow.Left = x;
                    MainWindow.Topmost = topmost;

                     count = contentIndicator;
                    for (int i = 0; i < count; i++)
                    {
                        string 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);

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

                        Window2 w2 = new Window2();
                        w2.Title = "Sticky Note";
                        w2.Tag = _arraySize;

                        w2.Height = height;
                        w2.Width = Width;
                        w2.Left = x;
                        w2.Top = y;
                        w2.ShowInTaskbar = false;
                        w2.Topmost = topmost;
                        w2.TopmostWindow = topmost;
                        if (w2.Topmost)
                        {
                            try
                            {
                                MenuItem 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;
                        if (loadRepeatNumber.Contains("null"))
                        {
                            w2.RepetitionNumber = "null";
                        }
                        else
                        {
                            w2.RepetitionNumber = loadRepeatNumber;
                        }

                        CheckIfAlarmFires(w2);

                        windowArray[_arraySize] = w2;
                        ArrayPos++;

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

                        RichTextBox rtb = ((RichTextBox)((StackPanel)(w2.Content)).Children[1]);
                        TextRange tr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
                        try
                        {
                            if (contentIndicator == 0)
                            {
                                tr.Load(noteFiles, DataFormats.XamlPackage);
                            }
                            else
                            {
                                tr.Load(noteFiles, DataFormats.Xaml);
                            }
                        }
                        catch (Exception) { }
                        noteFiles.Close();
                    }
                    fs.Close();
                }
            }
            for (int i = ++count; i < 100; i++)
            {
                if(File.Exists(i.ToString()))
                {
                    File.Delete(i.ToString());
                }
            }
        }