void GenerateContent() { if (model.Words.Count != 0) { Window win = window as Window; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(win, "DataGrid"); int index = rand.Next(0, model.Words.Count); answer = model.Words[index]; userAnswer = new char[answer.Word.Length]; Viewbox translate = DynamicElements.CreateViewBoxLabel(answer.Translate, answer.WordId); DynamicElements.SetRowColumnProperties(translate, 1, 0, 2, 1); grid.Children.Add(translate); Grid targetGrid = DynamicElements.CreateGrid(answer.Word.Length, 1, GridUnitType.Star, GridUnitType.Star); targetGrid.Name = "TargetGrid"; DynamicElements.SetRowColumnProperties(targetGrid, 2, 0, 2, 1); grid.Children.Add(targetGrid); Grid questGrid = DynamicElements.CreateGrid(answer.Word.Length, 1, GridUnitType.Star, GridUnitType.Star); questGrid.Name = "QuestGrid"; DynamicElements.SetRowColumnProperties(questGrid, 4, 0, 2, 1); grid.Children.Add(questGrid); FillGrid(Shuffle(answer.Word), questGrid); model.Words.RemoveAt(index); AddNextComplete(model.Words.Count); if (model.Words.Count != 0) { ((Border)LogicalTreeHelper.FindLogicalNode(win, "NextBord")).Visibility = Visibility.Visible; } else { ((Border)LogicalTreeHelper.FindLogicalNode(win, "CompleteBord")).Visibility = Visibility.Visible; } } }
//protected override void VariantMouseLeftDown(object sender, EventArgs e) //{ //} void GenerateContent() { if (model.Words.Count != 0) { // //int index = rand.Next(offset, repeatNumber * 5); Window window = win as Window; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); int index = rand.Next(0, model.Words.Count); answer = model.Words[index]; AddVoice(); Border mediaBord = (Border)LogicalTreeHelper.FindLogicalNode(window, "Speech"); DynamicElements.SetRowColumnProperties(mediaBord, 1, 0, 2, 2); Viewbox vB = new Viewbox(); DynamicElements.SetRowColumnProperties(vB, 4, 0, 2, 1); TextBox tB = new TextBox(); tB.MinWidth = 100; vB.Child = tB; tB.Name = "Answer"; tB.MinWidth = 100; tB.MaxWidth = 100; grid.Children.Add(vB); model.Words.RemoveAt(index); AddNextComplete(model.Words.Count); if (model.Words.Count != 0) { ((Border)LogicalTreeHelper.FindLogicalNode(window, "NextBord")).Visibility = Visibility.Visible; } else { ((Border)LogicalTreeHelper.FindLogicalNode(window, "CompleteBord")).Visibility = Visibility.Visible; } } }
public void SetPercent(float percent) { Border bord_percent = new Border(); bord_percent.Margin = new Thickness(2, 1, 1, 2); if (percent > 70) { bord_percent.Background = Brushes.GreenYellow; } else if (percent <= 70 && percent > 40) { bord_percent.Background = Brushes.Yellow; } else if (percent >= 0 && percent <= 40) { bord_percent.Background = Brushes.PaleVioletRed; } Viewbox vb_percent = new Viewbox(); bord_percent.Child = vb_percent; Label lb = new Label(); lb.Content = "Правильных: " + percent + "%"; vb_percent.Child = lb; DynamicElements.SetRowColumnProperties(bord_percent, mainGrid.RowDefinitions.Count - 1, 0, 1, 1); mainGrid.Children.Add(bord_percent); }
/// <summary> /// Add content elements, difference between elements content which are determined by type /// </summary> /// <param name="type"></param> //protected abstract void AddContent(string type); protected void AddNextComplete(int WordsCount) { Border nextBord; Style bordStyle; Window window = win as Window; if (WordsCount != 0) { bordStyle = window.FindResource("NextStyle") as Style; nextBord = DynamicElements.CreateBorder(bordStyle, 0);//CreateOwnBorder(bordStyle, 0); nextBord.Margin = new Thickness(0, 4, 4, 4); nextBord.Child = DynamicElements.CreateViewBoxLabel("Дальше", 0); nextBord.Name = "NextBord"; } else { bordStyle = window.FindResource("CompleteStyle") as Style; nextBord = DynamicElements.CreateBorder(bordStyle, 0);//CreateOwnBorder(bordStyle, 0); nextBord.Margin = new Thickness(0, 4, 4, 4); nextBord.Child = DynamicElements.CreateViewBoxLabel("Завершить", 0); nextBord.Name = "CompleteBord"; } DynamicElements.SetRowColumnProperties(nextBord, 7, 1, 1, 1); nextBord.Visibility = Visibility.Collapsed; nextBord.Background = window.FindResource("BrushBlue") as Brush; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); grid.Children.Add(nextBord); }
public void SetDataSideMenu(List <LectionsModel> lectionsList) { Style btnStyle = this.FindResource("btn_Choice") as Style; ScrollViewer scroll = new ScrollViewer(); DynamicElements.SetRowColumnProperties(scroll, 0, 0, 1, 1); StackPanel panel = new StackPanel(); Style testStyle = this.FindResource("btn_Test") as Style; Button btn_test = new Button(); btn_test.MinHeight = 50; btn_test.MaxHeight = 50; btn_test.Name = "btn_Test"; btn_test.Background = Brushes.Transparent; btn_test.Style = testStyle; btn_test.Content = DynamicElements.CreateViewBoxLabel("Тест по уроку", 0); panel.Children.Add(btn_test); for (int i = 0; i < lectionsList.Count; i++) { Button btn = new Button(); btn.MinHeight = 50; btn.MaxHeight = 50; btn.Style = btnStyle; btn.Background = Brushes.Transparent; btn.Content = DynamicElements.CreateViewBoxLabel(lectionsList[i].Name, lectionsList[i].Id); btn.Tag = lectionsList[i].Id; DynamicElements.SetRowColumnProperties(btn, i, 0, 1, 1); panel.Children.Add(btn); } scroll.Content = panel; mainGrid.Children.Add(scroll); }
protected void AddContent(string type, int index) { Window window = win as Window; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); Style bordStyle = window.FindResource("VariantStyle") as Style; Border answBorder = (Border)LogicalTreeHelper.FindLogicalNode(window, "Bord" + index); int filledInd = Grid.GetRow(answBorder); for (int i = 0; i < 5; i++) { if (i + 1 == filledInd) { } else { int ind = rand.Next(0, 5 - i); string content = model.Words[ind].Word; Border bord = DynamicElements.CreateBorder(bordStyle, model.Words[ind]);//model.Words[ind].WordId); bord.Margin = new Thickness(0, 4, 4, 4); bord.Name = "Bord" + i; bord.Child = DynamicElements.CreateViewBoxLabel(content, model.Words[ind].WordId); DynamicElements.SetRowColumnProperties(bord, i + 1, 1, 1, 1); bord.Background = window.FindResource("BrushYellow") as Brush; grid.Children.Add(bord); model.Words.RemoveAt(ind); } } }
Test(WindowState state) { InitializeComponent(); grid = DynamicElements.CreateGrid(4, 0, GridUnitType.Star, GridUnitType.Star); DynamicElements.SetRowColumnProperties(grid, 0, 1, mainGrid.ColumnDefinitions.Count - 1, mainGrid.RowDefinitions.Count - 1); mainGrid.Children.Add(grid); this.WindowState = state; questFontSize = WindowStateCheck(); }
protected MediaElement CreateMediElement(Style style) { MediaElement media = new MediaElement(); DynamicElements.SetRowColumnProperties(media, 0, 0, 1, 1); media.Style = style; media.Name = "MediaEl"; media.LoadedBehavior = MediaState.Manual; return(media); }
void CreateElements() { Border bord = DynamicElements.CreateBorder(this.FindResource("BorderStyle") as Style); DynamicElements.SetRowColumnProperties(bord, mainGrid.RowDefinitions.Count - 1, 1, 1, 1); Viewbox box = DynamicElements.CreateViewBoxLabel("Выйти", 0); bord.Child = box; bord.Margin = new Thickness(1, 1, 2, 2); mainGrid.Children.Add(bord); }
void CreateCompleteBlock(Grid grid, FrameworkElement result, string resultName, int column, string content) { Viewbox label = DynamicElements.CreateViewBoxLabel(content, 0); DynamicElements.SetRowColumnProperties(label, column, 0, 1, 1); grid.Children.Add(label); Viewbox container = DynamicElements.CreateViewBox(column + 1, 0, 1, 1); result.Name = resultName; result.MinWidth = 200; result.MaxWidth = 200; container.Child = result; grid.Children.Add(container); }
public void SetQuestion(QuestionsModel quest) { AddRow(grid); AddRow(grid); AddRow(grid); RichTextBox rich = new RichTextBox(); rich.Name = "rtb_Question"; rich.FontSize = questFontSize; rich.Background = Brushes.Transparent; rich.AppendText(quest.Text); DynamicElements.SetRowColumnProperties(rich, 0, 0, grid.ColumnDefinitions.Count, 3); grid.Children.Add(rich); }
void AddRightAnswer() { Window window = win as Window; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); Border bord = DynamicElements.CreateBorder(window.FindResource("BorderStyle") as Style, answer.WordId); bord.Margin = new Thickness(0, 4, 4, 4); bord.Background = window.FindResource("BrushYellow") as Brush; Viewbox vB = DynamicElements.CreateViewBoxLabel(answer.Word + " - " + answer.Translate, answer.WordId); DynamicElements.SetRowColumnProperties(bord, 5, 0, 2, 1); bord.Child = vB; grid.Children.Add(bord); }
public void SetMainData(TestsModel test) { int questCount = 0; foreach (QuestionsModel quest in test.Questions) { int count = 0; Grid grid = DynamicElements.CreateGrid(5, quest.Answers.Count + 3, GridUnitType.Star, GridUnitType.Star); RichTextBox rtb = new RichTextBox(); rtb.Name = "rtb_Question" + quest.Id; DynamicElements.SetRowColumnProperties(rtb, count, 1, 4, 2); Viewbox number = DynamicElements.CreateViewBoxLabel((questCount + 1) + ".", 0); DynamicElements.SetRowColumnProperties(number, count, 0, 1, 1); grid.Children.Add(number); count += 3; rtb.AppendText(quest.Text); rtb.FontSize = fontSize; grid.Children.Add(rtb); foreach (AnswersModel answer in quest.Answers) { Border bord = new Border(); bord.Margin = new Thickness(1, 3, 1, 1); bord.MaxHeight = 100; if (answer.UserChoice == true && answer.Rightness == true) { bord.Background = this.FindResource("Green") as Brush; } else if (answer.UserChoice == true) { bord.Background = Brushes.PaleVioletRed; } else if (answer.Rightness == true) { bord.Background = Brushes.LightGreen; } Viewbox vb = new Viewbox(); vb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; CheckBox cb = DynamicElements.CreateCheckBox(answer.UserChoice); vb.Child = cb; cb.Content = answer.Text; bord.Child = vb; DynamicElements.SetRowColumnProperties(bord, count, 1, 3, 1); count++; grid.Children.Add(bord); } panel.Children.Add(grid); questCount++; } }
void GenerateContent() { if (model.Words.Count != 0) { //int index = rand.Next(offset, repeatNumber * 5); int index = rand.Next(0, 5); answer = model.Words[index]; Viewbox vB = DynamicElements.CreateViewBoxLabel(answer.Translate, answer.WordId); DynamicElements.SetRowColumnProperties(vB, 1, 0, 1, 2); vB.Name = "Answer"; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(win as Window, "DataGrid"); grid.Children.Add(vB); AddContent(); AddNextComplete(model.Words.Count); } }
void AddAnswerBorder(SynonymWordModel synonym, int index) { Window window = win as Window; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); Style bordStyle = window.FindResource("VariantStyle") as Style; string content = Parse(synonym.Synonyms); Border bord = DynamicElements.CreateBorder(bordStyle, synonym);//synonym.WordId); bord.Margin = new Thickness(0, 4, 4, 4); bord.Name = "Bord" + index; bord.Child = DynamicElements.CreateViewBoxLabel(content, synonym.WordId); DynamicElements.SetRowColumnProperties(bord, index + 1, 1, 1, 1); bord.Background = window.FindResource("BrushYellow") as Brush; grid.Children.Add(bord); model.Synonyms.RemoveAt(index); }
void GenerateContent() { if (model.Synonyms.Count != 0) { Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(win as Window, "DataGrid"); int index = rand.Next(0, model.Synonyms.Count); answer = model.Synonyms[index]; //не явный upcast Viewbox vB = DynamicElements.CreateViewBoxLabel(answer.Word, answer.WordId); DynamicElements.SetRowColumnProperties(vB, 1, 0, 1, 2); vB.Name = "Answer"; grid.Children.Add(vB); AddAnswerBorder(((SynonymWordModel)answer), index); //явный downcast AddTVPS(); AddContent("synonyms", index); AddNextComplete(model.Synonyms.Count); } }
public void SetQuestion(QuestionsModel question) { ClearGrid(); AddRow(grid_QuestData, 1); Viewbox box = DynamicElements.CreateViewBoxLabel("Введите вопрос:", 0); grid_QuestData.Children.Add(box); AddRow(grid_QuestData, 2); RichTextBox rich = new RichTextBox(); rich.Name = "rtb_Question"; rich.FontSize = 20; rich.Tag = question.Id; rich.AppendText(question.Text); DynamicElements.SetRowColumnProperties(rich, 1, 0, 1, 2); grid_QuestData.Children.Add(rich); AddRow(grid_QuestData, 4); ScrollViewer scroll = new ScrollViewer(); StackPanel panel = new StackPanel(); Button btn = DynamicElements.CreateButton("Добавить ответ"); btn.Style = this.FindResource("btn_AddAnswer") as Style; panel.Children.Add(btn); scroll.Content = panel; scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; DynamicElements.SetRowColumnProperties(scroll, 3, 1, 1, 4); grid_QuestData.Children.Add(scroll); answerCount = 0; if (question.Answers.Count == 0) { AddAnswer(btn, new AnswersModel(answerCount, question.Id, "", false)); } else { foreach (AnswersModel el in question.Answers) { AddAnswer(btn, el); } } }
void AddContent() { Window window = win as Window; Style bordStyle = window.FindResource("VariantStyle") as Style; for (int i = 0; i < 5; i++) { //int ind = rand.Next(offset, repeatNumber * 5 - i); //TO DO:check index maybe need change to repeatNumber*5-i-1 int ind = rand.Next(0, 5 - i); string content = model.Words[ind].Word; Border bord = DynamicElements.CreateBorder(bordStyle, model.Words[ind]);//model.Words[ind].WordId); bord.Margin = new Thickness(0, 4, 4, 4); bord.Name = "Bord" + i; bord.Child = DynamicElements.CreateViewBoxLabel(content, model.Words[ind].WordId); DynamicElements.SetRowColumnProperties(bord, i + 1, 1, 1, 1); bord.Background = window.FindResource("BrushYellow") as Brush; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(window, "DataGrid"); grid.Children.Add(bord); model.Words.RemoveAt(ind); //bord = CreateOwnBorder(bordStyle, rand.Next(0, repeatNumber * 5); } }
/// <summary> /// Add transcription, voice, part of speech elements /// </summary> protected void AddTVPS() { Viewbox vB; Grid grid = (Grid)LogicalTreeHelper.FindLogicalNode(win as Window, "DataGrid"); if (answer.Transcription != null) { vB = DynamicElements.CreateViewBoxLabel(answer.Transcription, answer.WordId); DynamicElements.SetRowColumnProperties(vB, 5, 0, 1, 1); grid.Children.Add(vB); //win.DataGrid.Children.Add(vB); } if (answer.PartOfSpeech != null) { vB = DynamicElements.CreateViewBoxLabel(answer.PartOfSpeech, answer.WordId); vB.ToolTip = "Часть речи"; DynamicElements.SetRowColumnProperties(vB, 7, 0, 1, 2); grid.Children.Add(vB); //win.DataGrid.Children.Add(vB); } AddVoice(); }
public void SetAnswers(List <AnswersModel> answers) { int count = grid.RowDefinitions.Count; int i = 1; foreach (AnswersModel answer in answers) { AddRow(grid); Viewbox vb = new Viewbox(); DynamicElements.SetRowColumnProperties(vb, count, 0, grid.ColumnDefinitions.Count, 1); CheckBox cb = DynamicElements.CreateCheckBox(answer.UserChoice); cb.Name = "Checkbox" + i; i++; cb.Tag = answer.Id; cb.Content = answer.Text; vb.Child = cb; vb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; grid.Children.Add(vb); count++; } }
public void SetAllQuestions(List <QuestionsModel> questions) { ScrollViewer scroll = new ScrollViewer(); DynamicElements.SetRowColumnProperties(scroll, 0, 0, 1, mainGrid.RowDefinitions.Count); StackPanel panel = new StackPanel(); for (int i = 0; i < questions.Count; i++) { Style bordStyle = this.FindResource("ChoiceBorderStyle") as Style; Border bord = DynamicElements.CreateBorder(bordStyle); bord.MaxHeight = 50; bord.MinHeight = 50; bord.Name = "questionsBord" + questions[i].Id; bord.Margin = new Thickness(0, 2, 0, 0); bord.Tag = questions[i].Id; Viewbox box = DynamicElements.CreateViewBoxLabel((i + 1).ToString(), questions[i].Id); bord.Child = box; panel.Children.Add(bord); } scroll.Content = panel; mainGrid.Children.Add(scroll); }