Last active
October 6, 2020 03:48
-
-
Save amitkhare/ad4fad3bd5de8e95997785ff15c5dab3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region NameSpaceRegion | |
using System; | |
using System.Windows.Forms; | |
using System.Data; | |
using System.Drawing; | |
using System.Collections; | |
using System.ComponentModel; | |
using System.Xml; | |
using System.Xml.Linq; | |
using BeeSys.Wasp3D.Hosting; | |
using BeeSys.Wasp3D.HostingX; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
#endregion | |
namespace BeeSys.Wasp3D.Scene | |
{ | |
public partial class SceneGraph | |
{ | |
/// This method is called when scene initialize | |
private void OnInit() | |
{ | |
} | |
List<amitkhare.MapConstituency> ConstituencyList = new List<amitkhare.MapConstituency>(); | |
private void Initiate() { | |
amitkhare.StateMap stateMap = new amitkhare.StateMap(243, "AC_"); | |
string Phase1 = "1,2,3,4,5,9,10,11,12,19,20,21,23,24,25,26,27,31,32,33,34,35,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,83,84,85,86,87,88,89,91,92,93,94,126,130,131,132,133,135,136"; | |
string Phase2 = "6,7,8,13,14,15,16,17,18,22,28,29,30,36,37,38,39,78,79,80,81,82,90,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,127,128,129,134,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,158,156,171,172,173,174,175,176,177,180,181,182,183,184,185,186,187,188"; | |
string Phase3 = "155,157,159,160,161,162,163,164,165,166,167,168,169,170,178,179,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243"; | |
string IDList = ""; | |
if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 1") { | |
IDList = Phase1; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 2"){ | |
IDList = Phase2; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 3") { | |
IDList = Phase3; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 1-2") { | |
IDList = Phase1 + "," + Phase2; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 1-3") { | |
IDList = Phase1 + "," + Phase3; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 2-1") { | |
IDList = Phase2 + "," + Phase1; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 2-3") { | |
IDList = Phase2 + "," + Phase3; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 3-1") { | |
IDList = Phase3 + "," + Phase1; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 3-2") { | |
IDList = Phase3 + "," + Phase2; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "PHASE 1-2-3") { | |
IDList = Phase1 + "," + Phase2 + "," + Phase3; | |
} else if (WString.Constituency_IDs.ToString().ToUpper() == "ALL") { | |
IDList = Phase1 + "," + Phase2 + "," + Phase3; | |
} else { | |
IDList = WString.Constituency_IDs; | |
} | |
try | |
{ | |
List <string> IDStringList = IDList.ToString().Split(',').ToList(); | |
foreach(string id in IDStringList){ | |
stateMap.setMapConstituencyByName("AC_"+ id, Color.Yellow); | |
} | |
} | |
catch (System.Exception ex) | |
{ | |
LogWriter.WriteLog(ex); | |
} | |
Map.PolygonData = stateMap.ToString(); | |
} | |
/// this method is called when named event is raised | |
private void SceneGraph_Named(string name) | |
{ | |
try | |
{ | |
if (name == "Initiate") Initiate(); | |
} | |
catch (System.Exception ex) | |
{ | |
LogWriter.WriteLog(ex); | |
} | |
} | |
} | |
} | |
/* ########################################################################## */ | |
/* ######################## Map CLASS ####################################### */ | |
/* ########################################################################## */ | |
namespace amitkhare { | |
public class MapConstituency { | |
string name; | |
Color color; | |
bool visibility; | |
public string getName () { return this.name; } | |
public Color getColor () { return this.color; } | |
public void setName (string name) { this.name = name; } | |
public void setColor (Color color) { this.color = color; } | |
public MapConstituency(string name, Color color, bool visibility = true) { | |
this.name = name; | |
this.color = color; | |
this.visibility = visibility; | |
} | |
public string getNameRow(){ | |
return "<row text='" + this.name + "' />"; | |
} | |
public string getVisibilityRow(){ | |
return "<row text='" + (this.visibility ? 1 : 0) + "' />"; | |
} | |
public string getColorRow(){ | |
double dblR = (double)this.color.R / 255; | |
double dblG = (double)this.color.G / 255; | |
double dblB = (double)this.color.B / 255; | |
double dblA = (double)this.color.A / 255; | |
return "<row text='" + dblR + "," + dblG + "," + dblB + "," + dblA + "' />"; | |
} | |
} | |
public class StateMap { | |
private List<MapConstituency> ConstituencyList; | |
public StateMap(int total, string prefix = "AC_"){ | |
ConstituencyList = new List<MapConstituency>(); | |
for(int i = 0; i < total; i++){ | |
ConstituencyList.Add( new MapConstituency(prefix + (i + 1), Color.Transparent) ); | |
} | |
} | |
public override string ToString(){ | |
string data = @" | |
<table> | |
<data> | |
<col cid='0' colname='name' wireid='-1'> | |
" + this.getNameRows() + @" | |
</col> | |
<col cid='1' colname='visibility' wireid='-1'> | |
" + this.getVisibilityRows() + @" | |
</col> | |
<col cid='2' colname='color' wireid='-1'> | |
" + this.getColorRows() + @" | |
</col> | |
</data> | |
</table> | |
"; | |
return data; | |
} | |
private string getNameRows(){ | |
string data = ""; | |
foreach (MapConstituency mapConstituency in this.ConstituencyList){ | |
data += mapConstituency.getNameRow() + Environment.NewLine; | |
} | |
return data; | |
} | |
private string getColorRows(){ | |
string data = ""; | |
foreach (MapConstituency mapConstituency in this.ConstituencyList){ | |
data += mapConstituency.getColorRow() + Environment.NewLine; | |
} | |
return data; | |
} | |
private string getVisibilityRows(){ | |
string data = ""; | |
foreach (MapConstituency mapConstituency in this.ConstituencyList){ | |
data += mapConstituency.getVisibilityRow() + Environment.NewLine; | |
} | |
return data; | |
} | |
public void setMapConstituencyByName(string name, Color color){ | |
ConstituencyList.Find(elm => elm.getName() == name).setColor(color); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment