SafeDispatch/Safedispatch_4_0/RadioForm.cs

2800 lines
124 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
//#define NOALLCALL
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 Telerik.WinControls.UI;
using System.IO;
using System.Collections;
using System.Threading;
using SafeMobileLib;
using Telerik.WinControls;
using Telerik.WinControls.Enumerations;
using Telerik.WinControls.UI.Export;
using System.Runtime.InteropServices;
namespace Safedispatch_4_0
{
public partial class radioFrom : ShapeNew
{
private List<String> ChanelList = null;
private List<String> ZoneList = null;
private Int32 ChanSelIdx = 0;
private ArrayList vehicleListNames;
private DBgatewaysManager db4gateway;
List<RadioZones> zonesList;
List<RadioChannels> channelList;
private int selectedZoneNr = 0;
private Int32 backtoPlayRow = -1;
private DateTime FirstTime, LastTime, FirstTimePriv, LastTimePriv;
private TimeSpan DifTime,DifTimePriv;
private String secName;
private String talkTime;
private volatile Boolean Startrecevied = false;
private String unable = "", otherUser = "", sendlang = "", radiobusy = "", radiooffline="";
private Boolean chanelFree = true;
public volatile Boolean threadStarted = false;
public volatile Boolean progressChecked = false;
private ConvertDT convDT = new ConvertDT();
private String msgLimit;
private String allunits;
private String remoteMonitor;
private void setLanguage()
{
secName = MainForm2.returnLNGString("sec");
talkTime = MainForm2.returnLNGString("talkTime");
btPTT.Text = MainForm2.returnLNGString("ptt");
btPPT.Text = MainForm2.returnLNGString("ptt");
cbPatch.Text = MainForm2.returnLNGString("patch");
cbFullScreen.Text = MainForm2.returnLNGString("fullscreen");
lbCallID.Text = MainForm2.returnLNGString("callerID") + ":";
lbStat.Text = MainForm2.returnLNGString("SMSStatus") + ":";
btExport.Text = MainForm2.returnLNGString("expexcel");
lbAssingKey.Text = MainForm2.returnLNGString("hotkey") + ":";
tbRadio.Text = MainForm2.returnLNGString("radio");
tbRecord.Text = MainForm2.returnLNGString("rec");
ckShowLogin.Text = MainForm2.returnLNGString("showuser");
RecordingList.Columns[0].HeaderText = "";
RecordingList.Columns[2].HeaderText = MainForm2.returnLNGString("calltype");
RecordingList.Columns[3].HeaderText = MainForm2.returnLNGString("Ilabel1");
RecordingList.Columns[4].HeaderText = MainForm2.returnLNGString("Ilabel2");
RecordingList.Columns[5].HeaderText = MainForm2.returnLNGString("start");
RecordingList.Columns[6].HeaderText = MainForm2.returnLNGString("stop");
RecordingList.Columns[9].HeaderText = MainForm2.returnLNGString("duration");
lbChan.Text = MainForm2.returnLNGString("chanel");
lbZone.Text = MainForm2.returnLNGString("zonex");
gbCallControl.Text = MainForm2.returnLNGString("calltype");
cbCallType.Text = MainForm2.returnLNGString("calltype");
rbAllCall.Text = MainForm2.returnLNGString("allcall");
rbGroupCall.Text = MainForm2.returnLNGString("groupcall");
rbPrivateCall.Text = MainForm2.returnLNGString("privateCall");
cbVoicePriority.Text = MainForm2.returnLNGString("voicePriority");
btChDown.Text = MainForm2.returnLNGString("chdown");
btChUp.Text = MainForm2.returnLNGString("chup");
btDkey.Text = MainForm2.returnLNGString("dkey");
if (MainForm2.radioType == RADIOTYPE.HYT)
btDkey.Text = MainForm2.returnLNGString("forceStopPTT");
//"Force stop PTT";
unable = MainForm2.returnLNGString("unable");
otherUser = MainForm2.returnLNGString("otherTalk");
sendlang = MainForm2.returnLNGString("send");
radiobusy = MainForm2.returnLNGString("radiobusy");
btRem.Text = MainForm2.returnLNGString("rem");
btnRefresh.Text = MainForm2.returnLNGString("refresh");
radiooffline = MainForm2.returnLNGString("radiooffline");
msgLimit = MainForm2.returnLNGString("endtimegreate");
allunits = MainForm2.returnLNGString("allunits");
remoteMonitor = MainForm2.returnLNGString("remotemonitor");
dtFrom.Culture = MainForm2.culture;
dtTo.Culture = MainForm2.culture;
dtFrom.CustomFormat = dtTo.CustomFormat = SafeMobileLib.Utils.getDayCustomFormat(MainForm2.is24hours, MainForm2.DayFirst);
//if (MainForm2.is24hours)
//{
// if (MainForm2.DayFirst)
// {
// dtFrom.CustomFormat = "dd/MM/yyyy HH:mm";
// dtTo.CustomFormat = "dd/MM/yyyy HH:mm";
// }
// else
// {
// dtFrom.CustomFormat = "MM/dd/yyyy HH:mm";
// dtTo.CustomFormat = "MM/dd/yyyy HH:mm";
// }
//}
//else
//{
// if (MainForm2.DayFirst)
// {
// dtFrom.CustomFormat = "dd/MM/yyyy hh:mm tt";
// dtTo.CustomFormat = "dd/MM/yyyy hh:mm tt";
// }
// else
// {
// dtFrom.CustomFormat = "MM/dd/yyyy hh:mm tt";
// dtTo.CustomFormat = "MM/dd/yyyy hh:mm tt";
// }
//}
}
public radioFrom(MainForm2 _mainparent, RadioControl _parent, Int32 _gwID, Int32 _radioID, Int32 _ID, String _Name)
{
InitializeComponent();
// set theme for the Message Box
RadMessageBox.SetThemeName("TelerikMetroBlue");
(newtab.ViewElement as RadPageViewStripElement).ShowItemCloseButton = false;
(newtab.ViewElement as RadPageViewStripElement).StripButtons = StripViewButtons.Scroll;
lbStatus.AutoSize = false;
lbStatus.Size = new System.Drawing.Size(215, 22);
lbChanel.AutoSize = false;
lbChanel.Size = new System.Drawing.Size(215, 22);
ckShowLogin.AutoSize = false;
ckShowLogin.Size = new System.Drawing.Size(91, 43);
dropCalltype.Enabled = false;
switch (MainForm2.radioType)
{
case RADIOTYPE.CONECTPLUS:
case RADIOTYPE.TETRA:
case RADIOTYPE.MOTO:
this.ThemeName = "Breeze";
//ThemeResolutionService.ApplyThemeToControlTree(this, "Breeze");
this.newtab.Size = new Size(newtab.Width, 200);
cbChan.ForeColor = Color.White;
cbZone.ForeColor = Color.White;
btPPT.ForeColor = Color.White;
break;
case RADIOTYPE.REPEATER_TRBO:
this.ThemeName = "Breeze";
//ThemeResolutionService.ApplyThemeToControlTree(this, "Breeze");
this.newtab.Size = new Size(newtab.Width, 200);
cbChan.ForeColor = Color.White;
cbZone.ForeColor = Color.White;
btPPT.ForeColor = Color.White;
this.newtab.Controls.Remove(this.tbRadio);
this.newtab.SelectedPage = this.tbRecord;
this.radStatusStrip1.Items.Remove(this.btSound);
this.radStatusStrip1.Items.Remove(this.ProgVolum);
this.radStatusStrip1.Items.Remove(this.Sep7);
this.radStatusStrip1.Items.Remove(this.btPPT);
this.radStatusStrip1.Items.Remove(this.Sep12);
this.radStatusStrip1.Items.Remove(this.cbPatch);
this.radStatusStrip1.Items.Remove(this.Sep13);
break;
case RADIOTYPE.HYT:
try
{
this.ThemeName = "office2010";
this.newtab.Size = new Size(newtab.Width, 200);
//this.ScreenPanel.Size = new Size(ScreenPanel.Width, 115);//89
btCollapse.Image = global::Dispatcher.Properties.Resources.plusOR;
//this.btDkey.Visible = false;
this.btDkey.Text = "Force PTT Stop";
this.btPTT.Size = new Size(btPTT.Size.Width, btPTT.Size.Height + 25);
this.btPTT.ForeColor = Color.Black;
this.tbRadio.Image = global::Dispatcher.Properties.Resources.radio16;
this.lbAssingKey.ForeColor = MainForm2.HarTextColor;
this.lbCallID.ForeColor = MainForm2.HarTextColor;
this.lbIDValue.ForeColor = MainForm2.HarTextColor;
this.lbStat.ForeColor = MainForm2.HarTextColor;
this.cbPatch.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckName.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbFullScreen.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbCallType.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckShowLogin.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbVoicePriority.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckDataFilter.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckUnitName.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.lbFrom.ForeColor = MainForm2.HarTextColor;
this.lbTo.ForeColor = MainForm2.HarTextColor;
// this.gbCallControl.GroupBoxElement.ForeColor = MainForm2.HarTextColor;
this.rbAllCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbGroupCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbPrivateCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.newtab.BackColor = MainForm2.HyteraColor;
rbAllCall.Location = new Point(rbAllCall.Location.X, rbAllCall.Location.Y - 10);
rbGroupCall.Location = new Point(rbGroupCall.Location.X, rbGroupCall.Location.Y - 10);
rbPrivateCall.Location = new Point(rbPrivateCall.Location.X, rbPrivateCall.Location.Y - 10);
cbVehName.Location = new Point(cbVehName.Location.X, cbVehName.Location.Y - 10);
tbGroupCallId.Location = new Point(tbGroupCallId.Location.X, tbGroupCallId.Location.Y - 10);
tbPrivateCallId.Location = new Point(tbPrivateCallId.Location.X, tbPrivateCallId.Location.Y - 10);
//this.newtab.SelectedPage.BackColor = Color.FromArgb(255, 182, 83);
}
catch (Exception ex)
{
SM.Debug("Error on change color hytera:" + ex.ToString());
}
break;
case RADIOTYPE.HARRIS:
try
{
this.ThemeName = "Office2010Black";
this.newtab.Size = new Size(newtab.Width, 200);
//this.ScreenPanel.Size = new Size(ScreenPanel.Width, 114);
btCollapse.Image = global::Dispatcher.Properties.Resources.plusGR;
this.btDkey.Visible = false;
this.btPTT.Size = new Size(btPTT.Size.Width, btPTT.Size.Height + 25);
this.tbRadio.Image = global::Dispatcher.Properties.Resources.radio16;
this.lbAssingKey.ForeColor = MainForm2.HarTextColor;
this.lbCallID.ForeColor = MainForm2.HarTextColor;
this.lbIDValue.ForeColor = MainForm2.HarTextColor;
this.lbStat.ForeColor = MainForm2.HarTextColor;
this.cbPatch.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckName.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckShowLogin.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbFullScreen.TextElement.ForeColor = MainForm2.HarTextColor;
this.gbCallControl.GroupBoxElement.ForeColor = MainForm2.HarTextColor;
this.cbCallType.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbAllCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbGroupCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbPrivateCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbVoicePriority.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckDataFilter.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckUnitName.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.lbFrom.ForeColor = MainForm2.HarTextColor;
this.lbTo.ForeColor = MainForm2.HarTextColor;
rbAllCall.Location = new Point(rbAllCall.Location.X, rbAllCall.Location.Y - 10);
rbGroupCall.Location = new Point(rbGroupCall.Location.X, rbGroupCall.Location.Y - 10);
rbPrivateCall.Location = new Point(rbPrivateCall.Location.X, rbPrivateCall.Location.Y - 10);
cbVehName.Location = new Point(cbVehName.Location.X, cbVehName.Location.Y - 10);
tbGroupCallId.Location = new Point(tbGroupCallId.Location.X, tbGroupCallId.Location.Y - 10);
tbPrivateCallId.Location = new Point(tbPrivateCallId.Location.X, tbPrivateCallId.Location.Y - 10);
}
catch (Exception ex)
{
SM.Debug("Error on change color hytera:" + ex.ToString());
}
break;
case RADIOTYPE.ATLAS:
try
{
this.ThemeName = "Office2010Black"; //ATLASCHANGE
this.newtab.Size = new Size(newtab.Width, 195);
// this.ScreenPanel.Size = new Size(ScreenPanel.Width, 88);
btCollapse.Image = global::Dispatcher.Properties.Resources.plusGE;
this.btDkey.Visible = false;
this.btPTT.Size = new Size(btPTT.Size.Width, btPTT.Size.Height + 25);
this.tbRadio.Image = global::Dispatcher.Properties.Resources.astroStationOK;
this.lbAssingKey.ForeColor = MainForm2.HarTextColor;
this.lbCallID.ForeColor = MainForm2.HarTextColor;
this.lbIDValue.ForeColor = MainForm2.HarTextColor;
this.lbStat.ForeColor = MainForm2.HarTextColor;
this.cbPatch.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckName.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbFullScreen.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbCallType.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckShowLogin.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.gbCallControl.GroupBoxElement.ForeColor = MainForm2.HarTextColor;
this.rbAllCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbGroupCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.rbPrivateCall.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.cbVoicePriority.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckDataFilter.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.ckUnitName.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor;
this.lbFrom.ForeColor = MainForm2.HarTextColor;
this.lbTo.ForeColor = MainForm2.HarTextColor;
}
catch (Exception ex)
{
SM.Debug("Error on change color hytera:" + ex.ToString());
}
break;
case RADIOTYPE.SIMOCO:
// we don't need probably
break;
}
this.ProgVolum.IndicatorElement1.DrawFill = true;
this.ProgVolum.IndicatorElement1.BackColor3 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.IndicatorElement1.BackColor4 = System.Drawing.Color.White;
this.ProgVolum.IndicatorElement1.BackColor = System.Drawing.Color.LightGray;
this.ProgVolum.IndicatorElement1.BackColor2 = System.Drawing.SystemColors.ControlLight;
#if NOALLCALL
rbAllCall.Visible = false;
rbGroupCall.IsChecked = true;
#endif
dtFrom.CustomFormat = dtTo.CustomFormat = SafeMobileLib.Utils.getDayCustomFormat(MainForm2.is24hours, MainForm2.DayFirst);
//if (MainForm2.is24hours)
//{
// if (MainForm2.DayFirst)
// {
// dtFrom.CustomFormat = "dd/MM/yyyy HH:mm";
// dtTo.CustomFormat = "dd/MM/yyyy HH:mm";
// }
// else
// {
// dtFrom.CustomFormat = "MM/dd/yyyy HH:mm";
// dtTo.CustomFormat = "MM/dd/yyyy HH:mm";
// }
//}
//else
//{
// if (MainForm2.DayFirst)
// {
// dtFrom.CustomFormat = "dd/MM/yyyy hh:mm tt";
// dtTo.CustomFormat = "dd/MM/yyyy hh:mm tt";
// }
// else
// {
// dtFrom.CustomFormat = "MM/dd/yyyy hh:mm tt";
// dtTo.CustomFormat = "MM/dd/yyyy hh:mm tt";
// }
//}
dtFrom.Value = DateTime.Now;
dtTo.Value = DateTime.Now;
//newtab.isse = true;
try
{
setLanguage();
typeRadio = true;
ckName.Text = _Name;
ID = _ID;
userID = 0;
radID = _radioID;
gwID = _gwID;
gwandradID = gwID.ToString() + '.' + radID.ToString();
myIP = String.Format("224.10.{0}", gwandradID);
((Telerik.WinControls.Primitives.BorderPrimitive)(this.btCollapse.GetChildAt(2))).ForeColor = System.Drawing.Color.Transparent;
((Telerik.WinControls.Primitives.BorderPrimitive)(this.ImgRad.GetChildAt(2))).ForeColor = System.Drawing.Color.Transparent;
((Telerik.WinControls.Primitives.BorderPrimitive)(this.btSound.GetChildAt(2))).ForeColor = System.Drawing.Color.Transparent;
((Telerik.WinControls.Primitives.BorderPrimitive)(this.ImgStat.GetChildAt(2))).ForeColor = System.Drawing.Color.Transparent;
vehicleListNames = new ArrayList();
foreach (String obj in MainForm2.vehicleHT.Keys)
vehicleListNames.Add(new VehandID(((Vehicle)MainForm2.vehicleHT[obj]).busName, ((Vehicle)MainForm2.vehicleHT[obj]).sc_id, ((Vehicle)MainForm2.vehicleHT[obj]).IMEI));
vehicleListNames.Sort(new VehandIDComparer());
cbVehName.DataSource = vehicleListNames;
cbVehName.DisplayMember = "Name";
if (cbVehName.Items.Count > 1)
cbVehName.SelectedIndex = 0;
cbUnitName.DataSource = vehicleListNames;
cbUnitName.DisplayMember = "Name";
if (cbUnitName.Items.Count > 1)
cbUnitName.SelectedIndex = 0;
parent = _parent;
mainparent = _mainparent;
cbChan.Enabled = false;
cbZone.Enabled = false;
btPPT.Enabled = false;
btPTT.Enabled = false;
isEnabled = false;
isON = false;
if (MainForm2.LimitedUser)
{
tbRemote.Visible = false;
btRem.Visible = false;
}
db4gateway = new DBgatewaysManager(MainForm2.ServerDBip, MainForm2.Schema, MainForm2.UserDB, MainForm2.PassDB, MainForm2.PortDB);
LoadZone();
LoadChanel();
if (channelList != null)
lbChanel.Text = ChanelList[0].ToString();
if (MainForm2.LimitedUser)
newtab.Pages.Remove(tbRecord);
}
catch (Exception ex)
{
SM.Debug("Radio constuctor phase one:" + ex.ToString());
}
try
{
ArrayList tmpSound = smdbObj.GetSoundCards(radID + 255);
if (tmpSound.Count > 0)
{
if(tmpSound.Count > 2)
txAssingKey.Text = tmpSound[2].ToString();
else
txAssingKey.Text = "";
}
else
{
txAssingKey.Text = "";
}
txAssingKey.MaxLength = 1;
}
catch (Exception ex)
{
SM.Debug("Unable to load sound settings."+ex.ToString());
}
try
{
//iniVoiceComponents(listPlayBDevices, listRecBDevices);
StartRadioBus(myIP);
ChangeState();
checkMessage.RunWorkerAsync();
List<User> tmp = new List<User>();
foreach (User obj in MainForm2.UsersList)
{
if (obj.Id == MainForm2.userIDX)
{
tmp.Add(new User(obj.UType, obj.FirstName, obj.Lastname, obj.UserName, obj.Password, obj.Id));
break;
}
}
foreach (User obj in MainForm2.UsersList)
{
if (obj.UType == USERTYPE.LiteDispatcher)
tmp.Add(new User(obj.UType, obj.FirstName, obj.Lastname, obj.UserName, obj.Password, obj.Id));
}
cbUsers.DataSource = tmp;
cbUsers.DisplayMember = "UserName";
cbUsers.SelectedIndex = 0;
}
catch (Exception ex)
{
SM.Debug("Radio constuctor phase 3:" + ex.ToString());
}
afterload = true;
}
private Boolean afterload = false;
public void RefreshChanel()
{
try
{
String Totrans = "#104#" + gwandradID + "#0.0#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 0));
Thread.Sleep(1);
}
catch (Exception ex)
{
SM.Debug("FirstChanel:" + ex.ToString());
}
}
public void FirstChanel()
{
try
{
String Totrans = "#94#" + gwandradID + "#0.0#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 3000, 0));
Thread.Sleep(1);
}
catch (Exception ex)
{
SM.Debug("FirstChanel:"+ex.ToString());
}
}
private void LoadChanel()
{
if (selectedZoneNr > 0)
{
try
{
cbChan.Items.Clear();
channelList = db4gateway.gelAllradioChannels(zonesList[selectedZoneNr - 1].Id);
ChanelList = new List<string>();
foreach (RadioChannels rc in channelList)
ChanelList.Add(rc.Name);
int cnt = -1;
foreach (String obj in ChanelList)
{
cnt++;
RadMenuItem tmp = new RadMenuItem(obj);
tmp.Name = "chmenu" + cnt.ToString();
cbChan.Items.Add(tmp);
tmp.Click += new System.EventHandler(cbChanel_Click);
}
((RadMenuItem)cbChan.Items[0]).IsChecked = true;
cbChan.Text = ((RadMenuItem)cbChan.Items[0]).Text;
}
catch (Exception ex)
{
SM.Debug("radioForm->LoadChanel" + ex.ToString());
}
}
}
private void cbChanel_Click(object sender, EventArgs e)
{
try
{
Int32 cnt = -1;
foreach (RadMenuItem obj in cbChan.Items)
{
cnt++;
if (obj.Name == ((RadMenuItem)sender).Name) { ChanSelIdx = cnt; ChangeChanel(0); break; }
}
}
catch (Exception ex)
{
SM.Debug("cbChanel_Click:" + ex.ToString());
}
}
private void ChangeChanel(Int32 NewZone)
{
try
{
String Totrans = "";
if (NewZone != 0)
{
try
{
List<RadioChannels> TmpchList = db4gateway.gelAllradioChannels(zonesList[NewZone - 1].Id);
Totrans = "#104#" + gwandradID + "#" + zonesList[NewZone - 1].Nr + "." + TmpchList[0].Nr + "#";
}
catch (Exception ex)
{
SM.Debug("Error on change chanel" + ex.ToString());
}
}
else
Totrans = "#104#" + gwandradID + "#" + zonesList[selectedZoneNr - 1].Nr + "." + channelList[ChanSelIdx].Nr + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 0));
}
catch (Exception ex)
{
SM.Debug("ChangeChanel:" + ex.ToString());
}
}
private void DisplayChChanel(Int64 responseCH)
{
try
{
Int64 ZoneNr = responseCH / 100;
Int64 ChNr = responseCH % 100;
String ZonetoStr = "zone " + ZoneNr;
Int32 cnt = 0;
foreach (RadMenuItem obj in cbZone.Items)
{
cnt++;
if (obj.Text == ZonetoStr)
{
obj.IsChecked = true;
cbZone.Text = ZonetoStr;
selectedZoneNr = cnt;
}
else obj.IsChecked = false;
}
if (selectedZoneNr > 0)
{
cbChan.Items.Clear();
channelList = db4gateway.gelAllradioChannels(zonesList[selectedZoneNr - 1].Id);
cnt = -1;
foreach (RadioChannels rc in channelList)
{
cnt++;
RadMenuItem tmp = new RadMenuItem(rc.Name);
tmp.Name = "chmenu" + cnt.ToString();
if (rc.Nr == ChNr)
{
cbChan.Text = rc.Name;
tmp.IsChecked = true;
ChanSelIdx = cnt;
}
else tmp.IsChecked = false;
cbChan.Items.Add(tmp);
tmp.Click += new System.EventHandler(cbChanel_Click);
}
lbChanel.Text = cbChan.Text;
}
lbStatus.Text = "";
}
catch (Exception ex)
{
SM.Debug("DisplayChChanel:"+ex.ToString());
}
}
private void LoadZone()
{
try
{
zonesList = db4gateway.gelAllradioZones(radID);
ZoneList = new List<string>();
/*foreach (RadioZones rz in zonesList)
ZoneList.Add("zone " + rz.Nr);*/
foreach (RadioZones rz in zonesList)
ZoneList.Add(rz.Name);
int cnt = -1;
foreach (String obj in ZoneList)
{
cnt++;
RadMenuItem tmp = new RadMenuItem(obj);
tmp.Name = "znmenu" + cnt.ToString();
cbZone.Items.Add(tmp);
tmp.Click += new System.EventHandler(cbZone_Click);
}
if (cbZone.Items.Count > 0)
{
((RadMenuItem)cbZone.Items[0]).IsChecked = true;
selectedZoneNr = 1;
cbZone.Text = ((RadMenuItem)cbZone.Items[0]).Text;
}
}
catch (Exception ex)
{
SM.Debug("LoadZone:"+ex.ToString());
}
}
private void cbZone_Click(object sender, EventArgs e)
{
try
{
int cnt = 0;
foreach (RadMenuItem obj in cbZone.Items)
{
cnt++;
if (obj.Name == ((RadMenuItem)sender).Name) { ChangeChanel(cnt); break; }
}
SM.Debug("Sending zone change nr=" + selectedZoneNr);
}
catch (Exception ex)
{
SM.Debug("cbZone_Click:" + ex.ToString());
}
}
private void radCheckBoxElement1_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
try
{
if (!ForceUnCheck)
{
Selected = ckName.IsChecked;
foreach (ShapeNew obj in parent.RadioForms)
if (obj.ID != ID)
if (obj.Selected)
{
obj.ForceUnCheck = true;
obj.Selected = false;
if (obj.typeRadio) ((radioFrom)obj).ckName.IsChecked = false;
else ((dispFrom)obj).ckName.IsChecked = false;
}
}
else ForceUnCheck = false;
}
catch (Exception ex)
{
SM.Debug("radCheckBoxElement1:"+ex.ToString());
}
}
private void btCollapse_Click(object sender, EventArgs e)
{
ChangeState();
}
public Boolean ChangeState()
{
try
{
if (Collapse)
{
//Console.WriteLine(parent.SizeofScreen-parent.RadioForms.Count*27-20);
//Int32 FullHeight = parent.SizeofScreen - parent.RadioForms.Count * 27 - 20;
//Int32 FullHeight = parent.radScrollablePanel1.Size.Height - parent.RadioForms.Count * 24;
Int32 FullHeight = 255;
if (cbFullScreen.Checked)
FullHeight = parent.radScrollablePanel1.Size.Height - parent.RadioForms.Count * 24;
this.Size = new Size(this.Size.Width, FullHeight);
this.newtab.Size = new Size(this.newtab.Width, FullHeight-30);
switch (MainForm2.radioType)
{
case RADIOTYPE.CONECTPLUS:
case RADIOTYPE.TETRA:
case RADIOTYPE.REPEATER_TRBO:
case RADIOTYPE.MOTO:
//this.Size = new Size(this.Size.Width, 225);
btCollapse.Image = global::Dispatcher.Properties.Resources.minus;
break;
case RADIOTYPE.HYT:
//this.Size = new Size(this.Size.Width, 225);
btCollapse.Image = global::Dispatcher.Properties.Resources.minusOR;
break;
case RADIOTYPE.HARRIS:
//this.Size = new Size(this.Size.Width, 225);
btCollapse.Image = global::Dispatcher.Properties.Resources.minusGR;
break;
case RADIOTYPE.ATLAS: //ATLASCHANGE
//this.Size = new Size(this.Size.Width, 225);
btCollapse.Image = global::Dispatcher.Properties.Resources.minusGE;
break;
case RADIOTYPE.SIMOCO:
btCollapse.Image = global::Dispatcher.Properties.Resources.minus;
break;
}
}
else
{
this.Size = new Size(this.Size.Width, 27);
switch (MainForm2.radioType)
{
case RADIOTYPE.CONECTPLUS:
case RADIOTYPE.TETRA:
case RADIOTYPE.REPEATER_TRBO:
case RADIOTYPE.MOTO:
btCollapse.Image = global::Dispatcher.Properties.Resources.plus;
break;
case RADIOTYPE.HYT:
btCollapse.Image = global::Dispatcher.Properties.Resources.plusOR;
break;
case RADIOTYPE.HARRIS:
btCollapse.Image = global::Dispatcher.Properties.Resources.plusGR;
break;
case RADIOTYPE.ATLAS:
btCollapse.Image = global::Dispatcher.Properties.Resources.plusGE; //ATLASCHANGE
break;
case RADIOTYPE.SIMOCO:
btCollapse.Image = global::Dispatcher.Properties.Resources.plus;
break;
}
}
Collapse = !Collapse;
}
catch (Exception ex)
{
SM.Debug("ChangeState:"+ex.ToString());
}
return Collapse;
}
private void btSound_Click(object sender, EventArgs e)
{
try
{
if (VoiceON)
{
btSound.Image = global::Dispatcher.Properties.Resources.speakerofftest;
VoiceON = false;
MainForm2.ProrityIP = "";
}
else
{
btSound.Image = global::Dispatcher.Properties.Resources.speakeron;
VoiceON = true;
}
}
catch (Exception ex)
{
SM.Debug("btSound_Click:"+ex.ToString());
}
}
public ArrayList recordArrayList = new ArrayList();
volatile List<DataforRecording> ListforGrid = new List<DataforRecording>();
public void populateRecList(ArrayList recArray)
{
try
{
Console.WriteLine("Populate RecList");
Boolean havedate = false;
RecordingList.Columns[3].SortOrder = RadSortOrder.None;
foreach (Recording rs in recArray)
{
Console.WriteLine("Comapare rs.gwID=" + rs.gwID + " gwID" + gwID + " rez:" + (rs.gwID == gwID) + " rs.radioGWID=" + rs.radioGWID + " radID=" + radID + " rez:" + (rs.radioGWID == radID) + " SDtype=" + rs.typeSD);
if ((rs.gwID == gwID) && (rs.radioGWID == radID) && (rs.typeSD == 0)) { havedate = true; break; }
if (ckShowLogin.Checked)
{
if ((rs.gwID == gwID) && (rs.radioGWID == radID) && (rs.typeSD == 1) && (rs.subID == ((User)((RadListDataItem)cbUsers.SelectedItem).Value).Id)) { havedate = true; break; }
}
}
int n = -1;
if (havedate)
{
Console.WriteLine("Face populare");
try
{
if (RecordingList.InvokeRequired)
{
RecordingList.Invoke(new MethodInvoker(() =>
{
RecordingList.Rows.Clear();
}));
}
else
{
RecordingList.Rows.Clear();
}
}
catch (Exception ex)
{
SM.Debug("Error on populate grid" + ex.ToString());
}
recordArrayList.Clear();
foreach (Recording rs in recArray)
{
if (((rs.gwID == gwID) && (rs.radioGWID == radID)) && ((rs.typeSD == 0) || ((rs.typeSD == 1) && (rs.subID == ((User)((RadListDataItem)cbUsers.SelectedItem).Value).Id))))
{
//recordArrayList.Add(rs);
//public Recording(Int64 _id, long _startTime, long _endTime, DateTime _startDateTime, DateTime _endDateTime, string _hddLocation, int _subID, Int32 _gwID, Int32 _radioGWID, int _typeSD, int _calltype, Int32 _Group_ID)
recordArrayList.Add(new Recording(rs.id,rs.startTime,rs.endTime,rs.startDateTime,rs.endDateTime,rs.hddLocation,rs.subID,rs.gwID,rs.radioGWID,rs.typeSD,rs.calltype,rs.Group_ID));
Image tmpIMG = null;
switch (rs.calltype)
{
case 0:
tmpIMG = global::Dispatcher.Properties.Resources.call_made_24x20;
break;
case 1:
tmpIMG = global::Dispatcher.Properties.Resources.call_made_group_24x20;
break;
case 2:
tmpIMG = global::Dispatcher.Properties.Resources.call_made_all_24x20;
break;
case 4:
tmpIMG = global::Dispatcher.Properties.Resources.call_received_24X20;
break;
case 5:
tmpIMG = global::Dispatcher.Properties.Resources.call_received_group_24x20;
break;
case 6:
tmpIMG = global::Dispatcher.Properties.Resources.call_received_all_24x20;
break;
case 7:
tmpIMG = global::Dispatcher.Properties.Resources.remmonitor24x20;
break;
}
String ValCell3 = "", ValCell4 = "";
if (rs.typeSD == 0)
{
try
{
if (rs.calltype > 3)
{
try
{
if (MainForm2.VehIMEIHash[rs.subID.ToString()]!=null) ValCell3 = (String)MainForm2.VehIMEIHash[rs.subID.ToString()];
else ValCell3 = "Radio_ID " + rs.subID;
}
catch
{
ValCell3 = "Radio_ID " + rs.subID;
}
if (rs.calltype == 4)
{
ValCell4 = ((User)((RadListDataItem)cbUsers.SelectedItem).Value).UserName;
if (rs.Group_ID != 0)
{
try
{
if (MainForm2.VehIMEIHash[rs.Group_ID.ToString()] != null) ValCell4 = (String)MainForm2.VehIMEIHash[rs.Group_ID.ToString()];
else ValCell4 = "Radio_ID " + rs.Group_ID;
}
catch
{
ValCell4 = "Radio_ID " + rs.Group_ID;
}
}
Console.WriteLine();
}
else if (rs.calltype == 5)
{
try
{
ValCell4 = ((GroupClass)MainForm2.GroupHash[rs.Group_ID]).name;
}
catch
{
ValCell4 = "Group_ID " + rs.Group_ID;
}
}
else if (rs.calltype == 6) ValCell4 = allunits;
else
{
ValCell4 = ValCell3;
ValCell3 = remoteMonitor;
}
}
}
catch (Exception ex)
{
ValCell4 = rs.subID.ToString();
}
}
else
{
try
{
if (rs.calltype < 3)
{
ValCell3 = (String)MainForm2.userIDHash[rs.subID];
if (rs.calltype == 0)
{
try
{
ValCell4 = (String)MainForm2.VehIMEIHash[rs.radioGWID.ToString()];
}
catch
{
ValCell4 = "Radio_ID " + rs.radioGWID;
}
}
else if (rs.calltype == 1)
{
try
{
ValCell4 = ((GroupClass)MainForm2.GroupHash[rs.Group_ID]).name;
}
catch
{
ValCell4 = "Group_ID " + rs.Group_ID;
}
}
else ValCell4 = allunits;
}
}
catch (Exception ex)
{
ValCell4 = rs.subID.ToString();
}
}
TimeSpan duration = rs.endDateTime - rs.startDateTime;
//ListforGrid.Add(new DataforRecording(global::Dispatcher.Properties.Resources.play, rs.id.ToString(), tmpIMG, ValCell3, ValCell4, rs.startDateTime.ToString(), rs.endDateTime.ToString(), rs.startDateTime.ToUniversalTime().Ticks.ToString(), rs.endDateTime.ToUniversalTime().Ticks.ToString(), (Int32)duration.TotalSeconds, rs.calltype));
ListforGrid.Add(new DataforRecording(global::Dispatcher.Properties.Resources.play, rs.id.ToString(), tmpIMG, ValCell3, ValCell4, rs.startDateTime.ToString(), rs.endDateTime.ToString(), rs.startTime.ToString(), rs.endTime.ToString(), (Int32)duration.TotalSeconds, rs.calltype));
}
}
try
{
if (RecordingList.InvokeRequired)
{
RecordingList.Invoke(new MethodInvoker(() => {
RecordingList.DataSource = null;
RecordingList.DataSource = ListforGrid;
RecordingList.Refresh();
RecordingList.TableElement.ScrollToRow(0);
}));
}
else
{
RecordingList.DataSource = null;
RecordingList.DataSource = ListforGrid;
RecordingList.Refresh();
RecordingList.TableElement.ScrollToRow(0);
}
}
catch (Exception ex)
{
SM.Debug("Error on populate grid" + ex.ToString());
}
}
}
catch (Exception ex)
{
SM.Debug("populateRecList:"+ex.ToString());
}
}
private void RecordingList_CellClick(object sender, GridViewCellEventArgs e)
{
try
{
if ((e.ColumnIndex == 0) && (e.RowIndex >= 0) && (!MainForm2.PlayingFile))
{
backtoPlayRow = e.RowIndex;
SM.Debug("Duration:"+(Int32)((Convert.ToInt64(RecordingList.SelectedRows[0].Cells[9].Value))));
parent.PlayFile(Convert.ToInt64(RecordingList.SelectedRows[0].Cells[1].Value),(Int32)((Convert.ToInt64(RecordingList.SelectedRows[0].Cells[9].Value)))); //(Int32)((Convert.ToInt64(RecordingList.SelectedRows[0].Cells[8].Value) - Convert.ToInt64(RecordingList.SelectedRows[0].Cells[7].Value))/1000));
//System.Threading.Timer t1 = new System.Threading.Timer(SendStop, seqID, timeout, System.Threading.Timeout.Infinite);
RecordingList.Rows[e.RowIndex].Cells[0].Value = global::Dispatcher.Properties.Resources.stop;
RecordingList.Refresh();
}
}
catch (Exception ex)
{
SM.Debug("Error on click" + ex.ToString());
if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor;
RadMessageBox.Show(MainForm2.returnLNGString("unplayFile"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
public void BackToPlay()
{
try
{
if (backtoPlayRow != -1)
{
RecordingList.Rows[backtoPlayRow].Cells[0].Value = global::Dispatcher.Properties.Resources.play;
RecordingList.Refresh();
}
backtoPlayRow = -1;
ProgVolum.Value1 = ProgVolum.Maximum - 0 + ProgVolum.Minimum;
}
catch (Exception ex)
{
SM.Debug("Unable to get back volume" + ex.ToString());
}
}
public void BackVolum(Int32 volum)
{
try
{
if ((volum > 50) && (volum < 10000)) ProgVolum.Value1 = ProgVolum.Maximum - (Int32)((volum - 50) / 100) + ProgVolum.Minimum;
else if (volum <= 50) ProgVolum.Value1 = ProgVolum.Maximum - 0 + ProgVolum.Minimum;
Console.WriteLine("Volume="+volum);
foreach (String objkey in MainForm2.PopupOpen.Keys)
{
if (((Popupwindow)MainForm2.PopupOpen[objkey]).gwandradID == gwandradID)
((Popupwindow)MainForm2.PopupOpen[objkey]).BackVolum(volum);
}
}
catch (Exception ex)
{
SM.Debug("Erorr on backvolum" + ex.ToString());
}
}
private void btChDown_Click(object sender, EventArgs e)
{
try
{
if (isON)
{
ChanSelIdx++;
if (ChanSelIdx >= ChanelList.Count) ChanSelIdx = 0;
ChangeChanel(0);
}
}
catch (Exception ex)
{
SM.Debug("btchDown_click:" + ex.ToString());
}
}
private void btChUp_Click(object sender, EventArgs e)
{
try
{
if (isON)
{
ChanSelIdx--;
if (ChanSelIdx < 0) ChanSelIdx = ChanelList.Count - 1;
ChangeChanel(0);
}
}
catch (Exception ex)
{
SM.Debug("btChUp_click:" + ex.ToString());
}
}
private volatile Boolean PTTinprogres = false;
public volatile Int32 Callmade = 101;
private volatile Boolean MAKESTOPBOOL = true;
private volatile Boolean MAKESTOPBOOLPTTALL = true;
private void SendGroupCall()
{
Int64 id = 1;
try
{
id = Convert.ToInt64(tbGroupCallId.Text);
}
catch
{
id = 0;
}
if ((id >= 1) && (id <= 16776415))
{
INPTT = true;
LimitPTT.Enabled = true;
LimitPTT.Start();
PTTclicked = true;
parent.GeneralPTTclick = true;
//END
Callmade = 103;
String Totrans = "#103#" + gwandradID + "." + id.ToString() + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 103));
DisableCMDPTT();
MAKESTOPBOOL = false;
}//lbStatus.Text = rbGroupCall.Text + " " + id.ToString();
else lbStatus.Text = MainForm2.returnLNGString("errorIDLim");
}
private void SendPrivateCall()
{
Int64 id = 1;
try
{
id = Convert.ToInt64(tbPrivateCallId.Text);
}
catch
{
id = 0;
}
if ((id >= 1) && (id <= 16776415))
{
if (MainForm2.VehIMEIHash[id.ToString()] != null)
{
INPTT = true;
LimitPTT.Enabled = true;
LimitPTT.Start();
PTTclicked = true;
parent.GeneralPTTclick = true;
//END
Callmade = 102;
Send_Private_PTT(id.ToString());
MAKESTOPBOOL = false;
}
else lbStatus.Text = id.ToString() + " " + MainForm2.returnLNGString("IsNotYourUnit");
}
else lbStatus.Text = MainForm2.returnLNGString("errorIDLim");
}
private void btPTT_MouseDown(object sender, MouseEventArgs e)
{
try
{
Int64 id = 1;
String Totrans = "";
SM.Debug("VALUE statuson PTTclick: isON:" + isON + " PTTinprogres " + PTTinprogres + " PTTclicked: " + PTTclicked + " INPTT: " + INPTT);
if ((isON) && (!PTTinprogres) && (!PTTclicked) && (!INPTT))
{
#if NOALLCALL
#else
if (rbAllCall.IsChecked)
{
//common section safe BEGIN
if (sender == btPPT) btPTT.Enabled = false;
else btPPT.Enabled = false;
INPTT = true;
LimitPTT.Enabled = true;
LimitPTT.Start();
PTTclicked = true;
parent.GeneralPTTclick = true;
//END
Callmade = 101;
Send_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
MAKESTOPBOOL = false;
}
else
#endif
if (rbGroupCall.IsChecked)
{
if (sender == btPPT) btPTT.Enabled = false;
else btPPT.Enabled = false;
SendGroupCall();
/* try
{
id = Convert.ToInt64(tbGroupCallId.Text);
}
catch
{
id = 0;
}
if ((id >= 1) && (id <= 16776415))
{
//common section safe BEGIN
if (sender == btPPT) btPTT.Enabled = false;
else btPPT.Enabled = false;
INPTT = true;
LimitPTT.Enabled = true;
LimitPTT.Start();
PTTclicked = true;
parent.GeneralPTTclick = true;
//END
Callmade = 103;
Totrans = "#103#" + gwandradID + "." + id.ToString() + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 103));
DisableCMDPTT();
MAKESTOPBOOL = false;
}//lbStatus.Text = rbGroupCall.Text + " " + id.ToString();
else lbStatus.Text = MainForm2.returnLNGString("errorIDLim");*/
}
//1 - 16776415
else if (rbPrivateCall.IsChecked)
{
if (sender == btPPT) btPTT.Enabled = false;
else btPPT.Enabled = false;
SendPrivateCall();
/* try
{
id = Convert.ToInt64(tbPrivateCallId.Text);
}
catch
{
id = 0;
}
if ((id >= 1) && (id <= 16776415))
{
if (MainForm2.VehIMEIHash[id.ToString()] != null)
{
//common section safe BEGIN
if (sender == btPPT) btPTT.Enabled = false;
else btPPT.Enabled = false;
INPTT = true;
LimitPTT.Enabled = true;
LimitPTT.Start();
PTTclicked = true;
parent.GeneralPTTclick = true;
//END
Callmade = 102;
Send_Private_PTT(id.ToString());
MAKESTOPBOOL = false;
}
else lbStatus.Text = id.ToString() + " " + MainForm2.returnLNGString("IsNotYourUnit");
}
else lbStatus.Text = MainForm2.returnLNGString("errorIDLim");*/
}
}
}
catch (Exception ex)
{
SM.Debug("Ex btPTT_MouseDown:"+ex.ToString());
}
}
public void DisableCMDPTT()
{
try
{
ResponsePTT = false;
OUTBEFORE = false;
ImgStat.Image = global::Dispatcher.Properties.Resources.yellow_status;
DisableChALL();
btRem.Enabled = false;
}
catch (Exception ex)
{
SM.Debug("DisableCMDPTT:" + ex.ToString());
}
}
public void EnableCMDPTT()
{
try
{
EnableChALL();
ImgStat.Image = global::Dispatcher.Properties.Resources.green_status;
btPPT.Enabled = true;
btPTT.Enabled = true;
ProgVolum.Value1 = ProgVolum.Maximum - 0 + ProgVolum.Minimum;
btRem.Enabled = true;
}
catch (Exception ex)
{
SM.Debug("EnableCMDPTT:" + ex.ToString());
}
}
public volatile Boolean OUTBEFORE=false;
private void btPTT_MouseUp(object sender, MouseEventArgs e)
{
try
{
SM.Debug("Response on MouseUP:"+ResponsePTT);
if (ResponsePTT) callStopProcedure(false);
else OUTBEFORE = true;
if (PTTinprogres)
{
btPPT.Enabled = false;
btPTT.Enabled = false;
}//new code for hytera i think is also true for motorola
else
{
}
Thread.Sleep(1000);
}
catch (Exception ex)
{
SM.Debug("btPTT_MouseUp:"+ex.ToString());
}
}
private void callStopProcedure(Boolean forcePTTClicked)
{
try
{
SM.Debug("callStopProcedure with value CallMade:"+Callmade);
if (forcePTTClicked) PTTclicked = true;
String Totrans = "";
if (Callmade == 101) Stop_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
else if (Callmade == 103)
{
if (PTTclicked)
{
Totrans = "#113#" + gwandradID + "." + tbGroupCallId.Text + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 113));
PTTclicked = false;
parent.GeneralPTTclick = false;
}
}
else if (Callmade == 102) Stop_Private_PTT(tbPrivateCallId.Text);
}
catch (Exception ex)
{
SM.Debug("callStopProcedure:" + ex.ToString());
}
}
private void checkMessage_DoWork(object sender, DoWorkEventArgs e)
{
try
{
BackgroundWorker worker = sender as BackgroundWorker;
e.Result = Computation(worker, e);
}
catch (Exception ex)
{
SM.Debug("Erorr start checkMessage:" + ex.ToString());
}
}
private void TurnON()
{
try
{
ImgRad.Image = global::Dispatcher.Properties.Resources.radioGREEN;
cbChan.Enabled = true;
cbZone.Enabled = true;
isEnabled = true;
PTT_enable();
btRem.Enabled = true;
btChDown.Enabled = true;
btChUp.Enabled = true;
//ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screen_light2_on;
ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screenON;
}
catch (Exception ex)
{
SM.Debug(" TurnON:" + ex.ToString());
}
}
private void TurnOFF()
{
try
{
ImgRad.Image = global::Dispatcher.Properties.Resources.radioblack1;
cbChan.Enabled = false;
cbZone.Enabled = false;
isEnabled = false;
PTT_disable();
if (MainForm2.radioType != RADIOTYPE.HYT)
btDkey.Enabled = false;
btRem.Enabled = false;
btChDown.Enabled = false;
btChUp.Enabled = false;
//ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screen_light2;
ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screenOFF;
ImgStat.Image = global::Dispatcher.Properties.Resources.red_status;
}
catch (Exception ex)
{
SM.Debug(" TurnOFF:" + ex.ToString());
}
}
private void EnableALL()
{
try
{
cbChan.Enabled = true;
cbZone.Enabled = true;
isEnabled = true;
PTT_enable();
btRem.Enabled = true;
btChDown.Enabled = true;
btChUp.Enabled = true;
}
catch (Exception ex)
{
SM.Debug(" EnableALL:" + ex.ToString());
}
}
private void DisableALL()
{
try
{
cbChan.Enabled = false;
cbZone.Enabled = false;
isEnabled = false;
PTT_disable();
if (MainForm2.radioType != RADIOTYPE.HYT)
btDkey.Enabled = false;
btRem.Enabled = false;
btChDown.Enabled = false;
btChUp.Enabled = false;
lbStatus.Text = otherUser;
}
catch (Exception ex)
{
SM.Debug("Disable all:"+ex.ToString());
}
}
public volatile Boolean ResponsePTT = false;
public volatile Alarms voltmpx = null;
public volatile transfer125 tmptransVOL = null;
public volatile Int32 dataIntVOL = 0;
public volatile Int32 typeVOL = 0;
public volatile Int32 IdVOL = 0;
public volatile Int32 callStatusVOL = 0;
public volatile Int32 callTypeVOL = 0;
public volatile Int32 grpIDVOL = 0;
public volatile System.Threading.Timer tclose125 = null;
private void checkMessage_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
try
{
dataIntVOL = e.ProgressPercentage;
typeVOL = dataIntVOL % 1000;
IdVOL = dataIntVOL / 1000;
switch (typeVOL)
{
case 100:
if (IdVOL == 1)
{
TurnON();
isON = true; //intreb gaby cum da canalele
}
else
{
TurnOFF();
isON = false;
lbStatus.Text = radiooffline;
lbStatus.Update();
}
break;
case 999: //exitra timpu si opresc statia
rbAllCall.Enabled = true;
rbGroupCall.Enabled = true;
rbPrivateCall.Enabled = true;
#if NOALLCALL
rbGroupCall.IsChecked = true;
#else
rbAllCall.IsChecked = true;
#endif
TurnOFF();
PTTclicked = false;
lbStatus.Text = radiooffline;
lbStatus.Update();
break;
case 998:
lbStatus.Text = btRem.Text + " " + MainForm2.returnLNGString("error");
btRem.Enabled = true;
EnableChALL();
PTT_enable();
PTTclicked = false;
parent.GeneralPTTclick = false;
break;
case 207:
if (IdVOL == 1)
{
chanelFree = false;
DisableALL();
}
else
{
chanelFree = true;
EnableALL();
}
break;
case 124:
SM.Debug("proccess 124 for IP:" + myIP);
TurnON();
ImgStat.Image = global::Dispatcher.Properties.Resources.green_status;
isON = true;
FirstChanle00 = false;
DisplayChChanel(IdVOL);
PTTinprogres = false;
break;
case 115:
PTTinprogres = false;
PTTclicked = false;
parent.GeneralPTTclick = false;
lbStatus.Text = "";
//KEY UP
ReadyfornewKEY = true;
//nu situ dece e if isON
if (isON) PTT_enable();
EnableCMDPTT();
//confirmare mesajului de OFF
break;
case 116:
PTTinprogres = false;
PTTclicked = false;
parent.GeneralPTTclick = false;
lbStatus.Text = "";
LastTimePriv = DateTime.Now;
DifTimePriv = LastTimePriv - FirstTimePriv;
EnableCMDPTT();
ReadyfornewKEY = true;
Alarms tmp = null;
try
{
if (MainForm2.VehIMEIHash[tbPrivateCallId.Text] != null)
{
foreach (Alarms obj in ((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[tbPrivateCallId.Text]]).EventLists)
if (obj.type == rep_type.CALLSEND) tmp = obj;
}
if (tmp != null) tmp.descript = talkTime + ": " + (DifTimePriv.Minutes * 60 + DifTimePriv.Seconds).ToString() + " " + secName;
if (MainForm2.PopupOpen[tbPrivateCallId.Text] != null)
{
((Popupwindow)MainForm2.PopupOpen[tbPrivateCallId.Text]).populate();
((Popupwindow)MainForm2.PopupOpen[tbPrivateCallId.Text]).putPTTON();
}
}
catch (Exception ex)
{
SM.Debug("Error on STOP private call" + ex.ToString());
}
break;
case 117:
PTTinprogres = false;
PTTclicked = false;
parent.GeneralPTTclick = false;
lbStatus.Text = "";
EnableCMDPTT();
ReadyfornewKEY = true;
break;
case 121:
if (IdVOL == 1)
{
PTTinprogres = true;
lbStatus.Text = rbAllCall.Text;
lbStatus.Update();
rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;
}
else
{
lbStatus.Text = unable + " " + rbAllCall.Text;
PTTclicked = false;
parent.GeneralPTTclick = false;
}
ResponsePTT = true;
break;
case 10:
String reason = "unknown";
switch ((RADIO_STATUS)IdVOL)
{
case RADIO_STATUS.ALLcall_INIT:
reason = "All call";
break;
case RADIO_STATUS.ALLcall_INPROGRES:
reason = "All call";
break;
case RADIO_STATUS.CallEvent:
reason = "CallEvent";
break;
case RADIO_STATUS.ChannelQuery:
reason = "ChQuery";
break;
case RADIO_STATUS.DKEY:
reason = "Dkey";
break;
case RADIO_STATUS.EnableDisable:
reason = "En./Dis.";
break;
case RADIO_STATUS.FREE:
reason = "Free";
break;
case RADIO_STATUS.GroupCall_INIT:
reason = "GroupCall";
break;
case RADIO_STATUS.GroupCall_INPROGRES:
reason = "GroupCall";
break;
case RADIO_STATUS.HangTime:
reason = "HangTime";
break;
case RADIO_STATUS.OFF:
reason = "OFF";
break;
case RADIO_STATUS.PrivateCall_INIT:
reason = "Priv. Call";
break;
case RADIO_STATUS.PrivateCall_INPROGRES:
reason = "Priv. Call";
break;
case RADIO_STATUS.RemoteMonitor:
reason = "RM";
break;
case RADIO_STATUS.RemoteMonitor_INPROGRES:
reason = "RM";
break;
}
lbStatus.Text = radiobusy + reason;
lbStatus.Update();
break;
case 122:
if (IdVOL == 1)
{
PTTinprogres = true;
lbStatus.Text = rbPrivateCall.Text + " " + tbPrivateCallId.Text;
rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;
try
{
((Vehicle)MainForm2.vehicleHT[MainForm2.VehIMEIHash[tbPrivateCallId.Text]]).EventLists.Add(new Alarms(rep_type.CALLSEND, DateTime.Now, "", ""));
FirstTimePriv = DateTime.Now;
}
catch (Exception ex)
{
SM.Debug("Erorr adding 122:" + ex.ToString());
}
}
else
{
lbStatus.Text = unable + " " + rbPrivateCall.Text + " " + tbPrivateCallId.Text;
PTTclicked = false;
parent.GeneralPTTclick = false;
}
ResponsePTT = true;
break;
case 162:
if (IdVOL == 1)
{
lbStatus.Text = btRem.Text + " " + tbRemote.Text;
if (isON)
{
PTT_disable();
if (MainForm2.radioType != RADIOTYPE.HYT)
btDkey.Enabled = false;
RecivedData = true;
if (!ShapeNew.receiving_hash.Contains(currentID))
{
ShapeNew.receiving_hash.Add(currentID);
}
}
}
else if (IdVOL == 2)
{
lbStatus.Text = unable + " " + btRem.Text;
btRem.Enabled = true;
}
break;
case 172:
PTT_enable();
RecivedData = false;
MainForm2.ProrityIP = "";
parent.SendProrityOFF(PersonalIP);
if (ShapeNew.receiving_hash.Contains(currentID))
{
ShapeNew.receiving_hash.Remove(currentID);
}
PTTclicked = false;
parent.GeneralPTTclick = false;
btRem.Enabled = true;
EnableChALL();
break;
case 123:
if (IdVOL == 1)
{
PTTinprogres = true;
lbStatus.Text = rbGroupCall.Text + " " + tbGroupCallId.Text;
rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;
}
else
{
lbStatus.Text = unable + " " + rbGroupCall.Text + " " + tbGroupCallId.Text;
PTTclicked = false;
parent.GeneralPTTclick = false;
}
ResponsePTT = true;
break;
case 125:
callStatusVOL = (e.UserState as transfer125).callStatus;
callTypeVOL = (e.UserState as transfer125).callType;
grpIDVOL = (e.UserState as transfer125).grpID;
Int64 IdVOLx = (e.UserState as transfer125).intvalID;
if (callStatusVOL == 1)
{
//commet timer to close conversation if conection is over 70 sec
//tclose125 = new System.Threading.Timer(SendStopfor125, IdVOLx, 70000, System.Threading.Timeout.Infinite);
try
{
if (!Startrecevied)
{
try
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("CallStat:" + callStatusVOL + " calltype:" + callTypeVOL+" grpID:"+grpIDVOL);
Console.ResetColor();
string id = "";
if (MainForm2.VehIMEIHash[IdVOLx.ToString()] != null)
{
id = (string)MainForm2.VehIMEIHash[IdVOLx.ToString()];
if ((id != null) && (id != ""))
{
if (id.Length > 17)
{
id = id.Remove(17);
id += "...";
}
}
else id = IdVOLx.ToString();
}
else id = IdVOLx.ToString();
lbIDValue.Text = id;
lbStatus.Text = id;
if (callTypeVOL == 101) lbChanel.Text = rbAllCall.Text;
else if (callTypeVOL == 103) lbChanel.Text = rbGroupCall.Text + " (" + grpIDVOL + ")";
else if (callTypeVOL == 102) lbChanel.Text = rbPrivateCall.Text;
if (callTypeVOL == 101) rbAllCall.IsChecked = true;
else if (callTypeVOL == 103) { rbGroupCall.IsChecked = true; tbGroupCallId.Text = grpIDVOL.ToString(); }
else if (callTypeVOL == 102) { rbPrivateCall.IsChecked = true; tbPrivateCallId.Text = IdVOLx.ToString(); }
else rbAllCall.IsChecked = true; // add new for bug858
rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;
voltmpx = null;
if ((MainForm2.VehIMEIHash[IdVOLx.ToString()] != null) && (((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]) != null))
{
foreach (Alarms obj in ((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]).EventLists)
if (obj.type == rep_type.CALLRECIVE) voltmpx = obj;
if ((voltmpx != null) && (voltmpx.descript == ""))
((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]).EventLists.Remove(voltmpx);
((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]).EventLists.Add(new Alarms(rep_type.CALLRECIVE, DateTime.Now, "", ""));
//for the live maps
}
}
catch (Exception ex)
{
SM.Debug("Erorr adding 125:" + ex.ToString());
}
PTT_disable();
btChDown.Enabled = false;
btChUp.Enabled = false;
cbChan.Enabled = false;
cbZone.Enabled = false;
isEnabled = false;
btRem.Enabled = false;
RecivedData = true;
if (!ShapeNew.receiving_hash.Contains(currentID))
ShapeNew.receiving_hash.Add(currentID);
CheckPatchON(true);
FirstTime = DateTime.Now;
}
}
catch (Exception ex)
{
SM.Debug("Error on 125 with status 1 (begin call):" + ex.ToString());
}
Startrecevied = true;
}
else
{
try
{
if (Startrecevied)
{
lbChanel.Text = cbChan.Text;
lbIDValue.Text = "";
lbStatus.Text = "";
PTT_enable();
btChDown.Enabled = true;
btChUp.Enabled = true;
cbChan.Enabled = true;
cbZone.Enabled = true;
isEnabled = true;
btRem.Enabled = true;
//ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screen_light2_on;
ScreenPanel.BackgroundImage = global::Dispatcher.Properties.Resources.screenON;
RecivedData = false;
MainForm2.ProrityIP = "";
parent.SendProrityOFF(PersonalIP);
if (ShapeNew.receiving_hash.Contains(currentID))
{
ShapeNew.receiving_hash.Remove(currentID);
}
CheckPatchOFF(true);
LastTime = DateTime.Now;
DifTime = LastTime - FirstTime;
try
{
voltmpx = null;
if ((MainForm2.VehIMEIHash[IdVOLx.ToString()] != null) && ((MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]) != null))
foreach (Alarms obj in ((Vehicle)MainForm2.vehicleHT[(String)MainForm2.VehIMEIHash[IdVOLx.ToString()]]).EventLists)
if (obj.type == rep_type.CALLRECIVE) voltmpx = obj;
if (voltmpx != null) voltmpx.descript = talkTime + ": " + (DifTime.Minutes * 60 + DifTime.Seconds).ToString() + " " + secName;
if (MainForm2.PopupOpen[IdVOLx.ToString()] != null)
((Popupwindow)MainForm2.PopupOpen[IdVOLx.ToString()]).populate();
}
catch (Exception ex)
{
SM.Debug("Error on recevie 125" + ex.ToString());
}
}
}
catch (Exception ex)
{
SM.Debug("Error on 125 with status 2 or 3 (end call or hang time):" + ex.ToString());
}
Startrecevied = false;
if (callStatusVOL == 2)
{
rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;
}
else if (callStatusVOL == 3)
{
rbAllCall.Enabled = true;
rbGroupCall.Enabled = true;
rbPrivateCall.Enabled = true;
#if NOALLCALL
rbGroupCall.IsChecked = true;
#else
rbAllCall.IsChecked = true;
#endif
ReadyfornewKEY = true;
}
if (tclose125!=null)
tclose125.Dispose();
}
break;
}
}
catch (Exception ex)
{
SM.Debug("Error processmessage on radio:"+ex.ToString());
}
}
//send temporar end of call suppended
private void SendStopfor125(object IDState)
{
try
{
mainparent.Send_UDP_cmd_sent_withOutID("#0.0#125#" + gwandradID + "." + ((Int64)IDState).ToString() + "#3#101#0#");
}
catch (Exception ex)
{
SM.Debug("Ex:" + ex.ToString());
}
}
private volatile Boolean proces124 = false;
private volatile Boolean proces125 = false;
private volatile Boolean proces111or112or113 = false;
private volatile Boolean proces111or112or113FALSE = false;
private volatile Boolean proces121or122or123 = false;
private volatile Boolean proces101or102or103 = false;
private volatile Boolean procesReport = true;
private volatile Int32 Idproces = 0;
private volatile Int32 Limitsend = 0;
private volatile Int32 X = 0;
private volatile String volSTR = "";
long Computation(BackgroundWorker worker, DoWorkEventArgs e)
{
threadStarted = true;
while (true)
{
try
{
proces124 = false;
proces125 = false;
proces111or112or113 = false; proces111or112or113FALSE = false;
proces121or122or123 = false;
proces101or102or103 = false;
Idproces = 0;
lock (this)
{
X=0;
while (X < WatchList.Count)
{
//SM.Debug("in comands " + myIP);
volSTR = (String)WatchList[X];
if (mainparent.Listcmd[volSTR] == null)
ClearList.Add(volSTR);
else
{
if (!((TimerAndResp)mainparent.Listcmd[volSTR]).wait)
{
if (((TimerAndResp)mainparent.Listcmd[volSTR]).Respose)
{
Int32 tmp = (Int32)((TimerAndResp)mainparent.Listcmd[volSTR]).intval * 1000 + ((TimerAndResp)mainparent.Listcmd[volSTR]).typeID;
if (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID == 125)
{
tmp = 0 * 1000 + ((TimerAndResp)mainparent.Listcmd[volSTR]).typeID;
tmptransVOL = new transfer125(((TimerAndResp)mainparent.Listcmd[volSTR]).callStatus, ((TimerAndResp)mainparent.Listcmd[volSTR]).callType, ((TimerAndResp)mainparent.Listcmd[volSTR]).GrpID, ((TimerAndResp)mainparent.Listcmd[volSTR]).intval);
proces125 = true;
}
//displayStat
if (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID == 124) { proces124 = true; Limitsend = 0; }
if ((((TimerAndResp)mainparent.Listcmd[volSTR]).typeID > 120) && (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID < 124)) { proces121or122or123 = true; Limitsend = 0; }
procesReport = true;
if ((tmp > 2114) && (tmp < 2118))
{
if (tmp == 2115) Idproces = 111;
else if (tmp == 2116) Idproces = 112;
else Idproces = 113;
Limitsend++;
proces111or112or113FALSE = true;
procesReport = false;
}
if (procesReport)
{
if (!proces125) worker.ReportProgress(tmp);
else worker.ReportProgress(tmp, tmptransVOL);
}
}
else
{
if (((((TimerAndResp)mainparent.Listcmd[volSTR]).typeID > 110) && (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID < 114)) || (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID == 104) || (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID == 161))
{
proces111or112or113 = true;
Idproces = ((TimerAndResp)mainparent.Listcmd[volSTR]).typeID;
}
if (((((TimerAndResp)mainparent.Listcmd[volSTR]).typeID > 100) && (((TimerAndResp)mainparent.Listcmd[volSTR]).typeID < 104)))
{
proces101or102or103 = true;
//Idproces = ((TimerAndResp)mainparent.Listcmd[obj]).typeID;
}
}
mainparent.Listcmd.Remove(volSTR);
ClearList.Add(volSTR);
if ((FirstChanle00) && !proces124)
{
worker.ReportProgress(1999);//sc_id =1 (fake) si comanda 999
isON = false;
FirstChanle00 = false;
}
}
}
X++;
}
}
foreach (String obj in ClearList)
WatchList.Remove(obj);
ClearList.Clear();
// ciudat remove 104 pentru care a venit 124
String tmpIdtoRemove ="";
if (proces124)
{
foreach (String obj in WatchList)
if (((TimerAndResp)mainparent.Listcmd[obj]).typeID == 104)
{
tmpIdtoRemove = obj;
break;
}
if (tmpIdtoRemove != "") WatchList.Remove(tmpIdtoRemove);
}
//SM.Debug("Value for proces121or122or123:" + proces121or122or123 + " and OUTBEFORE:"+OUTBEFORE);
if ((proces121or122or123)&&(OUTBEFORE)) callStopProcedure(true);
if (proces101or102or103) worker.ReportProgress(1115);
if (proces111or112or113||proces111or112or113FALSE)
{
if (Limitsend < 6)
{
if (Idproces == 111)
{
if (proces111or112or113) Stop_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
else
{
String Totrans = String.Format("#111#{0}#{1}#", gwandradID, String.Format("224.20.{0}.1", MainForm2.userIDX));
WatchList.Add(mainparent.Send_delay(Totrans, 3000, 111, 3000));
}
}
else if (Idproces == 112)
{
String Totrans = "#112#" + gwandradID + "." + tbPrivateCallId.Text + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
if (proces111or112or113) WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 3000, 112));
else WatchList.Add(mainparent.Send_delay(Totrans, 3000, 112, 3000));
}
else if (Idproces == 113)
{
String Totrans = "#113#" + gwandradID + "." + tbGroupCallId.Text + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
if (proces111or112or113) WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 3000, 113));
else WatchList.Add(mainparent.Send_delay(Totrans, 3000, 113, 3000));
}
else if (Idproces == 161)
{
worker.ReportProgress(1998);//sc_id =1 (fake) si comanda 999
}
Limitsend++;
}
else //station come back to normal state
{
worker.ReportProgress(1999);//sc_id =1 (fake) si comanda 999
}
}
}
catch (Exception ex)
{
SM.Debug("Error on radio list"+ex.ToString());
}
Thread.Sleep(10);
if (MainForm2.ClosingApp)
{
SM.Debug("ComputMess Voice: CancellationPending in Radio: ");
e.Cancel = true;
return 1;
}
}
}
public void PTT_enable()
{
Application.DoEvents();
try
{
btPTT.Enabled = true;
btPPT.Enabled = true;
ProgVolum.Value1 = ProgVolum.Maximum - 0 + ProgVolum.Minimum;
if (MainForm2.radioType != RADIOTYPE.HYT)
btDkey.Enabled = false;
ImgStat.Image = global::Dispatcher.Properties.Resources.green_status;
lbStatus.Text = "";
foreach (String objkey in MainForm2.PopupOpen.Keys)
if (((Popupwindow)MainForm2.PopupOpen[objkey]).gwandradID == gwandradID)
((Popupwindow)MainForm2.PopupOpen[objkey]).EnablePTT();
}
catch (Exception ex)
{
SM.Debug("Error on enableD PTT" + ex.ToString());
}
}
public void PTT_disable()
{
try
{
btPTT.Enabled = false;
btPPT.Enabled = false;
btDkey.Enabled = true;
/*rbAllCall.Enabled = false;
rbGroupCall.Enabled = false;
rbPrivateCall.Enabled = false;*/
ImgStat.Image = global::Dispatcher.Properties.Resources.yellow_status;
foreach (String objkey in MainForm2.PopupOpen.Keys)
if (((Popupwindow)MainForm2.PopupOpen[objkey]).gwandradID == gwandradID)
((Popupwindow)MainForm2.PopupOpen[objkey]).DisablePTT();
}
catch (Exception ex)
{
SM.Debug("Error on disable PTT" + ex.ToString());
}
}
private void cbPatch_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
try
{
if (cbPatch.IsChecked)
{
MainForm2.PatchList.Add(new patchobj(myIP, this));
isPatch = true;
}
else
{
patchobj tmprem = null;
foreach (patchobj obj in MainForm2.PatchList)
if (obj.ip == myIP) { tmprem = obj; break; }
if (tmprem != null) MainForm2.PatchList.Remove(tmprem);
isPatch = false;
}
}
catch (Exception ex)
{
SM.Debug("cbPatch_ToggleStateChanged:"+ex.ToString());
}
}
public void Send_Private_PTT(String ID)
{
try
{
if (isON)
{
Callmade = 102;
PTTclicked = true;
parent.GeneralPTTclick = true;
String Totrans = "#102#" + gwandradID + "." + ID + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 102));
tbPrivateCallId.Text = ID;
try
{
tbPrivateCallId.Value = Convert.ToInt32(ID);
}
catch (Exception ex)
{
SM.Debug("Error convert ID to int" + ex.ToString());
}
DisableCMDPTT();
}
}
catch (Exception ex)
{
SM.Debug("Send_Private_PTT:" + ex.ToString());
}
}
public void Send_Remote_Monitor(String ID)
{
try
{
if (isON)
{
String Totrans = "#161#" + gwandradID + "." + ID + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 15000, 161));
tbRemote.Text = ID;
lbStatus.Text = sendlang + " " + btRem.Text;
btRem.Enabled = false;
PTT_disable();
if (MainForm2.radioType!=RADIOTYPE.HYT)
btDkey.Enabled = false;
DisableChALL();
}
}
catch (Exception ex)
{
SM.Debug("Send_Private_PTT:" + ex.ToString());
}
}
private void DisableChALL()
{
try
{
btChDown.Enabled = false;
btChUp.Enabled = false;
cbChan.Enabled = false;
cbZone.Enabled = false;
isEnabled = false;
mainparent.Send_UDP_cmd_sent_withOutID("#0.0#207#" + gwandradID + "#" + MainForm2.userIDX.ToString() + "#1#");
}
catch (Exception ex)
{
SM.Debug("DisableChALL:"+ex.ToString());
}
}
private void EnableChALL()
{
try
{
btChDown.Enabled = true;
btChUp.Enabled = true;
cbChan.Enabled = true;
cbZone.Enabled = true;
isEnabled = true;
mainparent.Send_UDP_cmd_sent_withOutID("#0.0#207#" + gwandradID + "#" + MainForm2.userIDX.ToString() + "#0#");
}
catch (Exception ex)
{
SM.Debug("EnableChALL:" + ex.ToString());
}
}
public void Stop_Private_PTT(String ID)
{
try
{
if (PTTclicked)
{
String Totrans = "#112#" + gwandradID + "." + ID + "#" + "224.20." + MainForm2.userIDX + ".1" + "#";
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 112));
PTTclicked = false;
parent.GeneralPTTclick = false;
}
}
catch (Exception ex)
{
SM.Debug("Stop_Private_PTT:" + ex.ToString());
}
}
public void Send_PTT(String IP)
{
try
{
if (isON)
{
PTTclicked = true;
parent.GeneralPTTclick = true;
String Totrans = String.Format("#101#{0}#{1}#", gwandradID, IP);
Callmade = 101;
DisableCMDPTT();
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 10000, 101));
}
}
catch (Exception ex)
{
SM.Debug("Send_PTT:" + ex.ToString());
}
}
public void Stop_PTT(String IP)
{
try
{
if (PTTclicked)
{
String Totrans = String.Format("#111#{0}#{1}#", gwandradID, IP);
WatchList.Add(mainparent.Send_UDP_cmd(Totrans, 3000, 111));
}
}
catch (Exception ex)
{
SM.Debug("Send_PTT:" + ex.ToString());
}
}
public void KeyDown(Int32 valuekey)
{
try
{
Console.WriteLine("Key down:"+((Char)valuekey).ToString());
Console.WriteLine("Compare with:" + txAssingKey.Text.ToUpper());
Console.WriteLine("compare:" + ((Char)valuekey).ToString().CompareTo(txAssingKey.Text.ToUpper()) + " " + ReadyfornewKEY+" "+chanelFree);
if (((((Char)valuekey).ToString() == txAssingKey.Text.ToUpper())||(((Char)(valuekey-32)).ToString() == txAssingKey.Text.ToUpper())) && (ReadyfornewKEY) && (chanelFree))
{
ReadyfornewKEY = false;
//Send_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
if (rbAllCall.IsChecked) Send_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
else if (rbGroupCall.IsChecked) SendGroupCall();
else if (rbPrivateCall.IsChecked) SendPrivateCall();
if (isON) PTT_disable();
}
else
{
//Console.WriteLine("Comparatia:" + ((Char)valuekey).ToString().ToUpper() + " compare:" + MainForm2.KeyforPTTall.ToUpper());
if (((Char)valuekey).ToString() == MainForm2.KeyforPTTall.ToUpper())
{
//Console.WriteLine("PTT ALL PRESS");
MAKESTOPBOOLPTTALL = false;
foreach (ShapeNew obj in parent.RadioForms)
{
if (obj.isON)
{
parent.PTTclickedALL = true;
obj.Send_PTT_ALL_ON();
}
}
}
}
}
catch (Exception ex)
{
SM.Debug("KeyDown:"+ex.ToString());
}
}
public void KeyUP(Int32 valuekey)
{
try
{
if ((((Char)valuekey).ToString() == txAssingKey.Text.ToUpper()) && chanelFree)
//Stop_PTT(String.Format("224.20.{0}.1", MainForm2.userIDX));
callStopProcedure(false);
else
{
//Console.WriteLine("Comparatia:" + ((Char)valuekey).ToString().ToUpper() + " compare:" + MainForm2.KeyforPTTall.ToUpper());
if (((Char)valuekey).ToString().ToUpper() == MainForm2.KeyforPTTall.ToUpper())
{
//Console.WriteLine("PTT ALL UP");
if (!MAKESTOPBOOLPTTALL)
{
MAKESTOPBOOLPTTALL = true;
foreach (ShapeNew obj in parent.RadioForms)
{
if (obj.isON)
{
obj.Send_PTT_ALL_OFF();
parent.PTTclickedALL = false;
}
}
Thread.Sleep(1000);
}
}
}
}
catch (Exception ex)
{
SM.Debug("KeyDown:" + ex.ToString());
}
}
private void btPPT_Click(object sender, EventArgs e)
{
try
{
if (!MAKESTOPBOOL)
{
if (ResponsePTT) callStopProcedure(false);
else OUTBEFORE = true;
btPPT.Enabled = false;
btPTT.Enabled = false;
MAKESTOPBOOL = true;
Thread.Sleep(2000);
}
}
catch (Exception ex)
{
SM.Debug("Ex:"+ex.ToString());
}
}
private void ChangeList(Int32 CallType,Int32 imei,Int64 startTime, Int64 stopTime)
{
try
{
if (!RadioControl.TCPstarted)
{
parent.StartTCP();
Thread.Sleep(100);
}
if (RadioControl.TCPstarted)
{
Int64 tmp = imei;
Byte Imei_1 = (Byte)(tmp / (256 * 256 * 256));
tmp = tmp % (256 * 256 * 256);
Byte Imei_2 = (Byte)(tmp / (256 * 256));
tmp = tmp % (256 * 256);
Byte Imei_3 = (Byte)(tmp / 256);
Byte Imei_4 = (Byte)(tmp % 256);
tmp = startTime;
Byte startTime_1 = (Byte)(tmp / (256*256*256));
tmp = tmp % (256 * 256 * 256);
Byte startTime_2 = (Byte)(tmp / (256 * 256));
tmp = tmp % (256 * 256);
Byte startTime_3 = (Byte)(tmp / 256);
Byte startTime_4 = (Byte)(tmp % 256);
tmp = stopTime;
Byte stopTime_1 = (Byte)(tmp / (256 * 256 * 256));
tmp = tmp % (256 * 256 * 256);
Byte stopTime_2 = (Byte)(tmp / (256 * 256));
tmp = tmp % (256 * 256);
Byte stopTime_3 = (Byte)(tmp / 256);
Byte stopTime_4 = (Byte)(tmp % 256);
parent.tcp.Send(new byte[] { 0, 1, (byte)gwID, (byte)radID, Imei_1, Imei_2, Imei_3, Imei_4, startTime_1, startTime_2, startTime_3, startTime_4, stopTime_1, stopTime_2, stopTime_3, stopTime_4, (byte)CallType });
if (ckShowLogin.Checked)
{
//if ()
//parent.tcp.Send(new byte[] { 0, 2, 0, (byte)MainForm2.userIDX });
parent.tcp.Send(new byte[] { 0, 2, 0, (byte)(((User)((RadListDataItem)cbUsers.SelectedItem).Value).Id), Imei_1, Imei_2, Imei_3, Imei_4, startTime_1, startTime_2, startTime_3, startTime_4, stopTime_1, stopTime_2, stopTime_3, stopTime_4, (byte)CallType });
}
}
}
catch (Exception ex)
{
SM.Debug("Error on sent tcp cmd: "+ex.ToString());
}
}
private void ckShowLogin_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
ChangeList(10,0,0,0);
}
private void btRem_Click(object sender, EventArgs e)
{
try
{
Int64 id = 1;
if (isON)
{
try
{
id = Convert.ToInt64(tbRemote.Text);
}
catch
{
id = 0;
}
if ((id >= 1) && (id <= 16776415))
{
if (MainForm2.VehIMEIHash[id.ToString()] != null) Send_Remote_Monitor(id.ToString());
else lbStatus.Text = id.ToString() + " " + MainForm2.returnLNGString("IsNotYourUnit");
}
else lbStatus.Text = MainForm2.returnLNGString("errorIDLim");
}
}
catch (Exception ex)
{
SM.Debug("btRem_Click:" + ex.ToString());
}
}
private void btnRefresh_Click(object sender, EventArgs e)
{
RefreshChanel();
rbAllCall.Enabled = true;
rbGroupCall.Enabled = true;
rbPrivateCall.Enabled = true;
}
private volatile Boolean INPTT = false;
private void LimitPTT_Tick(object sender, EventArgs e)
{
try
{
INPTT = false;
LimitPTT.Stop();
LimitPTT.Enabled = false;
}
catch (Exception ex)
{
SM.Debug("LimitPTT:"+ex.ToString());
}
}
private void btPPT_LostMouseCapture(object sender, MouseEventArgs e)
{
try
{
if (!MAKESTOPBOOL)
{
if (ResponsePTT) callStopProcedure(false);
else OUTBEFORE = true;
btPPT.Enabled = false;
btPTT.Enabled = false;
MAKESTOPBOOL = true;
Thread.Sleep(2000);
}
}
catch (Exception ex)
{
SM.Debug("Ex:" + ex.ToString());
}
}
private void btDkey_MouseDown(object sender, MouseEventArgs e)
{
try
{
if (MainForm2.radioType == RADIOTYPE.HYT)
{
callStopProcedure(false);
}
else
{
String Totrans = String.Format("#160#{0}#", gwandradID);
mainparent.Send_UDP_cmd(Totrans, 0, 0);
}
}
catch (Exception ex)
{
SM.Debug("btDkey_Click:" + ex.ToString());
}
}
private void cbUsers_SelectedIndexChanged(object sender, EventArgs e)
{
if (afterload) ChangeList(10,0,0,0);
}
private void radioFrom_Load(object sender, EventArgs e)
{
try
{
radStatusStrip1.ThemeName="Breeze";
this.ProgVolum.IndicatorElement1.BackColor3 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.IndicatorElement1.BackColor4 = System.Drawing.Color.White;
this.ProgVolum.IndicatorElement1.BackColor = System.Drawing.Color.LightGray;
this.ProgVolum.IndicatorElement1.BackColor2 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.IndicatorElement2.BackColor3 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.IndicatorElement2.BackColor4 = System.Drawing.Color.White;
this.ProgVolum.IndicatorElement2.BackColor = System.Drawing.Color.LightGray;
this.ProgVolum.IndicatorElement2.BackColor2 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.BackColor3 = System.Drawing.SystemColors.ControlLight;
this.ProgVolum.BackColor4 = System.Drawing.Color.White;
this.ProgVolum.BackColor = System.Drawing.Color.LightGray;
this.ProgVolum.BackColor2 = System.Drawing.SystemColors.ControlLight;
if (MainForm2.radioType == RADIOTYPE.REPEATER_TRBO)
{
ChangeList(10, 0, 0, 0);
OnRecording = true;
}
}
catch (Exception ex)
{
SM.Debug("Error on change progress bar color:"+ex.ToString());
}
/* if (MainForm2.Hytera)
{
this.ThemeName = "Desert";
this.radTabStrip1.Location = new Point(0, 63);
}
else
{
this.ThemeName = "Breeze";
this.radTabStrip1.Location = new Point(0, 50);
}*/
}
private void cbVehName_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
try
{
tbPrivateCallId.Text = (((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).Imei;
tbRemote.Text = (((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).Imei;
try
{
tbPrivateCallId.Value = Convert.ToInt32((((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).Imei);
tbRemote.Value = Convert.ToInt32((((RadListDataItem)cbVehName.Items[cbVehName.SelectedIndex]).Value as VehandID).Imei);
}
catch (Exception ex)
{
SM.Debug("Error convert imei" + ex.ToString());
}
}
catch (Exception ex)
{
SM.Debug("cbVehName_SelectedIndexChanged:" + ex.ToString());
}
}
private void newtab_SelectedPageChanged(object sender, EventArgs e)
{
try
{
if (newtab.SelectedPage.Name == "tbRecord")
{
ChangeList(10, 0, 0, 0);
OnRecording = true;
}
else OnRecording = false;
}
catch (Exception ex)
{
SM.Debug("radTabStrip1_TabSelected:" + ex.ToString());
}
}
private void cbVoicePriority_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
if (this.cbVoicePriority.ToggleState == ToggleState.On)
{
MainForm2.ProrityIP = PersonalIP;
parent.SendProrityOFF(PersonalIP);
}
}
private void ckDataFilter_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
if (ckDataFilter.Checked)
{
dtFrom.Enabled = true;
dtTo.Enabled = true;
}
else
{
dtFrom.Enabled = false;
dtTo.Enabled = false;
}
}
private void ckUnitName_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
if (this.ckUnitName.Checked) this.cbUnitName.Enabled = true;
else this.cbUnitName.Enabled = false;
}
private void btFilter_Click(object sender, EventArgs e)
{
Int32 imei = 0;
Int64 startTime = 0;
Int64 stopTime = 0;
Int32 CallType = 10;
Boolean Valid = true;
if (ckUnitName.Checked) imei = Convert.ToInt32((((RadListDataItem)cbUnitName.Items[cbUnitName.SelectedIndex]).Value as VehandID).Imei);
if (ckDataFilter.Checked)
{
if (convDT.GetSecondsFromDT(dtFrom.Value) > convDT.GetSecondsFromDT(dtTo.Value))
{
if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor;
RadMessageBox.Show(msgLimit);
Valid = false;
}
if (Valid)
{
startTime = convDT.GetSecondsLocalFromDT(dtFrom.Value);
stopTime = convDT.GetSecondsLocalFromDT(dtTo.Value);
}
}
if (cbCallType.Checked)
{
CallType = dropCalltype.SelectedIndex;
if (dropCalltype.SelectedIndex > 2)
CallType = dropCalltype.SelectedIndex + 1;
} ///CallType = Convert.ToInt32((((RadListDataItem)dropCalltype.Items[dropCalltype.SelectedIndex]).Value as CallType_Drop).Id);
if (Valid)
{
RecordingList.Rows.Clear();
ChangeList(CallType,imei, startTime, stopTime);
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
dropCalltype.DataSource = new CallType_DropCollection();
dropCalltype.DisplayMember = "Name";
dropCalltype.ValueMember = "Id";
}
private void dropCalltype_ItemDataBound(object sender, ListItemDataBoundEventArgs args)
{
var test = args.NewItem.DataBoundItem as CallType_Drop;
if (test == null)
{
return;
}
args.NewItem.Image = test.Image;
}
private void cbCallType_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
if (this.cbCallType.Checked) this.dropCalltype.Enabled = true;
else this.dropCalltype.Enabled = false;
}
public void AddRow(Recording tmpRecord)
{
///RecordingList.Rows.AddNew();
Boolean stop100 = false;
ArrayList tmp = new ArrayList();
tmp.Add(tmpRecord);
if (recordArrayList.Count > 110) stop100 = true;
Int32 cnt = 0;
foreach (Recording obj in recordArrayList)
{
cnt++;
tmp.Add(obj);
if ((stop100)&&(cnt > 100)) break;
}
populateRecList(tmp);
}
private void btExport_Click(object sender, EventArgs e)
{
Boolean errormess = false;
String filename = "";
try
{
filename = System.Windows.Forms.Application.StartupPath + @"\Call_log_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + "_Time_" + DateTime.Now.Hour + "_" + DateTime.Now.Minute + ".csv";
StreamWriter sw = new StreamWriter(filename, false);
// First we will write the headers.
int iColCount = RecordingList.ColumnCount;
for (int i = 2; i < iColCount-1; i++)
{
if ((i != 7) && (i != 8))
{
sw.Write(RecordingList.Columns[i].HeaderText);
if (i < iColCount - 2)
{
sw.Write(",");
}
}
}
sw.Write(sw.NewLine);
for (int j = 0; j < RecordingList.Rows.Count(); j++)
{
for (int i = 2; i < iColCount-1; i++)
{
if (!Convert.IsDBNull(RecordingList.Rows[j].Cells[i].Value))
{
if (i == 2)
{
switch (Convert.ToInt32(RecordingList.Rows[j].Cells[10].Value))
{
case 0:
sw.Write("Private call made");
break;
case 1:
sw.Write("Group call made");
break;
case 2:
sw.Write("ALL call made");
break;
case 4:
sw.Write("Private call received");
break;
case 5:
sw.Write("Group call received");
break;
case 6:
sw.Write("ALL call received");
break;
}
}
else
{
if ((i != 7) && (i != 8) && (RecordingList.Rows[j].Cells[i].Value != null))
{
sw.Write(RecordingList.Rows[j].Cells[i].Value.ToString());
}
}
}
if ((i < iColCount - 2)&&((i != 7) && (i != 8)))
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
sw.Close();
}
catch (Exception ex)
{
errormess = true;
SM.Debug("Error write file" + ex.ToString());
try
{
if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor;
RadMessageBox.Show("Erorr exporting file.", MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
catch (Exception ex2)
{
SM.Debug("Error exception2:" + ex2.ToString());
}
}
try
{
if (!errormess)
{
if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor;
if (filename.Length > 60)
{
if (filename.IndexOf('\\', 50)>0)
filename = filename.Insert(filename.IndexOf('\\', 50), "\n");
}
RadMessageBox.Show("Export file finish.\nFile is in: " + filename, "Info", MessageBoxButtons.OK, RadMessageIcon.Info);
}
}
catch (Exception ex)
{
SM.Debug("Error on put mess on screen:"+ex.ToString());
}
}
private void btPTT_Click(object sender, EventArgs e)
{
}
}
}