public MainWindow() { InitializeComponent(); const int n = 4; string[] url = { "https://en.wikipedia.org/wiki/Saint_Petersburg", "https://en.wikipedia.org/wiki/Moscow", "https://en.wikipedia.org/wiki/Perm", "https://en.wikipedia.org/wiki/Omsk" }; TextBlock[] var = { var_0, var_1, var_2, var_3 }; Parser parser_img = new Parser(new ParserImg()); Parser parser_title = new Parser(new ParserTitle()); WikiData[] data = new WikiData[4]; for (int i = 0; i < n; i++) { data[i] = new WikiData( parser_title.Parse(url[i]), parser_img.Parse(url[i]) ); } UiInit ui = new UiInit(var, image, data); }
/// <summary> /// Show 4 variants to answer and a picture /// </summary> /// <param name="k">Current right answer</param> private void SetSldie(int k) { _current_data = new WikiData(_urllist); for (int i = 0; i < n; i++) { _var[i].Text = _current_data.title[i]; } _img.Source = GetImage(_current_data.img_url[k]); }
/// <summary> /// Create main UI /// </summary> /// <param name="var">TextBoxes to choose answers in MainWindow</param> /// <param name="image">Image in MainWindow</param> /// <param name="urls">Array of links for a game</param> public UiInit(TextBox[] var, Image image, string[] urls) { _var = var; _img = image; _urllist = urls; _current_data = new WikiData(_urllist); RightAnsInit(); for (int i = 0; i < n; i++) { var[i].MouseLeftButtonUp += new MouseButtonEventHandler(OnVarClick); } SetSldie(_right_ans[_current_q]); }
public WikiData(WikiData a, WikiData b) { title = a.title; img_url = b.img_url; }