Windows (XP, Vista, Seven);
.NET Framework 4.0.
, , Windows-.
, :
v Control_panel - , , .
v External_Doorphone -, , , .
v Apartment_Doorphone -, , . .
v Processor , .
v Switch , 璺 .
v IComunication , TransmissionLines. .
v DataTransmissionLines , .
v ComunicationPanel - , .
v Door_locking_device , .
v User_History , .
v Melody .
v Clock , .
7.
Microsoft Visual Studio 2010 C#. C # '- ' , , 䳿 , . , , :
, ᒺ , , , .
, ( ), .
, ᒺ ᒺ. , .
8.
, , .
, .
|
|
8.1.
:
1) , ;
2) , , , 䳿( , , , ) .
3) ( ), (, ).
4) , .
8.2. ,
:
1) ;
2) ;
3) ;
4) , ;
5) ̳ , ;
6) ;
7) , .
8.3. ,
:
1) , ;
2) ;
3) ;
4) ̳ , ;
5) ;
6) , .
a) :
b) , :
c) :
d) :
Control_panel.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Doorphone1._2_OOP_Severina
{
public struct logstruct
{
public int number;
public string myevent;
public string date;
public logstruct(int Num, string MyEv, string Date)
{
number = Num;
myevent = MyEv;
date = Date;
}
};
public partial class Control_panel: Form
{
List<logstruct> loglist;
//
private IComucation<Char> Sound_1;
private IComucation<Char> Sound_2;
// '
private IComucation<short> Proces_1;
private IComucation<short> Proces_2;
// ,
private List<Apartment_Doorphone> _apartments;
private Processor processor; //
private Switch commutator; //
private External_Doorphone inputPanel; //
private Door_locking_device door; //
public Control_panel()
{
InitializeComponent();
FileStream file = File.Open("Log.txt", FileMode.OpenOrCreate);
file.Close();
loglist = new List<logstruct>();
short keyPass;
string line;
_apartments = new List<Apartment_Doorphone>();
try {
//
StreamReader sr = new StreamReader("DomophoneData.txt", Encoding.UTF8);
line = sr.ReadLine();
keyPass = Convert.ToInt16(line);
if (keyPass > 0) keyPass *= -1;
while (sr.Peek()!= -1) {
line = sr.ReadLine();
_apartments.Add(new Apartment_Doorphone(Convert.ToInt16(line), false, 0,this));
|
|
ApartmentsList.Items.Add(" " + line);
}
sr.Close();
} catch (Exception) {
MessageBox.Show(" . .");
//
for (short i = 1; i <= 10; i++) {
_apartments.Add(new Apartment_Doorphone(i, false, 0,this));
ApartmentsList.Items.Add(" " + i);
}
keyPass = -777;
}
Sound_1 = new TransmissionLines<Char>();
Sound_2 = new TransmissionLines<Char>();
processor = new Processor(keyPass);
Proces_1 = processor.PanelIn;
Proces_2 = processor.PanelOut;
commutator = new Switch(ref this._apartments,
processor.CommutatorOut, processor.CommutatorIn,
processor.ApartmentOut, processor.ApartmentIn,
Sound_1, Sound_2);
inputPanel = new External_Doorphone(Sound_2, Sound_1, Proces_2, Proces_1,this);
inputPanel.Show();
door = new Door_locking_device(ref this.pictureBox1);
processor.ClockOut.Signal += new SignalTransmission<DateTime>(ClockOut_Signal);
processor.HistoryOut.Signal += new SignalTransmission<User_History>(HistoryOut_Signal);
processor.DoorOut.Signal += new SignalTransmission<bool>(DoorOut_Signal);
ReadLog();
}
// ղ ˲ ί
///
public void DoorOut_Signal(object source, DataTransmissionLines<bool> options)
{
if (options.Data == true)
{
door.OpenDoor();
}
}
//
void HistoryOut_Signal(object source, DataTransmissionLines<User_History> options)
{
if (options.Data!= null)
{
security.Rows.Insert(0, new string[] { options.Data.ApartNumber.ToString(), options.Data.OpenTime.ToString("HH:mm:ss - dd.MM.yyyy") });
}
}
public void WriteLog(short num,string str)
{
try
{
StreamWriter sw = new StreamWriter("Log.txt", append: true);
sw.WriteLine(num);
sw.WriteLine(str);
string Date = DateTime.Now.ToString();
sw.WriteLine(Date);
sw.Close();
}
catch (Exception)
{
MessageBox.Show(".");
}
ReadLog();
}
public int NumberOfLines()
{
using (StreamReader r = new StreamReader("Log.txt"))
{
int i = 0;
while (r.ReadLine()!= null) { i++; }
{
r.Close();
return i;
}
}
}
public void ReadLog()
{
loglist.Clear();
try
{
StreamReader sr = new StreamReader("Log.txt");
for (int i = 0; i < NumberOfLines() / 3; i++)
{
int num = Convert.ToInt32(sr.ReadLine());
string ev = sr.ReadLine();
string date = sr.ReadLine();
loglist.Add(new logstruct(num, ev, date));
}
sr.Close();
}
catch (Exception)
{
MessageBox.Show(".");
}
ToStruct();
}
public void ToStruct()
{
security.Rows.Clear();
if (loglist.Count!= 0)
security.Rows.Add(loglist.Count);
int counter = 0;
for (int i = loglist.Count; i >0; i--)
{
security.Rows[counter].Cells[0].Value = loglist[i-1].number;
security.Rows[counter].Cells[1].Value = loglist[i-1].myevent;
security.Rows[counter].Cells[2].Value = loglist[i-1].date;
counter++;
}
}
// -
void ClockOut_Signal(object source, DataTransmissionLines<DateTime> options)
{
DateTime time = options.Data;
string t = time.ToString("dd.MM.yyyy HH:mm:ss");
this.Text = ":: " + t;
}
// IJ
private void ApartmentsList_DoubleClick(object sender, EventArgs e) {
}
private void ApartmentsList_KeyUp(object sender, KeyEventArgs e) {
}
private void ApartmentsList_DoubleClick_1(object sender, EventArgs e)
{
if (ApartmentsList.SelectedItems.Count!= 0)
|
|
{
_apartments[ApartmentsList.SelectedIndex].Show();
}
}
private void ApartmentsList_KeyUp_1(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && ApartmentsList.SelectedItems.Count!= 0)
{
_apartments[ApartmentsList.SelectedIndex].Show();
}
}
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("Log.txt", FileMode.Create);
fs.Close();
ReadLog();
}
}
}
External_Doorphone.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Doorphone1._2_OOP_Severina
{
public partial class External_Doorphone: Form
{
[DllImport("user32", CharSet = CharSet.Auto)]
internal extern static bool PostMessage(IntPtr hWind, uint Msg, uint WParam, uint LParam);
[DllImport("user32", CharSet = CharSet.Auto)]
internal extern static bool ReleaseCapture();
const uint WM_SYSCOMMAND = 0x0112;
const uint DOMOVE = 0xF012;
/* :
* >= 0 -
* < 0 -
**/
//
private IComucation<Char> inSound;
private IComucation<Char> outSound;
// '
private IComucation<short> inProcess;
private IComucation<short> outProcess;
//
private ComunicationPanel _comunicationPanel;
///
// CInputPanel
private Control_panel parentObject;
public External_Doorphone(IComucation<Char> InSound, IComucation<Char> OutSound,
IComucation<short> InProcess, IComucation<short> OutProcess, Control_panel cop)
{
InitializeComponent();
parentObject = cop;
//
inSound = InSound;
outSound = OutSound;
inProcess = InProcess;
outProcess = OutProcess;
//
_comunicationPanel = new ComunicationPanel(ref this.microphone, ref this.dynamic);
//
// :
_comunicationPanel.AddSignalListener(inSound, outSound);
// ϳ
inProcess.Signal += new SignalTransmission<short>(ProcInSignal);
}
//
///
private void CallProcessor(short data)
{
outProcess.hallenges = data;
}
// ղ ˲ ί
/* :
* >= 0 -
* -1 -
* -2 - ,
* -3 - ,
* -4 -
* -5 - ,
**/
/// ,
private void ProcInSignal(object source, DataTransmissionLines<short> options)
{
// ,
if (options.Data >= 0)
{
display.Text = Convert.ToString(options.Data);
}
// 䳿
else
{
switch (options.Data)
{
//
case -1:
this.display.Text = "!";
break;
//
case -2:
this.display.Text = "...";
|
|
break;
// , '
case -3:
this.display.Text = " .";
this.dynamic.Enabled = false;
this.microphone.Enabled = true;
this.microphone.Focus();
break;
//
case -4:
this.display.Text = "";
this.dynamic.Text = "";
this.microphone.Enabled = false;
this.dynamic.Enabled = false;
break;
// ,
case -5:
this.display.Text = " .";
Melody._doorOpen.Play();
break;
//
default:
break;
}
}
}
// IJ
private void but1_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(1);
}
private void but2_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(2);
}
private void but3_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(3);
}
private void but6_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(4);
}
private void but5_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(5);
}
private void but4_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(6);
}
private void but9_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(7);
}
private void but8_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(8);
}
private void but7_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(9);
}
private void but0_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(0);
}
private void butExit_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(11);
}
private void butCall_Click(object sender, EventArgs e)
{
Melody._btnClick.Play();
CallProcessor(10);
}
private void logo_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
PostMessage(this.Handle, WM_SYSCOMMAND, DOMOVE, 0);
}
private void key_Click(object sender, EventArgs e)
{
parentObject.WriteLog(0, " ");
CallProcessor(12);
}
}
}
Apartment_Doorphone.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Doorphone1._2_OOP_Severina
{
/// <summary>
///
/// </summary>
public partial class Apartment_Doorphone: Form
{
[DllImport("user32", CharSet = CharSet.Auto)]
internal extern static bool PostMessage(IntPtr hWind, uint Msg, uint WParam, uint LParam);
[DllImport("user32", CharSet = CharSet.Auto)]
internal extern static bool ReleaseCapture();
const uint WM_SYSCOMMAND = 0x0112;
const uint DOMOVE = 0xF012;
/* :
* 1 -
* 2 -
* 3 -
**/
//
private ComunicationPanel comunication_Panel;
//
private short Number;
//
private Byte state_;
//
private bool isBlocked;
// '
private IComucation<short> inProcess;
private IComucation<short> outProcess;
//
private IComucation<Char> inSound;
private IComucation<Char> outSound;
/// CApartment
private Control_panel parentObject;
public Apartment_Doorphone(short _number, bool _isBlocked, Byte _state,Control_panel cop)
{
InitializeComponent();
parentObject = cop;
isBlocked = _isBlocked;
Number = _number;
State = _state;
this.Text = " #" + _number;
//
comunication_Panel = new ComunicationPanel(ref this.microphone, ref this.dynamic);
}
//
public short GetNumber
{
get { return Number; }
}
/// ϳ
public void SetCommunications(IComucation<Char> _inSound, IComucation<Char> _outSound,
IComucation<short> _inProcess, IComucation<short> _outProcess)
{
|
|
//
inSound = _inSound;
outSound = _outSound;
inProcess = _inProcess;
outProcess = _outProcess;
comunication_Panel.AddSignalListener(inSound, outSound);
inProcess.Signal += new SignalTransmission<short>(ProcSignal);
}
// ³'
public void DelCommunications()
{
//
inProcess.Signal -= ProcSignal;
comunication_Panel.DelSignalListener();
// '
inSound = null;
outSound = null;
inProcess = null;
outProcess = null;
}
/* ,
* 1 -
* 2 -
* 3 - ,
**/
///
public Byte State
{
get { return state_; }
set
{
state_ = value;
switch (value)
{
//
case 1:
if (isBlocked == false)
{
this.display.Text = " !";
Melody._apartCall.PlayLooping();
this.silence.Visible = true;
this.actively.Visible = false;
this.silence.Enabled = true;
this.open_door.Visible = false;
this.mute.Visible = true;
this.dynamic.Enabled = false;
}
else this.display.Text = " !";
this.silence.Visible = true;
this.actively.Visible = false;
this.silence.Enabled = true;
this.open_door.Visible = false;
this.mute.Visible = true;
this.dynamic.Enabled = false;
break;
//
case 2:
this.display.Text = ".";
this.open_door.Visible = true;
this.mute.Visible = true;
this.silence.Visible = false;
this.silence.Enabled = false;
this.actively.Enabled = true;
this.actively.Visible = true;
this.open_door.Enabled = true;
this.microphone.Enabled = true;
break;
//
default:
this.display.Text = " .";
this.open_door.Visible = false;
this.mute.Visible = true;
this.silence.Visible = true;
this.silence.Enabled = false;
this.actively.Enabled = false;
this.actively.Visible = false;
this.microphone.Enabled = false;
this.dynamic.Text = "";
break;
}
}
}
//
///
private void CallProcessor(short data)
{
if (outProcess!= null)
{
outProcess.hallenges = data;
}
}
// ղ ˲ ί
/* :
* 1 -
* 2 -
**/
///
private void ProcSignal(object source, DataTransmissionLines<short> options)
{
switch (options.Data)
{
//
case 1:
State = 2;
break;
//
case 2:
State = 0;
break;
//
default:
break;
}
}
// IJ
// ³
private void silence_Click(object sender, EventArgs e)
{
CallProcessor(1);
this.microphone.Focus();
Melody._apartCall.Stop();
Melody._pick_up.Play();
parentObject.WriteLog(Number, " ");
}
//
private void actively_Click(object sender, EventArgs e)
{
CallProcessor(2);
Melody._hang_up.Play();
this.open_door.Focus();
parentObject.WriteLog(Number, " ");
}
// ³
private void open_door_Click(object sender, EventArgs e)
{
CallProcessor(3);
this.open_door.Focus();
parentObject.WriteLog(Number, "");
}
//
private void mute_Click(object sender, EventArgs e)
{
isBlocked =!isBlocked;
if (isBlocked == false && State == 1) Melody._apartCall.PlayLooping();
else if (isBlocked == true && State == 1) Melody._apartCall.Stop();
State = State;
}
private void Apartment_Doorphone_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
PostMessage(this.Handle, WM_SYSCOMMAND, DOMOVE, 0);
}
}
}
Processor.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Doorphone1._2_OOP_Severina
{
/// <summary>
///
/// </summary>
class Processor
{
/* ղ ˲
* :
* >= 0 -
* -1 -
* -2 - ,
* -3 - ,
* -4 -
* -5 - ,
*
* :
* > 0 - '
* 0 - '
*
* :
* 1 -
* 2 -
*
* :
* true -
*
* ղ ˲
* :
* >= 0 -
* < 0 -
*
* :
* 0 -
* 1 -
*
* :
* 1 -
* 2 -
* 3 -
*
* :
* '
**/
//
private enum state { inputNumber, commutation, commutated, decommutation, error }
// '
private IComucation<short> inExternal_doorphone;
private IComucation<short> outExternal_doorphone;
// '
private IComucation<short> inCommutator;
private IComucation<short> outCommutator;
// '
private IComucation<short> _apartmentInCommunications;
private IComucation<short> _apartmentOutCommunications;
// '
private IComucation<bool> _doorOutCommunications;
//
private IComucation<DateTime> _clockCommunications;
//
private IComucation<User_History> _historyCommunications;
//
private short _authCode;
// ,
private short _apartNumber;
//
private state _trueState;
//
private List<User_History> _history;
// ,
private DateTime _prevData;
//
private Clock clock;
//
private Clock doorClock;
///
/// <summary>
/// CProcessor
/// </summary>
/// <param name="authCode"> </param>
public Processor(short authCode) {
_history = new List<User_History>();
_authCode = authCode;
_apartNumber = 0;
_trueState = state.inputNumber;
clock = new Clock(ClockFunction);
clock.Speed = 1;
clock.Start();
_prevData = clock.GetTime();
doorClock = new Clock(DoorMessage);
doorClock.Speed = 1;
//
inExternal_doorphone = new TransmissionLines<short>();
outExternal_doorphone = new TransmissionLines<short>();
inCommutator = new TransmissionLines<short>();
outCommutator = new TransmissionLines<short>();
_apartmentInCommunications = new TransmissionLines<short>();
_apartmentOutCommunications = new TransmissionLines<short>();
_clockCommunications = new TransmissionLines<DateTime>();
_historyCommunications = new TransmissionLines<User_History>();
_doorOutCommunications = new TransmissionLines<bool>();
// 䳿
// '
inExternal_doorphone.Signal += new SignalTransmission<short>(PanelInSignal);
inCommutator.Signal += new SignalTransmission<short>(CommutatorInSignal);
_apartmentInCommunications.Signal += new SignalTransmission<short>(ApartmentInSignal);
}
/// <summary>
///
/// </summary>
private void ClockFunction()
{
DateTime time = clock.GetTime();
//
_clockCommunications.hallenges = time;
// ,
//
if (_prevData.Day!= time.Day)
{
foreach (User_History he in _history)
{
_historyCommunications.hallenges = he;
}
_history.Clear();
}
_prevData = time;
}
//
/// <summary>
/// ,
/// .
/// </summary>
private void DoorMessage()
{
CallPanel(-4);
doorClock.Stop();
}
/// <summary>
///
/// </summary>
/// <param name="data"> </param>
private void CallPanel(short data)
{
outExternal_doorphone.hallenges = data;
}
/// <summary>
///
/// </summary>
/// <param name="data"> </param>
private void CallCommutator(short data)
{
outCommutator.hallenges = data;
}
/// <summary>
/// , '
/// </summary>
/// <param name="data"> </param>
private void CallApartment(short data)
{
_apartmentOutCommunications.hallenges = data;
}
/// <summary>
///
/// </summary>
/// <param name="data"> </param>
private void CallDoor(bool data)
{
_doorOutCommunications.hallenges = data;
}
// ղ ˲ ί
/// <summary>
///
/// </summary>
/// <param name="source">, </param>
/// <param name="args">, </param>
private void PanelInSignal(object source, DataTransmissionLines<short> options)
{
switch (options.Data)
{
//
case 10:
//
// ,
if (_trueState == state.inputNumber && _apartNumber!= 0)
{
_trueState = state.commutation;
CallCommutator(_apartNumber);
}
break;
//
case 11:
// , '
// ,
if (_trueState == state.commutated)
{
_trueState = state.decommutation;
CallApartment(2);
CallCommutator(0);
}
// ,
else if (_trueState == state.error)
{
_trueState = state.inputNumber;
}
//
_apartNumber = 0;
CallPanel(-4);
break;
case 12:
CallDoor(true);
doorClock.Start();
CallPanel(-5);
break;
default:
//
//
//
if (options.Data >= 0 && options.Data <= 9 && _trueState == state.inputNumber)
{
_apartNumber *= 10;
_apartNumber += options.Data;
//
// : signed '
// ,
if (_apartNumber > 0) CallPanel(_apartNumber);
else
{
_trueState = state.error;
CallPanel(-1);
}
}
//
else if (_trueState!= state.commutated)
{
_trueState = state.error;
CallPanel(-1);
}
break;
}
}
/// <summary>
///
/// </summary>
/// <param name="source">, </param>
/// <param name="args">, </param>
private void CommutatorInSignal(object source, DataTransmissionLines<short> options)
{
switch (options.Data)
{
//
case 0:
//
CallPanel(-1);
_trueState = state.error;
break;
//
case 1:
// ,
//
// :
if (_trueState == state.commutation)
{
_trueState = state.commutated;
clock.Speed = 1;
CallPanel(-2);
}
// ,
//
// : 600
else if (_trueState == state.decommutation)
{
_apartNumber = 0;
_trueState = state.inputNumber;
clock.Speed = 1;
CallPanel(-4);
}
break;
//
default: break;
}
}
/// <summary>
///
/// </summary>
/// <param name="source">, </param>
/// <param name="args">, </param>
private void ApartmentInSignal(object source, DataTransmissionLines<short> options)
{
switch (options.Data)
{
//
case 1:
// , '
if (_trueState == state.commutated)
{
//
CallPanel(-3);
CallApartment(1);
}
break;
//
case 2:
// , '
if (_trueState == state.commutated)
{
//
_trueState = state.decommutation;
CallCommutator(0);
}
break;
//
case 3:
// , '
if (_trueState == state.commutated)
{
// ,
/// _history.Add(new CHistoryEntry(_apartNumber, _clock.GetTime()));
//
_trueState = state.decommutation;
CallCommutator(0);
//
CallDoor(true);
doorClock.Start();
CallPanel(-5);
}
break;
//
default:
break;
}
}
// ͲͲ Ͳ
public IComucation<short> CommutatorIn
{
get { return inCommutator; }
}
public IComucation<short> CommutatorOut
{
get { return outCommutator; }
}
public IComucation<short> ApartmentIn
{
get { return _apartmentInCommunications; }
}
public IComucation<short> ApartmentOut
{
get { return _apartmentOutCommunications; }
}
public IComucation<short> PanelIn
{
get { return inExternal_doorphone; }
}
public IComucation<short> PanelOut
{
get { return outExternal_doorphone; }
}
public IComucation<DateTime> ClockOut
{
get { return _clockCommunications; }
}
public IComucation<User_History> HistoryOut
{
get { return _historyCommunications; }
}
public IComucation<bool> DoorOut
{
get { return _doorOutCommunications; }
}
}
}
Switch.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Doorphone1._2_OOP_Severina
{
public class Switch
{
/* :
* 0 -
* 1 -
**/
// '
private IComucation<short> inProcess;
private IComucation<short> outProcess;
// '
private IComucation<short> inApartment;
private IComucation<short> outApartment;
//
private IComucation<Char> inSound;
private IComucation<Char> outSound;
// ,
private List<Apartment_Doorphone> apartments;
// ,
private bool isCommutated;
// _apartments
private short apart_index;
// CCommutator
public Switch(ref List<Apartment_Doorphone> aparts, IComucation<short> inProcCom, IComucation<short> outProcCom,
IComucation<short> inProcComForApart, IComucation<short> outProcComForApart,
IComucation<Char> inVoiceCom, IComucation<Char> outVoiceCom)
{
inProcess = inProcCom;
outProcess = outProcCom;
inSound = inVoiceCom;
outSound = outVoiceCom;
apartments = aparts;
inApartment = inProcComForApart;
outApartment = outProcComForApart;
//
inProcess.Signal += new SignalTransmission<short>(inProcess_Signal);
isCommutated = false;
apart_index = 0;
}
// '
private void BreakTrueCommunication()
{
if (isCommutated)
{
apartments[apart_index].State = 0;
apartments[apart_index].DelCommunications();
isCommutated = false;
}
CallProcessor(1);
}
/// '
private void CreateNewCommunication(short apartNumber)
{
//
int index = apartments.FindIndex(delegate(Apartment_Doorphone ap)
{
return ap.GetNumber == apartNumber;
});
// '
//
//
if (isCommutated ||
index == -1)
{
CallProcessor(0);
return;
}
//
apartments[index].SetCommunications(inSound, outSound, inApartment, outApartment);
apartments[index].State = 1;
apartments[index].Show();
isCommutated = true;
apart_index = (short)index;
CallProcessor(1);
}
//
/// <summary>
///
/// </summary>
/// <param name="data"> </param>
private void CallProcessor(short data)
{
outProcess.hallenges = data;
}
/* :
* > 0 - '
* 0 - '
**/
/// <summary>
///
/// </summary>
/// <param name="source">, </param>
/// <param name="args">, </param>
private void inProcess_Signal(object source, DataTransmissionLines<short> options)
{
switch (options.Data)
{
// '
case 0:
BreakTrueCommunication();
break;
// '
default:
CreateNewCommunication(options.Data);
break;
}
}
}
}
IComunication.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Doorphone1._2_OOP_Severina
{
//- 䳿. .
//Generic_Type -
// source - ' , .
//options - , .
public delegate void SignalTransmission<Generic_Type>(object source, DataTransmissionLines<Generic_Type> options);
//˳
//Generic_Type -
public interface IComucation<Generic_Type>
{
event SignalTransmission<Generic_Type> Signal;
Generic_Type hallenges { set; }
}
}
DataTransmissionLines.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Doorphone1._2_OOP_Severina
{
// ,
public class DataTransmissionLines<Generic_Type>
{
private Generic_Type data; //Generic_Type - ; data - ,
public DataTransmissionLines(Generic_Type _data) //
{
data = _data;
}
public Generic_Type Data // ""
{
get { return data; }
}
}
}
ComunicationPanel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Doorphone1._2_OOP_Severina
{
public class ComunicationPanel
{
//
private IComucation<Char> inSound;
private IComucation<Char> outSound;
// ,
private TextBox Microphone;
private TextBox Dynamic;
// CComunicationPanel
public ComunicationPanel(ref TextBox microphone_, ref TextBox dynamic_) {
Microphone = microphone_;
Dynamic = dynamic_;
Microphone.KeyUp +=new KeyEventHandler(microphone_KeyUp);
}
//
public void AddSignalListener(IComucation<Char> input, IComucation<Char> output)
{
//
inSound = input;
outSound = output;
//
inSound.Signal += new SignalTransmission<char>(inSignal);
}
///
public void DelSignalListener()
{
// 䳿
inSound.Signal -= inSignal;
//
inSound = null;
outSound = null;
}
//
private void microphone_KeyUp(object sender, KeyEventArgs e)
{
if (Microphone.Text.Length > 0) outSignal(Microphone.Text[0]);
Microphone.Text = "";
}
//
private void inSignal(object source, DataTransmissionLines<char> options)
{
Dynamic.Text += options.Data;
}
//
private void outSignal(Char data)
{
if (inSound!= null)
{
outSound.hallenges = data;
}
}
}
}
Door_locking_device.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Doorphone1._2_OOP_Severina
{
// , .
class Door_locking_device
{
private Timer _timer; // ,
private PictureBox door;
// CDoor
public Door_locking_device(ref PictureBox door_)
{
door = door_;
_timer = new Timer();
_timer.Interval = 3000;
_timer.Tick += new EventHandler(_timer_Tick);
}
// . .
private void _timer_Tick(object sender, EventArgs e)
{
door.Image = Properties.Resources.1;
_timer.Stop(); //
}
// .
public void OpenDoor()
{
door.Image = Properties.Resources.1;
_timer.Start(); //
}
}
}
User_History.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Doorphone1._2_OOP_Severina
{
///
public class User_History
{
private short _apartNumber; // ,
private DateTime openTime; // ,
// CHistoryEntry
public User_History(short apartNumber, DateTime _openTime)
{
_apartNumber = apartNumber;
openTime = _openTime;
}
// ,
public short ApartNumber { get { return _apartNumber; } }
// ,
public DateTime OpenTime { get { return openTime; } }
}
}
Melody.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Media;
namespace Doorphone1._2_OOP_Severina
{
public static class Melody
{
public static SoundPlayer _btnClick = new SoundPlayer(Properties.Resources.BtnBeep);
public static SoundPlayer _doorOpen = new SoundPlayer(Properties.Resources.Open);
public static SoundPlayer _apartCall = new SoundPlayer(Properties.Resources.Sound);
public static SoundPlayer _pick_up = new SoundPlayer(Properties.Resources.Activity);
public static SoundPlayer _hang_up = new SoundPlayer(Properties.Resources.Activity);
}
}
Clock.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Doorphone1._2_OOP_Severina
{
class Clock
{
// call-back
public delegate void funct();
private funct _callBack; // call-back
private Timer _timer; //
private DateTime _time; //
///
public short Speed { get; set; }
/// CClock
public Clock(funct callBack) {
_callBack = callBack;
_time = DateTime.Now;
_timer = new Timer();
_timer.Interval = 1000;
_timer.Tick += new EventHandler(_timer_Tick);
_timer.Start();
}
//
private void _timer_Tick(object sender, EventArgs e) {
_time = _time.AddSeconds(Speed);
_callBack();
}
//
public void Start() {
_timer.Start();
}
//
public void Stop() {
_timer.Stop();
}
///
public DateTime GetTime() {
return _time;
}
}
}
. , .
3- : , 䒿 , , , , .
, ʻ, ܻ. ͻ ʻ, , , .
ܻ - , , . .
ʻ, .
³ .
, .
11.
1) http://ru.wikipedia.org/wiki/
2) http://www.safe-systems.ru/sostav-domofona.html
3) , . # 3.0: .: . . .: 000 ".. ", 2010. 992 .
4) Mickey Gousset, Brian Keller, Ajoy Krishnamoorthy, Martin Woodward. Professional Application Lifecycle Management with Visual Studio 2010 Canada: Wiley Publishing, Inc., 2010. 655 .
1
ij .
2
ij .