2013-07-21 31 views
0

正在嘗試使用簡單的FB API應用程序來檢索狀態。 所以我打算做的是用我的字典進行單詞檢查。 我有一個數據庫,存儲關於感覺的感覺%和風格的感性數據。 如果狀態包含情緒單詞,我希望進行單詞分析。 比如:「我感到傷心和憤怒」在表單中創建自動標籤以顯示數據庫中的值

所以我希望它顯示像... 「用戶名」 感覺 50%生氣 和25%傷心。

*%通過隨機函數計算。 但是,我認爲它不可能繼續創造標籤。如果我的狀態有5種情緒會怎麼樣?是否可以創建自動標籤來顯示輸出?

下面是我的代碼:

private void EmotionAnalysis_Load(object sender, EventArgs e) 
     { 
      label1.Text = tpc.loadInfo(currentId)["target_name"].ToString(); 
      //List<DataRow> result = dict.AngerPercent(fbStatus); 
      CalculateAndDisplayAnalysis("Angry", topPercentLabel, topFeelingLabel); 
      CalculateAndDisplayAnalysis("Caring", bottomPercentLabel, bottomFeelingLabel); 

      //var item = new ListViewItem(new[] { "", String.Format("{0}%", percent.ToString()), result[0]["Genre"].ToString() }); 
      //listViewEmotion.Items.Add(item); 
     } 

     private void CalculateAndDisplayAnalysis(string genre, Label percentLabel, Label feelingLabel) 
     { 
      List<DataRow> result = dict.GenrePercent(fbStatus, genre); 
      var rnd = new Random(); 
      int total = 0; 
      for (int i = 0; i < result.Count; i++) 
      { 
       total += rnd.Next(Convert.ToInt32(result[i]["Min_Percentage"]), Convert.ToInt32(result[i]["Max_Percentage"])); 
      } 
      if (result.Count != 0) 
      { 
       int percent = total/result.Count; 
       percentLabel.Text = String.Format("{0}%", percent.ToString()); 
       feelingLabel.Text = result[0]["Genre"].ToString(); 
      } 
     } 

回答

0

,只要你想你可以創建許多標籤。你只需要設置標籤的位置,並把它添加到窗體控件枚舉:

Label lbl = new Label(); 
lbl.Text = "MyText"; 
lbl.Location = new Position(xPos, yPos); 
this.Controls.Add(lbl); 

你將不得不繼續跟蹤新的位置,這是在這種情況下,通過xPosyPos

確定
相關問題