예제 #1
0
        /// <summary>
        /// restore path from config file
        /// </summary>
        private void restoreData()
        {
            initConfig();

            String xp = "/configuration/chooser/chooser_" + Chooser.Name;
            String cp = Sharpend.Configuration.ConfigurationManager.getString(xp, true);

            if (!String.IsNullOrEmpty(ConfigFile))
            {
                cp = Sharpend.Configuration.ConfigurationManager.getString(ConfigFile, xp, true);
            }

            if (!String.IsNullOrEmpty(cp))
            {
                switch (Chooser.Action)
                {
                case FileChooserAction.SelectFolder:
                    Chooser.SetCurrentFolder(cp);
                    break;

                default:
                    Chooser.SetFilename(cp);
                    break;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Brings up the ASCOM Chooser Dialog to choose a SafetyMonitor
        /// </summary>
        /// <param name="SafetyMonitorID">SafetyMonitor Prog ID for default or null for None</param>
        /// <returns>Prog ID for chosen SafetyMonitor or null for none</returns>
        public static string Choose(string SafetyMonitorID)
        {
            Chooser oChooser = new Chooser();

            oChooser.DeviceType = "SafetyMonitor";                      // Requires Helper 5.0.3 (May '07)
            return(oChooser.Choose(SafetyMonitorID));
        }
예제 #3
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                Chooser choose = new Chooser();
                choose.DeviceType = "Telescope";
                string ProgId = choose.Choose(progId);
                if (ProgId != "")
                {
                    if (Driver != null)
                    {
                        Driver.Dispose();
                    }

                    Driver = new Telescope(ProgId);
                    btnSetup.Enabled = true;

                    nameTextBox.Text = Driver.Name;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// 根据权重获取
        /// </summary>
        public static Instance SelectHost(ServiceInfo serviceInfo)
        {
            var hosts = SelectAll(serviceInfo);

            _logger.Debug("entry randomWithWeight");

            Chooser <string, Instance> vipChooser = new Chooser <string, Instance>("www.vip56.cn");

            _logger.Debug("new Chooser");

            IList <Pair <Instance> > hostsWithWeight = new List <Pair <Instance> >();

            foreach (var host in hosts)
            {
                if (host.Healthy)
                {
                    hostsWithWeight.Add(new Pair <Instance>(host, host.Weight));
                }
            }

            _logger.Debug("foreach (Host host in hosts)");
            vipChooser.Refresh(hostsWithWeight);
            _logger.Debug("vipChooser.Refresh");
            return(vipChooser.RandomWithWeight());
        }
예제 #5
0
        public List <Particle> Find(Particles particles, Chooser chosser, Distribution distribution, int count)
        {
            if (count <= particles.ParticleList.Length)
            {
                List <Particle> chosenParticles = new List <Particle>();

                SetUpIncrement(distribution, particles, count);

                for (int i = 0; i < particles.ParticleList.Length; i += GetIncrement(distribution, particles, count))
                {
                    int index = GetIndex(distribution, particles, count, i);

                    if (index < particles.ParticleList.Length && chosenParticles.Count < count)
                    {
                        if (chosser(particles.ParticleList[index], index))
                        {
                            chosenParticles.Add(particles.ParticleList[index]);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                return(chosenParticles);
            }
            else
            {
                Debug.LogError("Not enough stars in galaxy");
                return(new List <Particle>());
            }
        }
예제 #6
0
 public override void Execute(Arguments arguments)
 {
     try
     {
         arguments.AssertMinimumCount(1);
         if (arguments.Exists(1) && arguments[1].Text == "/out")
         {
             FileName outfile = arguments[2].Text;
             if (outfile.Exists())
             {
                 outfile.Delete();
             }
             fileStream = outfile.WritingStream();
             writer     = new StreamWriter(fileStream)
             {
                 AutoFlush = true
             };
             SetOut(writer);
             SetError(writer);
         }
         var file    = arguments[0].FileName.Required($"File {arguments[0].Text} not found");
         var chooser = new Chooser(file);
         chooser.Choose();
         WriteLine("Done");
     }
     finally
     {
         writer?.Close();
         fileStream?.Close();
     }
 }
예제 #7
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                Chooser choose = new Chooser();
                choose.DeviceType = "Telescope";
                string ProgId = choose.Choose(progId);
                if (ProgId != "")
                {
                    if (Driver != null)
                    {
                        Driver.Dispose();
                    }

                    Driver           = new Telescope(ProgId);
                    btnSetup.Enabled = true;

                    nameTextBox.Text = Driver.Name;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #8
0
파일: Choice.cs 프로젝트: 0xCM/Meta.Core
        public void Test20()
        {
            var @class = typeof(Pick).Name;

            Option <Choice> ChoiceFunction(Choice input)
            {
                switch (input.Value)
                {
                case "A":
                    return(new Choice(("B", @class), "B"));

                case "B":
                    return(new Choice(("C", @class), "C"));

                case "C":
                    return(new Choice(("D", @class), "D"));

                case "D":
                    return(new Choice(("E", @class), "E"));

                case "E":
                    return(none <Choice>(inform("Endstate")));

                default:
                    return(none <Choice>(error("Unmatched")));
                }
            }

            var wf          = new Chooser(ChoiceFunction);
            var transitions = wf.Execute(new Choice(("A", @class), "A"));
        }
예제 #9
0
    public char GenerateMember(Chooser chooser, BinaryDecisionDiagram bdd)
    {
        var num = 0;

        for (var index = 0; index < BitLength; ++index)
        {
            if (index < bdd.Ordinal)
            {
                num |= chooser.ChooseBoolean() ? _bitMaps[index] : 0;
            }
            else if (bdd.FalseCase == BinaryDecisionDiagram.False)
            {
                num |= _bitMaps[index];
                bdd  = bdd.TrueCase;
            }
            else if (bdd.TrueCase == BinaryDecisionDiagram.False)
            {
                bdd = bdd.FalseCase;
            }
            else if (chooser.ChooseBoolean())
            {
                num |= _bitMaps[index];
                bdd  = bdd.TrueCase;
            }
            else
            {
                bdd = bdd.FalseCase;
            }
        }
        return((char)num);
    }
예제 #10
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialog to choose a SafetyMonitor
 /// </summary>
 /// <param name="safetyMonitorId">SafetyMonitor Prog ID for default or null for None</param>
 /// <returns>Prog ID for chosen SafetyMonitor or null for none</returns>
 public static string Choose(string safetyMonitorId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "SafetyMonitor";
         return(chooser.Choose(safetyMonitorId));
     }
 }
예제 #11
0
 public static string Choose(string cameraId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Camera";
         return(chooser.Choose(cameraId));
     }
 }
예제 #12
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialog to choose a Focuser
 /// </summary>
 /// <param name="focuserId">Focuser Prog ID for default or null for None</param>
 /// <returns>Prog ID for chosen focuser or null for none</returns>
 public static string Choose(string focuserId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Focuser";
         return(chooser.Choose(focuserId));
     }
 }
예제 #13
0
        /// <summary>
        /// The Choose() method returns the DriverID of the selected driver.
        /// Choose() allows you to optionally pass the DriverID of a "current" driver,
        /// and the corresponding camera type is pre-selected in the Chooser///s list.
        /// In this case, the OK button starts out enabled (lit-up); the assumption is that the pre-selected driver has already been configured.
        /// </summary>
        /// <param name="cameraId">Optional DriverID of the previously selected camera that is to be the pre-selected camera in the list.</param>
        /// <returns>
        /// The DriverID of the user selected camera. Null if the dialog is canceled.
        /// </returns>
        public static string Choose(string cameraId)
        {
            var oChooser = new Chooser {
                DeviceType = "Camera"
            };

            return(oChooser.Choose(cameraId));
        }
예제 #14
0
 public static string Choose(string domeId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Dome";
         return(chooser.Choose(domeId));
     }
 }
예제 #15
0
 public static string Choose(string videoId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Video";
         return(chooser.Choose(videoId));
     }
 }
예제 #16
0
        // No member here, we are relying on Dispose in the base class
        #endregion

        #endregion

        #region Convenience Members
        /// <summary>
        /// Brings up the ASCOM Chooser Dialog to choose a FilterWheel
        /// </summary>
        /// <param name="filterWheelId">FilterWheel Prog ID for default or null for None</param>
        /// <returns>Prog ID for chosen FilterWheel or null for none</returns>
        public static string Choose(string filterWheelId)
        {
            using (Chooser chooser = new Chooser())
            {
                chooser.DeviceType = "FilterWheel";
                return(chooser.Choose(filterWheelId));
            }
        }
예제 #17
0
        /// <summary>
        /// Brings up the ASCOM Chooser Dialog to choose a Focuser
        /// </summary>
        /// <param name="focuserId">Focuser Prog ID for default or null for None</param>
        /// <returns>Prog ID for chosen focuser or null for none</returns>
        public static string Choose(string focuserId)
        {
            var oChooser = new Chooser {
                DeviceType = "Focuser"
            };

            return(oChooser.Choose(focuserId));
        }
예제 #18
0
 public void SetStateChooser()
 {
     Reset();
     game.World = new World(game, "", components);
     chooser    = new Chooser(game);
     components.Add(chooser);
     inputFocus = chooser;
 }
예제 #19
0
        /// <summary>
        /// Shows the ASCOM Chooser to select a Dome.
        /// </summary>
        /// <param name="domeId">Prog ID of the default dome to select. Null if no default is to be set.</param>
        /// <returns>The Prog ID of the Dome chosen, or Null if no dome is chose, or the dialog is canceled.</returns>
        public static string Choose(string domeId)
        {
            var oChooser = new Chooser {
                DeviceType = "Dome"
            };

            return(oChooser.Choose(domeId));
        }
예제 #20
0
 public static string Choose(string telescopeId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Telescope";
         return(chooser.Choose(telescopeId));
     }
 }
예제 #21
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialogue to choose a CoverCalibrator
 /// </summary>
 /// <param name="coverCalibratorId">CoverCalibrator ProgID for default or null for None</param>
 /// <returns>ProgID for chosen CoverCalibrator or null for none</returns>
 public static string Choose(string coverCalibratorId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "CoverCalibrator";
         return(chooser.Choose(coverCalibratorId));
     }
 }
예제 #22
0
        ///// <summary>
        ///// Equivalent (identical)
        ///// </summary>
        //public static bool operator ==(BV128 x, BV128 y)
        //{
        //    return x.Item1 == y.Item1 && x.Item2 == y.Item2;
        //}

        ///// <summary>
        ///// Inequivalent (different)
        ///// </summary>
        //public static bool operator !=(BV128 x, BV128 y)
        //{
        //    return x.Item1 != y.Item1 || x.Item2 != y.Item2;
        //}

        /// <summary>
        /// Generates a random bitvector.
        /// </summary>
        public static BV128 Random()
        {
            var c  = new Chooser();
            var u1 = c.ChooseBV64();
            var u2 = c.ChooseBV64();

            return(new BV128(u1, u2));
        }
예제 #23
0
 public static string Choose(string switchId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Switch";
         return(chooser.Choose(switchId));
     }
 }
 public static string Choose(string observingConditionsId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "ObservingConditions";
         return(chooser.Choose(observingConditionsId));
     }
 }
예제 #25
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialogue to choose a Rotator
 /// </summary>
 /// <param name="rotatorId">Rotator ProgID for default or null for None</param>
 /// <returns>ProgID for chosen Rotator or null for none</returns>
 public static string Choose(string rotatorId)
 {
     using (Chooser chooser = new Chooser())
     {
         chooser.DeviceType = "Rotator";
         return(chooser.Choose(rotatorId));
     }
 }
예제 #26
0
        /// <summary>
        ///   Brings up the ASCOM Chooser Dialog to choose a Switch
        /// </summary>
        /// <param name = "switchId">Switch Prog ID for default or null for None</param>
        /// <returns>Prog ID for chosen Switch or null for none</returns>
        public static string Choose(string switchId)
        {
            var oChooser = new Chooser {
                DeviceType = "Switch"
            };

            return(oChooser.Choose(switchId));
        }
        public static string Choose(string id)
        {
            Chooser chooser = new Chooser
            {
                DeviceType = "Telescope"
            };

            return(chooser.Choose(id));
        }
예제 #28
0
 // update chooser, but not for random players
 internal bool UpdateChooser()
 {
     if (Def.PlayerLookup[CurrentBoard.TurnPlayer].IsRandom)
     {
         return(true);
     }
     Chooser.Update();
     return(Chooser.Choice.IsDone);
 }
        public static string Choose(string id)
        {
            Chooser chooser = new Chooser
            {
                DeviceType = "Focuser"
            };

            return(chooser.Choose(id));
        }
예제 #30
0
 private void btnChooseCCDCamera_Click(object sender, EventArgs e)
 {
     var chooser = new Chooser();
     chooser.DeviceType = "Camera";
     string driverProdId = chooser.Choose();
     if (!string.IsNullOrEmpty(driverProdId))
     {
         tbxCameraProgId.Text = driverProdId;
     }
 }
예제 #31
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialog to choose a FilterWheel
 /// </summary>
 /// <param name="filterWheelId">FilterWheel Prog ID for default or null for None</param>
 /// <returns>Prog ID for chosen FilterWheel or null for none</returns>
 public static string Choose(string filterWheelId)
 {
     try
     {
         var oChooser = new Chooser {
             DeviceType = "FilterWheel"
         };
         return(oChooser.Choose(filterWheelId));
     }
     catch
     {
         return("");
     }
 }
예제 #32
0
 /// <summary>
 /// Brings up the ASCOM Chooser Dialog to choose a Rotator
 /// </summary>
 /// <param name="rotatorId">Focuser Prog ID for default or null for None</param>
 /// <returns>Prog ID for chosen Rotator or null for none</returns>
 public static string Choose(string rotatorId)
 {
     try
     {
         var oChooser = new Chooser {
             DeviceType = "Rotator"
         };
         return(oChooser.Choose(rotatorId));
     }
     catch
     {
         return("");
     }
 }
예제 #33
0
 private void ChooseButton_Click(object sender, EventArgs e)
 {
     ASCOM.Utilities.Chooser _chooser = new Chooser();
     _chooser.DeviceType = "Focuser";
     _progID = _chooser.Choose(_progID);
     _chooser.Dispose();
     ChosenFocuser.Text = _progID;
     //_profile.WriteValue(_appID, "ChosenFocuser", _progID);
     if (_progID == "")
         return;
     if (_progID == "")
         ConnectButton.Enabled = false;
     else
         ConnectButton.Enabled = true;
 }
예제 #34
0
        public void OnButton()
        {
            var ch = new Chooser {DeviceType = "Telescope"};
            var device = ch.Choose();

            if (string.IsNullOrEmpty(device))
                return;

            try
            {
                var scope = CreateScope(device);
                Settings1.Default.LastMountId = device;
                Settings1.Default.LastMount = scope.Name;
                Settings1.Default.Save();
            }
            catch (Exception e)
            {
                _state.ShowMessage("Cannot create ASCOM mount driver " + device + "\r\nBecause : " + e.Message);
            }
        }
예제 #35
0
 ///// <summary>
 ///// Create a regex member generator for the given character encoding and the given random seed
 ///// </summary>
 ///// <param name="encoding">character encoding</param>
 ///// <param name="randomSeed">if less than 0 then a randomly chosen random seed is used</param>
 //public RexEngine(BitWidth encoding, int randomSeed)
 //{
 //    //int t = System.Environment.TickCount;
 //    this.encoding = encoding;
 //    solver = new CharSetSolver(encoding);
 //    chooser = (randomSeed < 0 ? new Chooser() : new Chooser(randomSeed));
 //    converter = solver.regexConverter;
 //}
 /// <summary>
 /// Create a regex member generator for the given character encoding.
 /// </summary>
 /// <param name="encoding">character encoding</param>
 public RexEngine(BitWidth encoding)
 {
     //int t = System.Environment.TickCount;
     this.encoding = encoding;
     solver = new CharSetSolver(encoding);
     chooser = new Chooser();
     converter = solver.regexConverter;
 }
예제 #36
0
 internal RexEngine(CharSetSolver solver)
 {
     this.solver = solver;
     converter = solver.regexConverter; //new RegexToAutomatonConverterCharSet(solver);
     chooser = converter.Chooser;
 }