250 lines
9.9 KiB
C#
250 lines
9.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Safedispatch_4_0;
|
|
using SafeMobileLib;
|
|
using Telerik.WinControls.Layouts;
|
|
using Telerik.WinControls.UI;
|
|
|
|
namespace Dispatcher.maptab.UIClasses
|
|
{
|
|
public class HistoryGridCellElement : GridDataCellElement
|
|
{
|
|
public static String timeFormat = "MM/dd HH:mm:ss";
|
|
|
|
private LightVisualElement unitNameElement;
|
|
private LightVisualElement addressElement;
|
|
private LightVisualElement timeElement;
|
|
private LightVisualElement numberElement;
|
|
|
|
private StackLayoutElement stackTop;
|
|
private StackLayoutElement stackBottom;
|
|
private StackLayoutElement stackRight;
|
|
private DockLayoutPanel dockLayout;
|
|
|
|
public HistoryGridCellElement(GridViewColumn column, GridRowElement row)
|
|
: base(column, row)
|
|
{
|
|
}
|
|
|
|
protected override void CreateChildElements()
|
|
{
|
|
base.CreateChildElements();
|
|
|
|
this.dockLayout = new DockLayoutPanel();
|
|
this.dockLayout.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;
|
|
this.dockLayout.StretchHorizontally = true;
|
|
this.dockLayout.StretchVertically = true;
|
|
this.dockLayout.AutoSize = true;
|
|
this.dockLayout.ShouldHandleMouseInput = false;
|
|
this.dockLayout.Margin = new Padding(0, 0, 0, 0);
|
|
this.dockLayout.Padding = new Padding(0, 0, 0, 0);
|
|
this.AutoToolTip = true;
|
|
|
|
|
|
stackRight = new StackLayoutElement();
|
|
stackRight.ElementSpacing = 0;
|
|
stackRight.Orientation = Orientation.Vertical;
|
|
stackRight.TextAlignment = ContentAlignment.MiddleLeft;
|
|
stackRight.Alignment = ContentAlignment.MiddleLeft;
|
|
stackRight.StretchHorizontally = true;
|
|
stackRight.StretchVertically = true;
|
|
stackRight.AutoSize = true;
|
|
stackRight.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;
|
|
stackRight.Margin = new Padding(0, 0, 0, 0);
|
|
/*
|
|
stackRight.MinSize = new System.Drawing.Size(107, stackRight.Size.Height);
|
|
stackRight.MaxSize = new System.Drawing.Size(107, stackRight.Size.Height);
|
|
stackRight.Size = new System.Drawing.Size(107, stackRight.Size.Height);*/
|
|
|
|
|
|
stackTop = new StackLayoutElement();
|
|
stackTop.StretchHorizontally = true;
|
|
stackTop.StretchVertically = true;
|
|
stackTop.AutoSize = true;
|
|
stackTop.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;
|
|
stackTop.ElementSpacing = 0;
|
|
stackTop.Orientation = Orientation.Horizontal;
|
|
stackTop.TextAlignment = ContentAlignment.MiddleLeft;
|
|
stackTop.Alignment = ContentAlignment.MiddleLeft;
|
|
|
|
|
|
numberElement = new LightVisualElement();
|
|
numberElement.StretchHorizontally = false;
|
|
numberElement.StretchVertically = true;
|
|
numberElement.AutoSize = true;
|
|
numberElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren;
|
|
numberElement.Alignment = ContentAlignment.MiddleLeft;
|
|
numberElement.TextAlignment = ContentAlignment.MiddleLeft;
|
|
|
|
Font fontNumber = new Font(
|
|
numberElement.Font.FontFamily,
|
|
9,
|
|
FontStyle.Regular,
|
|
GraphicsUnit.Pixel);
|
|
numberElement.Font = fontNumber;
|
|
numberElement.ForeColor = Color.FromArgb(161, 161, 161);
|
|
//numberElement.MaxSize = new System.Drawing.Size(30, 0);
|
|
numberElement.MinSize = new System.Drawing.Size(25, 0);
|
|
|
|
|
|
addressElement = new LightVisualElement();
|
|
addressElement.StretchHorizontally = true;
|
|
addressElement.StretchVertically = true;
|
|
addressElement.AutoSize = true;
|
|
addressElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren;
|
|
addressElement.Alignment = ContentAlignment.MiddleLeft;
|
|
addressElement.TextAlignment = ContentAlignment.MiddleLeft;
|
|
addressElement.Padding = new System.Windows.Forms.Padding(0, 3, 3, 0);
|
|
addressElement.Margin = new System.Windows.Forms.Padding(0,0,6,0);
|
|
addressElement.ForeColor = Color.FromArgb(99, 99, 99);
|
|
addressElement.TextWrap = true;
|
|
//addressElement.MaxSize = new System.Drawing.Size(dockLayout.MaxSize.Width - 30, 0);
|
|
//addressElement.MinSize = new System.Drawing.Size(dockLayout.MaxSize.Width - 30, 0);
|
|
|
|
// add crt number and address element to the top stack
|
|
stackTop.Children.Add(numberElement);
|
|
stackTop.Children.Add(addressElement);
|
|
|
|
|
|
|
|
|
|
// create the middle stack
|
|
stackBottom = new StackLayoutElement();
|
|
stackBottom.StretchHorizontally = true;
|
|
stackBottom.StretchVertically = true;
|
|
stackBottom.AutoSize = true;
|
|
stackBottom.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;
|
|
stackBottom.ElementSpacing = 0;
|
|
stackBottom.Orientation = Orientation.Horizontal;
|
|
stackBottom.TextAlignment = ContentAlignment.MiddleLeft;
|
|
stackBottom.Alignment = ContentAlignment.MiddleLeft;
|
|
|
|
|
|
unitNameElement = new LightVisualElement();
|
|
|
|
Font font = new Font(
|
|
unitNameElement.Font.FontFamily,
|
|
10,
|
|
FontStyle.Bold,
|
|
GraphicsUnit.Pixel);
|
|
unitNameElement.Font = font;
|
|
unitNameElement.ForeColor = Color.FromArgb(0, 0, 0);
|
|
unitNameElement.StretchHorizontally = true;
|
|
unitNameElement.AutoSize = true;
|
|
unitNameElement.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;
|
|
unitNameElement.Alignment = ContentAlignment.MiddleLeft;
|
|
unitNameElement.TextAlignment = ContentAlignment.MiddleLeft;
|
|
unitNameElement.MinSize = new System.Drawing.Size(140, 12);
|
|
|
|
|
|
timeElement = new LightVisualElement();
|
|
timeElement.StretchHorizontally = true;
|
|
unitNameElement.AutoSize = true;
|
|
timeElement.Alignment = ContentAlignment.MiddleRight;
|
|
timeElement.TextAlignment = ContentAlignment.MiddleRight;
|
|
timeElement.MaxSize = new System.Drawing.Size(110, 12);
|
|
timeElement.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
|
|
|
Font fontNumber3 = new Font(
|
|
timeElement.Font.FontFamily,
|
|
9,
|
|
FontStyle.Regular,
|
|
GraphicsUnit.Pixel);
|
|
timeElement.Font = fontNumber3;
|
|
timeElement.ForeColor = Color.FromArgb(161, 161, 161);
|
|
|
|
|
|
// add coordinates and time to bottom stack
|
|
stackBottom.Children.Add(unitNameElement);
|
|
stackBottom.Children.Add(timeElement);
|
|
|
|
|
|
// add top, middle and bottom stacks to the right stack
|
|
stackRight.Children.Add(stackTop);
|
|
stackRight.Children.Add(stackBottom);
|
|
|
|
|
|
// add stack to the dock
|
|
dockLayout.Children.Add(stackRight);
|
|
|
|
DockLayoutPanel.SetDock(this.stackRight, Telerik.WinControls.Layouts.Dock.Right);
|
|
|
|
this.Children.Add(dockLayout);
|
|
}
|
|
|
|
|
|
protected override Type ThemeEffectiveType
|
|
{
|
|
get
|
|
{
|
|
return typeof(GridDataCellElement);
|
|
}
|
|
}
|
|
|
|
public override bool IsCompatible(GridViewColumn data, object context)
|
|
{
|
|
return data is HistoryGridColumn && context is GridDataRowElement;
|
|
}
|
|
|
|
|
|
public override void SetContent()
|
|
{
|
|
GridViewDataRowInfo row = this.RowInfo as GridViewDataRowInfo;
|
|
if (row != null)
|
|
{
|
|
DataforGRID gridData = row.DataBoundItem as DataforGRID;
|
|
|
|
if (gridData != null)
|
|
{
|
|
|
|
// set the current point number
|
|
numberElement.Text = (row.Index + 1) + ""; // (Double.Parse(gridData.Id) + 1 ) + ".";
|
|
|
|
// set the vehicle name
|
|
unitNameElement.Text = gridData.VehName;
|
|
|
|
// set position time
|
|
if (gridData.Datatime.Year > 2000)
|
|
//timeElement.Text = String.Format("{0:"+ timeFormat+"}", gridData.Datatime);
|
|
timeElement.Text = $"{gridData.Datatime.ToString(timeFormat)}";
|
|
if (gridData.Address.Length > 0 && !gridData.Address.Equals("N/A"))
|
|
{
|
|
// set the addres
|
|
addressElement.Text = gridData.Address;
|
|
|
|
// add coordinates if available
|
|
if (gridData.Lng.Length > 0 && !gridData.Lng.Equals("N/A"))
|
|
addressElement.Text += " [" + gridData.Lat + "," + gridData.Lng + "]";
|
|
|
|
// add speed to the addres field
|
|
addressElement.Text += " - " + gridData.Speed + (MainForm2.isInMile ? " " + MainForm2.milesh : " " + MainForm2.kmh);
|
|
|
|
// set the tooltip text which will be displayed
|
|
this.ToolTipText = addressElement.Text;
|
|
}
|
|
else
|
|
addressElement.Text = MainForm2.returnLNGString("noAddress");
|
|
|
|
|
|
// change color of the selected row
|
|
if (this.IsCurrentRow)
|
|
{
|
|
this.DrawFill = true;
|
|
this.BackColor = MainForm2.GridSelectedRow;
|
|
}
|
|
else
|
|
this.DrawFill = false;
|
|
}
|
|
}
|
|
|
|
this.Text = string.Empty;
|
|
}
|
|
|
|
}
|
|
}
|