Автор работы: Пользователь скрыл имя, 29 Января 2013 в 17:29, курсовая работа
Целью курсовой работы является автоматизация рассылки SMS сообщений, для ускорения и облегчения работы по оповещению студентов.
Задачей, для достижения данной цели является создание приложения SmsMessenger, которое будет производить автоматизацию рассылки SMS.
Введение 2
1. Описание предметной области 3
1.1. Предметная область курсового проекта 3
1.2. Информационно-логическая модель предметной области 3
2. Создание приложения SmsMessenger 6
2.1. Логическое проектирование 6
2.2. Модель данных 7
2.3. Описание представлений и представителей 8
3. Тестирование программы 17
Заключение 25
Список литературы 26
Пиложение А. Задание на курсовой проект 27
Приложение Б. Структура исходных файлов 28
Приложение В. XAML код всех представлений и библиотек ресурсов 30
Приложение Г. Код классов программы. 62
if (e.LeftButton == MouseButtonState.Pressed)
{
Point currentPosition = e.GetPosition(sender as Border);
DataObject d = new DataObject();
d.SetData("SmsTemplate",(
DragDropEffects finalDropEffect = DragDrop.DoDragDrop(sender as Border, d, DragDropEffects.Move);
}
}
private void AddTemplateGroupButton_click(o
{
Presenter.
}
private void EditSmsTemplateGroupButton_
{
Button button = sender as Button;
if (button != null)
Presenter.
}
private void DeleteSmsTemplateGroupButton_
{
if (MessageBox.Show("Удаление группы шаблона SMS."+Environment.NewLine+"Все шаблоны входящие в эту группу будут удалены!", "Уверены?", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
return;
Button button = sender as Button;
if (button != null)
Presenter.
}
}
}
CellPhoneValidator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Text.
namespace SmsMessanger.Validators
{
class CellPhoneValidation : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureIn
{
string phone = value.ToString();
if (string.IsNullOrEmpty(phone)) return new ValidationResult(true, null);
for (int i = 0; i < phone.Length; i++)
if (!char.IsNumber(phone[i])) phone = phone.Remove(i,1);
phone = "+" + phone;
bool valid = Regex.IsMatch(phone, @"\+7[0-9]{10,10}$");
if (!valid)
return new ValidationResult(false, "Сотовый телефон должен быть в формате +7xxxxxxxxx");
else
return new ValidationResult(true, null);
}
}
}
ErrorsToMessagesConverter.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;
using System.Collections.
namespace SmsMessanger.Validators
{
class ErrorsToMessagesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureIn
{
StringBuilder sb = new StringBuilder();
var errors = value as ReadOnlyCollection<ValidationE
if (errors != null)
{
foreach (var e in errors.Where(e=>e.
{
sb.AppendLine(e.ErrorContent.
}
}
return sb.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureIn
{
throw new NotImplementedException();
}
}
}
ErrorsToVisibleConverter.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Controls;
using System.Collections.
namespace SmsMessanger.Validators
{
class ErrorsToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureIn
{
var errors = value as ReadOnlyCollection<ValidationE
if (errors == null) return System.Windows.Visibility.
if (errors.Count == 0) return System.Windows.Visibility.
return System.Windows.Visibility.
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureIn
{
throw new NotImplementedException();
}
}
}
TitlesValidator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
namespace SmsMessanger.Validators
{
class TitlesValidator : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureIn
{
string title = value.ToString();
if (string.IsNullOrEmpty(title))
return new ValidationResult(false,"Поле обязательно для заполнения");
if (title.Length < 2)
return new ValidationResult(false, "Длина текста в поле должна быть не менее 2-х символов");
return new ValidationResult(true, null);
}
}
}
EditConfigView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditConfigView.xaml
/// </summary>
public partial class EditConfigView : UserControl
{
public EditConfigView()
{
InitializeComponent();
}
EditConfigPresenter Presenter { get { return DataContext as EditConfigPresenter; } }
private void savebutton_click(object sender, RoutedEventArgs e)
{
Presenter.SaveSettings();
}
}
}
EditContactView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
using SmsMessanger.Model;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditContact.xaml
/// </summary>
public partial class EditContactView : UserControl
{
public EditContactView()
{
InitializeComponent();
}
public EditContactPresenter Presenter { get { return DataContext as EditContactPresenter; } }
private void choseImageButton_click(object sender, RoutedEventArgs e)
{
Presenter.SaveImage();
}
private void saveButton_Click(object sender, RoutedEventArgs e)
{
StringBuilder errors = new StringBuilder();
#region просмотр критических для сохранения полей
//Сохранять нельзя
if (Validation.GetHasError(
{
MessageBox.Show("Не коректно заполнено имя/фамилия студента. Сохранение отменено.");
return;
}
//Можно сохранять
if (Validation.GetHasError(
errors.AppendLine("Сотовый телефон
указан в неверном формате, и не будет
сохранен."+Environment.
#endregion
if (!string.IsNullOrEmpty(errors.
MessageBox.Show(errors.
Presenter.SaveContact();
}
}
}
EditDistributionListView.xaml.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
using SmsMessanger.Model;
using SmsMessanger.Model.ViewModels;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditContact.xaml
/// </summary>
public partial class EditDistributionListView : UserControl
{
public EditDistributionListView()
{
InitializeComponent();
}
public EditDistributionListPresenter Presenter { get { return DataContext as EditDistributionListPresenter; } }
private void SaveButton_click(object sender, RoutedEventArgs e)
{
Presenter.
}
private void GroupUnchecked(object sender, RoutedEventArgs e)
{
CheckBox checkBox = sender as CheckBox;
TreeViewItem node = SmsVisualTreeHelper.
TreeView tree = SmsVisualTreeHelper.
TreeViewItem container = tree.ItemContainerGenerator.
}
private void ContactChecked(object sender, RoutedEventArgs e)
{
CheckBox cbox = sender as CheckBox;
TreeViewItem node = SmsVisualTreeHelper.
TreeViewItem mainNode = SmsVisualTreeHelper.
(mainNode.DataContext as DistributionTreeGroup).
}
private void ContactUnchecked(object sender, RoutedEventArgs e)
{
CheckBox cbox = sender as CheckBox;
TreeViewItem node = SmsVisualTreeHelper.
TreeViewItem mainNode = SmsVisualTreeHelper.
foreach (var item in mainNode.Items)
{
if ((item as DistributionTreeContact).
{
(mainNode.DataContext as DistributionTreeGroup).
return;
}
(mainNode.DataContext as DistributionTreeGroup).
}
}
private void checkAllElementsButton_click(o
{
Button button = sender as Button;
if (button != null)
{
DistributionTreeGroup group = button.DataContext as DistributionTreeGroup;
bool groupChecked = !group.IsChecked;
group.IsChecked = groupChecked;
foreach (var item in group.Contacts)
{
item.IsChecked = groupChecked;
}
}
TreeViewItem node = SmsVisualTreeHelper.
node.IsExpanded = true;
}
}
}
EditGroupView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditGroupView.xaml
/// </summary>
public partial class EditGroupView : UserControl
{
public EditGroupView()
{
InitializeComponent();
}
public EditGroupPresenter Presenter { get { return DataContext as EditGroupPresenter; } }
private void saveButton_Click(object sender, RoutedEventArgs e)
{
Presenter.SaveGroup();
}
}
}
EditSmsTemplateGroupView.xaml.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditSmsTemplateGroup.xaml
/// </summary>
public partial class EditSmsTemplateGroupView : UserControl
{
public EditSmsTemplateGroupView()
{
InitializeComponent();
}
EditSmsTemplateGroupPresenter Presenter { get { return DataContext as EditSmsTemplateGroupPresenter; } }
private void saveButton_click(object sender, RoutedEventArgs e)
{
Presenter.Save();
}
}
}
EditSmsView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditGroupView.xaml
/// </summary>
public partial class EditSmsView : UserControl
{
public EditSmsView()
{
InitializeComponent();
}
public EditSmsTemplatePresenter Presenter { get { return DataContext as EditSmsTemplatePresenter; } }
private void saveButton_Click(object sender, RoutedEventArgs e)
{
Presenter.SaveSmsTemplate();
}
}
}
LogView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
using SmsMessanger.Model;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditContact.xaml
/// </summary>
public partial class LogView : UserControl
{
public LogView()
{
InitializeComponent();
}
public LogPresenter Presenter { get { return DataContext as LogPresenter; } }
}
}
SendSmsByListView.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SmsMessanger.Presenters;
using SmsMessanger.Model;
using SmsMessanger.Model.ViewModels;
namespace SmsMessanger.Views
{
/// <summary>
/// Interaction logic for EditContact.xaml
/// </summary>
public partial class SendSmsByListView : UserControl
{
public SendSmsByListView()
{
InitializeComponent();
}
public SendSmsByListPresenter Presenter { get { return DataContext as SendSmsByListPresenter; } }
private void PrepareSmsButton_click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
if (button!=null)
{
SmsTemplate template = button.DataContext as SmsTemplate;
SmsMessage.Text = template.Text;
}
}
private void SendSMS_button(object sender, RoutedEventArgs e)
{
Presenter.SendSmsList();
}
private void cancelButton_click(object sender, RoutedEventArgs e)
{
Presenter.Cancel();
}
private void saveTemplateButton_click(objec
{
if (templateGroupSelectorPanel.
{
SmsTemplateGroup templateGroup = templateGroupSelector.
if (templateGroup == null) return;
if (string.IsNullOrEmpty(
if (templateGroupSelector.
{
Presenter.SaveSmsTemplate(
templateGroupSelector.
newTemplateTitle.Text = string.Empty;
templateGroupSelectorPanel.
Информация о работе Разработка системы рассылки СМС сообщений