private void OnTriggerStay2D(Collider2D collision) { if (collision.name == "Laser(Clone)" | collision.name == "WallLaser(Clone)") { Lasers deadly = collision.GetComponent <Lasers>(); bool damaging = true; if (deadly != null) { damaging = deadly.deadly; } if (damaging) { part.Play(); } if (cooldown > 0) { cooldown -= Time.fixedDeltaTime; } if (!over & damaging & cooldown <= 0f) { cooldown = 3f; currhealth -= 1; StartCoroutine(healthbar.Damage(currhealth)); StartCoroutine(RedBlink()); if (currhealth < 0) { part.Stop(); FindObjectOfType <Manager2>().GameOver(); StartCoroutine(healthbar.Damage(0)); Destroy(gameObject); } } } }
public void RemoveLaser(Laser laser) { if (Lasers.Contains(laser)) { Lasers.Remove(laser); } }
private void SelectWeaponWithAmmo() { var weapon = Lasers.FirstOrDefault(l => l.RemainingAmmo > 0); if (weapon != null) { LaserIndex = Lasers.IndexOf(weapon); } }
void OnTriggerEnter2D(Collider2D other) { Lasers lasers = other.GetComponent <Lasers>(); if (lasers) { Destroy(other.gameObject); } }
void OnTriggerStay2D(Collider2D other) { Character character = other.GetComponent <Character>(); Lasers lasers = other.GetComponent <Lasers>(); if (character) { character.TakeDamage(); } }
void OnTriggerStay2D(Collider2D other) { Debug.Log("Here"); Lasers lasers = other.GetComponent <Lasers>(); if (lasers) { TakeDamage(); Destroy(other.gameObject); } }
protected void LasersAllOnOff(object sender, EventArgs e) { bool state = ((Button)sender).Label.Equals("Turn Sources On"); if (state) { // turn them all off ((Button)sender).Label = "Turn Sources Off"; label_srcbottom.Text = "Sources are On"; colorbutton_srcbottom.Color = new Gdk.Color(255, 0, 0); colorbutton4.Color = new Gdk.Color(255, 0, 0); for (int i = 0; i < _handles.lasers.Count; i++) { Lasers lasers = _handles.lasers[i]; int deviceIdx = lasers.deviceIdx; for (int j = 0; j < lasers.wavelength.Length; j++) { MainClass.devices[deviceIdx].SetLaserState(lasers.laserIdx[j], state); lasers.state[j] = state; lasers.buttons[j].ModifyBg(StateType.Normal, new Gdk.Color(255, 0, 0)); lasers.buttons[j].ModifyBg(StateType.Selected, new Gdk.Color(255, 0, 0)); lasers.buttons[j].ModifyBg(StateType.Active, new Gdk.Color(255, 0, 0)); lasers.led[j].Color = new Gdk.Color(255, 0, 0); } _handles.lasers[i] = lasers; } } else { ((Button)sender).Label = "Turn Sources On"; label_srcbottom.Text = "Sources are Off"; colorbutton_srcbottom.Color = new Gdk.Color(128, 128, 128); colorbutton4.Color = new Gdk.Color(128, 128, 128); for (int i = 0; i < _handles.lasers.Count; i++) { Lasers lasers = _handles.lasers[i]; int deviceIdx = lasers.deviceIdx; for (int j = 0; j < lasers.wavelength.Length; j++) { MainClass.devices[deviceIdx].SetLaserState(lasers.laserIdx[j], state); lasers.state[j] = state; lasers.buttons[j].ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128)); lasers.buttons[j].ModifyBg(StateType.Selected, new Gdk.Color(128, 128, 128)); lasers.buttons[j].ModifyBg(StateType.Active, new Gdk.Color(128, 128, 128)); lasers.led[j].Color = new Gdk.Color(128, 128, 128); } _handles.lasers[i] = lasers; } } }
protected void SourcePower_SetAll(object sender, EventArgs e) { int gain = (int)((SpinButton)sender).Value; for (int i = 0; i < _handles.lasers.Count; i++) { Lasers lasers = _handles.lasers[i]; for (int k = 0; k < lasers.spinButtons.Length; k++) { lasers.spinButtons[k].Value = gain; } } }
void SrcValueChanged(object sender, EventArgs e) { string[] name = ((SpinButton)sender).Name.Split(' '); int WidgetIdx = int.Parse(name[0]); Lasers laser = _handles.lasers[WidgetIdx]; int deviceIdx = laser.deviceIdx; int laserIdx = int.Parse(name[1]); laser.gain[laserIdx] = (int)((SpinButton)sender).Value; _handles.lasers[WidgetIdx] = laser; MainClass.devices[deviceIdx].SetLaserPower(laser.laserIdx[laserIdx], laser.gain[laserIdx]); return; }
public float[] DistanceFromRays(Transform agent, int spare) { float[] RayArray = new float[iter + spare]; for (int i = 0; i < iter + spare; i++) { if (i == iter) { RaycastHit2D center = Physics2D.Raycast(agent.position, Vector2.zero, RayLength, 1 << 9); if (center) { RayArray[i] = 1; } else { RayArray[i] = 0; } continue; } if (i >= iter + centerdetection) { RayArray[i] = 0; continue; } Vector2 direction = new Vector2(Mathf.Sin(i * theta), Mathf.Cos(i * theta)); RaycastHit2D hit = Physics2D.Raycast((Vector2)agent.position + direction * parameters.offset, direction, RayLength, 1 << 9); //Debug.DrawRay((Vector2)agent.position + direction * parameters.offset, direction * RayLength, Color.green); if (hit) { if (usetimemask) { float time = 1; Lasers collide = hit.collider.GetComponent <Lasers>(); if (collide != null) { time = collide.spawntime; } RayArray[i] = time * InvertMap(hit.distance, RayLength); } else { RayArray[i] = InvertMap(hit.distance, RayLength); } } else { RayArray[i] = 0; } } return(RayArray); }
void OnTriggerStay2D(Collider2D other) { Lasers lasers = other.GetComponent <Lasers>(); Character character = other.GetComponent <Character>(); if (lasers != null) { Destroy(other.gameObject); } if (character != null) { character.TakeDamage(); } }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("inside on trigger"); Lasers lasers = other.GetComponent <Lasers>(); Character character = other.GetComponent <Character>(); if (lasers != null) { Debug.Log("destroying"); Destroy(other.gameObject); } if (character != null) { Debug.Log("Character hit"); } }
private void LaserShoot() { lock (Bullets) { LaserSound.Play(); LaserFired = true; var laser = new Laser { Shape = { Position = Center, Rotation = Sprite.Rotation } }; Lasers.Add(laser); } }
void Start() { // Get components gps = GetComponent <GPS>(); lasers = GetComponent <Lasers>(); car = GetComponent <CarController>(); userControl = GetComponent <CarUserControl>(); // Calculate squared distances sqrWallThreshold = wallThreshold * wallThreshold; sqrCornerThreshold = cornerThreshold * cornerThreshold; sqrVertexThreshold = vertexThreshold * vertexThreshold; // Init state state = CarState.Free; graph = new List <Vertex>(); vertices = new List <Vertex>(); }
void Start() { // Get components gps = GetComponent <GPS>(); lasers = GetComponent <Lasers>(); car = GetComponent <CarController>(); userControl = GetComponent <CarUserControl>(); // Init state accel = 1f; _slices = 0; steering = 0f; handbreak = 0f; state = BUGState.Line; win = false; newLine = true; }
void OnTriggerStay2D(Collider2D other) { Character character = other.GetComponent <Character>(); Lasers lasers = other.GetComponent <Lasers>(); if (character) { character.TakeDamage(); } if (lasers) { if (other.GetComponent <Lasers>().Boss) { return; } TakeDamage(); Destroy(other.gameObject); } }
public float[] GetInput(Transform obj, Vector2 velocity) { float[] RayArray = new float[17]; for (int i = 0; i < 12; i++) { Vector2 direction = new Vector2(Mathf.Sin(i * theta), Mathf.Cos(i * theta)); RaycastHit2D hit = Physics2D.Raycast((Vector2)obj.position + direction * offset, direction, RayLength, 1 << 9); Debug.DrawRay((Vector2)obj.position + direction * offset, direction * RayLength, Color.green); if (hit) { float time = 1; Lasers collide = hit.collider.GetComponent <Lasers>(); if (collide != null) { time = collide.spawntime; } RayArray[i] = time * InvertMap(hit.distance, RayLength); } else { RayArray[i] = 0; } } RaycastHit2D center = Physics2D.Raycast(obj.position, Vector2.zero, RayLength, 1 << 9); if (center) { RayArray[12] = 1; } else { RayArray[12] = 0; } RayArray[13] = Tanh(obj.position.x, 4f); RayArray[14] = Tanh(obj.position.y, 9f / 4f); RayArray[15] = Tanh(velocity.x, man.max_v.x / 2f); RayArray[16] = Tanh(velocity.y, man.max_v.y / 2f); return(RayArray); }
public void AddToInventory(Laser laser) { var existing = Lasers.FirstOrDefault(l => l.Name.ToLower().Equals(laser.Name.ToLower())); if (existing != null) { existing.RemainingAmmo += laser.StartingAmmo; LaserIndex = Lasers.IndexOf(existing); } else { Lasers.Add(new WeaponInfo { Texture = laser.Texture, Name = laser.Name, RemainingAmmo = laser.StartingAmmo, ProjectileName = laser.ProjectileName }); // make this the current laser LaserIndex = Lasers.Count - 1; } }
private void Gameplay_Update(int GameState, GameTime pGameTime, ContentManager Content) { if (keyboard != previousKeyboard && keyboard.IsKeyDown(Keys.Escape) && pause) { this.Game_State = 0; } if (keyboard.IsKeyDown(Keys.Escape)) { pause = true; this.Pause = mstate.Position; } if (keyboard != previousKeyboard && keyboard.IsKeyDown(Keys.Enter) && pause) { pause = false; Mouse.SetPosition(Pause.X, Pause.Y); } if (!pause) { foreach (Enemy var1 in enemyFighter) { var1.Update(pGameTime); } foreach (Sprite HUD in hud) { HUD.Update(pGameTime); } foreach (Right_HUD R_H in R_hud) { R_H.Update(pGameTime); } SSV.Update(pGameTime); cone.Update(pGameTime); //Enemies Update foreach (Fighter Enemies in EnemyFighter) { Point ID = Enemies.Update(pGameTime); if (ID != Point.Zero) { TargetID = ID; } Enemies.UpdatePositionAngle(cone); if (Enemies.FireWeapon) { int i = 0; if (EnemyMissile.Count != 0) { while (i < EnemyMissile.Count && EnemyMissile[i] != null) { i++; } } Missile var = new Missile(content, this, i, new Point(0, 0)); EnemyMissile.Insert(i, var); EnemyMissile[i].SpawnAt(Enemies.Position); EnemyMissile[i].SetDestination(new Vector2(640, 360)); Enemies.FireWeapon = false; } if (!Enemies.IsActive) { EnemyFighterDump.Add(Enemies); } } EnemyFighter = EnemyFighter.Except(EnemyFighterDump).ToList(); foreach (Frigate Enemies in EnemyFrigate) { Point ID = Enemies.Update(pGameTime); if (ID != Point.Zero) { TargetID = ID; } Enemies.UpdatePositionAngle(cone); if (Enemies.FireWeapon) { int i = 0; if (EnemySlug.Count != 0) { while (i < EnemySlug.Count && EnemySlug[i] != null) { i++; } } Slug var = new Slug(content, this); EnemySlug.Insert(i, var); EnemySlug[i].SpawnAt(Enemies.Position); EnemySlug[i].SetDestination(new Vector2(640, 360)); Enemies.FireWeapon = false; } if (!Enemies.IsActive) { EnemyFrigateDump.Add(Enemies); } } EnemyFrigate = EnemyFrigate.Except(EnemyFrigateDump).ToList(); foreach (Carrier Enemies in EnemyCarrier) { Point ID = Enemies.Update(pGameTime); if (ID != Point.Zero) { TargetID = ID; } Enemies.UpdatePositionAngle(cone); if (Enemies.FireWeapon) { AddFigther(content, Enemies.Position, new Vector2(640, 360)); Enemies.FireWeapon = false; } if (!Enemies.IsActive) { EnemyCarrierDump.Add(Enemies); } } EnemyCarrier = EnemyCarrier.Except(EnemyCarrierDump).ToList(); foreach (Dreadnought Enemies in EnemyDreadnought) { Point ID = Enemies.Update(pGameTime); if (ID != Point.Zero) { TargetID = ID; } Enemies.UpdatePositionAngle(cone); if (Enemies.FireWeapon) { int i = 0; if (EnemyCannon.Count != 0) { while (i < EnemyCannon.Count && EnemyCannon[i] != null) { i++; } } Cannon var = new Cannon(content, this, new Point(0, 0), 10); EnemyCannon.Insert(i, var); EnemyCannon[i].SpawnAt(Enemies.Position); Enemies.FireWeapon = false; } if (!Enemies.IsActive) { EnemyDreadnoughtDump.Add(Enemies); } } EnemyDreadnought = EnemyDreadnought.Except(EnemyDreadnoughtDump).ToList(); //endEnemies Update //Weapons Update foreach (Missile Missile in EnemyMissile) { Point ID = Missile.Update(GetPositionByID(Missile.TargetID)); if (ID != Point.Zero) { TargetID = ID; } if (Missile.Friendly == false && Missile.IsMoving == false) { Missile.Destroy = true; enemyMissileDump.Add(Missile); HB_hp -= 1; } else if (Missile.Friendly && !Missile.IsMoving) { DamageTarget(Missile.TargetID, 1); } } enemyMissile = enemyMissile.Except(enemyMissileDump).ToList(); foreach (Laser Lsr in Lasers) { Lsr.Update(); } foreach (Slug Slug in EnemySlug) { Slug.Update(); if (Slug.Friendly == false && Slug.IsMoving == false) { Slug.Destroy = true; enemySlugDump.Add(Slug); HB_hp -= 5; } else if (Slug.Friendly && !Slug.IsMoving) { DamageTarget(Slug.TargetID, 2); } } enemySlug = enemySlug.Except(enemySlugDump).ToList(); foreach (Cannon Cannon in EnemyCannon) { Cannon.Update(); //Add destroy here. } enemySlug = enemySlug.Except(enemySlugDump).ToList(); //endWeapons Update ladar.Update(pGameTime, cone.Lockin, cone.stopAngle_M); if (SpawnBlock == 200) { SpawnEnemy(Content); SpawnBlock = 0; } else { SpawnBlock += 1; } //PlayerWeapons PlayerWpn[0].Update(); PlayerWpn[1].Update(); PlayerWpn[2].Update(); PlayerWpn[3].Update(); PlayerWpn[4].Update(); if (keyboard.IsKeyDown(Keys.D1)) { if (PlayerWpn[0].CanFire) { int i = 0; if (EnemyMissile.Count != 0) { while (i < EnemyMissile.Count && EnemyMissile[i] != null) { i++; } } Missile var = new Missile(content, this, i, TargetID); EnemyMissile.Insert(i, var); EnemyMissile[i].SpawnAt(new Vector2(640, 360)); EnemyMissile[i].SetDestination(GetPositionByID(TargetID)); EnemyMissile[i].Friendly = true; PlayerWpn[0].FireWeapon(); } } else if (keyboard.IsKeyDown(Keys.D2)) { if (PlayerWpn[1].CanFire) { int i = 0; if (Lasers.Count != 0) { while (i < Lasers.Count && Lasers[i] != null) { i++; } } Laser var = new Laser(content, this, TargetID, 10); Lasers.Insert(i, var); Lasers[i].SpawnAt(new Vector2(640, 360)); PlayerWpn[1].FireWeapon(); } } else if (keyboard.IsKeyDown(Keys.D3)) { if (PlayerWpn[2].CanFire) { int i = 0; if (EnemySlug.Count != 0) { while (i < EnemySlug.Count && EnemySlug[i] != null) { i++; } } Slug var = new Slug(content, this); EnemySlug.Insert(i, var); EnemySlug[i].SpawnAt(new Vector2(640, 360)); EnemySlug[i].SetDestination(GetPositionByID(TargetID)); PlayerWpn[2].FireWeapon(); } } else if (keyboard.IsKeyDown(Keys.D4)) { if (PlayerWpn[3].CanFire) { int i = 0; if (EnemyCannon.Count != 0) { while (i < EnemyCannon.Count && EnemyCannon[i] != null) { i++; } } Cannon var = new Cannon(content, this, TargetID, 10); EnemyCannon.Insert(i, var); EnemyCannon[i].SpawnAt(new Vector2(640, 360)); PlayerWpn[3].FireWeapon(); DamageTarget(TargetID, 3); } } else if (keyboard.IsKeyDown(Keys.D5)) { if (PlayerWpn[4].CanFire) { foreach (Fighter var1 in EnemyFighter) { DamageTarget(var1.ID, 4); } foreach (Frigate var1 in EnemyFrigate) { DamageTarget(var1.ID, 4); } foreach (Carrier var1 in EnemyCarrier) { DamageTarget(var1.ID, 4); } foreach (Dreadnought var1 in EnemyDreadnought) { DamageTarget(var1.ID, 4); } } } //End Player Weapons //Dreadnought Countdown foreach (Dreadnought Dreadnought in EnemyDreadnought) { if (Dreadnought.IsMoving == false) { Dreadnought.cannonCountdown -= 1; //Console.WriteLine(Dreadnought.cannonCountdown); } if (Dreadnought.cannonCountdown == 0) { Dreadnought.cannonCountdown = 100; } } //end Dreadnought Countdown } }
public void Shoot(Laser laser) { Lasers.Add(laser); }
public void SetupGUI(List <string> ports) { MainClass.win.settings.LoadSettingsSystem(); // remove all pages int n = notebook_detectors.NPages; for (int i = n - 1; i > -1; i--) { notebook_detectors.RemovePage(i); } n = notebook_sources.NPages; for (int i = n - 1; i > -1; i--) { notebook_sources.RemovePage(i); } if (ports.Count > 0) { // TODO DeviceOptionsAction.Sensitive = true; } List <string> ports2 = new List <string>(); for (int i = 0; i < ports.Count; i++) { ports2.Add(ports[i]); } // If the device already has some connected if (MainClass.devices != null) { for (int j = 0; j < MainClass.devices.Length; j++) { MainClass.devices[j].Disconnect(); } } MainClass.devices = new NIRSDAQ.Instrument.instrument[ports2.Count]; for (int i = 0; i < ports2.Count; i++) { MainClass.devices[i] = new NIRSDAQ.Instrument.instrument(settings.SYSTEM); MainClass.devices[i].Connect(ports2[i]); colorbutton3.Color = new Gdk.Color(128, 255, 128); DebugMessage(string.Format("Connected to device {0}", i + 1)); } if (nirsdata != null) { if (nirsdata.Count > ports2.Count) { nirsdata.RemoveRange(ports2.Count, nirsdata.Count - ports2.Count); } if (nirsdata.Count < ports2.Count) { if (nirsdata.Count > 0) { for (int i = nirsdata.Count - 1; i < ports2.Count; i++) { nirsdata.Add(nirsdata[0]); } } } } for (int i = 0; i < ports.Count; i++) { MainClass.devices[i].devicename = string.Format("{0}-{1}", MainClass.devices[i].devicename, i + 1); NIRSDAQ.info _info = MainClass.devices[i].GetInfo(); _info.numDet = settings.system_Info.numdet; _info.numSrc = settings.system_Info.numsrc; HBox hBox = new HBox(true, 0); Label label = new Label(); for (int j = 0; j < _info.numDet; j++) { if (j % 8 == 0) { hBox = new HBox(true, 0); label = new Label(string.Format("{0}\n{1}-{2}", _info.DeviceName, j + 1, j + 8)) { LineWrap = true }; notebook_detectors.InsertPage(hBox, label, notebook_detectors.NPages); } Detector det = new Detector { detectorIdx = j, deviceIdx = i, gain = 0, name = string.Format("Det-{0}", j + 1) }; det.frame = new Frame(det.name); VBox _box = new VBox(false, 0); _box.PackStart(new Gtk.Fixed()); det.led = new ColorButton(new Gdk.Color(0, 255, 0)) { HeightRequest = 25, Sensitive = false }; det.vScale = new VScale(0, settings.system_Info.maxgain, 1) { Value = det.gain, ValuePos = PositionType.Bottom, Inverted = true, HeightRequest = 175, Name = string.Format("{0}", _handles.detectors.Count) }; det.vScale.ValueChanged += DetChanged; _box.PackStart(det.led); _box.PackStart(det.vScale); det.frame.Add(_box); hBox.PackStart(det.frame); _handles.detectors.Add(det); } VBox _vbx = new VBox(); // Now add the source controls for (int j = 0; j < _info.numSrc; j += _info.numwavelengths) { if (j % 8 == 0) { _vbx = new VBox(true, 0); label = new Label(string.Format("{0}\n{1}-{2}", _info.DeviceName, j + 1, j + 8)) { LineWrap = true }; notebook_sources.InsertPage(_vbx, label, notebook_sources.NPages); } int sIdx = j / _info.numwavelengths + 1; Frame frame = new Frame(string.Format("Source-{0}", sIdx)); HBox _hbx = new HBox(true, 0); Lasers src = new Lasers { laserIdx = new int[_info.numwavelengths], wavelength = new int[_info.numwavelengths], gain = new int[_info.numwavelengths], state = new bool[_info.numwavelengths], buttons = new Button[_info.numwavelengths], led = new ColorButton[_info.numwavelengths], spinButtons = new SpinButton[_info.numwavelengths], deviceIdx = i, frame = frame }; for (int k = 0; k < _info.numwavelengths; k++) { src.laserIdx[k] = j + k; src.wavelength[k] = _info.wavelengths[k]; src.gain[k] = 0; src.state[k] = false; src.name = string.Format("{0}nm", src.wavelength[k]); HBox _hbx2 = new HBox(true, 0); src.buttons[k] = new Button { Label = src.name }; VBox _vbx3 = new VBox(true, 0); _vbx3.PackStart(src.buttons[k]); _vbx3.PackStart(new Gtk.Fixed()); _hbx2.PackStart(_vbx3); VBox _vbx2 = new VBox(true, 0); src.led[k] = new ColorButton(new Gdk.Color(128, 128, 128)) { HeightRequest = 25, Sensitive = false }; _vbx2.PackStart(src.led[k]); src.spinButtons[k] = new SpinButton(0, settings.system_Info.maxpower, 1) { Value = 0 }; src.buttons[k].Name = string.Format("{0}", _handles.lasers.Count); src.spinButtons[k].Name = string.Format("{0} {1}", _handles.lasers.Count, k); if (!settings.system_Info.laseradjustable) { src.spinButtons[k].Visible = false; } src.buttons[k].Clicked += SrcClicked; src.buttons[k].ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128)); src.buttons[k].ModifyBg(StateType.Selected, new Gdk.Color(128, 128, 128)); src.buttons[k].ModifyBg(StateType.Active, new Gdk.Color(128, 128, 128)); src.spinButtons[k].ValueChanged += SrcValueChanged; _vbx2.PackStart(src.spinButtons[k]); _hbx2.PackStart(_vbx2); _hbx.PackStart(_hbx2); if (k < _info.numwavelengths - 1) { _hbx.PackStart(new Gtk.VSeparator()); } } src.frame.Add(_hbx); _vbx.PackStart(src.frame); _handles.lasers.Add(src); } } string path = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); path = System.IO.Path.Combine(path, "LastSettings.xml"); if (System.IO.File.Exists(path)) { // Read the Config.xml file XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNodeList elemList; elemList = doc.GetElementsByTagName("probefile"); string probefile = elemList[0].InnerXml.Trim(); if (System.IO.File.Exists(probefile)) { QuickStartAction.Sensitive = true; // Read the Config.xml file elemList = doc.GetElementsByTagName("Investigator"); string investigator = elemList[0].InnerXml.Trim(); elemList = doc.GetElementsByTagName("Study"); string study = elemList[0].InnerXml.Trim(); QuickStartAction.Label = "Quick Start: " + investigator + ":" + study; DebugMessage("Last Settings Avaliable " + investigator + " : " + study); } else { QuickStartAction.Sensitive = false; } } else { QuickStartAction.Sensitive = false; } combobox_device1.Model = new ListStore(typeof(string)); combobox_device2.Model = new ListStore(typeof(string)); comboboxdeviceDemo.Model = new ListStore(typeof(string)); for (int i = 0; i < MainClass.devices.Length; i++) { combobox_device1.AppendText(MainClass.devices[i].devicename); combobox_device2.AppendText(MainClass.devices[i].devicename); comboboxdeviceDemo.AppendText(MainClass.devices[i].devicename); } combobox_device1.Active = 0; if (MainClass.devices.Length > 1) { combobox_device2.Active = 1; } ShowAll(); if (MainClass.devices.Length == 1) { fixed_device1.Visible = false; fixed_device2.Visible = false; combobox_device1.Visible = false; combobox_device2.Visible = false; drawingarea_Data2.Visible = false; drawingarea_SDG2.Visible = false; fixed_device1.Hide(); fixed_device2.Hide(); combobox_device1.Hide(); combobox_device2.Hide(); MultipleDevicesAction.Sensitive = false; drawingarea_Data2.Hide(); drawingarea_SDG2.Hide(); combobox_device1.Active = 0; DualViewAction.Sensitive = false; SingleViewAction.Sensitive = false; } else { // fixed_device1.Hide(); fixed_device2.Hide(); combobox_device1.Active = 0; combobox_device2.Active = 1; // combobox_device1.Hide(); combobox_device2.Hide(); MultipleDevicesAction.Sensitive = true; SingleViewAction.Active = false; DualViewAction.Sensitive = true; SingleViewAction.Sensitive = true; drawingarea_Data2.Hide(); drawingarea_SDG2.Hide(); } if (MainClass.devices.Length > 0) { NewSubjectAction.Sensitive = true; } }
void SrcClicked(object sender, EventArgs e) { int WidgetIdx = int.Parse(((Button)sender).Name); Lasers laser = _handles.lasers[WidgetIdx]; int deviceIdx = laser.deviceIdx; bool[] state = laser.state; string WL = ((Button)sender).Label; WL = WL.Remove(WL.Length - 2); // remove the trailing "nm" int laserIdx = int.Parse(WL); for (int i = 0; i < laser.wavelength.Length; i++) { if (laser.wavelength[i] == laserIdx) { laserIdx = i; break; } } bool newstate = !state[laserIdx]; if (checkbutton_linklasers.Active) { for (int i = 0; i < state.Length; i++) { if (state[i] != newstate) { MainClass.devices[deviceIdx].SetLaserState(laser.laserIdx[i], newstate); state[i] = newstate; } if (newstate) { laser.buttons[i].ModifyBg(StateType.Normal, new Gdk.Color(255, 0, 0)); laser.buttons[i].ModifyBg(StateType.Selected, new Gdk.Color(255, 0, 0)); laser.buttons[i].ModifyBg(StateType.Active, new Gdk.Color(255, 0, 0)); laser.led[i].Color = new Gdk.Color(255, 0, 0); } else { laser.buttons[i].ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128)); laser.buttons[i].ModifyBg(StateType.Selected, new Gdk.Color(128, 128, 128)); laser.buttons[i].ModifyBg(StateType.Active, new Gdk.Color(128, 128, 128)); laser.led[i].Color = new Gdk.Color(128, 128, 128); } } } else { MainClass.devices[deviceIdx].SetLaserState(laser.laserIdx[laserIdx], newstate); state[laserIdx] = newstate; if (newstate) { laser.buttons[laserIdx].ModifyBg(StateType.Normal, new Gdk.Color(255, 0, 0)); laser.buttons[laserIdx].ModifyBg(StateType.Selected, new Gdk.Color(255, 0, 0)); laser.buttons[laserIdx].ModifyBg(StateType.Active, new Gdk.Color(255, 0, 0)); laser.led[laserIdx].Color = new Gdk.Color(255, 0, 0); } else { laser.buttons[laserIdx].ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128)); laser.buttons[laserIdx].ModifyBg(StateType.Selected, new Gdk.Color(128, 128, 128)); laser.buttons[laserIdx].ModifyBg(StateType.Active, new Gdk.Color(128, 128, 128)); laser.led[laserIdx].Color = new Gdk.Color(128, 128, 128); } } laser.state = state; _handles.lasers[WidgetIdx] = laser; bool flag = false; for (int i = 0; i < state.Length; i++) { if (state[i]) { flag = true; } } if (flag) { label_srcbottom.Text = "Sources are On"; colorbutton_srcbottom.Color = new Gdk.Color(255, 0, 0); colorbutton4.Color = new Gdk.Color(255, 0, 0); button_srcOnOff.Label = "Turn Sources Off"; } else { label_srcbottom.Text = "Sources are Off"; colorbutton_srcbottom.Color = new Gdk.Color(128, 128, 128); colorbutton4.Color = new Gdk.Color(128, 128, 128); button_srcOnOff.Label = "Turn Sources On"; } return; }
public void AddLaser(string name, string photodiode) { Lasers.Add(name, photodiode); }
public void Clear() { Lasers.Clear(); }