public ChallengePageComponent() { mifnexsoEntities = new MIFNEXSOEntities(); challengePage = new ChallengePage(); challengePage.ChallengePageId = Guid.Empty; challengePage.ChallengeCustomDataId = Guid.Empty; mifnexsoEntities.ChallengePages.AddObject(challengePage); }
private void mnuChallengeFolderAdd_Click(object sender, EventArgs e) { ChallengePage challengePage = new ChallengePage(); challengePage.Title = "Untitled Challenge Page"; mPack.ChallengePages.Add(challengePage); ChallengeFolderNode.Nodes.Add(GetChallengePageNode(challengePage)); }
public ChallengePageForm(ChallengePage page) { mPage = page; InitializeComponent(); txtTitle.Text = page.Title; txtDescription.Text = page.Description; txtSmallDesc.Text = page.SmallDescription; }
private void mnuChallengePageAdd_Click(object sender, EventArgs e) { ChallengePage challengePage = SelectedNode.Tag as ChallengePage; Challenge challenge = new Challenge(); challenge.Name = "Untitled Challenge"; challengePage.Challenges.Add(challenge); SelectedNode.Nodes.Add(GetChallengeNode(challenge)); }
private void mnuChallengePageProperties_Click(object sender, EventArgs e) { ChallengePage challengePage = SelectedNode.Tag as ChallengePage; ChallengePageForm form = new ChallengePageForm(challengePage); if (form.ShowDialog() == DialogResult.OK) { //Challenge page name may have changed SelectedNode.Text = challengePage.Title; } }
private TreeNode GetChallengePageNode(ChallengePage challengePage) { TreeNode cpnode = new TreeNode(challengePage.Title); cpnode.ImageIndex = cpnode.SelectedImageIndex = IMG_KEY_FOLDER_CHALLENGES; cpnode.Tag = challengePage; foreach (Challenge challenge in challengePage.Challenges) { cpnode.Nodes.Add(GetChallengeNode(challenge)); } return(cpnode); }
private void mnuChallengePageDelete_Click(object sender, EventArgs e) { ChallengePage challengePage = SelectedNode.Tag as ChallengePage; DialogResult result = MessageBox.Show(challengePage.Title + " will be deleted permenently?", "Delete Challenge Page", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { //Remove from pack mParent.LevelPack.ChallengePages.Remove(challengePage); //Remove node from tree mTreeView.Nodes.Remove(SelectedNode); } }
/// <summary> /// Load Pages per Challenge Reference /// </summary> /// <param name="challengeCustomDataId"></param> /// <param name="reference"></param> public ChallengePageComponent(Guid challengeCustomDataId, string reference) { if (challengeCustomDataId != Guid.Empty && !string.IsNullOrEmpty(reference)) { mifnexsoEntities = new MIFNEXSOEntities(); try { challengePage = mifnexsoEntities.ChallengePages.FirstOrDefault(a => a.ChallengeCustomDataId == challengeCustomDataId && a.Reference == reference); if (challengePage == null) { challengePage = new ChallengePage(); challengePage.ChallengePageId = Guid.Empty; challengePage.ChallengeCustomDataId = Guid.Empty; mifnexsoEntities.ChallengePages.AddObject(challengePage); } } catch (Exception) { throw; } } }
public ChallengePageComponent(Guid challengePageId) { if (challengePageId != Guid.Empty) { mifnexsoEntities = new MIFNEXSOEntities(); try { challengePage = mifnexsoEntities.ChallengePages.FirstOrDefault(a => a.ChallengePageId == challengePageId); if (challengePage == null) { challengePage = new ChallengePage(); challengePage.ChallengePageId = Guid.Empty; challengePage.ChallengeCustomDataId = Guid.Empty; mifnexsoEntities.ChallengePages.AddObject(challengePage); } } catch (Exception) { throw; } } }
private void ShowChallengePage(Challenge challenge, bool noMoreChallenges, bool startChallenge, bool showMessageIfSkipChallenge, bool showActionButtons = true) { int points = int.Parse(_configuration.ReadProperty("Points") ?? "0"); SaveEventData(new DistractionEventData() { EventType = startChallenge ? DistractionEventType.StartChallenge : DistractionEventType.ChangeChallenge, Time = DateTime.UtcNow, UserId = _configuration.UserId, Data = $"Challenge type: { challenge.Type }, Challenge Id: { challenge.Id }", }); ChallengePage challengePage = new ChallengePage(_configuration, challenge, noMoreChallenges, points, showMessageIfSkipChallenge, showActionButtons); //selectChallengeTypePage.BackButtonPressed += () => { ShowSelectFirstEmotionalStatusPage(); }; challengePage.EnableBackButton = false; //selectChallengeTypePage.NextButtonPressed += () => { ShowChallengePage(); }; challengePage.EnableNextButton = false; challengePage.ShowNavigationBarOnEntry = false; challengePage.AnimateNavigationBarOnEntry = false; challengePage.AnimateNavigationBarOnBack = false; challengePage.AnimateNavigationBarOnNext = false; challengePage.ChallengeNoMore += () => { var completedDB = PositiveThingsDatabase.GetChallengesCompleted(); foreach (Challenge ch in _challenges) { if (ch.Completed) { if (_configuration.ReadBoolProperty("personal") && ch.TypeCheck.Contains("1")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("acertijos") && ch.TypeCheck.Contains("2")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("enigmas") && ch.TypeCheck.Contains("3")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("diferencias") && ch.TypeCheck.Contains("4")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("sopas") && ch.TypeCheck.Contains("5")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("relacionarme") && ch.TypeCheck.Contains("6")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("moverme") && ch.TypeCheck.Contains("7")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("musica") && ch.TypeCheck.Contains("8")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } if (_configuration.ReadBoolProperty("relax") && ch.TypeCheck.Contains("9")) { PositiveThingsDatabase.RemoveChallengeCompletedId(ch.Id); ch.Completed = false; continue; } } } var completedDB2 = PositiveThingsDatabase.GetChallengesCompleted(); //Task.Run(() => ShowChallengePage()); //Device.BeginInvokeOnMainThread(() => ShowChallengePage()); _currentChallenges = null; ShowChallengePage(); }; challengePage.ChallengeSkipped += () => { Task.Run(() => /*ShowChallengePage(challenge.Type)*/ ShowChallengePage()); }; challengePage.ChallengeEnd += (challengeResult) => { _currentChallenges = null; _currentChallengeIndex = 0; var cc = new ChallengeCompleted() { ChallengeId = challengeResult.ChallengeId }; PositiveThingsDatabase.SaveChallengeCompleted(cc); var ch = _challenges.First(x => x.Id == cc.ChallengeId); ch.Completed = true; int totaPoints = Math.Max(0, int.Parse(_configuration.ReadProperty("Points") ?? "0") + challengeResult.ChallengePoints); _configuration.SaveProperty("Points", totaPoints.ToString()); SaveEventDataSync(new DistractionEventData() { EventType = DistractionEventType.EndChallenge, Time = DateTime.UtcNow, UserId = _configuration.UserId, Data = challengeResult.ToString(), }); return(_configuration.ReadProperty("ranking")); }; challengePage.ChallengeExit += (continuePlaying) => { if (continuePlaying) { //ShowSelectChallengeTypePage(); ShowChallengePage(); /*TabbedPage1 tabbed = new TabbedPage1(_configuration); * * Device.BeginInvokeOnMainThread(() => { Xamarin.Forms.Application.Current.MainPage = tabbed; });*/ } else { ShowSelectEndEmotionalStatusPage(); } }; challengePage.Initialize(); //await currentPage.Navigation.PushModalAsync(selectNegativeTagFirstLevelSummaryPage, false); Device.BeginInvokeOnMainThread(() => { Xamarin.Forms.Application.Current.MainPage = challengePage; }); //await Task.Delay(1000); //Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Task.Delay(1000); }); //await Task.Delay(1000); currentPage = challengePage; }
private TreeNode GetChallengePageNode(ChallengePage challengePage) { TreeNode cpnode = new TreeNode(challengePage.Title); cpnode.ImageIndex = cpnode.SelectedImageIndex = IMG_KEY_FOLDER_CHALLENGES; cpnode.Tag = challengePage; foreach (Challenge challenge in challengePage.Challenges) { cpnode.Nodes.Add(GetChallengeNode(challenge)); } return cpnode; }
protected string createContext(ChallengeCustomData challengeCustomData, ChallengePage challengePage) { //main contenxt NZChallengePage.ContextPage objReturn = new NZChallengePage.ContextPage(); objReturn.ChallengeCustomDatalId = challengeCustomData.ChallengeCustomDatalId.ToString(); objReturn.ChallengeReference = challengeCustomData.ChallengeReference; objReturn.SolutionType = solutionType; objReturn.Description = challengeCustomData.Description; objReturn.Language = challengeCustomData.Language; objReturn.TagLine = challengeCustomData.TagLine; objReturn.Tags = challengeCustomData.Tags; objReturn.Title = challengeCustomData.Title; ChallengeComponent challengeComponent = new ChallengeComponent(challengeCustomData.ChallengeReference); var file = challengeComponent.Challenge.ChallengeFiles.FirstOrDefault(x => x.Language == challengeCustomData.Language && x.ObjectType == "Banner Challenge" && (x.Delete == null || x.Delete == false)); if (file != null) { objReturn.BannerImage = file.ObjectLocation; } objReturn.ChallengeSchemaContext = new ChallengeSchemaContext(); objReturn.ChallengeSchemaContext.Closed = challengeCustomData.ChallengeSchema.Closed.GetValueOrDefault(DateTime.MinValue).ToString();; objReturn.ChallengeSchemaContext.EnterUrl = challengeCustomData.ChallengeSchema.EnterUrl; objReturn.ChallengeSchemaContext.EntryFrom = challengeCustomData.ChallengeSchema.EntryFrom.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.EntryTo = challengeCustomData.ChallengeSchema.EntryTo.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.Flavor = challengeCustomData.ChallengeSchema.Flavor; objReturn.ChallengeSchemaContext.Launch = challengeCustomData.ChallengeSchema.Launch.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.OutUrl = challengeCustomData.ChallengeSchema.OutUrl; objReturn.ChallengeSchemaContext.PreLaunch = challengeCustomData.ChallengeSchema.PreLaunch.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.PublishType = challengeCustomData.ChallengeSchema.PublishType; objReturn.ChallengeSchemaContext.ScoringL1From = challengeCustomData.ChallengeSchema.ScoringL1From.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.ScoringL2From = challengeCustomData.ChallengeSchema.ScoringL2From.GetValueOrDefault(DateTime.MinValue).ToString(); objReturn.ChallengeSchemaContext.Url = challengeCustomData.ChallengeSchema.Url; var judgesPage = challengeCustomData.ChallengePages.SingleOrDefault(a => a.Reference == "judges"); if (judgesPage != null) { objReturn.Judges = GetGenericObjectList(judgesPage.Content); } objReturn.Dictionary = GetGenericListDictionary(challengeCustomData.Tags); objReturn.TimesLine = GenerateTimeLine(challengeCustomData, objReturn.Dictionary); objReturn.CurrentPageContext = new CurrentPageContext(); objReturn.CurrentPageContext.ChallengePageId = challengePage.ChallengePageId.ToString(); objReturn.CurrentPageContext.Content = challengePage.Content; objReturn.CurrentPageContext.ContentType = challengePage.ContentType; objReturn.CurrentPageContext.Description = challengePage.Description; objReturn.CurrentPageContext.Order = challengePage.Order.GetValueOrDefault(0).ToString(); objReturn.CurrentPageContext.Reference = challengePage.Reference; objReturn.CurrentPageContext.Tagline = challengePage.Tagline; objReturn.CurrentPageContext.Title = challengePage.Title; objReturn.CurrentPageContext.Url = challengePage.Url; objReturn.CurrentPageContext.Visibility = challengePage.Visibility; objReturn.Eligibility = GetGenericElegibility(challengeCustomData.EligibilityTemplate); switch (challengePage.Reference) { case "judges": { objReturn.CurrentPageContext.GenericObject = objReturn.Judges; break; } case "faq": { objReturn.CurrentPageContext.GenericObject = GetGenericFAQ(challengePage.Content); break; } case "partners": { objReturn.CurrentPageContext.GenericObject = GetGenericObjectList(challengePage.Content); break; } } objReturn.PagesContext = new List <PagesContext>(); foreach (var item in challengeCustomData.ChallengePages.OrderBy(a => a.Order)) { if (item.Title != string.Empty) { objReturn.PagesContext.Add(new PagesContext { Tagline = item.Tagline, Title = item.Title, Url = item.Url, Visibility = item.Visibility }); } } return(JsonConvert.SerializeObject(objReturn)); }