我目前正在使用VS studio 2010,.NET 4.0.这是我的场景:
我目前有一个名为"Images"的类库项目,其中包含一个名为"Icons"的子文件夹.我的所有图标目前都存在于此项目中,并通过siteoforigin由多个项目访问.在设计师中,一切都很好,但在运行时,图像不会显示.
这是我的文件夹结构:
所有项目都引用Images类lib.proj,"Images"项目中"icons"子文件夹内的所有图标都设置为:"Build Action = Resource".
xaml看起来像这样(在设计时完全可见):
<Button Name="Button1" Click="Button1_Click">
<Button.Content>
<Image Source="pack://siteoforigin:,,,/Data.Images;component/Icons/Button1.png" />
</Button.Content>
</Button>
Run Code Online (Sandbox Code Playgroud) 我正在创建一个前台服务,其中包含服务启动时通知栏中显示的通知.如果服务停止,通知将解除.我的问题是,当"清除所有通知"或解除通知(滑动)时,有没有办法停止服务?
更新以包括通知的实施:
public int onStartCommand(Intent intent, int flags, int startId)
{
Log.d(CLASS, "onStartCommand service started.");
if (getString(R.string.service_start_action) == intent.getAction())
{
Intent intentForeground = new Intent(this, ServiceMain.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intentForeground, 0);
Notification notification;
Notification.Builder builder = new Notification.Builder(getApplicationContext())
.setSmallIcon(android.R.drawable.btn_star)
.setTicker("Service started...")
.setContentIntent(pendIntent)
.setDefaults(Notification.DEFAULT_ALL)
.setOnlyAlertOnce(true)
.setOngoing(false);
notification = builder.build();
notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
startForeground(SERV_NOTIFY, notification);
player.start();
}
else
{
Log.d(CLASS, "onStartCommand unable to identify acition.");
}
return START_STICKY;
}
Run Code Online (Sandbox Code Playgroud) 我目前正在查询Android sms/mms数据库以检索MMS收到和发送的所有邮件.一切正常,但我注意到m_size列只有已MMS发送(未收到)的消息的值.
这是查询:
final String[] projection = new String[]{ "*" };
Uri uri = Uri.parse("content://mms");
Cursor query = _activity.getContentResolver().query(uri, projection, null, null, null);
Run Code Online (Sandbox Code Playgroud)
使用这个,我能够检索消息的总字节数,但它当前正在返回null收到的MMS消息.
if (query.moveToFirst())
{
do
{
// ...
Integer size = query.getInt(query.getColumnIndex("m_size"));
}
while (query.moveToNext());
}
Run Code Online (Sandbox Code Playgroud)
而不必计算"data"该消息的列大小,是有什么错我的查询/任何理由m_size将返回null为MMS收到的消息(并且有一个有效图片附件)?
注意:不确定早期API中是否有任何更改,因为此API未记录.我目前正在使用API 23在Nexus 5X上进行测试/开发.
我目前正在使用WPF中的单击事件调用Windows任务管理器.该事件只执行'Process.Start("taskmgr").
我的问题是,有没有办法在流程开始/显示时选择任务管理器中的哪个选项卡?我希望在引发click事件时自动选择"性能"选项卡.
谢谢您的帮助.
我一直在玩Unity以了解它,并遇到了以下情况.如果我要两次注册相同类型,但是一个是单例,我怎么调用Resolve才能返回单例?我知道这可以使用一个独特的Name,但我想知道如果没有这个可以完成.
例如:
_container.RegisterType<Music>(new InjectionConstructor(new Album("Non-singleton", "Non-singleton")));
_container.RegisterType<Music>(new ContainerControlledLifetimeManager());
Run Code Online (Sandbox Code Playgroud)
并打电话
var music = Factory.Resolve<Music>();
Run Code Online (Sandbox Code Playgroud)
返回'Non-singleton'对象.起初,我认为这是基于注册顺序,但切换我仍然收到'非单例'实例.
是否有一个原因?有没有办法Resolve只在同一容器中的两个注册对象的单例类型w/out指定Name属性?
.net c# dependency-injection inversion-of-control unity-container
RichTextBox放置在ViewBox内并缩放到10 - 1000%的各种级别.当百分比小于100%时,插入符号在随机光标位置消失.
我知道当视觉被缩小(压缩)时,它会丢失像素.有什么方法可以让我不再失去光标吗?
<Viewbox>
<RichTextBox Name="richTextBox1" Width="400" Height="400" />
</Viewbox>
Run Code Online (Sandbox Code Playgroud) 新手在这里努力成为一名业余爱好者。
我当前的项目使用方法、类、列表来显示书籍和评论,并允许用户在控制台视图中输入自己的评论。我已经构建了我的类,并且它们此时正在工作,因此我暂时删除了它们,以尽可能清楚地暴露我当前的问题。解决我的问题是,我觉得我的程序很快就变得很大,所以将一些代码移到我称为“选择”的方法中似乎是个好主意。在我将代码移至 select 方法之前,它工作正常/符合预期。但现在我在测试时遇到错误:没有可以打破的封闭循环
具体错误发生在线else if (command == "e"){break;}路上
我尝试将关键字“break”替换为“Continue”,但这不起作用。我已经浏览了网络和 stackoverflow,但没有找到任何我可以理解的内容,以我的理解水平来解决(我仍然是一个新手)。
代码:
class Program
{
public void Play(){
Announcer(" \n\nProgram Name Goes Here \n\n");
while (true)
{
/*
* Allow user to display director of books (Three)
* allow user to select specific book with any comments it might have (2-4 comments)
* Allow user to enter a specific comment
* display book with new new added comment
* Allow user to exit book
* */
Select();
Console.Read(); …Run Code Online (Sandbox Code Playgroud) 我试图找出用户输入的数组是否已排序(尽管不尝试排序).如果用户的输入是从最小到最大的升序,我想写一条消息说"输入已排序",如果不是"用户输入未排序".
到目前为止这是我的代码:
public static void Main()
{
int[] array = new int[20];
int n = 0;
char Continue;
InputArray(array, ref n);
IsSorted(array, n);
Console.WriteLine("{0}", IsSorted(array, n));
do{
Console.Write("Would you like to continue? Y/N : ");
Continue = Convert.ToChar(Console.ReadLine());
Continue = char.ToUpper(Continue);
}while(Continue != 'N');
}
public static void InputArray(int[] array, ref int n)
{
int i = 0;
Console.Write("Enter a number of elements under 20: ");
n = Convert.ToInt32(Console.ReadLine());
if (n < 0 || n > 20)
{
Console.Write("Please enter …Run Code Online (Sandbox Code Playgroud)