コード例 #1
0
        private void frmProjectFullInfo_Load(object sender, EventArgs e)
        {
            string str = clsUpdate.getProjectFullInfo(this.projectId);

            List <clsJSON> list = clsJSON.parceProj(str);

            #region проверка на ошибку
            if (list == null)
            {
                this.Close();
            }
            else if (list.Count != 1)
            {
                this.Close();
            }
            else if (list[0].bloks == null)
            {
                this.Close();
            }
            else if (list[0].bloks.Count == 0)
            {
                this.Close();
            }
            else if (Enumerable.FirstOrDefault <clsJSON_block>((IEnumerable <clsJSON_block>)list[0].bloks, (Func <clsJSON_block, bool>)(b => b.name.CompareTo("from") == 0)) == null)
            {
                this.Close();
            }
            #endregion

            else
            {
                this.project = new clsProject(list[0]);

                this.lblName.Text = this.project.name;

                this.lblTime.Text        = DateTime.Parse(this.project.publication_time).ToLongDateString() + " " + DateTime.Parse(this.project.publication_time).ToShortTimeString();
                this.lblDescription.Text = this.project.description.Replace("n", "\n");

                string descHtml = this.project.description_html;

                #region убираем пустые строки в конце описания

                while (descHtml.EndsWith("<p></p>"))
                {
                    descHtml = descHtml.Remove(descHtml.Length - 7);
                }
                while (descHtml.EndsWith("<p><br /></p>"))
                {
                    descHtml = descHtml.Remove(descHtml.Length - 13);
                }
                #endregion

                #region корректировка высоты окна

                int i = descHtml.Split(new string[] { "<p>" }, StringSplitOptions.None).Count();

                int ns = 0;
                foreach (char c in this.lblDescription.Text)
                {
                    if (c == '\n')
                    {
                        ns++;
                    }
                }
                ns = (ns * 7) / 10 + 1;
                i  = (i * 7) / 10 + 1;
                //MessageBox.Show(i+"\n"+ns);
                while (i > 0)
                {
                    this.lblDescription.Text += "\n ";
                    i--;
                }
                #endregion


                this.webBrowser1.DocumentText = "<font size=\"2\" face=\"Open Sans\">" + descHtml + "</font>";

                #region skills
                lblCategories.Text = "";
                if (this.project.skills != null)
                {
                    foreach (KeyValuePair <int, string> keyValuePair in this.project.skills)
                    {
                        lblCategories.Text += keyValuePair.Value + ", ";
                    }
                }
                if (lblCategories.Text.EndsWith(", "))
                {
                    lblCategories.Text = lblCategories.Text.Substring(0, lblCategories.Text.Length - 2);
                }
                #endregion

                #region ставки
                this.lblBidCount.Text = this.project.bid_count.ToString();
                if (this.project.bid_count == 1 || this.project.bid_count == 21 || this.project.bid_count == 31 || this.project.bid_count == 41 || this.project.bid_count == 51 || this.project.bid_count == 61 || this.project.bid_count == 71 || this.project.bid_count == 81 || this.project.bid_count == 91 || this.project.bid_count == 101)
                {
                    this.lblBidCount.Text += " ставка  ";
                }
                else if (this.project.bid_count >= 2 && this.project.bid_count <= 4 || this.project.bid_count >= 22 && this.project.bid_count <= 24 || this.project.bid_count >= 32 && this.project.bid_count <= 34 || this.project.bid_count >= 42 && this.project.bid_count <= 44 || this.project.bid_count >= 52 && this.project.bid_count <= 54 || this.project.bid_count >= 62 && this.project.bid_count <= 64 || this.project.bid_count >= 72 && this.project.bid_count <= 74 || this.project.bid_count >= 82 && this.project.bid_count <= 84 || this.project.bid_count >= 92 && this.project.bid_count <= 94)
                {
                    this.lblBidCount.Text += " ставки  ";
                }
                else
                {
                    this.lblBidCount.Text += " ставок  ";
                }
                #endregion

                this.lblLogin.Text = this.project.from.fname + " " + this.project.from.sname + " (" + this.project.from.login + ")";

                this.pcbProfileAvatar.BeginInvoke(new Action(() => this.pcbProfileAvatar.Image = (Image)Resources.DefaultAva));
                this.imgDownloadTryCount = 0;
                new Thread(new ThreadStart(this.downLoadImage)).Start();

                if (this.project.is_bid_added)
                {
                    button1.BackColor = Color.LightSteelBlue;
                    button1.Cursor    = Cursors.No;
                }

                if (Form1.is_customer)
                {
                    button1.Visible = false;
                }

                this.TopMost = true;
            }
        }
コード例 #2
0
        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; }
        }
コード例 #3
0
        void loadProjectes()
        {
            //scrollProjects.Visible = true;
            scrollSearchedProject.Controls.Clear();

            int PageNum = cmbPageNum.SelectedIndex + 1;

            {
                var lst = from z in searchedProject where z.pageNum == PageNum select z;

                if (lst != null && lst.Count() > 0)
                {
                    scrollSearchedProject.Visible = false;
                    int npc = 0; //счетчик нвых проектов
                    foreach (clsSerchedProject p in lst)
                    {
                        p.control.Dock = DockStyle.Top;
                        p.control.Parent = scrollSearchedProject;
                        p.control.BringToFront();

                        #region новый проект
                        if (!prjIDs.ContainsKey(p.control.project.id) )
                        {
                            addProjectIDToFile(p.control.project.id);
                            if (!is_customer && clsConfig.NotifyInterestProjOnly && clsConfig.ShowUpdateWindow)
                            {
                                npc++;
                            }
                        }
                        #endregion
                    }

                    scrollSearchedProject.Visible = true;
                    frmUpdInfo.addMessage("Новый проект " + npc, this, tabControl1);
                    return;
                }
            }

            string s = getSkills();
            string data = clsUpdate.getProgectes(s, PageNum);

            List<clsJSON> jsons = clsJSON.parce(data);

            #region обработка ошибок
            if (jsons == null)
            {
                if (this.Size.Height > 400)//если форма свернута это не показывать
                {
                    MessageBox.Show("Ошибка при получении списка проектов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return;
            }

            if (jsons.Count == 0)
            {
                if (this.Size.Height > 400) //если форма свернута это не показывать
                {
                    MessageBox.Show("Ничего не найднео", "информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                return;
            }
            #endregion

            foreach (clsJSON json in jsons)
            {
                clsProject pro = new clsProject(json);
                cntrlProject cp = new cntrlProject(pro);

                searchedProject.Add(new clsSerchedProject(PageNum, cp));
            }

            {
                var lst = from z in searchedProject where z.pageNum == PageNum select z;

                if (lst != null && lst.Count() > 0)
                {
                    scrollSearchedProject.Visible = false;
                    int npc = 0; //счетчик нвых проектов
                    foreach (clsSerchedProject p in lst)
                    {
                        p.control.Dock = DockStyle.Top;
                        p.control.Parent = scrollSearchedProject;
                        p.control.BringToFront();

                        #region новый проект

                        if (!prjIDs.ContainsKey(p.control.project.id) )
                        {
                            addProjectIDToFile(p.control.project.id);
                            if (!is_customer && clsConfig.NotifyInterestProjOnly)
                            { npc++; }
                        }
                        #endregion
                    }

                    scrollSearchedProject.Visible = true;
                    frmUpdInfo.addMessage("Новый проект " + npc, this, tabControl1);
                }
            }
        }
コード例 #4
0
        public cntrlProject(clsProject project)
        {
            InitializeComponent();
            this.project       = project;
            this.lblAutor.Text = project.from.login;


            this.lblTime.Text = "";// +
            this.lblName.Text = project.name;

            /*"budget_amount":"10",
             * "budget_currency_code":"EUR",*/

            if (project.budget_amount != null || project.budget_amount != "")
            {
                this.lblBudget.Text = project.budget_amount;
                if (project.budget_currency_code != null || project.budget_currency_code != "")
                {
                    if (project.budget_currency_code == "EUR")
                    {
                        this.lblBudget.Text += " €";
                    }
                    else if (project.budget_currency_code == "USD")
                    {
                        this.lblBudget.Text += " $";
                    }
                    else if (project.budget_currency_code == "UAH")
                    {
                        this.lblBudget.Text += " ₴";
                    }
                    else if (project.budget_currency_code == "RUB")
                    {
                        this.lblBudget.Text += " ₽";
                    }
                    else
                    {
                        this.lblBudget.Text += project.budget_currency_code;
                    }
                }
            }
            else
            {
                this.lblBudget.Text    = "";
                this.lblBudget.Visible = false;
                //this.lblBudget.Width = 1;
            }
            //if (lblBudget.Text == "")
            //{
            //    int yy = (panel2.Height - pcbAvatar.Height) / 2;
            //    int xx = pcbAvatar.Location.X;
            //    pcbAvatar.Location = new Point(xx,yy);
            //}

            //this.lblState.Text = project.status_name;
            //this.lblNumber.Text = "#" + project.id.ToString();
            //this.pcbIsFeatured.Image = project.is_featured ? (Image)Resources.prj_is_featured : (Image)Resources.prj_is_featured_gray;
            //this.pcbIsIdentityVerified.Image = project.is_identity_verified ? (Image)Resources.prj_is_identity_verified : (Image)Resources.prj_is_identity_verified_gray;
            //this.pcbIsJob.Image = project.is_job ? (Image)Resources.prj_is_job : (Image)Resources.prj_is_job_gray;
            //this.lblDescription.Text += project.publication_time;

            if (project.is_featured)
            {
                //this.Height += this.pcbAvatar.Width - this.pcbAvatar.Height;
                //this.pcbAvatar.Height = this.pcbAvatar.Width;
            }

            #region ставки
            this.lblBidCount.Text = project.bid_count.ToString();
            if (project.bid_count == 1 || project.bid_count == 21 || project.bid_count == 31 || project.bid_count == 41 || project.bid_count == 51 || project.bid_count == 61 || project.bid_count == 71 || project.bid_count == 81 || project.bid_count == 91 || project.bid_count == 101)
            {
                this.lblBidCount.Text += " ставка  ";
            }
            else if (project.bid_count >= 2 && project.bid_count <= 4 || project.bid_count >= 22 && project.bid_count <= 24 || project.bid_count >= 32 && project.bid_count <= 34 || project.bid_count >= 42 && project.bid_count <= 44 || project.bid_count >= 52 && project.bid_count <= 54 || project.bid_count >= 62 && project.bid_count <= 64 || project.bid_count >= 72 && project.bid_count <= 74 || project.bid_count >= 82 && project.bid_count <= 84 || project.bid_count >= 92 && project.bid_count <= 94)
            {
                this.lblBidCount.Text += " ставки  ";
            }
            else
            {
                this.lblBidCount.Text += " ставок  ";
            }
            #endregion

            #region время
            if (project.publication_time != null || project.publication_time != "")
            {
                DateTime DT;
                try { DT = DateTime.Parse(project.publication_time); }
                catch (Exception)
                {
                    this.lblTime.Text = " ";
                    new Thread(new ThreadStart(this.downLoadImage)).Start();
                    return;
                }

                TimeSpan dtn = DateTime.Now - DT;


                if (dtn.Days == 0)
                {
                    this.lblTime.Text += "";
                }
                else if (dtn.Days == 1)
                {
                    this.lblTime.Text += "1 день ";
                }
                else if (dtn.Days >= 2 && dtn.Days <= 4)
                {
                    this.lblTime.Text += dtn.Days + " дня ";
                }
                else if (dtn.Days >= 5 && dtn.Days <= 20)
                {
                    this.lblTime.Text += dtn.Days + " дней ";
                }
                else
                {
                    this.lblTime.Text += " более 21-го дня назад ";
                    new Thread(new ThreadStart(this.downLoadImage)).Start();
                    return;
                }

                if (dtn.Hours == 0)
                {
                    this.lblTime.Text += "";
                }
                else if (dtn.Hours == 1 || dtn.Hours == 21)
                {
                    this.lblTime.Text += dtn.Hours + " час ";
                }
                else if (dtn.Hours >= 2 && dtn.Hours <= 4 || dtn.Hours >= 22 && dtn.Hours <= 24)
                {
                    this.lblTime.Text += dtn.Hours + " часа ";
                }
                else if (dtn.Hours >= 5 && dtn.Hours <= 20)
                {
                    this.lblTime.Text += dtn.Hours + " часов ";
                }

                if (dtn.Minutes == 0)
                {
                    this.lblTime.Text += "назад  ";
                }
                else if (dtn.Minutes == 1 || dtn.Minutes == 21 || dtn.Minutes == 31 || dtn.Minutes == 41 || dtn.Minutes == 51)
                {
                    this.lblTime.Text += dtn.Minutes + " минуту назад  ";
                }
                else if (dtn.Minutes >= 2 && dtn.Minutes <= 4 || dtn.Minutes >= 22 && dtn.Minutes <= 24 || dtn.Minutes >= 32 && dtn.Minutes <= 34 || dtn.Minutes >= 42 && dtn.Minutes <= 44 || dtn.Minutes >= 52 && dtn.Minutes <= 54)
                {
                    this.lblTime.Text += dtn.Minutes + " минуты назад  ";
                }
                else
                {
                    this.lblTime.Text += dtn.Minutes + " минут назад  ";
                }
            }
            if (this.lblTime.Text.Trim() == "назад")
            {
                this.lblTime.Text = "только что";
            }
            #endregion

            new Thread(new ThreadStart(this.downLoadImage)).Start();

            #region skills
            lblCategories.Text = "";
            if (this.project.skills != null)
            {
                foreach (KeyValuePair <int, string> keyValuePair in this.project.skills)
                {
                    lblCategories.Text += keyValuePair.Value + ", ";
                }
            }
            if (lblCategories.Text.EndsWith(", "))
            {
                lblCategories.Text = lblCategories.Text.Substring(0, lblCategories.Text.Length - 2);
            }
            #endregion

            #region skills

            /* if (project.skills != null)
             * {
             *   foreach (KeyValuePair<int, string> keyValuePair in project.skills)
             *   {
             *       cntrlTagtext cntrlTagtext = new cntrlTagtext(keyValuePair.Value);
             *       cntrlTagtext.Dock = DockStyle.Left;
             *       cntrlTagtext.Parent = (Control)this.pnlSkills;
             *   }
             * }*/
            #endregion
        }
コード例 #5
0
        private void frmProjectFullInfo_Load(object sender, EventArgs e)
        {
            string str = clsUpdate.getProjectFullInfo(this.projectId);

            List<clsJSON> list = clsJSON.parceProj(str);

            #region проверка на ошибку
            if (list == null)
                this.Close();
            else if (list.Count != 1)
                this.Close();
            else if (list[0].bloks == null)
                this.Close();
            else if (list[0].bloks.Count == 0)
                this.Close();
            else if (Enumerable.FirstOrDefault<clsJSON_block>((IEnumerable<clsJSON_block>)list[0].bloks, (Func<clsJSON_block, bool>)(b => b.name.CompareTo("from") == 0)) == null)
            { this.Close(); }
            #endregion

            else
            {
                this.project = new clsProject(list[0]);

                this.lblName.Text = this.project.name;

                this.lblTime.Text = DateTime.Parse(this.project.publication_time).ToLongDateString() + " " + DateTime.Parse(this.project.publication_time).ToShortTimeString();
                this.lblDescription.Text = this.project.description.Replace("n", "\n");

                string descHtml =  this.project.description_html;

                #region убираем пустые строки в конце описани¤

                while (descHtml.EndsWith("<p></p>"))
                {
                    descHtml = descHtml.Remove(descHtml.Length - 7);
                }
                while (descHtml.EndsWith("<p><br /></p>"))
                {
                    descHtml = descHtml.Remove(descHtml.Length - 13);
                }
                #endregion

                #region корректировка высоты окна

                int i = descHtml.Split(new string[] { "<p>" }, StringSplitOptions.None).Count();

                int ns = 0;
                foreach (char c in this.lblDescription.Text) { if (c == '\n') { ns++; } }
                ns = (ns * 7) / 10 + 1;
                i = (i * 7) / 10 + 1;
                //MessageBox.Show(i+"\n"+ns);
                while (i > 0)
                {
                    this.lblDescription.Text += "\n ";
                    i--;
                }
                #endregion

                this.webBrowser1.DocumentText = "<font size=\"2\" face=\"Open Sans\">" + descHtml + "</font>";

                #region skills
                lblCategories.Text = "";
                if (this.project.skills != null)
                {
                    foreach (KeyValuePair<int, string> keyValuePair in this.project.skills)
                    { lblCategories.Text += keyValuePair.Value + ", "; }
                }
                if (lblCategories.Text.EndsWith(", ")) {
                    lblCategories.Text = lblCategories.Text.Substring(0, lblCategories.Text.Length - 2);
                }
                #endregion

                #region ставки
                this.lblBidCount.Text = this.project.bid_count.ToString();
                if (this.project.bid_count == 1 || this.project.bid_count == 21 || this.project.bid_count == 31 || this.project.bid_count == 41 || this.project.bid_count == 51 || this.project.bid_count == 61 || this.project.bid_count == 71 || this.project.bid_count == 81 || this.project.bid_count == 91 || this.project.bid_count == 101) { this.lblBidCount.Text += " ставка  "; }
                else if (this.project.bid_count >= 2 && this.project.bid_count <= 4 || this.project.bid_count >= 22 && this.project.bid_count <= 24 || this.project.bid_count >= 32 && this.project.bid_count <= 34 || this.project.bid_count >= 42 && this.project.bid_count <= 44 || this.project.bid_count >= 52 && this.project.bid_count <= 54 || this.project.bid_count >= 62 && this.project.bid_count <= 64 || this.project.bid_count >= 72 && this.project.bid_count <= 74 || this.project.bid_count >= 82 && this.project.bid_count <= 84 || this.project.bid_count >= 92 && this.project.bid_count <= 94) { this.lblBidCount.Text += " ставки  "; }
                else this.lblBidCount.Text += " ставок  ";
                #endregion

                this.lblLogin.Text = this.project.from.fname + " " + this.project.from.sname + " (" + this.project.from.login + ")";

                this.pcbProfileAvatar.BeginInvoke(new Action(() => this.pcbProfileAvatar.Image = (Image)Resources.DefaultAva));
                this.imgDownloadTryCount = 0;
                new Thread(new ThreadStart(this.downLoadImage)).Start();

                if (this.project.is_bid_added)
                {
                    button1.BackColor = Color.LightSteelBlue;
                    button1.Cursor = Cursors.No;
                }

                if (Form1.is_customer) { button1.Visible = false; }

                this.TopMost = true;
            }
        }
コード例 #6
0
        public cntrlProject(clsProject project)
        {
            InitializeComponent();
            this.project = project;
            this.lblAutor.Text = project.from.login;

            this.lblTime.Text = "";// +
            this.lblName.Text = project.name;

            /*"budget_amount":"10",
            "budget_currency_code":"EUR",*/

            if (project.budget_amount != null || project.budget_amount != "")
            {
                this.lblBudget.Text = project.budget_amount;
                if (project.budget_currency_code != null || project.budget_currency_code != "")
                {
                    if      (project.budget_currency_code == "EUR") { this.lblBudget.Text += " €"; }
                    else if (project.budget_currency_code == "USD") { this.lblBudget.Text += " $"; }
                    else if (project.budget_currency_code == "UAH") { this.lblBudget.Text += " ₴"; }
                    else if (project.budget_currency_code == "RUB") { this.lblBudget.Text += " ₽"; }
                    else this.lblBudget.Text += project.budget_currency_code;
                }
            }
            else {
                this.lblBudget.Text = "";
                this.lblBudget.Visible = false;
                //this.lblBudget.Width = 1;
            }
            //if (lblBudget.Text == "")
            //{
            //    int yy = (panel2.Height - pcbAvatar.Height) / 2;
            //    int xx = pcbAvatar.Location.X;
            //    pcbAvatar.Location = new Point(xx,yy);
            //}

            //this.lblState.Text = project.status_name;
            //this.lblNumber.Text = "#" + project.id.ToString();
            //this.pcbIsFeatured.Image = project.is_featured ? (Image)Resources.prj_is_featured : (Image)Resources.prj_is_featured_gray;
            //this.pcbIsIdentityVerified.Image = project.is_identity_verified ? (Image)Resources.prj_is_identity_verified : (Image)Resources.prj_is_identity_verified_gray;
            //this.pcbIsJob.Image = project.is_job ? (Image)Resources.prj_is_job : (Image)Resources.prj_is_job_gray;
            //this.lblDescription.Text += project.publication_time;

            if (project.is_featured) {

                //this.Height += this.pcbAvatar.Width - this.pcbAvatar.Height;
                //this.pcbAvatar.Height = this.pcbAvatar.Width;
            }

            #region ставки
            this.lblBidCount.Text = project.bid_count.ToString();
            if (project.bid_count == 1 || project.bid_count == 21 || project.bid_count == 31 || project.bid_count == 41 || project.bid_count == 51 || project.bid_count == 61 || project.bid_count == 71 || project.bid_count == 81 || project.bid_count == 91 || project.bid_count == 101) { this.lblBidCount.Text += " ставка  "; }
            else if (project.bid_count >= 2 && project.bid_count <= 4 || project.bid_count >= 22 && project.bid_count <= 24 || project.bid_count >= 32 && project.bid_count <= 34 || project.bid_count >= 42 && project.bid_count <= 44 || project.bid_count >= 52 && project.bid_count <= 54 || project.bid_count >= 62 && project.bid_count <= 64 || project.bid_count >= 72 && project.bid_count <= 74 || project.bid_count >= 82 && project.bid_count <= 84 || project.bid_count >= 92 && project.bid_count <= 94) { this.lblBidCount.Text += " ставки  "; }
            else this.lblBidCount.Text += " ставок  ";
            #endregion

            #region время
            if (project.publication_time != null || project.publication_time != "")
            {
                DateTime DT;
                try { DT = DateTime.Parse(project.publication_time); }
                catch (Exception)
                {
                    this.lblTime.Text = " ";
                    new Thread(new ThreadStart(this.downLoadImage)).Start();
                    return;
                }

                TimeSpan dtn = DateTime.Now - DT;

                if (dtn.Days == 0) { this.lblTime.Text += ""; }
                else if (dtn.Days == 1) { this.lblTime.Text += "1 день "; }
                else if (dtn.Days >= 2 && dtn.Days <= 4) { this.lblTime.Text += dtn.Days + " дня "; }
                else if (dtn.Days >= 5 && dtn.Days <= 20) { this.lblTime.Text += dtn.Days + " дней "; }
                else
                {
                    this.lblTime.Text += " более 21-го дня назад ";
                    new Thread(new ThreadStart(this.downLoadImage)).Start();
                    return;
                }

                if (dtn.Hours == 0) { this.lblTime.Text += ""; }
                else if (dtn.Hours == 1 || dtn.Hours == 21) { this.lblTime.Text += dtn.Hours + " час "; }
                else if (dtn.Hours >= 2 && dtn.Hours <= 4 || dtn.Hours >= 22 && dtn.Hours <= 24) { this.lblTime.Text += dtn.Hours + " часа "; }
                else if (dtn.Hours >= 5 && dtn.Hours <= 20) { this.lblTime.Text += dtn.Hours + " часов "; }

                if (dtn.Minutes == 0) { this.lblTime.Text += "назад  "; }
                else if (dtn.Minutes == 1 || dtn.Minutes == 21 || dtn.Minutes == 31 || dtn.Minutes == 41 || dtn.Minutes == 51) { this.lblTime.Text += dtn.Minutes + " минуту назад  "; }
                else if (dtn.Minutes >= 2 && dtn.Minutes <= 4 || dtn.Minutes >= 22 && dtn.Minutes <= 24 || dtn.Minutes >= 32 && dtn.Minutes <= 34 || dtn.Minutes >= 42 && dtn.Minutes <= 44 || dtn.Minutes >= 52 && dtn.Minutes <= 54) { this.lblTime.Text += dtn.Minutes + " минуты назад  "; }
                else this.lblTime.Text += dtn.Minutes + " минут назад  ";
            }
            if (this.lblTime.Text.Trim() == "назад") { this.lblTime.Text = "только что"; }
            #endregion

            new Thread(new ThreadStart(this.downLoadImage)).Start();

            #region skills
            lblCategories.Text = "";
            if (this.project.skills != null)
            {
                foreach (KeyValuePair<int, string> keyValuePair in this.project.skills)
                { lblCategories.Text += keyValuePair.Value + ", "; }
            }
            if (lblCategories.Text.EndsWith(", "))
            {
                lblCategories.Text = lblCategories.Text.Substring(0, lblCategories.Text.Length - 2);
            }
            #endregion

            #region skills
               /* if (project.skills != null)
            {
                foreach (KeyValuePair<int, string> keyValuePair in project.skills)
                {
                    cntrlTagtext cntrlTagtext = new cntrlTagtext(keyValuePair.Value);
                    cntrlTagtext.Dock = DockStyle.Left;
                    cntrlTagtext.Parent = (Control)this.pnlSkills;
                }
            }*/
            #endregion
        }