private void SetupPanel() { if (m_hgai == null) { return; } m_lbl_albumname.Text = String.IsNullOrEmpty(m_hgai.AlbumName) ? "未知编辑" : m_hgai.AlbumName; m_lbl_albumlabel.Text = "标签:"; // TODO: + m_hgai.AlbumName ? m_lbl_cat.Text = "分类:" + m_hgai.AlbumCategoryName; m_lbl_albumintro.Text = "简介:"; // TODO: + m_hgai.Al //TODO: if ((ContentPublishPanel.AlbumType)m_hgai.AlbumType == ContentPublishPanel.AlbumType.AudioAlbum) { m_bte_upload.Text = "上传音频"; } else { m_bte_upload.Text = "上传视频"; } // TODO: hgpp's isCheck and materialRecycleStatus doens't make sence and can't be retreived by m_hgai HGProgramParams hgpp = new HGProgramParams(m_hgai.AlbumId, 2, 1, 5, 1); if (Helpers.DebugHelper.getInstance().SamplePrograms) { hgpp = new HGProgramParams("190323013156596558242", 2, 1, 5, 1); } m_hg_program = HGRestfulAPI.getInstance().getHGProgram(hgpp); LoadPrograms(true); }
private void initAlbums() { // TODO: 根据界面参数来生成搜索参数 HGAlbumSearchParams hgasp = new HGAlbumSearchParams(1, 10); HGData.getInstance().Album = HGRestfulAPI.getInstance().getHGAlbum(hgasp); // HGAlbum hga = HGRestfulAPI.getInstance().getHGAlbum(1, "", 2, 1521738981174, 1541738981174, 1, 10); }
private void m_bte_add_Click(object sender, EventArgs e) { String albumName = m_tbx_albumname.Text; String albumLabel = m_tbx_albumtags.Text; String albumIntro = m_tbx_albumintro.Text; if (String.IsNullOrEmpty(albumName)) { MessageBox.Show("专辑名称不能为空"); m_tbx_albumname.Focus(); return; } // TODO: 判断是否选择了category // String albumCategoryId = "[10000000, 10001000, 10001001]"; HGComCategory hgcc = HGData.getInstance().ComCategory[m_cbx_albumcat1.SelectedIndex]; int cat1 = hgcc.Value; HGComCategoryItem hgcci = hgcc.Children[m_cbx_albumcat2.SelectedIndex]; int cat2 = hgcci.Value; HGComCategorySubItem hgccsi = hgcci.Children[m_cbx_albumcat3.SelectedIndex]; int cat3 = hgccsi.Value; Console.WriteLine("cat1 " + cat1 + " cat2 " + cat2 + "cat3 " + cat3); // TODO: 是否一定要封面? if (m_hg_iur == null) { MessageBox.Show("请上传专辑封面"); return; } String albumCoverUrl = HGRestfulAPI.FileServerBaseUrl + m_hg_iur.Url; String albumFileId = m_hg_iur.Data.FileId; Model.HGAlbumParams hgap = new HGAlbumParams(albumName, (int)m_album_type, albumIntro, albumCoverUrl, albumFileId, albumLabel, 10000000, 10001000, 10000001); if (Helpers.DebugHelper.getInstance().FakeNewAlbum) { hgap = new HGAlbumParams("70周年大阅兵7", (int)m_album_type, "70周年大阅兵,简介", "https://filetest.hongkazhijia.com/cb/cb7a88314621ad93ce4f9c5fe0495c942953197489e01f925162314153baa0a2.jpg", "cb7a88314621ad93ce4f9c5fe0495c942953197489e01f925162314153baa0a2", "70周年", 10000000, 10001000, 10000001); } try { // bool newAlbumOK = HGRestfulAPI.getInstance().newHGAlbum(albumName, 1, albumIntro, albumCoverUrl, albumFileId, albumLabel, albumCategoryId); bool newAlbumOK = HGRestfulAPI.getInstance().newHGAlbum(hgap); if (newAlbumOK) { MessageBox.Show("专辑《" + albumName + "》创建成功"); } else { MessageBox.Show("专辑《" + albumName + "》创建失败"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } this.Close(); }
private void LoadAlbums() { // TODO: 这个判断很重要,因为PagerControl会多次调用PageChange,没有必要我们不要多次调用网络。 if (m_curr_page == m_pgc_morealbum.CurrentPage && m_curr_rows_per_page == m_pgc_morealbum.RowsPerPage) { Console.WriteLine("No need to do duplicated operation"); return; } HGAlbumSearchParams hgasp = new HGAlbumSearchParams(m_pgc_morealbum.CurrentPage, m_pgc_morealbum.RowsPerPage); m_curr_page = m_pgc_morealbum.CurrentPage; m_curr_rows_per_page = m_pgc_morealbum.RowsPerPage; HGData.getInstance().Album = HGRestfulAPI.getInstance().getHGAlbum(hgasp); HGAlbum hga = HGData.getInstance().Album; if (hga == null) { return; } m_pgc_morealbum.RecordCount = hga.Total; foreach (AlbumInfo ai in m_albums) { this.Controls.Remove(ai); } m_albums.Clear(); for (int i = 0; i < hga.Data.Length; i++) { HGAlbumItem hgai = hga.Data[i]; AlbumInfo ai = new AlbumInfo(m_album_type, hgai); ai.AlbumName = hgai.AlbumName; if (!String.IsNullOrEmpty(hgai.FileUrl)) { try { MemoryStream ms = new MemoryStream(); Util.Download(HGRestfulAPI.FileServerBaseUrl + hgai.FileUrl, ms); ai.AlbumImage = Image.FromStream(ms); } catch (Exception ex) { //TODO; don't do that, just log MessageBox.Show("下载网络图片" + hgai.FileUrl + "失败:" + ex.Message); } } ai.ClickEventHandler += ShowAlbumDetail; m_albums.Add(ai); } ShowAlbums(); }
private void m_pbx_albumcover_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); // dialog.Multiselect = true;//该值确定是否可以选择多个文件 // dialog.Title = "请选择文件夹"; dialog.Filter = "图片文件(*.jpg,*.jpeg,*.png,*.bmp)|*.jpg;*.jpeg;*.png;*.bmp"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file = dialog.FileName; Console.WriteLine("file is " + file); if (getImageSize(file) > 1) { MessageBox.Show("图片文件不要超过1M"); return; } Image pic = Image.FromFile(file); //strFilePath是该图片的绝对路径 int intWidth = pic.Width; //长度像素值 int intHeight = pic.Height; //高度像素值 Console.WriteLine("file size is " + intWidth + "*" + intHeight); if (intWidth < 300 || intHeight < 300) { MessageBox.Show("图片分辨率不得低于300x300"); return; } m_hg_iur = HGRestfulAPI.getInstance().uploadHGFile(file); if (m_hg_iur == null || m_hg_iur.Status != 200) { MessageBox.Show("图片上传失败"); m_hg_iur = null; } else { m_pbx_albumcover.BorderStyle = BorderStyle.FixedSingle; m_pbx_albumcover.Load(file); } } }