using System; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.Threading; using System.Resources; using Telerik.WinControls.UI; using Telerik.WinControls; using Telerik.WinControls.UI.Docking; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.EngineCore; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Display; using SafeMobileLib; using Dispatcher.maptab.UIClasses; namespace Safedispatch_4_0 { /// /// This class implements the history tab. /// /// The history tab contains two areas, left and right. On the left side /// the vehicle selection and intervals are made, and on the right side information /// is displayed according to the criteria from the left public partial class HistoryTabGIS : UserControl { public bool KillTimerActive = false; public String calcADDr, endtimegreate,onlyonecar; private Boolean docLoad = false; private Int32 loadcnt = 0; private Int32 timestart = 0, timestop = 0; private volatile Boolean ForceStop = false; private volatile Int32 timeTemp = 0; private volatile bool first = true; private volatile RoutesInfo routesTemp; private Hashtable NametoSym = new Hashtable(); private volatile Boolean hitLimit = false; private String plsselcectcar = ""; private Boolean AniStateExpande = false; private IMapControl3 m_mapControl = null; public IGraphicTracker m_graphicTracker = null; public IGraphicTracker PlayTracker = null; private String Nodata = ""; private Image theme24H_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.h_24h, MainForm2.ButtonColor); private Image themelFilter_Image = Utils.ChangeColor(Dispatcher.Properties.Resources.h_filter, MainForm2.ButtonColor); private void setLanguage() { calcADDr = MainForm2.returnLNGString("retrevAddr"); endtimegreate = MainForm2.returnLNGString("endtimegreate"); //animatedPlayExpandoText.Text = MainForm2.returnLNGString("animatedPlayExpando"); btDisplayHeading.Text = MainForm2.returnLNGString("btDisplayHeading"); btnDisplayHistory.Text = MainForm2.returnLNGString("displayHistoryButton"); label1.Text = MainForm2.returnLNGString("hlabel1"); //sel_desel.Text = MainForm2.returnLNGString("cbselAll"); //gridHistoryPoints.Columns[0].HeaderText = MainForm2.returnLNGString("ID"); //gridHistoryPoints.Columns[1].HeaderText = MainForm2.returnLNGString("htableVehiclesListColumns1"); //gridHistoryPoints.Columns[2].HeaderText = MainForm2.returnLNGString("alarmsListColumns1"); //gridHistoryPoints.Columns[3].HeaderText = MainForm2.returnLNGString("tableVehiclesListColumns2"); //if (MainForm2.isInMile) gridHistoryPoints.Columns[4].HeaderText = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.milesh + ")"; //else gridHistoryPoints.Columns[4].HeaderText = MainForm2.returnLNGString("tablevehiclesListColumns3") + " (" + MainForm2.kmh + ")"; //gridHistoryPoints.Columns[5].HeaderText = MainForm2.returnLNGString("DI"); //gridHistoryPoints.Columns[6].HeaderText = MainForm2.returnLNGString("DO"); //toolWindow1.Text = MainForm2.returnLNGString("selectionExpando"); //toolWindow2.Text = MainForm2.returnLNGString("tabPage1"); //windowHistoryResult.Text = MainForm2.returnLNGString("tabPage2"); label2.Text = MainForm2.returnLNGString("label2"); label3.Text = MainForm2.returnLNGString("label3"); //label4.Text = MainForm2.returnLNGString("label4"); //label5.Text = MainForm2.returnLNGString("label5"); //vehiclesList.Columns[0].HeaderText = ""; //vehiclesList.Columns[1].HeaderText = ""; //vehiclesList.Columns[2].HeaderText = MainForm2.returnLNGString("htableVehiclesListColumns1"); onlyonecar = MainForm2.returnLNGString("onlyonecar"); plsselcectcar = MainForm2.returnLNGString("selval"); //radLabel3.Text = MainForm2.returnLNGString("hisInv"); rdpStartTime.Culture = MainForm2.culture; rdpEndTime.Culture = MainForm2.culture; rdpStartTime.CustomFormat = rdpEndTime.CustomFormat = Utils.getDayCustomFormat(MainForm2.is24hours, MainForm2.DayFirst); //if (MainForm2.is24hours) //{ // if (MainForm2.DayFirst) // { // dtFrom.CustomFormat = "dd/MM/yyyy HH:mm"; // dtTo.CustomFormat = "dd/MM/yyyy HH:mm"; // } // else // { // dtFrom.CustomFormat = "MM/dd/yyyy HH:mm"; // dtTo.CustomFormat = "MM/dd/yyyy HH:mm"; // } //} //else //{ // if (MainForm2.DayFirst) // { // dtFrom.CustomFormat = "dd/MM/yyyy hh:mm tt"; // dtTo.CustomFormat = "dd/MM/yyyy hh:mm tt"; // } // else // { // dtFrom.CustomFormat = "MM/dd/yyyy hh:mm tt"; // dtTo.CustomFormat = "MM/dd/yyyy hh:mm tt"; // } //} String speedname = MainForm2.HistSpeedLimit.ToString() + " " + MainForm2.kmh; if (MainForm2.isInMile) speedname = MainForm2.HistSpeedLimit.ToString() + " " + MainForm2.milesh; //lbSpeedLimit.Text = MainForm2.returnLNGString("spdlimit") + ": " + speedname; Nodata = MainForm2.returnLNGString("nodata");//nodata; rcbComputeAddress.Text = MainForm2.returnLNGString("compAddr"); rcbSpeedLower.Text = MainForm2.returnLNGString("lowerSpeed"); rcbSpeedLower.Text = (!MainForm2.isInMile) ? string.Format(rcbSpeedLower.Text,(MainForm2.returnLNGString("kmh"))) : string.Format(rcbSpeedLower.Text,(MainForm2.returnLNGString("milesh"))); rcbSpeedUpper.Text = MainForm2.returnLNGString("upperSpeed"); rcbSpeedUpper.Text = (!MainForm2.isInMile) ? string.Format(rcbSpeedUpper.Text, (MainForm2.returnLNGString("kmh"))) : string.Format(rcbSpeedUpper.Text, (MainForm2.returnLNGString("milesh"))); } public HistoryTabGIS(MainForm2 parentParam, String tabNameParam) { tabName = tabNameParam; parent = parentParam; try { smdbObj = new SMdb_access(); foreach (String obj in MainForm2.vehicleHT.Keys) { vehicleListNames.Add(((Vehicle)MainForm2.vehicleHT[obj]).busName); routesHT[((Vehicle)MainForm2.vehicleHT[obj]).busName] = new RoutesInfo(((Vehicle)MainForm2.vehicleHT[obj]).IMEI, ((Vehicle)MainForm2.vehicleHT[obj]).busName); } } catch (Exception ex) { SM.Debug("Error Connect to database: " + ex.ToString()); MainForm2.Connfailed = true; return; } InitializeComponent(); #region STYLE THEMING labelUnits.ForeColor = labelSlideshow.ForeColor = MainForm2.LabelColor; btnDisplayHistory.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; btDisplayHeading.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; rbResetHistory.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; // play buttons btBack.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; btPause.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; btForward.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; btPlay.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; btStop.ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; pb24H.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.h_24h, MainForm2.ButtonColor); theme24H_Image = pb24H.Image; pbFilter.Image = Utils.ChangeColor(Dispatcher.Properties.Resources.i_search, MainForm2.ButtonColor); #endregion // set theme for the Message Box RadMessageBox.SetThemeName("TelerikMetroBlue"); // add filter rule/predicate to the units tree treeViewUnits.TreeViewElement.FilterPredicate = FilterNode; // create the custom column which will display the positions in // the new way HistoryGridColumn ctc = new HistoryGridColumn("history"); ctc.AllowResize = true; ctc.Name = "history"; ctc.FieldName = "history"; ctc.HeaderText = "history"; ctc.AutoSizeMode = BestFitColumnMode.AllCells; ctc.HeaderTextAlignment = ContentAlignment.MiddleLeft; ctc.SortOrder = RadSortOrder.Ascending; this.gridHistoryPoints.TableElement.RowHeight = 55; this.gridHistoryPoints.Columns.Add(ctc); this.gridHistoryPoints.Columns.Move(ctc.Index, 0); // create the toolTip that will be displayed when the user sets a pattern // over the pictureBox toolTipHelp = new ToolTip(); toolTipHelp.ToolTipTitle = ""; toolTipHelp.AutoPopDelay = 0; toolTipHelp.InitialDelay = 0; toolTipHelp.ReshowDelay = 0; toolTipHelp.IsBalloon = false; toolTipHelp.ShowAlways = true; // add the groups and the units to the tree view populateListBoxGroup(); populateListBoxUnits(); // set the values for start and end time rdpStartTime.Value = DateTime.Now.AddDays(-1); rdpEndTime.Value = DateTime.Now; // disable the history result window foreach (Control ctr in windowHistoryResult.Controls) ctr.Enabled = false; setLanguage(); minTime = Int32.MaxValue; maxTime = 0; if (MainForm2.Connfailed) return; GetPositionForStart = false; txProgStatus.Visible = false; HistroyProgBar.Visible = false; HistoryPanel.Visible = false; rdpStartTime.Value = DateTime.Now; rdpEndTime.Value = DateTime.Now; toolWindow1.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu; toolWindow1.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; toolWindow1.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide; toolWindow2.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu; toolWindow2.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; windowHistoryResult.ToolCaptionButtons = Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.AutoHide | Telerik.WinControls.UI.Docking.ToolStripCaptionButtons.SystemMenu; windowHistoryResult.DocumentButtons &= ~Telerik.WinControls.UI.Docking.DocumentStripButtons.Close; windowHistoryResult.AllowedDockState = AllowedDockState.Docked | AllowedDockState.AutoHide; ContextMenuService menuService = this.radDock1.GetService(); menuService.ContextMenuDisplaying += menuService_ContextMenuDisplaying; btnDisplayHistory.Visible = false; //btDisplayHeading.Size = new Size(splitPanel2.Width - 10, btDisplayHeading.Height); //if (MainForm2.InterCalcAddr) rcbComputeAddress.Checked = true; //else rcbComputeAddress.Checked = false; rdpStartTime.CustomFormat = rdpEndTime.CustomFormat = Utils.getDayCustomFormat(MainForm2.is24hours, MainForm2.DayFirst); //if (MainForm2.is24hours) //{ // if (MainForm2.DayFirst) // { // dtFrom.CustomFormat = "dd/MM/yyyy HH:mm"; // dtTo.CustomFormat = "dd/MM/yyyy HH:mm"; // } // else // { // dtFrom.CustomFormat = "MM/dd/yyyy HH:mm"; // dtTo.CustomFormat = "MM/dd/yyyy HH:mm"; // } //} //else //{ // if (MainForm2.DayFirst) // { // dtFrom.CustomFormat = "dd/MM/yyyy hh:mm tt"; // dtTo.CustomFormat = "dd/MM/yyyy hh:mm tt"; // } // else // { // dtFrom.CustomFormat = "MM/dd/yyyy hh:mm tt"; // dtTo.CustomFormat = "MM/dd/yyyy hh:mm tt"; // } //} try { switch (MainForm2.radioType) { case RADIOTYPE.HYT: radDock1.BackColor = MainForm2.HyteraColor; //splitPanel5.BackColor = MainForm2.HyteraColor; //splitPanel2.BackColor = MainForm2.HyteraColor; //splitPanel3.BackColor = MainForm2.HyteraColor; //radSplitContainer1.BackColor = MainForm2.HyteraColor; //radSplitContainer2.BackColor = MainForm2.HyteraColor; documentTabStrip1.BackColor = MainForm2.HyteraColor; documentContainer1.BackColor = MainForm2.HyteraColor; HistoryPanel.BackColor = MainForm2.HyteraColor; //splitPanel2.BackColor = MainForm2.HyteraColor; //splitPanel3.BackColor = MainForm2.HyteraColor; break; case RADIOTYPE.HARRIS: radDock1.BackColor = MainForm2.HarrisColor; //splitPanel5.BackColor = MainForm2.HarrisColor; //splitPanel2.BackColor = MainForm2.HarrisColor; //splitPanel3.BackColor = MainForm2.HarrisColor; radSplitContainer1.BackColor = MainForm2.HarrisColor; //radSplitContainer2.BackColor = MainForm2.HarrisColor; documentTabStrip1.BackColor = MainForm2.HarrisColor; documentContainer1.BackColor = MainForm2.HarrisColor; HistoryPanel.BackColor = MainForm2.HarrisColor; //splitPanel2.BackColor = MainForm2.HarrisColor; //splitPanel3.BackColor = MainForm2.HarrisColor; this.label1.ForeColor = MainForm2.HarTextColor; this.label2.ForeColor = MainForm2.HarTextColor; this.label3.ForeColor = MainForm2.HarTextColor; //this.label4.ForeColor = MainForm2.HarTextColor; //this.label5.ForeColor = MainForm2.HarTextColor; this.label7.ForeColor = MainForm2.HarTextColor; //this.radLabel3.ForeColor = MainForm2.HarTextColor; //this.animatedPlayExpandoText.ForeColor = MainForm2.HarTextColor; //this.sel_desel.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor; this.rcbComputeAddress.ForeColor = MainForm2.HarTextColor; break; case RADIOTYPE.ATLAS: radDock1.BackColor = MainForm2.HarrisColor; //splitPanel5.BackColor = MainForm2.HarrisColor; //splitPanel2.BackColor = MainForm2.HarrisColor; //splitPanel3.BackColor = MainForm2.HarrisColor; radSplitContainer1.BackColor = MainForm2.HarrisColor; //radSplitContainer2.BackColor = MainForm2.HarrisColor; documentTabStrip1.BackColor = MainForm2.HarrisColor; documentContainer1.BackColor = MainForm2.HarrisColor; HistoryPanel.BackColor = MainForm2.HarrisColor; //splitPanel2.BackColor = MainForm2.HarrisColor; //splitPanel3.BackColor = MainForm2.HarrisColor; this.label1.ForeColor = MainForm2.HarTextColor; this.label2.ForeColor = MainForm2.HarTextColor; this.label3.ForeColor = MainForm2.HarTextColor; //this.label4.ForeColor = MainForm2.HarTextColor; //this.label5.ForeColor = MainForm2.HarTextColor; this.label7.ForeColor = MainForm2.HarTextColor; //this.radLabel3.ForeColor = MainForm2.HarTextColor; //this.animatedPlayExpandoText.ForeColor = MainForm2.HarTextColor; //this.sel_desel.ButtonElement.TextElement.ForeColor = MainForm2.HarTextColor; this.rcbComputeAddress.ForeColor = MainForm2.HarTextColor; //this.lbSpeedLimit.ForeColor = MainForm2.HarTextColor; break; case RADIOTYPE.SIMOCO: // we don't need this probably break; case RADIOTYPE.EXCERA: // we don't need this probably break; } } catch (Exception ex) { SM.Debug("Error on change color hytera:" + ex.ToString()); } } private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { if (e.MenuType == ContextMenuType.DockWindow && e.DockWindow.DockTabStrip is DocumentTabStrip) { for (int i = 0; i < e.MenuItems.Count; i++) { RadMenuItemBase menuItem = e.MenuItems[i]; if (menuItem.Name == "CloseWindow" || menuItem.Name == "CloseAllButThis" || menuItem.Name == "CloseAll" || menuItem.Name == "Floating" || menuItem.Name == "Docked" || menuItem.Name == "Hidden" || menuItem is RadMenuSeparatorItem) { menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } } } } private void GetPositionsAndAlarms(ArrayList listOfVehicles) { String toSendVehicles; String toSendTimes; toSendVehicles = ""; toSendTimes = ""; Int32 maxGooglePos = 50000; Int32 cntLimPos = 0; //max 50000 for google Int32 oldcntLimPos = 0; ArrayList ri; selectedPositions.Clear(); try { //for (int contor = 0; contor < listOfVehicles.Count; contor++) //{ // if (((bool)vehiclesList.Rows[contor].Cells[0].Value)) // { //for each group I should check the units which are selected foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { for (int contor2 = 0; contor2 < ((RoutesInfo)routesHT[unit.Text]).nOfRoutes; contor2++) { ri = (((RoutesInfo)routesHT[unit.Text]).routes); toSendVehicles = toSendVehicles + unit.Text + ","; if (cntLimPos < maxGooglePos) { ((RouteInfo)ri[contor2]).positions = smdbObj.get_HistoryPositions2(unit.Text, ((RouteInfo)ri[contor2]).startTime, ((RouteInfo)ri[contor2]).endTime); oldcntLimPos = cntLimPos; cntLimPos += ((RouteInfo)ri[contor2]).positions.Count; if (cntLimPos > maxGooglePos) { hitLimit = true; for (int i = (maxGooglePos - oldcntLimPos); i < (cntLimPos - oldcntLimPos); i++) ((RouteInfo)ri[contor2]).positions.RemoveAt(maxGooglePos - oldcntLimPos); } if (closeTabThread) return; ((RouteInfo)ri[contor2]).nOfPositions = ((RouteInfo)ri[contor2]).positions.Count; ((RouteInfo)ri[contor2]).Addresses = new String[((RouteInfo)ri[contor2]).positions.Count]; if (closeTabThread) return; ((RouteInfo)ri[contor2]).ComputeCorners(); if (addrDecision) { //aici caut adresse try { foreach (SMposition obj in ((RouteInfo)ri[contor2]).positions) { if ((obj.m_address == "") || (obj.m_address == " ")) { MainForm2.AddrCnt++; MainForm2.AddrGISQueue.Enqueue(new AddrAndID(MainForm2.AddrCnt, obj.m_lat, obj.m_lng)); MainForm2.IdReportHS.Add(MainForm2.AddrCnt.ToString(), "no address"); obj.m_address = MainForm2.AddrCnt.ToString(); } // obj.m_address = "LAT:" + Math.Round(dr.GetDouble(3), 5).ToString() + " , LNG:" + Math.Round(dr.GetDouble(4), 5).ToString(); } } catch (Exception ex) { SM.Debug("Error on calculate address:" + ex.ToString()); } } ((RoutesInfo)routesHT[unit.Text]).nOfPositions = ((RoutesInfo)routesHT[unit.Text]).nOfPositions + ((RouteInfo)ri[contor2]).nOfPositions; foreach (SMposition obj in ((RouteInfo)ri[contor2]).positions) selectedPositions.Add(obj); } else ((RouteInfo)ri[contor2]).positions = new ArrayList(); } } // } //} if (toSendVehicles.Length > 0) { // selectedPositions.Sort(new VehicleComparer()); actualNOfPositions = selectedPositions.Count; } else { actualNOfPositions = 0; selectedPositions.Clear(); } } catch (Exception ex) { SM.Debug("Error on database connection Mess: "+ex.Message); MainForm2.Connfailed = true; throw new ArgumentException("Database connection failed"); } } /// ///populates the list of vehicles from the Table tab /// an array of strings containing the vehicles names private void populateTableVehiclesList() { if (selectedPositions.Count > 0) { try { gridHistoryPoints.DataSource = null; gridHistoryPoints.DataSource = ListforGrid; // activate the history result tab radDock1.ActivateWindow(windowHistoryResult); // enable the history result window foreach (Control ctr in windowHistoryResult.Controls) ctr.Enabled = true; } catch (Exception ex) { SM.Debug("Error on populate grid" + ex.ToString()); } } else { gridHistoryPoints.Rows.Clear(); gridHistoryPoints.Refresh(); if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; RadMessageBox.Show(Nodata, "Info", MessageBoxButtons.OK, RadMessageIcon.Info); } gridHistoryPoints.TableElement.ScrollToRow(0); } /// /// Save the current configuration (selected vehicles and other info) /// to a XML file, from which information can be loaded afterwards /// private void UpdateAddresses(ArrayList listOfVehicles) { int contor; RoutesInfo routesTemp=null; foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { routesTemp = ((RoutesInfo)routesHT[unit.Text]); try { foreach (RouteInfo obj in routesTemp.routes) { if (obj.checkedRoute) { obj.ComputeAddresses(null); } } } catch (Exception ex) { SM.Debug(" Address: " + ex.ToString()); } } } /// /// Deletes all used resources /// public void Delete() { try { if (WorkerHead.IsBusy) closeTabThread = true; WorkerHead.Dispose(); this.Dispose(); } catch (Exception ex) { SM.Debug("Error on close TAB HISTORY:"+tabName+"/n Ex:"+ex.Message); } } private void textBox1_TextChanged(object sender, EventArgs e) { try { rseSkipSeconds.Text = ValidateText(rseSkipSeconds.Text); playInterval = Convert.ToInt32(rseSkipSeconds.Text); } catch (System.Exception ex) { SM.Debug("File: HistoryTabMap.cs Meth: textBox1_TextChanged " + ex.Message); rseSkipSeconds.Text = "10"; playInterval = 10; } } private void pauseIntervalTB_TextChanged(object sender, EventArgs e) { try { rsePositionDisplay.Text = ValidateText(rsePositionDisplay.Text); pauseInterval = Convert.ToInt32(rsePositionDisplay.Text); } catch (System.Exception ex) { SM.Debug("File: HistoryTabMap.cs Meth: pauseIntervalTB_TextChanged" + ex.Message); rsePositionDisplay.Text = "10"; pauseInterval = 10; } } private void UpdateCurrentTime(string text) { currentTimeBox.Text = text; } public delegate void UpdateCurrentTimeCallBack(string text); private void UpdateStatusBar(string text) { txProgStatus.Text = text; txProgStatus.Update(); } private void UpdateChangeSize(string text) { txProgStatus.Size = new Size(205, 20); txProgStatus.Update(); } public delegate void UpdateStatusBarCallBack(string text); private void UpdateProgressBar(Int32 max) { if (max == -1) { HistroyProgBar.ProgressBarElement.PerformStepValue1(); HistroyProgBar.Update(); } else HistroyProgBar.Maximum = max; } public delegate void UpdateProgressBarCallBack(Int32 max); private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; e.Result = Computation(worker, e); try { if (this.mapControl == null) return; parent.isCanceled[tabName] = false; int countStop = 0; while (this.WorkerHead.IsBusy) { Thread.Sleep(200); countStop++; if (countStop > 20) break; } Killtimer.Enabled = true; Killtimer.Start(); Killtimer.Stop(); this.mapControl = null; this.routesHT = null; GC.Collect(); } catch (Exception ex) { SM.Debug("Exception on close map HistoryTabMap "+ex.Message); } if ((MainForm2.ClosingApp)&&(!KillTimerActive)) { SM.Debug("Worker History : " + tabName + " FINISHED"); } } /// /// Validates the text from param; the text is valid if only contains numbers (from 0 to 9) /// /// The string to be validated /// public String ValidateText(String param) { string text, text2; int i; text = param; text2 = ""; for (i = 0; i < text.Length; i++) { if ((text[i] >= '0') && (text[i] <= '9')) { text2=text2+text[i]; } } return text2; } private Int32 CalcHead(Double lastLocX, Double lastLocY, Double prevLocX, Double prevLocY, Int32 heading) { Double dlng = lastLocX - prevLocX; Double dlat = lastLocY - prevLocY; Double mdelta_min = -0.00001; Double delta_min = 0.00001; Int32 headcalc = 0; Double blat = 0; Double blng = 0; if ((dlat > mdelta_min) && (dlat < delta_min) && ((mdelta_min < dlng) && dlng < (delta_min))) headcalc = (Int32)heading; else { if ((mdelta_min < dlat) && (dlat < delta_min)) { blng = 1; if (dlng < 0) headcalc = 180; else headcalc = 0; } else { blat = 1; if (dlat > 0) headcalc = 90; else headcalc = 270; } } if ((mdelta_min < dlng) && (dlng < delta_min)) { if (blat == 0) { if (dlat > 0) { if (headcalc == 180) headcalc = 135; if (headcalc == 0) headcalc = 45; } else { if (headcalc == 180) headcalc = 225; if (headcalc == 0) headcalc = 315; } } } else { if (blng == 0) { if (dlng < 0) { if (headcalc == 90) headcalc = 135; if (headcalc == 270) headcalc = 225; } else { if (headcalc == 90) headcalc = 45; if (headcalc == 270) headcalc = 315; } } } return headcalc; } /// /// Catches the click on the display history button /// Checks each vehicle for defined routes and displays them on the MapPoint control /// Computes the positions of the corners for all defined routes, for zooming purposes /// /// /// private void btDisplayHeadingHisotry_Click(object sender, EventArgs e) { // save upper and lower speed limits MainForm2.HistSpeedLimit = (rcbSpeedLower.Checked ? (int)rseSpeedLower.Value : 0); MainForm2.HistUpperSpeedLimit = (rcbSpeedUpper.Checked ? (int)rseSpeedUpper.Value : 0); try { smdbObj.Update_Speed_Limit("hisMinSpeed", MainForm2.HistSpeedLimit); smdbObj.Update_Speed_Limit("hisMaxSpeed", MainForm2.HistUpperSpeedLimit); } catch (Exception ex) { SM.Debug("Add history speed limit in Database" + ex.ToString()); } Boolean selOK = false; if (rdpStartTime.Enabled) { if (rdpStartTime.Value.GetSecondsFromDT().ConvertLocalToGMT() > rdpEndTime.Value.GetSecondsFromDT().ConvertLocalToGMT()) MessageBox.Show(endtimegreate, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); else { selOK = true; timestart = rdpStartTime.Value.GetSecondsFromDT().ConvertLocalToGMT(); timestop = rdpEndTime.Value.GetSecondsFromDT().ConvertLocalToGMT(); } } else { selOK = true; timestart = DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT() - 86400; timestop = DateTime.Now.GetSecondsFromDT().ConvertLocalToGMT(); } //hide animatedPlay //animatedPlayExpando.Enabled = false; if (selOK) { Boolean havecar = false; //for (int cont = 0; cont < vehiclesList.Rows.Count; cont++) // if ((bool)vehiclesList.Rows[cont].Cells[0].Value) { havecar = true; break; } //if (havecar) HeadStart(); // for each group I should check the units which are selected foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { havecar = true; break; } if (havecar) HeadStart(); else { if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; RadMessageBox.Show(plsselcectcar); } } } private volatile Boolean addrDecision = false; private void HeadStart() { try { //splitPanel3.SizeInfo.MaximumSize = new Size(splitPanel1.Width, 1); //splitPanel3.SizeInfo.MinimumSize = new Size(splitPanel1.Width, 1); int count = 0; //for (int cont = 0; cont < vehiclesList.Rows.Count; cont++) //{ // if ((bool)vehiclesList.Rows[cont].Cells[0].Value) // { // for each group I should check the units which are selected foreach(RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach(RadTreeNode unit in node.Nodes) if (unit.Checked) { count++; ((RoutesInfo)routesHT[unit.Text]).RemoveQuick(); ((RoutesInfo)routesHT[unit.Text]).AddRoute2(timestart, timestop, unit.Text, Color.Cyan, unit.Text + "_quick"); } /* if (count > 1) MainForm2.HistContinu = true; else MainForm2.HistContinu = false;*/ addrDecision = rcbComputeAddress.Checked; btnDisplayHistory.Enabled = false; btDisplayHeading.Enabled = false; rcbComputeAddress.Enabled = false; Cursor = Cursors.WaitCursor; //mapControl.MousePointer = GeoPointer.geoPointerHourglass; HistroyProgBar.Visible = true; HistroyProgBar.Value1 = 0; HistoryPanel.Visible = true; txProgStatus.Visible = true; txProgStatus.Clear(); WorkerHead.RunWorkerAsync(); } catch (Exception ex) { SM.Debug("Error on start heading" + ex.Message); } } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { if (this.mapControl == null) return; parent.isCanceled[tabName] = false; if (e.Cancelled) SM.Debug("File: HistoryTabMap.cs Meth: backgroundWorker1_RunWorkerCompleted You cancelled!"); else if (e.Error != null) SM.Debug("File: HistoryTabMap.cs Meth: backgroundWorker1_RunWorkerCompleted Worker exception: " + e.Error.ToString()); else SM.Debug("File: HistoryTabMap.cs Meth: backgroundWorker1_RunWorkerCompleted Complete - " + e.Result); // from DoWork //if (this.WorkerHead.IsBusy || this.WorkerHist.IsBusy) // Thread.Sleep(100); while (this.WorkerHead.IsBusy) { Thread.Sleep(100); } Killtimer.Enabled = true; Killtimer.Start(); Killtimer.Stop(); this.mapControl = null; this.routesHT = null; GC.Collect(); } catch (Exception ex) { SM.Debug("Final RunCompleted Worker History Error" + ex.ToString()); } if ((MainForm2.ClosingApp)&&(!KillTimerActive)) { SM.Debug("Worker History : " + tabName + " FINISHED"); } } enum PS { BACK = 0, PLAY, PAUSE, STOP, FORWARD } PS ePlayStatus = PS.STOP; PS ePrevPlayStatus = PS.STOP; private void btBack_Click(object sender, EventArgs e) { rseSkipSeconds.Enabled = true; rsePositionDisplay.Enabled = true; //expando1.Enabled = false; ePrevPlayStatus = ePlayStatus; ePlayStatus = PS.BACK; btBack.Enabled = true; btPlay.Enabled = true; btPause.Enabled = false; btStop.Enabled = true; btForward.Enabled = true; Thread.Sleep(200); } private void btPlay_Click(object sender, EventArgs e) { rseSkipSeconds.Enabled = false; rsePositionDisplay.Enabled = false; //expando1.Enabled = false; m_graphicTracker.RemoveAll(); ePrevPlayStatus = ePlayStatus; ePlayStatus = PS.PLAY; btBack.Enabled = false; btPlay.Enabled = false; btPause.Enabled = true; btStop.Enabled = true; btForward.Enabled = false; btDisplayHeading.Enabled = false; btnDisplayHistory.Enabled = false; rcbComputeAddress.Enabled = false; Thread.Sleep(200); } private void btPause_Click(object sender, EventArgs e) { rseSkipSeconds.Enabled = true; rsePositionDisplay.Enabled = true; ePrevPlayStatus = ePlayStatus; ePlayStatus = PS.PAUSE; btBack.Enabled = true; btPlay.Enabled = true; btPause.Enabled = false; btStop.Enabled = true; btForward.Enabled = true; btDisplayHeading.Enabled = true; btnDisplayHistory.Enabled = true; rcbComputeAddress.Enabled = true; Thread.Sleep(200); } private void btStopInvoke(string text) { btStop.PerformClick(); } public delegate void btStopInvokeCallBack(String text); private void btStop_Click(object sender, EventArgs e) { rseSkipSeconds.Enabled = true; rsePositionDisplay.Enabled = true; //expando1.Enabled = true; ePrevPlayStatus = ePlayStatus; ePlayStatus = PS.STOP; btBack.Enabled = false; btPlay.Enabled = true; btPause.Enabled = false; btStop.Enabled = false; btForward.Enabled = false; btDisplayHeading.Enabled = true; btnDisplayHistory.Enabled = true; rcbComputeAddress.Enabled = true; Thread.Sleep(200); } private void btForward_Click(object sender, EventArgs e) { rseSkipSeconds.Enabled = true; rsePositionDisplay.Enabled = true; //expando1.Enabled = false; ePrevPlayStatus = ePlayStatus; ePlayStatus = PS.FORWARD; btBack.Enabled = true; btPlay.Enabled = true; btPause.Enabled = false; btStop.Enabled = true; btForward.Enabled = true; Thread.Sleep(200); } long Computation(BackgroundWorker worker, DoWorkEventArgs e) { SMposition tempPos; int contor = 0; //ConvertDT convDT = new ConvertDT(); timeTemp = 0; first = true; while (MainForm2.isRunning) { if (FirstPlay) { FirstPlay = false; timeTemp = FirstTime; } Currenttime = timeTemp; try { Thread.Sleep(10); if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (ePlayStatus == ePrevPlayStatus) continue; switch (ePlayStatus) { case PS.PLAY: { if (first) { timeTemp = minTime; first = false; } if (ePrevPlayStatus == PS.STOP) { contor = 0; //while (contor < vehicleListNames.Count) //{ // if (((bool)vehiclesList.Rows[contor].Cells[0].Value)) // { foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { routesTemp = ((RoutesInfo)routesHT[unit.Text]); foreach (RouteInfo obj in routesTemp.routes) { if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (obj.checkedRoute) { /* Location loc = mapControl.ActiveMap.GetLocation(obj.GetCurrentPosition().m_lat, obj.GetCurrentPosition().m_lng, 10); pp = mapControl.ActiveMap.AddPushpin(loc, (String)vehiclesList.Rows[contor].Cells[2].Value); Thread.Sleep(10); if (pp != null && loc != null) { obj.SetPushpinMap(pp); pp.Symbol = busSymb.GetSymbolFromOrientation(obj.GetInitialHeading()); pp.MoveTo(vehiclesDataSet); if (checkBox2.Checked) { pp.BalloonState = GeoBalloonState.geoDisplayBalloon; } else { pp.BalloonState = GeoBalloonState.geoDisplayNone; } if (pp.Note == "") pp.Note = " "; }*/ IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(obj.GetCurrentPosition().m_lng, obj.GetCurrentPosition().m_lat); point.SpatialReference = MainForm2.CreateGeoCoordSys(); Int32 GISID = PlayTracker.Add(point as IGeometry, busSymb2.GetSymbolFromOrientation(obj.GetInitialHeading())); } } } // } // contor++; //} } // end if prev state is STOP try { while ((timeTemp >= minTime) && (timeTemp <= maxTime - playInterval) && (ePlayStatus == PS.PLAY)) { contor = 0; //while (contor < vehicleListNames.Count) //{ // if (((bool)vehiclesList.Rows[contor].Cells[0].Value)) // { foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { routesTemp = ((RoutesInfo)routesHT[unit.Text]); foreach (RouteInfo obj in routesTemp.routes) { if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (obj.checkedRoute) { tempPos = obj.LastPositionBeforeGivenTime(timeTemp - playInterval, timeTemp, out timeTemp, false); if (ePlayStatus == PS.PLAY) worker.ReportProgress(11, tempPos); else break; } } } // } // contor++; //} if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (pauseInterval > 200) { for (int mk = 0; mk < pauseInterval / 200; mk++) { if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } Thread.Sleep(200); } } else Thread.Sleep(pauseInterval); timeTemp = timeTemp + playInterval; Currenttime = timeTemp; } if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (timeTemp > maxTime - playInterval) { lock (this) { if ((currentTimeBox != null) && (!MainForm2.ClosingApp)) currentTimeBox.Invoke(new UpdateCurrentTimeCallBack(this.UpdateCurrentTime), new object[] {(maxTime).ConvertGMTToLocal().GetDTFromSeconds().ToString() }); btStop.Invoke(new btStopInvokeCallBack(this.btStopInvoke), new object[] { "test" }); } } } catch (Exception ex) { SM.Debug("Exception in play: " + ex.ToString()); } ePrevPlayStatus = PS.PLAY; } break; // --------------------------------------------------------- case PS.STOP: { StopProced(); } ePrevPlayStatus = PS.STOP; break; // --------------------------------------------------------- case PS.BACK: { //for (contor = 0; contor < vehicleListNames.Count; contor++) //{ // if (((bool)vehiclesList.Rows[contor].Cells[0].Value)) // { foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { routesTemp = ((RoutesInfo)routesHT[unit.Text]); foreach (RouteInfo obj in routesTemp.routes) { if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (obj.checkedRoute) { if (timeTemp >= minTime + playInterval) timeTemp = timeTemp - playInterval; else timeTemp = minTime; //tempPos = obj.LastPositionBeforeGivenTime(timeTemp - playInterval, timeTemp, out timeTemp,true); tempPos = obj.FirstPositionBeforeGivenTime(timeTemp); timeTemp = tempPos.m_time; worker.ReportProgress(11, tempPos); } } } // } //} } ePlayStatus = PS.PAUSE; break; // --------------------------------------------------------- case PS.PAUSE: break; // --------------------------------------------------------- case PS.FORWARD: { //for (contor = 0; contor < vehicleListNames.Count; contor++) //{ // if (((bool)vehiclesList.Rows[contor].Cells[0].Value)) // { foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { routesTemp = ((RoutesInfo)routesHT[unit.Text]); foreach (RouteInfo obj in routesTemp.routes) { if ((parent.isCanceled[tabName] != null && (bool)parent.isCanceled[tabName]) || MainForm2.ClosingApp) { e.Cancel = true; return 1; } if (obj.checkedRoute) { if (timeTemp <= maxTime - playInterval) timeTemp = timeTemp + playInterval; else timeTemp = maxTime; tempPos = obj.FirstPositionAfterGivenTime(timeTemp); timeTemp = tempPos.m_time; worker.ReportProgress(11, tempPos); } } } // } //} } ePlayStatus = PS.PAUSE; break; } } catch (Exception ex) { SM.Debug("File: HistoryTabMap.cs Meth: compuation :"+ex.ToString()); StopProced(); } } // end while (true) return 0; } private void StopProced() { //for (int contor = 0; contor < vehicleListNames.Count; contor++) //{ // if (routesHT != null && vehiclesList != null) // { // for each group I should check the units which are selected foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (routesHT != null && unit.Checked) { PlayTracker.RemoveAll(); routesTemp = ((RoutesInfo)routesHT[unit.Text]); if (routesTemp != null) if (routesTemp.nOfRoutes > 0) { foreach (RouteInfo obj in routesTemp.routes) { obj.ResetCurrentPosition(); } } } // } //} timeTemp = minTime; first = true; } long ComputHead(BackgroundWorker worker, DoWorkEventArgs e) { try { hitLimit = false; string proc1 = MainForm2.returnLNGString("Update"), proc2 = MainForm2.returnLNGString("Retriev"), proc3 = MainForm2.returnLNGString("Computing"), proc4 = MainForm2.returnLNGString("DelOld"); txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar),proc4); RoutesInfo tempRoutes = null; int contor; int i = 0; headingMode = true; if (closeTabThread) { e.Cancel = true; return 1; } //clean the map WorkerHead.ReportProgress(11); if (closeTabThread) { e.Cancel = true; return 1; } corners[0] = corners[2] = 181.00; corners[1] = corners[3] = -181.00; txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar), proc2); if (closeTabThread) { e.Cancel = true; return 1; } GetPositionsAndAlarms(vehicleListNames); if (closeTabThread) { e.Cancel = true; return 1; } txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar), proc1); UpdateAddresses(vehicleListNames); HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), actualNOfPositions / 250); if (closeTabThread) return 1; //checks for each vehicle if there is any defined route //there_are_routes is true if there are routes, and false otherwise bool there_are_routes = false; actualNOfPositions = 0; minTime = Int32.MaxValue; maxTime = 0; txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar), proc3); int progStep = 0; LNGMAX = -181;LNGMIN = 181; LATMAX = -91;LATMIN = 90; //for (contor = 0; contor < vehicleListNames.Count; contor++) //{ // if ((bool)vehiclesList.Rows[contor].Cells[0].Value) // { // for each group I should check the units which are selected foreach (RadTreeNode node in treeViewUnits.Nodes[0].Nodes) foreach (RadTreeNode unit in node.Nodes) if (unit.Checked) { tempRoutes = ((RoutesInfo)routesHT[unit.Text]); foreach (RouteInfo obj in tempRoutes.routes) { if (obj.checkedRoute) { actualNOfPositions = actualNOfPositions + obj.nOfPositions; if (obj.nOfPositions > 0) there_are_routes = true; Double oldLAT = -500, oldLNG = -500; Int32 Headingtmp = 0; i = 0; foreach (SMposition tempPos in obj.positions) { if (closeTabThread) { e.Cancel = true; return 1; } i++; tempPos.m_posID = i; if ((Math.Round(tempPos.m_lat) == 0) && (Math.Round(tempPos.m_lng) == 0)) continue; if ((progStep % 250) == 0) HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); if (oldLAT != -500) if (tempPos.m_speed > 0) Headingtmp = CalcHead(tempPos.m_lng, tempPos.m_lat, oldLNG, oldLAT, Headingtmp); if (closeTabThread) { e.Cancel = true; return 1; } string headtitle = unit.Text + " - " + i.ToString(); if (tempPos.m_evnt_id != 0) headtitle += " (ALARM)"; LNGMAX = Math.Max(LNGMAX, (float)tempPos.m_lng); LNGMIN = Math.Min(LNGMIN, (float)tempPos.m_lng); LATMAX = Math.Max(LATMAX, (float)tempPos.m_lat); LATMIN = Math.Min(LATMIN, (float)tempPos.m_lat); oldLAT = tempPos.m_lat; oldLNG = tempPos.m_lng; tempPos.m_heading = Headingtmp; tempPos.m_imei = headtitle; WorkerHead.ReportProgress(12, tempPos); progStep++; if (minTime > tempPos.m_time) minTime = tempPos.m_time; if (maxTime < tempPos.m_time) maxTime = tempPos.m_time; } if (i != 0) { try { obj.colorName = ((Vehicle)MainForm2.vehicleHT[unit.Text]).histcolor; } catch (Exception ex) { SM.Debug("Erorr Change color:" + ex.ToString()); } WorkerHead.ReportProgress(13, obj); } } tempRoutes.ComputeCorners(); if (corners[0] > tempRoutes.corners[0]) corners[0] = tempRoutes.corners[0]; if (corners[1] < tempRoutes.corners[1]) corners[1] = tempRoutes.corners[1]; if (corners[2] > tempRoutes.corners[2]) corners[2] = tempRoutes.corners[2]; if (corners[3] < tempRoutes.corners[3]) corners[3] = tempRoutes.corners[3]; } } // } //} bool retrynew = true; int cntmax = 0; Int32 limitstay = 0; ForceStop = false; if ((addrDecision)&&(MainForm2.IdReportHS.Keys.Count > 0)) { try { txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateStatusBar), calcADDr); txProgStatus.Invoke(new UpdateStatusBarCallBack(this.UpdateChangeSize), calcADDr); HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), MainForm2.IdReportHS.Keys.Count + 4); } catch { SM.Debug("Error on put on screen calc address"); } Int32 contNR = MainForm2.IdReportHS.Keys.Count; ArrayList numbers = new ArrayList(); Int32 continvalid = 0; while (retrynew) { cntmax++; retrynew = false; continvalid = 0; Int32 maxLimit = 0; Boolean stay = true; limitstay = (Int32)(contNR * System.Math.Abs(100 - cntmax * 3 + 10) * (0.5 + 0.1 * cntmax)); // nu poate depasi 50% din timp total lock (this) { foreach (String obj in MainForm2.IdReportHS.Keys) numbers.Add(obj); } foreach (String obj3 in numbers) { if (ForceStop) break; if ((String)MainForm2.IdReportHS[obj3] == "no address") { if (stay) { SM.Debug("Sta " + System.Math.Abs(100 - cntmax * 3 + 10) + " secunda"); Thread.Sleep(System.Math.Abs(100 - cntmax * 3 + 10)); maxLimit = maxLimit + System.Math.Abs(100 - cntmax * 3 + 10); retrynew = true; } continvalid++; } if (maxLimit > limitstay) { SM.Debug("OUT OVER Limit stay"); stay = false; } } if (cntmax > 20) retrynew = false; for (int ii = contNR; ii >= continvalid; ii--) HistroyProgBar.Invoke(new UpdateProgressBarCallBack(this.UpdateProgressBar), -1); contNR = continvalid; SM.Debug("new number count:" + contNR); if (ForceStop) break; } ForceStop = false; foreach (SMposition obj3 in selectedPositions) { if (MainForm2.IdReportHS[obj3.m_address] != null) { obj3.m_address = (String)MainForm2.IdReportHS[obj3.m_address]; //MainForm2.IdReportHS.Remove(obj3.m_address); if (obj3.m_address != "no address") smdbObj.Update_address_hist(obj3.m_imei, obj3.m_scevMSSQL, obj3.m_address); } } } if (there_are_routes) { //Load data for GRID ListforGrid.Clear(); int contx = -1; foreach (SMposition obj in selectedPositions) { contx++; if (MainForm2.isInMile) volSpeedString = Convert.ToString((int)Math.Round(obj.m_speed * 0.621371192)); else volSpeedString = Convert.ToString((int)(obj.m_speed)); volAddress = obj.m_address; if ((volAddress == "") || (volAddress == " ")) volAddress = "LAT:" + Math.Round(obj.m_lat, 5).ToString() + " , LNG:" + Math.Round(obj.m_lng, 5).ToString(); ListforGrid.Add(new DataforGRID(contx.ToString(), obj.m_vehName, (obj.m_time).ConvertGMTToLocal().GetDTFromSeconds(), volAddress, volSpeedString, Convert.ToString(obj.m_di), Convert.ToString(obj.m_do), "", "","",obj.m_heading)); } worker.ReportProgress(1); } else worker.ReportProgress(0); } catch (Exception ex) { SM.Debug("Thread exception:" + ex.ToString()); } return 1; } volatile String volSpeedString =""; volatile String volAddress = ""; volatile List ListforGrid = new List(); private void WorkerHead_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; e.Result = ComputHead(worker, e); } private volatile float LNGMAX = -181; private volatile float LNGMIN = 181; private volatile float LATMAX = -91; private volatile float LATMIN = 90; private object Missing = Type.Missing; private IElement element = null; private volatile ArrayList ElementsZone = new ArrayList(); private volatile ArrayList PositionList = new ArrayList(); private void WorkerHead_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage == 11) { try { m_graphicTracker.RemoveAll(); PlayTracker.RemoveAll(); IGraphicsContainer graphicsContainer = (IGraphicsContainer)mapControl.ActiveView; foreach (IElement obj in ElementsZone) graphicsContainer.DeleteElement(obj); ElementsZone.Clear(); mapControl.ActiveView.Refresh(); PositionList.Clear(); OLDHighlight = -1; } catch (Exception ex) { SM.Debug("Ex:"+ex.ToString()); } } else if (e.ProgressPercentage == 12) { try { SMposition tempPos = (e.UserState as SMposition); IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(tempPos.m_lng, tempPos.m_lat); point.SpatialReference = MainForm2.CreateGeoCoordSys(); Int32 GISID = m_graphicTracker.Add(point as IGeometry, busSymb.GetSymbolFromOrientation(tempPos.m_heading)); PositionList.Add(new POSIDGIS(GISID, tempPos)); toolSel.UpdateLIST(PositionList); } catch (Exception ex) { SM.Debug("Ex:" + ex.ToString()); } //m_graphicTracker.SetLabel(GISID, tempPos.m_imei + "\n" + MainForm2.langTime + " " + new ConvertDT().DateTimeOfDayHHMMLocal(tempPos.m_time) + " ; Speed: " + tempPos.m_speed.ToString() + Mainform2.Measure + ((tempPos.m_address != "") ? "\n" + tempPos.m_address : "")); } else if (e.ProgressPercentage == 13) { try { IPolyline newPath = new PolylineClass(); IPointCollection newPointCollection = newPath as IPointCollection; RouteInfo tempRoute = (e.UserState as RouteInfo); foreach (SMposition obj in tempRoute.positions) { if ((obj.m_lng != 0) && (obj.m_lat != 0)) { ESRI.ArcGIS.Geometry.IPoint fromPoint = new ESRI.ArcGIS.Geometry.PointClass(); fromPoint.PutCoords(obj.m_lng, obj.m_lat); fromPoint.SpatialReference = MainForm2.CreateGeoCoordSys(); newPointCollection.AddPoint(fromPoint, ref Missing, ref Missing); } } ESRI.ArcGIS.Display.IColor color = new RgbColorClass() { Red = tempRoute.colorName.R, Green = tempRoute.colorName.G, Blue = tempRoute.colorName.B }; // Implicit Cast ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 3; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; element = (IElement)lineElement; // Explicit Cast element.Geometry = (IPolyline)newPointCollection; IGraphicsContainer graphicsContainer = (IGraphicsContainer)mapControl.ActiveView; graphicsContainer.AddElement(element, 0); ElementsZone.Add(element); } catch (Exception ex) { SM.Debug("Error add route in histroy:"+ex.ToString()); } } else { try { Boolean there_are_routes = (e.ProgressPercentage == 1) ? true : false; populateTableVehiclesList(); if (there_are_routes) { startTimeBox.Text = (minTime).ConvertGMTToLocal().GetDTFromSeconds().ToString(); endTimeBox.Text = (maxTime).ConvertGMTToLocal().GetDTFromSeconds().ToString(); currentTimeBox.Text = (minTime).ConvertGMTToLocal().GetDTFromSeconds().ToString(); mapControl.Extent = MainForm2.ZoomTo(LNGMIN, LATMIN, LNGMAX, LATMAX); AniStateExpande = true; } else { AniStateExpande = false; } } catch (Exception ex) { SM.Debug("Erorr Worker Heading ProgressChanged: " + ex.Message + "\n Source: " + ex.Source); } } } private void WorkerHead_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { if (!closeTabThread) { Cursor = Cursors.Arrow; //mapControl.MousePointer = GeoPointer.geoPointerDefault; HistroyProgBar.Visible = false; HistoryPanel.Visible = false; HistoryPanel.Update(); txProgStatus.Visible = false; txProgStatus.Update(); btnDisplayHistory.Enabled = true; btDisplayHeading.Enabled = true; rcbComputeAddress.Enabled = true; } } catch (Exception ex) { SM.Debug("Erorr Worker Heading Complete: " + ex.ToString()); } if (MainForm2.Connfailed) { 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); MainForm2.Connfailed = false; } if (hitLimit) { if ((MainForm2.radioType == RADIOTYPE.HARRIS)||(MainForm2.radioType == RADIOTYPE.ATLAS)) ((RadLabel)RadMessageBox.Instance.Controls[1]).LabelElement.ForeColor = MainForm2.HarTextColor; RadMessageBox.Show(MainForm2.returnLNGString("lim50000"), MainForm2.returnLNGString("info"), MessageBoxButtons.OK, RadMessageIcon.Info); } SM.Debug("WorkerHead_RunWorkerCompleted END" + tabName); } private Boolean loadfinish = false; private volatile SelectGTHIS toolSel = null; private void HistoryTabMap_Load(object sender, EventArgs e) { //Load a pre-authored map document into the PageLayoutControl using relative paths. if (mapControl.CheckMxFile(MainForm2.ArcGisFileName)) mapControl.LoadMxFile(MainForm2.ArcGisFileName); mapControl.SpatialReference = MainForm2.CreateGeoCoordSys(); //Get the MapControl m_mapControl = (IMapControl3)mapControl.Object; m_graphicTracker = new GraphicTrackerClass(); m_graphicTracker.Initialize(m_mapControl.Map as IBasicMap); PlayTracker = new GraphicTrackerClass(); PlayTracker.Initialize(m_mapControl.Map as IBasicMap); loadfinish = true; busSymb = new BusSymbolsGIS(m_graphicTracker, tabName); busSymb2 = new BusSymbolsGIS(PlayTracker, tabName); toolSel = new SelectGTHIS(m_graphicTracker); ToolControl.AddItem(toolSel); backgroundWorker1.RunWorkerAsync(); VisualSettings.loadUserVisualSettings(this.Name, this.toolWindow1, MainForm2.HashVal); VisualSettings.loadUserVisualSettings(this.Name, this.windowHistoryResult, MainForm2.HashVal); } private void Killtimer_Tick(object sender, EventArgs e) { if (MainForm2.ClosingApp) KillTimerActive = true; } private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage == 11) { SMposition tempPos = (e.UserState as SMposition); try { PlayTracker.SetLabel(OLDPlay, ""); } catch { SM.Debug("Error remove lable unknow id:" + OLDPlay); } IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(tempPos.m_lng, tempPos.m_lat); point.SpatialReference = MainForm2.CreateGeoCoordSys(); Int32 GISID = PlayTracker.Add(point as IGeometry, busSymb2.GetSymbolFromOrientation(tempPos.m_heading)); MainForm2.simpleTextSymbol.YOffset = 20; PlayTracker.SetTextSymbol(GISID, MainForm2.simpleTextSymbol); if (MainForm2.isInMile) PlayTracker.SetLabel(GISID, MainForm2.langSpeed + " " + Convert.ToString((int)Math.Round(tempPos.m_speed * 0.621371192)) + MainForm2.Measure + " " + MainForm2.langTime + " " + tempPos.m_time.DateTimeOfDayHHMMLocal() + "\n" + MainForm2.FixComma(tempPos.m_address)); else PlayTracker.SetLabel(GISID, MainForm2.langSpeed + " " + tempPos.m_speed.ToString() + MainForm2.Measure + " " + MainForm2.langTime + " " + tempPos.m_time.DateTimeOfDayHHMMLocal() + "\n" + MainForm2.FixComma(tempPos.m_address)); OLDPlay = GISID; currentTimeBox.Text = (tempPos.m_time).ConvertGMTToLocal().GetDTFromSeconds().ToString(); } else { Int32 index = (Int32)e.UserState; if (index >= 0) { // idx gridHistoryPoints.Rows[index].IsSelected = true; gridHistoryPoints.Rows[index].IsCurrent = true; } } } private Int32 OLDHighlight = -1; private Int32 OLDPlay = -1; private void gridHistoryPoints_CellDoubleClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { try { if ((PositionList.Count > 0)||(loadfinish)) { Int32 both = 0; foreach (POSIDGIS obj in PositionList) { Console.WriteLine("Name:" + obj.SMpos.m_vehName + " name2:" + (String)gridHistoryPoints.SelectedRows[0].Cells[1].Value + " iful:" + (obj.SMpos.m_vehName == (String)gridHistoryPoints.SelectedRows[0].Cells[1].Value) + "db1:" + obj.SMpos.m_lat + " db2:" + Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[7].Value) + "if: " + (obj.SMpos.m_lat == Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[7].Value)) + " dbaa1:" + obj.SMpos.m_lng+" dbaa2:"+Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[8].Value)+"if2:"+(obj.SMpos.m_lng == Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[8].Value))); if ((obj.SMpos.m_vehName == (String)gridHistoryPoints.SelectedRows[0].Cells[1].Value) && (obj.SMpos.m_lat == Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[7].Value)) && (obj.SMpos.m_lng == Convert.ToDouble((String)gridHistoryPoints.SelectedRows[0].Cells[8].Value))) { Console.WriteLine("Enter over if"); m_graphicTracker.Highlight(obj.GISID, true); MainForm2.simpleTextSymbol.YOffset = 30; m_graphicTracker.SetTextSymbol(obj.GISID, MainForm2.simpleTextSymbol); String tmpSpeedData = ""; if (MainForm2.isInMile) tmpSpeedData = MainForm2.langSpeed + " " + Convert.ToString((int)Math.Round(obj.SMpos.m_speed * 0.621371192)) + MainForm2.milesh; else tmpSpeedData = MainForm2.langSpeed + " " + Convert.ToString(obj.SMpos.m_speed) + MainForm2.kmh; m_graphicTracker.SetLabel(obj.GISID, obj.SMpos.m_vehName + "_" + obj.SMpos.m_posID + "\n" + tmpSpeedData + " " + MainForm2.langTime + " " + obj.SMpos.m_time.ConvertGMTToLocal().GetDTFromSeconds().ToShortTimeString() + "\n" + obj.SMpos.m_address); obj.Select = true; both++; } else if (obj.Select) { m_graphicTracker.Highlight(obj.GISID, false); m_graphicTracker.SetLabel(obj.GISID, ""); obj.Select = false; both++; } if (both == 2) break; } } } catch (Exception ex) { SM.Debug("Exception on click select a unit:" + ex.ToString()); } } private void StartBasicHistory_Tick(object sender, EventArgs e) { if (docLoad) { btDisplayHeading.PerformClick(); StartBasicHistory.Stop(); StartBasicHistory.Enabled = false; } } private void btStopCalc_Click(object sender, EventArgs e) { } private void toolWindow2_Resize(object sender, EventArgs e) { int diffHeight, diffWidth; Control control = (Control)sender; diffHeight = control.Size.Height / 2; diffWidth = control.Size.Width / 2; diffHeight = diffHeight - 50; diffWidth = diffWidth - 170; if ((diffHeight > 0) && (diffWidth > 0)) HistoryPanel.Location = new System.Drawing.Point(diffWidth, diffHeight); } private Color getcolorFromID(Int32 id) { Color tmp = Color.Black; switch (id) { case 0: tmp = Color.Cyan; break; case 1: tmp = Color.Magenta; break; case 2: tmp = Color.Red; break; case 3: tmp = Color.Green; break; case 4: tmp = Color.Blue; break; } return tmp; } private void btCollapse_Click(object sender, EventArgs e) { if (!AniStateExpande) { AniStateExpande = true; } else { AniStateExpande = false; } } private void btStopCalc_Click_1(object sender, EventArgs e) { ForceStop = true; } private void ResizeWorker_DoWork(object sender, DoWorkEventArgs e) { Thread.Sleep(700); } private void ResizeWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { } /// /// Enable/disable the speed spinners when the combobox are selected /// private void speedLimit_CheckStateChanged(object sender, EventArgs e) { if ((RadCheckBox)sender == rcbSpeedLower) rseSpeedLower.Enabled = ((RadCheckBox)sender).Checked; else if ((RadCheckBox)sender == rcbSpeedUpper) rseSpeedUpper.Enabled = ((RadCheckBox)sender).Checked; } #region 24H /// /// Enable/Disable the date pickers for history stand and /// end date. The icon for the 24H will be changed depanding /// on it's state /// private void pb24H_Click(object sender, EventArgs e) { if (pb24H.Tag.Equals("selected")) { pb24H.Tag = "unselected"; rdpEndTime.Enabled = true; rdpStartTime.Enabled = true; pb24H.Image = global::Dispatcher.Properties.Resources.h_24h_w; } else if (pb24H.Tag.Equals("unselected")) { pb24H.Tag = "selected"; rdpEndTime.Enabled = false; rdpStartTime.Enabled = false; pb24H.Image = global::Dispatcher.Properties.Resources.h_24h; pb24H.Image = theme24H_Image; } } /// /// Display the tooltip when the mouse enters the 24H picture box /// private void pb24H_MouseEnter(object sender, EventArgs e) { toolTipHelp.ToolTipTitle = "Display last 24 hours: " + (pb24H.Tag.Equals("selected") ? "Active" : "Inactive"); toolTipHelp.Show( String.Format("Decide between displaying the last 24 hours of history " + Environment.NewLine + "or selected a desired interval.") , pb24H, 150000); } /// /// Hide the tooltip when the mouse leaves the 24H picture box /// private void pb24H_MouseLeave(object sender, EventArgs e) { toolTipHelp.Hide(pb24H); } #endregion /// /// Display the tooltip when the mouse enters the Filter picture box /// private void pbFilter_MouseEnter(object sender, EventArgs e) { toolTipHelp.ToolTipTitle = "Filter units: " + (pbFilter.Tag.Equals("selected") ? "Active" : "Inactive"); toolTipHelp.Show( String.Format("Filter the units list when the text box value changes") , pbFilter, 150000); } /// /// Hide the tooltip when the mouse leaves the Filter picture box /// private void pbFilter_MouseLeave(object sender, EventArgs e) { toolTipHelp.Hide(pbFilter); } /// /// Hide or show the filter for the units tree view /// private void pbFilter_Click(object sender, EventArgs e) { // activate the filter and show the text box if (pbFilter.Tag.Equals("unselected")) { pbFilter.Image = global::Dispatcher.Properties.Resources.h_filter; pbFilter.Tag = "selected"; rtbFilterUnits.Visible = true; } else if (pbFilter.Tag.Equals("selected")) { pbFilter.Image = global::Dispatcher.Properties.Resources.h_filter_w; pbFilter.Tag = "unselected"; rtbFilterUnits.Visible = false; rtbFilterUnits.Text = ""; } } /// /// Filter the tree view in order for the units to be find faster /// private void rtbFilterUnits_TextChanged(object sender, EventArgs e) { treeViewUnits.Filter = null; treeViewUnits.Filter = rtbFilterUnits.Text; } /// /// Set the type of the item inside the tree view to be /// a Custom Tree Node which will hav the Color in the right /// and as a property of the object /// private void treeViewUnits_CreateNodeElement(object sender, CreateTreeNodeElementEventArgs e) { e.NodeElement = new CustomTreeNodeElement(); if (e.NodeElement.ContentElement is ColorTreeContentElement) { ColorTreeContentElement treeElement = e.NodeElement.ContentElement as ColorTreeContentElement; treeElement.OnColorChanged += delegate(object s2, ColorTreeContentElement.ColorChangedEventArgs e2) { if (e2.unitName != null && e2.unitName.Length > 0) { ((Vehicle)MainForm2.vehicleHT[e2.unitName]).histcolor = e2.newColor; String imageColor = "#" + e2.newColor.R.ToString("X2") + e2.newColor.G.ToString("X2") + e2.newColor.B.ToString("X2"); VisualSettings.InsertUpdateHTforVisualItems("histColor", ((Vehicle)MainForm2.vehicleHT[e2.unitName]).sc_id + "", imageColor); } }; } } /// /// Add the Groups as Nodes inside the Tree View /// private void populateListBoxGroup() { // all units group ColorUnitTreeNode groupNode = new ColorUnitTreeNode(MainForm2.returnLNGString("allunits")); groupNode.Font = new Font( new FontFamily("Segoe UI"), 12, FontStyle.Bold, GraphicsUnit.Pixel); groupNode.Tag = -1; groupNode.CheckState = Telerik.WinControls.Enumerations.ToggleState.Off; groupNode.Expanded = true; groupNode.Color = Color.Brown; treeViewUnits.Nodes.Add(groupNode); GroupClass g = new GroupClass(); // for each group add a tree node foreach (int i in MainForm2.GroupHash.Keys) { g = (GroupClass)MainForm2.GroupHash[i]; try { AddTreeGroup(g.name, g.id); } catch (Exception ex) { Utils.WriteLine("Unable to create Group: " + ex.ToString(), ConsoleColor.Red); } } } /// /// Add a Group Node to the Tree View /// /// Group name which needs to be added to the Tree Node /// Group ID which will be set as a tag for this group node /// Returns the inserted Tree Node private ColorUnitTreeNode AddTreeGroup(string groupName, Int32 groupID) { ColorUnitTreeNode groupNode = new ColorUnitTreeNode(groupName); groupNode.Font = new Font( new FontFamily("Segoe UI"), 12, FontStyle.Bold, GraphicsUnit.Pixel); groupNode.Tag = groupID; groupNode.CheckState = Telerik.WinControls.Enumerations.ToggleState.Off; groupNode.Expanded = true; groupNode.Color = Color.Red; // add the node to the tree view treeViewUnits.Nodes[0].Nodes.Add(groupNode); return groupNode; } private bool DefaultGroupAdded = false; /// /// Add Units to the groups nodes in the Tree View /// private void populateListBoxUnits() { // for each Unit defined in the hash table foreach (DictionaryEntry de in MainForm2.vehicleHT) { Vehicle veh = de.Value as Vehicle; if (veh != null) { ColorUnitTreeNode unitNode = new ColorUnitTreeNode(veh.busName); unitNode.Tag = veh.sc_id; unitNode.Color = ((Vehicle)MainForm2.vehicleHT[veh.busName]).histcolor; // check to see if the unit is assigned to a group if (veh.group != null && veh.group.Id != 0) { // the group already exists } else { // create Unassigned group if not created until now if (!DefaultGroupAdded) { AddTreeGroup(MainForm2.returnLNGString("otherunit"), 0); DefaultGroupAdded = true; } } // search the group in which the unit will be added foreach (ColorUnitTreeNode groupNode in treeViewUnits.Nodes[0].Nodes) { Int32 groupID = (Int32)groupNode.Tag; if (groupID == veh.group.Id) groupNode.Nodes.Add(unitNode); } } } } /// /// /// /// /// private bool FilterNode(RadTreeNode node) { // add Group and 'All units' Nodes if (node.Level < 2) return true; // add unit if no filtering is required if (!rtbFilterUnits.Visible || (rtbFilterUnits.Visible && rtbFilterUnits.Text.Length == 0)) return true; // add unit if the name contains the desired text if (node.Text.ToUpper().Contains(rtbFilterUnits.Text.Trim().ToUpper())) return true; return false; } /// /// Reset the visual UI for the history tab, including speeds, /// times, grids and animation /// private void rbResetHistory_Click(object sender, EventArgs e) { // remove old dataset points if (docLoad) { btDisplayHeading.PerformClick(); StartBasicHistory.Stop(); StartBasicHistory.Enabled = false; } // uncheck all units foreach (RadTreeNode node in treeViewUnits.Nodes) node.Checked = false; // clear speed values rseSpeedLower.Value = 0; rseSpeedUpper.Value = 0; // clear time values rdpStartTime.Value = DateTime.Now.AddDays(-1); rdpEndTime.Value = DateTime.Now; // clear the grid ListforGrid.Clear(); gridHistoryPoints.DataSource = null; // reset the animation btStop.PerformClick(); // disable the history result window foreach (Control ctr in windowHistoryResult.Controls) ctr.Enabled = false; } /// /// Set the type of data which will be displayed inside the points grid /// private void gridHistoryPoints_CreateCell(object sender, GridViewCreateCellEventArgs e) { // format Ticket Log table if (e.Row is GridDataRowElement) { // increase row height //e.Row.RowInfo.Height = 53; if (e.Column.Name.Equals("history")) { e.CellType = typeof(HistoryGridColumn); e.CellElement = new HistoryGridCellElement(e.Column, e.Row); } } } /// /// Format the cells of history points to the custom format, including padding /// private void gridHistoryPoints_CellFormatting(object sender, CellFormattingEventArgs e) { GridCellElement cellElement = e.CellElement; GridViewDataColumn columnInfo = e.CellElement.ColumnInfo as GridViewDataColumn; // set padding and force the content adding if (cellElement is HistoryGridCellElement && columnInfo.Name == "history") { cellElement.Padding = new Padding(0, 0, 0, 0); cellElement.SetContent(); } } /// /// Change the buttons background color for the animation buttons depending on their enabled/disabled /// state /// private void rbtAnimation_EnabledChanged(object sender, EventArgs e) { if (((RadButton)sender).Enabled) ((RadButton)sender).ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColor; else ((RadButton)sender).ButtonElement.ButtonFillElement.BackColor = MainForm2.ButtonColorDisabled; } #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 /// /// 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 /// private void radDock1_DockStateChanging(object sender, DockStateChangingEventArgs e) { e.Cancel = true; } private void checkbox_UpdateHT(object sender, StateChangedEventArgs args) { VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadCheckBox)sender).Name, ((RadCheckBox)sender).Checked.ToString()); } private void rse_ValueChanged(object sender, EventArgs e) { VisualSettings.InsertUpdateHTforVisualItems(this.Name, ((RadSpinEditor)sender).Name, ((RadSpinEditor)sender).Value.ToString()); } } }