我正在使用Windows Phone 7中的媒体播放器播放手机歌曲集中的音乐.但是当它播放音乐时,它们将是一个例外而且错误正在陈述
尚未调用FrameworkDispatcher.Update.定期的FrameworkDispatcher.Update调用是必要的,以便消除和忘记声音效果和框架事件以正常运行.
我该如何修改我的代码?
private void songBtn_Click(object sender, RoutedEventArgs e)
{
using (var ml = new MediaLibrary())
{
foreach (var song in ml.Songs)
{
System.Diagnostics.Debug.WriteLine(song.Artist + " " + song.Name);
MessageBox.Show(song.Artist + " " + song.Name);
}
MediaPlayer.Play(ml.Songs[0]);
}
}
Run Code Online (Sandbox Code Playgroud) 此表单具有NotifyIcon对象.当用户单击"关闭"按钮时,我希望表单不要关闭但是变得不可见.然后,如果用户想要再次看到该表单,他可以双击系统托盘中的图标.如果用户想要关闭表单,他可以右键单击该图标并选择"关闭".
有人能告诉我如何使关闭按钮不关闭表单但让它隐形吗?
(或者,如果有人能够想出一种更好的方法来实现同样的目标)
我有一个 System.Windows.Forms.ListView 包含许多项目。它闪烁得令人无法忍受(似乎经常是这种情况),所以经过一番搜索后,我决定在“ListViewLessFlicker”类中做这两件事。
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.Opaque, true);
Run Code Online (Sandbox Code Playgroud)
尽管 DoubleBuffering 在这些主题中最常作为解决方案给出,但它并没有太大影响,但将样式设置为不透明,真正大大减少了闪烁。
http://www.virtualdub.org/blog/pivot/entry.php?id=273
然而,它有一个副作用,我似乎无法找到解决办法。当我将鼠标悬停在 ListView 中的一个项目上时,它现在使文本变得粗体且非常模糊(除非 opaque 为真,否则不会发生这种情况)。
这是一个非常放大的示例。

如果有人有修复方法或知道为什么会这样做,我很想知道!
我需要一些代码帮助来替换 listView 中项目的文本。
我想替换我的 listView 第 4 列下的所有项目。这是第 4 列中项目的示例字符串:<span class="stat">0.58
无论如何,这是我为替换 listView 中的文本而编写的内容,但它不起作用:
foreach (ListViewItem i in listViewClickbank.Items)
{
if (i.SubItems[3].Text.Contains("span"))
{
i.Text.Replace("<span class=", "");
}
}
Run Code Online (Sandbox Code Playgroud) 我是 C# 的初学者,我遇到了一个问题。每次在webBrowser控件中进行搜索请求后,每次发现出现的情况时都需要弹出一个消息框,此时会选择出现的情况。我正在使用计时器刷新 webBrowser 并再次启动搜索。这就像一个通知系统。
using System;
using System.Windows.Forms;
using mshtml;
namespace websearch
{
public partial class Form1 : Form
{
Timer temp = new Timer();
//Timer refreshh = new Timer();
public Form1()
{
InitializeComponent();
temp.Tick += new EventHandler(refreshh_Tick);
temp.Interval = 1000 * 5;
temp.Enabled = true;
temp.Start();
WebBrowser1.Navigate("http://stackoverflow.com/");
}
void refreshh_Tick(object sender, EventArgs e)
{
WebBrowser1.Refresh();
WebBrowser1.DocumentCompleted += Carder_DocumentCompleted;
}
private void Carder_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
FindNext("C#", WebBrowser1);
temp.Tick += refreshh_Tick;
}
public void FindNext(string text, WebBrowser webBrowser2) …Run Code Online (Sandbox Code Playgroud) 我想在枚举中添加一个toString方法CustomerType.我的班级返回System.out.println()折扣百分比消息,如果取决于我cutomerType现在.20因为它是customerType大学.我是枚举的新手,我希望能够toString在我的枚举中添加一个方法,根据客户类型打印"College customer".我在完成这个方面遇到了一些麻烦?我究竟做错了什么?
听到我的班级:
import java.text.NumberFormat;
public class CustomerTypeApp
{
public static void main(String[] args)
{
// display a welcome message
System.out.println("Welcome to the Customer Type Test application\n");
// get and display the discount percent for a customer type
double Customer = getDiscountPercent(CustomerType.College);
NumberFormat percent = NumberFormat.getPercentInstance();
String display = "Discount Percent: " + percent.format(Customer);
System.out.println(display);
}
// a method that accepts a CustomerType enumeration
public static double getDiscountPercent (CustomerType ct) …Run Code Online (Sandbox Code Playgroud) 我正在编写这种方法来创建一个洗牌的牌组:
public static ArrayList<String> shuffle() {
String cards[] = {"Two of Spades","Three of Spades","Four of Spades","Five of Spades", "Six of Spades","Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades", "Ace of Spades",
"Two of Hearts","Three of Hearts","Four of Hearts","Five of Hearts", "Six of Hearts","Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts", "Ace of Hearts",
"Two …Run Code Online (Sandbox Code Playgroud) 我有一个小问题要问。如何将数字字段四舍五入到小数点后两位,并仅显示小数点后两位
例如,以下代码将返回255.88000000000
select round(255.87908765444,2)
Run Code Online (Sandbox Code Playgroud)
如何仅获得255.88?
请帮助。
谢谢,
当在类定义中有可变的私有字段,并且公开它们的getter / setter时,我们得到的异常如下所示:
[INFO] path.getInsertDate() may expose internal representation by returning Ttt.insertDate path.Ttt] At Ttt.java:[line 119]
Run Code Online (Sandbox Code Playgroud)
我添加了一个可变的类:
public class Test {
public String test;
}
Run Code Online (Sandbox Code Playgroud)
添加了此Test类和getters / setter方法的私有字段。但是finbugs很喜欢它。
public class ExposingTest {
private Test test;
//No warning here.
public Test getTest() {
return test;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么对于此警告,Findbugs仅检查Java标准库类,而不检查用户定义的类?有办法控制吗?