This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmMain.cs
77 lines (65 loc) · 3.09 KB
/
frmMain.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace DevExpress.XtraWizard.Demos {
public partial class frmMain : XtraForm {
bool finish = false;
public frmMain() {
InitializeComponent();
}
private void wizardControl1_SelectedPageChanging(object sender, WizardPageChangingEventArgs e) {
if(e.PrevPage == wpCardTemplate && e.Direction == Direction.Forward)
e.Page = ceSignature.Checked ? wpSignature : wpPreview;
if(e.PrevPage == wpPreview && e.Direction == Direction.Backward)
e.Page = ceSignature.Checked ? wpSignature : wpCardTemplate;
if(e.Page == wpPreview && e.Direction == Direction.Forward)
CreateCardPreview();
}
private void wizardControl1_SelectedPageChanged(object sender, WizardPageChangedEventArgs e) {
if(e.Page == wpRecipientData)
teRecipientName.Focus();
if(e.Page == wpSignature)
teYourName.Focus();
}
private void teRecipient_TextChanged(object sender, EventArgs e) {
wpRecipientData.AllowNext = teRecipientName.Text != string.Empty && teEmail.Text != string.Empty;
}
private void teYourName_TextChanged(object sender, EventArgs e) {
wpSignature.AllowNext = teYourName.Text != string.Empty;
}
private void sbSkipSignature_Click(object sender, EventArgs e) {
teYourName.Text = string.Empty;
ceSignature.Checked = false;
wizardControl1.SelectedPage = wpPreview;
}
void CreateCardPreview() {
meCard.Text = string.Format("Happy birthday, {0}!!!\r\n{1}", teRecipientName.Text, rgWishes.Properties.Items[rgWishes.SelectedIndex].Description);
if(ceSignature.Checked)
meCard.Text += string.Format("\r\n\r\n{0}, {1}", cbeSignatureTemplate.Text, teYourName.Text);
}
private void sbSend_Click(object sender, EventArgs e) {
System.Diagnostics.Process.Start(string.Format("mailto:{0}?subject={1}&body={2}",
teEmail.Text, "Happy Birthday!", meCard.Text.Replace("\r\n", "%0A")));
}
private void wizardControl1_CancelClick(object sender, CancelEventArgs e) {
this.Close();
}
private void wizardControl1_FinishClick(object sender, CancelEventArgs e) {
finish = true;
this.Close();
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) {
if(finish) return;
if(XtraMessageBox.Show(this, "Do you want to exit the XtraWizard control demo?", "XtraWizard", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
e.Cancel = true;
}
private void teEmail_InvalidValue(object sender, DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs e) {
e.ErrorText = "Invalid email address";
}
}
}