Exemple #1
0
 private void SharedConnection_QueryReply(object sender, Connection.QueryReplyEvent e)
 {
     Debug.WriteLine("SharedConnection_QueryReply is expected reply: " + (e.Query == m_Query));
     if (e.Query == m_Query)
     {
         m_Response = e.Response;                 // MakeRequest will stop looping now this is defined
     }
 }
Exemple #2
0
 void SharedConnection_QueryReply(object sender, Connection.QueryReplyEvent e)
 {
     Debug.WriteLine("SharedConnection_QueryReply is expected reply: " + (e.Query == m_Query).ToString());
     if (e.Query == m_Query)
     {
         m_Message = "";
         pnlImages.Invalidate();
         Response response = e.Response;
         pnlImages.SuspendLayout();
         cmbUpdateWord.Items.Clear();
         cmbUpdateWord.Text = "";
         try
         {
             foreach (Response.Representation representation in response.Representations)
             {
                 if (representation.Language == SelectedLanguage)
                 {                         // this gives us the word forms; not a picture.  Probably only one of these, but will work for more
                     string[] words = representation.Repr.Split(',');
                     foreach (string word in words)
                     {
                         cmbUpdateWord.Items.Add(word.Trim());
                     }
                 }
                 else
                 {
                     PictureBox ctr  = new PictureBox();
                     string     file = Connection.LocalPath + representation.Repr.Replace(Connection.URLReplace, "");                         // NB doesn't always seem to be prefixed, so don't want to use SubString
                     Debug.WriteLine(file);
                     ctr.Image        = Image.FromFile(file);
                     ctr.Tag          = representation;
                     ctr.Size         = new Size(100, 100);
                     ctr.SizeMode     = PictureBoxSizeMode.Zoom;
                     ctr.Margin       = new Padding(10, 10, 10, 10);
                     ctr.Padding      = new Padding(10, 10, 10, 10);
                     ctr.Click       += Image_Click;
                     ctr.DoubleClick += Image_DoubleClick;
                     pnlImages.Controls.Add(ctr);
                 }
             }
             if (pnlImages.Controls.Count == 0)
             {
                 m_Message = Strings.Item("CCF_Failed");                         // valid response, but no images available
             }
         }
         catch (Exception ex) when(!Globals.Root.IsDebug)
         {
             m_Message = ex.ToString();
         }
         finally
         { pnlImages.ResumeLayout(); }
     }
 }