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);
        }
Example #2
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
              };
        }
        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();
        }
        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 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 #6
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);
 }
        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 #8
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");
 }
        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 #10
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 #11
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 #12
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);
        }
        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;
        }
 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 #15
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 #16
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;
        }
        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 #19
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;
    }
Example #20
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 #21
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 #22
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());
        }
Example #23
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);
        }
Example #24
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;
 }
Example #26
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();
        }
 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 #28
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 #29
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 #30
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);
                }
            }
        }
 private void AddLoserToLowerBracket(Side side, string loser)
 {
     if (_lowerBracketParticipants?.Count < GameIndex * 2)
     {
         _lowerBracketParticipants?.Insert(GameIndex, new Participant(loser));
     }
     else
     {
         _lowerBracketParticipants?.Insert(GameIndex * 2, new Participant(loser));
     }
 }
Example #32
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Adds a range. </summary>
        ///
        /// <param name="item"> The object to add to the
        ///                     <see cref="T:System.Collections.Generic.ICollection`1" />. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public void AddRange(T[] item)
        {
            foreach (T thing in item)
            {
                m_innerList?.Insert(FindIndexForSortedInsert(m_innerList, m_comparer, thing), thing);
            }
        }
Example #33
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BlendShapeItems.Clear();
            await Globals.Client.SendCommandWaitAsync(new PipeCommands.GetFaceKeys(), d =>
            {
                var ret = (PipeCommands.ReturnFaceKeys)d;
                Dispatcher.Invoke(() => BlendShapeKeys = ret.Keys);
            });

            BlendShapeKeys?.Insert(0, null);
            await Globals.Client.SendCommandWaitAsync(new PipeCommands.GetViveLipTrackingBlendShape(), d =>
            {
                var ret = (PipeCommands.SetViveLipTrackingBlendShape)d;
                Dispatcher.Invoke(() =>
                {
                    LipShapes = ret.LipShapes;
                    foreach (var key in LipShapes)
                    {
                        BlendShapeItems.Add(new BlendShapeItem {
                            LipShape = key, BlendShape = ret.LipShapesToBlendShapeMap.ContainsKey(key) ? ret.LipShapesToBlendShapeMap[key] : null, BlendShapeKeys = BlendShapeKeys
                        });
                    }
                });
            });

            KeysDataGrid.DataContext = this;
            KeysDataGrid.ItemsSource = BlendShapeItems;
        }
Example #34
0
        // GET: Projects/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var project = await _context.Project.FindAsync(id);

            if (project == null)
            {
                return(NotFound());
            }
            List <SelectListItem> CustomerOptions = await _context.Customer.OrderBy(c => c.LastName).Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.FullName
            }).ToListAsync();

            CustomerOptions?.Insert(0, new SelectListItem {
                Value = "", Text = "Select A Customer", Selected = true
            });

            ViewData["CustomerId"] = CustomerOptions;
            return(View(project));
        }
Example #35
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BlendShapeItems.Clear();
            await Globals.Client.SendCommandWaitAsync(new PipeCommands.GetFaceKeys(), d =>
            {
                var ret = (PipeCommands.ReturnFaceKeys)d;
                Dispatcher.Invoke(() => BlendShapeKeys = ret.Keys);
            });

            BlendShapeKeys?.Insert(0, null);
            await Globals.Client.SendCommandWaitAsync(new PipeCommands.GetMidiCCBlendShape(), d =>
            {
                var ret = (PipeCommands.SetMidiCCBlendShape)d;
                Dispatcher.Invoke(() =>
                {
                    int index = 0;
                    foreach (var key in ret.BlendShapes)
                    {
                        BlendShapeItems.Add(new BlendShapeItem {
                            Index = index++, BlendShape = key, BlendShapeKeys = BlendShapeKeys
                        });
                    }
                });
            });

            KeysDataGrid.DataContext = this;
            KeysDataGrid.ItemsSource = BlendShapeItems;

            await Globals.Client.SendCommandAsync(new PipeCommands.StartKeySend {
            });

            Globals.Client.ReceivedEvent += Client_Received;
        }
Example #36
0
            public List <char> FindPath(char ch)
            {
                if (LeafValue.HasValue)
                {
                    return(ch == LeafValue ? new List <char>() : null);
                }

                List <char> result = Left.FindPath(ch);

                result?.Insert(0, '0');
                if (result != null)
                {
                    return(result);
                }
                result = Right.FindPath(ch);
                result?.Insert(0, '1');
                return(result);
            }
Example #37
0
        public override TypeConverter.StandardValuesCollection GetStandardValuesCore(
            ITypeDescriptorContext context,
            TypeConverter.StandardValuesCollection collection)
        {
            List <CommandBase> commandBaseList = CommandBaseConverter.DiscoverCommands(collection);

            commandBaseList?.Insert(0, (CommandBase)null);
            return(new TypeConverter.StandardValuesCollection((ICollection)commandBaseList));
        }
Example #38
0
 public void SetHost(List <AccountAllocation> listHost, BankAccountDTO bankAccount, ISimpleRepo <GLAccountDTO> glAcctsRepo)
 {
     _list = listHost;
     _bank = bankAccount;
     //todo: use .IncludeCashInBanks()
     _glAccts = glAcctsRepo?.GetAll();
     _glAccts?.Insert(0, GLAccountDTO.CashInBank(_bank));
     UpdateUILists();
 }
Example #39
0
        public new void PlayGame(Func <string, string, string> inputWinner)
        {
            if (RoundBracket == null || GameIndex >= RoundBracket.Count / 2)
            {
                OrganizeLowerBracketRound();
            }

            var leftParticipant  = RoundBracket[GameIndex * 2];
            var rightParticipant = RoundBracket[GameIndex * 2 + 1];
            var game             = new Game(leftParticipant, rightParticipant);

            game.PlayGame(inputWinner, out string winner, out string loser);

            if (_isPlayingLastRound)
            {
                UpperBracketParticipants[GameIndex].SetName(winner);
            }
            else if (_isPlayingUpperBracket)
            {
                UpperBracketParticipants[GameIndex].SetName(winner);
                if (_lowerBracketParticipants?.Count < GameIndex * 2)
                {
                    _lowerBracketParticipants?.Insert(GameIndex, new Participant(loser));
                }
                else
                {
                    _lowerBracketParticipants?.Insert(GameIndex * 2, new Participant(loser));
                }
            }
            else
            {
                _lowerBracketParticipants[GameIndex].SetName(winner);
            }

            GameIndex++;
            BinarySaver.SaveDoubleToBinnary(this);
        }
Example #40
0
        public static List <KeyValuePair <string, string> > AddDefaultValue(this List <KeyValuePair <string, string> > list, bool chooseType = true)
        {
            var name = chooseType
                ? Resource?.Get("Choose") ?? "Choose"
                : Resource?.Get("All") ?? "All";

            if (list?.Any(i => i.Value?.Equals(name, StringComparison.InvariantCultureIgnoreCase) == true) == true)
            {
                return(list);
            }

            list?.Insert(0, new KeyValuePair <string, string>(null, name));

            return(list);
        }
Example #41
0
        // GET: Projects/Create
        public async Task <IActionResult> Create()
        {
            List <SelectListItem> CustomerOptions = await _context.Customer.OrderBy(c => c.LastName).Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.FullName
            }).ToListAsync();

            CustomerOptions?.Insert(0, new SelectListItem {
                Value = "", Text = "Select A Customer", Selected = true
            });

            var today = DateTime.Now.ToString("yyyy-MM-dd");

            ViewData["DefaultDate"] = today;
            ViewData["CustomerId"]  = CustomerOptions;
            return(View());
        }
Example #42
0
        public static List <SelectListItem> AddDefaultValue(this List <SelectListItem> list, bool chooseType = true)
        {
            var name = chooseType
                ? Resource?.Get("Choose") ?? "Choose"
                : Resource?.Get("All") ?? "All";

            if (list?.Any(i => i.Text?.Equals(name, StringComparison.InvariantCultureIgnoreCase) == true) == true)
            {
                return(list);
            }

            list?.Insert(0, new SelectListItem {
                Text = name
            });

            return(list);
        }
        public IEnumerable <NamedGraph>?GetEndpointGraphs(string endpointName)
        {
            if (_endpoints.TryGetValue(endpointName, out var endpoint))
            {
                string?defaultGraph =
                    endpoint?.DefaultGraph;
                List <NamedGraph>?graphsList =
                    endpoint?.NamedGraphs;
                NamedGraph namedGraph = new NamedGraph()
                {
                    GraphName = "default", Uri = defaultGraph
                };
                graphsList?.Insert(0, namedGraph);
                return(graphsList);
            }

            return(null);
        }
Example #44
0
        private void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                Destroy(this);
                return;
            }
            DontDestroyOnLoad(gameObject);

            if (LoadingScreen.Instance == null)
            {
                Debug.Log("[Kopernicus] LoadingScreen instance not found! Aborting Mesh preloading.");
                return;
            }

            List <LoadingSystem> list = LoadingScreen.Instance.loaders;

            list?.Insert(list.FindIndex(m => m is GameDatabase) + 1, gameObject.AddComponent <MeshPreloader>());
        }
Example #45
0
        public static List <TModel> AddDefaultValue <TModel>(this List <TModel> list, bool chooseType = true)
            where TModel : Nomenclature, new()
        {
            var name = chooseType
                ? Resource?.Get("Choose") ?? "Choose"
                : Resource?.Get("All") ?? "All";

            if (list?.Any(i => i.Name?.Equals(name, StringComparison.InvariantCultureIgnoreCase) == true) == true)
            {
                return(list);
            }

            var item = Activator.CreateInstance <TModel>();

            item.Name = name;
            list?.Insert(0, item);

            return(list);
        }
Example #46
0
        private YieldMarker GetYieldMarker(YieldExpression node)
        {
            YieldMarker result = new YieldMarker(_yields.Count + 1);

            _yields.Add(result);
            if (node.YieldMarker != -1)
            {
                if (_debugCookies == null)
                {
                    _debugCookies = new List <int>(1);
                    _debugCookies.Add(Int32.MaxValue);
                }
                _debugCookies.Insert(result.State, node.YieldMarker);
            }
            else
            {
                _debugCookies?.Insert(result.State, Int32.MaxValue);
            }
            return(result);
        }
Example #47
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="modelSystemStructure"></param>
        /// <param name="referencePath"></param>
        /// <returns></returns>
        private string GetModuleReferencePath(IModelSystemStructure modelSystemStructure, List <string> referencePath)
        {
            if (modelSystemStructure.Parent == null)
            {
                referencePath?.Insert(0, modelSystemStructure.Name);



                return(string.Join(".", referencePath?.ToArray()));
            }
            else
            {
                referencePath.Insert(0, modelSystemStructure.Name);
                if (modelSystemStructure.Parent.IsCollection)
                {
                    referencePath.Insert(0, modelSystemStructure.Parent.Children.IndexOf(modelSystemStructure).ToString());
                }
                return(GetModuleReferencePath(modelSystemStructure.Parent, referencePath));
            }
        }
Example #48
0
        public async Task <IActionResult> Create(
            [Bind("Id,ProjectName,StartDate,CompletionDate,AmountCharged,CustomerId,UserId")] Project project)
        {
            if (ModelState.IsValid)
            {
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            List <SelectListItem> CustomerOptions = await _context.Customer.OrderBy(c => c.LastName).Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.FullName
            }).ToListAsync();

            CustomerOptions?.Insert(0, new SelectListItem {
                Value = "", Text = "Select A Customer", Selected = true
            });

            ViewData["CustomerId"] = CustomerOptions;
            return(View(project));
        }
Example #49
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind("Id,ProjectName,StartDate,CompletionDate,AmountCharged,CustomerId,UserId,IsComplete")] Project project)
        {
            if (id != project.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException) {
                    if (!ProjectExists(project.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            List <SelectListItem> CustomerOptions = await _context.Customer.OrderBy(c => c.LastName).Select(c => new SelectListItem {
                Value = c.Id.ToString(),
                Text  = c.FullName
            }).ToListAsync();

            CustomerOptions?.Insert(0, new SelectListItem {
                Value = "", Text = "Select A Customer", Selected = true
            });

            ViewData["CustomerId"] = CustomerOptions;
            return(View(project));
        }
Example #50
0
        void StartEngine()
        {
            Ping ping = new Ping();

            CancellationTokenSource source = new CancellationTokenSource();

            Task task = Task.Run(() =>
            {
                while (true)
                {
                    if (source.Token.IsCancellationRequested)
                    {
                        break;
                    }
                    try
                    {
                        string ip = this.Dispatcher?.Invoke(() =>
                        {
                            return(this.IP);
                        });

                        var reply = ping.Send(ip);

                        this.Dispatcher?.Invoke(() =>
                        {
                            this.Status = reply.Status;

                            if (reply.Status == IPStatus.Success)
                            {
                                this.RoundtripTime = reply.RoundtripTime;

                                _cache.Insert(0, $"[{DateTime.Now.ToString("HH:mm:ss")}] ping {this.IP} {this.RoundtripTime} ms");
                            }
                            else
                            {
                                this.RoundtripTime = -1;

                                _cache.Insert(0, $"[{DateTime.Now.ToString("HH:mm:ss")}][{this.Status}] {this.IP} {reply.Options?.Ttl}");
                            }
                        });
                    }
                    catch (Exception ex)
                    {
                        this?.Dispatcher?.Invoke(() =>
                        {
                            Status = IPStatus.Unknown;

                            _cache?.Insert(0, ex?.Message);
                        });

                        Debug.WriteLine(ex);
                    }
                    finally
                    {
                        //  Do :只取最新十个
                        this._cache = this._cache.Take(10)?.ToList();

                        this.Dispatcher?.Invoke(() =>
                        {
                            this.Message = string.Join(Environment.NewLine, this._cache);
                        });
                    }

                    Thread.Sleep(Sleep);
                }
            }, source.Token);

            _queue.Enqueue(Tuple.Create(source, task));
        }
Example #51
0
        public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview)
        {
            if (!User.CanEdit("T_Patient") || !CustomAuthorizationBeforeEdit(id, HostingEntityName, AssociatedType))
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            T_Patient t_patient = db.T_Patients.Find(id);

            // NEXT-PREVIOUS DROP DOWN CODE
            TempData.Keep();
            string json = "";

            if (TempData["T_Patientlist"] == null)
            {
                json = Newtonsoft.Json.JsonConvert.SerializeObject(db.T_Patients.Select(z => new { ID = z.Id, DisplayValue = z.DisplayValue }).ToList());
            }
            else
            {
                ViewBag.EntityT_PatientDisplayValueEdit = TempData["T_Patientlist"];
                json = Newtonsoft.Json.JsonConvert.SerializeObject(TempData["T_Patientlist"]);
            }

            Newtonsoft.Json.JsonSerializerSettings serSettings = new    Newtonsoft.Json.JsonSerializerSettings();
            serSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            var lst = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <object> >(json, serSettings);

            ViewBag.EntityT_PatientDisplayValueEdit = new SelectList(lst, "ID", "DisplayValue");
            //
            if (t_patient == null)
            {
                return(HttpNotFound());
            }
            if (string.IsNullOrEmpty(defaultview))
            {
                defaultview = "Edit";
            }
            GetTemplatesForEdit(defaultview);
            // NEXT-PREVIOUS DROP DOWN CODE
            SelectList            selitm  = new SelectList(lst, "ID", "DisplayValue");
            List <SelectListItem> newList = selitm.ToList();

            if (Request.UrlReferrer != null && Request.UrlReferrer.AbsolutePath.EndsWith("/T_Patient/Create"))
            {
                newList.Insert(0, (new SelectListItem {
                    Text = t_patient.DisplayValue, Value = t_patient.Id.ToString()
                }));
                ViewBag.EntityT_PatientDisplayValueEdit = newList;
                TempData["T_Patientlist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            else if (!newList.Exists(p => p.Value == Convert.ToString(t_patient.Id)))
            {
                if (newList.Count > 0)
                {
                    newList[0].Text  = t_patient.DisplayValue;
                    newList[0].Value = t_patient.Id.ToString();
                }
                else
                {
                    newList.Insert(0, (new SelectListItem {
                        Text = t_patient.DisplayValue, Value = t_patient.Id.ToString()
                    }));
                }
                ViewBag.EntityT_PatientDisplayValueEdit = newList;
                TempData["T_Patientlist"] = newList.Select(z => new { ID = z.Value, DisplayValue = z.Text });
            }
            //
            if (UrlReferrer != null)
            {
                ViewData["T_PatientParentUrl"] = UrlReferrer;
            }
            if (ViewData["T_PatientParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Patient") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Patient/Edit/" + t_patient.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/T_Patient/Create"))
            {
                ViewData["T_PatientParentUrl"] = Request.UrlReferrer;
            }
            ViewData["HostingEntityName"] = HostingEntityName;
            ViewData["AssociatedType"]    = AssociatedType;
            LoadViewDataBeforeOnEdit(t_patient);
            ViewBag.T_PatientIsHiddenRule       = checkHidden("T_Patient", "OnEdit", false);
            ViewBag.T_PatientIsGroupsHiddenRule = checkHidden("T_Patient", "OnEdit", true);
            ViewBag.T_PatientIsSetValueUIRule   = checkSetValueUIRule("T_Patient", "OnEdit");
            return(View(t_patient));
        }
Example #52
0
 public static void Add <T>(this List <T> list, int index, T item) => list?.Insert(index, item);
Example #53
0
 public void Insert(int index, T item)
 {
     m_List?.Insert(index, item);
     SetDirty();
 }
Example #54
0
        // Token: 0x060025FA RID: 9722 RVA: 0x000DBE84 File Offset: 0x000DA084
        public static List <TimeRange> GetTimeRanges(UserContext userContext)
        {
            TimeRange.RangeId rangeId        = TimeRange.RangeId.All;
            ExDateTime        normalizedDate = TimeRange.GetNormalizedDate(DateTimeUtilities.GetLocalTime());
            int        num              = (7 + (normalizedDate.DayOfWeek - userContext.UserOptions.WeekStartDay)) % 7;
            ExDateTime normalizedDate2  = TimeRange.GetNormalizedDate(normalizedDate.IncrementDays(1));
            ExDateTime normalizedDate3  = TimeRange.GetNormalizedDate(normalizedDate.IncrementDays(-1));
            ExDateTime normalizedDate4  = TimeRange.GetNormalizedDate(normalizedDate.IncrementDays(7 - num));
            ExDateTime normalizedDate5  = TimeRange.GetNormalizedDate(normalizedDate4.IncrementDays(7));
            ExDateTime normalizedDate6  = TimeRange.GetNormalizedDate(normalizedDate5.IncrementDays(7));
            ExDateTime normalizedDate7  = TimeRange.GetNormalizedDate(normalizedDate6.IncrementDays(7));
            ExDateTime normalizedDate8  = TimeRange.GetNormalizedDate(normalizedDate.IncrementDays(-1 * (7 + num)));
            ExDateTime normalizedDate9  = TimeRange.GetNormalizedDate(normalizedDate8.IncrementDays(-7));
            ExDateTime normalizedDate10 = TimeRange.GetNormalizedDate(normalizedDate9.IncrementDays(-7));

            if (normalizedDate7.Month != normalizedDate.Month)
            {
                rangeId &= ~TimeRange.RangeId.LaterThisMonth;
            }
            if (num != 6)
            {
                rangeId &= ~TimeRange.RangeId.Tomorrow;
            }
            if (num != 0)
            {
                rangeId &= ~TimeRange.RangeId.Yesterday;
            }
            if (normalizedDate10.Month != normalizedDate.Month || 1 >= normalizedDate10.Day)
            {
                rangeId &= ~TimeRange.RangeId.EarlierThisMonth;
            }
            List <TimeRange> list       = new List <TimeRange>(18);
            ExDateTime       exDateTime = new ExDateTime(userContext.TimeZone, normalizedDate.Year, normalizedDate.Month, 1);

            exDateTime = TimeRange.GetNormalizedDate(exDateTime.AddMonths(2));
            ExDateTime exDateTime2 = ExDateTime.MaxValue;

            list.Insert(0, new TimeRange(TimeRange.RangeId.BeyondNextMonth, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            int num2 = ExDateTime.DaysInMonth(normalizedDate.Year, normalizedDate.Month) - normalizedDate.Day;

            if (21 < num2)
            {
                exDateTime = TimeRange.GetNormalizedDate(exDateTime2.AddMonths(-1));
            }
            else
            {
                exDateTime = TimeRange.GetNormalizedDate(normalizedDate6.IncrementDays(7));
            }
            list.Insert(0, new TimeRange(TimeRange.RangeId.NextMonth, exDateTime, exDateTime2));
            if ((TimeRange.RangeId) 0 < (rangeId & TimeRange.RangeId.LaterThisMonth))
            {
                exDateTime2 = exDateTime;
                exDateTime  = TimeRange.GetNormalizedDate(normalizedDate6.IncrementDays(7));
                list.Insert(0, new TimeRange(TimeRange.RangeId.LaterThisMonth, exDateTime, exDateTime2));
            }
            exDateTime2 = exDateTime;
            exDateTime  = normalizedDate6;
            list.Insert(0, new TimeRange(TimeRange.RangeId.ThreeWeeksAway, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            exDateTime  = normalizedDate5;
            list.Insert(0, new TimeRange(TimeRange.RangeId.TwoWeeksAway, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            if (num == 6)
            {
                exDateTime = TimeRange.GetNormalizedDate(normalizedDate4.IncrementDays(1));
            }
            else
            {
                exDateTime = normalizedDate4;
            }
            list.Insert(0, new TimeRange(TimeRange.RangeId.NextWeek, exDateTime, exDateTime2));
            if ((TimeRange.RangeId) 0 < (rangeId & TimeRange.RangeId.Tomorrow))
            {
                exDateTime2 = exDateTime;
                exDateTime  = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1));
                list.Insert(0, new TimeRange(TimeRange.RangeId.Tomorrow, exDateTime, exDateTime2));
            }
            int num3 = 7;

            while (0 < num3)
            {
                exDateTime2 = exDateTime;
                exDateTime  = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1));
                TimeRange.RangeId rangeId2 = TimeRange.RangeId.None;
                if (normalizedDate2.Equals(exDateTime))
                {
                    rangeId2 = TimeRange.RangeId.Tomorrow;
                }
                else if (normalizedDate.Equals(exDateTime))
                {
                    rangeId2 = TimeRange.RangeId.Today;
                }
                else if (normalizedDate3.Equals(exDateTime))
                {
                    rangeId2 = TimeRange.RangeId.Yesterday;
                }
                else
                {
                    switch (exDateTime.DayOfWeek)
                    {
                    case DayOfWeek.Sunday:
                        rangeId2 = TimeRange.RangeId.Sunday;
                        break;

                    case DayOfWeek.Monday:
                        rangeId2 = TimeRange.RangeId.Monday;
                        break;

                    case DayOfWeek.Tuesday:
                        rangeId2 = TimeRange.RangeId.Tuesday;
                        break;

                    case DayOfWeek.Wednesday:
                        rangeId2 = TimeRange.RangeId.Wednesday;
                        break;

                    case DayOfWeek.Thursday:
                        rangeId2 = TimeRange.RangeId.Thursday;
                        break;

                    case DayOfWeek.Friday:
                        rangeId2 = TimeRange.RangeId.Friday;
                        break;

                    case DayOfWeek.Saturday:
                        rangeId2 = TimeRange.RangeId.Saturday;
                        break;
                    }
                }
                list.Insert(0, new TimeRange(rangeId2, exDateTime, exDateTime2));
                num3--;
            }
            if ((TimeRange.RangeId) 0 < (rangeId & TimeRange.RangeId.Yesterday))
            {
                exDateTime2 = exDateTime;
                exDateTime  = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1));
                list.Insert(0, new TimeRange(TimeRange.RangeId.Yesterday, exDateTime, exDateTime2));
            }
            exDateTime2 = exDateTime;
            exDateTime  = normalizedDate8;
            list.Insert(0, new TimeRange(TimeRange.RangeId.LastWeek, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            exDateTime  = normalizedDate9;
            list.Insert(0, new TimeRange(TimeRange.RangeId.TwoWeeksAgo, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            exDateTime  = normalizedDate10;
            list.Insert(0, new TimeRange(TimeRange.RangeId.ThreeWeeksAgo, exDateTime, exDateTime2));
            if ((TimeRange.RangeId) 0 < (rangeId & TimeRange.RangeId.EarlierThisMonth))
            {
                exDateTime2 = exDateTime;
                exDateTime  = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1 * (exDateTime.Day - 1)));
                list.Insert(0, new TimeRange(TimeRange.RangeId.EarlierThisMonth, exDateTime, exDateTime2));
            }
            exDateTime2 = exDateTime;
            if (exDateTime2.Day == 1)
            {
                exDateTime = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1));
            }
            exDateTime = TimeRange.GetNormalizedDate(exDateTime.IncrementDays(-1 * (exDateTime.Day - 1)));
            list.Insert(0, new TimeRange(TimeRange.RangeId.LastMonth, exDateTime, exDateTime2));
            exDateTime2 = exDateTime;
            exDateTime  = ExDateTime.MinValue.AddTicks(1L);
            list.Insert(0, new TimeRange(TimeRange.RangeId.Older, exDateTime, exDateTime2));
            list.Insert(0, new TimeRange(TimeRange.RangeId.None, ExDateTime.MinValue, ExDateTime.MinValue));
            return(list);
        }
Example #55
0
        /// <summary>
        /// Gauna visus koeficientus kurie yra pradinis vektorius
        /// </summary>
        /// <param name="encodedVector"></param>
        /// <returns></returns>
        private List <int> GetVotes(List <int> encodedVector)
        {
            var n    = (int)Math.Pow(2, m);
            var rows = m.CountCombination(r);

            bytes = BytesCounter.GetBytes(n, m);

            for (int i = r; i >= 0; i--)
            {
                if (i == 0)
                {
                    w = new List <List <int> >();
                    for (int h = 0; h < n; h++)
                    {
                        wt = new List <int>();
                        for (int j = 0; j < n - 1; j++)
                        {
                            wt.Add(0);
                        }
                        wt.Insert(h, 1);
                        w.Add(wt);
                    }
                    CalculateDominantVote(n, encodedVector);
                }

                else
                {
                    int positionsMissingCount = m - i;
                    var missingPositionsList  = GetMissingPossitionsList(positionsMissingCount);

                    var tList = BytesCounter.GetBytes((int)Math.Pow(2, positionsMissingCount), positionsMissingCount);

                    foreach (var missingPosition in missingPositionsList)
                    {
                        w = new List <List <int> >();
                        foreach (var t in tList)
                        {
                            wt = new List <int>();
                            foreach (var _byte in bytes)
                            {
                                bool value = false;
                                for (int pos = 0; pos < positionsMissingCount; pos++)
                                {
                                    if (_byte[missingPosition[pos]] == t[pos])
                                    {
                                        value = true;
                                    }
                                    else
                                    {
                                        value = false;
                                        break;
                                    }
                                }
                                if (value == false)
                                {
                                    wt.Add(0);
                                }
                                else
                                {
                                    wt.Add(1);
                                }
                            }
                            w.Add(wt);
                        }
                        CalculateDominantVote(n, encodedVector);
                    }

                    if (finalVotes.Count != rows)
                    {
                        encodedVector = SubtractFromMainVector(rows, n, encodedVector);
                    }
                }
            }
            return(finalVotes);
        }
        public static double Solve(string text)
        {
            if (text.StartsWith("-") || text.StartsWith("+"))
            {
                text = "0" + text;
            }

            char[] delimiterChars = { '+', '-', '*', '/', '^', '(', ')' };

            string[]       words      = text.Split(delimiterChars);
            List <string>  Expression = words.ToList();
            Stack <double> Values     = new Stack <double>();
            Stack <string> Operands   = new Stack <string>();
            int            count      = 1;
            double         Number;

            foreach (char c in text)
            {
                if (delimiterChars.Contains(c))
                {
                    Expression.Insert(count, c.ToString());
                    count = count + 2;
                }
            }
            Console.WriteLine();

            foreach (string s in Expression)
            {
                if (string.Compare(s, "(") == 0)
                {
                    Operands.Push(s);
                }
                else if (string.Compare(s, ")") == 0)
                {
                    while (Operands.Peek() != "(")
                    {
                        Values.Push(PerformOperations(Operands.Pop(), Values.Pop(), Values.Pop()));
                    }
                    Operands.Pop();
                }
                else if (s == "^")
                {
                    // Values.Push(PerformOperations(Operands.Pop(), Values.Pop(), Values.Pop()));
                    Operands.Push(s);
                }


                else if (s == "+" || s == "-" || s == "*" || s == "/" || s == "^")
                {
                    while (Operands.Count != 0 && hasPrecedence(s, Operands.Peek()))
                    {
                        Values.Push(PerformOperations(Operands.Pop(), Values.Pop(), Values.Pop()));
                    }
                    Operands.Push(s);
                }
                else if (IsNumeric(s, out Number))
                {
                    Values.Push(Number);
                }
            }

            while (Operands.Count != 0)
            {
                Values.Push(PerformOperations(Operands.Pop(), Values.Pop(), Values.Pop()));
            }

            return(Math.Round(Values.Pop(), 3));
        }
Example #57
0
        private void SortLayer(ref List <Box> layerList)
        {
            foreach (Box b in layerList)
            {
                b.ApplyElong(-_tuneParam);
            }

            // build y list
            List <double> yList = new List <double>();

            foreach (Box b in layerList)
            {
                if (!yList.Contains(b.YMin))
                {
                    yList.Add(b.YMin);
                }
                if (!yList.Contains(b.YMax))
                {
                    yList.Add(b.YMax);
                }
            }
            yList.Sort();
            if (_direction.Y < 0)
            {
                yList.Reverse();
            }

            List <Box> treeList = new List <Box>();
            List <Box> resList  = new List <Box>();

            // sweep stage
            foreach (double y in yList)
            {
                // clean treelist
                if (_direction.Y > 0.0)
                {
                    CleanByYMax(treeList, y);
                    // add new
                    List <Box> listYMin = GetByYMin(layerList, y);

                    foreach (Box by in listYMin)
                    {
                        treeList.Add(by);
                        if (_direction.X > 0.0)
                        {
                            treeList.Sort(new BoxComparerXMin(_direction));
                        }
                        else
                        {
                            treeList.Sort(new BoxComparerXMax(_direction));
                        }

                        // find successor of by
                        int id = treeList.FindIndex(delegate(Box b) { return(b.PickId == by.PickId); });
                        Box successor = null;
                        if (id < treeList.Count - 1)
                        {
                            successor = treeList[id + 1];
                        }

                        // insert by
                        if (null == successor)
                        {
                            resList.Add(by);
                        }
                        else
                        {
                            int idBefore = resList.FindIndex(delegate(Box b) { return(b.PickId == successor.PickId); });
                            resList.Insert(idBefore, by);
                        }
                    }
                }
                else
                {
                    CleanByYMin(treeList, y);
                    // add new
                    List <Box> listYMax = GetByYMax(layerList, y);

                    foreach (Box by in listYMax)
                    {
                        treeList.Add(by);
                        if (_direction.X > 0.0)
                        {
                            treeList.Sort(new BoxComparerXMin(_direction));
                        }
                        else
                        {
                            treeList.Sort(new BoxComparerXMax(_direction));
                        }

                        // find successor of by
                        int id = treeList.FindIndex(delegate(Box b) { return(b.PickId == by.PickId); });
                        Box successor = null;
                        if (id < treeList.Count - 1)
                        {
                            successor = treeList[id + 1];
                        }

                        // insert by
                        if (null == successor)
                        {
                            resList.Add(by);
                        }
                        else
                        {
                            int idBefore = resList.FindIndex(delegate(Box b) { return(b.PickId == successor.PickId); });
                            resList.Insert(idBefore, by);
                        }
                    }
                }
            }

            layerList.Clear();
            resList.Reverse();
            layerList.AddRange(resList);

            foreach (Box b in layerList)
            {
                b.ApplyElong(_tuneParam);
            }
        }
Example #58
0
 public static void InsertAsFirst <T>(this List <T> list, T item)
 {
     list?.Insert(0, item);
 }
Example #59
0
 public void Insert(int index, MiCakeModuleDescriptor item)
 {
     _descriptors.Insert(index, item);
 }
Example #60
0
        public static Block[] DecodeSubroutine(MemoryManager memory, ulong address, ExecutionMode mode)
        {
            List <Block> blocks = new List <Block>();

            Queue <Block> workQueue = new Queue <Block>();

            Dictionary <ulong, Block> visited = new Dictionary <ulong, Block>();

            Block GetBlock(ulong blkAddress)
            {
                if (!visited.TryGetValue(blkAddress, out Block block))
                {
                    block = new Block(blkAddress);

                    workQueue.Enqueue(block);

                    visited.Add(blkAddress, block);
                }

                return(block);
            }

            GetBlock(address);

            while (workQueue.TryDequeue(out Block currBlock))
            {
                // Check if the current block is inside another block.
                if (BinarySearch(blocks, currBlock.Address, out int nBlkIndex))
                {
                    Block nBlock = blocks[nBlkIndex];

                    if (nBlock.Address == currBlock.Address)
                    {
                        throw new InvalidOperationException("Found duplicate block address on the list.");
                    }

                    nBlock.Split(currBlock);

                    blocks.Insert(nBlkIndex + 1, currBlock);

                    continue;
                }

                // If we have a block after the current one, set the limit address.
                ulong limitAddress = ulong.MaxValue;

                if (nBlkIndex != blocks.Count)
                {
                    Block nBlock = blocks[nBlkIndex];

                    int nextIndex = nBlkIndex + 1;

                    if (nBlock.Address < currBlock.Address && nextIndex < blocks.Count)
                    {
                        limitAddress = blocks[nextIndex].Address;
                    }
                    else if (nBlock.Address > currBlock.Address)
                    {
                        limitAddress = blocks[nBlkIndex].Address;
                    }
                }

                FillBlock(memory, mode, currBlock, limitAddress);

                if (currBlock.OpCodes.Count != 0)
                {
                    // Set child blocks. "Branch" is the block the branch instruction
                    // points to (when taken), "Next" is the block at the next address,
                    // executed when the branch is not taken. For Unconditional Branches
                    // (except BL/BLR that are sub calls) or end of executable, Next is null.
                    OpCode64 lastOp = currBlock.GetLastOp();

                    bool isCall = IsCall(lastOp);

                    if (lastOp is IOpCodeBImm op && !isCall)
                    {
                        currBlock.Branch = GetBlock((ulong)op.Imm);
                    }

                    if (!IsUnconditionalBranch(lastOp) || isCall)
                    {
                        currBlock.Next = GetBlock(currBlock.EndAddress);
                    }
                }

                // Insert the new block on the list (sorted by address).
                if (blocks.Count != 0)
                {
                    Block nBlock = blocks[nBlkIndex];

                    blocks.Insert(nBlkIndex + (nBlock.Address < currBlock.Address ? 1 : 0), currBlock);
                }
                else
                {
                    blocks.Add(currBlock);
                }
            }

            return(blocks.ToArray());
        }