Автор работы: Пользователь скрыл имя, 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
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
TransparentButton.xaml
<ResourceDictionary xmlns="http://schemas.
xmlns:x="http://schemas.
<Style x:Key="ButtonFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Resource dictionary entries should be defined here. -->
<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#F3F3F3" Offset="0"/>
<GradientStop Color="#EBEBEB" Offset="0.5"/>
<GradientStop Color="#DDDDDD" Offset="0.5"/>
<GradientStop Color="#CDCDCD" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
<Style x:Key="TransparentButton" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.
<Setter Property="
<Setter Property="
<Setter Property="Padding" Value="1"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter HorizontalAlignment="{Template
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocused" Value="true"/>
<Trigger Property="ToggleButton.
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#ADADAD"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
App
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace SmsMessanger
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Shell
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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class Shell : Window
{
private System.Windows.Forms.NotifyIco
public System.Windows.Forms.NotifyIco
{
get { return notifyIcon; }
}
public Shell()
{
InitializeComponent();
#region Установка иконки в трее
notifyIcon = new System.Windows.Forms.NotifyIco
//notifyIcon.BalloonTipTitle = "SMS Messenger";
//notifyIcon.BalloonTipText = "SMS";
notifyIcon.Text = "Sms Messenger";
notifyIcon.Icon = new System.Drawing.Icon(@"icon.
notifyIcon.DoubleClick += (o, arg) =>
{
Show();
WindowState = System.Windows.WindowState.
};
if (notifyIcon != null)
notifyIcon.Visible = true;
#endregion
DataContext = new ApplicationPresenter(this);
}
public void RemoveTab(TabItem tabItem)
{
tabs.Items.Remove(tabItem);
}
public void RemoveAllTabs()
{
tabs.Items.Clear();
}
public void AddTab<T>(PresenterBase<T> presenter)
{
TabItem newTab = null;
foreach(TabItem existingTab in tabs.Items)
if (existingTab.DataContext.
{
tabs.Items.Remove(existingTab)
newTab = existingTab;
break;
}
if(newTab==null)
{
newTab = new TabItem();
Binding headerBinding = new Binding(presenter.
BindingOperations.SetBinding(
newTab,
TabItem.HeaderProperty,
headerBinding
);
newTab.DataContext = presenter;
newTab.Content = presenter.View;
}
#region Контекстное меню шапки
ContextMenu tabMenu = new System.Windows.Controls.Contex
MenuItem item = new MenuItem(){Header="Закрыть"};
item.Click+=(o,arg)=>
{
RemoveTab(newTab);
};
tabMenu.Items.Add(item);
item = new MenuItem() { Header = "Закрыть все" };
item.Click += (o, arg) =>
{
RemoveAllTabs();
};
tabMenu.Items.Add(item);
newTab.ContextMenu = tabMenu;
#endregion
tabs.Items.Insert(0, newTab);
newTab.Focus();
}
public void RemoveTab<T>(PresenterBase<T> presenter)
{
foreach(TabItem existingTab in tabs.Items)
if (existingTab.DataContext.
{
tabs.Items.Remove(existingTab)
break;
}
}
private void app_closed(object sender, EventArgs e)
{
Loger.Write("Приложение закрыто", LogImages.Exit);
}
private void Window_StateChanged(object sender, EventArgs e)
{
if (WindowState == System.Windows.WindowState.
{
Hide();
if (notifyIcon != null)
notifyIcon.ShowBalloonTip(
}
}
}
}
Notifer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace SmsMessanger
{
[Serializable]
public abstract class Notifer : INotifyPropertyChanged
{
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(
}
}
}
}
Config.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Configuration;
using System.Xml.Linq;
namespace SmsMessanger
{
public static class Configurator
{
public static string GetSetting(string settingName)
{
XDocument doc = XDocument.Load("Config.xml");
XElement root = doc.Element("root");
XElement element = root.Element(settingName);
if (element == null) return null;
else return element.Attribute("value").
}
public static void SetSetting(string settingName,string value)
{
XDocument doc = XDocument.Load("Config.xml");
XElement root = doc.Element("root");
XElement element = root.Element(settingName);
if (element != null)
element.SetAttributeValue("
doc.Save("Config.xml");
}
public static string SmscLogin
{
get { return GetSetting("SmscLogin"); }
set { SetSetting("SmscLogin",value); }
}
public static string SmscPassword
{
get { return GetSetting("SmscPassword"); }
set { SetSetting("SmscPassword",valu
}
public static bool CombatMode
{
get { return bool.Parse(GetSetting("
set { SetSetting("CombatMode",value.
}
}
}
Enums.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SmsMessanger
{
public enum LogImages
{
Normal = 0,
Exit = 1,
Save = 2,
Warning = 3,
Error = 4
}
}
Loger.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace SmsMessanger
{
public static class Loger
{
private static string logFile { get { return "log.txt"; } }
private static string currentImage = "0";
public static void Write(string text)
{
using (FileStream stream = new FileStream(logFile, FileMode.Append))
{
TextWriter tw = new StreamWriter(stream);
tw.WriteLine(string.Format("{
tw.Close();
}
}
public static void Write(string text,LogImages image)
{
currentImage = Enum.Format(typeof(LogImages), image, "d");
Write(text);
}
}
}
Loger.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
namespace SmsMessanger
{
public static class SmsVisualTreeHelper
{
public static T FindAncestor<T>(DependencyObje
where T : class
{
DependencyObject target = dependencyObject;
do
{
target = VisualTreeHelper.GetParent(
}
while (target != null && !(target is T));
return target as T;
}
}
}
ContactRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.
namespace SmsMessanger.Model
{
public class ContactRepository:RepositoryBa
{
public ContactRepository(GroupReposit
{
//Связываем контакты и группы
foreach (Contact contact in _store)
{
contact.Group = groupRepository.GetGroup(
if (contact.Group == null) continue;
if (contact.Group.Contacts == null) contact.Group.Contacts = new List<Contact>();
contact.Group.Contacts.Add(
}
}
public Contact GetContact(Guid id)
{
return _store.First(c => c.Id == id);
}
public void DeleteContact(Contact contact)
{
if (contact != null)
_store.Remove(contact);
Serialize();
}
public void SaveContact(Contact contact)
{
if (contact.Id == Guid.Empty)
contact.Id = Guid.NewGuid();
if (!_store.Contains(contact))
_store.Add(contact);
Serialize();
}
public List<Contact> FindAll()
{
return new List<Contact>(_store);
}
public List<Contact> FindById(Guid[] Ids)
{
return (from c in _store where Ids.Contains(c.Id) select c).ToList();
}
public void ClearChecked()
{
foreach (var item in _store)
{
item.Checked = false;
if (item.Group!=null)
item.Group.Checked = false;
}
}
}
}
DistributionListRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SmsMessanger.Model
{
class DistributionListRepository:Rep
{
private ContactRepository _contactRepository;
public DistributionListRepository(Con
: base("DistributionList.source"
{
_contactRepository = contactRepository;
RebuildTree();
}
public List<DistributionList> FindAll()
{
return new List<DistributionList>(_store)
}
public Group GetDistributionList(Guid id)
{
return null;
//return _store.FirstOrDefaultx(g=>g.
}
public void SaveDistributionList(Distribut
{
if (list.Id == Guid.Empty)
list.Id = Guid.NewGuid();
if (!_store.Contains(list))
_store.Add(list);
Serialize();
}
public void DeleteDestributionList(Distrib
{
if (list != null)
{
_store.Remove(list);
Serialize();
}
}
public void RebuildTree()
{
foreach (var dList in _store)
{
dList.Contacts = (from c in _contactRepository.FindAll() where dList.ContactsId.Contains(c.
dList.Groups = DistributionList.
}
}
}
}
DistributionListRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SmsMessanger.Model
{
public class GroupRepository:RepositoryBase
{
public GroupRepository():base("
{
//SaveGroup(new Group(){ Title = "Group-1"});
}
public List<Group> FindAll()
{
return new List<Group>(_store);
}
public Group GetGroup(Guid id)
{
return _store.FirstOrDefault(g=>g.Id=
}
public void SaveGroup(Group group)
{
if (group.Id == Guid.Empty)
group.Id = Guid.NewGuid();
if (!_store.Contains(group))
_store.Add(group);
Serialize();
}
Информация о работе Разработка системы рассылки СМС сообщений