Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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.º 5
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.º 6
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());
                }
            }
        }