Last active
December 18, 2019 18:55
-
-
Save amitkhare/87072a6bf2e8372d8a65634ab08d7145 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.Linq; | |
#endregion | |
namespace BeeSys.Wasp3D.Scene | |
{ | |
public class Segment { | |
public Var_Integer Value { get; private set;} | |
public Var_Color Color { get; private set;} | |
public Var_String Name { get; private set;} | |
public Segment (Var_String name, Var_Integer value, Var_Color color){ | |
this.Name = name; | |
this.Value = value; | |
this.Color = color; | |
} | |
} | |
public partial class SceneGraph | |
{ | |
private bool msgOn = true; | |
List<Segment> segmentList; | |
List<Segment> segmentListWired; | |
/// This method is called when scene initialize | |
private void OnInit() | |
{ | |
} | |
private void Initialize() | |
{ | |
WInteger.TouchedId = 0; | |
ResetPiVars(); | |
segmentListWired = new List<Segment>(); | |
segmentList = new List<Segment>(); | |
segmentListWired.Add(new Segment(WString.WireParty_1, WInteger.WireVal_1, WColor.WireColor_1)); | |
segmentListWired.Add(new Segment(WString.WireParty_2, WInteger.WireVal_2, WColor.WireColor_2)); | |
segmentListWired.Add(new Segment(WString.WireParty_3, WInteger.WireVal_3, WColor.WireColor_3)); | |
segmentListWired.Add(new Segment(WString.WireParty_4, WInteger.WireVal_4, WColor.WireColor_4)); | |
segmentListWired.Add(new Segment(WString.WireParty_5, WInteger.WireVal_5, WColor.WireColor_5)); | |
segmentListWired.Add(new Segment(WString.WireParty_6, WInteger.WireVal_6, WColor.WireColor_6)); | |
segmentListWired.Add(new Segment(WString.WireParty_7, WInteger.WireVal_7, WColor.WireColor_7)); | |
segmentListWired.Add(new Segment(WString.WireParty_8, WInteger.WireVal_8, WColor.WireColor_8)); | |
} | |
private void ResetPiVars(){ | |
WInteger.PiVal_1 = 0; | |
WInteger.PiVal_2 = 0; | |
WInteger.PiVal_3 = 0; | |
WInteger.PiVal_4 = 0; | |
WInteger.PiVal_5 = 0; | |
WInteger.PiVal_6 = 0; | |
WInteger.PiVal_7 = 0; | |
WInteger.PiVal_8 = 0; | |
WString.PiParty_1 = ""; | |
WString.PiParty_2 = ""; | |
WString.PiParty_3 = ""; | |
WString.PiParty_4 = ""; | |
WString.PiParty_5 = ""; | |
WString.PiParty_6 = ""; | |
WString.PiParty_7 = ""; | |
WString.PiParty_8 = ""; | |
WColor.PiColor_1 = WColor.DefaultColor; | |
WColor.PiColor_2 = WColor.DefaultColor; | |
WColor.PiColor_3 = WColor.DefaultColor; | |
WColor.PiColor_4 = WColor.DefaultColor; | |
WColor.PiColor_5 = WColor.DefaultColor; | |
WColor.PiColor_6 = WColor.DefaultColor; | |
WColor.PiColor_7 = WColor.DefaultColor; | |
WColor.PiColor_8 = WColor.DefaultColor; | |
} | |
private void touched(int touchID){ | |
if(touchID < 1 || touchID > segmentListWired.Count) return; | |
Segment seg = segmentListWired[touchID - 1]; | |
if(!segmentList.Exists(el => el.Name == seg.Name && el.Value == seg.Value)){ | |
segmentList.Add(seg); | |
} else{ | |
if(WBoolean.ToggleTouch) segmentList.Remove(seg); | |
} | |
ExpandSegmentList(); | |
FillOtherPiVars(); | |
} | |
private void ExpandSegmentList(){ | |
ResetPiVars(); | |
int idx = 0; | |
if(segmentList.Count > 0){ | |
idx = 0; | |
WInteger.PiVal_1 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_1 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_1.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 1){ | |
idx = 1; | |
WInteger.PiVal_2 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_2 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_2.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 2){ | |
idx = 2; | |
WInteger.PiVal_3 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_3 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_3.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 3){ | |
idx = 3; | |
WInteger.PiVal_4 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_4 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_4.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 4){ | |
idx = 4; | |
WInteger.PiVal_5 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_5 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_5.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 5){ | |
idx = 5; | |
WInteger.PiVal_6 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_6 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_6.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 6){ | |
idx = 6; | |
WInteger.PiVal_7 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_7 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_7.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
if(segmentList.Count > 7){ | |
idx = 7; | |
WInteger.PiVal_8 = Convert.ToInt32(segmentList[idx].Value.ToString()); | |
WString.PiParty_8 = segmentList[idx].Name.ToString(); | |
WColor.PiColor_8.SetValue(segmentList[idx].Color.Red,segmentList[idx].Color.Green, segmentList[idx].Color.Blue, segmentList[idx].Color.Alpha); | |
} | |
} | |
private void FillOtherPiVars(){ | |
// fill remaining | |
int totalValSegment = segmentList.Sum(item => item.Value); | |
int totalValWired = segmentListWired.Sum(item => item.Value); | |
int totalDeference = totalValWired - totalValSegment; | |
int idx = segmentList.Count; | |
if(idx == 0){ | |
WInteger.PiVal_1 = totalDeference; | |
WString.PiParty_1 = WString.OtherParty; | |
WColor.PiColor_1 = WColor.OthersColor; | |
} | |
if(idx == 1){ | |
WInteger.PiVal_2 = totalDeference; | |
WString.PiParty_2 = WString.OtherParty; | |
WColor.PiColor_2 = WColor.OthersColor; | |
} | |
if(idx == 2){ | |
WInteger.PiVal_3 = totalDeference; | |
WString.PiParty_3 = WString.OtherParty; | |
WColor.PiColor_3 = WColor.OthersColor; | |
} | |
if(idx == 3){ | |
WInteger.PiVal_4 = totalDeference; | |
WString.PiParty_4 = WString.OtherParty; | |
WColor.PiColor_4 = WColor.OthersColor; | |
} | |
if(idx == 4){ | |
WInteger.PiVal_5 = totalDeference; | |
WString.PiParty_5 = WString.OtherParty; | |
WColor.PiColor_5 = WColor.OthersColor; | |
} | |
if(idx == 5){ | |
WInteger.PiVal_6 = totalDeference; | |
WString.PiParty_6 = WString.OtherParty; | |
WColor.PiColor_6 = WColor.OthersColor; | |
} | |
if(idx == 6){ | |
WInteger.PiVal_7 = totalDeference; | |
WString.PiParty_7 = WString.OtherParty; | |
WColor.PiColor_7 = WColor.OthersColor; | |
} | |
if(idx == 7){ | |
WInteger.PiVal_8 = totalDeference; | |
WString.PiParty_8 = WString.OtherParty; | |
WColor.PiColor_8 = WColor.OthersColor; | |
} | |
} | |
/// this method is called when raise trigger | |
private void SceneGraph_ExecuteTrigger(int triggerId) | |
{ | |
try | |
{ | |
if(triggerId == 1001){ | |
int touchID = WInteger.TouchedId; | |
WInteger.TouchedId = 0; | |
touched(touchID); | |
} | |
if(triggerId == 1002){ | |
Initialize(); | |
} | |
} | |
catch (System.Exception ex) | |
{ | |
LogWriter.WriteLog(ex); | |
} | |
} | |
/// This method is called when scene is cued | |
private void OnSceneCue(ref bool render) | |
{ | |
try | |
{ | |
Initialize(); | |
} | |
catch (System.Exception ex) | |
{ | |
LogWriter.WriteLog(ex); | |
} | |
} | |
private void MSG(object obj, string prefix = ""){ | |
if(!msgOn) return; | |
MessageBox.Show(prefix + " : " + obj.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment