public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("Name", Name); writer.WriteAttributeString("Label", Label); writer.WriteAttributeString("Enabled", Enabled.ToString()); writer.WriteAttributeString("WindowStyle", WindowStyle.ToString()); writer.WriteElementString("Data", Data); }
void button_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; WindowStyle style = (WindowStyle)Enum.Parse(typeof(WindowStyle), (string)button.Content); ResizeMode resize = (ResizeMode)Enum.Parse(typeof(ResizeMode), (string)resizeCombo.Text); Window window = new Window(); window.Initialized += new EventHandler(window_Initialized); window.Unloaded += new RoutedEventHandler(window_Unloaded); // do look 'n' feel //window.Background = Brushes.Yellow; window.WindowStyle = style; window.ResizeMode = resize; //window.Owner = this; if (Properties.Settings.Default.ShowResizeMode) { window.Content = " WindowStyle." + style.ToString() + "\r\n ResizeMode." + resize.ToString() + "\r\n (" + Properties.Settings.Default.OsThemeLabel + ")"; } else { window.Content = " WindowStyle." + style.ToString() + "\r\n\r\n (" + Properties.Settings.Default.OsThemeLabel + ")"; } window.Width = 220; window.Height = 100; window.MouseDown += delegate(object sender2, MouseButtonEventArgs e2) { window.DragMove(); }; window.Title = "The Title"; if (modalCheckBox.IsChecked == true) { window.ShowDialog(); } else { window.Show(); } }
private void Window2_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (WindowStyle.ToString() == WindowStyle.None.ToString()) { WindowStyle = WindowStyle.ToolWindow; Height = _windowHeight; Width = _windowWidth; ResizeMode = ResizeMode.CanResize; Background = _backGround; Foreground = _foreGround; Cursor = Cursors.Arrow; BorderThickness = new Thickness(0); ShowInTaskbar = false; } }
private void dialog_Closed(object sender, EventArgs e) { var dia = sender as Dialog; if (dia.Tag != null) { dia.Tag = null; var arr = dia.PropertyArray; if (arr[0] != null) { BackgroundColorIndex = (int)(arr[0]); if (WindowStyle.ToString() == WindowStyle.None.ToString()) { _backGround = ChangeBackgroundColor(Dialog.ColorArray[BackgroundColorIndex]); } else { Background = ChangeBackgroundColor(Dialog.ColorArray[BackgroundColorIndex]); _backGround = Background; } } else { BackgroundColorIndex = (BackgroundColorIndex != -1) ? BackgroundColorIndex : -1; } if (arr[1] != null) { ForegroundColorIndex = (int)(arr[1]); var rtb = LogicalTreeHelper.FindLogicalNode(this, "NoteBox") as RichTextBox; rtb.SelectAll(); rtb.Selection.ApplyPropertyValue(ForegroundProperty, Dialog.ColorArrayForeground[ForegroundColorIndex]); rtb.Selection.Select(rtb.Document.ContentStart, rtb.Document.ContentStart); _foreGround = Foreground; } else { ForegroundColorIndex = (ForegroundColorIndex != -1) ? ForegroundColorIndex : -1; } if (arr[2] != null) { Alarm = dia.Alarm; var w = this; 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 m2 = LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as Image; var alarm = w.Alarm; var current = DateTime.Now; m2.Visibility = (alarm.CompareTo(DateTime.Now) >= 0) ? (Visibility.Visible) : (Visibility.Hidden); 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.Topmost = true; m.IsChecked = true; m1.IsEnabled = true; w.BorderBrush = 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 = Brushes.Transparent; w.BorderThickness = new Thickness(0); } } RepetitionNumber = dia.AlarmRepetition; } }