SafeDispatch/Safedispatch_4_0/maptab/LiveTabGIS.cs

2578 lines
88 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using MapGoogle;
using Telerik.WinControls.UI;
using Telerik.WinControls;
using Telerik.WinControls.UI.Docking;
using SafeMobileLib;
using Telerik.WinControls.Data;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.EngineCore;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using Dispatcher.maptab.UIClasses;
using Dispatcher.Helpers;
using System.Drawing.Imaging;
namespace Safedispatch_4_0
{
/// <summary>
/// This class implements the live tab.</summary>
/// <remarks>
/// The live tab contains two areas, left and right. On the left side
/// the vehicle selection is made, and on the right side information
/// is displayed according to the criteria from the left</remarks>
public partial class LiveTabGIS : UserControl
{
/// <summary>
/// The class constructor. </summary>
///
public bool KillTimerActive = false;
private String latname = "";
private String lngname = "";
private String zonename = "";
private String altname = "";
private String milesh, kmh,msg2,s18;
public Boolean docLoad = true;
private IMapControl3 m_mapControl = null;
public IGraphicTracker m_graphicTracker = null;
public IGraphicTracker placeSet = null;
public static volatile Boolean TableViewDataComplete = true;
public static volatile Boolean TableViewSortComplete = true;
public static volatile Boolean TableViewFinish = true;
public LiveTabGIS(MainForm2 parentParam,String tabNameParam)
{
parent = parentParam;
tabName = tabNameParam;
InitializeComponent();
LiveGridColumn ctc = new LiveGridColumn("live");
ctc.AllowResize = true;
ctc.AllowGroup = true;
ctc.Name = "live";
ctc.FieldName = "live";
ctc.HeaderText = "live";
ctc.AutoSizeMode = BestFitColumnMode.AllCells;
ctc.HeaderTextAlignment = ContentAlignment.MiddleLeft;
ctc.SortOrder = RadSortOrder.Ascending;
this.vehiclesList.TableElement.RowHeight = 55;
this.vehiclesList.Columns.Add(ctc);
this.vehiclesList.Columns.Move(ctc.Index, 0);
this.vehiclesList.GridViewElement.DrawBorder = false;
this.vehiclesList.GridViewElement.GroupPanelElement.DrawBorder = false;
LiveAddressGridColumn positionCell = new LiveAddressGridColumn("history");
positionCell.AllowResize = true;
positionCell.Name = "history";
positionCell.FieldName = "history";
positionCell.HeaderText = "history";
positionCell.AutoSizeMode = BestFitColumnMode.AllCells;
positionCell.HeaderTextAlignment = ContentAlignment.MiddleLeft;
positionCell.SortOrder = RadSortOrder.Ascending;
this.tableVehiclesList.TableElement.RowHeight = 75;
this.tableVehiclesList.Columns.Add(positionCell);
this.tableVehiclesList.Columns.Move(positionCell.Index, 0);
this.tableVehiclesList.GridViewElement.DrawBorder = false;
this.tableVehiclesList.GridViewElement.GroupPanelElement.DrawBorder = false;
// set the group comparer in order to display the custom groups in
// desired order
CustomGroupComparer gc = new CustomGroupComparer();
this.vehiclesList.MasterTemplate.GroupComparer = gc;
// change the icons for grouping and add them to the hashtable
// add image to the dictionary if not exists
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_group"))
MainForm2.imagesDictionary.Add("l_filter_group", global::Dispatcher.Properties.Resources.l_user_n);
// return the desired image
pbGroup.Image = MainForm2.imagesDictionary["l_filter_group"];
// add image to the dictionary if not exists
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_time"))
MainForm2.imagesDictionary.Add("l_filter_time", global::Dispatcher.Properties.Resources.l_history_b);
// return the desired image
pbGroupTime.Image = MainForm2.imagesDictionary["l_filter_time"];
// add image to the dictionary if not exists
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_status"))
MainForm2.imagesDictionary.Add("l_filter_status", global::Dispatcher.Properties.Resources.l_bullet_bl);
// return the desired image
pbGroupStatusType.Image = MainForm2.imagesDictionary["l_filter_status"];
pbFilter_Click(pbGroup, null);
if (MainForm2.NOAddress)
tableVehiclesList.Columns["address"].IsVisible = false;
try
{
if (MainForm2.is24hours)
{
if (MainForm2.DayFirst)
((GridViewDateTimeColumn)tableVehiclesList.Columns["datetime"]).FormatString = "{0:dd/MM/yyyy HH:mm:ss}";
else
((GridViewDateTimeColumn)tableVehiclesList.Columns["datetime"]).FormatString = "{0:MM/dd/yyyy HH:mm:ss}";
}
else
{
if (MainForm2.DayFirst)
((GridViewDateTimeColumn)tableVehiclesList.Columns["datetime"]).FormatString = "{0:dd/MM/yyyy hh:mm:ss tt}";
else
((GridViewDateTimeColumn)tableVehiclesList.Columns["datetime"]).FormatString = "{0:MM/dd/yyyy hh:mm:ss tt}";
}
}
catch (Exception ex)
{
SM.Debug("Error on gridview DateFormat:" + ex.ToString());
}
this.SelectionLive.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255)))));
AdjustSizes();
populateVehiclesList(vehicleListNames);
//ChangeIcons(vehicleListNames);
SelectionLive.Enabled = true;
GetPositionForPlace = false;
GetPositionForStart = false;
GetPositionForZones = false;
#region THEMING
rlUnits.ForeColor = MainForm2.LabelColor;
displayButton.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
pbFilter.Image = Utils.ChangeColor(global::Dispatcher.Properties.Resources.i_search, MainForm2.ButtonColor);
#endregion
string s1 = MainForm2.returnLNGString("displayButton"),
s2 = MainForm2.returnLNGString("cbselAll"),
s3 = MainForm2.returnLNGString("selectionExpando"),
s4 = MainForm2.returnLNGString("tabPage1"),
s5 = MainForm2.returnLNGString("positions"),
s6 = MainForm2.returnLNGString("htableVehiclesListColumns1"),
s7 = MainForm2.returnLNGString("htableVehiclesListColumns1"),
s8 = MainForm2.returnLNGString("alarmsListColumns1"),
s9 = MainForm2.returnLNGString("tableVehiclesListColumns2"),
s10 = MainForm2.returnLNGString("tablevehiclesListColumns3"),
s11 = MainForm2.returnLNGString("tableVehiclesListColumns4"),
s12 = MainForm2.returnLNGString("lbGroup"),
s13 = MainForm2.returnLNGString("btGetAddress"),
s15 = MainForm2.returnLNGString("SMScomp"),
s16 = MainForm2.returnLNGString("DI"),
s17 = MainForm2.returnLNGString("DO"),
s19 = MainForm2.returnLNGString("quickhist"),
s20 = MainForm2.returnLNGString("snd"),
s21 = MainForm2.returnLNGString("changeDO");
s18 = MainForm2.returnLNGString("allunits");
langProgStat = MainForm2.returnLNGString("txProgStatLive");
latname = MainForm2.returnLNGString("colum2");
lngname = MainForm2.returnLNGString("colum3");
zonename = MainForm2.returnLNGString("zone");
msg2 = MainForm2.returnLNGString("toomany");
ckShowLand.Text = MainForm2.returnLNGString("prevland");
ckShowZone.Text = MainForm2.returnLNGString("prevzone");
altname = MainForm2.returnLNGString("altname");
kmh = MainForm2.returnLNGString("kmh");
milesh = MainForm2.returnLNGString("milesh");
displayButton.Text = s1;
sel_desel.Text = s2;
windowUnits.Text = s3;
toolWindow2.Text = s4;
windowPositions.Text = s5;
vehiclesList.Columns[2].HeaderText = s6;
vehiclesList.Columns[4].HeaderText = MainForm2.returnLNGString("SMSStatus");
tableVehiclesList.Columns[0].HeaderText = s7;
tableVehiclesList.Columns[1].HeaderText = s8;
tableVehiclesList.Columns[2].HeaderText = s9;
if (MainForm2.isInMile) tableVehiclesList.Columns[3].HeaderText = s10 + " ("+milesh+")";
else tableVehiclesList.Columns[3].HeaderText = s10 + " ("+kmh+")";
tableVehiclesList.Columns[4].HeaderText = s11;
tableVehiclesList.Columns[5].HeaderText = s16;
tableVehiclesList.Columns[6].HeaderText = s17;
sendSMSToolStripMenuItem1.Text = s15;
sendSMSToolStripMenuItem.Text = s15;
basicHistoryToolStripMenuItem.Text = s19;
sendPOLLToolStripMenuItem.Text = s20;
changeDOStatusToolStripMenuItem.Text = s21;
tableVehiclesList.Columns[7].HeaderText = latname;
tableVehiclesList.Columns[8].HeaderText = lngname;
tableVehiclesList.Columns[9].HeaderText = "";
tableVehiclesList.Columns[10].HeaderText = altname;
tableVehiclesList.Refresh();
LiveProgBar.Visible = false;
txProgStatus.Visible = false;
LivePanel.Visible = false;
if (MainForm2.MotoTURBO)
{
sendPOLLToolStripMenuItem.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
changeDOStatusToolStripMenuItem.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
}
else sendSMSToolStripMenuItem1.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
windowPositions.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu;
windowPositions.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
windowPositions.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide;
windowUnits.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu;
windowUnits.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
windowUnits.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide;
toolWindow2.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu;
toolWindow2.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
ContextMenuService menuService = this.radDock1.GetService<ContextMenuService>();
//menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying;
//this disables the context menu
menuService.AllowActiveWindowListContextMenu = false;
menuService.AllowDocumentContextMenu = false;
menuService.AllowToolContextMenu = false;
switch (MainForm2.radioType)
{
case RADIOTYPE.HYT:
radDock1.BackColor = MainForm2.HyteraColor;
LivePanel.BackColor = MainForm2.HyteraColor;
radSplitContainer1.BackColor = MainForm2.HyteraColor;
radSplitContainer2.BackColor = MainForm2.HyteraColor;
documentTabStrip1.BackColor = MainForm2.HyteraColor;
break;
case RADIOTYPE.HARRIS:
radDock1.BackColor = MainForm2.HarrisColor;
LivePanel.BackColor = MainForm2.HarrisColor;
radSplitContainer1.BackColor = MainForm2.HarrisColor;
radSplitContainer2.BackColor = MainForm2.HarrisColor;
documentTabStrip1.BackColor = MainForm2.HarrisColor;
break;
case RADIOTYPE.ATLAS:
radDock1.BackColor = MainForm2.HarrisColor;
LivePanel.BackColor = MainForm2.HarrisColor;
radSplitContainer1.BackColor = MainForm2.HarrisColor;
radSplitContainer2.BackColor = MainForm2.HarrisColor;
documentTabStrip1.BackColor = MainForm2.HarrisColor;
break;
case RADIOTYPE.SIMOCO:
case RADIOTYPE.EXCERA:
// probably we don't need color
break;
}
rddlGroupingType.Items.Clear();
//RadListDataItem item = new RadListDataItem(MainForm2.returnLNGString("")) { Tag = "categories" };
rddlGroupingType.Items.Add(new RadListDataItem(MainForm2.returnLNGString("liveGroupingCategories")) { Tag = "categories" });
if (MainForm2.HasVoice)
rddlGroupingType.Items.Add(new RadListDataItem(MainForm2.returnLNGString("liveGroupingRadioGateway")) { Tag = "radiogateway" });
String currentGroupingType = VisualSettings.GetGroupingTypeInLiveTab(tabName);
bool found = false;
foreach (RadListDataItem item in rddlGroupingType.Items)
{
if (currentGroupingType == null)
{
item.Selected = true;
VisualSettings.SetGroupingTypeInLiveTab(item.Tag + "", tabName);
break;
}
else if (item.Tag.ToString().Equals(currentGroupingType))
{
item.Selected = true;
found = true;
}
}
rddlGroupingType.SelectedIndexChanged += GroupingType_SelectedIndexChanged;
if (!found)
rddlGroupingType.SelectedIndex = 0;
}
private void GroupingType_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
// skip the case when the position is out of bounds
if (!(e.Position >= 0 && e.Position < rddlGroupingType.Items.Count))
return;
RadListDataItem selectedItem = rddlGroupingType.Items[e.Position];
gridVehicles_SetGrouping(selectedItem.Tag.ToString().Equals("categories") ? GroupType.GROUPNAME : GroupType.RADIOGATEWAY, false);
}
public void updateGwAndRagioGatewayForSubscriber(String radioID, String gwId, String radioGwId)
{
//Utils.WriteLine("updateGwAndRagioGatewayForSubscriber " + radioID, ConsoleColor.DarkMagenta);
vehiclesList.BeginUpdate();
foreach (DataforVehList item in ListforVehList)
{
if (item == null)
continue;
if (item.RadioId.Equals(radioID))
{
RadioGateway rg = MainForm2.myGatewaylist.Find(d => (gwId + "." + radioGwId).Equals(d.Gw_id + "." + d.Id));
item.RadioGateway = rg != null ? rg.Name : "unassigned";
item.NrOfUpdates++;
}
}
vehiclesList.EndUpdate();
}
public void CheckForUpdate(String unitName)
{
try
{
populateTableVehiclesList2(false, unitName);
}
catch (Exception ex)
{
SM.Debug("Unable to move unit on tab " + tabName + " ex:" + ex.ToString());
}
}
/// <summary>
///adjust controls sizes </summary>
private void AdjustSizes()
{
try
{
Size size = new Size();
mapControl.Size = size;
}
catch (Exception ex)
{
SM.Debug("Error on AdjustSizes:"+ex.ToString());
}
}
private Hashtable CheckedGroup = new Hashtable();
private volatile Hashtable CheckedGroupTmp = new Hashtable();
/// <summary>
///populates the list of vehicles from the left part of the tab </summary>
/// <param name="listOfVehicles">an array of strings containing the vehicles names</param>
public volatile List<DataforVehList> ListforVehList = new List<DataforVehList>();
volatile String GroupNameforgrid = "";
volatile Image Imageforgrid = null;
volatile String Statusforgrid = "";
volatile Int32 EmergStat = 0;
private void populateVehiclesList(ArrayList listOfVehicles)
{
SM.Debug("Before populate VehicleList");
try
{
ListforVehList.Clear();
vehiclesList.Columns["unitName"].SortOrder = RadSortOrder.None;
int cont = 0;
foreach (String obj in MainForm2.vehicleHT.Keys)
{
GroupNameforgrid = ((Vehicle)MainForm2.vehicleHT[obj]).group.Name;
/*MainForm2.returnLNGString("otherunit");
if (MainForm2.GrpIdforScId[((Vehicle)MainForm2.vehicleHT[obj]).sc_id] != null)
GroupNameforgrid = ((GroupClass)MainForm2.GrpIdforScId[((Vehicle)MainForm2.vehicleHT[obj]).sc_id]).name;
*/
Car crtCar = ((Car)MainForm2.carlist[((Vehicle)MainForm2.vehicleHT[obj]).IconID]);
if (crtCar == null)
{
Utils.WriteLine("nullllll", ConsoleColor.Cyan);
continue;
}
String iconPath = crtCar.listFilePath;
try
{
Bitmap bmp = new Bitmap(iconPath);
Image tmp2 = Utils.ScaleImage(bmp, 64, 64); //tmp.ToBitmap();
tmp2.Tag = crtCar.listFilePath;
// add image to the dictionary if not exists
if (!MainForm2.imagesDictionary.ContainsKey(crtCar.listFilePath))
MainForm2.imagesDictionary.Add(crtCar.listFilePath, tmp2);
// set the icon for the unit
Imageforgrid = MainForm2.imagesDictionary[crtCar.listFilePath];
}
catch (Exception)
{
SM.Debug("Grid icon could not be found [" + iconPath + "]");
Imageforgrid = imageList1.Images[2];
}
///new emergency status
EmergStat = 0;
if (((Vehicle)MainForm2.vehicleHT[obj]).is_emergency)
{
EmergStat = 1;
((Vehicle)MainForm2.vehicleHT[obj]).IconName.Replace(".png", "_FF79A6_l.png");
SetSymbol(((Vehicle)MainForm2.vehicleHT[obj]));
}
// get the
Vehicle veh = ((Vehicle)MainForm2.vehicleHT[obj]);
Statusforgrid = Vehicle.GetString_Status(veh.actual_status);
cont++;
RadioGateway rg = MainForm2.myGatewaylist.Find(d => (veh.GwandRadioID).Equals(d.Gw_id + "." + d.Id));
String gatewayName = rg == null ? "unassigned" : rg.Name;
// add vehicle with position to the list
ListforVehList.Add(new DataforVehList()
{
RadioId = veh.IMEI,
SipId = veh.sipID,
GrpName = GroupNameforgrid,
Pict = Imageforgrid,
UnitName = obj,
OnMap = veh.is_displayed,
UnitStatus = veh.actual_status,
Status = Statusforgrid,
Emerg0off1on = EmergStat,
IsEmergency = veh.is_emergency,
Latitude = veh.LAT,
Longitude = veh.LNG,
Address = veh.GetLastAddress(),
PositionTime = veh.lastActivityTime.ConvertGMTToLocal().GetDTFromSeconds(), //lastValidPositionTime)),
Speed = veh.GetSpeed(),
IsMPH = MainForm2.isInMile,
HasAlerts = false,
HasVoice = veh.has_voice,
HasText = veh.has_text,
Stolen = veh.is_stolen,
RadioGateway = gatewayName
});
}
try
{
// set data source and refresh it
vehiclesList.DataSource = null;
vehiclesList.DataSource = ListforVehList;
}
catch (Exception ex)
{
SM.Debug("Error on populate grid" + ex.ToString());
}
vehiclesList.Columns["unitName"].SortOrder = RadSortOrder.Ascending;
vehiclesList.MasterTemplate.GroupDescriptors.Clear();
GroupDescriptor groupDescriptor = new GroupDescriptor();
groupDescriptor.GroupNames.Add(vehiclesList.Columns["GroupName"].Name, ListSortDirection.Ascending);
vehiclesList.GroupDescriptors.Add(groupDescriptor);
CheckedGroup.Clear();
GridExpandAnimationType temp = vehiclesList.GroupExpandAnimationType;
vehiclesList.GroupExpandAnimationType = GridExpandAnimationType.None;
for (int i = 0; i < vehiclesList.Groups.Count; i++)
{
string key = this.tabName + "_" + "ExpandGroupingHT_" + (vehiclesList.Groups[i]).Key;
if (MainForm2.HashVal.ContainsKey(key))
{
if (Boolean.Parse(MainForm2.HashVal[key] + ""))
this.Expand(vehiclesList.Groups[i]);
}
else
{
this.Expand(vehiclesList.Groups[i]);
}
//vehiclesList.Groups[i].HeaderRow
CheckedGroup.Add(i, false);
}
vehiclesList.GroupExpandAnimationType = temp;
vehiclesList.TableElement.ScrollToRow(0);
}
catch (Exception ex)
{
SM.Debug("ExLive4:" + ex.ToString());
}
SM.Debug("Finish populate VehicleList");
}
private void Expand(DataGroup group)
{
try
{
group.Expand();
if (group.Groups.Count > 0)
{
for (int i = 0; i < group.Groups.Count; i++)
{
this.Expand(group.Groups[i]);
}
}
}
catch (Exception ex)
{
SM.Debug("Ex:" + ex.ToString());
}
}
volatile Boolean EnableAction = true;
volatile List<DataforGRID> ListforGrid = new List<DataforGRID>();
public void populateTableVehiclesList2(Boolean Refresh, String unitName)
{
Int32 oldColomnSort = 0;
RadSortOrder oldSortType = RadSortOrder.Ascending;
EnableAction = false;
try
{
Vehicle vehicleTemp;
if (Refresh)
{
ListforGrid.Clear(); //aici e combinatia fatala
try
{
for (int i = 0; i < tableVehiclesList.Columns.Count; i++)
{
if (tableVehiclesList.Columns[i].SortOrder != RadSortOrder.None)
{
oldColomnSort = i;
oldSortType = tableVehiclesList.Columns[i].SortOrder;
break;
}
}
}
catch (Exception ex)
{
SM.Debug("Error on finding the sort column:" + ex.ToString());
}
tableVehiclesList.Columns["VehName"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["datetime"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["address"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["speed"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["head"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["di"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["do"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["lat"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["lng"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["zone"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["Altitude"].SortOrder = RadSortOrder.None;
Thread.Sleep(100);
}
int countlist = -1;
String LatStr = "";
String LngStr = "";
String AltStr = "";
String Zone;
Double LatDou, LngDou;
if (MainForm2.LatLngUTM.CompareTo("Lat/Lng No.") == 0)
{
tableVehiclesList.Columns["lat"].HeaderText = latname;
tableVehiclesList.Columns["lng"].HeaderText = lngname;
tableVehiclesList.Columns["zone"].HeaderText = "";
tableVehiclesList.Columns["Altitude"].HeaderText = altname;
}
else if (MainForm2.LatLngUTM.CompareTo("Lat/Lng Deg.") == 0)
{
tableVehiclesList.Columns["lat"].HeaderText = latname;
tableVehiclesList.Columns["lng"].HeaderText = lngname;
tableVehiclesList.Columns["zone"].HeaderText = "";
tableVehiclesList.Columns["Altitude"].HeaderText = altname;
}
else if (MainForm2.LatLngUTM.CompareTo("UTM") == 0)
{
tableVehiclesList.Columns["lat"].HeaderText = "X";
tableVehiclesList.Columns["lng"].HeaderText = "Y";
tableVehiclesList.Columns["zone"].HeaderText = zonename;
tableVehiclesList.Columns["Altitude"].HeaderText = altname;
}
// flag that an update will be made
//gridVehicles.TableElement.BeginUpdate();
//ListforGrid.Clear();
for (int contor = 0; contor < vehiclesList.Rows.Count; contor++)
{
// get current vehicle which is updated
vehicleTemp = (Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[contor].Cells["UnitName"].Value];
// get the Data bound item for each grid row
DataforVehList gridData = vehiclesList.Rows[contor].DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
{
// skip this unit if it doesn't need to be updated
if (unitName != null && !gridData.UnitName.Equals(unitName))
;
else
{
// save previous values
string prevStatus = gridData.PreviousStatus;
string prevTimeAgo = gridData.PositionTimeAgo;
// remove null values to empty ones
if (prevStatus == null)
prevStatus = "";
if (prevTimeAgo == null)
prevTimeAgo = "";
// update all the new fields and values
gridData.Address = vehicleTemp.lastAddress;
gridData.PositionTime = vehicleTemp.lastValidPositionTime.ConvertGMTToLocal().GetDTFromSeconds();
gridData.Latitude = vehicleTemp.LAT;
gridData.Longitude = vehicleTemp.LNG;
gridData.Speed = vehicleTemp.GetSpeed();
gridData.UnitStatus = vehicleTemp.actual_status;
gridData.Status = Vehicle.GetString_Status(vehicleTemp.actual_status); ;
// check to see if the status has changed
if (!prevStatus.Equals(gridData.Status))
{
Utils.WriteLine("REFRESH GROUPS BY STATUS " + " [" + prevStatus + " -> " + gridData.Status + "]", ConsoleColor.Yellow);
// refresh the grid only if the group is STATUS
if (groupType == GroupType.STATUS)
gridVehicles_SetGrouping(groupType, false);
}
// check if the position had changed the ago time which needs to be displayed
if (!prevTimeAgo.Equals(Utils.GetDateTimeAgo(gridData.PositionTime)))
{
Utils.WriteLine("REFRESH GROUPS BY TIME", ConsoleColor.Yellow);
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
// refresh the grid only if the group is POSITION TIME
if (groupType == GroupType.POSITIONTIMEAGO)
gridVehicles_SetGrouping(groupType, false);
}
}
}
// if the update was as a result of a position received
if (unitName != null && gridData.UnitName.Equals(unitName))
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
}
}
catch (Exception ex)
{
SM.Debug("EXLive6:" + ex.ToString());
}
EnableAction = true;
}
/// <summary>
///Deletes all used resources
///</summary>
public void Delete()
{
try
{
timerAddPlace.Stop();
timerAddPlace.Enabled = false;
try
{
parent.isCanceled[tabName] = false;
if (this.app != null)
{
app.Quit();
app = null;
}
Thread.Sleep(100);
Killtimer.Enabled = true;
Killtimer.Start();
//this.mapControl.Dispose();
Killtimer.Stop();
this.mapControl = null;
this.Dispose();
GC.Collect();
}
catch (Exception ex)
{
SM.Debug("Exception on close LIVETabGIS " + ex.ToString());
}
}
catch (Exception ex)
{
SM.Debug("Error on delete live :"+ex.ToString());
}
}
public delegate void UpdateVehListInvokeCallBack(String name, Boolean withoutReset);
private Object thisLock = new Object();
private void UpdateDataGridUnit(String unitName)
{
// find the subscriber in the datasource
DataforVehList result = ListforVehList.Find(d => d.UnitName.Equals(unitName));
// get current vehicle which is updated
Vehicle vehicleTemp = (Vehicle)MainForm2.vehicleHT[unitName];
// update the favorite if found
if (result != null)
{
lock (thisLock)
{
vehiclesList.BeginEdit();
// save previous values
int prevSpeed = result.Speed;
string prevStatus = result.PreviousStatus;
string prevTimeAgo = result.PositionTimeAgo;
// remove null values to empty ones
if (prevStatus == null)
prevStatus = "";
if (prevTimeAgo == null)
prevTimeAgo = "";
// update all the new fields and values
result.Address = vehicleTemp.lastAddress;
result.PositionTime = vehicleTemp.lastActivityTime.ConvertGMTToLocal().GetDTFromSeconds(); // lastValidPositionTime));
result.Latitude = vehicleTemp.LAT;
result.Longitude = vehicleTemp.LNG;
result.Speed = vehicleTemp.GetSpeed();
result.UnitStatus = vehicleTemp.actual_status;
result.Status = Vehicle.GetString_Status(vehicleTemp.actual_status);
result.IsEmergency = vehicleTemp.is_emergency;
result.Stolen = vehicleTemp.is_stolen;
// check to see if the status has changed
if (!prevStatus.Equals(result.Status) || prevSpeed != result.Speed)
{
//Utils.WriteLine("REFRESH GROUPS BY STATUS " + " [" + prevStatus + " -> " + gridData.Status + "]", ConsoleColor.Yellow);
// notify that an update must be made
result.NrOfUpdates = result.NrOfUpdates + 1;
}
// check if the position had changed the ago time which needs to be displayed
if (!prevTimeAgo.Equals(Utils.GetDateTimeAgo(result.PositionTime)))
{
//Utils.WriteLine("REFRESH GROUPS BY TIME", ConsoleColor.Yellow);
// notify that an update must be made
result.NrOfUpdates = result.NrOfUpdates + 1;
}
vehiclesList.EndEdit();
// check to see if the status has changed
if (!prevStatus.Equals(result.Status))
{
// refresh the grid only if the group is STATUS
if (groupType == GroupType.STATUS)
{
vehiclesList.BeginUpdate();
gridVehicles_SetGrouping(groupType, false);
vehiclesList.EndUpdate();
}
}
// check if the position had changed the ago time which needs to be displayed
if (!prevTimeAgo.Equals(Utils.GetDateTimeAgo(result.PositionTime)))
{
// refresh the grid only if the group is POSITION TIME
if (groupType == GroupType.POSITIONTIMEAGO)
{
vehiclesList.BeginUpdate();
gridVehicles_SetGrouping(groupType, false);
vehiclesList.EndUpdate();
}
}
}
}
}
public void SetSymbol(Vehicle veh)
{
try
{
IPictureMarkerSymbol bitmapPictureMarkerSymbolCls = new
ESRI.ArcGIS.Display.PictureMarkerSymbolClass();
//check if bmp file is saved for emergency
2024-06-07 13:20:57 +00:00
string fileNamePattern = veh.IconName.Split("/".ToCharArray())[1].Split(".".ToCharArray())[0];
2024-02-22 16:43:59 +00:00
string filePath = System.Windows.Forms.Application.StartupPath + @"\resource\cars\" + fileNamePattern + ".png";
Image ArcgisImage = null;
veh.IconID = veh.is_emergency ? 10000 + veh.IconID : veh.IconID % 10000;
if (!MainForm2.carlist.ContainsKey(veh.IconID))
{
MainForm2.carlist.Add(veh.IconID, new Car());
}
if (!File.Exists(filePath))
{
MainForm2.CheckCreateEmergencyIcon(veh.IconID % 10000);
IconHelper.CheckCreateEmergencyIcon(veh.IconID % 10000);
}
ArcgisImage = Image.FromFile(filePath, true);
ArcgisImage.Save(System.Windows.Forms.Application.StartupPath + @"\resource\cars\" + fileNamePattern + ".bmp", ImageFormat.Bmp);
bitmapPictureMarkerSymbolCls.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, filePath.Replace("png", "bmp"));
bitmapPictureMarkerSymbolCls.Angle = 0;//Minicar
RgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColor();
rgbColor.Red = 255;
rgbColor.Green = 255;
rgbColor.Blue = 255;
bitmapPictureMarkerSymbolCls.BitmapTransparencyColor = rgbColor;
bitmapPictureMarkerSymbolCls.Size = 24;
bitmapPictureMarkerSymbolCls.XOffset = -12;
bitmapPictureMarkerSymbolCls.YOffset = -12;
((Car)MainForm2.carlist[veh.IconID]).GISsymb = bitmapPictureMarkerSymbolCls;
((Car)MainForm2.carlist[veh.IconID]).SymbGIS[tabName] = m_graphicTracker?.CreateSymbol(((Car)MainForm2.carlist[veh.IconID]).GISsymb as ISymbol, null);
}
catch(Exception ex)
{ Utils.WriteLine(ex.ToString(), ConsoleColor.Red); }
}
public void onEmergencyStateChangedHandler(Vehicle veh, Boolean isEmergency)
{
//update status for unit
this.Invoke((MethodInvoker)delegate ()
{
veh.actual_status = isEmergency ? Status_for_tab.EMERG : Status_for_tab.MADEON;
veh.is_emergency = isEmergency;
try
{
//create bitmap based on png file
//set the red icon for unit
SetSymbol(veh);
if (isEmergency)
{
((MapElement)((Vehicle)MainForm2.vehicleHT[veh.busName]).MapsHT[tabName])?.DeactivatePushpin();
//
MainForm2.POLLunit = veh.busName;
if ((Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG) != 0))
{
if (((MapElement)(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).MapsHT[tabName])).isActive) ;
else
{
//vehiclesList.SelectedRows[0].Cells["OnMap"].Value = true;
displayButton.PerformClick();
}
mapControl.Extent = MainForm2.ZoomTo(veh.LNG, veh.LAT, veh.LNG, veh.LAT);
}
}
}
catch (Exception ex)
{
SM.Debug("Error on CENTER ON MAP " + ex.ToString());
}
});
}
public void onUnitPositionOrStateChanged(String unitName)
{
//populateTableVehiclesList2(true, unitName);
UpdateDataGridUnit(unitName);
// refresh the grid if positions window is active
if (positionsWindowIsActive)
RefreshPositionsGrid(unitName);
}
public void RefreshPositionsGrid(string unitName)
{
for (int contor = 0; contor < tableVehiclesList.Rows.Count; contor++)
{
// get the Data bound item for each grid row
DataforGRID gridData = tableVehiclesList.Rows[contor].DataBoundItem as DataforGRID;
// verify if the unit is valid or not
if (gridData != null)
{
if (!unitName.Equals(gridData.VehName))
continue;
// get current vehicle which is updated
Vehicle vehicleTemp = (Vehicle)MainForm2.vehicleHT[gridData.VehName];
int countlist = -1;
String LatStr = "";
String LngStr = "";
String AltStr = "";
String Zone;
Double LatDou, LngDou;
LatLngUTM tmpLatLng = new LatLngUTM();
Zone = "";
AltStr = Math.Round(vehicleTemp.GetAlt(), 5).ToString();
if (MainForm2.LatLngUTM.CompareTo("Lat/Lng No.") == 0)
{
LatStr = Math.Round(vehicleTemp.GetLat(), 5).ToString();
LngStr = Math.Round(vehicleTemp.GetLng(), 5).ToString();
}
else if (MainForm2.LatLngUTM.CompareTo("Lat/Lng Deg.") == 0)
tmpLatLng.LatLongtoDeg(vehicleTemp.GetLat(), vehicleTemp.GetLng(), out LatStr, out LngStr);
else if (MainForm2.LatLngUTM.CompareTo("UTM") == 0)
{
tmpLatLng.LatLongtoUTM(vehicleTemp.GetLat(), vehicleTemp.GetLng(), out LatDou, out LngDou, out Zone);
LatStr = LatDou.ToString("###,###,###");
LngStr = LngDou.ToString("###,###,###");
}
gridData.Address = vehicleTemp.GetLastAddress();
gridData.Datatime = (vehicleTemp.lastActivityTime).ConvertGMTToLocal().GetDTFromSeconds();
gridData.Speed = Convert.ToString(vehicleTemp.GetSpeed());
gridData.DI = Convert.ToString(vehicleTemp.GetDI());
gridData.DO = Convert.ToString(vehicleTemp.GetDO());
if (!((Math.Round(vehicleTemp.GetLat()) == 0) && (Math.Round(vehicleTemp.GetLng()) == 0)))
{
gridData.Alt = Convert.ToString(AltStr);
gridData.Lat = Convert.ToString(LatStr);
gridData.Lng = Convert.ToString(LngStr);
gridData.Zone = zonename;
gridData.Head = Utils.GetDirection(vehicleTemp.GetHeading()).ToString();
}
else
{
gridData.Alt = gridData.Lat = gridData.Lng = "N/A";
gridData.Zone = "";
gridData.Head = "N/A";
}
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
}
}
//foreach()
}
public void OnUnitStolenChanged(String unitName, Boolean isStolen)
{
//UpdateVehList(unitName, true);
UpdateDataGridUnit(unitName);
}
/// <summary>
///treats the click on Display Telerik.WinControls.UI.RadButton - centers map on selected vehicles </summary>
private void displayButton_Click(object sender, EventArgs e)
{
displayButton.Enabled = false;
try
{
centeredState = false;
ComputeCheckedVehicles(true);
mapControl.Extent = MainForm2.ZoomTo(LngminCAL, LatminCAL, LngmaxCAL, LatmaxCAL);
if (MainForm2.Displaywithname)
{
//if (docLoad) mapGoogles.Navigate("javascript:void(GWTcallback('" + "putLabels," + vehiclesDataSet.Name + "'))");
HideALLName = true;
}
else
{
if (HideALLName)
HideALLName = false;
}
//COMMENT TO BE REMOVED populateTableVehiclesList2(true, volVehName);
}
catch (Exception ex)
{
SM.Debug("Error on display Telerik.WinControls.UI.RadButton click" + ex.ToString());
}
displayButton.Enabled = true;
}
public Double LatmaxCAL = -90, LatminCAL = 90, LngmaxCAL = -180, LngminCAL = 180;
/// <summary>
///only displays on the map the selected vehicles </summary>
public void ComputeCheckedVehicles(bool displayButtonCase)
{
this.Invoke((MethodInvoker)delegate ()
{
int cont;
Int32 timenowsec = (int)DateTime.Now.GetSecondsLocalFromDT();
try
{
LatmaxCAL = -90; LatminCAL = 90; LngmaxCAL = -180; LngminCAL = 180;
if (displayButtonCase)
{
foreach (DataforVehList obj2 in (List<DataforVehList>)vehiclesList.DataSource)
{
if ((bool)obj2.OnMap)
{
try
{
if (!((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).itemCheck)
{
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).itemCheck = true;
if ((parent.NoteAddr[obj2.UnitName] == null))
parent.NoteAddr.Add(obj2.UnitName, "none");
else
parent.NoteAddr[obj2.UnitName] = "none";
//((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).ActivatePushPin();
}
if ((Math.Round(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).LAT) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).LNG) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).LAT) != 0.1) && (Math.Round(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).LNG) != 0.1))
{
LatmaxCAL = Math.Max(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).lastLocLAT, LatmaxCAL);
LatminCAL = Math.Min(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).lastLocLAT, LatminCAL);
LngmaxCAL = Math.Max(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).lastLocLNG, LngmaxCAL);
LngminCAL = Math.Min(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).lastLocLNG, LngminCAL);
}
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).ActivatePushPin();
if (((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).GISID > 0)
m_graphicTracker.Highlight(((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).GISID, false);
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).GISSelect = false;
if (MainForm2.Displaywithname) ((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).Updatelabel(((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).busName, 1);
else ((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).Updatelabel("", 1);
if (MainForm2.HideInactiveUnitsCheck)
if (((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).lastActivityTime < (timenowsec - (MainForm2.Livelastmin * 60)))
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).DeactivatePushpin();
}
catch (Exception ex)
{
SM.Debug("Error in compute display not click: " + ex.ToString());
}
}
else
{
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).itemCheck = false;
if (((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).GISID != -1)
{
((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).DeactivatePushpin();
if (((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).selectCenter)
{
((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).selectCenter = false;
centeredState = false;
}
}
}
if (((MapElement)((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).MapsHT[tabName]).GISID != -1)
((Vehicle)MainForm2.vehicleHT[obj2.UnitName]).selectCenter = false;
}
}
else
{
for (cont = 0; cont < vehiclesList.Rows.Count; cont++)
{
if ((bool)vehiclesList.Rows[cont].Cells["OnMap"].Value)
{
try
{
((MapElement)((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[cont].Cells["UnitName"].Value]).MapsHT[tabName]).ActivatePushPin();
if (MainForm2.HideInactiveUnitsCheck)
if (((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[cont].Cells["UnitName"].Value]).lastActivityTime < (timenowsec - (MainForm2.Livelastmin * 60)))
((MapElement)((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[cont].Cells["UnitName"].Value]).MapsHT[tabName]).DeactivatePushpin();
}
catch (Exception ex)
{
SM.Debug("Error in compute not Button Click: " + ex.ToString());
}
}
}
}
}
catch (Exception x)
{
SM.Debug("Erorr compute checked vehicle " + x.ToString());
}
});
}
public void ForceUnitState(String Name, Boolean check)
{
try
{
vehiclesList.TableElement.BeginUpdate();
foreach (DataforVehList obj2 in (List<DataforVehList>)vehiclesList.DataSource)
{
if (obj2.UnitName.CompareTo(Name) == 0)
{
obj2.OnMap = check;
break;
}
}
vehiclesList.TableElement.EndUpdate(false);
vehiclesList.TableElement.Update(GridUINotifyAction.DataChanged);
vehiclesList.Refresh();
}
catch (Exception x)
{
SM.Debug("Erorr on ForceUnitState: " + x.ToString());
}
}
/// <summary>
///Catches the event when
///the user inputs/deletes a character in/from the search box,
///and the vehicles list is refreshed accordingly </summary>
private void searchTextBox_TextChanged(object sender, EventArgs e)
{
try
{
//RefreshVehiclesList();
FilterGridVehicles(searchTextBox.Text);
}
catch (Exception x)
{
SM.Debug("Erorr on searchTextBox_TextChanged: " + x.ToString());
}
}
private void Killtimer_Tick(object sender, EventArgs e)
{
if (MainForm2.ClosingApp)
KillTimerActive = true;
}
private void sendPOLLToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
smdbObj.Send_cmd_to_val(false, ((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value]).IMEI, "");
}
catch (Exception ex)
{
SM.Debug("Cann't send POLL cmd" + ex.ToString());
}
}
private void sel_desel_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
seldeselALL(sel_desel.Checked);
}
public void seldeselALL(bool state)
{
for (int i = 0; i < vehiclesList.Groups.Count; i++)
{
//GridViewRowInfo groupHeaderRow = gridVehicles.Groups[i].GroupRow;
GroupCheckBox_StateChanged(null, new GRPEventArgs(i, state));
//gridVehicles.Groups[i].GroupRow.ViewInfo.ChildRows
DataGroup dg = (vehiclesList.Groups[i]) as DataGroup;
//dg.GroupRow.
}
}
private void vehiclesList_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
try
{
if (e.ContextMenuProvider is GridHeaderCellElement)
{
// e.ContextMenu = columnHeaderMenu;
}
else if (e.ContextMenuProvider is GridDataCellElement || e.ContextMenuProvider is LiveGridCellElement)
{
GridViewRowInfo row =
(e.ContextMenuProvider is LiveGridCellElement ?
((LiveGridCellElement)e.ContextMenuProvider).RowInfo as GridViewDataRowInfo :
((GridDataCellElement)e.ContextMenuProvider).RowInfo);
RadDropDownMenu TelemMenu = new RadDropDownMenu();
if ((!MainForm2.LimitedUser) && (MainForm2.radioType != RADIOTYPE.ATLAS) && (MainForm2.radioType != RADIOTYPE.TETRA) && (MainForm2.radioType != RADIOTYPE.CONECTPLUS)
&& (MainForm2.radioType != RADIOTYPE.SIMOCO) && (MainForm2.radioType != RADIOTYPE.EXCERA))
{
if (!((Vehicle)MainForm2.vehicleHT[(String)row.Cells["UnitName"].Value]).canMakeSipCalls)
{
RadMenuItem tmpItem2 = new RadMenuItem(MainForm2.returnLNGString("enRadio"));
tmpItem2.Image = Dispatcher.Properties.Resources.l_menu_enable;
tmpItem2.Click += new EventHandler(SendRadioEnable_Click);
TelemMenu.Items.Add(tmpItem2);
RadMenuItem tmpItem3 = new RadMenuItem(MainForm2.returnLNGString("disRadio"));
tmpItem3.Image = Dispatcher.Properties.Resources.l_menu_disable;
tmpItem3.Click += new EventHandler(SendRadioDisable_Click);
TelemMenu.Items.Add(tmpItem3);
}
}
if (docLoad)
{
if ((MainForm2.radioType != RADIOTYPE.EXCERA))
{
RadMenuItem tmpItem4 = new RadMenuItem(MainForm2.returnLNGString("poll"));
tmpItem4.Image = Dispatcher.Properties.Resources.l_menu_poll;
tmpItem4.Click += new EventHandler(SendPOLL_Click);
TelemMenu.Items.Add(tmpItem4);
}
}
if ((MainForm2.radioType == RADIOTYPE.HYT) || (MainForm2.radioType == RADIOTYPE.HARRIS) ||
(MainForm2.radioType == RADIOTYPE.SIMOCO) || (MainForm2.radioType == RADIOTYPE.EXCERA))
{
RadMenuItem tmpItem6 = new RadMenuItem(MainForm2.returnLNGString("radcheck"));
tmpItem6.Click += new EventHandler(SendPOLLARS_Click);
TelemMenu.Items.Add(tmpItem6);
}
RadMenuItem tmpItem5 = null;
//markasstolen
if ((!MainForm2.LimitedUser) && (MainForm2.radioType != RADIOTYPE.ATLAS) && (MainForm2.radioType != RADIOTYPE.TETRA)
&& (MainForm2.radioType != RADIOTYPE.CONECTPLUS)
&& (MainForm2.radioType != RADIOTYPE.SIMOCO) && (MainForm2.radioType != RADIOTYPE.EXCERA))
{
if (!((Vehicle)MainForm2.vehicleHT[(String)row.Cells["UnitName"].Value]).is_stolen)
{
tmpItem5 = new RadMenuItem(MainForm2.returnLNGString("markasstolen"));
tmpItem5.Image = Dispatcher.Properties.Resources.l_menu_stolen;
tmpItem5.Click += new EventHandler(SendStolen_Click);
TelemMenu.Items.Add(tmpItem5);
}
else
{
tmpItem5 = new RadMenuItem(MainForm2.returnLNGString("unmarkasstolen"));
tmpItem5.Image = Dispatcher.Properties.Resources.l_menu_unstolen;
tmpItem5.Click += new EventHandler(SendUNStolen_Click);
TelemMenu.Items.Add(tmpItem5);
}
}
RadMenuItem tmpItem7 = null;
int sc_id = (((Vehicle)MainForm2.vehicleHT[(String)row.Cells["UnitName"].Value])).sc_id;
DBalarmManager dbalm = new DBalarmManager(MainForm2.cfg.DB_IP, MainForm2.cfg.DB_schema, MainForm2.cfg.DB_user, MainForm2.cfg.DB_passwd, MainForm2.cfg.DB_port);
int alarmsCounter = dbalm.Get_nonACK_alarms(sc_id).Count;
if (alarmsCounter > 0)
{
tmpItem7 = new RadMenuItem(MainForm2.returnLNGString("alarmALLACK"));
tmpItem7.Click += new EventHandler(AckAlarmForUnit_Click);
TelemMenu.Items.Add(tmpItem7);
}
TelemMenu.Items.Add(new RadMenuSeparatorItem() { BackColor = MainForm2.ButtonColor, Padding = new Padding(0, 8, 0, 0) });
string unitName = (String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value;
string groupName = (((Vehicle)MainForm2.vehicleHT[unitName])).group.Name;
RadMenuItem tmpItemDisplay = new RadMenuItem(String.Format(MainForm2.returnLNGString("displayGroup"), groupName));
tmpItemDisplay.Tag = groupName;
tmpItemDisplay.Image = Dispatcher.Properties.Resources.l_menu_display;
tmpItemDisplay.Click += new EventHandler(delegate (object s, EventArgs e2)
{
String group_name = ((RadMenuItem)s).Tag.ToString();
GroupCheckBox_StateChanged(group_name,true);
});
TelemMenu.Items.Add(tmpItemDisplay);
RadMenuItem tmpItemHide = new RadMenuItem(String.Format(MainForm2.returnLNGString("hideGroup"), groupName));
tmpItemHide.Tag = groupName;
tmpItemHide.Image = Dispatcher.Properties.Resources.l_menu_hide;
tmpItemHide.Click += new EventHandler(delegate (object s, EventArgs e2)
{
String group_name = ((RadMenuItem)s).Tag.ToString();
GroupCheckBox_StateChanged(group_name, false);
});
TelemMenu.Items.Add(tmpItemHide);
if (MainForm2.GroupHash.Count > 0)
{
TelemMenu.Items.Add(new RadMenuSeparatorItem() { BackColor = MainForm2.ButtonColor, Padding = new Padding(0, 8, 0, 0) });
RadMenuItem tmpShowAll = new RadMenuItem(String.Format(MainForm2.returnLNGString("displayAllUnits"), groupName));
tmpShowAll.Image = Dispatcher.Properties.Resources.l_menu_display_all;
tmpShowAll.Click += new EventHandler(delegate (object s, EventArgs e2)
{
seldeselALL(true);
});
TelemMenu.Items.Add(tmpShowAll);
RadMenuItem tmpHideAll = new RadMenuItem(String.Format(MainForm2.returnLNGString("hideAllUnits"), groupName));
tmpHideAll.Tag = groupName;
tmpHideAll.Image = Dispatcher.Properties.Resources.l_menu_hide_all;
tmpHideAll.Click += new EventHandler(delegate (object s, EventArgs e2)
{
seldeselALL(false);
});
TelemMenu.Items.Add(tmpHideAll);
}
e.ContextMenu = TelemMenu;
}
}
catch (Exception ex)
{
SM.Debug("EXLive10:" + ex.ToString());
}
}
void AckAlarmForUnit_Click(object sender, EventArgs e)
{
try
{
//AlarmTypes type = (((Vehicle)MainForm2.vehicleHT[(String)gridVehicles.SelectedRows[0].Cells["UnitName"].Value])).EventLists.Contains;
//AlarmTypes type = AlarmTypes.emergency;
string unitName = (String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value;
int sc_id = (((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value])).sc_id;
DBalarmManager dbalm = new DBalarmManager(MainForm2.cfg.DB_IP, MainForm2.cfg.DB_schema, MainForm2.cfg.DB_user, MainForm2.cfg.DB_passwd, MainForm2.cfg.DB_port);
bool hasEmergencyActivated = dbalm.hasEmergencyActivated(sc_id);
dbalm.ACKALLalarms(sc_id, MainForm2.userIDX);
if (hasEmergencyActivated)
{
((Vehicle)MainForm2.vehicleHT[unitName]).is_emergency = false;
String Totrans = "#153#" + ((Vehicle)MainForm2.vehicleHT[unitName]).IMEI + "#" + (Int32)Status_for_tab.ON + "#";
parent.Send_UDP_cmd(Totrans, 0, 0);
Utils.WriteLine("Sending ALARM ACK to " + unitName);
//update GwandRadioID for current vehicle if is 0.0
((Vehicle)MainForm2.vehicleHT[unitName]).CheckPositionInSystem();
Totrans = "#238#" + ((Vehicle)MainForm2.vehicleHT[unitName]).GwandRadioID + "."
+ ((Vehicle)MainForm2.vehicleHT[unitName]).IMEI + "#";
parent.Send_UDP_cmd(Totrans, 0, 0);
Thread.Sleep(100);
MainForm2.UpdateStatusLive(unitName);
}
String Totrans2 = "#238#" + ((Vehicle)MainForm2.vehicleHT[unitName]).GwandRadioID + "."
+ ((Vehicle)MainForm2.vehicleHT[unitName]).IMEI + "#" + (int)AlarmTypes.unknown;
parent.Send_UDP_cmd(Totrans2, 0, 0);
//NEED TO DO SAME STUFF FROM PUT EMERGENCY IN RED
foreach (String name in ((Vehicle)MainForm2.vehicleHT[unitName]).MapsHT.Keys)
{
((Vehicle)MainForm2.vehicleHT[unitName]).is_emergency = false;
((MapElement)((Vehicle)MainForm2.vehicleHT[unitName]).MapsHT[name]).UpdateSymbol();
MainForm2.RemoveIconsFromMap();
}
Thread.Sleep(100);
MainForm2.UpdateStatusLive(unitName);
}
catch (Exception ex)
{
SM.Debug("EX:" + ex.ToString());
}
try
{
this.parent.AlarmTracking_Click(null, null);
((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value]).EventLists = new ArrayList();
}
catch (Exception ex)
{
SM.Debug("EX:" + ex.ToString());
}
}
void SendRadioEnable_Click(object sender, EventArgs e)
{
try
{
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value,CMDTYPE.EnableCMD);
}
catch (Exception ex)
{
SM.Debug("Error on SendRadioEnable_Click " + ex.ToString());
}
}
void SendRadioDisable_Click(object sender, EventArgs e)
{
try
{
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value, CMDTYPE.DisableCMD);
}
catch (Exception ex)
{
SM.Debug("Error on SendRadioDisable_Click " + ex.ToString());
}
}
void SendStolen_Click(object sender, EventArgs e)
{
try
{
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value, CMDTYPE.StolenONCMD);
}
catch (Exception ex)
{
SM.Debug("Error on SendStolen_Click " + ex.ToString());
}
}
void SendUNStolen_Click(object sender, EventArgs e)
{
try
{
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value, CMDTYPE.StolenOFFCMD);
}
catch (Exception ex)
{
SM.Debug("Error on SendUNStolen_Click " + ex.ToString());
}
}
void SendPOLLARS_Click(object sender, EventArgs e)
{
try
{
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value, CMDTYPE.POLLARSCMD);
}
catch (Exception ex)
{
SM.Debug("Error on SendPOLLARS_Click " + ex.ToString());
}
}
void SendPOLL_Click(object sender, EventArgs e)
{
try
{
// 2 -- POLL UNIT
parent.Send_EnableOrDisable((String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value, CMDTYPE.POLLGPSCMD);
MainForm2.POLLunit = (String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value;
if ((Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG) != 0))
{
if (((MapElement)(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).MapsHT[tabName])).isActive) ;
else
{
vehiclesList.SelectedRows[0].Cells["OnMap"].Value = true;
displayButton.PerformClick();
}
mapControl.Extent = MainForm2.ZoomTo(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG, ((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT);
}
}
catch (Exception ex)
{
SM.Debug("Error on SendPOLL_Click " + ex.ToString());
}
}
private void vehiclesList_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
GridViewDataRowInfo row = e.Row as GridViewDataRowInfo;
if (row != null)
{
DataforVehList gridData = row.DataBoundItem as DataforVehList;
if (gridData != null)
{
//gridVehicles.BeginUpdate();
// change the state of displayed/not Displayed on the map
gridData.OnMap = !gridData.OnMap;
//gridVehicles.EndUpdate(true);
//gridVehicles.TableElement.Update(GridUINotifyAction.DataChanged);
displayButton.PerformClick();
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
}
}
}
private void ckShowLand_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
try
{
if (ckShowLand.Checked) placeSymb = new PlaceSymbolsGIS(placeSet, tabName);
MainForm2.simpleTextSymbol.YOffset = 20;
Int32 Idgen = 0;
if (loadfinish) placeSet.RemoveAll();
if (ckShowLand.Checked)
{
try
{
ArrayList tmp = smdbObj.get_all_places_GIS("");
foreach (Place obj in tmp)
{
IPoint point = new ESRI.ArcGIS.Geometry.Point();
point.PutCoords(obj.lng, obj.lat);
point.SpatialReference = MainForm2.CreateGeoCoordSys();
Idgen = placeSet.Add(point as IGeometry, ((IGraphicTrackerSymbol)((Place)MainForm2.PlaceTypesGIS[obj.type + obj.color + obj.iconSize]).SymbGIS[tabName]));
MainForm2.simpleTextSymbol.YOffset = 20;
placeSet.SetTextSymbol(Idgen, MainForm2.simpleTextSymbol);
placeSet.SetLabel(Idgen, obj.name + "\n" + obj.desc);
}
}
catch (Exception ex)
{
SM.Debug("Error on put place on live:" + ex.ToString());
}
}
}
catch (Exception ex)
{
SM.Debug("Error on ckShowLand_ToggleStateChanged:" + ex.ToString());
}
}
ArrayList ElementsZone = new ArrayList();
private void ckShowZone_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
try
{
if (ckShowZone.Checked) ForceShowZone();
else ForceHideZone();
}
catch (Exception ex)
{
SM.Debug("Error on ckShowZone_ToggleStateChanged:" + ex.ToString());
}
}
public void ForceShowZone()
{
try
{
object Missing = Type.Missing;
IElement element = null;
Boolean First = true;
Int32 pas = -1;
Double LatMN = 0, LatMX = 0, LngMN = 0, LngMX = 0;
Boolean first = true;
Double latfirst = 0, lngfirst = 0;
int cont = 0;
Boolean retur = false;
ElementsZone.Clear();
foreach (Int32 obj3 in MainForm2.ZoneIDHash.Keys)
{
IPolyline newPath = new PolylineClass();
IPointCollection newPointCollection = newPath as IPointCollection;
ZoneClass obj2 = (ZoneClass)MainForm2.ZoneIDHash[obj3];
pas++;
first = true;
foreach (PointonZone obj in obj2.arrSc_id)
{
if (First)
{
LatMN = obj.lat; LatMX = obj.lat;
LngMN = obj.lng; LngMX = obj.lng;
First = false;
}
if (first)
{
latfirst = obj.lat;
lngfirst = obj.lng;
first = false;
}
LatMN = System.Math.Min(obj.lat - 0.000, LatMN); LatMX = System.Math.Max(LatMX, obj.lat + 0.000);
LngMN = System.Math.Min(obj.lng - 0.000, LngMN); LngMX = System.Math.Max(LngMX, obj.lng + 0.000);
//datasetCMD = datasetCMD + MainForm2.FixDouble(obj.lat.ToString()) + "," + MainForm2.FixDouble(obj.lng.ToString()) + ",";
ESRI.ArcGIS.Geometry.IPoint fromPoint = new ESRI.ArcGIS.Geometry.PointClass();
fromPoint.PutCoords(obj.lng, obj.lat);
fromPoint.SpatialReference = MainForm2.CreateGeoCoordSys();
newPointCollection.AddPoint(fromPoint, ref Missing, ref Missing);
cont++;
}
if (cont > 2)
{
ESRI.ArcGIS.Geometry.IPoint fromPoint = new ESRI.ArcGIS.Geometry.PointClass();
fromPoint.PutCoords(lngfirst, latfirst);
fromPoint.SpatialReference = MainForm2.CreateGeoCoordSys();
newPointCollection.AddPoint(fromPoint, ref Missing, ref Missing);
Color colorOK = (new GetColorID()).getColorid(obj2.color);
ESRI.ArcGIS.Display.IColor color = new RgbColorClass() { Red = colorOK.R, Green = colorOK.G, Blue = colorOK.B }; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
simpleLineSymbol.Color = color;
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
simpleLineSymbol.Width = 3;
ILineElement lineElement = new LineElementClass();
lineElement.Symbol = simpleLineSymbol;
element = (IElement)lineElement; // Explicit Cast
element.Geometry = (IPolyline)newPointCollection;
IGraphicsContainer graphicsContainer = (IGraphicsContainer)mapControl.ActiveView;
graphicsContainer.AddElement(element, 0);
ElementsZone.Add(element);
}
retur = true;
}
if (retur)
{
try
{
mapControl.Extent = MainForm2.ZoomTo(LngMN, LatMN, LngMX, LatMX);
}
catch (Exception ex)
{
SM.Debug("Error zone preview:" + ex.ToString());
}
}
}
catch (Exception ex)
{
SM.Debug("Error on ForceShowZone:" + ex.ToString());
}
}
public void ForceHideZone()
{
try
{
IGraphicsContainer graphicsContainer = (IGraphicsContainer)mapControl.ActiveView;
foreach (IElement obj in ElementsZone)
graphicsContainer.DeleteElement(obj);
mapControl.ActiveView.Refresh();
}
catch (Exception ex)
{
SM.Debug("Unable to remove zones from map " + ex.ToString());
}
}
private void vehiclesList_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
{
try
{
string suff = String.Concat(" (", e.Group.ItemCount.ToString(), ")");
e.Group.Header = e.Group.Key + "";
if (e.FormatString.Contains(":"))
{
//e.FormatString = e.FormatString.Replace("GroupName:", "");
e.FormatString = e.Group.Key + " " + e.FormatString.Replace("{0}:", "");
}
if (!e.FormatString.EndsWith(suff))
{
e.FormatString = String.Concat(e.FormatString, suff);
}
}
catch (Exception ex)
{
SM.Debug("Erorr on GroupSummaryEvaluate" + ex.ToString());
}
}
Boolean loadfinish = false;
private void LiveTabGIS_Load(object sender, EventArgs e)
{
try
{
if (mapControl.CheckMxFile(MainForm2.ArcGisFileName)) mapControl.LoadMxFile(MainForm2.ArcGisFileName);
mapControl.SpatialReference = MainForm2.CreateGeoCoordSys();
//Get the MapControl
m_mapControl = (IMapControl3)mapControl.Object;
m_graphicTracker = new GraphicTrackerClass();
m_graphicTracker.Initialize(m_mapControl.Map as IBasicMap);
placeSet = new GraphicTrackerClass();
placeSet.Initialize(m_mapControl.Map as IBasicMap);
loadfinish = true;
displayButton.Enabled = true;
busSymb = new BusSymbolsGIS(m_graphicTracker, tabName);
//placeSymb = new PlaceSymbolsGIS(placeSet, tabName);
try
{
foreach (String obj in MainForm2.vehicleHT.Keys)
((Vehicle)MainForm2.vehicleHT[obj]).AddNewLiveGIS(tabName, m_graphicTracker, busSymb, mapControl);
}
catch (Exception ex)
{
SM.Debug("Error on init vehicle on new live tab:" + ex.Message);
}
ToolControl.AddItem(new SelectGT(m_graphicTracker, tabName));
}
catch (Exception ex)
{
SM.Debug("Erorr on LiveTabGIS_Load:" + ex.ToString());
}
}
private void StartOver500msec_Tick(object sender, EventArgs e)
{
try
{
//Load a pre-authored map document into the PageLayoutControl using relative paths.
//string fileName = @"E:\Cape Girardeau\GIS data\workspace.mxd";
}
catch (Exception ex)
{
SM.Debug("Erorr on StartOver500msec_Tick:" + ex.ToString());
}
}
/// <summary>
/// Set the type of data which will be displayed inside the grid
/// </summary>
private void vehiclesList_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
// format live column
if (e.Row is GridDataRowElement)
{
// increase row height
//e.Row.RowInfo.Height = 53;
if (e.Column.Name.Equals("live"))
{
e.CellType = typeof(LiveGridColumn);
e.CellElement = new LiveGridCellElement(e.Column, e.Row);
}
if (e.Column is GridViewIndentColumn)
{
}
}
}
private System.Threading.Timer timerCheck = null;
private void vehiclesList_CellClick(object sender, GridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
{
SM.Debug("Fire the timer");
if (timerCheck != null) timerCheck.Dispose();
timerCheck = new System.Threading.Timer(VerifyChecks, null, 2000, 2000);
}
}
//timer de verificat checkuri
private void VerifyChecks(object state)
{
try
{
this.Invoke(new CheckOnInvokeCallBack(CheckOnInvoke2));
}
catch (Exception ex)
{
SM.Debug("Ex:" + ex.ToString());
}
}
private void CheckOnInvoke2()
{
try
{
Boolean someCheck = false;
vehiclesList.TableElement.BeginUpdate();
vehiclesList.TableElement.EndUpdate(false);
vehiclesList.TableElement.Update(GridUINotifyAction.DataChanged);
vehiclesList.Refresh();
String selectedValue = "";
try
{
selectedValue = (String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value;
}
catch
{
selectedValue = " ";
}
SM.Debug("Verify Check");
CheckedGroupTmp.Clear();
foreach (DataforVehList obj2 in (List<DataforVehList>)vehiclesList.DataSource)
{
if ((obj2.OnMap) && (obj2.UnitName.CompareTo(selectedValue) != 0))
{
someCheck = true;
if (CheckedGroupTmp[obj2.GrpName] == null) CheckedGroupTmp.Add(obj2.GrpName, true);
}
}
for (int i = 0; i < vehiclesList.Groups.Count; i++)
if ((Boolean)CheckedGroup[i])
{
if (CheckedGroupTmp[vehiclesList.Groups[i].Header] == null)
{
int j = -1;
foreach (GridViewRowInfo row in this.vehiclesList.ChildRows)
{
j++;
GridViewGroupRowInfo groupRow = row as GridViewGroupRowInfo;
if ((groupRow != null) && (j == i))
{
groupRow.Tag = false;
CheckedGroup[i] = false;
break;
}
}
}
}
if ((sel_desel.Checked) && (!someCheck))
{
SM.Debug("Select all false");
sel_desel.Checked = false;
}
if (timerCheck != null) timerCheck.Dispose();
}
catch (Exception ex)
{
SM.Debug("Error backtop play" + ex.ToString());
}
}
public delegate void CheckOnInvokeCallBack();
private Font normalFont = new Font(new FontFamily("Segoe UI"), 8.0F, FontStyle.Regular);
private Font boldFont = new Font(new FontFamily("Segoe UI"), 8.0F, FontStyle.Bold);
public static GroupType groupType = GroupType.GROUPNAME;
public static ListSortDirection sortDirection = ListSortDirection.Ascending;
/// <summary>
/// Event Handler for when a filter picture box is clicked
/// This should group the grid based on it's status
/// </summary>
private void pbFilter_Click(object sender, EventArgs e)
{
// add image to the dictionary if not exists
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_status_g"))
MainForm2.imagesDictionary.Add("l_filter_status_g", Utils.MakeGrayscale3(global::Dispatcher.Properties.Resources.l_bullet_bl, 0.5f));
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_time_g"))
MainForm2.imagesDictionary.Add("l_filter_time_g", Utils.MakeGrayscale3(global::Dispatcher.Properties.Resources.l_history_b, 0.5f));
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_group_g"))
MainForm2.imagesDictionary.Add("l_filter_group_g", Utils.MakeGrayscale3(global::Dispatcher.Properties.Resources.l_user_n, 0.5f));
pbGroupTime.Image = MainForm2.imagesDictionary["l_filter_time_g"];
pbGroupStatusType.Image = MainForm2.imagesDictionary["l_filter_status_g"];
pbGroup.Image = MainForm2.imagesDictionary["l_filter_group_g"];
if ((PictureBox)sender == pbGroupTime)
{
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_time"))
MainForm2.imagesDictionary.Add("l_filter_time", global::Dispatcher.Properties.Resources.l_history_b);
pbGroupTime.Image = MainForm2.imagesDictionary["l_filter_time"];
groupType = GroupType.POSITIONTIMEAGO;
}
else if ((PictureBox)sender == pbGroupStatusType)
{
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_status"))
MainForm2.imagesDictionary.Add("l_filter_status", global::Dispatcher.Properties.Resources.l_bullet_bl);
pbGroupStatusType.Image = MainForm2.imagesDictionary["l_filter_status"];
groupType = GroupType.STATUS;
}
else if ((PictureBox)sender == pbGroup)
{
if (!MainForm2.imagesDictionary.ContainsKey("l_filter_group"))
MainForm2.imagesDictionary.Add("l_filter_group", global::Dispatcher.Properties.Resources.l_user_n);
pbGroup.Image = MainForm2.imagesDictionary["l_filter_group"];
groupType = GroupType.GROUPNAME;
}
// group the vehicles
gridVehicles_SetGrouping(groupType, true);
}
/// <summary>
/// Change the group type of the grid and mention if the reordering should be
/// made or not
/// </summary>
/// <param name="type">Sorting type which corresponds to the column</param>
/// <param name="changeOrder"></param>
private void gridVehicles_SetGrouping(GroupType type, bool changeOrder)
{
string filterName = "GroupName";
if (type == GroupType.GROUPNAME)
filterName = "GroupName";
else if (type == GroupType.POSITIONTIMEAGO)
filterName = "PositionTimeAgo";
else if (type == GroupType.STATUS)
filterName = "Status";
else if (type == GroupType.RADIOGATEWAY)
filterName = "RadioGateway";
if (changeOrder)
{
// reverse the sorting order
if (vehiclesList.GroupDescriptors.Count > 0 &&
vehiclesList.GroupDescriptors[0].Expression.Contains(filterName))
{
GroupDescriptor gd = vehiclesList.GroupDescriptors[0];
sortDirection = gd.Expression.Contains("ASC") ? ListSortDirection.Descending : ListSortDirection.Ascending;
}
else if (type == GroupType.POSITIONTIMEAGO)
{
// time ago should start as descending
sortDirection = ListSortDirection.Descending;
}
}
// clear previous filters and add the new one
vehiclesList.GroupDescriptors.Clear();
GroupDescriptor groupDescriptor = new GroupDescriptor(new SortDescriptor[] { new SortDescriptor(filterName, sortDirection) });
vehiclesList.GroupDescriptors.Add(groupDescriptor);
int i = 0;
CheckedGroup.Clear();
foreach (GridViewRowInfo groupRow in vehiclesList.ChildRows)
{
// the group has items
if (groupRow.ChildRows.Count > 0)
{
// group name is groupRow.Group.Header
bool areAllChecked = true;
foreach (GridViewRowInfo gridRow in groupRow.ChildRows)
{
// get the Data bound item for each grid row
DataforVehList gridData = gridRow.DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
{
if (!gridData.OnMap)
areAllChecked = false;
}
}
CheckedGroup.Add(i++, areAllChecked);
groupRow.IsExpanded = true;
if (groupRow != null && areAllChecked)
groupRow.Tag = true;
}
}
}
private void GroupCheckBox_StateChanged(string groupname, bool stat)
{
try
{
int nrstartPerf = 0;
bool StartPerf = false;
centeredState = false;
//SM.Debug("Send command to google");
//gridVehicles.TableElement.BeginUpdate();
//timerBegin = new System.Threading.Timer(MakeUpdateToListBegin, null, 300, System.Threading.Timeout.Infinite);
for (int contor = 0; contor < vehiclesList.Rows.Count; contor++)
{
// get current vehicle which is updated
Vehicle vehicleTemp = (Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[contor].Cells["UnitName"].Value];
// get the Data bound item for each grid row
DataforVehList gridData = vehiclesList.Rows[contor].DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
{
bool isInThisGroup = false;
if (groupType == GroupType.STATUS && gridData.Status.Equals(groupname))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Red);
isInThisGroup = true;
}
else if (groupType == GroupType.GROUPNAME && gridData.GrpName.Equals(groupname))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Yellow);
isInThisGroup = true;
}
else if (groupType == GroupType.POSITIONTIMEAGO && gridData.PositionTimeAgo.Equals(groupname))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Cyan);
isInThisGroup = true;
}
// make modifications only if the unit is in the group
if (isInThisGroup)
{
if (!gridData.OnMap && stat)
{
nrstartPerf++;
gridData.OnMap = true;
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).ActivatePushPin();
}
else if (!stat && gridData.OnMap)
{
gridData.OnMap = false;
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
if (((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp != null)
{
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp.Highlight = false;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp.BalloonState = GeoBalloonStatex.geoDisplayNone;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).DeactivatePushpin();
if (((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).selectCenter)
{
((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).selectCenter = false;
centeredState = false;
}
}
}
}
}
// if group is selected
if (stat)
{
if (StartPerf)
{
txProgStatus.Clear();
Console.WriteLine("Panel visibil false 3");
LivePanel.Visible = false;
txProgStatus.Visible = false;
Cursor = Cursors.Arrow;
//mapControl.MousePointer = GeoPointerx.geoPointerDefault;
}
}
//gridVehicles.TableElement.EndUpdate(false);
//gridVehicles.TableElement.Update(GridUINotifyAction.DataChanged);
displayButton.PerformClick();
}
}
catch (Exception ex)
{
SM.Debug("Error on select ALL: " + ex.ToString());
}
}
/// <summary>
/// Event handler for when the groupBox checkbox changes its state
/// </summary>
private void GroupCheckBox_StateChanged(object sender, GRPEventArgs e)
{
try
{
int nrstartPerf = 0;
bool StartPerf = false;
centeredState = false;
SM.Debug("Enter on custom cell customCell_MeCheckChanged with e.idx:" + e.idx);
if (e.stat != (Boolean)CheckedGroup[e.idx])
{
CheckedGroup[e.idx] = e.stat;
//SM.Debug("Send command to google");
//gridVehicles.TableElement.BeginUpdate();
//timerBegin = new System.Threading.Timer(MakeUpdateToListBegin, null, 300, System.Threading.Timeout.Infinite);
for (int contor = 0; contor < vehiclesList.Rows.Count; contor++)
{
// get current vehicle which is updated
Vehicle vehicleTemp = (Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[contor].Cells["UnitName"].Value];
// get the Data bound item for each grid row
DataforVehList gridData = vehiclesList.Rows[contor].DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
{
bool isInThisGroup = false;
if (groupType == GroupType.STATUS && gridData.Status.Equals(vehiclesList.Groups[e.idx].Header))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Red);
isInThisGroup = true;
}
else if (groupType == GroupType.GROUPNAME && gridData.GrpName.Equals(vehiclesList.Groups[e.idx].Header))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Yellow);
isInThisGroup = true;
}
else if (groupType == GroupType.POSITIONTIMEAGO && gridData.PositionTimeAgo.Equals(vehiclesList.Groups[e.idx].Header))
{
//Utils.WriteLine("THIS UNIT " + gridData.UnitName + " IS IN THIS GROUP " + vehiclesList.Groups[e.idx].Header, ConsoleColor.Cyan);
isInThisGroup = true;
}
// make modifications only if the unit is in the group
if (isInThisGroup)
{
if (!gridData.OnMap && e.stat)
{
nrstartPerf++;
gridData.OnMap = true;
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).ActivatePushPin();
}
else if (!e.stat && gridData.OnMap)
{
gridData.OnMap = false;
// notify that an update must be made
gridData.NrOfUpdates = gridData.NrOfUpdates + 1;
if (((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp != null)
{
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp.Highlight = false;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).pp.BalloonState = GeoBalloonStatex.geoDisplayNone;
((MapElement)((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).MapsHT[tabName]).DeactivatePushpin();
if (((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).selectCenter)
{
((Vehicle)MainForm2.vehicleHT[gridData.UnitName]).selectCenter = false;
centeredState = false;
}
}
}
}
}
}
// if group is selected
if (e.stat)
{
if (StartPerf)
{
txProgStatus.Clear();
Console.WriteLine("Panel visibil false 3");
LivePanel.Visible = false;
txProgStatus.Visible = false;
Cursor = Cursors.Arrow;
//mapControl.MousePointer = GeoPointerx.geoPointerDefault;
}
}
//gridVehicles.TableElement.EndUpdate(false);
//gridVehicles.TableElement.Update(GridUINotifyAction.DataChanged);
displayButton.PerformClick();
}
}
catch (Exception ex)
{
SM.Debug("Error on select ALL: " + ex.ToString());
}
}
private void vehiclesList_CustomGrouping(object sender, GridViewCustomGroupingEventArgs e)
{
string colName = vehiclesList.GroupDescriptors[e.Level].GroupNames[0].PropertyName;
if (colName == "PositionTimeAgo")
{
// get the Data bound item for each grid row
if (e.Row.DataBoundItem != null && e.Row.DataBoundItem is DataforVehList)
{
DataforVehList gridData = e.Row.DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
e.GroupKey = gridData.PositionTimeAgo; //new DateTime(gridData.PositionTime.Year, gridData.PositionTime.Month, gridData.PositionTime.Day);
}
}
else if (colName == "Status")
{
// get the Data bound item for each grid row
if (e.Row.DataBoundItem != null && e.Row.DataBoundItem is DataforVehList)
{
DataforVehList gridData = e.Row.DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
e.GroupKey = gridData.Status;
}
}
else if (colName == "GroupName")
{
// get the Data bound item for each grid row
if (e.Row.DataBoundItem != null && e.Row.DataBoundItem is DataforVehList)
{
DataforVehList gridData = e.Row.DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
e.GroupKey = gridData.GrpName;
}
}
else if (colName == "RadioGateway")
{
// get the Data bound item for each grid row
if (e.Row.DataBoundItem != null && e.Row.DataBoundItem is DataforVehList)
{
DataforVehList gridData = e.Row.DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
e.GroupKey = gridData.RadioGateway;
}
}
}
/// <summary>
/// Filter the vehicles grid based on a string patter
/// </summary>
/// <param name="vehicleName">Filter for vehicle name</param>
private void FilterGridVehicles(string vehicleName)
{
try
{
for (int i = 0; i < vehiclesList.Rows.Count; i++)
{
// get the Data bound item for each grid row
DataforVehList gridData = vehiclesList.Rows[i].DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null && gridData.UnitName.ToUpper().Contains(vehicleName.ToUpper()))
vehiclesList.Rows[i].IsVisible = true;
else
vehiclesList.Rows[i].IsVisible = false;
}
}
catch (Exception ex)
{
SM.Debug("ExLive8:" + ex.ToString());
}
}
private void vehiclesList_ViewCellFormatting_1(object sender, CellFormattingEventArgs e)
{
if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS))
{
if (e.CellElement is GridGroupContentCellElement)
{
e.CellElement.ForeColor = MainForm2.HarTextColor;
}
else
{
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}
}
if (e.CellElement.RowIndex >= 0)
{
//SM.Debug("VALUE OF THE BOX" + Convert.ToInt32(vehiclesList.Rows[e.CellElement.RowIndex].Cells[5].Value));
//if (Convert.ToInt32(vehiclesList.Rows[e.CellElement.RowIndex].Cells[5].Value) == 1)
if (Convert.ToInt32(e.Row.Cells["Emerg0off1on"].Value) == 1)
{
e.CellElement.ForeColor = Color.Red;
e.CellElement.Font = boldFont;
}
else
{
e.CellElement.ForeColor = Color.Black;
e.CellElement.Font = normalFont;
}
}
}
/// <summary>
/// Open a popup window which will desplay the desired info
/// </summary>
/// <param name="unitName"></param>
/// <param name="popupType"></param>
private void openPopupWindow(string unitName, EventType popupType)
{
try
{
if (MainForm2.PopupOpen[((Vehicle)MainForm2.vehicleHT[unitName]).IMEI] == null)
{
((Vehicle)MainForm2.vehicleHT[unitName]).CheckPositionInSystem();
FastCommandWindow frmPop = new FastCommandWindow(unitName, ((Vehicle)MainForm2.vehicleHT[unitName]).IMEI, parent, popupType, smdbObj.get_all_DefSMS())
{
has_text = ((Vehicle)MainForm2.vehicleHT[unitName]).has_text,
has_voice = ((Vehicle)MainForm2.vehicleHT[unitName]).has_voice
};
if (MainForm2.HasVoice)
{
if (parent.VoiceFirstTime)
parent.First_time_start_radio();
frmPop.gwandradID = ((Vehicle)MainForm2.vehicleHT[unitName]).GwandRadioID;
frmPop.checkStatus();
}
else frmPop.DisablePTT();
frmPop.Show();
MainForm2.PopupOpen.Add(((Vehicle)MainForm2.vehicleHT[unitName]).IMEI, frmPop);
}
else
{
// the tab is already opened so it needs to change the tab
FastCommandWindow frmPop = (FastCommandWindow)MainForm2.PopupOpen[((Vehicle)MainForm2.vehicleHT[unitName]).IMEI];
frmPop.SelectTab(popupType);
frmPop.Activate();
}
}
catch (Exception ex)
{
SM.Debug("Cann't show new PopupWindow form" + ex.ToString());
}
}
private void vehiclesList_CellFormatting(object sender, CellFormattingEventArgs e)
{
GridCellElement cellElement = e.CellElement;
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
// set padding and force the content adding
if (cellElement is LiveGridCellElement && columnInfo.Name == "live")
{
cellElement.Padding = new Padding(0, 0, 0, 0);
//cellElement.SetContent();
// add click listener only if not added before
if ((cellElement.Tag != null && !cellElement.Tag.Equals("done")) || cellElement.Tag == null)
{
((LiveGridCellElement)cellElement).OnLiveCell_Click += delegate(object s, LiveGridCellElement.LiveCellClickEventArgs ea)
{
Utils.WriteLine("CLICKED " + ea.gridData.UnitName + " | " + ea.eventType, ConsoleColor.Red);
switch (ea.eventType)
{
// update the units which are displayed on the map
case EventType.DISPLAY:
displayButton.PerformClick();
break;
case EventType.ALERT:
{
openPopupWindow(ea.gridData.UnitName, EventType.ALERT);
break;
}
case EventType.TEXT:
{
openPopupWindow(ea.gridData.UnitName, EventType.TEXT);
break;
}
case EventType.VOICE:
{
openPopupWindow(ea.gridData.UnitName, EventType.VOICE);
break;
}
case EventType.CENTER:
{
// todo
try
{
MainForm2.POLLunit = (String)vehiclesList.SelectedRows[0].Cells["UnitName"].Value;
if ((Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LAT) != 0) && (Math.Round(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).LNG) != 0))
{
if (((MapElement)(((Vehicle)MainForm2.vehicleHT[MainForm2.POLLunit]).MapsHT[tabName])).isActive) ;
else
{
vehiclesList.SelectedRows[0].Cells["OnMap"].Value = true;
displayButton.PerformClick();
}
mapControl.Extent = MainForm2.ZoomTo(ea.gridData.Longitude, ea.gridData.Latitude, ea.gridData.Longitude, ea.gridData.Latitude);
}
}
catch (Exception ex)
{
SM.Debug("Error on CENTER ON MAP " + ex.ToString());
}
break;
}
}
};
}
cellElement.Tag = "done";
}
}
private bool positionsWindowIsActive = false;
/// <summary>
/// Refresh the positions list only when the Window is entered
/// </summary>
private void windowPositions_Enter(object sender, EventArgs e)
{
positionsWindowIsActive = true;
// get the address based on the positionss
displayButton.PerformClick();
RefreshPositionsGrid();
}
/// <summary>
/// Refresh the grid of positions
/// </summary>
public void RefreshPositionsGrid()
{
Int32 oldColomnSort = 0;
RadSortOrder oldSortType = RadSortOrder.Ascending;
EnableAction = false;
Vehicle vehicleTemp;
ListforGrid.Clear(); //aici e combinatia fatala
try
{
for (int i = 0; i < tableVehiclesList.Columns.Count; i++)
{
if (tableVehiclesList.Columns[i].SortOrder != RadSortOrder.None)
{
oldColomnSort = i;
oldSortType = tableVehiclesList.Columns[i].SortOrder;
break;
}
}
}
catch (Exception ex)
{
SM.Debug("Error on finding the sort column:" + ex.ToString());
}
tableVehiclesList.Columns["VehName"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["datetime"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["address"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["speed"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["head"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["di"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["do"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["lat"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["lng"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["zone"].SortOrder = RadSortOrder.None;
tableVehiclesList.Columns["Altitude"].SortOrder = RadSortOrder.None;
Thread.Sleep(100);
int countlist = -1;
String LatStr = "";
String LngStr = "";
String AltStr = "";
String Zone;
Double LatDou, LngDou;
// flag that an update will be made
//gridVehicles.TableElement.BeginUpdate();
//ListforGrid.Clear();
for (int contor = 0; contor < vehiclesList.Rows.Count; contor++)
{
// get current vehicle which is updated
vehicleTemp = (Vehicle)MainForm2.vehicleHT[(String)vehiclesList.Rows[contor].Cells["UnitName"].Value];
// get the Data bound item for each grid row
DataforVehList gridData = vehiclesList.Rows[contor].DataBoundItem as DataforVehList;
// verify if the unit is valid or not
if (gridData != null)
{
// skip this unit if it doesn't need to be updated
if (gridData.OnMap)
{
LatLngUTM tmpLatLng = new LatLngUTM();
Zone = "";
AltStr = Math.Round(vehicleTemp.GetAlt(), 5).ToString();
if (MainForm2.LatLngUTM.CompareTo("Lat/Lng No.") == 0)
{
LatStr = Math.Round(vehicleTemp.GetLat(), 5).ToString();
LngStr = Math.Round(vehicleTemp.GetLng(), 5).ToString();
}
else if (MainForm2.LatLngUTM.CompareTo("Lat/Lng Deg.") == 0)
tmpLatLng.LatLongtoDeg(vehicleTemp.GetLat(), vehicleTemp.GetLng(), out LatStr, out LngStr);
else if (MainForm2.LatLngUTM.CompareTo("UTM") == 0)
{
tmpLatLng.LatLongtoUTM(vehicleTemp.GetLat(), vehicleTemp.GetLng(), out LatDou, out LngDou, out Zone);
LatStr = LatDou.ToString("###,###,###");
LngStr = LngDou.ToString("###,###,###");
}
// update all the new fields and values
if (!((Math.Round(vehicleTemp.GetLat()) == 0) && (Math.Round(vehicleTemp.GetLng()) == 0)))
ListforGrid.Add(new DataforGRID(countlist.ToString(), vehicleTemp.busName,
vehicleTemp.lastActivityTime.ConvertGMTToLocal().GetDTFromSeconds(),
vehicleTemp.GetLastAddress(), Convert.ToString(vehicleTemp.GetSpeed()),
Utils.GetDirection(vehicleTemp.GetHeading()).ToString(), Convert.ToString(vehicleTemp.GetDI()),
Convert.ToString(vehicleTemp.GetDO()), Convert.ToString(LatStr),
Convert.ToString(LngStr), Zone, Convert.ToString(AltStr)));
else
ListforGrid.Add(new DataforGRID(countlist.ToString(), vehicleTemp.busName,
vehicleTemp.lastActivityTime.ConvertGMTToLocal().GetDTFromSeconds(), "N/A",
Convert.ToString(vehicleTemp.GetSpeed()), "N/A", Convert.ToString(vehicleTemp.GetDI()),
Convert.ToString(vehicleTemp.GetDO()), "N/A", "N/A", "", "N/A"));
}
}
}
TableViewSortComplete = false;
TableViewDataComplete = false;
try
{
tableVehiclesList.DataSource = null;
tableVehiclesList.DataSource = ListforGrid;
}
catch (Exception ex)
{
SM.Debug("Error on populate grid" + ex.ToString());
}
tableVehiclesList.Columns[oldColomnSort].SortOrder = oldSortType;
tableVehiclesList.TableElement.ScrollToRow(0);
tableVehiclesList.Refresh();
}
#region CHANGE TABS BACKGROUND
private DockWindow oldDockWindow = null;
private void radDock1_ActiveWindowChanging(object sender, DockWindowCancelEventArgs e)
{
// reset the background icon for the previous tab
e.OldWindow.TabStripItem.BackColor = Color.White;
e.OldWindow.TabStripItem.DrawFill = true;
e.OldWindow.TabStripItem.NumberOfColors = 1;
// reset the background for the new window
e.NewWindow.TabStripItem.DrawFill = true;
e.NewWindow.TabStripItem.NumberOfColors = 1;
e.NewWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;
// save old dock window
oldDockWindow = e.OldWindow;
}
private void radDock1_ActiveWindowChanged(object sender, DockWindowEventArgs e)
{
// reset the background icon for the previous tab
oldDockWindow.TabStripItem.BackColor = Color.White;
oldDockWindow.TabStripItem.DrawFill = true;
oldDockWindow.TabStripItem.NumberOfColors = 1;
e.DockWindow.TabStripItem.DrawFill = true;
e.DockWindow.TabStripItem.NumberOfColors = 1;
e.DockWindow.TabStripItem.BackColor = MainForm2.TabSelectedColor;
}
#endregion
/// <summary>
/// Event handler for when the left tab panel needs to be docked/transfor in floating state.
/// This will cancel this event in order to prevent the stupid case with hiding the dock window
/// </summary>
private void radDock1_DockStateChanging(object sender, DockStateChangingEventArgs e)
{
e.Cancel = true;
}
}
}