示例#1
0
 private static string ConvertEntries(Entries entries)
 {
     var data = new[] { "1", "2", "M"};
     if ((int)entries < 0) entries = Entries.SingleEntry;
     if ((int)entries >= data.Length) entries = Entries.SingleEntry;
     return data[(int)entries];
 }
示例#2
0
        public void Init()
        {            
            //init can be called to refresh the board
            m_currentEntries = new Entries(); //clear entried

            if (File.Exists(m_filePath)) //check if the leaderboard file exists, is so use it
            {
                Console.WriteLine("file found, loading high scores");
                ParseLeaderBoard();
            }
            else
            {
                FileStream fs = new FileStream(m_filePath, FileMode.Create); //create the file for later dumping            
                fs.Close();
                // default leaderboard
                m_currentEntries.m_names.Add("Hero");
                m_currentEntries.m_scores.Add(5);
                m_currentEntries.m_names.Add("Guran");
                m_currentEntries.m_scores.Add(10);
                m_currentEntries.m_names.Add("Kit");
                m_currentEntries.m_scores.Add(9);
                m_currentEntries.m_names.Add("Ghost");
                m_currentEntries.m_scores.Add(3);
                m_currentEntries.m_names.Add("Devil");
                m_currentEntries.m_scores.Add(1);
                m_currentEntries.m_names.Add("Diana");
                m_currentEntries.m_scores.Add(30);

                m_currentEntries = SortLeaderBoard(m_currentEntries); //ensure we have a sorted leaderboard  

                Serialize(); //ensure there is data in the file
            }
        }
示例#3
0
 public void Adding()
 {
     var entries = new Entries();
     entries.Get("name", x => x.SetValue("dru"));
     var e = entries.Get("name");
     Assert.AreEqual("dru", e.Value);
 }
示例#4
0
 public void Removing()
 {
     var entries = new Entries();
     entries.Get("name", x => x.SetValue("dru"));
     entries.Remove("name");
     var e = entries.Get("name");
     Assert.IsNull(e);
 }
示例#5
0
        public void Json()
        {
            var before = "[{\"Key\":\"name\",\"Value\":\"dru\"}]";
            var after = "[]";

            var entries = new Entries();
            entries.Get("name", x => x.SetValue("dru"));
            Assert.AreEqual(before, JsonUtil.ToJson(entries));
            entries.Remove("name");

            Assert.AreEqual(after, JsonUtil.ToJson(entries));
        }
示例#6
0
        private BlogListItemModel CreateBlogItemModel(Entries entry, string blogPageUrl)
        {
            using (var con = new DataConnection())
            {
                var image = con.Get<IMediaFile>().FirstOrDefault(m => m.KeyPath == entry.Image);
                var model = new BlogListItemModel
                {
                    Title = entry.Title,
                    Url = BlogFacade.GetBlogUrl(entry.Date, entry.Title, entry.PageId, blogPageUrl),
                    Tags = entry.Tags,
                    TagsByType = BlogFacade.GetTagsByType(entry.Tags),
                    ImageUrl = image != null ? BlogFacade.GetFullPath(MediaUrls.BuildUrl(image)) : string.Empty
                };

                return model;
            }
        }
示例#7
0
        private void ParseLeaderBoard()
        {
            //converts hash table to custom type            

            Hashtable hTable = Deserialize(); //get the hastable from file

            //populate the current leaderboard entries
            ICollection key = hTable.Keys;
            foreach (string k in key)
            {
                //Console.WriteLine(k + ": " + hTable[k]);

                m_currentEntries.m_names.Add(hTable[k].ToString());
                m_currentEntries.m_scores.Add(Int32.Parse(k));
            }
            
            m_currentEntries =  SortLeaderBoard(m_currentEntries); //ensure we have a sorted leaderboard            
        }
 /// <summary>
 /// Deserializes an XmlReader representing a site.xml file.
 /// </summary>
 /// <param name="reader">
 /// The XmlReader to deserialize.
 /// </param>
 /// <returns>
 /// Entries representing the site.xml file.
 /// </returns>
 public Entries DeserializeXml(XmlReader reader)
 {
     Entries entries = new Entries();
     try
     {
         var doc = new XmlDocument();
         doc.Load(reader);
         var props = doc.SelectNodes("//property");
         if (!ReferenceEquals(props, null))
         {
             foreach (XmlNode prop in props)
             {
                 string name;
                 string value = string.Empty;
                 var nameNode = prop.SelectSingleNode("name");
                 var valueNode = prop.SelectSingleNode("value");
                 if (!ReferenceEquals(nameNode, null))
                 {
                     name = nameNode.InnerText;
                     if (!ReferenceEquals(valueNode, null))
                     {
                         value = valueNode.InnerText;
                     }
                     if (!string.IsNullOrWhiteSpace(name))
                     {
                         entries.Add(name, value);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         if (!(ex is IOException || ex is XmlException))
         {
             throw;
         }
     }
     return entries;
 }
 public async Task RemoveTimeSheetEntry(TimeSheetEntry entry)
 {
     Entries.Remove(entry);
     await SaveChangesAsync();
 }
 private Entries ConvertStringToEntries(string encoded)
 {
     Entries retval = new Entries();
     var entriesLines = encoded.Split(new string[] { EntryDelimiter.ToString() }, StringSplitOptions.None);
     foreach (var entriesLine in entriesLines)
     {
         if (!string.IsNullOrWhiteSpace(entriesLine))
         {
             string[] pairs = entriesLine.Split(new string[] { EntryPairDelimiter.ToString() }, StringSplitOptions.None);
             retval.Add(pairs[0], pairs[1]);
         }
     }
     return retval;
 }
示例#11
0
 public virtual IEnumerable <T> GetEntries <T>() where T : GumpEntry
 {
     return(Entries.OfType <T>());
 }
 public Task <List <TimeSheetEntry> > GetEntriesForUser(User user)
 {
     return(Entries.Where(e => e.User == user).Include(e => e.Job).ToListAsync());
 }
示例#13
0
 internal override void GetIndices(MSBD msb, Entries entries)
 {
     base.GetIndices(msb, entries);
     SpawnPointIndices = MSB.FindIndices(entries.Regions, SpawnPointNames);
     SpawnPartIndices  = MSB.FindIndices(entries.Parts, SpawnPartNames);
 }
示例#14
0
 internal virtual void GetNames(MSB2 msb, Entries entries)
 {
     ModelName = GetName(entries.Models, modelIndex);
 }
        /// <summary>
        /// Returns products to compare.
        /// </summary>
        /// <param name="mcId">Id of a metaClass.</param>
        /// <returns></returns>
        public static Entries GetCompareProducts(string mcId)
        {
            Entries    products      = new Entries();
            HttpCookie compareCookie = HttpContext.Current.Request.Cookies.Get(MakeCurrentApplicationCookieName(_CompareCookieItemsName));

            if (compareCookie != null && compareCookie.Values != null)
            {
                List <int> productIds = new List <int>();

                string[] values = new string[] { };
                if (String.IsNullOrEmpty(mcId))
                {
                    List <string> _values = new List <string>();
                    foreach (string key in compareCookie.Values.AllKeys)
                    {
                        if (!String.IsNullOrEmpty(key))
                        {
                            string[] valuesByKey = compareCookie.Values.GetValues(key);
                            _values.AddRange(valuesByKey);
                        }
                    }
                    values = _values.ToArray();
                }
                else
                {
                    values = compareCookie.Values.GetValues(mcId);
                }

                if (values != null && values.Length > 0)
                {
                    foreach (string productId in values)
                    {
                        int prodId = Int32.Parse(productId);
                        if (!productIds.Contains(prodId))
                        {
                            productIds.Add(prodId);
                        }
                    }
                }

                if (productIds.Count == 0)
                {
                    return(products);
                }

                // get the products
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions();

                options.CacheResults      = true;
                options.StartingRecord    = 0;
                options.RecordsToRetrieve = _MaxProductsToCompare;
                options.ReturnTotalCount  = true;
                //pars.SqlWhereClause = String.Format("ClassTypeId='{0}'", "product");

                pars.SqlWhereClause = String.Format("1=1");

                // add productids to where statement, since we need to return only selected products
                pars.SqlWhereClause += BuildWhereStatementForSearch(productIds);

                products = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
            }

            return(products);
        }
示例#16
0
 public Todo FindById(int id)
 {
     return(Entries.FirstOrDefault(todo => todo.Id == id));
 }
示例#17
0
        public void Apply(EntryTimeCorrectedEvent aggregateEvent)
        {
            EntryEntity entry = Entries.First(e => e.Id == aggregateEvent.EntryId);

            entry.ChangeTime(aggregateEvent.TimeInMillis);
        }
示例#18
0
 private CompetitionSnapshot CreateSnapshot(CancellationToken cancellationToken)
 {
     return(new CompetitionSnapshot(Competitionname, User, IsDeleted, Entries.Select(e => e.CreateSnapshot()).ToArray()));
 }
示例#19
0
 public void Apply(EntryRecordedEvent aggregateEvent)
 {
     Entries.Add(new EntryEntity(aggregateEvent.EntryId, aggregateEvent.Discipline, aggregateEvent.Name, aggregateEvent.TimeInMillis));
 }
示例#20
0
 internal IExecutionResult ChangeEntryTime(EntryId entryId, int timeInMillis)
 {
     return(ExecuteAfterValidation(
                () => Entries.FirstOrDefault(e => e.Id == entryId)?.ChangeTime(timeInMillis)
                ));
 }
        /// <summary>
        /// Imports a simple mod pack
        /// </summary>
        /// <param name="modPackJson">The mod pack json</param>
        private async Task ImportSimpleModPack(ModPackJson modPackJson)
        {
            var modding = new Modding(_gameDirectory);

            Dispatcher.Invoke(() =>
            {
                // This does not need to be an async task set.
                for (int i = 0; i < modPackJson.SimpleModsList.Count; i++)
                {
                    var jsonItem = modPackJson.SimpleModsList[i];

                    // For some reason the ModPackEntry was never set before 2.0.13 so this is necessary for modpacks created prior to then
                    if (jsonItem.ModPackEntry == null)
                    {
                        // Manually add the modpack entry that this mod is a part of
                        jsonItem.ModPackEntry = new ModPack
                        {
                            name    = modPackJson.Name,
                            author  = modPackJson.Author,
                            version = modPackJson.Version
                        };
                    }

                    JsonEntries.Add(jsonItem);
                    Entries.Add(new SimpleModpackEntry(JsonEntries.Count - 1, this));
                }

                if (!String.IsNullOrEmpty(modPackJson.MinimumFrameworkVersion))
                {
                    Version ver;
                    bool success = Version.TryParse(modPackJson.MinimumFrameworkVersion, out ver);
                    if (success)
                    {
                        var frameworkVersion = typeof(XivCache).Assembly.GetName().Version;
                        if (ver > frameworkVersion)
                        {
                            var Win32Window = new WindowWrapper(new WindowInteropHelper(this).Handle);
                            FlexibleMessageBox.Show(Win32Window, "This Modpack requires a more recent version of TexTools to install.", "Framework Version Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            Close();
                            return;
                        }
                    }
                }

                ModPackName.Content    = modPackJson.Name;
                ModPackAuthor.Content  = modPackJson.Author;
                ModPackVersion.Content = modPackJson.Version;

                var cv = (CollectionView)CollectionViewSource.GetDefaultView(ModListView.ItemsSource);
                cv.SortDescriptions.Clear();
                cv.SortDescriptions.Add(new SortDescription(nameof(SimpleModpackEntry.ItemName), _lastDirection));

                SelectedEntries.Clear();
                long size = 0;
                for (int i = 0; i < JsonEntries.Count; i++)
                {
                    SelectedEntries.Add(i);
                    size += JsonEntries[i].ModSize;
                }
                ModListView.SelectAll();
                ModSize = size;
            });
        }
 /// <summary>
 /// Creates the data source.
 /// </summary>
 /// <param name="entries">The entries.</param>
 /// <param name="count">The count.</param>
 /// <returns></returns>
 private CatalogIndexSearchDataSource CreateDataSource(Entries entries, int count)
 {
     var datasource = new CatalogIndexSearchDataSource();
     datasource.CatalogEntries = entries;
     datasource.TotalResults = count;
     return datasource;
 }
示例#23
0
        /// <summary>
        /// When the page loads, we'll perform the search based on the criteria defined in the query string.
        /// Some of this is automatically done by ECF, for better or for worse, other things are done by us in our
        /// public properties such as KeyWords
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //before we conduct the search, we'd better make sure the prices are set for the user
            global::NWTD.Profile.SetSaleInformation();

            //Hide the "Add Selected items to cart" button on the top of the results
            this.srBookSearch.AddToCartTop.Visible = false;


            //The criteria for this search is going to be based on the query string.

            //first get some variables ready
            int      count        = 0;
            bool     cacheResults = true;
            TimeSpan cacheTimeout = new TimeSpan(0, 0, 30);             //by default we'll have our cache timeout after 30 seconds

            if (String.IsNullOrEmpty(this.KeyWords))
            {
                cacheTimeout = new TimeSpan(0, 1, 0);                 //if there's no keyword search, we'll up the timeout to a minute
            }
            //get the current filter
            //(ECF will automatically pull filters from the query string)
            SearchFilterHelper filter = SearchFilterHelper.Current;


            string keyWords = this.KeyWords;

            //*********COMMENTED OUT THE FOLLOWING 'IF' TO MATCH NWTD BookSearchControl LOGIC (HEATH GARDNER 01/22/16)*********
            ////check to see if the KeyWords matches an ISBN Pattern
            //if(System.Text.RegularExpressions.Regex.IsMatch(keyWords, @"^[0-9-]+[a-z-0-9]?$")){ //any string of all hyphens or numbers and possibly an alpha character at the end
            //    keyWords = keyWords.Replace("-",string.Empty);
            //}


            //build the criteria based on sort and keywords
            CatalogEntrySearchCriteria criteria = filter.CreateSearchCriteria(keyWords, this.SortBy);


            // the current catalog if that's not been added yet (which it shouldn't be)
            if (criteria.CatalogNames.Count == 0)
            {
                CatalogDto catalogs = CatalogContext.Current.GetCatalogDto(CMSContext.Current.SiteId);
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                        {
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }

            //Incorporate the state availablity flag
            criteria.Add(
                global::NWTD.Catalog.UserStateAvailablityField,
                new SimpleValue()
            {
                key          = string.Empty,
                value        = "y",
                locale       = "en-us",
                Descriptions = new Descriptions()
                {
                    defaultLocale = "en-us"
                }
            });

            //*********COMMENTED OUT THE FOLLOWING LUCENE SetMaxClause TO MATCH NWTD BookSearchControl LOGIC (HEATH GARDNER 01/22/16)*********
            //setting this in the helper class now
            //Lucene.Net.Search.BooleanQuery.SetMaxClauseCount(Int32.MaxValue);
            //exectute the search
            Entries entries = filter.SearchEntries(
                criteria,
                this.StartIndex,
                this.ItemsPerPage,
                out count,
                new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo),
                cacheResults,
                cacheTimeout
                );

            //Lucene.Net.Search.BooleanQuery.SetMaxClauseCount(1024);
            //the number of results that were returned
            int resultsCount = entries.Entry != null?entries.Entry.Count() : 0;

            if (entries.Entry != null && entries.Entry.Count() > this.ItemsPerPage)               //ECF's search helper pads the results by 5
            {
                Entry[] entryset = entries.Entry;
                Array.Resize <Entry>(ref entryset, this.ItemsPerPage);

                entries.Entry = entryset;
            }

            int fromResult = (this.StartIndex + 1);
            int toResult   = this.StartIndex + (this.ItemsPerPage > resultsCount ? resultsCount : this.ItemsPerPage);

            //indicate to the user what page we're on
            if (resultsCount > 0)
            {
                this.litPageNumber.Text = string.Format("({0}-{1} of {2})", fromResult.ToString(), toResult.ToString(), count.ToString());
            }
            else
            {
                //this.ddlSortBy.Visible = false;
            }

            decimal numberOfPages = 1 + Convert.ToDecimal(Math.Floor(Convert.ToDouble((count / this.ItemsPerPage))));

            //if we're not on page 1, add a prev button to the pager
            if (this.PageNumber != 1)
            {
                this.blPager.Items.Add(new ListItem("Prev", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber - 1).ToString())));
                this.blBottomPager.Items.Add(new ListItem("Prev", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber - 1).ToString())));
            }
            //if we're not on the last page, add a next button to the pager
            if (this.PageNumber != numberOfPages)
            {
                this.blPager.Items.Add(new ListItem("Next", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber + 1).ToString())));
                this.blBottomPager.Items.Add(new ListItem("Next", SearchFilterHelper.GetQueryStringNavigateUrl("page", (PageNumber + 1).ToString())));
            }

            //this.srBookSearch.ResultsGrid.ShowFooter = true;
            this.srBookSearch.ResultsGrid.Parent.Controls.AddAt(this.srBookSearch.ResultsGrid.Parent.Controls.IndexOf(this.srBookSearch.ResultsGrid) + 1, this.pnlBottomPager);

            //I can't figure out why this needs to be cast. For some reason VS is calling it a UserControl, not a SideMenu
            FiltersSideMenu.Filters = filter.SelectedFilters;

            //Only show facet if results are more than 1 - Heath Gardner 01/22/16 ////////////////////////////////////////
            FacetGroup[] facets = null;


            if (resultsCount > 1)
            {
                facets = filter.GetFacets(cacheResults, cacheTimeout);
            }

            FiltersSideMenu.Facets = facets;
            //End modify//////////////////////////////////////////////////////////////////////////////////////////////////

            //Original facet logic that was replaced with the above - Heath Gardner 01/22/16
            //FacetGroup[]  facets = filter.GetFacets(cacheResults, cacheTimeout);
            //FiltersSideMenu.Facets = facets;

            //Bind the results to our search results control
            this.srBookSearch.Entries      = entries;
            this.srBookSearch.TotalResults = count;

            //We don't want them to be able to just view everything with no search (for reasons unbeknownst to me)
            if (Request.QueryString.Count == 0)
            {
                this.srBookSearch.Visible     = false;
                this.blPager.Visible          = false;
                this.blBottomPager.Visible    = false;
                this.litPageNumber.Visible    = false;
                this.pnlBrowseCatalog.Visible = true;
                this.pnlSearchHead.Visible    = false;
                //return;
            }
            //if there are no results, we need to hide certain things
            else if (count == 0)
            {
                this.srBookSearch.Visible  = false;
                this.blPager.Visible       = false;
                this.blBottomPager.Visible = false;
                this.litPageNumber.Visible = false;
                this.pnlNoResults.Visible  = true;
                this.pnlSearchHead.Visible = false;
                //return;
            }

            if (!string.IsNullOrEmpty(this.KeyWords))
            {
                this.litSearchString.Text = string.Format("<span class=\"nwtd-searchString\">for \"{0}\"</span>", this.KeyWords);
            }

            DataBind();
        }
示例#24
0
 private Entries GetConsoleInput()
 {
     if (ReferenceEquals(this.lines, null))
     {
         List<string> lines = new List<string>();
         using (var input = Console.OpenStandardInput())
         using (var reader = new StreamReader(input))
         {
             while (!reader.EndOfStream)
             {
                 lines.Add(reader.ReadLine());
             }
         }
         this.lines = Entries.MakeEntries(lines);
     }
     return this.lines;
 }
示例#25
0
 public string GetCategory(ModEntry mod)
 {
     return(Entries.First(entry => entry.Value.Entries.Contains(mod)).Key);
 }
示例#26
0
 internal override void GetIndices(MSBD msb, Entries entries)
 {
     base.GetIndices(msb, entries);
     TreasurePartIndex = MSB.FindIndex(entries.Parts, TreasurePartName);
 }
示例#27
0
 public bool ContainsKey(
     int key
     )
 {
     return(Entries.ContainsKey(key));
 }
示例#28
0
        public override async Task LoadContent()
        {
            try
            {
                await base.LoadContent();

                if (null == FontSmall)
                {
                    FontSmall = new FontBuddyPlus();
                    FontSmall.LoadContent(Content, StyleSheet.SmallFontResource, StyleSheet.UseFontPlus, StyleSheet.SmallFontSize);
                }

                if (null == FontMedium)
                {
                    FontMedium = new FontBuddyPlus();
                    FontMedium.LoadContent(Content, StyleSheet.MediumFontResource, StyleSheet.UseFontPlus, StyleSheet.MediumFontSize);
                }

                //create the stack layout to hold the question and words
                var questionStack = new StackLayout(StackAlignment.Top)
                {
                    Vertical         = VerticalAlignment.Bottom,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                };

                //Add the text asking a question
                questionStack.AddItem(new Label($"What is the", FontSmall)
                {
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                });
                questionStack.AddItem(new Shim(0, 8));
                questionStack.AddItem(new Label($"{correctAnswer.Language} for:", FontSmall)
                {
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopTop),
                });
                questionStack.AddItem(new Shim(0, 8));

                //Add all the translations
                foreach (var translation in correctQuestion.Translations)
                {
                    if (translation.Language != correctAnswer.Language)
                    {
                        CreateTranslationLabel(FontMedium, questionStack, translation);
                    }
                }

                questionStack.Position = new Point(Resolution.ScreenArea.Center.X, (int)((Resolution.TitleSafeArea.Height * 0.2f) - (questionStack.Rect.Height * 0.4f)));
                AddItem(questionStack);

                //create the correct menu entry
                CorrectAnswerEntry          = CreateQuestionMenuEntry(correctAnswer.Word, correctQuestion, true, FontMedium);
                CorrectAnswerEntry.OnClick += CorrectAnswerSelected;
                Entries.Add(CorrectAnswerEntry);

                //Add exactly three wrong answers
                for (int i = 0; i < 3; i++)
                {
                    //get a random wrong answer
                    int index = _rand.Next(wrongAnswers.Count);

                    //create a menu entry for that answer
                    var wrongMenuEntry = CreateQuestionMenuEntry(wrongAnswers[index].Word, wrongQuestions[index], false, FontMedium);
                    wrongMenuEntry.OnClick += WrongAnswerSelected;
                    Entries.Add(wrongMenuEntry);

                    //remove the wrong answer from the list so it wont be added again
                    wrongAnswers.RemoveAt(index);
                    wrongQuestions.RemoveAt(index);
                }

                //shuffle the answers
                Entries.Shuffle(_rand);

                //create the stack layout to hold the possible answers
                var answersStack = new StackLayout(StackAlignment.Top)
                {
                    Name             = "AnswerStack",
                    Vertical         = VerticalAlignment.Center,
                    Horizontal       = HorizontalAlignment.Center,
                    Highlightable    = false,
                    TransitionObject = new WipeTransitionObject(TransitionWipeType.PopBottom),
                    Position         = new Point(Resolution.ScreenArea.Center.X, (int)(Resolution.TitleSafeArea.Height * 0.5f))
                };

                //add all the question entries to the menu
                foreach (var entry in Entries)
                {
                    answersStack.AddItem(entry);
                }
                AddItem(answersStack);

                //load the sound effect to play when time runs out on a question
                WrongAnswerSound = Content.Load <SoundEffect>("WrongAnswer");

                AutoQuit.Stop();
            }
            catch (Exception ex)
            {
                await ScreenManager.ErrorScreen(ex);
            }

            //Try to load the sound effects
            soundContent = new ContentManager(ScreenManager.Game.Services, "Content");
            try
            {
                QuestionSoundEffect = soundContent.Load <SoundEffect>($"TTS/{correctAnswer.Language}Question");
            }
            catch (Exception ex)
            {
                //ignore for now
            }

            //load the correct answer sound effect
            try
            {
                QuestionWordSoundEffect = CorrectQuestion.LoadSoundEffect(correctQuestion.OtherLanguage(correctAnswer.Language), soundContent);
            }
            catch (Exception ex)
            {
                //ignore for now
            }

            //load the sound effect for each question
            for (int i = 0; i < Entries.Count; i++)
            {
                try
                {
                    Entries[i].LoadSoundEffect(correctAnswer.Language, soundContent);
                }
                catch (Exception ex)
                {
                    //ignore for now
                }
            }

            QuestionStateMachine = new QuestionStateMachine();
            QuestionStateMachine.StartTimer(Transition.OnTime + 0.1f);
            QuestionStateMachine.StateChangedEvent += QuestionStateMachine_StateChangedEvent;
        }
示例#29
0
 public bool Remove(
     int key
     )
 {
     return(Entries.Remove(key));
 }
示例#30
0
 internal virtual void GetIndices(MSB2 msb, Entries entries)
 {
     modelIndex = GetIndex(entries.Models, ModelName);
 }
示例#31
0
 public void Reset()
 {
     currentIterator = Entries.GetEnumerator();
 }
示例#32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExFatMetaDirectoryEntry"/> class.
 /// </summary>
 /// <param name="entries">The entries.</param>
 public ExFatMetaDirectoryEntry(IEnumerable <ExFatDirectoryEntry> entries)
 {
     Entries.AddRange(entries);
 }
示例#33
0
        public void CreateFromDefault(string name)
        {
            Load(DefaultFile);

            if (!Has("Configuration", "BasedOn"))
            {
                return;
            }


            var baseFile = Get("Configuration", "BasedOn").First();

            Remove("Configuration", "BasedOn");

            var file = System.IO.Path.GetFullPath(System.IO.Path.Combine(XCOM2.GameDir, "XComGame", baseFile));

            // Create config from base baseFile
            var baseConfig = new IniFile(file, true);

            // Overwrite values
            foreach (var section in Entries)
            {
                foreach (var entries in section.Value)
                {
                    var op = entries.Key[0];

                    switch (op)
                    {
                    case '+':
                    case '.':
                        foreach (var value in entries.Value)
                        {
                            baseConfig.Add(section.Key, entries.Key.Substring(1), value.Replace("%GAME%", "XCom"));
                        }
                        break;

                    case '-':
                        foreach (var value in entries.Value)
                        {
                            baseConfig.Remove(section.Key, entries.Key.Substring(1), value.Replace("%GAME%", "XCom"));
                        }
                        break;

                    case '!':
                        // !key=ClearArray
                        baseConfig.Remove(section.Key, entries.Key.Substring(1));
                        break;

                    case ';':
                        break;

                    default:
                        foreach (var value in entries.Value)
                        {
                            baseConfig.Set(section.Key, entries.Key, new List <string> {
                                value
                            });
                        }
                        break;
                    }
                }
            }

            Entries.Clear();
            Entries = baseConfig.Entries;
            UpdateTimestamp(file);
        }
 public async Task AddTimeSheetEntry(TimeSheetEntry entry)
 {
     Entries.Add(entry);
     await SaveChangesAsync();
 }
示例#35
0
        internal Entries ToEntries()
        {
            Entries es = new Entries();

            // is it the sum of all the various items?
            if (this.Items.Count > 0) es.Count = (uint)this.Items.Count;

            foreach (SLEntriesItemsTypeIndexPair pair in this.Items)
            {
                switch (pair.Type)
                {
                    case SLEntriesItemsType.Missing:
                        es.Append(this.MissingItems[pair.Index].ToMissingItem());
                        break;
                    case SLEntriesItemsType.Number:
                        es.Append(this.NumberItems[pair.Index].ToNumberItem());
                        break;
                    case SLEntriesItemsType.Error:
                        es.Append(this.ErrorItems[pair.Index].ToErrorItem());
                        break;
                    case SLEntriesItemsType.String:
                        es.Append(this.StringItems[pair.Index].ToStringItem());
                        break;
                }
            }

            return es;
        }
 private string ConvertEntriesToString(Entries entries)
 {
     var encoded = (from e in entries select this.ReplaceString(e.Key) + EntryPairDelimiter + this.ReplaceString(e.Value)).ToArray();
     var result = string.Join(EntryDelimiter.ToString(), encoded);
     return result;
 }
示例#37
0
 public static string GetBlogPath(Entries entry)
 {
     return GetBlogPath(entry.Date, entry.Title);
 }
示例#38
0
 public void LoadFile(string path)
 {
     FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
     memsize = (int)fileStream.Length;
     memory = new byte[memsize];
     int cnt;
     int sum = 0;
     while ((cnt = fileStream.Read(memory, sum, memsize - sum)) > 0) sum += cnt;
     fileStream.Close();
     fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
     BitConverter.IsLittleEndian = true;
     int magic = ReadInt32(fileStream);
     if (magic != 0x434F4E44)
     {
         fileStream.Close();
         return;
     }
     int version = ReadInt32(fileStream);
     if (version != 1)
     {
         fileStream.Close();
         return;
     }
     UnknownInt16 = ReadInt16(fileStream);
     int count = ReadInt16(fileStream);
     Entry = new List<Entries>();
     listBox1.Items.Clear();
     Entries temp = new Entries();
     for (int i = 0; i < count; i++)
     {
         temp.id = ReadInt32(fileStream);
         temp.off = ReadInt32(fileStream);
         temp.size = -1;
         temp.listoff = i * 8 + 12;
         Entry.Add(temp);
     }
     SortEntries();
     CalcSize(fileStream.Length);
     for (int i = 0; i < count; i++)
     {
         temp = Entry[i];
         temp.data = ReadArray(fileStream, (uint)temp.off, (uint)temp.size);
         Entry[i] = temp;
     }
     SortEntries2();
     for (int i = 0; i < count; i++)
     {
         temp = Entry[i];
         listBox1.Items.Add(temp.id.ToString() + " : " + temp.off.ToString("X") + " = " + temp.size.ToString("X"));
     }
     fileStream.Close();
 }
示例#39
0
 public override void ConfigurePreTaskAction(AsyncTaskSequence sequence)
 {
     sequence.Add(() => s_logger.Info($"Start ImageTagRemoving"));
     sequence.Add(() => s_logger.Info($"      Entries : {Entries.ArrayToString()}"));
     sequence.Add(() => s_logger.Info($"      TagNames : {TagNames.ArrayToString()}"));
 }
示例#40
0
 private Entries GetSystemValues()
 {
     var machineName = System.Environment.MachineName;
     Entries retval = new Entries();
     retval.Add("MachineName", machineName);
     return retval;
 }
示例#41
0
 internal override void GetNames(MSBD msb, Entries entries)
 {
     base.GetNames(msb, entries);
     TreasurePartName = MSB.FindName(entries.Parts, TreasurePartIndex);
 }
示例#42
0
 public Day3(string inputFile)
 {
     Entries = Reader.ReadStrings(inputFile);
     MaxCol  = Entries.First().Length;
 }
示例#43
0
 public IEnumerable <Todo> FindAll()
 {
     return(Entries.Select(todo => todo));
 }
示例#44
0
        internal void FromEntries(Entries es)
        {
            this.SetAllNull();

            SLMissingItem mi;
            SLNumberItem ni;
            SLErrorItem ei;
            SLStringItem si;
            using (OpenXmlReader oxr = OpenXmlReader.Create(es))
            {
                while (oxr.Read())
                {
                    // make sure to add to Items first, because of the Count thing.
                    if (oxr.ElementType == typeof(MissingItem))
                    {
                        mi = new SLMissingItem();
                        mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLEntriesItemsTypeIndexPair(SLEntriesItemsType.Missing, this.MissingItems.Count));
                        this.MissingItems.Add(mi);
                    }
                    else if (oxr.ElementType == typeof(NumberItem))
                    {
                        ni = new SLNumberItem();
                        ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLEntriesItemsTypeIndexPair(SLEntriesItemsType.Number, this.NumberItems.Count));
                        this.NumberItems.Add(ni);
                    }
                    else if (oxr.ElementType == typeof(ErrorItem))
                    {
                        ei = new SLErrorItem();
                        ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLEntriesItemsTypeIndexPair(SLEntriesItemsType.Error, this.ErrorItems.Count));
                        this.ErrorItems.Add(ei);
                    }
                    else if (oxr.ElementType == typeof(StringItem))
                    {
                        si = new SLStringItem();
                        si.FromStringItem((StringItem)oxr.LoadCurrentElement());
                        this.Items.Add(new SLEntriesItemsTypeIndexPair(SLEntriesItemsType.String, this.StringItems.Count));
                        this.StringItems.Add(si);
                    }
                }
            }
        }
示例#45
0
 public override List <LineEntry> GetSortedEntries()
 {
     return(Entries
            .OrderBy(entry => entry.Position)
            .ToList());
 }
示例#46
0
        private string GenerateApi(DirectoryList.ItemsData api)
        {
            var tmpl = new Template();
            tmpl.Add("|| *{VERSION}* | [{URL_BINARY} {FILE_BINARY}]  ([{URL_SOURCE} Source]) | [{URL_XML} XmlDoc] ||");
            tmpl.Add("|| [{URL_DOCU} Documentation] | " +
                     "[https://code.google.com/apis/explorer/#_s={NAME}&_v={VERSION} APIs Explorer] ||");
            string formalName = api.Name.ToUpperFirstChar();
            string formalVersion = api.Version;
            string binFileName = string.Format("Google.Apis.{0}.{1}.dll", formalName, formalVersion);

            // Fill in the data.
            const string RELEASE_DIR = "http://contrib.google-api-dotnet-client.googlecode.com/hg/Stable";
            const string BINARY_PATH = RELEASE_DIR + "/Generated/Bin/{0}Service/{1}";
            var data = new Entries();
            data.Add("URL_DOCU", api.DocumentationLink);
            data.Add("URL_BINARY", BINARY_PATH, formalName, binFileName);
            data.Add("URL_XML", BINARY_PATH, formalName, Path.ChangeExtension(binFileName, ".xml"));
            data.Add("FILE_BINARY", binFileName);
            data.Add("URL_SOURCE", RELEASE_DIR + "/Generated/Source/{0}", Path.ChangeExtension(binFileName, ".cs"));
            data.Add("NAME", api.Name);
            data.Add("VERSION", api.Version);
            return tmpl.ToString(data);
        }
示例#47
0
 internal virtual void GetNames(MSBD msb, Entries entries)
 {
     PartName   = MSB.FindName(entries.Parts, PartIndex);
     RegionName = MSB.FindName(entries.Regions, RegionIndex);
 }
示例#48
0
 internal virtual void GetIndices(MSBD msb, Entries entries)
 {
     PartIndex   = MSB.FindIndex(entries.Parts, PartName);
     RegionIndex = MSB.FindIndex(entries.Regions, RegionName);
 }
示例#49
0
        /// <summary>
        /// sort the leader board based on score
        /// returns the sorted leaderboard
        /// </summary>
        /// <returns></returns>
        private Entries SortLeaderBoard(Entries board)
        {
            //using a quick sort algorythm to sort the leaderboard
            //reference from http://www.sorting-algorithms.com/quick-sort
            // and http://www.sorting-algorithms.com/static/QuicksortIsOptimal.pdf
            //http://betterexplained.com/articles/sorting-algorithms/

            Entries lesser = new Entries();
            Entries greater = new Entries();            

            //get random pivot to work with
            Random rnd = new Random();
            int pivotIndex = rnd.Next(board.m_names.Count); // creates a number between 0 and entries length
            pivotIndex = 1; //debug ovverride
            String pivotName = board.m_names[pivotIndex];
            int pivotScore = board.m_scores[pivotIndex];
            board.m_names.RemoveAt(pivotIndex); //remove the pivot entry from the index
            board.m_scores.RemoveAt(pivotIndex); //
            
            //sort the board into greater/lesser fields            
            for (int i = 0; i < board.m_scores.Count; i++)
            {
                if (board.m_scores[i] >= pivotScore)
                {
                    lesser.m_scores.Add(board.m_scores[i]);
                    lesser.m_names.Add(board.m_names[i]);
                }
                else
                {
                    greater.m_scores.Add(board.m_scores[i]);
                    greater.m_names.Add(board.m_names[i]);
                }
            }

            //check if we are done, if not recursivly go till we are
            if (lesser.m_scores.Count > 1)
                lesser = SortLeaderBoard(lesser);

            if (greater.m_scores.Count > 1)
                greater = SortLeaderBoard(greater);

            //build the resulting entry and return it
            Entries result = new Entries();

            result.m_names.AddRange(lesser.m_names);
            result.m_names.Add(pivotName);
            result.m_names.AddRange(greater.m_names);

            result.m_scores.AddRange(lesser.m_scores);
            result.m_scores.Add(pivotScore);
            result.m_scores.AddRange(greater.m_scores);

            return result;
        }