Example #1
0
        public void FinishedLoadCategory(List<Category> list)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DeCallbackCategoryList(FinishedLoadCategory), list);
                return;
            }

            //adding All to search in all category
            Category all = new Category();
            all.id = 0;
            all.name = "All";
            list.Insert(0, all);

            //adding a favorite category, this is kind of special category.
            Category fav = new Category();
            fav.id = -1;
            fav.name = "Favorites";
            list.Insert(1, fav);

            comboBoxCategory.Items.Clear();
            categories.Clear();
            foreach (Category i in list)
            {
                categories.Add(i);
                comboBoxCategory.Items.Add(i.name);
            }
            comboBoxCategory.SelectedIndex = 0;
            is_get_category = true;
            EnableSearch();
        }
        static void Main(string[] args)
        {
            Console.Title = "管理学生信息";

            List<Student> students = new List<Student>();              //学生信息列表
            students.Add(new Student("张三", 20, "男", 20120001));     //添加学生"张三"的信息
            students.Add(new Student("李四", 19, "女", 20120002));     //添加学生"李四"的信息
            students.Add(new Student("王五", 18, "男", 20120003));     //添加学生"王五"的信息
            students.Add(new Student("赵六", 21, "女", 20120004));     //添加学生"赵六"的信息
            Console.WriteLine("遍历学生信息表,输出学生信息:");
            foreach (Student s in students)
            {
            Console.WriteLine("{0}\t{1}岁\t{2}生\t{3}号", s.Name, s.Age, s.Sex, s.ID);
            }

            Console.WriteLine("删除学生“李四”的信息!");
            students.RemoveAt(1);
            Console.WriteLine("在表头插入学生“孙七”的信息!");
            students.Insert(0, new Student("孙七", 22, "男", 20120005));
            Console.WriteLine("在表尾插入学生“周八”信息!");
            students.Insert(4, new Student("周八", 17, "女", 20120006));
            Console.WriteLine("重新遍历学生信息表,输出学生信息:");
            foreach (Student s in students)
            {
            Console.WriteLine("{0}\t{1}岁\t{2}生\t{3}号", s.Name, s.Age, s.Sex, s.ID);
            }

            Console.ReadLine();
        }
Example #3
0
 public override void Initialize(ContentManager content, WaveManager manager)
 {
     infiniteAmmoModeOn = true;
     infiniteFoodModeOn = true;
     isTutorialWave = true;
     waveSize = wavesize;
     spawnTimings = new List<double>(waveSize);
     enemiesToSpawn = new List<Enemy>(waveSize);
     lootList = new List<Loot>(waveSize);
     enemiesToSpawn.Insert(0, new Enemy1());
     spawnTimings.Insert(0, baseTime + 0 * interval);
     enemiesToSpawn.Insert(1, new Enemy1());
     spawnTimings.Insert(1, 2 * interval);
     enemiesToSpawn.Insert(2, new Enemy1());
     spawnTimings.Insert(2, 3.5 * interval);
     enemiesToSpawn.Insert(3, new Enemy1());
     spawnTimings.Insert(3, 5 * interval);
     enemiesToSpawn.Insert(waveSize - 1, new HeadShotTest());
     spawnTimings.Insert(waveSize - 1, baseTime + 6.5 * interval);
     lootList.Add(new SniperAmmoLoot(2, content));
     lootList.Add(new SniperAmmoLoot(2, content));
     //lootList.Add(new FoodLoot(1, content));
     lootList.Add(new MachineGunAmmoLoot(5, content));
     lootList.Add(new SniperAmmoLoot(2, content));
     lootList.Add(new MachineGunAmmoLoot(5, content));
     openingTextFilename = "Content//Text//TutorialWave1Open.txt";
     layout = new FoxholeLayout();
     helpTexture = content.Load<Texture2D>("Graphics\\Tutorial1Help");
     helpTextureController = content.Load<Texture2D>("Graphics\\Tutorial1HelpController");
     base.Initialize(content, manager);
 }
        private IList<IMenuModel> SortByAfter(IList<IMenuModel> menuModels)
        {
            var sorted = new List<IMenuModel>(menuModels);

            foreach (IMenuModel model in menuModels)
            {
                int newIndex =
                    sorted.FindIndex(m => m.Name.Equals(model.After, StringComparison.InvariantCultureIgnoreCase));

                if (newIndex < 0) continue;

                int currentIndex = sorted.IndexOf(model);

                if (currentIndex < newIndex)
                {
                    sorted.Remove(model);
                    sorted.Insert(newIndex, model);
                }
                else
                {
                    sorted.Remove(model);
                    sorted.Insert(newIndex + 1, model);
                }
            }

            return sorted;
        }
Example #5
0
    static void Main()
    {
        // Create a List called Deck
        List<int> Deck = new List<int>();

        for (int iCards = 0; iCards < 52; iCards++)
        {
            Deck.Insert(0, iCards + 1); //PUSH
        }

        //Shuffle Deck
        // Declare an Instance of Random Class outside the Loop

        Random MyRandNumb = new Random() ;
           int iSwap = 0;

        foreach (int card in Deck )
        {
        // Generate Random number from 1 to CardNum - 1
        int RandomCard = MyRandNumb.Next(1, 52) ;
            iSwap = Deck[RandomCard];
            Deck.RemoveAt(RandomCard);
        Deck.Insert(0, iSwap);
        }

        Console.WriteLine("Count: {0}", Deck.Count);

        // Print them to the screen
        foreach (int card in Deck )
        {
            Console.WriteLine(card);
        }
    }
Example #6
0
        public static string[] GetComments(IToken[] FileTokens, List<IToken> alreadyTakenComments, int lastTokenLineNo,
            int prevTokenIndex, int nextTokenIndex, bool acn = false)
        {
            List<string> comments = new List<string>();
            int WS = acn ? acnLexer.WS : asn1Lexer.WS;
            int COMMENT = acn ? acnLexer.COMMENT : asn1Lexer.COMMENT;
            int COMMENT2 = acn ? acnLexer.COMMENT2 : asn1Lexer.COMMENT2;

            //first see if there comments on the same line

            while (nextTokenIndex >= 0 && nextTokenIndex < FileTokens.Length)
            {
                IToken t = FileTokens[nextTokenIndex++];
                if (alreadyTakenComments.Contains(t))
                {
                    break;
                }
                if (t.Line != lastTokenLineNo)
                {
                    break;
                }
                if (t.Type == WS)
                {
                    continue;
                }
                else if (t.Type == COMMENT || t.Type == COMMENT2)
                {
                        comments.Insert(0, t.Text);
                        alreadyTakenComments.Add(t);
                }
                else
                {
                    break;
                }

            }

            //if no comments were found at the same line, then look back (above)
            if (comments.Count == 0)
            {

                while (prevTokenIndex >= 0 && prevTokenIndex < FileTokens.Length)
                {
                    IToken t = FileTokens[prevTokenIndex--];
                    if (alreadyTakenComments.Contains(t))
                        break;
                    if (t.Type == WS)
                        continue;
                    else if (t.Type == COMMENT || t.Type == COMMENT2)
                    {
                            comments.Insert(0, t.Text);
                            alreadyTakenComments.Add(t);
                    }
                    else
                        break;
                }
            }

            return comments.ToArray();
        }
Example #7
0
        public static string FromBase10(int number, int targetBase)
        {
            if (targetBase < 2 || targetBase > 36) return "";
            if (targetBase == 10) return number.ToString();

            int n = targetBase;
            int q = number;
            int r;
            List<string> rtn = new List<string>();

            while (q >= n)
            {

                r = q % n;
                q = q / n;

                if (r < 10)
                    rtn.Insert(0, r.ToString());
                else
                    rtn.Insert(0, Convert.ToChar(r + 55).ToString());
            }

            if (q < 10)
                rtn.Insert(0, q.ToString());
            else
                rtn.Insert(0, Convert.ToChar(q + 55).ToString());

            return string.Join("", rtn);
        }
 static List<int> Check(List<int> num, int digit, List<int> paths)
 {
     int i=0;
     // - FOR EACH PATH OF DIGIT, CHECK LOCATION IN FINAL NUMBER
     for (i=0;i<paths.Count;i++)
     {
     int path = paths[i];
     // - IF PATH DIGIT IS NOT IN FINAL, ADD AT POS 0
     if (num.IndexOf(path) == -1)
     {
         num.Insert(0,path);
     }
     // - IF DIGIT IS NOT IN FINAL, ADD BEFORE PATH DIGIT
     if (num.IndexOf(digit) == -1)
     {
         num.Insert(num.IndexOf(path),digit);
     }
     // - IF DIGIT COMES AFTER PATH DIGIT, REMOVE DIGIT AND PUT IT BEFORE PATH
     else if (num.IndexOf(digit) > num.IndexOf(path))
     {
         num.RemoveAt(num.IndexOf(digit));
         num.Insert(num.IndexOf(path),digit);
     }
     // - OTHERWISE NUMBER CHECKS OUT
     else if (num.IndexOf(digit) < num.IndexOf(path))
     {
         continue;
     }
     }
     return num;
 }
Example #9
0
 private static string GetBSAList(bool p_booInsertAI)
 {
   var bsas =
     new List<string>(
       NativeMethods.GetPrivateProfileString("Archive", "SArchiveList", null,
                                             ((FalloutNewVegasGameMode.SettingsFilesSet)
                                               Program.GameMode.SettingsFiles).FOIniPath).Split(new[]
                                               {
                                                 ','
                                               }, StringSplitOptions.RemoveEmptyEntries));
   var lstNewBSAs = new List<string>();
   for (var i = 0; i < bsas.Count; i++)
   {
     bsas[i] = bsas[i].Trim(' ');
     if (bsas[i] == OldAiBsa)
     {
       continue;
     }
     if (bsas[i].Contains("Misc"))
     {
       lstNewBSAs.Insert(0, bsas[i]);
     }
     else if (bsas[i] != AiBsa)
     {
       lstNewBSAs.Add(bsas[i]);
     }
   }
   if (p_booInsertAI)
   {
     lstNewBSAs.Insert(0, AiBsa);
   }
   return string.Join(", ", lstNewBSAs.ToArray());
 }
Example #10
0
        public static bool RunTest( string inputRom, string testFile,  string cmdLineArgs)
        {
            bool ret = false;
            String[] args = cmdLineArgs.Split(new char[] { ' ' });
            List<String> listArgs = new List<String>(args);
            listArgs.Insert(0, inputRom);
            listArgs.Insert(1, testFile);
            args = listArgs.ToArray();

            MainClass.RunMain(args);
            String testFileContents = File.ReadAllText(testFile);
            if (String.Compare(testFileContents, MainClass.TestString) != 0)
            {
                //fail
                File.WriteAllText("output.txt", testFileContents);
                String argLine = String.Concat(testFile, " output.txt");
                Process.Start(diffTool, argLine);
            }
            else
            {
                ret = true;
            }

            return ret;
        }
        private static List<bool> CreateLSList(List<int> S)
        {
            // L/S list where S is true and L is false
            List<bool> t = new List<bool>();

            for (int i = S.Count - 1; i >= 0; i--)
            {
                if (i == S.Count - 1)
                {
                    t.Insert(0, true); //insert S for last charachter
                }
                else
                {
                    if (S[i] > S[i + 1])
                    {
                        t.Insert(0, false); //insert L for S[i] > S[i + 1]
                    }
                    else if (S[i] < S[i + 1])
                    {
                        t.Insert(0, true); //insert S for S[i] < S[i + 1]
                    }
                    else
                    {
                        t.Insert(0, t[0]); //copy value if S[i] == S[i + 1]
                    }
                }
            }

            return t;
        }
Example #12
0
        public static void GetVariations(List<int> toSearch, int Left, int LengthToBuild)
        {
            // If This is the last element in the squence
            // get all possible variations and return
            if (LengthToBuild==1)
            {
                // Step 1: Print Variations
                for (int position = Left; position < toSearch.Count; position++)
                {
                    // Step 1: Print Current
                    PrintCurrentVariation(toSearch, Left);

                    // Step 2: Shuffle
                    toSearch.Insert(Left, toSearch[toSearch.Count - 1]);
                    toSearch.RemoveAt(toSearch.Count - 1);
                }
                // Step 2: Go back up
                return;
            }

            // OtherWise pick the next element in the sequence
            // and Send down
            for (int currElement = 0; currElement < toSearch.Count; currElement++)
            {
                // Step 1: Get Variatopms
                GetVariations(toSearch, Left + 1, LengthToBuild-1);

                // Step 2: Shuffle
                // last element goes first
                toSearch.Insert(Left, toSearch[toSearch.Count - 1]);
                toSearch.RemoveAt(toSearch.Count - 1);
            }

            return;
        }
Example #13
0
 private void Load_Load(object sender, EventArgs e)
 {
     newWidth.Text = ApplicationSettings.LastMapSize.Width.ToString();
     newHeight.Text = ApplicationSettings.LastMapSize.Height.ToString();
     if (multiBoard.Boards.Count == 0)
     {
         newTab.Checked = true;
         newTab.Enabled = false;
     }
     else
         newTab.Checked = ApplicationSettings.newTab;
     List<string> listBoxObjects = new List<string>();
     foreach (DictionaryEntry map in Program.InfoManager.Maps)
         listBoxObjects.Add((string)map.Key + " - " + (string)map.Value);
     listBoxObjects.Sort();
     listBoxObjects.Insert(0, "CashShopPreview");
     listBoxObjects.Insert(0, "MapLogin");
     listBoxObjects.Insert(0, "MapLogin1");
     foreach (string map in listBoxObjects)
         mapNamesBox.Items.Add(map);
     switch (ApplicationSettings.lastRadioIndex)
     {
         case 0:
             NewSelect.Checked = true;
             break;
         case 1:
             XMLSelect.Checked = true;
             break;
         case 2:
             WZSelect.Checked = true;
             break;
     }
 }
 public static ICollection<string> GetSensorList()
 {
     var sensors = new List<string>(WebSocketEventProcessor.g_devices.Keys);
     sensors.Insert(0, "All");
     sensors.Insert(0, "None");
     return sensors;
 }
        protected List<SelectListItem> GetTaxDisplayTypesList(CustomerRoleModel model)
        {
            var list = new List<SelectListItem>();

            if (model.TaxDisplayType.HasValue)
            {
                list.Insert(0, new SelectListItem()
                {
                    Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.IncludingTax"),
                    Value = "0",
                    Selected = (TaxDisplayType)model.TaxDisplayType == TaxDisplayType.IncludingTax
                });
                list.Insert(1, new SelectListItem()
                {
                    Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.ExcludingTax"),
                    Value = "10",
                    Selected = (TaxDisplayType)model.TaxDisplayType == TaxDisplayType.ExcludingTax
                });
            }
            else
            {
                list.Insert(0, new SelectListItem() { Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.IncludingTax"), Value = "0" });
                list.Insert(1, new SelectListItem() { Text = _localizationService.GetResource("Enums.Smartstore.Core.Domain.Tax.TaxDisplayType.ExcludingTax"), Value = "10" });
            }

            return list;
        }
 public void BindSelected()
 {
     var selectedList = Position.GetPositionList()
         .Where(p => this.SelectedList.Contains(p.Id))
         .ToList();
     var fullNameList = new List<string>();
     foreach (Position postion in selectedList)
     {
         if (postion == null) continue;
         List<string> buffer = new List<string>();
         buffer.Insert(0, postion.Name);
         var org = postion.GetOrganization();
         if (org != null)
         {
             buffer.Insert(0, org.Name);
             var parentOrgList = org.DeepParentList;
             if (parentOrgList != null)
             {
                 buffer.InsertRange(0, parentOrgList.Select(o2 => o2.Name));
             }
         }
         fullNameList.Add(string.Join("/", buffer.ToArray()));
     }
     this.selectedDataList.DataSource = fullNameList;
     this.selectedDataList.DataBind();
     this.PageEngine.UpdateControlRender(this.selectedDataListArea);
 }
Example #17
0
        private void Callback(object obj)
        {
            if (sideVar >= 0)
            {
                ResetFilter ();
                List<GVar> _vars = new List<GVar>();

                if (sideVarLocation == VariableLocation.Global)
                {
                    _vars = vars;
                }
                else
                {
                    _vars = KickStarter.localVariables.localVars;
                }
                GVar tempVar = _vars[sideVar];

                switch (obj.ToString ())
                {
                case "Insert after":
                    Undo.RecordObject (this, "Insert variable");
                    _vars.Insert (sideVar+1, new GVar (GetIDArray (_vars)));
                    DeactivateAllVars ();
                    break;

                case "Delete":
                    Undo.RecordObject (this, "Delete variable");
                    _vars.RemoveAt (sideVar);
                    DeactivateAllVars ();
                    break;

                case "Move up":
                    Undo.RecordObject (this, "Move variable up");
                    _vars.RemoveAt (sideVar);
                    _vars.Insert (sideVar-1, tempVar);
                    break;

                case "Move down":
                    Undo.RecordObject (this, "Move variable down");
                    _vars.RemoveAt (sideVar);
                    _vars.Insert (sideVar+1, tempVar);
                    break;
                }
            }

            sideVar = -1;

            if (sideVarLocation == AC.VariableLocation.Global)
            {
                EditorUtility.SetDirty (this);
                AssetDatabase.SaveAssets ();
            }
            else
            {
                if (KickStarter.localVariables)
                {
                    EditorUtility.SetDirty (KickStarter.localVariables);
                }
            }
        }
Example #18
0
        /// <summary>
        /// Gets the collection of the property info for the specified target object.
        /// </summary>
        /// <param name="target">Object to get default value from.</param>
        /// <returns>Collection of values for type of property, using the value on the target object 
        /// for this property as default value.</returns>
        public List<ValueItem> GetCollection(object target, IEnumerable items = null)
        {
            var enumValue = target as Enum;
            if (enumValue == null)
            {
                return new List<ValueItem>();
            }

            var values = items ?? Enum.GetValues(enumValue.GetType());

            var collection = new List<ValueItem>();

            // Note: do not convert the foreach to a Linq expression, the list will not be ordered as defined anymore.
            foreach (Enum value in values)
            {
                if (!value.IsExcluded())
                {
                    var item = ValueItem.New(value.GetDescription(), value.ToString(), IsEqual(value, enumValue));

                    // Always insert empty item at index 0
                    if(IsEmpty(value))
                        collection.Insert(0,item);
                    else
                        collection.Add(item);
                }
            }

            // if current value is not in list, add it
            if (!IsEmpty(enumValue) && !collection.Any(vi => vi.Selected))
            {
                collection.Insert(0, ValueItem.New(string.Format("<{0}>", enumValue.GetDescription()), enumValue.ToString(), true));
            }

            return collection;
        }
Example #19
0
 public static string[] Split(string words, StringSplitOptions splitOptions, bool splitOnCaseDifference)
 {
     if (string.IsNullOrEmpty(words))
     {
         return new string[] { words };
     }
     string[] initial = words.Split(_separators, splitOptions);
     List<string> final = new List<string>();
     int finalIndex = 0;
     for (int i = 0; i < initial.Length; i++)
     {
         StringBuilder sb = new StringBuilder();
         string w = initial[i];
         bool isUpper = char.IsUpper(w[0]);
         sb.Append(w[0]);
         for (int c = 1; c < w.Length; c++)
         {
             if (splitOnCaseDifference && char.IsUpper(w[c]))
             {
                 final.Insert(finalIndex++, sb.ToString());
                 sb.Clear();
             }
             sb.Append(w[c]);
         }
         if (sb.Length > 0)
         {
             final.Insert(finalIndex++, sb.ToString());
             sb.Clear();
         }
     }
     return final.ToArray();
 }
Example #20
0
        public async Task<IHttpActionResult> Waypoints(int id)
        {
            Mission mission = await db.Missions.FindAsync(id);
            if (mission == null)
            {
                return BadRequest();
            }
            var wps = mission.Waypoints;
            List<Waypoint> wpsInOrder = new List<Waypoint>();
            if (wps.Count == 0)
            {
                return Ok(wpsInOrder.AsQueryable());
            }
            var activeWps = from wp in mission.Waypoints
                            where wp.IsActive
                            select wp;
            var tail = activeWps.First(wp => wp.NextWaypoint == null && wp.IsActive);
            wpsInOrder.Add(tail);
            foreach (var wp in activeWps)
            {
                if (wp.Id == tail.Id)
                {
                    //This is already in the list we don't want to insert it.
                    continue;
                }
                var next = wp.NextWaypoint;
                int index = next != null ? wpsInOrder.FindIndex(n => n.Id == next.Id) : -1;
                if (index == -1)
                {
                    //The next waypoint of this waypoint is not in this list, just insert it behind the last waypoint.
                    int len = wpsInOrder.Count;
                    wpsInOrder.Insert(len - 1, wp);
                }
                else
                {
                    //Insert the waypoint behind its next waypoint.
                    wpsInOrder.Insert(index, wp);
                }

            }

            var diffType = from wp in wpsInOrder.AsQueryable()
                           select new
                           {
                               MissionId = wp.MissionId,
                               NextWaypointId = wp.NextWaypointId,
                               Latitude = wp.Latitude,
                               Longitude = wp.Longitude,
                               Altitude = wp.Altitude,
                               IsActive = wp.IsActive,
                               Id = wp.Id,
                               TimeCompleted = wp.TimeCompleted,
                               WaypointName = wp.WaypointName,
                               Action = wp.Action,
                               GeneratedBy = wp.GeneratedBy,
                           };


            return Ok(diffType);
        }
        public static IList<IList<int>> LevelOrderBottom(TreeNode root)
        {
            if(root == null) return new List<IList<int>>();

            List<IList<int>> result = new List<IList<int>>();
            List<int> level = new List<int>();
            var queue = new Queue<NodeWithHeight>();
            int height = 0;
            var temp = new NodeWithHeight(root,height);
            queue.Enqueue(temp);
            while(queue.Count != 0){
                temp = queue.Dequeue();
                if (temp.Height > height)
                {
                    result.Insert(0, level);
                    height = temp.Height;
                    level = new List<int>();
                    level.Add(temp.Node.val);
                }
                else
                    level.Add(temp.Node.val);
                if (temp.Node.left != null)
                    queue.Enqueue(new NodeWithHeight(temp.Node.left, temp.Height + 1));
                if (temp.Node.right != null)
                    queue.Enqueue(new NodeWithHeight(temp.Node.right, temp.Height + 1));
            }
            if (level.Count != 0)
                result.Insert(0, level);
            return result;
        }
Example #22
0
        public String doacao_CheckInDoacao(int userId, int idDoacao, int idSolicitacao, int idHemo)
        {
            Doacao doacao = new Doacao();
            Solicitacoes sol = new Solicitacoes();

            doacao.idDoacao         = idDoacao;
            doacao.usuarioDoador    = userId;
            doacao.idSolicitacao    = idSolicitacao;
            doacao.idHemocentro     = idHemo;
            sol.codDoacao           = idDoacao;

            List<Boolean> json = new List<Boolean>();
            JavaScriptSerializer jsonClient = new JavaScriptSerializer();
            NotificacaoPush push = new NotificacaoPush();

            if (doacao.checkInDonation())
            {
                push.pushNotificacao(sol.getUsuarioSolicitador(), "Nova doação efetuada. Parabéns! <3");
                json.Insert(0, true);
            }
            else
            {
                push.pushNotificacao(userId, "Check-In efetuado fora da área do hemocentro.");
                json.Insert(0, false);
            }

            return jsonClient.Serialize(json);
        }
Example #23
0
 public override void Initialize(ContentManager content, WaveManager manager)
 {
     infiniteAmmoModeOn = false;
     infiniteFoodModeOn = false;
     isTutorialWave = false;
     waveSize = wavesize;
     spawnTimings = new List<double>(waveSize);
     enemiesToSpawn = new List<Enemy>(waveSize);
     lootList = new List<Loot>(waveSize);
     for (int i = 0; i < waveSize; i++)
     {
         if (i % 4 == 0) enemiesToSpawn.Insert(i, new HeadShotTest());
         else enemiesToSpawn.Insert(i, new Enemy1());
         spawnTimings.Insert(i, baseTime + i * interval);
     }
     lootList.Add(new SniperAmmoLoot(2, content));
     lootList.Add(new FoodLoot(1, content));
     lootList.Add(new MachineGunAmmoLoot(10, content));
     lootList.Add(new FoodLoot(1, content));
     lootList.Add(new MachineGunAmmoLoot(4, content));
     lootList.Add(new SniperAmmoLoot(4, content));
     lootList.Add(new MachineGunAmmoLoot(6, content));
     lootList.Add(new FoodLoot(1, content));
     lootList.Add(new SniperAmmoLoot(3, content));
     lootList.Add(new SniperAmmoLoot(1, content));
     openingTextFilename = "Content//Text//Wave2Open.txt";
     layout = new TowerLayout();
     base.Initialize(content, manager);
 }
Example #24
0
 /// <summary>
 /// Helper method to return the visibility options as selecte list
 /// </summary>
 /// <returns>required slect list.</returns>
 public static SelectList GetVisibilityList()
 {
     List<SelectListItem> listItems = new List<SelectListItem>();
     listItems.Insert(0, new SelectListItem() { Value = "2", Text = "Visible to Admin" });
     listItems.Insert(1, new SelectListItem() { Value = "1", Text = "Visible to All" });
     return new SelectList((IEnumerable<SelectListItem>)listItems, "Value", "Text");
 }
        public static List<FortData> Optimize(FortData[] pokeStops, LatLong latlng, GMapOverlay routeOverlay)
        {
            List<FortData> optimizedRoute = new List<FortData>(pokeStops);

            // NN
            FortData NN = FindNN(optimizedRoute, latlng.Latitude, latlng.Longitude);
            optimizedRoute.Remove(NN);
            optimizedRoute.Insert(0, NN);
            for (int i = 1; i < pokeStops.Length; i++)
            {
                NN = FindNN(optimizedRoute.Skip(i), NN.Latitude, NN.Longitude);
                optimizedRoute.Remove(NN);
                optimizedRoute.Insert(i, NN);
                Visualize(optimizedRoute, routeOverlay);
            }

            // 2-Opt
            bool isOptimized;
            do
            {
                optimizedRoute = Optimize2Opt(optimizedRoute, out isOptimized);
                Visualize(optimizedRoute, routeOverlay);
            }
            while (isOptimized);

            return optimizedRoute;
        }
Example #26
0
        public string Insert(string template, string tag, string value)
        {
            var startTag = "<" + tag + ">";
              var startPosition = template.IndexOf (startTag);
              startPosition += startTag.Length;

              var endPosition = template.IndexOf ("// </" + tag + ">");
              endPosition -= Environment.NewLine.Length;

              var length = endPosition - startPosition;
              var innerContent = template.Substring (startPosition, length);
              innerContent = innerContent.Trim ();

              var chars = new List<char>(template.ToCharArray());

              for (int i = endPosition; i > startPosition; i--) {
            var c = chars [i];
            chars.RemoveAt (i);
              }

              var position = startPosition;
              chars.Insert (position, '\n');
              position++;
              foreach (var c in value.ToCharArray()) {
            chars.Insert(position, c);
            position++;
              }

              return ToString (chars.ToArray());
        }
        internal override List<BuilderExtent> FixExtents(out long totalLength)
        {
            List<BuilderExtent> extents = new List<BuilderExtent>();

            ServerSparseExtentHeader header = DiskImageFile.CreateServerSparseExtentHeader(_content.Length);
            GlobalDirectoryExtent gdExtent = new GlobalDirectoryExtent(header);

            long grainTableStart = (header.GdOffset * Sizes.Sector) + gdExtent.Length;
            long grainTableCoverage = header.NumGTEsPerGT * header.GrainSize * Sizes.Sector;

            foreach (var grainTableRange in StreamExtent.Blocks(_content.Extents, grainTableCoverage))
            {
                for (int i = 0; i < grainTableRange.Count; ++i)
                {
                    long grainTable = grainTableRange.Offset + i;
                    long dataStart = grainTable * grainTableCoverage;
                    GrainTableExtent gtExtent = new GrainTableExtent(grainTableStart, new SubStream(_content, dataStart, Math.Min(grainTableCoverage, _content.Length - dataStart)), header);
                    extents.Add(gtExtent);
                    gdExtent.SetEntry((int)grainTable, (uint)(grainTableStart / Sizes.Sector));

                    grainTableStart += gtExtent.Length;
                }
            }

            extents.Insert(0, gdExtent);

            header.FreeSector = (uint)(grainTableStart / Sizes.Sector);

            byte[] buffer = header.GetBytes();
            extents.Insert(0, new BuilderBufferExtent(0, buffer));

            totalLength = grainTableStart;

            return extents;
        }
        public AppleseedRazorViewEngine()
        {
            var viewLocationFormatsList = new List<string>
            {
                "~/{0}.cshtml",
                "~/{0}.vbhtml",
                "~/Views/{1}/{0}.cshtml",
                "~/Views/{1}/{0}.vbhtml",
                "~/Views/Shared/{0}.cshtml",
                "~/Views/Shared/{0}.vbhtml",
            };

            var masterLocationFormatsList = new List<string>
            {
                "~/{0}.master",
                "~/Shared/{0}.master",
                "~/Views/{1}/{0}.master",
                "~/Views/Shared/{0}.master",
            };

            viewLocationFormatsList.Insert(0, @"~/Portals/_$$/MVCTemplates/{0}.cshtml");
            viewLocationFormatsList.Insert(1, @"~/Portals/_$$/MVCTemplates/{0}.vbhtml");

            ViewLocationFormats = viewLocationFormatsList.ToArray();
            PartialViewLocationFormats = ViewLocationFormats;

            MasterLocationFormats = masterLocationFormatsList.ToArray();
            AreaMasterLocationFormats = MasterLocationFormats;
        }
Example #29
0
        /// <summary>
        /// Process a method declaration for documentation.
        /// </summary>
        /// <param name="symbol">The method in question.</param>
        /// <returns><c>Docs</c> if the method contains any, otherwise <c>null</c>.</returns>
        public static Doc ForMethod(IMethodSymbol symbol)
        {
            var doc = symbol.GetDocumentationCommentXml();
              if (string.IsNullOrEmpty(doc))
              {
            return null;
              }

              var sections = new List<Tuple<int, string, string>>();
              var xdoc = XDocument.Parse(doc).Root;

              ProcessFull(xdoc, sections);
              var cursor = sections.FindIndex(t => t.Item2 == "Summary");
              var paramsSection = ProcessParameters(xdoc, symbol.Parameters.Select(p => p.Name).ToList());
              sections.Insert(cursor + 1, paramsSection);

              var returnElement = xdoc.Element("returns");
              if (returnElement != null)
              {
            var content = ProcessContent(returnElement);
            if (!string.IsNullOrEmpty(content))
            {
              sections.Insert(cursor + 2, Tuple.Create(2, "Return value", $"<p>{content}</p>"));
            }
              }

              var resultString = string.Join("\n", sections.Select(t => $"<h{t.Item1 + 2}>{t.Item2}</h{t.Item1 + 2}>{t.Item3}"));

              return new Doc
              {
            Format = "text/html",
            Data = resultString
              };
        }
Example #30
0
    static List<int> MultiplicateArrayAndDigit(int number, List<int> list)
    {
        List<int> result = new List<int>();
        int res = 0;

        for (int i = 0; i < list.Count; i++)
        {
            int temp = (list[list.Count - i - 1] * number) + res;

            if (i == list.Count - 1)
            {
                result.Insert(0, temp);
                break;
            }

            if (temp < 10)
            {
                result.Insert(0, temp);
                res = 0;
            }
            else
            {
                result.Insert(0, temp % 10);
                res = temp / 10;
            }
        }

        result = ConvertList(result);
        return result;
    }