public cntrlFeed(clsFeed feed) { InitializeComponent(); this.feed = feed; Thread th = new Thread(downLoadImage); th.Start(); }
void clsMeessages_evRefresh(getInfoType type, string text) { if (is_init) {OpenSkill();} List<clsJSON> jsons = null; if (type == getInfoType.messagesFrom || type == getInfoType.messagesFrom1) { jsons = clsJSON.parceMessage(text); } else if (type == getInfoType.projects || type == getInfoType.projectsF) { jsons = clsJSON.parceProj(text); } else { jsons = clsJSON.parce(text); } if (jsons == null || jsons.Count == 0) return; if (text.LastIndexOf("error") > -1) { #region обработка ошибок if (jsons == null) { saveError("Обновление " + type.ToString(), "Ничего не получено"); return; } if (jsons.Count == 1) { if (jsons[0].bloks != null) { if (jsons[0].bloks.Count > 0) { clsJSON_block block = jsons[0].bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) { string inf = clsUpdate.cmdReq(type) + "\r\n"; foreach (string[] line in block.data) { inf += line[0] + ":" + line[1] + "\r\n"; } saveError("Обновление " + type.ToString(), inf); } } } } #endregion } #region обновление ленты if (type == getInfoType.feed) { foreach (clsJSON json in jsons) { #region проверка на ошибку if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) continue; } #endregion clsFeed feed = new clsFeed(json); cntrlFeed ff = null; try { ff = lstFeeds.FirstOrDefault(f => f.feed.message.CompareTo(feed.message) == 0); } catch (Exception) { } if (ff != null) continue; cntrlFeed cf = new cntrlFeed(feed); lstFeeds.Add(cf); cf.Dock = DockStyle.Top; try { if (is_init_f) { scrollFeed.BeginInvoke(new Action(() => { cf.Parent = scrollFeed; cf.BringToFront(); })); } else { scrollFeed.BeginInvoke(new Action(() => { cf.Parent = scrollFeed; })); } } catch (Exception) { } if (feed.is_new && clsConfig.ShowUpdateWindow) { frmUpdInfo.addMessage("Новый пост в ленте от ", this, tabControl1); } } if (is_init_f) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabLoading"]) { tabControl1.SelectedTab = tabControl1.TabPages["tabFeeds"]; } })); } catch (Exception) { } is_init_f = false; } } #endregion #region переписка if (type == getInfoType.messagesFrom || type == getInfoType.messagesFrom1) { #region очистить scrollMessDialog от предыдущего диалога и переключить на вкладку tabLoading try { scrollMessDialog.BeginInvoke(new Action(() => { tabControl1.SelectedTab = tabControl1.TabPages["tabLoading"]; scrollMessDialog.Controls.Clear(); })); } catch (Exception) { } #endregion if (jsons.Count > 110) { jsons.RemoveRange(0, jsons.Count - 100); } foreach (clsJSON json in jsons) { #region проверка на ошибку if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) continue; } #endregion clsMessDialog msg = new clsMessDialog(json); int w = scrollMessages.Width - 25 - 95; cntrlMessDialog cf = new cntrlMessDialog(msg, w); lstMessDialog.Add(cf); cf.Dock = DockStyle.Top; try { scrollMessDialog.BeginInvoke(new Action(() => { cf.Parent = scrollMessDialog; cf.BringToFront(); })); } catch (Exception) { } //cf.chSize(); } #region переключить на вкладку tabDialog и прокрутить к последнему сообщению try { scrollMessDialog.BeginInvoke(new Action(() => { tabControl1.SelectedTab = tabControl1.TabPages["tabDialog"]; scrollMessDialog.Focus(); scrollMessDialog.VerticalScroll.Value = scrollMessDialog.VerticalScroll.Maximum; scrollMessDialog.VerticalScroll.Value = scrollMessDialog.VerticalScroll.Maximum; })); } catch (Exception) { } #endregion } #endregion #region сообщения if (type == getInfoType.messages) { lstMessages.Clear(); int newMessCnt = 0; try { scrollMessages.BeginInvoke(new Action(() => { scrollMessages.Controls.Clear(); scrollMessages.Visible = false; })); } catch (Exception) { } foreach (clsJSON json in jsons) { #region проверка на ошибку if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) continue; } #endregion clsMessage msg = new clsMessage(json); //cntrlMessageInfo fmi = lstMessages.FirstOrDefault(f => f.message.post_time.CompareTo(msg.post_time) == 0); //cntrlMessageInfo fmi1 = lstMessages.FirstOrDefault(f => f.message.last_post_time.CompareTo(msg.last_post_time) == 0); //if (fmi != null || fmi1 != null) continue; int w = scrollMessages.Width - 400; cntrlMessageInfo cf = new cntrlMessageInfo(msg, w); lstMessages.Add(cf); cf.Dock = DockStyle.Top; try { scrollMessages.BeginInvoke(new Action(() => { cf.Parent = scrollMessages; cf.BringToFront(); })); } catch (Exception) { } if (msg.unread_count > 0 || msg.is_unread) { newMessCnt++; } } try { scrollMessages.BeginInvoke(new Action(() => { scrollMessages.Visible = true; })); } catch (Exception) { } if (newMessCnt > 0) { if (clsConfig.ShowUpdateWindow) { frmUpdInfo.addMessage("Новое сообщение " + newMessCnt, this, tabControl1); } #region notify.Text string notifyText = "Freelancehunt Monitor \n" + newMessCnt; if (newMessCnt == 1 || newMessCnt == 21 || newMessCnt == 31 || newMessCnt == 41 || newMessCnt == 51 || newMessCnt == 61 || newMessCnt == 71 || newMessCnt == 81 || newMessCnt == 91 || newMessCnt == 101) { notifyText += " новое сообщение "; } else if (newMessCnt >= 2 && newMessCnt <= 4 || newMessCnt >= 22 && newMessCnt <= 24 || newMessCnt >= 32 && newMessCnt <= 34 || newMessCnt >= 42 && newMessCnt <= 44 || newMessCnt >= 52 && newMessCnt <= 54 || newMessCnt >= 62 && newMessCnt <= 64 || newMessCnt >= 72 && newMessCnt <= 74 || newMessCnt >= 82 && newMessCnt <= 84 || newMessCnt >= 92 && newMessCnt <= 94) { notifyText += " новых сообщения "; } else notifyText += " новых сообшений "; this.notify.Text = notifyText; #endregion #region notify.icon if (newMessCnt == 1) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm1)); } if (newMessCnt == 2) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm2)); } if (newMessCnt == 3) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm3)); } if (newMessCnt == 4) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm4)); } if (newMessCnt == 5) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm5)); } if (newMessCnt == 6) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm6)); } if (newMessCnt == 7) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm7)); } if (newMessCnt == 8) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm8)); } if (newMessCnt == 9) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm9)); } if (newMessCnt > 9) { notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon_nnm9_)); } #endregion } else { this.notify.Text = "Freelancehunt Monitor"; notify.Icon = ((System.Drawing.Icon)(Properties.Resources.favicon1)); } if (is_init_m) { //tabControl1.SelectedTab = tabControl1.TabPages["tabMessages"]; try { tabControl1.BeginInvoke(new Action(() => { tabControl1.SelectedTab = tabControl1.TabPages["tabMessages"]; })); } catch (Exception) { } is_init_m = false; } if (is_forse_upd) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabMessages"]) { scrollMessages.Focus(); } })); } catch (Exception) { } is_forse_upd = false; } //if (is_init) } #endregion #region профайл if (type == getInfoType.profiles) { #region проверка на ошибку if (jsons == null) return; if (jsons.Count != 1) return; if (jsons[0].bloks != null) { clsJSON_block block = jsons[0].bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) { //try { this.BeginInvoke(new Action(() => { // tabControl1.SelectedTab = tabControl1.TabPages["tabUserList"]; // //MessageBox.Show("Пользователь с логином \"" + txtProfileName.Text.Trim() + "\" не найден!","Ошибка" ); //})); } //catch (Exception) { } return; } } #endregion profile = new clsProfile(jsons[0]); if (is_init_u) { is_customer = !profile.is_freelancer; is_init_u = false; } #region данные профиля //dataGridView1.BeginInvoke(new Action(() => // { // dataGridView1.Rows.Clear(); // foreach (object[] line in profile.table) // dataGridView1.Rows.Add(line); // })); //frmUpdInfo.addMessage("Информация о профиле " + profile.fname + " " + profile.sname + " (" + profile.login + ")", this); #endregion #region изображения //pnlUserParam.BeginInvoke(new Action(() => // { // pcbUser_Day.Image = profile.is_birth_date_verified ? Properties.Resources.user_date : Properties.Resources.user_date_gray; // pcbUser_email.Image = profile.is_email_verified ? Properties.Resources.user_email : Properties.Resources.user_email_gray; // pcbUser_OKPAY.Image = profile.is_okpay_verified ? Properties.Resources.user_okpay : Properties.Resources.user_okpay_gray; // pcbUser_Phone.Image = profile.is_phone_verifie ? Properties.Resources.user_phone : Properties.Resources.user_phone_gray; // pcbUser_WMID.Image = profile.is_wmid_verified ? Properties.Resources.user_wmid : Properties.Resources.user_wmid_gray; // })); //pcbProfileAvatar.BeginInvoke(new Action(() => pcbProfileAvatar.Image = Properties.Resources.DefaultAva)); //txtProfileName.BeginInvoke(new Action(() => txtProfileName.Text = profile.login)); //imgDownloadTryCount = 0; //Thread th = new Thread(downLoadImage); //th.Start(); //setSizeForReviews(); #endregion //try { scrollMessDialog.BeginInvoke(new Action(() => { tabControl1.SelectedTab = tabControl1.TabPages["tabUsers"]; })); } //catch (Exception) { } //if (is_init_u) { is_init_u = false; } } #endregion #region проекты if (type == getInfoType.projects || type == getInfoType.projectsF) { lstProjects.Clear(); int newProjCnt = 0; try { this.BeginInvoke(new Action(() => { panel19.Visible = true; progressBar1.Value = 40; })); } catch (Exception) { } int step = 960 / jsons.Count; if (jsons.Count < 2) { try { this.BeginInvoke(new Action(() => { progressBar1.Value = 1000; })); this.BeginInvoke(new Action(() => { panel19.Visible = false; })); } catch (Exception) { } } foreach (clsJSON json in jsons) { #region проверка на ошибку if (json.bloks != null) { clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("error") == 0); if (block != null) continue; } #endregion try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } clsProject prj = new clsProject(json); cntrlProject fp = lstProjects.FirstOrDefault(p => p.project.id == prj.id); try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } if (fp != null) continue; cntrlProject cp = new cntrlProject(prj); try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } lstProjects.Add(cp); try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } //try //{ // scrollProjects.BeginInvoke(new Action(() => // { // cp.Parent = scrollProjects; // cp.BringToFront(); // })); //} //catch (Exception) { } try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } if (!prjIDs.ContainsKey(prj.id) ) { addProjectIDToFile(prj.id); newProjCnt++; //if (!is_customer && !clsConfig.NotifyInterestProjOnly) //{ frmUpdInfo.addMessage("Новый проект, #" + prj.id, this, tabControl1); } } try { this.BeginInvoke(new Action(() => { progressBar1.Value += (step / 8); })); } catch (Exception) { } } #region скрыть scrollProjects try { scrollProjects.BeginInvoke(new Action(() => { scrollProjects.Visible = false; scrollProjects.Controls.Clear(); })); } catch (Exception) { } #endregion Thread.Sleep(100);//надо для разделения во времени BeginInvoke'ов try { this.BeginInvoke(new Action(() => { progressBar1.Value = 900; })); } catch (Exception) { } #region добавить каждый элемент на scrollProjects foreach (cntrlProject cpr in lstProjects) { cpr.Dock = DockStyle.Top; try { scrollProjects.BeginInvoke(new Action(() => { cpr.Parent = scrollProjects; cpr.BringToFront(); })); } catch (Exception) { } } #endregion Thread.Sleep(100);//надо для разделения во времени BeginInvoke'ов try { this.BeginInvoke(new Action(() => { progressBar1.Value = 1000; })); } catch (Exception) { } #region показать scrollProjects и скрыть panel19 try { this.BeginInvoke(new Action(() => { panel19.Visible = false; scrollProjects.Visible = true; })); } catch (Exception) { } #endregion if (!is_customer && !clsConfig.NotifyInterestProjOnly && clsConfig.ShowUpdateWindow) { frmUpdInfo.addMessage("Новый проект " + newProjCnt, this, tabControl1); } if (is_init_p) { if (!clsConfig.ShowInterestProjOnly) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabLoading"]) { tabControl1.SelectedTab = tabControl1.TabPages["tabProjects"]; } })); } catch (Exception) { } } is_init_p = false; } if (is_forse_upd) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabProjects"]) { scrollProjects.Focus(); } })); } catch (Exception) { } is_forse_upd = false; } #region фильтр проектов try { this.BeginInvoke(new Action(() => { initData(); loadProjectes(); })); } catch (Exception) { } if(is_init_ps) { if (clsConfig.ShowInterestProjOnly) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabLoading"]) { tabControl1.SelectedTab = tabControl1.TabPages["tabSearchProj"]; } })); } catch (Exception) { } } is_init_ps = false; } if (is_forse_upd) { try { tabControl1.BeginInvoke(new Action(() => { if (tabControl1.SelectedTab == tabControl1.TabPages["tabSearchProj"]) { scrollSearchedProject.Focus(); } })); } catch (Exception) { } is_forse_upd = false; } #endregion } try{ this.BeginInvoke(new Action(() => { scrollProjects.Visible = true; })); } catch (Exception) { } #endregion if (is_init) { is_init = false; } }