private void AppointmentTemplate_Loaded(object sender, RoutedEventArgs e) { AppointmentTemplate template = sender as AppointmentTemplate; template.CancelButtonClicked += this.onCancelButtonClicked; template.RescheduleButtonClicked += this.onResBtnClicked; }
private void ShowPreview() { documentViewer.Visibility = Visibility.Collapsed; FlowDocument doc = null; switch (_args.DocumentType) { case EditType.Appointment: doc = new AppointmentTemplate((Appointment)_args.DatabaseObject).GetFlowDocument(); break; case EditType.Contact: doc = new ContactTemplate((Contact)_args.DatabaseObject).GetFlowDocument(); break; case EditType.Note: doc = new NoteTemplate((NotebookPage)_args.DatabaseObject).GetFlowDocument(); break; case EditType.Task: doc = new TaskTemplate((UserTask)_args.DatabaseObject).GetFlowDocument(); break; default: break; } FlowDocument copy = doc.Copy(); Size size = ((PaperSize)((FrameworkElement)paperSizeCombo.SelectedItem).Tag).Size; if ((size.Width < size.Height && orientationCombo.SelectedIndex == 1) || (size.Width > size.Height && orientationCombo.SelectedIndex == 0)) { size = new Size(size.Height, size.Width); } documentViewer.Document = FlowPaginator.ConvertFrom( copy, size, ((PageMargin)((FrameworkElement)marginCombo.SelectedItem).Tag).Margin ); documentViewer.Visibility = Visibility.Visible; documentViewer.FadeIn(AnimationHelpers.AnimationDuration); documentViewer.FitToWidth(); }
private static void SaveAppointment(Window owner, StatusStrip statusStrip, string filename, Appointment appointment) { try { switch (Path.GetExtension(filename).ToLower()) { case ".rtf": FlowDocument doc = new AppointmentTemplate(appointment).GetFlowDocument(); TextRange range = new TextRange(doc.ContentStart, doc.ContentEnd); FileStream fStream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write); range.Save(fStream, DataFormats.Rtf); fStream.Close(); statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL"); break; case ".txt": string[] filecontents = new AppointmentTemplate(appointment).GetTextDocument(); File.WriteAllLines(filename, filecontents); statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL"); break; default: statusStrip.UpdateMainStatus("ERROR: REQUESTED FILE TYPE UNAVAILABLE"); TaskDialog dialog = new TaskDialog(owner, "Error Saving File", "The requested file type is not available.", MessageType.Error); dialog.ShowDialog(); break; } } catch (Exception exc) { statusStrip.UpdateMainStatus("ERROR: " + exc.Message.ToUpper()); TaskDialog dialog = new TaskDialog(owner, "Error Saving File", exc.Message, MessageType.Error); dialog.ShowDialog(); ExportAppointment(owner, statusStrip, Path.GetDirectoryName(saveDialog.SelectedFile), appointment); } }