private void btnTheme_Click(object sender, RoutedEventArgs e) { if (Application.Current.Resources.MergedDictionaries[0].Source.ToString() == "Theme1.xaml") { Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("Theme2.xaml", UriKind.Relative) }); } else { Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("Theme1.xaml", UriKind.Relative) }); } if (isMaximized) { CommonWindowHelper.SetMaximizedBackground(maxBorder); } else { CommonWindowHelper.SetRestoredBackground(maxBorder); } }
private void btnMaximize_Click(object sender, RoutedEventArgs e) { if (isMaximized) { Height = RestoredHeight; Width = RestoredWidth; Left = RestoredLeft; Top = RestoredTop; isMaximized = false; CommonWindowHelper.SetRestoredBackground(maxBorder); btnMaximize.Style = (Style)App.Current.Resources["MaximizeButtonStyle"]; } else { WindowStartupLocation = WindowStartupLocation.Manual; RestoredHeight = Height; RestoredWidth = Width; RestoredLeft = Left; RestoredTop = Top; Height = SystemParameters.WorkArea.Height; Width = SystemParameters.WorkArea.Width; Left = (SystemParameters.WorkArea.Location.X); Top = (SystemParameters.WorkArea.Location.Y); isMaximized = true; CommonWindowHelper.SetMaximizedBackground(maxBorder); btnMaximize.Style = (Style)App.Current.Resources["RestoreButtonStyle"]; } }
private void resizeHandle_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { this.Height = e.GetPosition(this).Y; this.Width = e.GetPosition(this).X + 20; isMaximized = false; CommonWindowHelper.SetRestoredBackground(maxBorder); } e.Handled = true; }
private void SaveTimer_Tick(object sender, EventArgs e) { //Don't save anything if this window is not active if (!this.IsActive) { return; } CommonWindowHelper.DisplayMessage("", lblSave); //saving contents in active rich text box RichTextBox rtb = ((RichTextBox)tabControl.SelectedContent); if (rtb != null) { int difference = rtb.Document.ContentStart.GetOffsetToPosition(rtb.Document.ContentEnd); //adding a character make difference 5 or more if (difference >= 5) { CommonWindowHelper.DisplayMessage("Saved", lblSave); TextRange range = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd); try { //saving as different file types if (((string)rtb.Tag).EndsWith(".rtf", StringComparison.InvariantCultureIgnoreCase)) { rtb.Foreground = Brushes.Black; using (FileStream file = new FileStream((string)rtb.Tag, FileMode.OpenOrCreate, FileAccess.Write)) { range.Save(file, DataFormats.Rtf); } rtb.Foreground = Brushes.White; } else { File.WriteAllText((string)rtb.Tag, range.Text); } } catch (Exception ex) { rtb.Foreground = Brushes.White; CommonWindowHelper.DisplayException("Error saving.\r\nHover over me to learn more.", lblSave, ex); } //updating count of words and lines CommonWindowHelper.DisplayUpdatedWordAndLineCount(range, lblCount); } } }
private void btnClose_Click(object sender, RoutedEventArgs e) { CommonWindowHelper.CloseWindow(); }