using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Microsoft.Win32;
using System.Resources;
using System.IO;
using Telerik.WinControls.UI;
using Telerik.WinControls;
using Telerik.WinControls.UI.Docking;
using SafeMobileLib;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.EngineCore;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
namespace Safedispatch_4_0
{
///
/// This class implements the live tab.
///
/// 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
public partial class TelemTabGIS : UserControl
{
///
/// The class constructor.
///
public enum TelemCommands { SET = 0, CLEAR = 1, TOGGLE = 2, PULSE = 3 };
public bool KillTimerActive = false;
private String milesh, kmh;
public Boolean docLoad = false;
private Int32 loadcnt = 0;
public String updatecomand;
public String getADDRcomand;
public String lasttime;
private String selectName = "";
private IMapControl3 m_mapControl = null;
public IGraphicTracker m_graphicTracker = null;
private void setLanguage()
{
langProgStat = MainForm2.returnLNGString("txProgStatLive");
kmh = MainForm2.returnLNGString("kmh");
milesh = MainForm2.returnLNGString("milesh");
toolWindow1.Text = MainForm2.returnLNGString("selectionExpando");
toolWindow2.Text = MainForm2.returnLNGString("tabPage1");
toolWindow3.Text = MainForm2.returnLNGString("tabPage2");
vehiclesList.Columns[2].HeaderText = MainForm2.returnLNGString("htableVehiclesListColumns1");
lasttime = MainForm2.returnLNGString("lbLastTime");
lbStatus1.Text = MainForm2.returnLNGString("SMSStatus");
lbStatus2.Text = MainForm2.returnLNGString("SMSStatus");
lbStatus3.Text = MainForm2.returnLNGString("SMSStatus");
lbStatus4.Text = MainForm2.returnLNGString("SMSStatus");
lbStatus5.Text = MainForm2.returnLNGString("SMSStatus");
btSend1.Text = MainForm2.returnLNGString("send");
btSend2.Text = MainForm2.returnLNGString("send");
btSend3.Text = MainForm2.returnLNGString("send");
btSend4.Text = MainForm2.returnLNGString("send");
btSend5.Text = MainForm2.returnLNGString("send");
}
public TelemTabGIS(MainForm2 parentParam)
{
DateTime FirstTime;
parent = parentParam;
InitializeComponent();
//this.SelectionLive.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255)))));
//ThemeResolutionService.ApplyThemeToControlTree(this, "ControlDefault");
FirstTime = DateTime.Now;
// set height for the grid items
this.vehiclesList.TableElement.RowHeight = 45;
this.vehiclesList.GridViewElement.DrawBorder = false;
this.vehiclesList.GridViewElement.GroupPanelElement.DrawBorder = false;
setLanguage();
vehiclesList.TableElement.RowHeight = 32;
populateVehiclesList(vehicleListNames);
//update data
try
{
if (vehiclesList.SelectedRows[0].Cells[2].Value != null)
{
selectName = vehiclesList.SelectedRows[0].Cells[2].Value.ToString();
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemList)
{
ChangePreview(temobj, (Bitmap)vehiclesList.SelectedRows[0].Cells[temobj.DigitalNr + 2].Value);
}
//if (((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemPos != null)
// lbLastUpdate.Text = lasttime + ": " + convDT.GetDTFromSeconds(convDT.ConvertGMTToLocal(((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemPos.TimeGMT));
}
else selectName = "";
}
catch (Exception ex)
{
SM.Debug("Unable to change telemetry " + ex.ToString());
}
cbType1.SelectedIndex = 0;
cbType2.SelectedIndex = 0;
cbType3.SelectedIndex = 0;
cbType4.SelectedIndex = 0;
cbType5.SelectedIndex = 0;
SelectionLive.Enabled = true;
GetPositionForPlace = false;
GetPositionForStart = false;
GetPositionForZones = false;
toolWindow1.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu;
toolWindow1.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
toolWindow1.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;
toolWindow3.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu;
toolWindow3.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
toolWindow3.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide;
ContextMenuService menuService = this.radDock1.GetService();
menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying;
try
{
switch (MainForm2.radioType)
{
case RADIOTYPE.HYT:
radSplitContainer1.BackColor = MainForm2.HyteraColor;
radSplitContainer2.BackColor = MainForm2.HyteraColor;
radSplitContainer4.BackColor = MainForm2.HyteraColor;
documentContainer1.BackColor = MainForm2.HyteraColor;
radDock1.BackColor = MainForm2.HyteraColor;
break;
case RADIOTYPE.HARRIS:
radSplitContainer1.BackColor = MainForm2.HarrisColor;
radSplitContainer2.BackColor = MainForm2.HarrisColor;
radSplitContainer4.BackColor = MainForm2.HarrisColor;
documentContainer1.BackColor = MainForm2.HarrisColor;
radDock1.BackColor = MainForm2.HarrisColor;
lbGPIO1.ForeColor = MainForm2.HarTextColor;
lbGPIO2.ForeColor = MainForm2.HarTextColor;
lbGPIO3.ForeColor = MainForm2.HarTextColor;
lbGPIO4.ForeColor = MainForm2.HarTextColor;
lbGPIO5.ForeColor = MainForm2.HarTextColor;
lbStatus1.ForeColor = MainForm2.HarTextColor;
lbStatus2.ForeColor = MainForm2.HarTextColor;
lbStatus3.ForeColor = MainForm2.HarTextColor;
lbStatus4.ForeColor = MainForm2.HarTextColor;
lbStatus5.ForeColor = MainForm2.HarTextColor;
lbName1.ForeColor = MainForm2.HarTextColor;
lbName2.ForeColor = MainForm2.HarTextColor;
lbName3.ForeColor = MainForm2.HarTextColor;
lbName4.ForeColor = MainForm2.HarTextColor;
lbName5.ForeColor = MainForm2.HarTextColor;
//lbLastUpdate.ForeColor = MainForm2.HarTextColor;
break;
case RADIOTYPE.ATLAS:
radSplitContainer1.BackColor = MainForm2.HarrisColor;
radSplitContainer2.BackColor = MainForm2.HarrisColor;
radSplitContainer4.BackColor = MainForm2.HarrisColor;
documentContainer1.BackColor = MainForm2.HarrisColor;
radDock1.BackColor = MainForm2.HarrisColor;
lbGPIO1.ForeColor = MainForm2.HarTextColor;
lbGPIO2.ForeColor = MainForm2.HarTextColor;
lbGPIO3.ForeColor = MainForm2.HarTextColor;
lbGPIO4.ForeColor = MainForm2.HarTextColor;
lbGPIO5.ForeColor = MainForm2.HarTextColor;
lbStatus1.ForeColor = MainForm2.HarTextColor;
lbStatus2.ForeColor = MainForm2.HarTextColor;
lbStatus3.ForeColor = MainForm2.HarTextColor;
lbStatus4.ForeColor = MainForm2.HarTextColor;
lbStatus5.ForeColor = MainForm2.HarTextColor;
lbName1.ForeColor = MainForm2.HarTextColor;
lbName2.ForeColor = MainForm2.HarTextColor;
lbName3.ForeColor = MainForm2.HarTextColor;
lbName4.ForeColor = MainForm2.HarTextColor;
lbName5.ForeColor = MainForm2.HarTextColor;
//lbLastUpdate.ForeColor = MainForm2.HarTextColor;
break;
case RADIOTYPE.SIMOCO:
case RADIOTYPE.EXCERA:
//we don't need
break;
}
}
catch (Exception ex)
{
SM.Debug("Error on change color constructor:" + ex.ToString());
}
}
private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
{
if (e.MenuType == ContextMenuType.DockWindow &&
e.DockWindow.DockTabStrip is DocumentTabStrip)
{
for (int i = 0; i < e.MenuItems.Count; i++)
{
RadMenuItemBase menuItem = e.MenuItems[i];
if (menuItem.Name == "CloseWindow" ||
menuItem.Name == "CloseAllButThis" ||
menuItem.Name == "CloseAll" ||
menuItem.Name == "Floating" ||
menuItem.Name == "Docked" ||
menuItem.Name == "Hidden" ||
menuItem is RadMenuSeparatorItem)
{
menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
}
}
}
///
///populates the list of vehicles from the left part of the tab
/// an array of strings containing the vehicles names
public volatile List ListforTelemList = new List();
volatile String GroupNameforgrid = "";
volatile Image Imageforgrid = null;
volatile String Statusforgrid = "";
volatile List ListImg = new List();
private void populateVehiclesList(ArrayList listOfVehicles)
{
vehiclesList.Columns[2].SortOrder = RadSortOrder.None;
int cont = 0;
ListforTelemList.Clear();
foreach (String obj in MainForm2.vehicleHT.Keys)
{
GroupNameforgrid = 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]);
String iconPath = crtCar.listFilePath;
try
{
Bitmap bmp = new Bitmap(iconPath);
Image tmp2 = bmp; //tmp.ToBitmap();
Imageforgrid = tmp2;
}
catch (Exception ex)
{
SM.Debug("Grid icon could not be found [" + iconPath + "]");
Imageforgrid = imageList1.Images[2];
}
ListImg.Clear();
for (int i = 0; i < 5; i++)
ListImg.Add(global::Dispatcher.Properties.Resources.te_in_d);
if ((((Vehicle)MainForm2.vehicleHT[obj]).telemList.Count != 0))
{
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[obj]).telemList)
{
// set icon for no valid info in case of a out pin
if (!temobj.DigitalType.Equals("IN"))
ListImg[temobj.DigitalNr - 1] = global::Dispatcher.Properties.Resources.te_out_d;
Byte digit = (Byte)Math.Pow(2, temobj.DigitalNr - 1);
// if old value exists for this unit
if ((((Vehicle)MainForm2.vehicleHT[obj]).telemPos != null))
{
// if the pin value is on
if ((((Byte)((Vehicle)MainForm2.vehicleHT[obj]).telemPos.ByteValue) & digit) > 0)
{
// set icon for in pin
ListImg[temobj.DigitalNr - 1] = global::Dispatcher.Properties.Resources.te_in_g;
// set icon for out pin
if (!temobj.DigitalType.Equals("IN"))
ListImg[temobj.DigitalNr - 1] = global::Dispatcher.Properties.Resources.te_out_g;//vehiclesList.Rows[cont].Cells[temobj.DigitalNr + 2].Value = global::Dispatcher.Properties.Resources.green_status;
}
// if pin vlaue is off
else
{
// set icon for in pin
ListImg[temobj.DigitalNr - 1] = global::Dispatcher.Properties.Resources.te_in_r;
// set icon for out pin
if (!temobj.DigitalType.Equals("IN"))
ListImg[temobj.DigitalNr - 1] = global::Dispatcher.Properties.Resources.te_out_r;
}
}
}
}
cont++;
ListforTelemList.Add(new DataforTelemList(GroupNameforgrid, Imageforgrid, obj, ListImg[0], ListImg[1], ListImg[2], ListImg[3], ListImg[4]));
}
try
{
vehiclesList.DataSource = null;
vehiclesList.DataSource = ListforTelemList;
}
catch (Exception ex)
{
SM.Debug("Error on populate grid" + ex.ToString());
}
vehiclesList.Columns[2].SortOrder = RadSortOrder.Ascending;
//grouping stuff
vehiclesList.GroupDescriptors.Clear();
GridGroupByExpression expression = new GridGroupByExpression();
expression.Expression = "GroupName as GroupName format \"{0}: {1}\" Group By GroupName";
vehiclesList.GroupDescriptors.Add(expression);
// vehiclesList.MasterGridViewTemplate.GroupDescriptors.Insert(0, new Telerik.WinControls.Data.GroupDescriptor("GroupName as GroupName format \"{0}: {1}\" Group By GroupName"));
GridExpandAnimationType temp = vehiclesList.GroupExpandAnimationType;
vehiclesList.GroupExpandAnimationType = GridExpandAnimationType.None;
for (int i = 0; i < vehiclesList.Groups.Count; i++)
this.Expand(vehiclesList.Groups[i]);
vehiclesList.GroupExpandAnimationType = temp;
//if (vehiclesList.RowCount > 0)
// vehiclesList.Rows[0].IsSelected = true;
//vehiclesList.Refresh();
}
private void ChangePreview(TelemetryObj temobj, Bitmap tmpImg)
{
switch (temobj.DigitalNr)
{
case 1:
lbName1.Text = temobj.Name;
panStat1.BackgroundImage = tmpImg;
if (temobj.DigitalType == "IN")
{
btSend1.Visible = false;
cbType1.Visible = false;
}
else
{
btSend1.Enabled = true;
cbType1.Enabled = true;
}
break;
case 2:
lbName2.Text = temobj.Name;
panStat2.BackgroundImage = tmpImg;
if (temobj.DigitalType == "IN")
{
btSend2.Visible = false;
cbType2.Visible = false;
}
else
{
btSend2.Enabled = true;
cbType2.Enabled = true;
}
break;
case 3:
lbName3.Text = temobj.Name;
panStat3.BackgroundImage = tmpImg;
if (temobj.DigitalType == "IN")
{
btSend3.Visible = false;
cbType3.Visible = false;
}
else
{
btSend3.Enabled = true;
cbType3.Enabled = true;
}
break;
case 4:
lbName4.Text = temobj.Name;
panStat4.BackgroundImage = tmpImg;
if (temobj.DigitalType == "IN")
{
btSend4.Visible = false;
cbType4.Visible = false;
}
else
{
btSend4.Enabled = true;
cbType4.Enabled = true;
}
break;
case 5:
lbName5.Text = temobj.Name;
panStat5.BackgroundImage = tmpImg;
if (temobj.DigitalType == "IN")
{
btSend5.Visible = false;
cbType5.Visible = false;
}
else
{
btSend5.Enabled = true;
cbType5.Enabled = true;
}
break;
}
}
public void updateName(String Name)
{
Boolean change = false;
try
{
foreach (GridViewRowInfo obj in vehiclesList.Rows)
{
if (obj.Cells[2].Value.ToString() == Name)
{
if ((((Vehicle)MainForm2.vehicleHT[Name]).telemList.Count != 0) && (((Vehicle)MainForm2.vehicleHT[Name]).telemPos != null))
{
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[Name]).telemList)
{
Byte digit = (Byte)Math.Pow(2, temobj.DigitalNr - 1);
Bitmap tmpImg = global::Dispatcher.Properties.Resources.red_status;
if ((((Byte)((Vehicle)MainForm2.vehicleHT[Name]).telemPos.ByteValue) & digit) > 0) tmpImg = global::Dispatcher.Properties.Resources.green_status;
obj.Cells[temobj.DigitalNr + 2].Value = tmpImg;
change = true;
if (selectName == Name)
{
ChangePreview(temobj, tmpImg);
//lbLastUpdate.Text = lasttime + ": " + convDT.GetDTFromSeconds(convDT.ConvertGMTToLocal(((Vehicle)MainForm2.vehicleHT[Name]).telemPos.TimeGMT));
}
}
}
break;
}
}
if (change) vehiclesList.Refresh();
}
catch (Exception ex)
{
SM.Debug("Erorr on UpdateName:" + ex.ToString());
}
}
private void Expand(DataGroup group)
{
group.Expand();
if (group.Groups.Count > 0)
{
for (int i = 0; i < group.Groups.Count; i++)
{
this.Expand(group.Groups[i]);
}
}
}
private void Killtimer_Tick(object sender, EventArgs e)
{
if (MainForm2.ClosingApp)
{
SM.Debug("Worker Live:Telem FINISHED from timer");
SM.Debug("RELEASE SEMAFOR TAB LIVE: Telem");
KillTimerActive = true;
}
}
void SendTelem_Click(object sender, EventArgs e)
{
foreach(TelemetryObj obj in ((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.SelectedRows[0].Cells[2].Value]).telemList)
if (obj.Name == ((RadMenuItem)sender).Text)
{
String Totrans = "#106#"+((Vehicle)MainForm2.vehicleHT[(String)vehiclesList.SelectedRows[0].Cells[2].Value]).sc_id+"#"+ obj.DigitalNr+"#";
parent.Send_UDP_cmd(Totrans, 10000,0);
break;
}
}
Int32 Idgen = -1;
private void vehiclesList_SelectionChanged(object sender, EventArgs e)
{
IGraphicTrackerSymbol tmpSYMB = null;
if (vehiclesList.SelectedRows.Count > 0)
{
lbName1.Text = "Unknown1";
lbName2.Text = "Unknown2";
lbName3.Text = "Unknown3";
lbName4.Text = "Unknown4";
lbName5.Text = "Unknown5";
panStat1.BackgroundImage = global::Dispatcher.Properties.Resources.grey_status;
panStat2.BackgroundImage = global::Dispatcher.Properties.Resources.grey_status;
panStat3.BackgroundImage = global::Dispatcher.Properties.Resources.grey_status;
panStat4.BackgroundImage = global::Dispatcher.Properties.Resources.grey_status;
panStat5.BackgroundImage = global::Dispatcher.Properties.Resources.grey_status;
/* panStat1.BackgroundImage = global::Dispatcher.Properties.Resources.red_status;
panStat2.BackgroundImage = global::Dispatcher.Properties.Resources.red_status;
panStat3.BackgroundImage = global::Dispatcher.Properties.Resources.red_status;
panStat4.BackgroundImage = global::Dispatcher.Properties.Resources.red_status;
panStat5.BackgroundImage = global::Dispatcher.Properties.Resources.red_status;*/
btSend1.Visible = true; cbType1.Visible = true;
btSend2.Visible = true; cbType2.Visible = true;
btSend3.Visible = true; cbType3.Visible = true;
btSend4.Visible = true; cbType4.Visible = true;
btSend5.Visible = true; cbType5.Visible = true;
btSend1.Enabled = false; cbType1.Enabled = false;
btSend2.Enabled = false; cbType2.Enabled = false;
btSend3.Enabled = false; cbType3.Enabled = false;
btSend4.Enabled = false; cbType4.Enabled = false;
btSend5.Enabled = false; cbType5.Enabled = false;
try
{
if (vehiclesList.SelectedRows[0].Cells[2].Value != null)
{
selectName = vehiclesList.SelectedRows[0].Cells[2].Value.ToString();
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemList)
ChangePreview(temobj, (Bitmap)vehiclesList.SelectedRows[0].Cells[temobj.DigitalNr + 2].Value);
//if (((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemPos != null)
// lbLastUpdate.Text = lasttime + ": " + convDT.GetDTFromSeconds(convDT.ConvertGMTToLocal(((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemPos.TimeGMT));
}
else selectName = "";
}
catch (Exception ex)
{
SM.Debug("Unable to change telemetry "+ex.ToString());
}
if (vehiclesList.SelectedRows[0].Cells[2].Value != null)
{
if (loadfinish)
{
if (MainForm2.carlist[((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).IconID] != null)
tmpSYMB = m_graphicTracker.CreateSymbol(((Car)MainForm2.carlist[((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).IconID]).GISsymb as ISymbol, null);
IPoint point = new ESRI.ArcGIS.Geometry.Point();
point.X = ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LNG;
point.Y = ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LAT;
point.SpatialReference = MainForm2.CreateGeoCoordSys();
if (Idgen == -1)
Idgen = m_graphicTracker.Add(point as IGeometry, tmpSYMB);
else
{
m_graphicTracker.SuspendUpdate = true;
m_graphicTracker.SetGeometry(Idgen, point as IGeometry);
m_graphicTracker.SetSymbol(Idgen, tmpSYMB);
m_graphicTracker.SuspendUpdate =false;
}
MainForm2.simpleTextSymbol.YOffset = 35;
m_graphicTracker.SuspendUpdate = true;
m_graphicTracker.SetTextSymbol(Idgen, MainForm2.simpleTextSymbol);
m_graphicTracker.SetLabel(Idgen, vehiclesList.SelectedRows[0].Cells[2].Value.ToString() + "\n " + MainForm2.langSpeed + " " + Convert.ToString(((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).GetSpeed()) + MainForm2.Measure + " " + MainForm2.langTime + " " + ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).lastActivityTime.TimeOfDayHHMMLocal() + " \n " + ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).lastAddress + " ");
m_graphicTracker.SuspendUpdate = false;
//mapControl.Extent = MainForm2.ZoomTo(((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LNG - 0.01, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LAT - 0.01, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LNG + 0.01, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LAT + 0.01);
mapControl.Extent = MainForm2.ZoomTo(((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LNG, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LAT, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LNG, ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).LAT);
}
}
}
else
{
/*Recordset rs = telemDataSet.QueryAllRecords();
rs.MoveFirst();
if (!rs.EOF)
{
pp = rs.Pushpin;
pp.Delete();
} */
}
}
Boolean loadfinish = false;
private void btRefresh_Click(object sender, EventArgs e)
{
if (selectName != "") parent.Send_telem_digit(selectName, 10, 0);
}
private void vehiclesList_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
{
try
{
string suff = String.Concat(" (", e.Group.ItemCount.ToString(), ")");
if (e.FormatString.Contains(":"))
{
//e.FormatString = e.FormatString.Replace("GroupName:", "");
e.FormatString = 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());
}
}
private void TelemTabGIS_Load(object sender, EventArgs e)
{
//Load a pre-authored map document into the PageLayoutControl using relative paths.
//string fileName = @"E:\Cape Girardeau\GIS data\workspace.mxd";
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);
loadfinish = true;
}
private void ResizeWorker_DoWork(object sender, DoWorkEventArgs e)
{
Thread.Sleep(700);
}
private void ResizeWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
if (((toolWindow2.Size.Width > 25) && (toolWindow2.Size.Height > 25)) || ((mapControl.Size.Width > 25) && (mapControl.Size.Height > 25)))
{
vehiclesList.Size = new Size(vehiclesList.Size.Width, splitPanel1.Size.Height);
vehiclesList.Refresh();
if (toolWindow1.DockState == DockState.Docked)
{
toolWindow1.AutoHide();
toolWindow1.DockState = DockState.Docked;
}
}
}
catch (Exception ex)
{
SM.Debug("Error on resize" + ex.ToString());
}
}
private void radDock1_Resize(object sender, EventArgs e)
{
try
{
ResizeWorker.RunWorkerAsync();
}
catch (Exception ex)
{
SM.Debug("Unable to start resize thread" + ex.ToString());
}
}
private void vehiclesList_ViewCellFormatting(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);
}
}
}
private void vehiclesList_CellFormatting(object sender, CellFormattingEventArgs e)
{
GridCellElement cellElement = e.CellElement;
GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn;
if (cellElement != null)
cellElement.DrawBorder = false;
if (columnInfo.Name.StartsWith("Digi"))
{
string unitName = e.Row.Cells[2].Value.ToString();
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[unitName]).telemList)
{
/*
if (("Digi" + temobj.DigitalNr).Equals(columnInfo.Name) && !temobj.DigitalType.Equals("IN"))
{
cellElement.DrawFill = true;
cellElement.NumberOfColors = 1;
cellElement.BackColor = Color.Thistle;
}*/
}
}
}
private void vehiclesList_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement;
if (cell == null)
{
return;
}
try
{
if (e.ContextMenuProvider is GridDataCellElement)
{
GridViewRowInfo row = ((GridDataCellElement)e.ContextMenuProvider).RowInfo;
// create the drop down menu
RadDropDownMenu TelemMenu = new RadDropDownMenu();
try
{
if (vehiclesList.SelectedRows[0].Cells[2].Value != null)
{
selectName = vehiclesList.SelectedRows[0].Cells[2].Value.ToString();
foreach (TelemetryObj temobj in ((Vehicle)MainForm2.vehicleHT[vehiclesList.SelectedRows[0].Cells[2].Value.ToString()]).telemList)
{
if (temobj.DigitalNr == cell.ColumnIndex - 2)
{
TelemMenu.Text = "Pin " + temobj.DigitalNr + " options";
if (temobj.DigitalType != "IN")
{
// create context menu button
RadMenuItem itemSet = new RadMenuItem(MainForm2.returnLNGString("telemSet"));
// add click listener for the context menu button
itemSet.Click += delegate(object s, EventArgs ev)
{
// send SET command
parent.Send_telem_digit(selectName, temobj.DigitalNr, (int)TelemCommands.SET);
TelemMenu.ClosePopup(RadPopupCloseReason.Mouse);
};
// add button to context menu
TelemMenu.Items.Add(itemSet);
// create context menu button
RadMenuItem itemClear = new RadMenuItem(MainForm2.returnLNGString("telemClear"));
// add click listener for the context menu button
itemClear.Click += delegate(object s, EventArgs ev)
{
// send CLEAR command
parent.Send_telem_digit(selectName, temobj.DigitalNr, (int)TelemCommands.CLEAR);
TelemMenu.ClosePopup(RadPopupCloseReason.Mouse);
};
// add button to context menu
TelemMenu.Items.Add(itemClear);
// create context menu button
RadMenuItem itemToggle = new RadMenuItem(MainForm2.returnLNGString("telemToggle"));
// add click listener for the context menu button
itemToggle.Click += delegate(object s, EventArgs ev)
{
// send TOGGLE command
parent.Send_telem_digit(selectName, temobj.DigitalNr, (int)TelemCommands.TOGGLE);
TelemMenu.ClosePopup(RadPopupCloseReason.Mouse);
};
// add button to context menu
TelemMenu.Items.Add(itemToggle);
// create context menu button
RadMenuItem itemPulse = new RadMenuItem(MainForm2.returnLNGString("telemPulse"));
// add click listener for the context menu button
itemPulse.Click += delegate(object s, EventArgs ev)
{
// send PULSE command
parent.Send_telem_digit(selectName, temobj.DigitalNr, (int)TelemCommands.PULSE);
TelemMenu.ClosePopup(RadPopupCloseReason.Mouse);
};
// add button to context menu
TelemMenu.Items.Add(itemPulse);
}
}
}
}
}
catch (Exception ex)
{
SM.Debug("Unable to change telemetry " + ex.ToString());
}
// create context menu button
RadMenuItem itemRefresh = new RadMenuItem(MainForm2.returnLNGString("refreshAll"));
// add click listener for the context menu button
itemRefresh.Click += delegate(object s, EventArgs ev)
{
// send the refresh command
if (selectName != "")
parent.Send_telem_digit(selectName, 10, 0);
TelemMenu.ClosePopup(RadPopupCloseReason.Mouse);
};
// add button to context menu
TelemMenu.Items.Add(itemRefresh);
e.ContextMenu = TelemMenu;
}
}
catch (Exception ex)
{
SM.Debug("EXLive10:" + ex.ToString());
}
}
///
/// Format the cell in order to remove the indent of the cells
///
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 is GridViewIndentColumn)
{
e.Column.IsVisible = false;
/*
e.Column.MaxWidth = 7;
e.Column.MinWidth = 7;
e.Column.Width = 7;*/
//e.CellElement.Visibility = ElementVisibility.Hidden;
}
}
}
}
}