Exemple #1
0
    public string Execute(string command)
    {
        CommandLog.Push(command);
        string[] roSplitCommand = command.Split(' ');
        string   commandName    = roSplitCommand[0];
        Command  TMP;

        if (Commands.TryGetValue(commandName, out TMP))
        {
            var list = new List <string>(roSplitCommand);
            list.Remove(commandName);
            roSplitCommand = list.ToArray();
            return(TMP.Execute(roSplitCommand));
        }
        else
        {
            return(ErrorCommand);
        }
    }
        // khởi tạo đối tượng môn học và set các thuộc tính cần thiết cho nó
        public Control_Subject(DataRow data)
        {
            InitializeComponent();

            Name = data["Subject Code"].ToString();
            Dock = DockStyle.Top;

            SubjectCode = data["Subject Code"].ToString();
            SubjectName = data["Subject Name"].ToString();
            Information = data["Information"].ToString();
            Lecturer = data["Lecturer"].ToString();
            Credits = data["Credits"].ToString();

            DateTime TMP;
            TMP = DateTime.Parse(data["Start Date"].ToString());
            StartDate = TMP.ToString("d");
            TMP = DateTime.Parse(data["End Date"].ToString());
            EndDate = TMP.ToString("d");

            label1.Text = data["Subject Name"].ToString();
            label2.Text = data["Lecturer"].ToString();
        }
        public static void LoadListFromINI(MapTheater TheaterData, bool arg)
        {
            String IniName = String.Format("{0}MD.INI", TheaterData.mixName);

            var INIStream = FileSystem.LoadFile(IniName);
            var isoINI    = new INI(INIStream);

            int negative = -1;

            foreach (var lookup in TilesetIndices)
            {
                isoINI.GetInteger("General", lookup.Value.Name, out lookup.Value.TilesetIndex, negative);
            }

            int tsetIdx = 0;

            while (true)
            {
                String TilesetSection = String.Format("TileSet{0:d4}", tsetIdx);
                if (!isoINI.SectionExists(TilesetSection))
                {
                    break;
                }
                var tsCfg = new TilesetConfig()
                {
                    TilesInSet = -1
                };
                isoINI.GetInteger(TilesetSection, "TilesInSet", out tsCfg.TilesInSet, negative);
                if (tsCfg.TilesInSet == -1)
                {
                    break;
                }

                foreach (var lookup in TilesetIndices)
                {
                    if (tsetIdx == lookup.Value.TilesetIndex)
                    {
                        lookup.Value.TileIndex = All.Count;
                    }
                }

                ++tsetIdx;

                isoINI.GetString(TilesetSection, "SetName", out tsCfg.SetName, "No Name");
                isoINI.GetString(TilesetSection, "FileName", out tsCfg.FileName, "TILE");
                isoINI.GetInteger(TilesetSection, "MarbleMadness", out tsCfg.MarbleMadness, 65535);
                isoINI.GetInteger(TilesetSection, "NonMarbleMadness", out tsCfg.NonMarbleMadness, 65535);
                isoINI.GetBool(TilesetSection, "Morphable", out tsCfg.Morphable, false);
                isoINI.GetBool(TilesetSection, "AllowToPlace", out tsCfg.AllowToPlace, true);
                isoINI.GetBool(TilesetSection, "AllowBurrowing", out tsCfg.AllowBurrowing, true);
                isoINI.GetBool(TilesetSection, "AllowTiberium", out tsCfg.AllowTiberium, false);
                isoINI.GetBool(TilesetSection, "RequiredForRMG", out tsCfg.RequiredForRMG, false);
                isoINI.GetInteger(TilesetSection, "ToSnowTheater", out tsCfg.ToSnowTheater, -1);
                isoINI.GetInteger(TilesetSection, "ToTemperateTheater", out tsCfg.ToTemperateTheater, -1);
                isoINI.GetBool(TilesetSection, "ShadowCaster", out tsCfg.ShadowCaster, false);
                if (tsCfg.ShadowCaster)
                {
                    isoINI.GetInteger(TilesetSection, "ShadowTiles", out tsCfg.ShadowTiles, 0);
                }

                for (var i = 1; i <= tsCfg.TilesInSet; ++i)
                {
                    var TileFnameBase = String.Format("{0:s}{1:d2}", tsCfg.FileName, i);

                    var variation            = 0;
                    var exists               = false;
                    IsoTileTypeClass curTile = null;
                    do
                    {
                        var TileFname = String.Format("{0:s}{1:s}.{2:s}", TileFnameBase, GetSuffix(variation), TheaterData.Extension);
                        ++variation;
                        var tileFile = FileSystem.LoadFile(TileFname);
                        if (tileFile == null)
                        {
                            exists = false;
                        }
                        else
                        {
                            var tileVariation = new IsoTileTypeClass()
                            {
                                cfg                = tsCfg,
                                IndexInTileset     = i,
                                AllowBurrowing     = tsCfg.AllowBurrowing,
                                AllowTiberium      = tsCfg.AllowTiberium,
                                AllowToPlace       = tsCfg.AllowToPlace,
                                Morphable          = tsCfg.Morphable,
                                RequiredForRMG     = tsCfg.RequiredForRMG,
                                ToSnowTheater      = tsCfg.ToSnowTheater,
                                ToTemperateTheater = tsCfg.ToTemperateTheater,
                            };
                            try {
                                var tmpVariation = new TMP(tileFile);
                                tileVariation.Tile = tmpVariation;
                                if (curTile == null)
                                {
                                    curTile = tileVariation;
                                }
                                else
                                {
                                    curTile.NextVariation = tileVariation;
                                }
                                exists = true;
                            } catch (ArgumentException) {
                                // bleh, broken file
                            }
                        }
                        if (curTile == null)
                        {
                            Debug.WriteLine("Failed to load tile {0}{1}", TileFname, ".");
                        }
                    } while (exists);

                    All.Add(curTile);
                }
            }
        }
        /// <summary>
        /// solve a TMP problem Solves a TMP problem
        /// </summary>
        /// <exception cref="SolviceRoutingClient.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">TMP problem solve request (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > SolveTMPAsyncWithHttpInfo(TMP body = null)
        {
            var    localVarPath         = "/solve#TMP";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (basicAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SolveTMP", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
 /// <summary>
 /// solve a TMP problem Solves a TMP problem
 /// </summary>
 /// <exception cref="SolviceRoutingClient.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="body">TMP problem solve request (optional)</param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task SolveTMPAsync(TMP body = null)
 {
     await SolveTMPAsyncWithHttpInfo(body);
 }
 /// <summary>
 /// solve a TMP problem Solves a TMP problem
 /// </summary>
 /// <exception cref="SolviceRoutingClient.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="body">TMP problem solve request (optional)</param>
 /// <returns></returns>
 public void SolveTMP(TMP body = null)
 {
     SolveTMPWithHttpInfo(body);
 }