public override bool AttemptUseAbility(InputAction.CallbackContext ctx, Vector2 inputDirection) { if (DEBUGFLAGS.ABILITY) { Debug.Log(string.Format("{0} ATTEMPT USE perf:{1} strt:{2} canc:{3}", name, ctx.performed, ctx.started, ctx.cancelled)); } if (!IsCastable()) { return(false); } if (!started) //the first press of the button { started = true; temp = PoolManager.instance.RequestObject(laserPrefab); BaseLaser laser = temp.GetComponent <BaseLaser>(); // temp.transform.localScale = new Vector3(size, size, size); laser.Setup ( playerAbilities.transform.position, inputDirection, playerAbilities.gameObject, laser.totalLength ); temp.GetComponent <Poolable>().Reset(); return(true); } started = false; UseAbility(ctx, inputDirection); return(false); }
/// <summary> /// Opens dialog to select laser executable manually. /// Gets the filename of selected executable and adds it to the list of sensors to be loaded. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLoadLaser_Click(object sender, EventArgs e) { DialogResult result = ofdSelectLaser.ShowDialog(); if (result == DialogResult.OK) { // get sensor executable title and add it to list Assembly laserAssembly = Assembly.LoadFrom(ofdSelectLaser.FileName); Type[] types = laserAssembly.GetExportedTypes(); BaseLaser laser = Activator.CreateInstance(types[0]) as BaseLaser; string laserTitle = laser.Title; if (cmbLasers.Items.Contains(laserTitle)) { int i = 1; laserTitle = laserTitle + " (" + i.ToString() + ")"; while (true) { if (!cmbLasers.Items.Contains(laserTitle)) { break; } } } cmbLasers.Items.Add(laserTitle); _laserPaths.Add(ofdSelectLaser.FileName); cmbLasers.SelectedIndex = cmbLasers.Items.Count - 1; EnableLaserRemoval(); } }
/// <summary> /// When laser form is closed, the resources must be released. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void laser_FormClosed(object sender, FormClosedEventArgs e) { _laser.FormClosed -= laser_FormClosed; _laser.Dispose(); _laser = null; gbLaser.Enabled = true; }
/// <summary> /// Starts the selected laser. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStartLaser_Click(object sender, EventArgs e) { // check the sensor part to exists if (!File.Exists(_laserPaths[cmbLasers.SelectedIndex])) { MessageBox.Show("The laser part is not found on path " + _laserPaths[cmbLasers.SelectedIndex] + ". Check the config file or load the part manually using \"Load\" button.", "Laser part not found.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // load the sensor part Assembly laserAssembly = Assembly.LoadFrom(_laserPaths[cmbLasers.SelectedIndex]); Type[] types = laserAssembly.GetExportedTypes(); _laser = Activator.CreateInstance(types[0]) as BaseLaser; _laser.FormClosed += laser_FormClosed; _laser.Show(); // Organize windows _laser.Location = new Point(Location.X + Size.Width + 10, 10); // Disable controls gbLaser.Enabled = false; }
public ZWPictureBox() { // enable double buffering this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.laser = new FixedLaser(this); rulers = new Rulers(this); listViewItemArray = new ListViewItemArray(); GraphicsList = new GraphicsList(); this.GraphicsList.DrawObjsChanged += GraphicsList_DrawObjsChanged; Initialize(); InitializeControls(); InitializeImageTracker(); this.PictureBoxPaintedEvent += imageTracker.OnPicturePainted; }
/// <summary> /// Finds laser executables and populates the dropdown list. /// </summary> /// <param name="laserPath">Path to laser executables</param> /// <param name="selectedIndex">Selected index for dropdownlist</param> private void FindLasers(string laserPath, JArray userLasers, int selectedIndex) { if (!Path.IsPathRooted(laserPath)) { laserPath = Path.GetFullPath(Path.Combine(BASE_DIR, laserPath)); } ofdSelectLaser.InitialDirectory = laserPath; string[] allLaserExes = Directory.GetFiles(laserPath, "*.exe", SearchOption.AllDirectories); List <string> laserTitles = new List <string>(); foreach (string laserExe in allLaserExes) { if (!laserExe.Contains("ref")) { _laserPaths.Add(laserExe); Assembly laserAssembly = Assembly.LoadFrom(laserExe); Type[] types = laserAssembly.GetExportedTypes(); BaseLaser laser = Activator.CreateInstance(types[0]) as BaseLaser; laserTitles.Add(laser.Title); } } cmbLasers.Items.AddRange(laserTitles.ToArray()); _numInstalledLasers = laserTitles.Count; // Finally load the sensors added by user foreach (JToken laser in userLasers) { cmbLasers.Items.Add(laser["title"]); _laserPaths.Add(Path.GetFullPath((string)laser["path"])); } if (selectedIndex < cmbLasers.Items.Count) { cmbLasers.SelectedIndex = selectedIndex; } EnableLaserRemoval(); }