void ReleaseDesignerOutlets() { if (btnFavJob != null) { btnFavJob.Dispose(); btnFavJob = null; } if (CategoryImageView != null) { CategoryImageView.Dispose(); CategoryImageView = null; } if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (ContractType != null) { ContractType.Dispose(); ContractType = null; } if (ContractTypeImgView != null) { ContractTypeImgView.Dispose(); ContractTypeImgView = null; } if (datePostedLabel != null) { datePostedLabel.Dispose(); datePostedLabel = null; } if (lblNew != null) { lblNew.Dispose(); lblNew = null; } if (LocationLabel != null) { LocationLabel.Dispose(); LocationLabel = null; } if (titleLabel != null) { titleLabel.Dispose(); titleLabel = null; } }
void ReleaseDesignerOutlets() { if (CallButton != null) { CallButton.Dispose(); CallButton = null; } if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (CommunityLabel != null) { CommunityLabel.Dispose(); CommunityLabel = null; } if (DayCountLabel != null) { DayCountLabel.Dispose(); DayCountLabel = null; } if (EmailButton != null) { EmailButton.Dispose(); EmailButton = null; } if (ProspectLabel != null) { ProspectLabel.Dispose(); ProspectLabel = null; } if (SMSButton != null) { SMSButton.Dispose(); SMSButton = null; } if (TaskDueLabel != null) { TaskDueLabel.Dispose(); TaskDueLabel = null; } if (TaskLabel != null) { TaskLabel.Dispose(); TaskLabel = null; } }
public ColoredTableViewCell(string reuseIdentifier, SizeF size) : base(UITableViewCellStyle.Default, reuseIdentifier) { //edge aanpassen met 2 pixels aan de linker BackgroundColor = UIColor.Clear; CategoryLabel = new CategoryLabel(new RectangleF(size.Width - 50 - (size.Height), 10, size.Height * 1.5f, size.Height - 20)); AddSubview(CategoryLabel); // ColorView = new UIView(new RectangleF(size.Width - 50 - (size.Height), 5, size.Height, size.Height - 10)); // ColorView.Layer.CornerRadius = 4f; // AddSubview(ColorView); }
void ReleaseDesignerOutlets() { if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (ClearWritingBarButton != null) { ClearWritingBarButton.Dispose(); ClearWritingBarButton = null; } if (ConvertWritingBarButton != null) { ConvertWritingBarButton.Dispose(); ConvertWritingBarButton = null; } if (HandwritingContainerView != null) { HandwritingContainerView.Dispose(); HandwritingContainerView = null; } if (HandwritingToolbar != null) { HandwritingToolbar.Dispose(); HandwritingToolbar = null; } if (NoteErrorLabel != null) { NoteErrorLabel.Dispose(); NoteErrorLabel = null; } if (NoteTextView != null) { NoteTextView.Dispose(); NoteTextView = null; } if (RankingTextField != null) { RankingTextField.Dispose(); RankingTextField = null; } }
void ReleaseDesignerOutlets() { if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (RSSItemTable != null) { RSSItemTable.Dispose(); RSSItemTable = null; } }
void ReleaseDesignerOutlets() { if (AircraftLabel != null) { AircraftLabel.Dispose(); AircraftLabel = null; } if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (ClassificationLabel != null) { ClassificationLabel.Dispose(); ClassificationLabel = null; } if (CloseButton != null) { CloseButton.Dispose(); CloseButton = null; } if (ConklinImageView != null) { ConklinImageView.Dispose(); ConklinImageView = null; } if (SpecDescriptionLabel != null) { SpecDescriptionLabel.Dispose(); SpecDescriptionLabel = null; } if (SpecImage != null) { SpecImage.Dispose(); SpecImage = null; } if (SpecTableView != null) { SpecTableView.Dispose(); SpecTableView = null; } }
private void PositionElements() { Body.Position = new Point(Background.Graphic.LeftBorderThickness, Background.Graphic.TopBorderThickness); // Figure out width Body.Width = ToggleBag.Width; TopRow.Width = Body.Width; // Width = Body.Width + Background.Graphic.LeftBorderThickness + Background.Graphic.RightBorderThickness + Padding * 2; // Build the top row var longestCat = Categories.OrderByDescending(s => s.Length).First(); var headerWidth = (int)HeaderFont.MeasureString(longestCat).X; NextButton.X = TopRow.Width / 2 + headerWidth / 2; PrevButton.X = TopRow.Width / 2 - PrevButton.Width - headerWidth / 2; SelectAllButton.X = Padding; CategoryLabel.Text = ActiveCategory; CategoryLabel.CenterHorizontally(); TopRow.Height = TopRow.Children.Max(c => c.Height); foreach (var child in TopRow.Children) { child.Y = TopRow.Height / 2 - child.Height / 2; } // Figure out height and vertical positioning ToggleBag.Y = TopRow.Y + TopRow.Height + Padding; Body.Height = ToggleBag.Y + ToggleBag.Height; Height = TopRow.Height + Game1.tileSize * MaxItemRows + Padding * (MaxItemRows - 1) + Background.Graphic.TopBorderThickness + Background.Graphic.BottomBorderThickness + Padding * 2; Background.Width = Width; Background.Height = Height; CloseButton.Position = new Point(Width - CloseButton.Width, 0); ScrollBar.Position = new Point(Width - 64 - 3 * 4, CloseButton.Height); ScrollBar.Height = Height - CloseButton.Height - 16; ScrollBar.Visible = NumItems > MaxItemsPage; ScrollBar.ScrollPosition = 0; ScrollBar.ScrollMax = NumItems; ScrollBar.Step = MaxItemsPage; }
//Shows Converter Menu private void ShowConverter() { //Show the converter menu's controls and labels CategoryLabel.Show(); CategoryComboBox.Show(); InstructionLabel.Show(); ValueOfLabel.Show(); UserInputTextBox.Show(); FromLabel.Show(); InitialUnitsComboBox.Show(); ToLabel.Show(); ResultingUnitsComboBox.Show(); BackButtonLabel.Show(); BackButton.Show(); DividerLabel.Show(); UserInputTextBox.Focus(); }
void ReleaseDesignerOutlets() { if (MainLabel != null) { MainLabel.Dispose(); MainLabel = null; } if (RunButton != null) { RunButton.Dispose(); RunButton = null; } if (StatisticsLabel != null) { StatisticsLabel.Dispose(); StatisticsLabel = null; } if (StatusLabel != null) { StatusLabel.Dispose(); StatusLabel = null; } if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (StopButton != null) { StopButton.Dispose(); StopButton = null; } }
//Hides Converter Menu private void HideConverter() { CategoryLabel.Hide(); CategoryComboBox.Hide(); InstructionLabel.Hide(); ValueOfLabel.Hide(); UserInputTextBox.Hide(); FromLabel.Hide(); InitialUnitsComboBox.Hide(); ToLabel.Hide(); ResultingUnitsComboBox.Hide(); ConvertSubmissionButton.Hide(); BackButtonLabel.Hide(); BackButton.Hide(); DividerLabel.Hide(); InitialValueLabel.Hide(); InitialUnitsLabel.Hide(); EqualsLabel.Hide(); ResultingUnitsLabel.Hide(); ResultingValueLabel.Hide(); //When navigating back to the main menu its important to clear the field values for the ComboBoxes ClearUnitsComboBoxes(); }
/// <summary> /// Formのコンストラクタからインスタンス生成するだけ。 /// 2回目以降エラー返し。 /// </summary> /// <param name="formParent">null不可</param> public MainFlowLayoutPanel(MainForm formParent) { if (flgCreated) { throw new Exception("一回しか呼べません"); } else { flgCreated = true; } form = formParent; form.Controls.Add(this); FlowDirection = FlowDirection.TopDown; Width = 800; Height = 600; new TabFlowLayoutPanel(this); lbCate = new CategoryLabel(this); lbCate.DoubleClick += OnDoubleClick_Category; new MainPanel(this); form.Load += OnLoad_readTSV; }
//Overrided method accepting a category parameter obtained from menu selection private void ShowConverter(String category) { //Shows the converter menu's controls and labels CategoryLabel.Show(); CategoryComboBox.Show(); InstructionLabel.Show(); ValueOfLabel.Show(); UserInputTextBox.Show(); FromLabel.Show(); InitialUnitsComboBox.Show(); ToLabel.Show(); ResultingUnitsComboBox.Show(); ConvertSubmissionButton.Show(); BackButtonLabel.Show(); BackButton.Show(); DividerLabel.Show(); //Selects the category field in the converter CategoryComboBox.SelectedIndex = CategoryComboBox.FindStringExact(category); //Shows the default units of measurement ShowDefaultUnits(category); UserInputTextBox.Focus(); }
private void PositionElements() { Body.Position = new Point(Background.Graphic.LeftBorderThickness, Background.Graphic.RightBorderThickness); // Figure out width Body.Width = ToggleBag.Width; TopRow.Width = Body.Width; Width = Body.Width + Background.Graphic.LeftBorderThickness + Background.Graphic.RightBorderThickness + Padding * 2; // Build the top row var longestCat = Categories.OrderByDescending(s => s.Length).First(); var headerWidth = (int)HeaderFont.MeasureString(longestCat).X; NextButton.X = TopRow.Width / 2 + headerWidth / 2; PrevButton.X = TopRow.Width / 2 - PrevButton.Width - headerWidth / 2; SelectAllButton.X = Padding; CategoryLabel.CenterHorizontally(); TopRow.Height = TopRow.Children.Max(c => c.Height); foreach (var child in TopRow.Children) { child.Y = TopRow.Height / 2 - child.Height / 2; } // Figure out height and vertical positioning ToggleBag.Y = TopRow.Y + TopRow.Height + Padding; Body.Height = ToggleBag.Y + ToggleBag.Height; Height = (Body.Height + Background.Graphic.TopBorderThickness + Background.Graphic.BottomBorderThickness + Padding * 2); Background.Width = Width; Background.Height = Height; CloseButton.Position = new Point(Width - CloseButton.Width, 0); }
public override Variable[] Read() { if (this.Document == null) { throw new Exception("File not validated yet."); } Dictionary <string, Variable> variables = new Dictionary <string, Variable>(); Dictionary <string, Dictionary <string, Guid> > categories = new Dictionary <string, Dictionary <string, Guid> >(); base.Status = BaseClasses.DataImportStatus.Step4; base.Progress = 0; XmlNodeList xmlNodes = this.Document.DocumentElement.SelectNodes("Variables/Variable"); Variable variable; VariableLabel variableLabel; Category category; CategoryLabel categoryLabel; int i = 0; StringBuilder query = new StringBuilder(); foreach (XmlNode xmlNode in xmlNodes) { variable = new Variable(base.Core.Variables); variable.Name = xmlNode.Attributes["Name"].Value; variable.IdStudy = base.Study.Id; variable.Type = (VariableType)Enum.Parse( typeof(VariableType), xmlNode.Attributes["Type"].Value ); variable.Insert(); variableLabel = new VariableLabel(base.Core.VariableLabels); variableLabel.IdVariable = variable.Id; variableLabel.Label = xmlNode.SelectSingleNode("Label").InnerText; variableLabel.IdLanguage = base.IdLanguage; variableLabel.Insert(); if (!variables.ContainsKey(variable.Name)) { variables.Add(variable.Name, variable); categories.Add(variable.Name, new Dictionary <string, Guid>()); } // Create the responses database table for the variable. CreateResponsesTable(variable); query.Clear(); foreach (XmlNode xmlNodeCategory in xmlNode.ChildNodes) { if (xmlNodeCategory.Name != "Category") { continue; } category = new Category(base.Core.Categories); category.IdVariable = variable.Id; category.Name = xmlNodeCategory.Attributes["Name"].Value; query.Append(category.RenderInsertQuery()); //category.Insert(); if (!categories[variable.Name].ContainsKey(category.Name)) { categories[variable.Name].Add(category.Name, category.Id); } categoryLabel = new CategoryLabel(base.Core.CategoryLabels); categoryLabel.IdCategory = category.Id; categoryLabel.Label = xmlNodeCategory.InnerText; categoryLabel.IdLanguage = base.IdLanguage; //categoryLabel.Insert(); query.Append(categoryLabel.RenderInsertQuery()); if (query.Length >= 200000) { base.Core.Categories.ExecuteQuery(query.ToString()); query.Clear(); } } if (query.Length > 0) { base.Core.Categories.ExecuteQuery(query.ToString()); } // Calculate the current reading progress. base.Progress = (int)(i++ *100 / xmlNodes.Count); } base.Progress = 100; base.Status = BaseClasses.DataImportStatus.Step5; base.Progress = 0; Dictionary <string, Guid> respondents = new Dictionary <string, Guid>(); query.Clear(); xmlNodes = this.Document.DocumentElement.SelectNodes("Respondents/Respondent"); foreach (XmlNode xmlNode in xmlNodes) { Respondent respondent = new Respondent(base.Core.Respondents); respondent.IdStudy = base.Study.Id; respondent.OriginalRespondentID = xmlNode.Attributes["Id"].Value; query.Append(respondent.RenderInsertQuery()); if (!respondents.ContainsKey(respondent.OriginalRespondentID)) { respondents.Add(respondent.OriginalRespondentID, respondent.Id); } if (query.Length >= 200000) { base.Core.Respondents.ExecuteQuery(query.ToString()); query.Clear(); } } if (query.Length > 0) { base.Core.Respondents.ExecuteQuery(query.ToString()); } base.Status = BaseClasses.DataImportStatus.Step6; base.Progress = 0; query.Clear(); xmlNodes = this.Document.DocumentElement.SelectNodes("Responses/Response"); i = 0; Variable v; foreach (XmlNode xmlNode in xmlNodes) { v = variables[xmlNode.Attributes["Variable"].Value]; if (v.Type == VariableType.Numeric) { query.Append(string.Format( "INSERT INTO [resp].[Var_{0}] (Id, IdRespondent, IdStudy, NumericAnswer) VALUES (NEWID(), '{1}', '{2}', '{3}')" + Environment.NewLine, v.Id, respondents[xmlNode.Attributes["Respondent"].Value], base.Study.Id, double.Parse(xmlNode.Attributes["Category"].Value) )); } else if (v.Type == VariableType.Text) { query.Append(string.Format( "INSERT INTO [resp].[Var_{0}] (Id, IdRespondent, IdStudy, TextAnswer) VALUES (NEWID(), '{1}', '{2}', '{3}')" + Environment.NewLine, v.Id, respondents[xmlNode.Attributes["Respondent"].Value], base.Study.Id, xmlNode.Attributes["Category"].Value.Replace("'", "''") )); } else { query.Append(string.Format( "INSERT INTO [resp].[Var_{0}] (Id, IdRespondent, IdStudy, IdCategory) VALUES (NEWID(), '{1}', '{2}', '{3}')" + Environment.NewLine, v.Id, respondents[xmlNode.Attributes["Respondent"].Value], base.Study.Id, categories[xmlNode.Attributes["Variable"].Value][xmlNode.Attributes["Category"].Value] )); } if (xmlNodes.Count <= 100 || i % (xmlNodes.Count / 100) == 0) { base.Core.Respondents.ExecuteQuery(query.ToString()); query.Clear(); base.Progress = ((i++ *100) / (double)xmlNodes.Count); } } if (query.Length != 0) { base.Core.Respondents.ExecuteQuery(query.ToString()); query.Clear(); } base.Progress = 100; return(variables.Values.ToArray()); }
public override Variable[] Read() { ExcelReader reader = new ExcelReader(this.FileName); // Create a new list of variables for the result. List <Variable> result = new List <Variable>(); base.Status = BaseClasses.DataImportStatus.Step4; base.Progress = 0; Dictionary <string, Dictionary <string, int> > variables = new Dictionary <string, Dictionary <string, int> >(); int columnCount = 0; while (true) { if (string.IsNullOrEmpty(reader[columnCount])) { break; } columnCount++; } int respondentVariableIndex = 0; int lineCount = 0; while (reader.Read()) { for (int i = 0; i < columnCount; i++) { string variableName = reader[0, i]; if (variableName == this.RespondentVariable) { respondentVariableIndex = i; } if (string.IsNullOrEmpty(reader[0])) { break; } string category = reader[i]; if (string.IsNullOrEmpty(category)) { continue; } if (!variables.ContainsKey(variableName)) { variables.Add(variableName, new Dictionary <string, int>()); } if (variables[variableName].ContainsKey(category)) { variables[variableName][category]++; } else { variables[variableName].Add(category, 1); } } lineCount++; } base.Status = BaseClasses.DataImportStatus.Step4; base.Progress = 0; int variableOrder = 0; foreach (string variableName in variables.Keys) { VariableType variableType = VariableType.Single; /*if (variableName.Contains("LiNK_Var_Type_")) * { * variableType = (VariableType)Enum.Parse( * typeof(VariableType), * variableName.Split( * ); * }*/ //int typeCheck = variables[variableName].Values.Count(x => x > 1); int test = variables[variableName].Keys.Count * 10 / 100; int typeCheck = variables[variableName].Values.Count(x => x > test); if (typeCheck == 0) { variableType = VariableType.Text; } bool isNumeric = true; foreach (string category in variables[variableName].Keys) { double value; if (double.TryParse(category, out value) == false && category != "") { isNumeric = false; break; } if (category.Contains(" ")) { variableType = VariableType.Text; break; } } if (isNumeric) { variableType = VariableType.Numeric; } // Create a new variable. Variable variable = new Variable(base.Core.Variables); // Set the variable's project id. variable.IdStudy = base.Study.Id; // Set the variable's values. variable.Name = variableName.Replace(" ", ""); variable.Type = variableType; variable.Order = variableOrder++; // Lock the insert action. lock (this) { // Insert the new variable into the database. variable.Insert(); } // Create a new variable label. VariableLabel variableLabel = new VariableLabel(this.Core.VariableLabels); variableLabel.Label = variableName; variableLabel.IdLanguage = 2057; variableLabel.IdVariable = variable.Id; // Lock the insert action. lock (this) { // Insert the new variable label into the database. variableLabel.Insert(); } this.Categories.Add(variable.Id, new Dictionary <string, Guid>()); if (variable.Type != VariableType.Numeric && variable.Type != VariableType.Text) { int categoryOrder = 0; // Run through all parsed categories of the variable. foreach (string categoryNames in variables[variableName].Keys) { foreach (string categoryName in categoryNames.Split(',')) { if (this.Categories[variable.Id].ContainsKey(categoryName.Replace(" ", "_"))) { continue; } // Create a new category. Category category = new Category(base.Core.Categories); // Set the category's variable id. category.IdVariable = variable.Id; // Set the category's values. category.Name = categoryName.Replace(" ", "_"); //category.Factor = (categoryOrder + 1); category.Value = (categoryOrder + 1); category.Order = categoryOrder++; // Lock the insert action. lock (this) { // Insert the new variable into the database. category.Insert(); } // Create a new category label. CategoryLabel categoryLabel = new CategoryLabel(this.Core.CategoryLabels); categoryLabel.Label = categoryName; categoryLabel.IdLanguage = 2057; categoryLabel.IdCategory = category.Id; // Lock the insert action. lock (this) { // Insert the new category label into the database. categoryLabel.Insert(); } this.Categories[variable.Id].Add(category.Name, category.Id); } } } this.Variables.Add(variable.Name, variable); // Calculate the current reading progress. base.Progress = (int)(variableOrder * 100 / variables.Count); } base.Progress = 100; base.Status = BaseClasses.DataImportStatus.Step5; base.Progress = 0; StringBuilder bulkInsertBuilder = new StringBuilder(); int insertSteps = lineCount / 100; if (insertSteps == 0) { insertSteps = 1; } reader.Position = 0; while (reader.Read()) { if (string.IsNullOrEmpty(reader[respondentVariableIndex])) { break; } string respondentId = reader[respondentVariableIndex]; Respondent respondent = new Respondent(this.Core.Respondents); respondent.OriginalRespondentID = respondentId; respondent.IdStudy = this.Study.Id; //respondent.Insert(); bulkInsertBuilder.Append(respondent.RenderInsertQuery()); bulkInsertBuilder.Append(Environment.NewLine); this.Respondents.Add(respondentId, respondent.Id); if (reader.Position % insertSteps == 0) { this.Core.Respondents.ExecuteQuery(bulkInsertBuilder.ToString()); bulkInsertBuilder = new StringBuilder(); base.Progress = reader.Position * 100 / lineCount; } } if (bulkInsertBuilder.Length > 0) { this.Core.Respondents.ExecuteQuery(bulkInsertBuilder.ToString()); } base.ResponseInsertStarted = DateTime.Now; base.Status = BaseClasses.DataImportStatus.Step6; base.Progress = 0; reader.Position = 0; List <Guid> createdResponsesTables = new List <Guid>(); Dictionary <string, StringBuilder> responseBulkInsertBuilder = new Dictionary <string, StringBuilder>(); while (reader.Read()) { for (int i = 0; i < columnCount; i++) { string variableName = reader[0, i].Replace(" ", ""); if (!this.Variables.ContainsKey(variableName)) { continue; } if (!responseBulkInsertBuilder.ContainsKey(variableName)) { responseBulkInsertBuilder.Add(variableName, new StringBuilder()); } if (!createdResponsesTables.Contains(this.Variables[variableName].Id)) { // Create the responses database table for the variable. CreateResponsesTable(this.Variables[variableName]); createdResponsesTables.Add(this.Variables[variableName].Id); } if (string.IsNullOrEmpty(reader[0])) { break; } string[] values = new string[] { reader[i].Replace(" ", "_") }; if (this.Variables[variableName].Type == VariableType.Single || this.Variables[variableName].Type == VariableType.Multi) { values = values[0].Split(','); } foreach (string value in values) { Response response = new Response(this.Core.Responses[this.Variables[variableName].Id]); response.IdRespondent = this.Respondents[reader[respondentVariableIndex]]; response.IdStudy = this.Study.Id; switch (this.Variables[variableName].Type) { case VariableType.Text: response.TextAnswer = value; break; case VariableType.Single: case VariableType.Multi: if (!this.Categories[this.Variables[variableName].Id].ContainsKey(value)) { continue; } response.IdCategory = this.Categories[this.Variables[variableName].Id][value]; break; case VariableType.Numeric: decimal numericValue; if (decimal.TryParse(value, out numericValue)) { response.NumericAnswer = numericValue; } break; } //response.Insert(); responseBulkInsertBuilder[variableName].Append(response.RenderInsertQuery()); responseBulkInsertBuilder[variableName].Append(Environment.NewLine); } } //base.Progress = reader.Position * 100 / lineCount; if (reader.Position % insertSteps == 0) { foreach (string variableName in responseBulkInsertBuilder.Keys.ToList()) { if (responseBulkInsertBuilder[variableName].Length > 0) { this.Core.Responses[this.Variables[variableName].Id].ExecuteQuery( responseBulkInsertBuilder[variableName].ToString() ); } responseBulkInsertBuilder[variableName] = new StringBuilder(); } if (lineCount != 0) { base.Progress = reader.Position * 100 / lineCount; } } } foreach (string variableName in responseBulkInsertBuilder.Keys.ToList()) { if (responseBulkInsertBuilder[variableName].Length == 0) { continue; } this.Core.Responses[this.Variables[variableName].Id].ExecuteQuery( responseBulkInsertBuilder[variableName].ToString() ); responseBulkInsertBuilder[variableName] = new StringBuilder(); } CreateStudyLinkVariable(reader, respondentVariableIndex); return(result.ToArray()); }
public void SelectCategory(object menuItem) { if ((menuItem as MenuItem).Header.ToString() != CategoryLabel.ToString()) { int seconds = (deadline - DateTime.Now).Seconds; StopTimer(); MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to change the category?\nIf you change it you will lose this game!", "Change category?", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { switch (oldCategory) { case Category.All: user.StatisticsProperty.LostGamesAll += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.All; break; case Category.Cars: user.StatisticsProperty.LostGamesCars += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.Cars; break; case Category.Movies: user.StatisticsProperty.LostGamesMovies += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.Movies; break; case Category.States: user.StatisticsProperty.LostGamesStates += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.States; break; case Category.Mountains: user.StatisticsProperty.LostGamesMountains += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.Mountains; break; case Category.Rivers: user.StatisticsProperty.LostGamesRivers += 1; CategoryLabel = user.GameProperty.CategoryProperty = Category.Rivers; break; default: break; } switch ((menuItem as MenuItem).Header) { case "All": CategoryLabel = user.GameProperty.CategoryProperty = Category.All; AllIsSelected = true; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case "Cars": CategoryLabel = user.GameProperty.CategoryProperty = Category.Cars; AllIsSelected = false; CarsIsSelected = true; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case "Mountains": CategoryLabel = user.GameProperty.CategoryProperty = Category.Mountains; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = true; RiversIsSelected = false; StatesIsSelected = false; break; case "Movies": CategoryLabel = user.GameProperty.CategoryProperty = Category.Movies; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = true; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case "Rivers": CategoryLabel = user.GameProperty.CategoryProperty = Category.Rivers; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = true; StatesIsSelected = false; break; case "States": CategoryLabel = user.GameProperty.CategoryProperty = Category.States; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = true; break; default: break; } user.GameProperty.LevelProperty = 1; user.GameProperty.MistakesProperty = 0; foreach (var userInList in users.List) { if (userInList.Name == user.Name) { userInList.StatisticsProperty = user.StatisticsProperty; if (resumeGame) { userInList.GameProperty = new Game(); userInList.GameProperty.CategoryProperty = user.GameProperty.CategoryProperty; } } } serializationActions.SerializeUsers(Constants.UsersFile, users); ResetButtons(); HomeViewModel homeViewModel = new HomeViewModel(user); App.Current.MainWindow.DataContext = homeViewModel; } else { switch (oldCategory) { case Category.All: CategoryLabel = user.GameProperty.CategoryProperty = Category.All; AllIsSelected = true; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Cars: CategoryLabel = user.GameProperty.CategoryProperty = Category.Cars; AllIsSelected = false; CarsIsSelected = true; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Movies: CategoryLabel = user.GameProperty.CategoryProperty = Category.Movies; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = true; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.States: CategoryLabel = user.GameProperty.CategoryProperty = Category.States; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = true; break; case Category.Mountains: CategoryLabel = user.GameProperty.CategoryProperty = Category.Mountains; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = true; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Rivers: CategoryLabel = user.GameProperty.CategoryProperty = Category.Rivers; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = true; StatesIsSelected = false; break; default: break; } StartTimer(seconds); } } else { switch (oldCategory) { case Category.All: CategoryLabel = user.GameProperty.CategoryProperty = Category.All; AllIsSelected = true; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Cars: CategoryLabel = user.GameProperty.CategoryProperty = Category.Cars; AllIsSelected = false; CarsIsSelected = true; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Movies: CategoryLabel = user.GameProperty.CategoryProperty = Category.Movies; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = true; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = false; break; case Category.States: CategoryLabel = user.GameProperty.CategoryProperty = Category.States; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = false; StatesIsSelected = true; break; case Category.Mountains: CategoryLabel = user.GameProperty.CategoryProperty = Category.Mountains; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = true; RiversIsSelected = false; StatesIsSelected = false; break; case Category.Rivers: CategoryLabel = user.GameProperty.CategoryProperty = Category.Rivers; AllIsSelected = false; CarsIsSelected = false; MoviesIsSelected = false; MountainsIsSelected = false; RiversIsSelected = true; StatesIsSelected = false; break; default: break; } } }
private void UploadTextVariableAssignmentFile() { int idLanguage = 2057; Guid idVariable = Guid.Parse(this.Request.Params["Id"]); string variableName = this.Request.Params["VariableName"]; FileInfo fInfo = new FileInfo(Request.Files[0].FileName); string fileName = Path.Combine( Path.GetTempPath(), Guid.NewGuid() + fInfo.Extension ); Request.Files[0].SaveAs(fileName); Variable variable = new Variable(Global.Core.Variables); variable.IdStudy = (Guid)Global.Core.Variables.GetValue("IdStudy", "Id", idVariable); variable.Name = variableName; variable.Type = VariableType.Single; variable.Insert(); VariableLabel variableLabel = new VariableLabel(Global.Core.VariableLabels); variableLabel.IdVariable = variable.Id; variableLabel.IdLanguage = idLanguage; variableLabel.Label = (string)Global.Core.VariableLabels.GetValue( "Label", new string[] { "IdVariable", "IdLanguage" }, new object[] { idVariable, idLanguage } ); variableLabel.ReportLabel = variableLabel.Label; variableLabel.Insert(); // Read the script from the script template file. string script = File.ReadAllText(Path.Combine( Request.PhysicalApplicationPath, "App_Data", "DataStorage", "CreateResponses.sql" )); // Format the script with the variable's id. script = string.Format( script, variable.Id ); // Lock the create table action. lock (this) { // Execute the script on the database. this.Core.Responses[variable.Id].ExecuteQuery(script); } ExcelReader reader = new ExcelReader(fileName); Database storageMethod = new Database( Global.Core, null ); reader.Position = 0; int categoryOrder = 0; while (reader.Read()) { string textAnswer = reader[0]; string categoryName = reader[1]; Data respondents = storageMethod.GetRespondentsText( textAnswer, idVariable, false, null, null, false ); object idCategory = Global.Core.Categories.GetValue( "Id", new string[] { "IdVariable", "Name" }, new object[] { variable.Id, categoryName } ); if (idCategory == null) { Category category = new Category(Global.Core.Categories); category.IdVariable = variable.Id; category.Name = categoryName; category.Order = categoryOrder++; category.Insert(); idCategory = category.Id; CategoryLabel categoryLabel = new CategoryLabel(Global.Core.CategoryLabels); categoryLabel.IdCategory = category.Id; categoryLabel.IdLanguage = idLanguage; categoryLabel.Label = reader[2]; categoryLabel.Insert(); } // Run through all respondents of the text answer. foreach (Guid idRespondent in respondents.Responses.Keys) { Response response = new Response(Global.Core.Responses[variable.Id]); response.IdCategory = (Guid)idCategory; response.IdRespondent = idRespondent; response.IdStudy = variable.IdStudy; // Lock the insert action. lock (this) { response.Insert(); } } } Global.HierarchyFilters = new Crosstables.Classes.HierarchyClasses.HierarchyFilterCollection(); }
public void SetLabel(int idLanguage, string label) { switch (this.StorageType) { case StorageMethodType.Database: string source = ""; string identifier = ""; switch (this.Source) { case "TaxonomyVariables": source = "TaxonomyVariableLabels"; identifier = "IdTaxonomyVariable"; break; case "TaxonomyCategories": source = "TaxonomyCategoryLabels"; identifier = "IdTaxonomyCategory"; break; case "Variables": source = "VariableLabels"; identifier = "IdVariable"; break; case "Categories": source = "CategoryLabels"; identifier = "IdCategory"; break; } string path = identifier + "=" + this.GetValue("Id") + "&IdLanguage=" + idLanguage; object idLabel = this.Core.Tables[source].GetValue( "Id", path ); if (idLabel != null) { this.Core.Tables[source].SetValue( path, "Label", label ); } else { switch (source) { case "TaxonomyVariableLabels": TaxonomyVariableLabel taxonomyVariableLabel = new TaxonomyVariableLabel(this.Core.TaxonomyVariableLabels); taxonomyVariableLabel.IdTaxonomyVariable = (Guid)this.GetValue("Id"); taxonomyVariableLabel.IdLanguage = idLanguage; taxonomyVariableLabel.Label = label; taxonomyVariableLabel.Insert(); break; case "TaxonomyCategoryLabels": TaxonomyCategoryLabel taxonomyCategoryLabel = new TaxonomyCategoryLabel(this.Core.TaxonomyCategoryLabels); taxonomyCategoryLabel.IdTaxonomyCategory = (Guid)this.GetValue("Id"); taxonomyCategoryLabel.IdLanguage = idLanguage; taxonomyCategoryLabel.Label = label; taxonomyCategoryLabel.Insert(); break; case "VariableLabels": VariableLabel variableLabel = new VariableLabel(this.Core.VariableLabels); variableLabel.IdVariable = (Guid)this.GetValue("Id"); variableLabel.IdLanguage = idLanguage; variableLabel.Label = label; variableLabel.Insert(); break; case "CategoryLabels": CategoryLabel categoryLabel = new CategoryLabel(this.Core.CategoryLabels); categoryLabel.IdCategory = (Guid)this.GetValue("Id"); categoryLabel.IdLanguage = idLanguage; categoryLabel.Label = label; categoryLabel.Insert(); break; } } break; case StorageMethodType.Xml: this.SetValue("Label" + idLanguage, label); break; } }
void ReleaseDesignerOutlets() { if (CategoryLabel != null) { CategoryLabel.Dispose(); CategoryLabel = null; } if (DescriptionLabel != null) { DescriptionLabel.Dispose(); DescriptionLabel = null; } if (ImageView != null) { ImageView.Dispose(); ImageView = null; } if (IsSoldLabel != null) { IsSoldLabel.Dispose(); IsSoldLabel = null; } if (LocationLabel != null) { LocationLabel.Dispose(); LocationLabel = null; } if (NotesLabel != null) { NotesLabel.Dispose(); NotesLabel = null; } if (PriceLabel != null) { PriceLabel.Dispose(); PriceLabel = null; } if (PurchaseDateLabel != null) { PurchaseDateLabel.Dispose(); PurchaseDateLabel = null; } if (QuantityLabel != null) { QuantityLabel.Dispose(); QuantityLabel = null; } if (SerialNumberLabel != null) { SerialNumberLabel.Dispose(); SerialNumberLabel = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } }
private void CreateStudyLinkVariable(ExcelReader reader, int respondentVariableIndex) { // Create a new variable. Variable variable = new Variable(base.Core.Variables); // Set the variable's project id. variable.IdStudy = base.Study.Id; // Set the variable's values. variable.Name = "StudyLink"; variable.Type = VariableType.Single; variable.Order = 0; // Lock the insert action. lock (this) { // Insert the new variable into the database. variable.Insert(); } // Create a new variable label. VariableLabel variableLabel = new VariableLabel(this.Core.VariableLabels); variableLabel.Label = "StudyLink"; variableLabel.IdLanguage = 2057; variableLabel.IdVariable = variable.Id; // Lock the insert action. lock (this) { // Insert the new variable label into the database. variableLabel.Insert(); } this.Categories.Add(variable.Id, new Dictionary <string, Guid>()); // Create a new category. Category category = new Category(base.Core.Categories); // Set the category's variable id. category.IdVariable = variable.Id; // Set the category's values. category.Name = "StudyLink"; //category.Factor = (categoryOrder + 1); category.Value = 0; category.Order = 0; // Lock the insert action. lock (this) { // Insert the new variable into the database. category.Insert(); } // Create a new category label. CategoryLabel categoryLabel = new CategoryLabel(this.Core.CategoryLabels); categoryLabel.Label = "StudyLink"; categoryLabel.IdLanguage = 2057; categoryLabel.IdCategory = category.Id; // Lock the insert action. lock (this) { // Insert the new category label into the database. categoryLabel.Insert(); } this.Categories[variable.Id].Add(category.Name, category.Id); this.Variables.Add(variable.Name, variable); CreateResponsesTable(variable); reader.Position = 0; StringBuilder bulkInsertBuilder = new StringBuilder(); int insertSteps = this.Respondents.Count / 100; if (insertSteps == 0) { insertSteps = 1; } while (reader.Read()) { if (string.IsNullOrEmpty(reader[0])) { break; } Response response = new Response(this.Core.Responses[this.Variables[variable.Name].Id]); response.IdRespondent = this.Respondents[reader[respondentVariableIndex]]; response.IdStudy = this.Study.Id; response.IdCategory = category.Id; bulkInsertBuilder.Append(response.RenderInsertQuery()); bulkInsertBuilder.Append(Environment.NewLine); if (reader.Position % insertSteps == 0) { this.Core.Respondents.ExecuteQuery(bulkInsertBuilder.ToString()); bulkInsertBuilder = new StringBuilder(); } } if (bulkInsertBuilder.Length > 0) { this.Core.Respondents.ExecuteQuery(bulkInsertBuilder.ToString()); } }