示例#1
0
        static async Task ProcessarMensagemAsync(Message message, CancellationToken token)
        {
            try
            {
                Console.WriteLine($"Mensagem recebida: Número sequencial: {message.SystemProperties.SequenceNumber} Body: {Encoding.UTF8.GetString(message.Body)}");

                await queueClient.CompleteAsync(message.SystemProperties.LockToken);

                var evento = Newtonsoft.Json.JsonConvert.DeserializeObject <Domain.Eventos.Evento>(Encoding.UTF8.GetString(message.Body));
                evento.Status = EnumMethods.GetDescription(EnumStatus.Processado);

                if (await Collection.Find(x => x.Id == evento.Id).FirstOrDefaultAsync() == null)
                {
                    await Collection.InsertOneAsync(evento);
                }
            }
            catch (Exception ex)
            {
                var evento = Newtonsoft.Json.JsonConvert.DeserializeObject <Domain.Eventos.Evento>(Encoding.UTF8.GetString(message.Body));
                evento.Status = EnumMethods.GetDescription(EnumStatus.Erro);

                if (await Collection.Find(x => x.Id == evento.Id).FirstOrDefaultAsync() == null)
                {
                    await Collection.InsertOneAsync(evento);
                }

                throw ex;
            }
        }
示例#2
0
        protected override Expression <Func <string, TTo> > CompileToExpression()
        {
            ParameterExpression from = Expression.Parameter(typeof(string), "from");

            if (typeof(TTo).IsEnum)
            {
                return(Expression.Lambda <Func <string, TTo> >(
                           Expression.Convert(
                               Expression.Call(
                                   null,
                                   EnumMethods.Parse(typeof(TTo)),
                                   Expression.Constant(typeof(TTo)),
                                   from
                                   ),
                               typeof(TTo)
                               ),
                           from
                           ));
            }
            else
            {
                return(Expression.Lambda <Func <string, TTo> >(
                           Expression.Call(
                               null,
                               PrimitiveTypeMethods.Parse(typeof(TTo)),
                               from
                               ),
                           from
                           ));
            }
        }
示例#3
0
        public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
        {
            try
            {
                string status = string.IsNullOrWhiteSpace(request.Valor) ? EnumMethods.GetDescription(Status.Erro) : EnumMethods.GetDescription(Status.Processado);
                await _eventoWrite.Inserir(new Evento(request.TimeStamp, request.Tag, request.Valor, status));

                await _mediator.Publish(new Notification
                {
                    TimeStamp = request.TimeStamp,
                    Tag       = request.Tag,
                    Valor     = request.Valor,
                    Status    = status
                }, cancellationToken);

                return(new Response("Evento criado com sucesso."));
            }
            catch
            {
                var evento = new Evento(request.TimeStamp, request.Tag, request.Valor, EnumMethods.GetDescription(Status.Erro));
                await _eventoWrite.Inserir(evento);

                return(new Response("Erro ao criar evento."));
            }
        }
示例#4
0
        /// <summary>
        /// Refactor button click
        /// </summary>
        private void btnRefactor_Click(object sender, EventArgs e)
        {
            int           index = 0;
            StringBuilder sb    = new StringBuilder();

            // Enum.GetValues doesn't order the enums as they are listed in code, this itrates in code order, or at least it should XD
            // It is done this way to make sure enemy and character sprites are in the order they are in the rom, as an offset is used for their sprite id
            foreach (FieldInfo type in typeof(SpriteType).GetFields().Where(fi => fi.IsStatic).OrderBy(fi => fi.MetadataToken))
            {
                // Only increment sprite values, other types use their byte address as the value
                sb.AppendLine("[Description(\"" + EnumMethods.GetDescription(typeof(SpriteType), type.Name) + "\")]");
                sb.AppendLine("[PaletteGroupID(" + EnumMethods.GetPaletteGroupID(typeof(SpriteType), type.Name) + ")]");
                sb.AppendLine("[PaletteIndex(" + EnumMethods.GetPaletteIndex(typeof(SpriteType), type.Name) + ")]");
                string     tilesetIDs = "new int[] { ";
                List <int> ts         = EnumMethods.GetTilesetIDs(typeof(SpriteType), type.Name);
                foreach (int tilesetId in ts)
                {
                    tilesetIDs += tilesetId + (tilesetId != ts[ts.Count - 1] ? ", " : "");
                }
                string     tileMapIDs = "new int[] { ";
                List <int> tm         = EnumMethods.GetTileMapIDs(typeof(SpriteType), type.Name);
                foreach (int tileMapId in tm)
                {
                    tileMapIDs += tileMapId + (tileMapId != tm[tm.Count - 1] ? ", " : "");
                }
                sb.AppendLine("[TilesetIDs(" + tilesetIDs + " })]");
                sb.AppendLine("[TileMapIDs(" + tileMapIDs + " })]");
                sb.AppendLine(type.Name + " = " + index + ",");
                index++;
            }
            // Dump to control (Use ouput to replace SpriteType enumeration)
            txtResults.Text = sb.ToString();
        }
示例#5
0
        /// <summary>
        /// Loads map data
        /// </summary>
        private void LoadData()
        {
            // Load scale types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbTilesetScale
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ScaleType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ScaleType), (ScaleType)value)));
                }
            }

            // If there is data, load map data
            if (_mainForm != null && _mainForm.RomData != null)
            {
                // Load maps
                foreach (Map map in MainForm.RomData.Maps)
                {
                    TreeNode mapNode = new TreeNode(map.Name);
                    mapNode.Tag = map.ID.ToString();
                    trMaps.Nodes.Add(mapNode);
                }
            }
        }
示例#6
0
文件: DataForm.cs 项目: xfixium/Rika
        /// <summary>
        /// Sets the grid data
        /// </summary>
        private void SetGrid()
        {
            colName.DataPropertyName  = "CustomName";
            colValue.DataPropertyName = _stat.ToString();
            colValue.HeaderText       = EnumMethods.GetDescription(typeof(StatType), _stat);
            BindingSource source = new BindingSource {
                DataSource = _list
            };

            grdMain.DataSource = source;
        }
示例#7
0
        public static void EnsureFolderStructure(List <string> scenarios)
        {
            string root = DataWorks.FolderPlotsRemote;

            foreach (var es in EnumMethods.AllExperimentScenarios().Where(x => scenarios.Contains(x.ToLongString())))
            {
                string esDir = $"{root}{es.ToLongString()}/";
                if (!Directory.Exists(esDir))
                {
                    Directory.CreateDirectory(esDir);
                }
            }
        }
        public List <EnumMethods> GetEntities()
        {
            var entities = new List <EnumMethods>();

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_EnumMethods_Repository_GetEntities, null)) {
                while (rdr.Read())
                {
                    var entity = new EnumMethods();
                    entity.Id      = SqlTypeConverter.DBNullInt32Handler(rdr["Id"]);
                    entity.Name    = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.TypeId  = SqlTypeConverter.DBNullInt32Handler(rdr["TypeId"]);
                    entity.Index   = SqlTypeConverter.DBNullInt32Handler(rdr["Index"]);
                    entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]);
                    entities.Add(entity);
                }
            }
            return(entities);
        }
示例#9
0
文件: DataForm.cs 项目: xfixium/Rika
 /// <summary>
 /// Constructors
 /// </summary>
 /// <param name="title">Window title</param>
 /// <param name="list">The list to use</param>
 /// <param name="item">The item that will have focus in the list</param>
 /// <param name="stat">The property to display, and is based on the comparisons</param>
 public DataForm(string title, object list, string item, StatType stat)
 {
     InitializeComponent();
     Text  = title;
     _list = list;
     _stat = stat;
     grdMain.AutoGenerateColumns = false;
     foreach (ComboBox cb in new List <ComboBox>()
     {
         cbSort
     })
     {
         cb.Items.Clear();
         foreach (int value in Enum.GetValues(typeof(SortType)))
         {
             cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SortType), (SortType)value)));
         }
         cb.SelectedIndex = 1;
     }
 }
        public EnumMethods GetEntity(int id)
        {
            SqlParameter[] parms = { new SqlParameter("@Id", SqlDbType.Int) };
            parms[0].Value = SqlTypeConverter.DBNullInt32Checker(id);

            EnumMethods entity = null;

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_EnumMethods_Repository_GetEntity, parms)) {
                if (rdr.Read())
                {
                    entity         = new EnumMethods();
                    entity.Id      = SqlTypeConverter.DBNullInt32Handler(rdr["Id"]);
                    entity.Name    = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.TypeId  = SqlTypeConverter.DBNullInt32Handler(rdr["TypeId"]);
                    entity.Index   = SqlTypeConverter.DBNullInt32Handler(rdr["Index"]);
                    entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]);
                }
            }
            return(entity);
        }
示例#11
0
 /// <summary>
 /// Analyze button click
 /// </summary>
 private void btnAnalyze_Click(object sender, EventArgs e)
 {
     if (sender == btnElementAnalyze)
     {
         if (cbElement.SelectedItem == null)
         {
             return;
         }
         lstDamageAnalyze.Items.Clear();
         ObjectID item = cbElement.SelectedItem as ObjectID;
         foreach (Enemy enemy in MainForm.RomData.Enemies)
         {
             if (enemy.AttackElement == (ElementType)item.ID && !lstDamageAnalyze.Items.Contains(enemy.CustomName))
             {
                 lstDamageAnalyze.Items.Add(enemy.CustomName);
             }
         }
         string elementName = EnumMethods.GetDescription(typeof(ElementType), item);
         int    count       = lstDamageAnalyze.Items.Count;
         lblDamageAnalyze.Text = (count < 1 ? "No" : count.ToString()) + (count == 1 ? " enemy" : " enemies") + " use" + (count == 1 ? "s" : "") + " the " + elementName + " damage element:";
     }
     else if (sender == btnStatusAnalyze)
     {
         lstDamageAnalyze.Items.Clear();
         ObjectID item = cbStatus.SelectedItem as ObjectID;
         foreach (Enemy enemy in MainForm.RomData.Enemies)
         {
             if (enemy.StatusEffect == (StatusEffectType)item.ID && !lstDamageAnalyze.Items.Contains(enemy.CustomName))
             {
                 lstDamageAnalyze.Items.Add(enemy.CustomName);
             }
         }
         string elementName = EnumMethods.GetDescription(typeof(StatusEffectType), item);
         int    count       = lstDamageAnalyze.Items.Count;
         lblDamageAnalyze.Text = (count < 1 ? "No" : count.ToString()) + (count == 1 ? " enemy" : " enemies") + " use" + (count == 1 ? "s" : "") + " the " + elementName + " status effect:";
     }
 }
示例#12
0
        public static void EnsureFolderStructure()
        {
            string root = DataWorks.FolderPlotsRemote;

            foreach (var ex in EnumMethods.AllExperiments())
            {
                string exDir = $"{root}{ex.ToLongString()}/";
                if (!Directory.Exists(exDir))
                {
                    Directory.CreateDirectory(exDir);
                }

                foreach (var et in EnumMethods.AllExperimentTypes())
                {
                    // exception
                    if (ex == Experiment.Precision && et == ExperimentType.Streaming)
                    {
                        continue;
                    }

                    string etDir = $"{exDir}{et.ToLongString()}/";
                    if (!Directory.Exists(etDir))
                    {
                        Directory.CreateDirectory(etDir);
                    }

                    foreach (var es in EnumMethods.AllExperimentScenarios())
                    {
                        string esDir = $"{etDir}{es.ToLongString()}/";
                        if (!Directory.Exists(esDir))
                        {
                            Directory.CreateDirectory(esDir);
                        }
                    }
                }
            }
        }
        public List <EnumMethods> GetEntities(EnmMethodType type, string comment)
        {
            SqlParameter[] parms = { new SqlParameter("@TypeId",  SqlDbType.Int),
                                     new SqlParameter("@Comment", SqlDbType.VarChar, 512) };

            parms[0].Value = (int)type;
            parms[1].Value = SqlTypeConverter.DBNullStringChecker(comment);

            var entities = new List <EnumMethods>();

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_EnumMethods_Repository_GetEntitiesByType, parms)) {
                while (rdr.Read())
                {
                    var entity = new EnumMethods();
                    entity.Id      = SqlTypeConverter.DBNullInt32Handler(rdr["Id"]);
                    entity.Name    = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.TypeId  = SqlTypeConverter.DBNullInt32Handler(rdr["TypeId"]);
                    entity.Index   = SqlTypeConverter.DBNullInt32Handler(rdr["Index"]);
                    entity.Comment = SqlTypeConverter.DBNullStringHandler(rdr["Comment"]);
                    entities.Add(entity);
                }
            }
            return(entities);
        }
示例#14
0
        private static void Main(string[] args)
        {
            DataWorks.FolderPlotsRemote = DataWorks.FolderPlotsRemoteBase = "Results/";

            // technical
            Console.CancelKeyPress += InterruptHandler;

            // cli
            List <string>    codesinit   = new List <string>();
            List <Algorithm> algos       = new List <Algorithm>();
            List <string>    scenarios   = new List <string>();
            bool             doPrecision = true;
            bool             doRuntime   = true;

            CLIParse(args, ref codesinit, ref algos, ref scenarios, ref doPrecision, ref doRuntime);

            if (!(doPrecision || doRuntime))
            {
                Console.WriteLine("Both precision and runtime tests are disabled, no results will be produced");
                Environment.Exit(-1);
            }

            if (codesinit == null || codesinit.Count == 0)
            {
                codesinit = Directory.GetDirectories(DataWorks.FolderData)
                            .Where(x => !x.EndsWith("_.temp"))
                            .Select(x => x.Replace(DataWorks.FolderData, ""))
                            .ToList();
            }

            string[] codes        = codesinit.Distinct().ToArray();
            string[] codesLimited = codes
                                    .Where(c => DataWorks.CountMatrixColumns($"{c}/{c}_normal.txt") > 4)
                                    .ToArray();

            if (algos == null || algos.Count == 0)
            {
                algos = AlgoPack.ListAlgorithms.ToList();
            }

            if (scenarios == null || scenarios.Count == 0)
            {
                scenarios = EnumMethods.AllExperimentScenarios().Select(EnumMethods.ToLongString).ToList();
            }
            AlgoPack.GlobalAlgorithmsLocation    = "../../../Algorithms/";
            AlgoPack.GlobalNewAlgorithmsLocation = "../../../NewAlgorithms/";

            // verificaiton that all necessary entries are provided

            if (codes == null || codes.Length == 0)
            {
                throw new InvalidProgramException($"Invalid program state: no datasets found in {DataWorks.FolderData} folder");
            }

            AlgoPack.ListAlgorithms            = algos.ToArray();
            AlgoPack.ListAlgorithmsMulticolumn = algos.Where(alg => alg.IsMultiColumn).ToArray();

            AlgoPack.CleanUncollectedResults();
            AlgoPack.EnsureFolderStructure(scenarios);

            void FullRun(bool enablePrecision, bool enableRuntime)
            {
                foreach (string code in codes)
                {
                    foreach (ExperimentScenario es in EnumMethods.AllExperimentScenarios().Where(x => scenarios.Contains(x.ToLongString()) || scenarios.Contains(x.ToShortString())))
                    {
                        if (es.IsLimited() && !codesLimited.Contains(code))
                        {
                            continue;
                        }
                        if (enablePrecision)
                        {
                            TestRoutines.PrecisionTest(ExperimentType.Recovery, es, code);
                        }
                        if (enableRuntime)
                        {
                            TestRoutines.RuntimeTest(ExperimentType.Recovery, es, code);
                        }
                    }
                }
            }

            FullRun(doPrecision, doRuntime);

            FinalSequence();
        }
示例#15
0
        private static void CLIParse(
            string[] args, ref List <string> codes, ref List <Algorithm> algos, ref List <string> scenarios,
            ref bool doPrecision, ref bool doRuntime)
        {
            string subCmd;
            bool   allAlgosInvoked = false;

            if (args.Length == 0)
            {
                CLIPrintHelp();
                Environment.Exit(0);
            }

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToLower())
                {
                case "[arguments]":
                case "--help":
                case "-h":
                    CLIPrintHelp();
                    Environment.Exit(0);
                    break;

                case "--dataset":
                case "-d":
                    CLIVerifyInput(i + 1, args.Length, args[i], "dataset name(s)");
                    subCmd = args[++i];

                    if (subCmd == "all")
                    {
                    }
                    else if (subCmd.Contains(","))
                    {
                        codes.AddRange(subCmd.Split(',').Select(x => x.Trim()).Distinct());
                    }
                    else
                    {
                        codes.Add(subCmd);
                    }
                    break;

                case "--algorithm":
                case "-alg":
                    CLIAllAgosIntegrity(allAlgosInvoked);
                    CLIVerifyInput(i + 1, args.Length, args[i], "algorithm name(s)");
                    subCmd = args[++i];

                    if (subCmd == "all")
                    {
                        if (algos.Count() != 0)
                        {
                            Console.WriteLine("Algorithms were already added with --algorithm or --algorithm-param");
                            Console.WriteLine("`--algorithm all` can't be invoked any more");
                            Environment.Exit(-1);
                        }
                        // static list for vldb bench
                        algos.AddRange(new[] { AlgoPack.Stmvl, AlgoPack.CdRec, AlgoPack.Tkcm, AlgoPack.Spirit, AlgoPack.Trmf, AlgoPack.Nnmf, AlgoPack.Grouse, AlgoPack.Svt, AlgoPack.SoftImpute, AlgoPack.ROSL, AlgoPack.DynaMMo, AlgoPack.SvdI });
                        allAlgosInvoked = true;
                    }
                    else if (subCmd == "full")
                    {
                        if (algos.Count() != 0)
                        {
                            Console.WriteLine("Algorithms were already added with --algorithm or --algorithm-param");
                            Console.WriteLine("`--algorithm full` can't be invoked any more");
                            Environment.Exit(-1);
                        }
                        // left null and will be filled with ALL algorithms
                        allAlgosInvoked = true;
                    }
                    else if (subCmd.Contains(","))
                    {
                        DataWorks.PlottableOverride = true;
                        algos.AddRange(subCmd.Split(',').Select(x => x.Trim()).Select(CLIFindAlgorithmByName));
                    }
                    else
                    {
                        DataWorks.PlottableOverride = true;
                        algos.Add(CLIFindAlgorithmByName(subCmd));     //map into Algorithm instance
                    }
                    break;

                case "--algorithm-param":
                case "-algx":
                    CLIAllAgosIntegrity(allAlgosInvoked);
                    CLIVerifyInput(i + 1, args.Length, args[i], "algorithm name");
                    subCmd = args[++i];

                    CLIVerifyInput(i + 1, args.Length, args[i], "algorithm parameter");
                    string param = args[++i];

                    DataWorks.PlottableOverride = true;
                    Algorithm alg = CLIFindAlgorithmByName(subCmd);
                    algos.Add(alg);

                    CLISetAlgoParam(alg, param);

                    break;

                case "--scenario":
                case "-scen":
                    CLIVerifyInput(i + 1, args.Length, args[i], "scenario name(s)");
                    subCmd = args[++i];

                    if (subCmd == "all")
                    {
                    }
                    else if (subCmd.Contains(","))
                    {
                        scenarios.AddRange(subCmd.Split(',').Select(x => x.Trim()).Distinct());
                    }
                    else
                    {
                        scenarios.Add(subCmd);
                    }
                    break;

                case "--no-runtime":
                case "-nort":
                    doRuntime = false;
                    break;

                case "--no-precision":
                case "-noprec":
                    doPrecision = false;
                    break;

                case "--no-visualization":
                case "-novis":
                    DataWorks.DisableVisualization = true;
                    break;

                case "--set-output":
                case "-out":
                    CLIVerifyInput(i + 1, args.Length, args[i], "output folder");
                    subCmd = args[++i];

                    if (!subCmd.EndsWith("/"))
                    {
                        subCmd = subCmd + "/";
                    }

                    DataWorks.FolderPlotsRemote = DataWorks.FolderPlotsRemoteBase = subCmd;
                    break;

                default:
                    Console.WriteLine($"{args[i]} is not a recognized CLI parameter for the program");
                    Environment.Exit(-1);
                    break;
                }
            }

            if (algos.Count() != algos.Distinct().Count())
            {
                Console.WriteLine($"One or more algorithms were supplied multiple times. This can cause configuration conflicts.");
                Console.WriteLine($"Please ensure every algorithm is given only once.");
                Environment.Exit(-1);
            }

            codes.ForEach(c =>
            {
                if (!File.Exists(DataWorks.FolderData + $"{c}/{c}_normal.txt"))
                {
                    Console.WriteLine($"Dataset with name {c} is not found. Please make sure dataset with this name exists and the file is named correctly");
                    Environment.Exit(-1);
                }
            });

            var allScen     = EnumMethods.AllExperimentScenarios().SelectMany(x => new[] { x.ToLongString(), x.ToShortString() });
            var invalidScen = scenarios.Except(allScen);

            if (invalidScen.Count() != 0)
            {
                Console.WriteLine($"{invalidScen.First()} is an invalid scenario name");
                Environment.Exit(-1);
            }
        }
示例#16
0
        /// <summary>
        /// Loads character data
        /// </summary>
        private void LoadData()
        {
            // Load character types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacters
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(CharacterType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(CharacterType), (CharacterType)value)));
                }
            }

            // Load character graphics types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbGraphics
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(CharacterGraphicsType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(CharacterGraphicsType), (CharacterGraphicsType)value)));
                }
            }

            // Load sort types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterSort, cbEquipmentSort
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SortType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SortType), (SortType)value)));
                }
            }

            // Load resistance types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbPhysicalResistance, cbRadiationResistance, cbFireResistance, cbGravityResistance, cbWaterResistance,
                cbEnergyResistance, cbElectricResistance, cbHolyResistance, cbDeathResistance, cbBiologicalResistance, cbPsychicResistance, cbMechanicalResistance,
                cbLightResistance, cbDestroyResistance
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ResistanceType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ResistanceType), (ResistanceType)value)));
                }
            }

            // Load equipment types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbEquipmentType
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(CharacterEquipmentType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(CharacterEquipmentType), (CharacterEquipmentType)value)));
                }
            }

            // Select second item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterSort, cbEquipmentSort
            })
            {
                if (cb.Items.Count > 1)
                {
                    cb.SelectedIndex = 1;
                }
            }

            // Select first item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacters, cbGraphics
            })
            {
                if (cb.Items.Count > 0)
                {
                    cb.SelectedIndex = 0;
                }
            }
        }
示例#17
0
        /// <summary>
        /// Loads enemy data
        /// </summary>
        private void LoadData()
        {
            // Load sort types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbEnemiesSort
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SortType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SortType), (SortType)value)));
                }
            }

            // Load enemy graphic types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbGraphics
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(EnemyGraphicsType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EnemyGraphicsType), (EnemyGraphicsType)value)));
                }
            }

            // Load scale types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbScale
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ScaleType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ScaleType), (ScaleType)value)));
                }
            }

            // Load damage element types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbElement
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ElementType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ElementType), (ElementType)value)));
                }
            }

            // Load status effect types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbStatus
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(StatusEffectType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(StatusEffectType), (StatusEffectType)value)));
                }
            }

            // Load resistance types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbPhysicalResistance, cbRadiationResistance, cbFireResistance, cbGravityResistance, cbWaterResistance,
                cbEnergyResistance, cbElectricResistance, cbHolyResistance, cbDeathResistance, cbBiologicalResistance, cbPsychicResistance, cbMechanicalResistance,
                cbLightResistance, cbDestroyResistance
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ResistanceType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ResistanceType), (ResistanceType)value)));
                }
            }

            // Load condition types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbTrigger1, cbTrigger2, cbTrigger3, cbTrigger4
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(TriggerType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(TriggerType), (TriggerType)value)));
                }
            }

            // Load enemy data
            if (HasData)
            {
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbAction1, cbAction2, cbAction3, cbAction4, cbAction5, cbAction6, cbAction7,
                    cbAction8, cbTriggerAction1, cbTriggerAction2, cbTriggerAction3, cbTriggerAction4
                })
                {
                    cb.Items.Clear();
                    foreach (Skill skill in MainForm.RomData.EnemySkills)
                    {
                        cb.Items.Add(new ObjectID(skill.ID, skill.CustomName));
                    }
                }

                cbEnemies.Items.Clear();
                foreach (Enemy enemy in MainForm.RomData.Enemies)
                {
                    cbEnemies.Items.Add(new ObjectID(enemy.ID, enemy.CustomName));
                }

                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbEnemies
                })
                {
                    if (cb.Items.Count > 0)
                    {
                        cb.SelectedIndex = 0;
                    }
                }
            }

            // Select first item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbGraphics, cbScale
            })
            {
                if (cb.Items.Count > 0)
                {
                    cb.SelectedIndex = 0;
                }
            }

            // Select second item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbEnemiesSort
            })
            {
                if (cb.Items.Count > 1)
                {
                    cb.SelectedIndex = 1;
                }
            }
        }
示例#18
0
        /// <summary>
        /// Saves selected data
        /// </summary>
        private void SaveData()
        {
            // If the required objects are missing, return
            if (_mainForm == null || _mainForm.RomData == null || cbSave.SelectedItem == null || cbSaveAs.SelectedItem == null)
            {
                return;
            }

            // Set up objects
            ObjectID   objectID   = null;
            Bitmap     bmp        = null;
            SaveType   saveType   = (SaveType)(cbSave.SelectedItem as ObjectID).ID;
            SaveAsType saveAsType = (SaveAsType)(cbSaveAs.SelectedItem as ObjectID).ID;
            string     save       = EnumMethods.GetDescription(typeof(SaveType), saveType);
            string     saveAs     = EnumMethods.GetDescription(typeof(SaveAsType), saveAsType);

            switch (saveType)
            {
            case SaveType.PaletteGroup: objectID = GetSelectedPaletteGroup(); bmp = objectID != null?GetSelectedPaletteGroup().GetPaletteGroupImage() : null; break;

            case SaveType.Sprite: objectID = GetSelectedSprite(); bmp = pnlSprite.Image; break;

            case SaveType.SpriteTileset: objectID = GetSelectedTileset(cbSpriteTilesets); bmp = pnlSpriteTilesets.Image; break;

            case SaveType.SpriteTileMap: objectID = GetSelectedTileMap(cbSpriteTileMaps); bmp = pnlSpriteTileMaps.Image; break;

            case SaveType.Tileset: objectID = GetSelectedTileset(cbTilesets); bmp = pnlTilesets.Image; break;

            case SaveType.TileMap: objectID = GetSelectedTileMap(cbTileMaps); bmp = pnlTileMaps.Image; break;
            }

            // If no object was selected, return
            if (objectID == null)
            {
                ShowMessage("Please select a " + EnumMethods.GetDescription(typeof(SaveType), saveType).ToLower() + " to save.");
                return;
            }

            // Create open file dialog
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                // Set up the open file dialog
                dialog.Filter   = saveAsType == SaveAsType.Binary ? "Uncompressed Binary|*.bin" : saveAsType == SaveAsType.CompressedBinary ? "Compressed Binary|*.bin" : "Image|*.png";
                dialog.Title    = "Save " + save + " " + saveAs + " File";
                dialog.FileName = objectID.Name + saveType.ToString() + saveAsType.ToString();

                // Show dialog, if the user clicks OK
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // Write data to disk, based on save as type
                    switch (saveAsType)
                    {
                    case SaveAsType.Binary: using (BinaryWriter bw = new BinaryWriter(File.Create(dialog.FileName))) { bw.Write(MainForm.RomData.Decompress(objectID.Compression, objectID.DataStart, objectID.Length)); break; }

                    case SaveAsType.CompressedBinary: using (BinaryWriter bw = new BinaryWriter(File.Create(dialog.FileName))) { bw.Write(MainForm.RomData.GetBytes(objectID.DataStart, objectID.Length)); } break;

                    case SaveAsType.Image: if (bmp != null)
                        {
                            bmp.Save(dialog.FileName, ImageFormat.Png);
                        }
                        break;
                    }
                }
            }
        }
示例#19
0
 public string TiposDeUsuario([FromHeader] int IdIdioma)
 {
     return(EnumMethods.ObterTiposDeUsuario(IdIdioma));
 }
示例#20
0
        private static void Main(string[] args)
        {
            DataWorks.FolderPlotsRemote = DataWorks.FolderPlotsRemoteBase = "Results/";

            // technical
            Console.CancelKeyPress += InterruptHandler;

            // cli
            List <string>    codesinit   = new List <string>();
            List <Algorithm> algos       = new List <Algorithm>();
            List <string>    scenarios   = new List <string>();
            bool             doPrecision = true;
            bool             doRuntime   = true;

            CLIParse(args, ref codesinit, ref algos, ref scenarios, ref doPrecision, ref doRuntime);

            if (!(doPrecision || doRuntime))
            {
                Console.WriteLine("Both precision and runtime tests are disabled, no results will be produced");
                Environment.Exit(-1);
            }

            if (codesinit == null || codesinit.Count == 0)
            {
                codesinit = Directory.GetDirectories(DataWorks.FolderData)
                            .Where(x => !x.EndsWith("_.temp"))
                            .Select(x => x.Replace(DataWorks.FolderData, ""))
                            .ToList();
            }

            string[] codes        = codesinit.Distinct().ToArray();
            string[] codesLimited = codes
                                    .Where(c => DataWorks.CountMatrixColumns($"{c}/{c}_normal.txt") > 4)
                                    .ToArray();

            if (algos == null || algos.Count == 0)
            {
                algos = AlgoPack.ListAlgorithms.Where(alg => alg.AlgCode != "meanimp" && alg.AlgCode != "linimp").ToList();
            }

            if (scenarios == null || scenarios.Count == 0)
            {
                scenarios = EnumMethods.AllExperimentScenarios().Select(EnumMethods.ToLongString).ToList();
            }
            AlgoPack.GlobalAlgorithmsLocation = "../../../Algorithms/";

            // verificaiton that all necessary entries are provided

            if (codes == null || codes.Length == 0)
            {
                throw new InvalidProgramException($"Invalid program state: no datasets found in {DataWorks.FolderData} folder");
            }

            AlgoPack.ListAlgorithms = algos.ToArray();

            algos.Remove(AlgoPack.Tkcm);
            algos.Remove(AlgoPack.Spirit);
            algos.Remove(AlgoPack.Ssa);
            AlgoPack.ListAlgorithmsMulticolumn = algos.ToArray();

            AlgoPack.CleanUncollectedResults();
            AlgoPack.EnsureFolderStructure(scenarios);

            void FullRun(bool enablePrecision, bool enableRuntime)
            {
                foreach (string code in codes)
                {
                    foreach (ExperimentScenario es in EnumMethods.AllExperimentScenarios().Where(x => scenarios.Contains(x.ToLongString()) || scenarios.Contains(x.ToShortString())))
                    {
                        if (es.IsLimited() && !codesLimited.Contains(code))
                        {
                            continue;
                        }
                        if (enablePrecision)
                        {
                            TestRoutines.PrecisionTest(ExperimentType.Recovery, es, code);
                        }
                        if (enableRuntime)
                        {
                            TestRoutines.RuntimeTest(ExperimentType.Recovery, es, code);
                        }
                    }
                }
            }

            FullRun(doPrecision, doRuntime);

            //
            // multi-run for 1...N runtime tests and averaging the results from them
            //

            #if false
            {
                for (int i = 1; i <= 3; i++)
                {
                    DataWorks.FolderPlotsRemote = DataWorks.FolderPlotsRemoteBase + i + "/";
                    if (!Directory.Exists(DataWorks.FolderPlotsRemote))
                    {
                        Directory.CreateDirectory(DataWorks.FolderPlotsRemote);
                        AlgoPack.EnsureFolderStructure();
                    }

                    FullRuntime();
                    //FullStreaming();
                }
                DataWorks.FolderPlotsRemote = DataWorks.FolderPlotsRemoteBase;
            }

            //SingularExperiments.AverageRTRuns(codes, codesLimited, 5);
            #endif

            #if false
            {
                string cmptype = "meaninit_vert";

                var sw_prec = new StreamWriter(File.Open($"prec_report_{cmptype}.txt", FileMode.Create));
                var sw_rt   = new StreamWriter(File.Open($"rt_report_{cmptype}.txt", FileMode.Create));

                SingularExperiments.MsePerformanceReport(codes, codesLimited, sw_prec.WriteLine, cmptype);
                SingularExperiments.SSVIterPerformanceReport(codes, codesLimited, sw_rt.WriteLine, cmptype);

                sw_prec.Close();
                sw_rt.Close();
            }
            #endif
            //
            // time series
            //

            #if false
            {
                var data = DataWorks.TimeSeries("BAFU", "*.asc", 3, Utils.Specific.ParseWasserstand, new DateTime(2005, 1, 1), true);
                DataWorks.TimeSeriesMerge(data, "BAFU_total.txt");
            }
            #endif

            FinalSequence();
        }
示例#21
0
        /// <summary>
        /// Loads sprite data
        /// </summary>
        private void LoadData()
        {
            // Load sort types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbSpritesSort, cbPaletteGroupsSort, cbTilesetsSort, cbTileMapsSort, cbSpriteLabSort
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SortType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SortType), (SortType)value)));
                }
            }

            // Load scale types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbSpriteScale, cbTilesetScale, cbSpriteLabScale
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ScaleType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ScaleType), (ScaleType)value)));
                }
            }

            // Load save types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbSave
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SaveType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SaveType), (SaveType)value)));
                }
            }

            // Load save as types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbSaveAs
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SaveAsType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SaveAsType), (SaveAsType)value)));
                }
            }

            // If there is data, load palette and sprite data
            if (_mainForm != null && _mainForm.RomData != null)
            {
                // Load sprites to UI
                trSprites.Nodes.Clear();
                foreach (Sprite sprite in MainForm.RomData.Sprites)
                {
                    TreeNode node = new TreeNode(sprite.Name)
                    {
                        Tag = sprite.ID
                    };
                    trSprites.Nodes.Add(node);
                }

                // Load palette collections to UI
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbPaletteGroups
                })
                {
                    cb.Items.Clear();
                    foreach (PaletteGroup collection in MainForm.RomData.PaletteGroups)
                    {
                        cb.Items.Add(new ObjectID(collection.ID, collection.Name));
                    }
                }

                // Load tilesets to UI
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbTilesets, cbSpriteLabTilesets1, cbSpriteLabTilesets2, cbSpriteLabTilesets3, cbSpriteLabTilesets4, cbSpriteLabTilesets5
                })
                {
                    cb.Items.Clear();
                    foreach (Tileset tileset in MainForm.RomData.Tilesets)
                    {
                        if (tileset.ID != 0)
                        {
                            cb.Items.Add(new ObjectID(tileset.ID, tileset.Name));
                        }
                    }
                }

                // Load tile maps to UI
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbTileMaps, cbSpriteLabTileMaps
                })
                {
                    cb.Items.Clear();
                    foreach (TileMap tileMap in MainForm.RomData.TileMaps)
                    {
                        cb.Items.Add(new ObjectID(tileMap.ID, tileMap.Name));
                    }
                }

                // Set palette grid
                grdPalettes.AutoGenerateColumns = false;
                grdPalettes.DataSource          = MainForm.RomData.GetPalettes();
            }

            // Select first item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbPaletteGroups, cbPaletteGroupsSort, cbSave, cbSaveAs, cbSpriteScale, cbTilesetScale, cbSpriteLabScale
            })
            {
                if (cb.Items.Count > 0)
                {
                    cb.SelectedIndex = 0;
                }
            }

            // Select second item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbSpritesSort, cbPaletteGroupsSort, cbTilesetsSort, cbTileMapsSort, cbSpriteLabSort
            })
            {
                if (cb.Items.Count > 1)
                {
                    cb.SelectedIndex = 1;
                }
            }
        }
示例#22
0
        public void VerifyColorEnumFriendlyValues()
        {
            var EnumsString = EnumMethods.ObterTiposDeUsuario(1);

            Assert.AreEqual("Advogado|Escritor|Escritório|", EnumsString);
        }
示例#23
0
        private static void Main(string[] args)
        {
            // technical
            Console.CancelKeyPress += InterruptHandler;

            string[] codes        = null;
            string[] codesLimited = null;

            List <string> ignoreList = new List <string>();

            List <string> scenarios = new List <string>();

            Dictionary <string, string> config =
                args.Length == 0
                    ? Utils.ReadConfigFile()
                    : Utils.ReadConfigFile(args[0]);

            bool runPrecision = true;
            bool runRuntime   = true;

            foreach (KeyValuePair <string, string> entry in config)
            {
                switch (entry.Key)
                {
                case "PlotsFolder":
                    DataWorks.FolderPlotsRemoteBase = entry.Value.Trim().Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                    DataWorks.FolderPlotsRemote     = DataWorks.FolderPlotsRemoteBase;
                    break;

                case "AlgorithmsLocation":
                    AlgoPack.GlobalAlgorithmsLocation = entry.Value.Trim().Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                    break;

                case "Datasets":
                    codes        = entry.Value.Split(',').Select(c => c.Trim()).ToArray();
                    codesLimited = codes
                                   .Where(c => DataWorks.CountMatrixColumns($"{c}/{c}_normal.txt") > 4)
                                   .ToArray();
                    break;

                case "Scenarios":
                    scenarios.AddRange(entry.Value.Split(',').Select(x => x.Trim().ToLower()));
                    break;

                case "EnableStreaming":
                    EnumMethods.EnableStreaming = Convert.ToBoolean(entry.Value);
                    break;

                case "EnableContinuous":
                    EnumMethods.EnableContinuous = Convert.ToBoolean(entry.Value);
                    break;

                case "EnableBatchMid":
                    EnumMethods.EnableBatchMid = Convert.ToBoolean(entry.Value);
                    break;

                case "EnabledAlgorithms":
                    ignoreList.AddRange(entry.Value.Split(',').Select(x => x.Trim().ToLower()));
                    break;

                case "DisablePrecision":
                    runPrecision = !Convert.ToBoolean(entry.Value);
                    break;

                case "DisableRuntime":
                    runRuntime = !Convert.ToBoolean(entry.Value);
                    break;

                default:
                    Utils.DelayedWarnings.Enqueue($"Warning: unknown config entry with the key {entry.Key}");
                    break;
                }
            }

            // verification that all necessary entries are provided
            if (DataWorks.FolderPlotsRemoteBase == null)
            {
                throw new InvalidProgramException("Invalid config file: plots folder has to be supplied (PlotsFolder=)");
            }

            if (AlgoPack.GlobalAlgorithmsLocation == null)
            {
                throw new InvalidProgramException("Invalid config file: algorithms folder has to be supplied (AlgorithmsLocation=)");
            }

            if (codes == null || codes.Length == 0)
            {
                throw new InvalidProgramException("Invalid config file: datasets are not supplied (Datasets=) or the list is empty");
            }

            AlgoPack.ListAlgorithms            = AlgoPack.ListAlgorithms.Where(x => ignoreList.Contains(x.AlgCode.ToLower())).ToArray();
            AlgoPack.ListAlgorithmsStreaming   = AlgoPack.ListAlgorithms.Where(x => x.IsStreaming).ToArray();
            AlgoPack.ListAlgorithmsMulticolumn = AlgoPack.ListAlgorithms.Where(x => x.IsMulticolumn).ToArray();

            AlgoPack.CleanUncollectedResults();

            List <ExperimentScenario> activeScenarios = new List <ExperimentScenario>();

            foreach (string scen in scenarios)
            {
                bool found = false;
                foreach (ExperimentScenario es in EnumMethods.AllExperimentScenarios())
                {
                    if (scen == es.ToLongString())
                    {
                        found = true;
                        activeScenarios.Add(es);
                    }
                }
                if (!found)
                {
                    throw new InvalidProgramException("Invalid config file: list of scenarios contains entries which are not supported by the testing framework");
                }
            }

            void FullRun(bool enablePrecision, bool enableRuntime)
            {
                foreach (string code in codes)
                {
                    if (EnumMethods.EnableContinuous)
                    {
                        AlgoPack.EnsureFolderStructure(ExperimentType.Continuous, activeScenarios.Where(EnumMethods.IsContinuous).Select(es => es.ToLongString()).ToList());

                        foreach (ExperimentScenario es in activeScenarios.Where(EnumMethods.IsContinuous))
                        {
                            if (es.IsLimited() && !codesLimited.Contains(code))
                            {
                                continue;
                            }
                            if (enablePrecision)
                            {
                                TestRoutines.PrecisionTest(ExperimentType.Continuous, es, code);
                            }
                            if (enableRuntime)
                            {
                                TestRoutines.RuntimeTest(ExperimentType.Continuous, es, code);
                            }
                        }
                    }

                    if (EnumMethods.EnableBatchMid)
                    {
                        AlgoPack.EnsureFolderStructure(ExperimentType.Recovery, activeScenarios.Where(EnumMethods.IsBatchMid).Select(es => es.ToLongString()).ToList());

                        foreach (ExperimentScenario es in activeScenarios.Where(EnumMethods.IsBatchMid))
                        {
                            if (es.IsLimited() && !codesLimited.Contains(code))
                            {
                                continue;
                            }
                            if (enablePrecision)
                            {
                                TestRoutines.PrecisionTest(ExperimentType.Recovery, es, code);
                            }
                            if (enableRuntime)
                            {
                                TestRoutines.RuntimeTest(ExperimentType.Recovery, es, code);
                            }
                        }
                    }

                    if (EnumMethods.EnableStreaming)
                    {
                        AlgoPack.EnsureFolderStructure(ExperimentType.Streaming, activeScenarios.Where(EnumMethods.IsStreaming).Select(es => es.ToLongString()).ToList());

                        foreach (ExperimentScenario es in activeScenarios.Where(EnumMethods.IsStreaming))
                        {
                            if (es.IsLimited() && !codesLimited.Contains(code))
                            {
                                continue;
                            }
                            if (enablePrecision)
                            {
                                TestRoutines.PrecisionTest(ExperimentType.Streaming, es, code);
                            }
                            if (enableRuntime)
                            {
                                TestRoutines.RuntimeTest(ExperimentType.Streaming, es, code);
                            }
                        }
                    }
                }
            }

            void FullRuntimeReplot() //service method
            {
                if (EnumMethods.EnableContinuous)
                {
                    codes.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Continuous, ExperimentScenario.Missing, c));
                    codes.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Continuous, ExperimentScenario.Length, c));
                    codesLimited.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Continuous, ExperimentScenario.Columns, c));
                }

                codes.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Recovery, ExperimentScenario.Missing, c));
                codes.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Recovery, ExperimentScenario.Length, c));
                codesLimited.ForEach(c => TestRoutines.RuntimeTestReplot(ExperimentType.Recovery, ExperimentScenario.Columns, c));
            }

            FullRun(runPrecision, runRuntime);

            FinalSequence();
        }
示例#24
0
        /// <summary>
        /// Load techniques and skills data
        /// </summary>
        private void LoadData()
        {
            // Load sort type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbTechniquesSort, cbCharacterSkillsSort, cbEnemySkillsSort
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(SortType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(SortType), (SortType)value)));
                }
            }

            // Load element type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterTechniqueElement, cbCharacterSkillElement, cbEnemySkillElement
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ElementType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ElementType), (ElementType)value)));
                }
            }

            // Load target type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterTechniqueTarget, cbCharacterSkillTarget, cbEnemySkillTarget
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(EffectTargetType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EffectTargetType), (EffectTargetType)value)));
                }
            }

            // Load effect type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterTechniqueEffect, cbCharacterSkillEffect, cbEnemySkillEffect
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(EffectType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EffectType), (EffectType)value)));
                }
            }

            // Load effect area type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterTechniqueEffectArea, cbCharacterSkillEffectArea
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(EffectAreaType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EffectAreaType), (EffectAreaType)value)));
                }
            }

            // Load effect stat type drop downs
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbCharacterSkillAtkStat, cbCharacterTechniqueTargetDefenseStat, cbCharacterSkillTargetDefenseStat, cbEnemySkillAtkStat, cbEnemySkillTargetDefenseStat
            })
            {
                int i = 0;
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(EffectStatType)))
                {
                    if ((i <= 7 || value == (int)EffectStatType.DisabledIfSealed) && cb != cbCharacterSkillAtkStat)
                    {
                        cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EffectStatType), (EffectStatType)value)));
                    }

                    if (cb == cbCharacterSkillAtkStat && value != (int)EffectStatType.DisabledIfSealed)
                    {
                        cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(EffectStatType), (EffectStatType)value)));
                    }
                    i++;
                }
            }

            if (HasData)
            {
                // Load character techniques drop down
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbCharacterTechniques
                })
                {
                    cb.Items.Clear();
                    foreach (Technique technique in MainForm.RomData.Techniques)
                    {
                        cb.Items.Add(new ObjectID(technique.ID, technique.CustomName));
                    }
                }

                // Load character skills drop down
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbCharacterSkills
                })
                {
                    cb.Items.Clear();
                    foreach (Skill skill in MainForm.RomData.CharacterSkills)
                    {
                        cb.Items.Add(new ObjectID(skill.ID, skill.CustomName));
                    }
                }

                // Load action drop drowns with enemy skills
                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbEnemySkills
                })
                {
                    cb.Items.Clear();
                    foreach (Skill skill in MainForm.RomData.EnemySkills)
                    {
                        cb.Items.Add(new ObjectID(skill.ID, skill.CustomName));
                    }
                }

                foreach (ComboBox cb in new List <ComboBox>()
                {
                    cbCharacterTechniques, cbCharacterSkills, cbEnemySkills
                })
                {
                    cb.SelectedIndex = 0;
                }
            }

            // Select Ascending
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbTechniquesSort, cbCharacterSkillsSort, cbEnemySkillsSort
            })
            {
                cb.SelectedIndex = 1;
            }
        }
示例#25
0
        /// <summary>
        /// Loads item data
        /// </summary>
        private void LoadData()
        {
            // Load item character filter types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemCharacterFilter
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ItemCharacterFilterType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ItemCharacterFilterType), (ItemCharacterFilterType)value)));
                }
            }

            // Load item type filter types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemTypeFilter
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ItemTypeFilterType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ItemTypeFilterType), (ItemTypeFilterType)value)));
                }
            }

            // Load item element filter types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemElementFilter
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ItemElementFilterType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ItemElementFilterType), (ItemElementFilterType)value)));
                }
            }

            // Load item effect filter types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemEffectFilter
            })
            {
                cb.Items.Clear();
                foreach (int value in Enum.GetValues(typeof(ItemEffectFilterType)))
                {
                    cb.Items.Add(new ObjectID(value, EnumMethods.GetDescription(typeof(ItemEffectFilterType), (ItemEffectFilterType)value)));
                }
            }

            // Load sort types to UI
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemsSort
            })
            {
                cb.Items.Clear();
                foreach (object value in Enum.GetValues(typeof(SortType)))
                {
                    cb.Items.Add(value.ToString());
                }
            }

            // If there is data, add items to item grid
            if (HasData)
            {
                BindingSource source = new BindingSource {
                    DataSource = MainForm.RomData.Items
                };
                grdItems.DataSource = source;
                grdItems.Rows.RemoveAt(0);
            }

            // Select second item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemsSort
            })
            {
                if (cb.Items.Count > 1)
                {
                    cb.SelectedIndex = 1;
                }
            }

            // Select first item
            foreach (ComboBox cb in new List <ComboBox>()
            {
                cbItemCharacterFilter, cbItemTypeFilter, cbItemElementFilter, cbItemEffectFilter
            })
            {
                if (cb.Items.Count > 0)
                {
                    cb.SelectedIndex = 0;
                }
            }
        }