SafeDispatch/Safedispatch_4_0/maptab/UIClasses/IconCellElement.cs

80 lines
2.5 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Safedispatch_4_0;
using SafeMobileLib;
using Telerik.WinControls.UI;
namespace Dispatcher.maptab.UIClasses
{
public class IconCellElement : SimpleListViewVisualItem
{
private LightVisualElement iconElem;
protected override void CreateChildElements()
{
base.CreateChildElements();
this.iconElem = new LightVisualElement();
this.iconElem.ShouldHandleMouseInput = false;
this.NumberOfColors = 1;
this.iconElem.MinSize = new System.Drawing.Size(24, 24);
this.iconElem.MaxSize = new System.Drawing.Size(24, 24);
this.iconElem.Size = new System.Drawing.Size(24, 24);
this.iconElem.ImageAlignment = ContentAlignment.MiddleCenter;
this.Children.Add(this.iconElem);
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(SimpleListViewVisualItem);
}
}
protected override void SynchronizeProperties()
{
base.SynchronizeProperties();
KeyValuePair<Int32, LandmarkType> landmarkKeyValue = (KeyValuePair<Int32, LandmarkType>)this.Data.Value;
LandmarkType landmarkType = null;
this.Text = "";
landmarkType = landmarkKeyValue.Value;
String safemobileDirPath = System.Windows.Forms.Application.StartupPath; //.Replace('\\', '/').Replace(" ", "%20");
//safemobileDirPath = safemobileDirPath.Replace("#", "%23");
string iconPath = safemobileDirPath + @"\resource\landmarks\" + landmarkType.IconName;
//if (this.iconElem.Image == null)
{
try
{
this.ToolTipText = landmarkType.TypeName;
this.iconElem.Image = Utils.ScaleImage(Bitmap.FromFile(iconPath), 19, 19);
}
catch (Exception ex)
{
this.iconElem.Image = Utils.ScaleImage(global::Dispatcher.Properties.Resources.classic_unknown, 19, 19);
Utils.WriteLine("IconCellElement Exception: " + ex.ToString(), ConsoleColor.Red);
}
}
if (this.Selected)
this.BackColor = Color.LightGray;
else
this.BackColor = Color.White;
}
}
}