SafeDispatch/Safedispatch_4_0/maptab/LandZoneCfg.cs
2024-06-07 16:20:57 +03:00

3181 lines
145 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using Telerik.WinControls;
using Telerik.WinControls.UI.Docking;
using System.Net.NetworkInformation;
using SafeMobileLib;
using System.Threading;
using Dispatcher.maptab.UIClasses;
using System.IO;
using Telerik.WinControls.UI.Localization;
using System.Drawing.Imaging;
using Dispatcher.maptab;
namespace Safedispatch_4_0
{
public partial class LandZoneCfg : UserControl
{
private SMdb_access smdbObj;
private Int32 loadcnt = 0;
private String datasetCMD;
public Boolean docLoad = false;
private Boolean Loaddata = true;
private Boolean StopTimer = false;
private Boolean PingGoogle = false;
private Boolean LandMarkNotSpecPoint = false;
private Int32 RowToUpdate = -1;
private ArrayList vehicleListNames = new ArrayList();
String col0, col1, col2, col3, col4, mess1, mess2, mess5, mess4, mess6, messaddlatlongout, messadd, messaddquiz, messaddname, msgNotSave, msgWar;
String mess11, mess12, mess15, messWill, msgNotSaveZone, mess16, messPointToDel, need3Points, mesdeletelimit, messinfo, msgSplitEmail, msgInvalidEmail;
Color color = Color.Red;
private Boolean OnNewLandMark = false;
private Boolean OnNewZone = false;
public static Boolean isFilterLoaded = false;
public static volatile Boolean StreetViewOpened = false;
private volatile ReverseGeocoding volltmpGo2 = new ReverseGeocoding(MainForm2.cfg.ReverseGeoOSM);
private Boolean ChangeLandmarkLocationOnClick = true;
private static String safemobileDirPath = System.Windows.Forms.Application.StartupPath;
public delegate void ProcessResponseFromMapInvokeCallBack(String url);
// Colors list
private List<Color> colorsList;
public static Dictionary<Int32, LandmarkType> landmarkTypesList;
private Image themeEditActive_Image = Utils.ChangeColor(Dispatcher.Properties.Resources._edit_geofence, MainForm2.ButtonColor);
private Image themeEditDisabled_Image = Utils.MakeGrayscale3(Dispatcher.Properties.Resources._edit_geofence, 1);
private MainForm2 parent = null;
public LandZoneCfg(MainForm2 parent)
{
smdbObj = new SMdb_access();
RadGridLocalizationProvider.CurrentProvider = new GridLanguageProvider();
InitializeComponent();
this.parent = parent;
#region THEMING
labelGeofences.ForeColor = MainForm2.LabelColor;
labelLandmarks.ForeColor = MainForm2.LabelColor;
labelAlerts.ForeColor = MainForm2.LabelColor;
labelStyle.ForeColor = MainForm2.LabelColor;
rbResetGeofence.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
rbSaveGeofence.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
rbResetLandmark.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
rbSaveLandmark.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
documentTabStrip2.TabStripElement.BorderTopColor = MainForm2.ButtonColor;
documentTabStrip2.TabStripElement.BorderTopShadowColor = MainForm2.ButtonColor;
documentTabStrip2.SplitPanelElement.Border.TopShadowColor = MainForm2.ButtonColor;
documentTabStrip2.SplitPanelElement.Border.TopColor = MainForm2.ButtonColor;
rgbStyle.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbStyle.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbStyle.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbStyle.GroupBoxElement.Header.ImagePrimitive.Image =
pbStyle.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_style_24, MainForm2.ButtonColor);
rgbAlerts.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbAlerts.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbAlerts.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbAlerts.GroupBoxElement.Header.ImagePrimitive.Image =
pbAlerts.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_alert_24, MainForm2.ButtonColor);
rgbDetails.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbDetails.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbDetails.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbDetails.GroupBoxElement.Header.ImagePrimitive.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_details_24, MainForm2.ButtonColor);
rgbStyleLand.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbStyleLand.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbStyleLand.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbStyleLand.GroupBoxElement.Header.ImagePrimitive.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_style_24, MainForm2.ButtonColor);
rgbAlertsLand.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbAlertsLand.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbAlertsLand.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbAlertsLand.GroupBoxElement.Header.ImagePrimitive.Image =
pbAlerts.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_alert_24, MainForm2.ButtonColor);
rgbDetailsLand.GroupBoxElement.Header.Border.TopColor = MainForm2.ButtonColor;
rgbDetailsLand.GroupBoxElement.Header.Border.TopShadowColor = MainForm2.ButtonColor;
rgbDetailsLand.GroupBoxElement.Header.TextPrimitive.ForeColor = MainForm2.ButtonColor;
rgbDetailsLand.GroupBoxElement.Header.ImagePrimitive.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_details_24, MainForm2.ButtonColor);
pbEditGeofence.Image = themeEditDisabled_Image;
#endregion
// set theme for the Message Box
RadMessageBox.SetThemeName("TelerikMetroBlue");
// create the toolTip that will be displayed when the user sets a pattern
// over the hint pictureBox
toolTipHelp = new ToolTip();
toolTipHelp.ToolTipTitle = "";
toolTipHelp.AutoPopDelay = 0;
toolTipHelp.InitialDelay = 0;
toolTipHelp.ReshowDelay = 0;
toolTipHelp.IsBalloon = false;
toolTipHelp.ShowAlways = true;
// check if resource directory exists
if (!Directory.Exists("resource"))
{
Directory.CreateDirectory("resource");
}
// check if resource directory exists
if (!Directory.Exists("resource/landmarks"))
{
Directory.CreateDirectory("resource/landmarks");
}
// set the items which will be used inside the telerik controls
//RadGridLocalizationProvider.CurrentProvider = new MyEnglishRadGridLocalizationProvider();
// select the 'New Geofence' item and focus
rddlGeofences.SelectedIndex = 0;
rddlGeofences.Focus();
// select the 'New Landmark' item and focus
rddlLandmarks.SelectedIndex = 0;
rddlLandmarks.Focus();
#region COLORS LIST
// create the list of colors for the Landmarks
colorsList = new List<Color>() {
System.Drawing.ColorTranslator.FromHtml("#efed4f"),
System.Drawing.ColorTranslator.FromHtml("#d3e4ab"),
System.Drawing.ColorTranslator.FromHtml("#b7e64b"),
System.Drawing.ColorTranslator.FromHtml("#8ee247"),
System.Drawing.ColorTranslator.FromHtml("#52c144"),
System.Drawing.ColorTranslator.FromHtml("#61c1a3"),
System.Drawing.ColorTranslator.FromHtml("#97c8e3"),
System.Drawing.ColorTranslator.FromHtml("#3ea8e5"),
System.Drawing.ColorTranslator.FromHtml("#1796d9"),
System.Drawing.ColorTranslator.FromHtml("#007cb8"),
System.Drawing.ColorTranslator.FromHtml("#2636cb"),
System.Drawing.ColorTranslator.FromHtml("#4f6aa1"),
System.Drawing.ColorTranslator.FromHtml("#856dc3"),
System.Drawing.ColorTranslator.FromHtml("#ac70dd"),
System.Drawing.ColorTranslator.FromHtml("#cd567a"),
System.Drawing.ColorTranslator.FromHtml("#c7282a"),
System.Drawing.ColorTranslator.FromHtml("#f94040"),
System.Drawing.ColorTranslator.FromHtml("#e2635c"),
System.Drawing.ColorTranslator.FromHtml("#fe5011"),
System.Drawing.ColorTranslator.FromHtml("#fa7746"),
System.Drawing.ColorTranslator.FromHtml("#f3b24b"),
System.Drawing.ColorTranslator.FromHtml("#e4aa63"),
System.Drawing.ColorTranslator.FromHtml("#e3e3e3"),
System.Drawing.ColorTranslator.FromHtml("#b6b6b6"),
System.Drawing.ColorTranslator.FromHtml("#606060"),
System.Drawing.ColorTranslator.FromHtml("#414141"),
System.Drawing.ColorTranslator.FromHtml("#000000") };
// style for the Colors ListView
rlvLandmarkColors.ItemSize = new System.Drawing.Size(29, 29);
rlvLandmarkColors.ItemSpacing = 0;
// style the Visual Item for the Colors ListView
rlvLandmarkColors.VisualItemCreating += delegate(object sender, Telerik.WinControls.UI.ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem = new ColorCellElement();
};
// set the data source of the Colors ListView
rlvLandmarkColors.DataSource = colorsList;
// style for the Colors ListView
rlvGeofenceBorderColors.ItemSize = new System.Drawing.Size(29, 29);
rlvGeofenceBorderColors.ItemSpacing = 0;
// style the Visual Item for the Colors ListView
rlvGeofenceBorderColors.VisualItemCreating += delegate(object sender, Telerik.WinControls.UI.ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem = new ColorCellElement();
};
// set the data source of the Colors ListView
rlvGeofenceBorderColors.DataSource = colorsList;
// style for the Colors ListView
rlvGeofenceFillColors.ItemSize = new System.Drawing.Size(29, 29);
rlvGeofenceFillColors.ItemSpacing = 0;
// style the Visual Item for the Colors ListView
rlvGeofenceFillColors.VisualItemCreating += delegate(object sender, Telerik.WinControls.UI.ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem = new ColorCellElement();
};
// set the data source of the Colors ListView
rlvGeofenceFillColors.DataSource = colorsList;
#endregion
#region LANDMARKS ICONS LIST
// Process the list of files found in the directory.
if (landmarkTypesList == null)
landmarkTypesList = smdbObj.GetAllLandmarkTypes();
// style for the Icons ListView
rlvIcons.ItemSize = new System.Drawing.Size(27, 27);
rlvIcons.ItemSpacing = 0;
// style the Visual Item for the Icons ListView
rlvIcons.VisualItemCreating += delegate(object sender, Telerik.WinControls.UI.ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem = new IconCellElement();
};
// set the data source of the Icons ListView
rlvIcons.DataSource = landmarkTypesList;
#endregion
// populate the units list for the geofence alerts
// for each Unit defined in the hash table
List<Vehicle> vehicles = new List<Vehicle>();
foreach (DictionaryEntry de in MainForm2.vehicleHT)
{
Vehicle veh = de.Value as Vehicle;
vehicles.Add(veh);
/*
if (veh != null)
{
// add units to the drop down list
RadCheckedListDataItem item = new RadCheckedListDataItem();
item.Checked = false;
item.Value = veh.veh_id;
item.Text = veh.busName;
item.Tag = veh.IMEI;
rcbddUnitsList.Items.Add(item);
}*/
}
rcbddUnitsList.DataSource = vehicles;
rcbddUnitsList.DisplayMember = "Name";
RadCheckedListDataItem radCheckedListDataItem1 = new RadCheckedListDataItem(MainForm2.returnLNGString("g_in"), true);
RadCheckedListDataItem radCheckedListDataItem2 = new RadCheckedListDataItem(MainForm2.returnLNGString("g_out"), true);
this.rcbddAlertType.Items.Add(radCheckedListDataItem1);
this.rcbddAlertType.Items.Add(radCheckedListDataItem2);
// remove all context menu options for the left panels
ContextMenuService menuService2 = this.radDock1.GetService<ContextMenuService>();
menuService2.ContextMenuDisplaying += delegate(object sender, ContextMenuDisplayingEventArgs e)
{
if (e.MenuType == ContextMenuType.DockWindow &&
e.DockWindow.DockTabStrip is DocumentTabStrip)
{
//remove the "Close" menu items
for (int i = 0; i < e.MenuItems.Count; i++)
e.MenuItems[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
};
#region MAP
// create the map element
String safemobileDirPath = System.Windows.Forms.Application.StartupPath.Replace('\\', '/').Replace(" ", "%20");
safemobileDirPath = safemobileDirPath.Replace("#", "%23");
mapGoogles = new CefSharpChromiumWebBrowser("file:///" + safemobileDirPath + "/resource/" + MainForm2.MapHtmlName);
mapGoogles.OnWebPageLoaded += delegate()
{
docLoad = true;
bool isClassicIcons = (Safedispatch_4_0.MainForm2.iconThemeType == IconTheme.CLASSIC ? true : false);
try
{
mapGoogles.ExecuteScript(string.Format("window.GWTcallback('showconsole,{0}');",MainForm2.MapDebugConsole)); //FORKITT
mapGoogles.ExecuteScript("window.GWTcallback('setLegacyIcons," + (isClassicIcons ? "false" : "false") + "');");
//mapGoogles.ExecuteScript("window.GWTcallback('setLegacyIcons," + (isClassicIcons ? "true" : "false") + "');");
mapGoogles.ExecuteScript("window.GWTcallback('centerzoom,"
+ MainForm2.FixDoubleLAT(Safedispatch_4_0.MainForm2.LatStart.ToString()) + ","
+ MainForm2.FixDoubleLNG(Safedispatch_4_0.MainForm2.LngStart.ToString()) + ","
+ Safedispatch_4_0.MainForm2.ZoomStart + "');");
this.Invoke((MethodInvoker)delegate()
{
// get all geofences from the db and display them
currentTab = "landmark";
GeofencesWindow_Enter(GeofencesWindow, null);
// force the editing of a new geofence
rddlGeofences_SelectedIndexChanged(rddlGeofences, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(rddlGeofences.SelectedIndex));
});
}
catch (Exception ex)
{
Utils.WriteLine("Error on Load page Geofence ex:" + ex.ToString(), ConsoleColor.Red);
}
};
mapGoogles.OnBrowserURLChanged += delegate(String currentURL)
{
//MessageBox.Show("Current URL is " + currentURL);
};
mapGoogles.OnURLResponseReceived += delegate(String urlResponse)
{
try
{
this.Invoke(new ProcessResponseFromMapInvokeCallBack(this.ProcessResponseFromMap), urlResponse);
}
catch (Exception ex)
{
Utils.WriteLine("Error on response LandZone ex:" + ex.ToString(), ConsoleColor.Red);
}
};
MapPanel.Controls.Add(mapGoogles);
#endregion
// start the timer which will change the web page
//StartGoogleMap.Enabled = true;
setLanguage();
//mapGoogles.AllowFileAccessFromFileURLs = true;
// load all items inside the Landmarks and Geofences comboboxes
ReloadLandmarksDDL("");
ReloadGeofencesDDL("");
Loaddata = true;
ContextMenuService menuService = this.radDock1.GetService<ContextMenuService>();
menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying;
menuService.AllowActiveWindowListContextMenu = false;
menuService.AllowDocumentContextMenu = false;
menuService.AllowToolContextMenu = false;
MainForm2.RestartMEM += 70000000;
}
/// <summary>
/// Localize objects from the UI
/// </summary>
private void setLanguage()
{
col0 = MainForm2.returnLNGString("colum0");
col1 = MainForm2.returnLNGString("lbDescript");
col2 = MainForm2.returnLNGString("colum2");
col3 = MainForm2.returnLNGString("colum3");
col4 = MainForm2.returnLNGString("colum4");
mess1 = MainForm2.returnLNGString("messdelete");
messPointToDel = MainForm2.returnLNGString("messdeletePoint");
mess2 = MainForm2.returnLNGString("messdeletequiz");
mess4 = MainForm2.returnLNGString("zonename");
mess5 = MainForm2.returnLNGString("messdeletename");
mess6 = MainForm2.returnLNGString("geoNameExist2");
messaddlatlongout = MainForm2.returnLNGString("messaddlatlongout");
messadd = MainForm2.returnLNGString("messadd");
messaddname = MainForm2.returnLNGString("messaddname");
messaddquiz = MainForm2.returnLNGString("messaddquiz");
msgWar = MainForm2.returnLNGString("msgWar");
msgNotSave = MainForm2.returnLNGString("msgNotSave");
msgNotSaveZone = MainForm2.returnLNGString("msgNotSaveZone");
need3Points = MainForm2.returnLNGString("need3Points");
mesdeletelimit = MainForm2.returnLNGString("mesdeletelimit");
mess11 = MainForm2.returnLNGString("zone");
mess12 = MainForm2.returnLNGString("messdeletequizzone");
mess15 = MainForm2.returnLNGString("messdeletenamezone");
mess16 = MainForm2.returnLNGString("messdeletenamePoint");
messWill = MainForm2.returnLNGString("willdelete");
messinfo = MainForm2.returnLNGString("info");
msgInvalidEmail = MainForm2.returnLNGString("msgInvalidEmail");
msgSplitEmail = MainForm2.returnLNGString("msgSplitEmail");
rgbDetails.Text = rgbDetailsLand.Text = MainForm2.returnLNGString("details");
rcbShowGeofences.Text = MainForm2.returnLNGString("showOtherGeofences");
rtbGeofenceName.NullText = MainForm2.returnLNGString("geoName");
rcbEditGeofence.Text = MainForm2.returnLNGString("editGeo");
rgbStyle.Text = labelStyle.Text = rgbStyleLand.Text = MainForm2.returnLNGString("style");
radLabel2.Text = radLabel12.Text = MainForm2.returnLNGString("name");
labelGeofences.Text = GeofencesWindow.Text = MainForm2.returnLNGString("geos");
radLabel6.Text = MainForm2.returnLNGString("borderColor");
radLabel3.Text = MainForm2.returnLNGString("borderOpacity");
radLabel5.Text = MainForm2.returnLNGString("borderWidth");
radLabel13.Text = MainForm2.returnLNGString("fillColor");
radLabel7.Text = MainForm2.returnLNGString("fillOpacity");
rbResetGeofence.Text = rbResetLandmark.Text = MainForm2.returnLNGString("reset");
rbSaveGeofence.Text = rbSaveLandmark.Text = MainForm2.returnLNGString("save");
labelAlerts.Text = rgbAlerts.Text = MainForm2.returnLNGString("tabAlerts");
radLabel19.Text = MainForm2.returnLNGString("emailAndMessage"); //Email address and message that will sent
rtbEmailAddress.NullText = MainForm2.returnLNGString("fillemail"); //Fill email address
rtbEmailMessage.NullText = MainForm2.returnLNGString("fillmsg"); //Fill email message
radLabel17.Text = MainForm2.returnLNGString("geofenceAlertType"); //Geofence alert type
rtbUnitMessage.NullText = MainForm2.returnLNGString("Msg2Unit"); //Message which will be sent to unit
rtbUnitsMessage.NullText = MainForm2.returnLNGString("Msg2Units"); //Message which will be sent to units
rcbddUnitsList.NullText = MainForm2.returnLNGString("selAtleast1Unit"); //Select at least one unit
rcbEmailAlert.Text = MainForm2.returnLNGString("sendEmailWhenAlarmRaised"); //Send email when alert raised
rcbUnitMessage.Text = MainForm2.returnLNGString("sendMsgUnit"); //Send message to unit which raised the alert
rcbUnitsAlert.Text = MainForm2.returnLNGString("sendMsgUnits"); //Send text message to units when alert raised
rcbSpeedLimit.Text = MainForm2.returnLNGString("speedLimitInGeofence"); //Speed limit in geofence [km/h]
rcbSpeedLimit.Text = (!MainForm2.isInMile) ? string.Format(rcbSpeedLimit.Text, (MainForm2.returnLNGString("kmh"))) : string.Format(rcbSpeedLimit.Text, (MainForm2.returnLNGString("milesh")));
radLabel16.Text = MainForm2.returnLNGString("units2Rcv"); //Units which will receive the message
radLabel18.Text = MainForm2.returnLNGString("mssg");
labelLandmarks.Text = LandmarksWindow.Text = MainForm2.returnLNGString("lands");
rtbLandName.NullText = MainForm2.returnLNGString("landName");
rtbLandDesc.NullText = MainForm2.returnLNGString("landDesc");
radLabel11.Text = MainForm2.returnLNGString("lbDescript");
radLabel10.Text = MainForm2.returnLNGString("colum2");
radLabel9.Text = MainForm2.returnLNGString("colum3");
radLabel8.Text = MainForm2.returnLNGString("tableVehiclesListColumns2");
rcbMoveLandmark.Text = MainForm2.returnLNGString("moveLand");
rtbSmall.Text = MainForm2.returnLNGString("small");
rtbMedium.Text = MainForm2.returnLNGString("medium");
rtbLarge.Text = MainForm2.returnLNGString("large");
radLabel14.Text = MainForm2.returnLNGString("markerColor");
radLabel15.Text = MainForm2.returnLNGString("markerIcon");
rtbLandAddress.NullText = MainForm2.returnLNGString("landAddr");
// The ToolTip for the PictureBox.
new ToolTip().SetToolTip(pbSpeedLimitHint, MainForm2.returnLNGString("speedHint"));
rgvGeofencePoints.Columns[0].HeaderText = "";
rgvGeofencePoints.Columns[1].HeaderText = "";
rgvGeofencePoints.Columns[2].HeaderText = MainForm2.returnLNGString("Lat");
rgvGeofencePoints.Columns[3].HeaderText = MainForm2.returnLNGString("Lng");
rgvGeofencePoints.Columns[5].HeaderText = "";
rddzSeverity.Items.Clear();
rddzSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity1"), 1));
rddzSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity2"), 2));
rddzSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity3"), 3));
rddzSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity4"), 4));
rddzSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity5"), 5));
rddlSeverity.Items.Clear();
rddlSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity1"), 1));
rddlSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity2"), 2));
rddlSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity3"), 3));
rddlSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity4"), 4));
rddlSeverity.Items.Add(new RadListDataItem(MainForm2.returnLNGString("severity5"), 5));
/*
toolWindow1.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None;
//toolWindow1.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close;
toolWindow1.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None;
toolWindow1.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide;
toolWindow4.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None;
toolWindow4.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None;
toolWindow4.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide;*/
// hide delete icons and tool caption button
GeofencesWindow.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None;
GeofencesWindow.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None;
LandmarksWindow.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.None;
LandmarksWindow.DocumentButtons = Telerik.WinControls.UI.Docking.DocumentStripButtons.None;
/*
lbSpeedName.Text = MainForm2.kmh;
if (MainForm2.isInMile)
lbSpeedName.Text = MainForm2.milesh;*/
}
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 == "Hidden" ||
menuItem is RadMenuSeparatorItem)
{
menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
}
}
}
/// <summary>
/// Reaload all Landmarks inside the combo box
/// </summary>
/// <param name="focus">The element which needs to be focused</param>
public void ReloadLandmarksDDL(String focus)
{
int index = 0;
ArrayList tmpName = new ArrayList();
List<LandmarkUI> allLandmarks = smdbObj.GetAllLandmarks();
allLandmarks.Insert(0, new LandmarkUI() { Name = MainForm2.returnLNGString("newLand"), Idx = 0 });
// search the focused element
for (int i = 0; i < allLandmarks.Count; i++)
if (allLandmarks[i].Name.Equals(focus))
{
index = i;
break;
}
foreach (Int32 obj in MainForm2.LandIDHash.Keys)
tmpName.Add(new Zone_type((String)MainForm2.LandIDHash[obj], obj, 0));
tmpName.Sort(new DefineSMSComparer());
// load Landmarks inside the drop down list
rddlLandmarks.DataSource = allLandmarks;
rddlLandmarks.DisplayMember = "Name";
// select the desired index
rddlLandmarks.SelectedIndex = index;
}
/// <summary>
/// Reload all Geofences inside the combo box
/// </summary>
/// <param name="focus">The element which needs to be focused</param>
public void ReloadGeofencesDDL(String focus)
{
int index = 0;
List<GeofenceUI> allGeofences = smdbObj.GetAllGeofences();
allGeofences.Insert(0, new GeofenceUI() { Name = MainForm2.returnLNGString("newGeofence"), Idx = 0 });
// search the focused element
for (int i = 0; i < allGeofences.Count; i++)
if (allGeofences[i].Name.Equals(focus))
{
index = i;
break;
}
ArrayList tmpName = new ArrayList();
foreach (Int32 obj in MainForm2.ZoneIDHash.Keys)
tmpName.Add((ZoneClass)MainForm2.ZoneIDHash[obj]);
tmpName.Sort(new ZoneClassComparer());
// load Geofences inside the drop down list
rddlGeofences.DataSource = allGeofences;
rddlGeofences.DisplayMember = "Name";
#region Hide CallOut from interface
chkzCallout.Visible = false;
lbzCalloutSeverity.Visible = false;
rddzSeverity.Visible = false;
rgbAlertsLand.Visible = false;
radLabel1.Visible = false;
pictureBox1.Visible = false;
#endregion
// reset values
ResetGeofenceUI();
// select the desired index
rddlGeofences.SelectedIndex = index;
}
/// <summary>
/// Reset the values from the alerts panel
/// </summary>
private void ResetGeofenceUI()
{
// reset alerts UI
foreach (RadCheckedListDataItem item in rcbddUnitsList.Items)
item.Checked = false;
rcbddUnitsList.SelectedItem = null;
foreach (RadListDataItem item in rcbddAlertType.Items)
item.Selected = true;
//if (isFilterLoaded && rddlGeofences.Text != MainForm2.returnLNGString("newGeofence"))
if (isFilterLoaded)
{
bool showTetraAudibleAlerts = MainForm2.radioType == RADIOTYPE.TETRA && MainForm2.hasAudibleAlerts;
rcbEmailAlert.Checked = false;
rcbSpeedLimit.Checked = false;
rcbUnitMessage.Checked = false;
rcbUnitsAlert.Checked = false;
chkzCallout.Checked = false;
#region Enable CallOut - to be added after dongle update
//Make CallOut Audible Alerts visible in the interface
chkzCallout.Visible = showTetraAudibleAlerts;
lbzCalloutSeverity.Visible = showTetraAudibleAlerts;
rddzSeverity.Visible = showTetraAudibleAlerts;
rgbAlertsLand.Visible = showTetraAudibleAlerts;
radLabel1.Visible = showTetraAudibleAlerts;
pictureBox1.Visible = showTetraAudibleAlerts;
#endregion
rtbEmailAddress.ResetText();
rtbEmailMessage.ResetText();
rtbUnitMessage.ResetText();
rtbUnitsMessage.ResetText();
rseSpeedLimit.Value = 50;
}
}
/// <summary>
/// Remove all Geofences from the map, even the new one
/// </summary>
private void RemoveAllGeofences()
{
if (mapGoogles != null)
{
mapGoogles.ExecuteScript("window.GWTcallback('" + "deletePolygon,ALL');");
mapGoogles.ExecuteScript("window.GWTcallback('" + "removeDataset,ZOOM');");
// delete temporary geofence
mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon," + rddlGeofences.Text + "');");
}
}
/// <summary>
/// Display all the landmarks defined in the combobox on the map
/// </summary>
private void DisplayAllLandmarksOnMap()
{
// send command to remove previous dataset
mapGoogles.ExecuteScript("window.GWTcallback('removeDataset,LandView');");
try
{
List<LandmarkUI> landmarks = smdbObj.GetAllLandmarks();
datasetCMD = "setDataset,LandView";
foreach (LandmarkUI land in landmarks)
datasetCMD = datasetCMD + ","
+ MainForm2.FixDoubleLAT(land.Latitude + "") + ","
+ MainForm2.FixDoubleLNG(land.Longitude + "") + ","
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ","
+ MainForm2.FixComma(land.Name) + ","
+ "speed" + ","
+ "0" + ","
+ MainForm2.FixComma(land.Description).Replace(',', ' ') + ","
+ "landmarks/" + GetLandmarkIcon(land.TypeIdx, land.Color, land.Size) + ","
+ "false" + "," + "false" + "," + "false";
datasetCMD = datasetCMD.Replace(';', ' ');
mapGoogles.ExecuteScript("window.GWTcallback('" + datasetCMD + "');");
mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,false,LandView');");
System.Threading.Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('" + "putLabels,LandView');");
parent.DisplayToast(MainForm2.returnLNGString("landDisp"),
string.Format(MainForm2.returnLNGString("landHTML"), landmarks.Count));
}
catch (Exception ex)
{
Utils.WriteLine("Error on displaying all landmarks: " + ex.ToString(), ConsoleColor.Red);
}
}
/// <summary>
/// Display all the geofences on the map
/// </summary>
private void DisplayGeofencesOnMap()
{
String datasetCMD = "";
String datasetZoom = "";
foreach (GridViewRowInfo row in rgvGeofencePoints.Rows)
{
GridViewCellInfo lat = row.Cells["Lat"];
GridViewCellInfo lng = row.Cells["Lng"];
if (lat.Value == null || lng.Value == null)
continue;
Decimal latD = (Decimal)lat.Value;
Decimal lngD = (Decimal)lng.Value;
datasetCMD = datasetCMD + MainForm2.FixDoubleLAT(latD.ToString()) + "," + MainForm2.FixDoubleLNG(lngD.ToString()) + ",";
datasetZoom = datasetZoom + ","
+ MainForm2.FixDoubleLAT(latD.ToString()) + ","
+ MainForm2.FixDoubleLNG(lngD.ToString()) + ",,,,,,,false,false,false";
}
if (docLoad)
{
try
{
if (datasetCMD.Length > 0)
datasetCMD = datasetCMD.Remove(datasetCMD.Length - 1);
}
catch (Exception ex) { SM.Debug("Ex:" + ex.ToString()); }
mapGoogles.ExecuteScript("window.GWTcallback('" + "deletePolygon,ALL');");
System.Threading.Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('" + "removeDataset,ZOOM');");
System.Threading.Thread.Sleep(100);
if (rddlGeofences.SelectedItem != null)
{
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence == null)
return;
// show other geofences if desired
if (rcbShowGeofences.Checked)
showOtherZone(geofence.Idx);
Color fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
String hexFillColor = "#" + fillColor.R.ToString("X2") + fillColor.G.ToString("X2") + fillColor.B.ToString("X2");
Color borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
String hexBorderColor = "#" + borderColor.R.ToString("X2") + borderColor.G.ToString("X2") + borderColor.B.ToString("X2");
mapGoogles.ExecuteScript("window.GWTcallback('" + "setPolygon,"
+ geofence.Name + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString()) + ","
+ datasetCMD + "');");
if (datasetZoom.Length > 0)
{
mapGoogles.ExecuteScript("window.GWTcallback('" + "setDataset,ZOOM" + datasetZoom + "');");
mapGoogles.ExecuteScript("window.GWTcallback('putOnMap,true,ZOOM');");
}
/*
if(rddlGeofences.SelectedIndex == 0)
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + "tmpPol" + "');");
*/
}
}
}
/// <summary>
/// Update the new Geofence as a result of a point beeing deleted
/// </summary>
private void UpdateNewGeofence()
{
// prepare the map to accept a new polygon
Color fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
String hexFillColor = "#" + fillColor.R.ToString("X2") + fillColor.G.ToString("X2") + fillColor.B.ToString("X2");
Color borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
String hexBorderColor = "#" + borderColor.R.ToString("X2") + borderColor.G.ToString("X2") + borderColor.B.ToString("X2");
// remove the geofence from the map if not point anymore
if (rgvGeofencePoints.RowCount == 0)
{
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon');");
System.Threading.Thread.Sleep(10);
mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon," + rddlGeofences.Text + "');");
System.Threading.Thread.Sleep(10);
mapGoogles.ExecuteScript("window.GWTcallback('newPolygon," + rddlGeofences.Text + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString())
+ "');");
System.Threading.Thread.Sleep(10);
}
else
{
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon');");
System.Threading.Thread.Sleep(10);
mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon," + rddlGeofences.Text + "');");
System.Threading.Thread.Sleep(10);
String datasetCMD = "";
// add again the points of the landmark
foreach (GridViewRowInfo row in rgvGeofencePoints.Rows)
{
GridViewCellInfo lat = row.Cells["Lat"];
GridViewCellInfo lng = row.Cells["Lng"];
Decimal latD = (Decimal)lat.Value;
Decimal lngD = (Decimal)lng.Value;
datasetCMD = datasetCMD + MainForm2.FixDoubleLAT(latD.ToString()) + "," + MainForm2.FixDoubleLNG(lngD.ToString()) + ",";
}
try
{
datasetCMD = datasetCMD.Remove(datasetCMD.Length - 1);
}
catch (Exception ex) { SM.Debug("Ex:" + ex.ToString()); }
mapGoogles.ExecuteScript("window.GWTcallback('" + "setPolygon," + rddlGeofences.Text + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString()) + ","
+ datasetCMD + "');");
System.Threading.Thread.Sleep(10);
mapGoogles.ExecuteScript("window.GWTcallback('" + "startEditPolygon," + rddlGeofences.Text + "');");
System.Threading.Thread.Sleep(10);
}
}
/// <summary>
/// Show others geofences which are not edited now
/// </summary>
private void showOtherZone(Int32 currentGeofenceID)
{
foreach (RadListDataItem obj2 in rddlGeofences.Items)
{
GeofenceUI geofence = obj2.DataBoundItem as GeofenceUI;
// skip current geofence and the New Geofence one
if (geofence.Idx != currentGeofenceID && geofence.Idx != 0)
{
datasetCMD = "";
foreach (GeofencePoint point in geofence.points)
{
datasetCMD = datasetCMD
+ MainForm2.FixDoubleLAT(point.Latitude + "") + ","
+ MainForm2.FixDoubleLNG(point.Longitude + "") + ",";
}
// get geofence fill color
String hexFillColor = "#" + geofence.FillColor.R.ToString("X2") + geofence.FillColor.G.ToString("X2") + geofence.FillColor.B.ToString("X2");
String hexBorderColor = "#" + geofence.BorderColor.R.ToString("X2") + geofence.BorderColor.G.ToString("X2") + geofence.BorderColor.B.ToString("X2");
try
{
datasetCMD = datasetCMD.Remove(datasetCMD.Length - 1);
}
catch (Exception ex) { SM.Debug("Ex:" + ex.ToString()); }
if (docLoad) mapGoogles.ExecuteScript("window.GWTcallback('" + "setPolygon,"
+ geofence.Name + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(geofence.FillOpacity.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(geofence.BorderOpacity.ToString()) + ","
+ MainForm2.FixDoubleLAT(geofence.BorderWidth.ToString()) + ","
+ datasetCMD + "');");
System.Threading.Thread.Sleep(10);
}
}
if (rddlGeofences.Items.Count > 0)
parent.DisplayToast(MainForm2.returnLNGString("geofenceDisplayed"),
string.Format(MainForm2.returnLNGString("geoHTML"),rddlGeofences.Items.Count - 1));
}
/// <summary>
/// Force the map to load our html map file after the timer expires
/// </summary>
private void StartGoogleMap_Tick(object sender, EventArgs e)
{
StartGoogleMap.Stop();
StartGoogleMap.Enabled = false;
// remove space and # from the map path
String safemobileDirPath = System.Windows.Forms.Application.StartupPath.Replace('\\', '/').Replace(" ", "%20");
safemobileDirPath = safemobileDirPath.Replace("#", "%23");
mapGoogles.LoadWebPage("file:///" + safemobileDirPath + "/resource/" + MainForm2.MapHtmlName);
TimerToLoadMap.Enabled = true;
TimerToLoadMap.Start();
docLoad = true;
}
private String FixLandName(String Name)
{
String ret = Name;
ret = ret.ToLower();
ret = ret.Replace(" ", "_");
//ret = ret.Insert(ret.Length, ".png");
return ret;
}
/// <summary>
/// Get the icon name and relative path for a specific landmark
/// </summary>
/// <param name="landmarkTypeID">The landmark icon type id for which the icon
/// needs to be returned</param>
/// <param name="color">Color for the desired landmark</param>
/// <param name="iconSize">Desired size of the landmark</param>
/// <returns></returns>
public static String GetLandmarkIcon(Int32 landmarkTypeID, Color color, LandmarkUI.IconSize iconSize)
{
int width = 36;
int heigth = 48;
if (iconSize == LandmarkUI.IconSize.MEDIUM)
{
width = 27;
heigth = 36;
}
else if (iconSize == LandmarkUI.IconSize.SMALL)
{
width = 20;
heigth = 26;
}
//36,48; 27,36; 20,26;
// get the hex colors for the desired color
String hexColor = color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");
LandmarkType lt = null;
if (landmarkTypesList.ContainsKey(landmarkTypeID))
{
lt = landmarkTypesList[landmarkTypeID];
// generate the name and the path of the desired icon
string iconNameAndPath = System.Windows.Forms.Application.StartupPath
+ @"\resource\landmarks\" + lt.IconName.Replace(".png", "") + "_" + hexColor + "_" + iconSize.ToString() + ".png";
// check if the icon exists on the hdd
if (System.IO.File.Exists(iconNameAndPath))
{
// we are ok, and the icon doesn't need to be recreated
}
else
{
float r = (float)((1.0 / 256) * color.R);// / 256;
float g = (float)((1.0 / 256) * color.G);// / 256;
float b = (float)((1.0 / 256) * color.B);// / 256;
// create the landmark icon
using (Bitmap landmarkPin = new Bitmap(System.Windows.Forms.Application.StartupPath
+ @"\resource\landmarks\_pin_02.png"))
{
Bitmap bitmap = new Bitmap(landmarkPin.Width, landmarkPin.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
ImageAttributes imageAttributes = new ImageAttributes();
// create a color matrix in order to change the color
float[][] colorMatrixElements = {
new float[] {1, 0, 0, 0, 0}, // Red scaling [multiply]
new float[] {0, 1, 0, 0, 0}, // Green scaling [multiply]
new float[] {0, 0, 1, 0, 0}, // Blue scaling [multiply]
new float[] {r, g, b, 1, 0}, // this will add values to R,G,B,A
new float[] {0, 0, 0, 0, 1}}; // three translations of 0.2
ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
imageAttributes.SetColorMatrix(
colorMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
// Create a Graphics object
using (Graphics gr = Graphics.FromImage(bitmap))
{
// Draw image with no affects
gr.DrawImage(landmarkPin, 0, 0, landmarkPin.Width, landmarkPin.Height);
// Draw image with ImageAttributes
gr.DrawImage(landmarkPin, new Rectangle(0, 0, landmarkPin.Width, landmarkPin.Height), 0, 0,
landmarkPin.Width, landmarkPin.Height, GraphicsUnit.Pixel, imageAttributes);
// add landmark type icon
string iconPath = safemobileDirPath + @"\resource\landmarks\" + lt.IconName;
using (Image img = Utils.ScaleImage(Bitmap.FromFile(iconPath), 44, 44))
{
gr.DrawImage(img, 19, 18);
}
Image resizedImage = Utils.ScaleImage(bitmap, width, heigth);
resizedImage.Save(iconNameAndPath);
//bitmap.Save(iconNameAndPath);
// Dispose
bitmap.Dispose();
resizedImage.Dispose();
}
}
}
return lt.IconName.Replace(".png", "") + "_" + hexColor + "_" + iconSize.ToString() + ".png";
}
return @"landmarks\default.png";
}
private void MapPanelLand_Click(object sender, EventArgs e)
{
LandMarkNotSpecPoint = true;
}
/// <summary>
/// Display a geofence on the map using a dataset command and a dataset zoom level
/// </summary>
/// <param name="geofence">Geofence object which contains all the informations in
/// order to display it on the map</param>
/// <param name="datasetCMD">Command to send to the map in order to display the points</param>
/// <param name="datasetZoom">Zoom level to which the map has to zoom</param>
private void DisplayGeofenceOnMap(GeofenceUI geofence, String datasetCMD, string datasetZoom)
{
}
private String FixInt(Int32 nr)
{
if (nr < 10) return "0" + nr.ToString();
else return nr.ToString();
}
private void ckHide_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
//populateList();
}
private void TimerToLoadMap_Tick(object sender, EventArgs e)
{
try
{
String safemobileDirPath = System.Windows.Forms.Application.StartupPath.Replace('\\', '/').Replace(" ", "%20");
safemobileDirPath = safemobileDirPath.Replace("#", "%23");
mapGoogles.LoadWebPage("file:///" + safemobileDirPath + "/resource/" + MainForm2.MapHtmlName);
TimerToLoadMap.Stop();
}
catch (Exception ex)
{
SM.Debug("Ex:" + ex.ToString());
}
}
private WaitToLoad WaitWindow = null;
private void MessageScreen_Tick(object sender, EventArgs e)
{
try
{
MessageScreen.Stop();
MessageScreen.Enabled = false;
WaitWindow = new WaitToLoad(false);
WaitWindow.ShowDialog();
}
catch (Exception ex)
{
SM.Debug("Ex10:" + ex.ToString());
}
}
private void ProcessResponseFromMap(String url)
{
Double lat, lng;
//String slat, slng;
//Console.WriteLine("URL-ul: " + url);
if (url.IndexOf("app://") > -1)
{
//Console.WriteLine(url);
//URL-ul: app://landmark/7.885147283424357,38.8476562500004
//URL-ul: app://landmark/6.6646075621725975,36.914062500000334
//processRequest(url);
//polygon/[New2222,#008000,51.611194610484276,23.093261718750007,52.00517397055554,26.38916015625025,51.193115244645824,29.245605468749616]
if (url.IndexOf("landmark") > -1)
{
if (!currentTab.Equals("landmark"))
return;
// do not handle anything if the pin icon wasn't selected
if (!ChangeLandmarkLocationOnClick)
return;
// get current latitude and longitude
ParseLatAndLng(url.Remove(0, url.IndexOf("landmark") + 9));
}
//points/48.34164617237463,20.676269531249712,48.28319289548377,24.642333984375423,47.89424772020971,28.201904296874567,46.22545288226939,29.19067382812518,45.274886437048785,28.47656250000034
else if (url.IndexOf("points") > -1)
{
String tmpstr = url.Remove(0, url.IndexOf("points") + 7);
//Console.WriteLine("TmpStr:" + tmpstr);
String[] tmp = tmpstr.Split(",".ToCharArray());
//begin
Int32 max = tmp.Length;
Int32 Step = 0;//2
//Newarr.Clear();
int count = 1;
while (Step < (max - 1))
{
MainForm2.SafeConvertStringToDouble(tmp[Step], tmp[Step + 1], out lat, out lng);
if ((lat == 0) && (lng == 0))
;
else
{
if (rgvGeofencePoints.RowCount <= (Step / 2))
rgvGeofencePoints.Rows.AddNew();
rgvGeofencePoints.Rows[Step / 2].Cells["Number"].Value = count++;
rgvGeofencePoints.Rows[Step / 2].Cells[1].Value = global::Dispatcher.Properties.Resources.map;
rgvGeofencePoints.Rows[Step / 2].Cells["Lat"].Value = lat.ToString();
rgvGeofencePoints.Rows[Step / 2].Cells["Lng"].Value = lng.ToString();
rgvGeofencePoints.Rows[Step / 2].Cells[5].Value = global::Dispatcher.Properties.Resources.trashmic1;
}
Step += 2;
}
rgvGeofencePoints.Refresh();
// scroll to last inserted point
rgvGeofencePoints.TableElement.ScrollToRow(rgvGeofencePoints.RowCount - 1);
}
else if (url.IndexOf("map-loaded") > -1)
{
if (WaitWindow != null)
WaitWindow.Close();
}
else if (url.IndexOf("street-view-open") > -1)
{
String tmpstr = url.Remove(0, url.IndexOf("street-view-open") + 17);
//Console.WriteLine("parsare:" + tmpstr);
tmpstr = tmpstr.Trim();
if (tmpstr.ToUpper().CompareTo("TRUE") == 0) StreetViewOpened = true;
else StreetViewOpened = false;
}
}
}
/// <summary>
/// Get the Latitude and Longitude from the response received
/// from the maps
/// </summary>
/// <param name="mapResponse">String containing the response from the map</param>
private void ParseLatAndLng(string mapResponse)
{
String[] tmp = mapResponse.Split(",".ToCharArray());
Double lat = 0, lng = 0;
string decimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
String tmpLat = tmp[0];
String tmpLng = tmp[1];
if ((decimalSeparator == ",") && (tmpLat.Contains(".")))
{
tmpLat = tmpLat.Replace(".", ",");
tmpLng = tmpLng.Replace(".", ",");
}
else if ((decimalSeparator == ".") && (tmpLat.Contains(",")))
{
tmpLat = tmpLat.Replace(",", ".");
tmpLng = tmpLng.Replace(",", ".");
}
// get the double values of the latitude and longitude
Double.TryParse(tmpLat, out lat);
Double.TryParse(tmpLng, out lng);
// write the latitude and longitude to the spin editors
rseLatitude.Value = (decimal)lat;
rseLongitude.Value = (decimal)lng;
// prevent the case when no color is selected
if (rlvLandmarkColors.SelectedItem == null)
rlvLandmarkColors.SelectedIndex = 0;
// prevent the case when no icon is selected
if (rlvIcons.SelectedItem == null)
rlvIcons.SelectedIndex = 0;
KeyValuePair<Int32, LandmarkType> landType = (KeyValuePair<Int32, LandmarkType>)rlvIcons.SelectedItem.DataBoundItem;
Color color = (Color)rlvLandmarkColors.SelectedItem.DataBoundItem;
// if a new landmark was selected
if (rddlLandmarks.SelectedIndex == 0)
{
String datasetCMD = "setDataset,NewLandView";
datasetCMD = datasetCMD + ","
+ MainForm2.FixDoubleLAT(lat.ToString()) + ","
+ MainForm2.FixDoubleLNG(lng.ToString()) + ","
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ","
+ MainForm2.FixComma(rtbLandName.Text.Length > 0 ? rtbLandName.Text : "Unnamed") + ","
+ "speed" + ","
+ "0" + ","
+ MainForm2.FixComma(rtbLandDesc.Text) + ","
+ "landmarks/" + GetLandmarkIcon(landType.Value.Idx, color, GetIconSize()) + ","
+ "false" + "," + "false" + "," + "false";
datasetCMD = datasetCMD.Replace(';', ' ');
// send commands to map in order to remove previous new landmark,
// add the new one with its label
mapGoogles.ExecuteScript("window.GWTcallback('removeDataset,NewLandView');");
mapGoogles.ExecuteScript("window.GWTcallback('" + datasetCMD + "');");
mapGoogles.ExecuteScript("window.GWTcallback('" + "putOnMap,false,NewLandView');");
System.Threading.Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('" + "putLabels,NewLandView');");
//if (docLoad)
// mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," + MainForm2.FixDoubleLAT(lat + "") + "," + MainForm2.FixDoubleLNG(lng + "") + ",-1');");
}
else
{
//GetLandmarkIcon(land)
mapGoogles.ExecuteScript("window.GWTcallback('updateDataset,LandView,"
+ MainForm2.FixDoubleLAT(lat + "") + ","
+ MainForm2.FixDoubleLNG(lng + "") + ","
+ DateTime.Now.ToString() + ","
+ MainForm2.FixComma(rtbLandName.Text.Length > 0 ? rtbLandName.Text : "Unnamed") + ","
+ "speed" + ","
+ "0" + ","
+ MainForm2.FixComma(rtbLandDesc.Text) + ","
+ "landmarks/" + GetLandmarkIcon(landType.Value.Idx, color, GetIconSize()) + ","
+ "false" + "," + "false" + "," + "false" + "');");
mapGoogles.ExecuteScript("window.GWTcallback('putOnMap,false,LandView');");
//if (docLoad)
// mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," + MainForm2.FixDoubleLAT(lat + "") + "," + MainForm2.FixDoubleLNG(lng + "") + ",-1');");
}
}
private int previousLandmarkPosition = 0;
private bool ddlLandmarkChanging = false;
/// <summary>
/// Event handler for when the Selected Landmark had been changed. This function
/// will reset the UI elements values and fill focus the Landmark on the map
/// </summary>
private void rddlLandmarks_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
// remove previous NewLandmark when the previous position was the New Landmark one
if (previousLandmarkPosition == 0 && mapGoogles != null)
{
mapGoogles.ExecuteScript("window.GWTcallback('removeDataset,NewLandView');");
}
// save current position as previous
previousLandmarkPosition = e.Position;
if (e.Position == 0)
{
// reset landmark values
rtbLandName.ResetText();
rtbLandAddress.ResetText();
rtbLandDesc.ResetText();
// reset latitude and longitude
rseLatitude.Value = 0;
rseLongitude.Value = 0;
// reset colors and icons
rlvLandmarkColors.SelectedIndex = 0;
rlvIcons.SelectedIndex = 0;
// disable delete button
pb_DeleteLandmark.Enabled = false;
pb_DeleteLandmark.Cursor = Cursors.Default;
pb_DeleteLandmark.Image = global::Dispatcher.Properties.Resources.trash_disabled;
}
else if (e.Position > 0)
{
if (rddlLandmarks.SelectedItem != null)
{
LandmarkUI land = rddlLandmarks.SelectedItem.DataBoundItem as LandmarkUI;
if (land != null)
{
// reset landmark values
rtbLandName.Text = land.Name;
rtbLandAddress.Text = land.Address;
rtbLandDesc.Text = land.Description;
// reset latitude and longitude
rseLatitude.Value = (decimal)land.Latitude;
rseLongitude.Value = (decimal)land.Longitude;
// set color, icon and icon size
rlvLandmarkColors.SelectedIndex = colorsList.IndexOf(land.Color);
// select Callout alert
chklCallout.Checked = land.Callout;
RadListDataItem selectedSeverityItem = rddlSeverity.Items.FirstOrDefault(d => (int)d.Value == land.CalloutSeverity);
if (selectedSeverityItem != null)
rddlSeverity.SelectedItem = selectedSeverityItem;
else
rddlSeverity.SelectedIndex = 2;
// check to see if the type of landmark exists and then get the index of landmark type
// from the alfabethicall order
rlvIcons.SelectedIndex = landmarkTypesList.ContainsKey(land.TypeIdx) ? landmarkTypesList[land.TypeIdx].CrtIdx : 0;
// change the toggle buttons state
ChangeIconSizeToggleButtons(land.Size);
{
mapGoogles.ExecuteScript("window.GWTcallback('updateDataset,LandView,"
+ MainForm2.FixDoubleLAT(land.Latitude + "") + ","
+ MainForm2.FixDoubleLNG(land.Longitude + "") + ","
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ","
+ MainForm2.FixComma(land.Name) + ","
+ "speed" + ","
+ "0" + ","
+ MainForm2.FixComma(land.Description) + ","
+ "landmarks/" + GetLandmarkIcon(land.TypeIdx, land.Color, land.Size) + ","
+ "false" + "," + "false" + "," + "false" + "');");
mapGoogles.ExecuteScript("window.GWTcallback('putOnMap,false,LandView');");
if (docLoad)
mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," + MainForm2.FixDoubleLAT(land.Latitude + "") + "," + MainForm2.FixDoubleLNG(land.Longitude + "") + ",-1');");
}
}
// enable delete button
pb_DeleteLandmark.Enabled = true;
pb_DeleteLandmark.Cursor = Cursors.Hand;
pb_DeleteLandmark.Image = global::Dispatcher.Properties.Resources.trash_activ;
}
}
// flag that the change from the combobox had finished
ddlLandmarkChanging = false;
}
/// <summary>
/// Event handler for when the value inside the landmark combobox is changing. This
/// will have to prevent others UI controls to change the map and flod it
/// </summary>
private void rddlLandmarks_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
ddlLandmarkChanging = true;
}
/// <summary>
/// Change the toggle button which is on depending on the state received
/// as a parameter
/// </summary>
/// <param name="size">The desired icon size which needs to be selected</param>
private void ChangeIconSizeToggleButtons(Safedispatch_4_0.LandmarkUI.IconSize size)
{
// find out which value needs to be on
if (size == Safedispatch_4_0.LandmarkUI.IconSize.SMALL)
rrbSmall.CheckState = CheckState.Checked;
else if (size == Safedispatch_4_0.LandmarkUI.IconSize.MEDIUM)
rrbMedium.CheckState = CheckState.Checked;
else if (size == Safedispatch_4_0.LandmarkUI.IconSize.LARGE)
rrbLarge.CheckState = CheckState.Checked;
}
/// <summary>
/// Event handler for when the Alerts pictureBox or Label are pressed
/// This will cause the Alerts GroupBox to be brought to front
/// </summary>
private void AlertsMenu_Click(object sender, EventArgs e)
{
if(sender == pbAlerts || sender == labelAlerts)
rgbAlerts.BringToFront();
else if(sender == radLabel1 || sender == pictureBox1)
rgbAlertsLand.BringToFront();
}
/// <summary>
/// Event handler for when the Style pictureBox or Label are pressed
/// This will cause the Style GroupBox to be brought to front
/// </summary>
private void StyleMenu_Click(object sender, EventArgs e)
{
if(sender == pbStyle || sender == labelStyle)
rgbStyle.BringToFront();
else if(sender == pictureBox2 || sender == radLabel21)
rgbStyleLand.BringToFront();
}
/// <summary>
/// Event handler for when the speed limit checkbox state is changed
/// </summary>
private void rcbSpeedLimit_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
rseSpeedLimit.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the unit message checkbox state is changed
/// </summary>
private void rcbUnitMessage_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
rtbUnitMessage.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the units alert checkbox state is changed
/// </summary>
private void rcbUnitsAlert_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
rtbUnitsMessage.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
rcbddUnitsList.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the email alert checkbox state is changed
/// </summary>
private void rcbEmailAlert_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
rtbEmailAddress.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
rtbEmailMessage.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the Callout Zones alert checkbox state is changed
/// </summary>
private void chkzCallout_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
lbzCalloutSeverity.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
rddzSeverity.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the Callout LAndmarks alert checkbox state is changed
/// </summary>
private void chklCallout_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
lblCalloutSeverity.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
rddlSeverity.Enabled = (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? true : false);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
private string currentTab = "landmark";
private string activeTab = "landmark";
/// <summary>
/// Event handler for when the user enters in the Geofences Tab
/// This will populate the geofences list, if needed, hide landmarks
/// and display all geofences
/// </summary>
private void GeofencesWindow_Enter(object sender, EventArgs e)
{
// select 'New Geofence' item of the geofences list
if (currentTab.Equals("landmark"))
{
// remove all Landmarks
RemoveLandmarkDataset("LandView");
RemoveLandmarkDataset("NewLandView");
// display all geofences
DisplayGeofencesOnMap();
currentTab = "geofence";
}
/*
else if(currentTab.Equals("geofence"))
{
// the tab is loading
currentTab = "landmark";
// remove all Landmarks
RemoveLandmarkDataset("LandView");
RemoveLandmarkDataset("NewLandView");
// display all geofences
DisplayGeofencesOnMap();
// fake the change of index in order to set the new polygon state
//rddlGeofences_SelectedIndexChanged(rddlGeofences, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(rddlGeofences.SelectedIndex));
}*/
activeTab = "geofence";
}
/// <summary>
/// Event handler for when the user enters in the Landmarks Tab
/// This will populate the landmarks list, if needed, hide geofences
/// and display all landmarks
/// </summary>
private void LandmarksWindow_Enter(object sender, EventArgs e)
{
if (docLoad && currentTab.Equals("geofence"))
{
// clear all geofences from the map
RemoveAllGeofences();
DisplayAllLandmarksOnMap();
currentTab = "landmark";
// fake the change of index in order to set the new landmark state
//rddlLandmarks_SelectedIndexChanged(rddlLandmarks, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(rddlLandmarks.SelectedIndex));
}
activeTab = "landmark";
}
/// <summary>
/// Event handler for when the user enters in the Map Tab
/// This will keep a track of windows focus
/// </summary>
private void mapWindow_Enter(object sender, EventArgs e)
{
activeTab = "map";
}
/// <summary>
/// Event handler for when the mouse enters over the Delete or
/// Reset Landmark picture boxes
/// </summary>
private void pbDeleteAction_MouseEnter(object sender, EventArgs e)
{
if ((PictureBox)sender == pb_DeleteLandmark)
{
pb_DeleteLandmark.Image = global::Dispatcher.Properties.Resources.trash_over;
label_DeleteLandmark.ForeColor = Color.Black;
}
else if ((PictureBox)sender == pb_DeleteGeofence)
{
pb_DeleteGeofence.Image = global::Dispatcher.Properties.Resources.trash_over;
}
}
/// <summary>
/// Event handler for when the mouse leaves the Delete or
/// Reset Landmark picture boxes
/// </summary>
private void pbDeleteAction_MouseLeave(object sender, EventArgs e)
{
if ((PictureBox)sender == pb_DeleteLandmark)
{
pb_DeleteLandmark.Image = global::Dispatcher.Properties.Resources.trash_activ;
label_DeleteLandmark.ForeColor = Color.FromArgb(158, 158, 158);
}
else if ((PictureBox)sender == pb_DeleteGeofence)
{
pb_DeleteGeofence.Image = global::Dispatcher.Properties.Resources.trash_activ;
}
}
/// <summary>
/// Event handler for when the mouse enters over the Delete or
/// Reset Landmark labels
/// </summary>
private void labelLandmarkAction_MouseEnter(object sender, EventArgs e)
{
((RadLabel)sender).ForeColor = Color.FromArgb(0, 0, 0);
if ((RadLabel)sender == label_DeleteLandmark)
pbDeleteAction_MouseLeave(pb_DeleteLandmark, null);
}
/// <summary>
/// Event handler for when the mouse leaves the Delete or
/// Reset Landmark labels
/// </summary>
private void labelLandmarkAction_MouseLeave(object sender, EventArgs e)
{
((RadLabel)sender).ForeColor = Color.FromArgb(158, 158, 158);
if ((RadLabel)sender == label_DeleteLandmark)
pbDeleteAction_MouseLeave(pb_DeleteLandmark, null);
}
/// <summary>
/// Reset the values from all UI controls when the reset button is pressed
/// </summary>
private void pb_ResetLandmark_Click(object sender, EventArgs e)
{
// remove previous landmark with this name
// RemoveLandmarkDataset(rtbLandName.Text);
// trigger the event for changing the combobo item
rddlLandmarks_SelectedIndexChanged(null, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(rddlLandmarks.SelectedIndex));
}
/// <summary>
/// Delete the Landmark which is selected
/// </summary>
private void pb_DeleteLandmark_Click(object sender, EventArgs e)
{
LandmarkUI landmark = rddlLandmarks.SelectedItem.DataBoundItem as LandmarkUI;
if (landmark == null)
return;
Boolean validanswer = true;
// stupid thing abount the password from the old version
if (MainForm2.userIDX != landmark.UserIdx)
{
validanswer = false;
if (landmark.UserIdx != 1)
{
TabName tmp = new TabName((String)MainForm2.userIDHash[landmark.UserIdx], true);
tmp.ShowDialog();
string password = tmp.Name;
if (password.ToUpper().CompareTo(((String)MainForm2.passUserHash[landmark.UserIdx]).ToUpper()) == 0)
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
else
{
TabName tmp = new TabName("administrator", true);
tmp.ShowDialog();
string password = tmp.Name;
if (smdbObj.test_user(landmark.UserIdx, password))
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
if (validanswer)
{
// display the delete dialog
DialogResult dr2 = RadMessageBox.Show(this, mess1 + "\r\n" +
col0 + " = " + rtbLandName.Text + "\r\n" +
col1 + " = " + rtbLandDesc.Text + "\r\n" +
col2 + " = " + rseLatitude.Value + "\r\n" +
col3 + " = " + rseLongitude.Value + "\r\n" +
mess2, mess5, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
if (dr2 == DialogResult.Yes)
{
try
{
// delete the landmark from the database
smdbObj.Delete_Place(landmark.Idx + "");
parent.DisplayToast(string.Format(MainForm2.returnLNGString("LandDelSucces"), rtbLandName.Text),
string.Format(MainForm2.returnLNGString("HTMLLandDelSucces"), rtbLandName.Text));
// remove the landmark from the hash
MainForm2.LandIDHash.Remove(landmark.Idx);
// remove the landmark from the dataset
RemoveLandmarkFromDataset("LandView", landmark.Name);
}
catch (Exception ex)
{
if ((MainForm2.radioType == RADIOTYPE.HARRIS) || (MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor;
RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation);
SM.Debug("Ex:" + ex.ToString());
}
int idx = rddlLandmarks.SelectedIndex;
int newIdx = idx < rddlLandmarks.Items.Count - 1 ? idx : idx - 1;
// remove the landmark from the drop down list
rddlLandmarks.Items.RemoveAt(rddlLandmarks.SelectedIndex);
// select New Landmark Item
rddlLandmarks_SelectedIndexChanging(rddlLandmarks, new Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs(newIdx));
rddlLandmarks_SelectedIndexChanged(rddlLandmarks, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(newIdx));
}
}
}
/// <summary>
/// Save the landmark to the database, add it to the hash and to the
/// drop down list
/// </summary>
private void rbSaveLandmark_Click(object sender, EventArgs e)
{
string password = "";
Place res = new Place();
Boolean saveOK = true;
// get the selected Landmark which can be the 'New Landmark' one
LandmarkUI landmark = rddlLandmarks.SelectedItem.DataBoundItem as LandmarkUI;
if (landmark == null)
return;
// check if the landmark name was completed
if ((rtbLandName.Text.Trim().Length >= 1) && (rtbLandName.Text.Trim() != "\\"))
{
try
{
// check if a landmark with same name exists in the database
res = smdbObj.test_place_exist(rtbLandName.Text, landmark.Idx + "");
}
catch (Exception ex)
{
SM.Debug("Error Test on save from add new place" + ex.Message);
RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation);
return;
}
// if no error was found until now
if (saveOK)
{
// display a modify message if a similar landmark was found into db
if (res != null)
{
DialogResult dr2 = RadMessageBox.Show(this, messadd + "\r\n" +
res.name + " = " + res.desc + "\r\n" +
rseLatitude.Value + " = " + res.lat.ToString() + "\r\n" +
rseLongitude.Value + " = " + res.lng.ToString() + "\r\n" +
messaddquiz, messaddname, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
if (dr2 == DialogResult.No)
saveOK = false;
}
}
if (saveOK)
{
Boolean validanswer = true;
if (MainForm2.userIDX != landmark.UserIdx && landmark.UserIdx > 0 && landmark.Idx > 0)
{
validanswer = false;
if (landmark.UserIdx != 1)
{
TabName tmp = new TabName((String)MainForm2.userIDHash[landmark.UserIdx], true);
DialogResult result = tmp.ShowDialog();
if (result == DialogResult.OK)
{
password = tmp.Name;
if (password.ToUpper().CompareTo(((String)MainForm2.passUserHash[landmark.UserIdx]).ToUpper()) == 0)
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
else
{
TabName tmp = new TabName("administrator", true);
DialogResult result = tmp.ShowDialog();
if (result == DialogResult.OK)
{
password = tmp.Name;
if (smdbObj.test_user(landmark.UserIdx, password))
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
}
if (validanswer)
{
try
{
Color color = colorsList[0];
// get the landmark color
if (rlvLandmarkColors.SelectedItem != null && rlvLandmarkColors.SelectedItem.DataBoundItem != null)
{
color = (Color)rlvLandmarkColors.SelectedItem.DataBoundItem;
}
// get landmark type
KeyValuePair<Int32, LandmarkType> landType = (KeyValuePair<Int32, LandmarkType>)rlvIcons.SelectedItem.DataBoundItem;
if (landmark.Idx != 0)
smdbObj.Delete_Place(landmark.Idx + "");
if (!chklCallout.Checked)
rddlSeverity.SelectedIndex = 2;
// insert the landmark
smdbObj.Insert_Place(rtbLandName.Text, rtbLandDesc.Text, (Double)rseLatitude.Value,
(Double)rseLongitude.Value, (landType.Value != null ? landType.Value.Idx + "" : "1") + "",
rtbLandAddress.Text, MainForm2.userIDX, color, GetIconSize(), chklCallout.Checked, (int)rddlSeverity.SelectedItem.Value);
parent.DisplayToast(string.Format(MainForm2.returnLNGString("LandSaveSucces"), rtbLandName.Text),
(rddlLandmarks.SelectedIndex == 0 ?
string.Format(MainForm2.returnLNGString("HTMLLandAddedSucces"), rtbLandName.Text) :
string.Format(MainForm2.returnLNGString("HTMLLandUpdatedSucces"), rtbLandName.Text)
));
if (landmark.Idx != 0)
{
Int32 tmp = smdbObj.Get_Last_Place_Insert();
smdbObj.Update_all_old_alarms(tmp.ToString(), landmark.Idx + "");
smdbObj.Update_all_old_Reports(tmp.ToString(), landmark.Idx + "", false);
}
// reload hash tables
smdbObj.get_land_and_ID_Hash();
// reload all hash tables
ReloadLandmarksDDL(rtbLandName.Text);
parent.Send_UDP_cmd("#209#", 0, 0);
}
catch (Exception ex)
{
SM.Debug("Error on save from add new place" + ex.Message + ex.StackTrace);
RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation);
}
}
}
}
else
{
RadMessageBox.Show(msgNotSave, msgWar, MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
/// <summary>
/// Remove the landmark from the map
/// </summary>
/// <param name="datasetName">Name for the landmark dateset which needs to be removed</param>
private void RemoveLandmarkDataset(String datasetName)
{
mapGoogles.ExecuteScript("window.GWTcallback('removeDataset," + datasetName + "');");
}
/// <summary>
/// Delete a landmark from the dataset, a.k.a. eliminate it from the map
/// </summary>
/// <param name="datasetName">Dataset name in which the landmark is to be found</param>
/// <param name="landmarkName">Landmark name which is to be deleted</param>
private void RemoveLandmarkFromDataset(String datasetName, String landmarkName)
{
mapGoogles.ExecuteScript("window.GWTcallback('deletefromdataset," + datasetName + "," + landmarkName + "');");
}
/// <summary>
/// Event when the color had changed for a landmark
/// </summary>
private void rlvLandmarkColors_SelectedIndexChanged(object sender, EventArgs e)
{
OnSomethingChangedForLandmark(rtbLandName.Text, rtbLandName.Text);
if (rddlLandmarks.SelectedItem.Text == MainForm2.returnLNGString("newLand") && isFilterLoaded == true)
{
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvLandmarkColors.Name, rlvLandmarkColors.SelectedIndex.ToString());
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvIcons.Name, rlvIcons.SelectedIndex.ToString());
}
}
/// <summary>
/// Event when the icon had changed for a landmark
/// </summary>
private void rlvIcons_SelectedIndexChanged(object sender, EventArgs e)
{
OnSomethingChangedForLandmark(rtbLandName.Text, rtbLandName.Text);
if (rddlLandmarks.SelectedItem.Text == MainForm2.returnLNGString("newLand") && isFilterLoaded == true)
{
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvLandmarkColors.Name, rlvLandmarkColors.SelectedIndex.ToString());
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvIcons.Name, rlvIcons.SelectedIndex.ToString());
}
}
/// <summary>
/// Determin the size of the icon as displayed in the UI
/// </summary>
/// <returns>Returns the size of the icon</returns>
private LandmarkUI.IconSize GetIconSize()
{
// determin the icon size
return rrbMedium.IsChecked ? LandmarkUI.IconSize.MEDIUM :
(rrbLarge.IsChecked ? LandmarkUI.IconSize.LARGE : LandmarkUI.IconSize.SMALL);
}
/// <summary>
/// The Latitude or Longitude of a landmark had changed
/// </summary>
private void rseLatLng_ValueChanged(object sender, EventArgs e)
{
OnSomethingChangedForLandmark(rtbLandName.Text, rtbLandName.Text);
}
/// <summary>
/// Event which will handle every change of the landmark, meaning color,
/// latitude/longitude, type, name
/// </summary>
/// <param name="landmarkName">Name of the landmark which will be </param>
private void OnSomethingChangedForLandmark(String prevLandmarkName, String crtlandmarkName)
{
if (rlvIcons.SelectedIndex < 0 || rlvIcons.SelectedItem.DataBoundItem == null)
return;
if (rlvLandmarkColors.SelectedIndex < 0 || rlvLandmarkColors.SelectedItem.DataBoundItem == null)
return;
// do not change the icon if the latitude and longitude ar false
if (rseLongitude.Value == 0 && rseLongitude.Value == 0)
return;
KeyValuePair<Int32, LandmarkType> landType = (KeyValuePair<Int32, LandmarkType>)rlvIcons.SelectedItem.DataBoundItem;
Color color = (Color)rlvLandmarkColors.SelectedItem.DataBoundItem;
string dataSetName = "LandView";
if (rddlLandmarks.SelectedIndex == 0)
dataSetName = "NewLandView";
UpdateLandmarkOnMap(dataSetName, (prevLandmarkName.Length > 0 ? prevLandmarkName : "Unnamed"),
(double)rseLatitude.Value, (double)rseLongitude.Value,
crtlandmarkName.Length > 0 ? crtlandmarkName : "Unnamed",
rtbLandDesc.Text, landType.Value.Idx, color, GetIconSize());
}
/// <summary>
/// Update the pin on the map as a change of any parameter of it
/// </summary>
/// <param name="datasetName">Name of the dataset which will be modified</param>
/// <param name="lat">Latitude of the landmark</param>
/// <param name="lng">Longitude of the landmark</param>
/// <param name="name">Name of the landmark</param>
/// <param name="description">Description of the landmark</param>
/// <param name="landmarkTypeID">Id of the type of the landmark</param>
/// <param name="color">Color of the landmark</param>
/// <param name="size">Size of the landmark</param>
private void UpdateLandmarkOnMap(String datasetName, String prevLandmarkName, Double lat, Double lng, String name, String description,
int landmarkTypeID, Color color, LandmarkUI.IconSize size)
{
if (mapGoogles == null || !docLoad)
return;
// do not change the map from here in order to prevent all others UI
// controls to change the map
if (ddlLandmarkChanging)
return;
mapGoogles.ExecuteScript("window.GWTcallback('deletefromdataset," + datasetName + "," + prevLandmarkName + "');");
Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('updateDataset," + datasetName + ","
+ MainForm2.FixDoubleLAT(lat + "") + ","
+ MainForm2.FixDoubleLNG(lng + "") + ","
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ","
+ MainForm2.FixComma(name) + ","
+ "speed" + ","
+ "0" + ","
+ MainForm2.FixComma(description) + ","
+ "landmarks/" + GetLandmarkIcon(landmarkTypeID, color, size) + ","
+ "false" + "," + "false" + "," + "false" + "');");
mapGoogles.ExecuteScript("window.GWTcallback('putOnMap,false,LandView');");
Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('putOnMap,false," + datasetName + "');");
//if (docLoad)
// mapGoogles.ExecuteScript("window.GWTcallback('centerzoom," + MainForm2.FixDoubleLAT(lat + "") + "," + MainForm2.FixDoubleLNG(lng + "") + ",-1');");
}
/// <summary>
/// Event Handler for when the size of the icon had changed.
/// This will cause the Toggle Buttons to change the values
/// and to trigger the ChangeLandmark event
/// </summary>
private void rrb_CheckStateChanged(object sender, EventArgs e)
{
RadRadioButton senderButton = sender as RadRadioButton;
if (senderButton == null)
return;
// get current state
CheckState state = (senderButton.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On ? CheckState.Checked : CheckState.Unchecked);
// change the toggle button
if (senderButton == rrbSmall)
rtbSmall.CheckState = state;
else if (senderButton == rrbMedium)
rtbMedium.CheckState = state;
else if (senderButton == rrbLarge)
rtbLarge.CheckState = state;
// change on the map the size of the landmark
if (state == CheckState.Checked)
OnSomethingChangedForLandmark(rtbLandName.Text, rtbLandName.Text);
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadRadioButton)sender).Name, ((RadRadioButton)sender).IsChecked.ToString());
}
/// <summary>
/// Intercept the mouse up event on the Toggle Buttons in order to
/// prevent setting the toggle button to unchecked state and to
/// change the radio buttons when a new toggle button becames active
/// </summary>
private void rtb_MouseUp(object sender, MouseEventArgs e)
{
RadToggleButton toggleSender = sender as RadToggleButton;
if (toggleSender == null)
return;
if ((toggleSender.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On))
{
// this means that I have now on state and I can change the state
Telerik.WinControls.Enumerations.ToggleState state = Telerik.WinControls.Enumerations.ToggleState.On;
// change the state of the radio buttons according to the
// radio button
if (toggleSender == rtbSmall)
rrbSmall.ToggleState = state;
else if (toggleSender == rtbMedium)
rrbMedium.ToggleState = state;
else if (toggleSender == rtbLarge)
rrbLarge.ToggleState = state;
}
else
{
// force the state to be on because I don't need the user to set this toggle button
// to off state
toggleSender.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On;
}
}
/// <summary>
/// Event handler for when the key are pressed on the Landmark/Geofence Name TextBox.
/// This will filter the keys in order to allow only letters, digits, space and backspace
/// </summary>
private void rtbName_KeyPress(object sender, KeyPressEventArgs e)
{
// check to see if letters,digits, backspace or space was pressed and handle them
if (Char.IsLetterOrDigit(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == ' '
|| e.KeyChar == '-' || e.KeyChar == '_')
{
}
else
{
// do now allow the key to update the text
e.Handled = true;
}
}
/// <summary>
/// Event handler for when the text name of the landmark had changed. This
/// will update the UI
/// </summary>
private void rtbLandName_TextChanging(object sender, TextChangingEventArgs e)
{
OnSomethingChangedForLandmark(e.OldValue, e.NewValue);
}
/// <summary>
/// Enable or disable the clicks on the map which allows the move of the landmark
/// with every click
/// </summary>
private void rcbMoveLandmark_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
ChangeLandmarkLocationOnClick = rcbMoveLandmark.Checked;
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
/// <summary>
/// Event handler for when the Selected Geofence had been changed. This function
/// will reset the UI elements values and fill focus the Geofence on the map
/// </summary>
private void rddlGeofences_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
// reset the UI
ResetGeofenceUI();
#region NEW GEOFENCE
if (e.Position == 0)
{
rcbEditGeofence.Text = MainForm2.returnLNGString("startDrawGeo");
rcbEditGeofence.Checked = false;
// reset geofence values
rtbGeofenceName.ResetText();
try
{
rgvGeofencePoints.DataSource = null;
while (rgvGeofencePoints.Rows.Count > 0)
rgvGeofencePoints.Rows.RemoveAt(0);
}
catch (Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); }
if (isFilterLoaded && rddlGeofences.Text != MainForm2.returnLNGString("newGeofence"))
{
// reset opacity and width values
rseBorderOpacity.Value = (decimal)0.7;
rseBorderWidth.Value = (decimal)4;
rseFillOpacity.Value = (decimal)0.7;
// reset colors and icons
rlvGeofenceBorderColors.SelectedIndex = 0;
rlvGeofenceFillColors.SelectedIndex = 0;
}
// disable delete button
pb_DeleteGeofence.Enabled = false;
pb_DeleteGeofence.Cursor = Cursors.Default;
pb_DeleteGeofence.Image = global::Dispatcher.Properties.Resources.trash_disabled;
Color fillColor = Color.Black;
if (rlvGeofenceFillColors.SelectedItem != null)
fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
String hexFillColor = "#" + fillColor.R.ToString("X2") + fillColor.G.ToString("X2") + fillColor.B.ToString("X2");
Color borderColor = Color.Black;
if (rlvGeofenceBorderColors.SelectedItem != null)
borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
String hexBorderColor = "#" + borderColor.R.ToString("X2") + borderColor.G.ToString("X2") + borderColor.B.ToString("X2");
if (mapGoogles != null)
{
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('newPolygon," + rddlGeofences.Text + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString())
+ "');");
Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + rddlGeofences.Text + "');");
}
else
{
Thread.Sleep(100);
//mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon," + "tmpPol" + "');");
}
// focus the map in order to prevent change of geofence on keys press
mapGoogles.Focus();
}
}
#endregion
#region OLD GEOFENCE
else if (e.Position > 0)
{
if (rddlGeofences.SelectedItem != null)
{
rcbEditGeofence.Text = MainForm2.returnLNGString("editGeo");
// delete temporary geofence
//mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon,tmpPol');");
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence != null)
{
// set geofence values
rtbGeofenceName.Text = geofence.Name;
// write points into the list
int cont = 0;
rgvGeofencePoints.DataSource = null;
while (rgvGeofencePoints.Rows.Count > 0)
rgvGeofencePoints.Rows.RemoveAt(0);
String datasetCMD = "";
String datasetZoom = "";
// populate point and calculate which map zone to be displayed
foreach (GeofencePoint point in geofence.points)
{
rgvGeofencePoints.Rows.AddNew();
rgvGeofencePoints.Rows[cont].Cells[0].Value = (cont + 1).ToString();
rgvGeofencePoints.Rows[cont].Cells[1].Value = global::Dispatcher.Properties.Resources.map;
rgvGeofencePoints.Rows[cont].Cells[2].Value = Math.Round(point.Latitude, 5).ToString();
rgvGeofencePoints.Rows[cont].Cells[3].Value = Math.Round(point.Longitude, 5).ToString();
rgvGeofencePoints.Rows[cont].Cells[4].Value = point.Idx;
rgvGeofencePoints.Rows[cont].Cells[5].Value = global::Dispatcher.Properties.Resources.trashmic1;
datasetCMD = datasetCMD + MainForm2.FixDoubleLAT(point.Latitude.ToString()) + "," + MainForm2.FixDoubleLNG(point.Longitude.ToString()) + ",";
datasetZoom = datasetZoom + "," + MainForm2.FixDoubleLAT(point.Latitude.ToString()) + "," + MainForm2.FixDoubleLNG(point.Longitude.ToString()) + ",,,";
cont++;
}
rgvGeofencePoints.TableElement.ScrollToRow(rgvGeofencePoints.RowCount - 1);
// set opacity and width values
rseBorderOpacity.Value = (decimal)geofence.BorderOpacity;
rseBorderWidth.Value = (decimal)geofence.BorderWidth;
rseFillOpacity.Value = (decimal)geofence.FillOpacity;
// set color for border and fill
rlvGeofenceBorderColors.SelectedIndex = colorsList.IndexOf(geofence.BorderColor);
rlvGeofenceFillColors.SelectedIndex = colorsList.IndexOf(geofence.FillColor);
// set speed limit value
if (MainForm2.isInMile)
rseSpeedLimit.Value = (geofence.SpeedLimit > 0 ? (decimal)(geofence.SpeedLimit * 0.621371) : 50);
else
rseSpeedLimit.Value = (geofence.SpeedLimit > 0 ? (decimal)geofence.SpeedLimit : 50);
rcbSpeedLimit.Checked = (geofence.SpeedLimit > 0 ? true : false);
// select alert type
rcbddAlertType.Items[0].Checked = geofence.AlertTypee == GeofenceUI.AlertType.IN
|| geofence.AlertTypee == GeofenceUI.AlertType.IN_OUT;
rcbddAlertType.Items[1].Checked = (geofence.AlertTypee == GeofenceUI.AlertType.OUT
|| geofence.AlertTypee == GeofenceUI.AlertType.IN_OUT);
// select callout
chkzCallout.Checked = geofence.Callout;
RadListDataItem selectedSeverityItem = rddzSeverity.Items.FirstOrDefault(d => (int)d.Value == geofence.CalloutSeverity);
if (selectedSeverityItem != null)
rddzSeverity.SelectedItem = selectedSeverityItem;
else
rddzSeverity.SelectedIndex = 0;
if (isFilterLoaded && rddlGeofences.Text != MainForm2.returnLNGString("newGeofence"))
{
// select message to unit
rcbUnitMessage.Checked = geofence.SendUnitMessage;
rtbUnitMessage.Text = geofence.UnitMessage;
// select message to units and the checked units
rcbUnitsAlert.Checked = geofence.SendUnitsMessage;
rtbUnitsMessage.Text = geofence.UnitsMessage;
// check for assigned units
foreach (RadCheckedListDataItem item in rcbddUnitsList.Items)
{
Vehicle veh = item.DataBoundItem as Vehicle;
if (veh == null)
return;
// check if the assigned unit id exists inside the units list
if (geofence.UnitsIds.Contains(veh.sc_id))
item.Checked = true;
}
// select email and message addres + body
rcbEmailAlert.Checked = geofence.SendEmail;
rtbEmailAddress.Text = geofence.EmailAddress;
rtbEmailMessage.Text = geofence.EmailBody;
}
// enable delete button
pb_DeleteGeofence.Enabled = true;
pb_DeleteGeofence.Cursor = Cursors.Hand;
pb_DeleteGeofence.Image = global::Dispatcher.Properties.Resources.trash_activ;
// display the geofence on map
DisplayGeofencesOnMap();
// start editing the geofence
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon," + geofence.Name + "');");
Thread.Sleep(100);
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + geofence.Name + "');");
}
/*
else
{
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon," + "tmpPol" + "');");
}*/
}
}
}
#endregion
// display a message for when the table elements are empty
if (rgvGeofencePoints.RowCount > 0)
rgvGeofencePoints.TableElement.Text = "";
else
rgvGeofencePoints.TableElement.Text = MainForm2.returnLNGString("pressMap");
}
/// <summary>
/// Event handler for when the value inside the geofence combobox is changing. This
/// will have to prevent others UI controls to change the map and flod it
/// </summary>
private void rddlGeofences_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
// delete temporary geofence
if (rddlGeofences.SelectedIndex == 0)
mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon,tmpPol');");
}
/// <summary>
/// Reset the values from all UI controls when the reset button is pressed
/// </summary>
private void rbResetGeofence_Click(object sender, EventArgs e)
{
// delete temporary geofence
if (rddlGeofences.SelectedIndex == 0)
mapGoogles.ExecuteScript("window.GWTcallback('deletePolygon,tmpPol');");
// trigger the event for changing the combobo item
rddlGeofences_SelectedIndexChanged(null, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(rddlGeofences.SelectedIndex));
}
/// <summary>
/// Delete the geofence which is selected
/// </summary>
private void pb_DeleteGeofence_Click(object sender, EventArgs e)
{
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence == null)
return;
Boolean validanswer = true;
if (MainForm2.userIDX != geofence.UserIdx)
{
validanswer = false;
if (geofence.UserIdx != 1)
{
TabName tmp = new TabName((String)MainForm2.userIDHash[geofence.UserIdx], true);
tmp.ShowDialog();
string password = tmp.Name;
if (password.ToUpper().CompareTo(((String)MainForm2.passUserHash[geofence.UserIdx]).ToUpper()) == 0)
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
else
{
TabName tmp = new TabName("administrator", true);
tmp.ShowDialog();
string password = tmp.Name;
if (smdbObj.test_user(geofence.UserIdx, password))
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
if (validanswer)
{
DialogResult dr2 = RadMessageBox.Show(this, mess11 + " " + '"' + rddlGeofences.Text + '"' + " " + messWill + "\r\n" + mess12,
mess15, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
if (dr2 == DialogResult.Yes)
{
try
{
smdbObj.Delete_Zone(geofence.Idx + "");
smdbObj.Delete_Zone_Alarm(geofence.Idx + "");
smdbObj.Delete_Zone_Reports(geofence.Idx + "");
MainForm2.ZoneIDHash.Remove(geofence.Idx + "");
parent.DisplayToast(string.Format(MainForm2.returnLNGString("GeoDelSucces"), rddlGeofences.Text),
string.Format(MainForm2.returnLNGString("HTMLGeoDelSucces"), rddlGeofences.Text, rgvGeofencePoints.Rows.Count));
}
catch (Exception ex)
{
RadMessageBox.Show(MainForm2.returnLNGString("database"), MainForm2.returnLNGString("war"), MessageBoxButtons.OK, RadMessageIcon.Exclamation);
SM.Debug("Ex:" + ex.ToString());
}
int idx = rddlGeofences.SelectedIndex;
int newIdx = idx < rddlGeofences.Items.Count - 1 ? idx : idx - 1;
// remove the geofence from the drop down list
rddlGeofences.Items.RemoveAt(rddlGeofences.SelectedIndex);
rddlGeofences_SelectedIndexChanging(rddlGeofences, new Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs(newIdx));
rddlGeofences_SelectedIndexChanged(rddlGeofences, new Telerik.WinControls.UI.Data.PositionChangedEventArgs(newIdx));
if(rddlGeofences.Items.Count == 1)
{
// remove the final geofence
RemoveAllGeofences();
}
//rddlGeofences.SelectedIndex = (idx < rddlGeofences.Items.Count -1 ? idx : idx - 1);
//rddlGeofences.SelectedIndex = 0;
// reload all geofences
//ReloadGeofencesDDL("");
}
}
}
/// <summary>
/// Event handler when a geofence needs to be saved
/// </summary>
private void rbSaveGeofence_Click(object sender, EventArgs e)
{
int geofenceIdx = 0;
int geofenceUserIdx = -1;
if (rtbGeofenceName.Text.Equals(MainForm2.returnLNGString("newGeofence")))
{
RadMessageBox.Show("You are not allowed to use 'New Geofence' as name for a geofence", "Wrong geofence name", MessageBoxButtons.OK, RadMessageIcon.Error);
return;
}
if (rcbUnitsAlert.Checked && rcbddUnitsList.Text == "")
{
RadMessageBox.Show("You have to select at least one unit!", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
return;
}
// if a new geofence should be added
if (rddlGeofences.SelectedIndex != 0)
{
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence != null)
{
geofenceIdx = geofence.Idx;
geofenceUserIdx = geofence.UserIdx;
}
}
// check if another geofence exists with the same name
{
Boolean saveOK = true;
foreach (Int32 obj in MainForm2.ZoneIDHash.Keys)
{
if (((ZoneClass)MainForm2.ZoneIDHash[obj]).name.ToUpper() == rddlGeofences.Text.ToUpper())
{
if (geofenceIdx != 0)
{
if (geofenceIdx != obj)
{
saveOK = false;
RadMessageBox.Show(mess4 + " " + '"' + rddlGeofences.Text + '"' + " " + mess6);
break;
}
}
else
{
saveOK = false;
RadMessageBox.Show(mess4 + " " + '"' + rddlGeofences.Text + '"' + " " + mess6);
break;
}
}
}
// check if the name of points is greater than three
if ((saveOK) && (rgvGeofencePoints.RowCount < 3))
{
RadMessageBox.Show(need3Points, msgWar, MessageBoxButtons.OK, RadMessageIcon.Error);
saveOK = false;
return;
}
// check if the email addresses are valid
if (rcbEmailAlert.Checked && saveOK)
{
bool areEmailValids = (rtbEmailAddress.Text.Length > 0 ? true : false);
string[] emails = rtbEmailAddress.Text.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
foreach (String email in emails)
{
// check if there is an email which is invalid
if (!Utils.IsValidEmail(email))
areEmailValids = false;
}
// display invalid emails message
if (!areEmailValids)
{
RadMessageBox.Show(msgInvalidEmail);
saveOK = false;
return;
}
}
if (saveOK)
{
// redundant check for geofence
if ((rtbGeofenceName.Text.Trim().Length >= 1) && (rtbGeofenceName.Text.Trim() != "\\"))
{
bool validanswer = true;
if (MainForm2.userIDX != geofenceUserIdx && geofenceUserIdx > 0 && geofenceIdx > 0)
{
validanswer = false;
if (geofenceUserIdx != 1)
{
TabName tmp = new TabName((String)MainForm2.userIDHash[geofenceUserIdx], true);
DialogResult result = tmp.ShowDialog();
if (result == DialogResult.OK)
{
String password = tmp.Name;
if (password.ToUpper().CompareTo(((String)MainForm2.passUserHash[geofenceUserIdx]).ToUpper()) == 0)
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
else
{
TabName tmp = new TabName("administrator", true);
DialogResult result = tmp.ShowDialog();
if (result == DialogResult.OK)
{
String password = tmp.Name;
if (smdbObj.test_user(geofenceUserIdx, password))
validanswer = true;
else RadMessageBox.Show(MainForm2.returnLNGString("passIsWrong"), MainForm2.returnLNGString("error"), MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
}
if (!validanswer)
return;
try
{
// delete previous geofence if an update is desired
if (geofenceIdx != 0)
smdbObj.Delete_Zone(geofenceIdx + "");
// get the type of the alarm
GeofenceUI.AlertType alertType = GeofenceUI.AlertType.NONE;
if (rcbddAlertType.Items[0].Checked && rcbddAlertType.Items[1].Checked)
alertType = GeofenceUI.AlertType.IN_OUT;
else if (rcbddAlertType.Items[0].Checked)
alertType = GeofenceUI.AlertType.IN;
else if (rcbddAlertType.Items[1].Checked)
alertType = GeofenceUI.AlertType.OUT;
String listOfUnits = "";
String imeilist = "";
if (rcbUnitsAlert.Checked)
{
// check for assigned units
foreach (RadCheckedListDataItem item in rcbddUnitsList.Items)
{
Vehicle veh = item.DataBoundItem as Vehicle;
if (veh == null)
continue;
// get the checked items and add them to the list
if (item.Checked)
{
// add imei and id to the lists
listOfUnits += veh.sc_id.ToString() + ",";
imeilist += veh.IMEI.ToString() + ",";
}
}
}
// get and convert geofence value
Int32 Speedval = 0;
if (rcbSpeedLimit.Checked)
Speedval = (MainForm2.isInMile ?
(Int32)Math.Round((Int32)rseSpeedLimit.Value * 1.60934) : (Int32)rseSpeedLimit.Value);
// get fillColor and borderColor
Color fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
Color borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
// get all geofence points
List<PointonZone> points = new List<PointonZone>();
foreach (GridViewRowInfo row in rgvGeofencePoints.Rows)
{
GridViewCellInfo lat = row.Cells["Lat"];
GridViewCellInfo lng = row.Cells["Lng"];
Decimal latD = (Decimal)lat.Value;
Decimal lngD = (Decimal)lng.Value;
points.Add(new PointonZone((double)latD, (double)lngD, geofenceIdx));
}
if (!chkzCallout.Checked)
rddzSeverity.SelectedIndex = 2;
if (!rcbEmailAlert.Checked)
{
rtbEmailAddress.ResetText();
rtbEmailMessage.ResetText();
}
// insert the geofence
string from = (MainForm2.radioType == RADIOTYPE.SIMOCO) ? "Simoco" : (MainForm2.radioType == RADIOTYPE.EXCERA) ? "Excera" : "SafeMobile";
Int32 newIdx = smdbObj.InsertGeofence(rtbGeofenceName.Text, fillColor, rseFillOpacity.Value, borderColor, rseBorderWidth.Value,
rseBorderOpacity.Value, points, alertType, Speedval, rcbUnitMessage.Checked ? rtbUnitMessage.Text.Replace("\'", "\'\'") : "",
rcbUnitsAlert.Checked ? rtbUnitsMessage.Text.Replace("\'", "\'\'") : "", listOfUnits, imeilist,
rcbEmailAlert.Checked ? rtbEmailAddress.Text.Replace("\'", "\'\'") : "", "Geofence Alert from " + from,
rtbEmailMessage.Text.Replace("\'", "\'\'"), chkzCallout.Checked, (int)rddzSeverity.SelectedItem.Value, MainForm2.userIDX);
parent.DisplayToast(string.Format(MainForm2.returnLNGString("GeoSaveSucces"), rtbGeofenceName.Text),
(rddlGeofences.SelectedIndex == 0 ?
string.Format(MainForm2.returnLNGString("HTMLGeoAddedSucces"), rtbGeofenceName.Text, rgvGeofencePoints.Rows.Count) :
string.Format(MainForm2.returnLNGString("HTMLGeoUpdatedSucces"), rtbGeofenceName.Text, rgvGeofencePoints.Rows.Count)
));
// update alerts if updated a previous geofence
if (geofenceIdx != 0)
{
smdbObj.Update_all_old_alarms(newIdx + "", geofenceIdx + "");
smdbObj.Update_all_old_Reports(newIdx + "", geofenceIdx + "", true);
}
// reload zones inside the hash tables
MainForm2.ZoneIDHash = smdbObj.get_all_zone();
// reload Geofences ComboBox
ReloadGeofencesDDL(rtbGeofenceName.Text);
parent.Send_UDP_cmd("#209#", 0, 0);
Utils.WriteLine("Send Restart Command to App Server (209)", ConsoleColor.Yellow);
}
catch (Exception ex)
{
SM.Debug("Erorr insert zone:" + ex.ToString());
}
}
else
{
RadMessageBox.Show(msgNotSaveZone, msgWar, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
}
MainForm2.ForceSaveZone = false;
}
}
//end save zone
}
/// <summary>
/// Event which will handle every change of the geofence, meaning border and
/// fill color, border width, opacity, name
/// </summary>
/// <param name="prevGeofenceName">Name of the Geofence before editing</param>
/// <param name="crtGeofenceName">Name of the Geofence after editing</param>
private void OnSomethingChangedForGeofence(String prevGeofenceName, String crtGeofenceName)
{
Color fillColor = Color.Black;
if (rlvGeofenceFillColors.SelectedItem != null)
fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
String hexFillColor = "#" + fillColor.R.ToString("X2") + fillColor.G.ToString("X2") + fillColor.B.ToString("X2");
Color borderColor = Color.Black;
if (rlvGeofenceBorderColors.SelectedItem != null)
borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
String hexBorderColor = "#" + borderColor.R.ToString("X2") + borderColor.G.ToString("X2") + borderColor.B.ToString("X2");
if (rddlGeofences.SelectedIndex == 0)
crtGeofenceName = "tmpPol";
if (mapGoogles != null)
mapGoogles.ExecuteScript("window.GWTcallback('updatePolygonStyle," + crtGeofenceName + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString())
+ "');");
}
/// <summary>
/// Event handler for when the value of a spin editor had changed. This will
/// cause the geofence to be redraw one map
/// </summary>
private void rseGeofence_ValueChanged(object sender, EventArgs e)
{
OnSomethingChangedForGeofence(rddlGeofences.Text, rddlGeofences.Text);
rse_ValueChanged(sender, e);
}
/// <summary>
/// Event when the color had changed for a geofence, for border or fill
/// </summary>
private void rlvGeofenceColors_SelectedIndexChanged(object sender, EventArgs e)
{
OnSomethingChangedForGeofence(rddlGeofences.Text, rddlGeofences.Text);
if (rddlGeofences.SelectedItem.Text == MainForm2.returnLNGString("newGeofence") && isFilterLoaded == true)
{
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvGeofenceFillColors.Name, rlvGeofenceFillColors.SelectedIndex.ToString());
VisualSettings.InsertUpdateHTforVisualItems(this.Name, rlvGeofenceBorderColors.Name, rlvGeofenceBorderColors.SelectedIndex.ToString());
}
}
/// <summary>
/// Event handler for when a latitude/longitude position had finished editing
/// </summary>
private void rgvGeofencePoints_CellEndEdit(object sender, GridViewCellEventArgs e)
{
Utils.WriteLine("Edit : " + e.Row.Index + " | " + e.Column.Index, ConsoleColor.Red);
if (rddlGeofences.SelectedIndex == 0)
// update the state of the geofence
UpdateNewGeofence();
// display the geofence on map
DisplayGeofencesOnMap();
// start editing the geofence
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + rddlGeofences.Text + "');");
}
}
/// <summary>
/// Set the default values for the new lat lng point
/// </summary>
private void rgvGeofencePoints_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
{
if (rgvGeofencePoints.CurrentRow is GridViewNewRowInfo)
{
// set delete icon
e.Row.Cells["ColDelete"].Value = global::Dispatcher.Properties.Resources.trashmic1;
if (rgvGeofencePoints.RowCount > 0)
{
e.Row.Cells["Number"].Value = rgvGeofencePoints.RowCount + 1;
e.Row.Cells["Lat"].Value = rgvGeofencePoints.Rows[rgvGeofencePoints.RowCount - 1].Cells["Lat"].Value;
e.Row.Cells["Lng"].Value = rgvGeofencePoints.Rows[rgvGeofencePoints.RowCount - 1].Cells["Lng"].Value;
}
else
{
e.Row.Cells["Number"].Value = rgvGeofencePoints.RowCount + 1;
e.Row.Cells["Lat"].Value = 0;
e.Row.Cells["Lng"].Value = 0;
}
}
}
/// <summary>
/// Event when the show geofence state is change, this will cause the other
/// geofences apart from the one in the combobox, to be hidden or shown
/// on the map
/// </summary>
private void rcbShowGeofences_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
// display the geofence on map
DisplayGeofencesOnMap();
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
// start editing the geofence
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + rddlGeofences.Text + "');");
}
}
/// <summary>
/// Intercept delete point event in order to reset the geofence on the map
/// </summary>
private void rgvGeofencePoints_CellClick(object sender, GridViewCellEventArgs e)
{
if (e.ColumnIndex == 5 && e.RowIndex != -1)
{
Utils.WriteLine("Nr of rows : " + rgvGeofencePoints.RowCount);
DialogResult dr2 = RadMessageBox.Show(this, messPointToDel + "\r\n" +
"Latitude" + " = " + rgvGeofencePoints.Rows[e.RowIndex].Cells[2].Value.ToString() + "\r\n" +
"Longitude" + " = " + rgvGeofencePoints.Rows[e.RowIndex].Cells[3].Value.ToString() + "\r\n" +
mess12, mess16, MessageBoxButtons.YesNo, RadMessageIcon.Exclamation);
if (dr2 == DialogResult.Yes)
{
try
{
// remove point from the grid
rgvGeofencePoints.Rows.RemoveAt(e.RowIndex);
if (rgvGeofencePoints.RowCount == 0)
{
rgvGeofencePoints.DataSource = new DataTable();
rgvGeofencePoints.Refresh();
}
rgvGeofencePoints.Invalidate();
// reset the crt index number
for (int i = 0; i < rgvGeofencePoints.Rows.Count; i++)
rgvGeofencePoints.Rows[i].Cells[0].Value = (i + 1).ToString();
if (rddlGeofences.SelectedIndex == 0)
// update the state of the geofence
UpdateNewGeofence();
// display the geofence on map
DisplayGeofencesOnMap();
// start editing the geofence
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + rddlGeofences.Text + "');");
}
}
catch (Exception ex)
{ SM.Debug("Error on delete point:" + ex.ToString()); }
}
}
}
/// <summary>
/// Intercept when a document window had changed it's state, on double click
/// or drag/drop, and set that it is not allowed to close/hide it
/// </summary>
private void radDock1_DockStateChanged(object sender, DockWindowEventArgs e)
{
e.DockWindow.ToolCaptionButtons = ToolStripCaptionButtons.None;
e.DockWindow.AllowedDockState = AllowedDockState.Docked | AllowedDockState.TabbedDocument;
}
/// <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;
}
private void rgvGeofencePoints_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
// display a message for when the table elements are empty
if (rgvGeofencePoints.RowCount > 0)
rgvGeofencePoints.TableElement.Text = "";
else
rgvGeofencePoints.TableElement.Text = "Press on the map in order to" + Environment.NewLine + " add points for the geofence.";
}
#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
private void toggleButton_StateChanged(object sender, StateChangedEventArgs args)
{
if (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
((RadToggleButton)sender).ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
else
((RadToggleButton)sender).ButtonElement.ButtonFillElement.BackColor = Color.White;
}
private void LandZoneCfg_Load(object sender, EventArgs e)
{
// change color for the toggle button
if (rtbLarge.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
rtbLarge.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
else if (rtbMedium.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
rtbMedium.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
else if (rtbSmall.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
rtbSmall.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor;
VisualSettings.loadUserVisualSettings(this.Name, this.radScrollablePanel1.PanelContainer, MainForm2.HashVal);
VisualSettings.loadUserVisualSettings(this.Name, this.rgbStyle, MainForm2.HashVal);
VisualSettings.loadUserVisualSettings(this.Name, this.rgbAlerts, MainForm2.HashVal);
VisualSettings.loadUserVisualSettings(this.Name, this.rgbStyleLand, MainForm2.HashVal);
VisualSettings.loadUserVisualSettings(this.Name, this.rgbAlertsLand, MainForm2.HashVal);
isFilterLoaded = true;
}
/// <summary>
/// Change background color for the row according to its state and theme
/// </summary>
private void rgvGeofencePoints_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e.RowElement.IsSelected)
{
e.RowElement.DrawFill = true;
e.RowElement.BackColor = MainForm2.GridSelectedRow;
e.RowElement.NumberOfColors = 1;
}
else
e.RowElement.DrawFill = false;
}
private void rgvGeofencePoints_CellFormatting(object sender, CellFormattingEventArgs e)
{
// do not highlight the cell on which was clicked
if (e.CellElement.IsCurrent)
e.CellElement.IsCurrent = false;
}
private void pbEditGeofence_Click(object sender, EventArgs e)
{
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence != null)
{
// set geofence values
//rtbGeofenceName.Text = geofence.Name;
string GeoName = rddlGeofences.Text;
// set name for the geofence as tmpPol if new Geofence
if (rddlGeofences.SelectedIndex == 0)
GeoName = "tmpPol";
if (pbEditGeofence.Tag.Equals("disabled"))
{
pbEditGeofence.Tag = "enabled";
// start editing the geofence
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + GeoName + "');");
pbEditGeofence.Image = themeEditActive_Image;
}
else
{
pbEditGeofence.Tag = "disabled";
// start editing the geofence
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon," + GeoName + "');");
pbEditGeofence.Image = themeEditDisabled_Image;
}
}
}
private void rgvGeofencePoints_UserAddedRow(object sender, GridViewRowEventArgs e)
{
Utils.WriteLine("ADDED", ConsoleColor.DarkCyan);
if (rddlGeofences.SelectedIndex == 0)
// update the state of the geofence
UpdateNewGeofence();
// display the geofence on map
DisplayGeofencesOnMap();
// start editing the geofence
if (rcbEditGeofence.Checked)
{
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + rddlGeofences.Text + "');");
}
}
private void rse_ValueChanged(object sender, EventArgs e)
{
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadSpinEditor)sender).Name, ((RadSpinEditor)sender).Value.ToString());
}
/// <summary>
/// Enable or disable the editing of selected geofence by actions on map
/// </summary>
private void rcbEditGeofence_ToggleStateChanged(object sender, StateChangedEventArgs args)
{
GeofenceUI geofence = rddlGeofences.SelectedItem.DataBoundItem as GeofenceUI;
if (geofence != null)
{
// set geofence values
//rtbGeofenceName.Text = geofence.Name;
string GeoName = rddlGeofences.Text;
// set name for the geofence as tmpPol if new Geofence
if (rddlGeofences.SelectedIndex == 0)
GeoName = "tmpPol";
if (rcbEditGeofence.Checked)
{
// send the new polygon command if the selected index is 'New Geofence'
// this must be done because the start edit of a new geofence with 0 points
// not working
if (rgvGeofencePoints.RowCount == 0)
{
Color fillColor = Color.Black;
if (rlvGeofenceFillColors.SelectedItem != null)
fillColor = (Color)rlvGeofenceFillColors.SelectedItem.DataBoundItem;
String hexFillColor = "#" + fillColor.R.ToString("X2") + fillColor.G.ToString("X2") + fillColor.B.ToString("X2");
Color borderColor = Color.Black;
if (rlvGeofenceBorderColors.SelectedItem != null)
borderColor = (Color)rlvGeofenceBorderColors.SelectedItem.DataBoundItem;
String hexBorderColor = "#" + borderColor.R.ToString("X2") + borderColor.G.ToString("X2") + borderColor.B.ToString("X2");
mapGoogles.ExecuteScript("window.GWTcallback('newPolygon," + GeoName + ","
+ hexFillColor + ","
+ MainForm2.FixDoubleLAT(rseFillOpacity.Value.ToString()) + ","
+ hexBorderColor + ","
+ MainForm2.FixDoubleLAT(rseBorderOpacity.Value.ToString()) + ","
+ MainForm2.FixDoubleLAT(rseBorderWidth.Value.ToString())
+ "');");
Thread.Sleep(100);
}
// start editing the geofence
mapGoogles.ExecuteScript("window.GWTcallback('startEditPolygon," + GeoName + "');");
}
else
// start editing the geofence
mapGoogles.ExecuteScript("window.GWTcallback('endEditPolygon," + GeoName + "');");
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString());
}
}
private void RadTextBox_Leave(object sender, EventArgs e)
{
if (isFilterLoaded) VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadTextBox)sender).Name, ((RadTextBox)sender).Text);
}
#region Compute Coordinates
private void rtbLandAddress_Leave(object sender, EventArgs e)
{
ComputeCoordinates();
}
private void rtbLandAddress_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ComputeCoordinates();
}
}
private void ComputeCoordinates()
{
decimal lat, lng;
volltmpGo2.getCoordinates(rtbLandAddress.Text, out lat, out lng);
if (lat > -181 || lng > -181)
{
rseLatitude.Value = lat;
rseLongitude.Value = lng;
}
}
#endregion Compute Coordinates
}
public class GetColorID
{
public Color getColorid(Int32 id)
{
Color ret = Color.Black;
switch (id)
{
case 0: ret = Color.Red;
break;
case 1: ret = Color.Green;
break;
case 2: ret = Color.Blue;
break;
case 3: ret = Color.Cyan;
break;
case 4: ret = Color.Magenta;
break;
}
return ret;
}
}
}