我想将按钮的背景颜色绑定到枚举.我想知道是否有一个可以容纳多个值的枚举对象,例如状态和颜色.我想避免两个可能不同步的枚举.以下是我想要相互整合的两个枚举.
enum StateValue { Player, Wall, Box }
enum StateColor { Colors.Red, Colors.Grey, Colors.Brown }
Run Code Online (Sandbox Code Playgroud)
然后我需要为XAML按钮创建一个绑定.
<Button Content="Player" Background="{Binding Source=...?}" />
Run Code Online (Sandbox Code Playgroud)
也许,像下面的字典是有帮助的.但我仍然不知道如何编写绑定.
public Dictionary<StateValue, Color> stateValueColor =
new Dictionary<ElementState, Color>()
{
{ StateValue.Player, Colors.Red },
{ StateValue.Wall, Colors.Grey },
{ StateValue.Box, Colors.Brown }
};
Run Code Online (Sandbox Code Playgroud) 我想保存很多文件,差不多200个.当我只保存一些文件时,我就是这样做的:
dialog.Filter = "Bmp files (*.bmp)|*.bmp";
dialog.FileName = name + "_copy";
dialog.ShowDialog();
bitmap1.Save(dialog.FileName);
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做但不使用dialog.showdialog()?
我想开发一个仅供Windows Phone 7使用的应用程序.我可以不经过应用程序商店吗?从我的PC直接到使用USB的手机?
我在Ruby 1.9.2上运行Rails 3.0.1.以下是相关的模型,控制器和视图.
user.rb:
class User < ActiveRecord::Base
belongs_to :directory
attr_accessor :new_password, :new_password_confirmation
validates_confirmation_of :new_password, :if => :password_changed?
before_save :hash_password, :if => :password_changed?
def self.authenticate(login, password)
# Check to see if the user exists
if user = find_by_login(login)
# If this is an directory user, authenticate them against their directory
if user.directory
return directory_auth user, password
# Otherwise, authenticate them against the local database
elsif user.hash == Digest::SHA2.hexdigest(user.salt + password)
return user
end
end
return nil
end
def …
Run Code Online (Sandbox Code Playgroud) 我已将MapView上的经度和纬度转换为MKMapPoint.然后,我想使用imageViews center属性将imageView移动到该点.似乎我不知何故需要将MKMapPoint转换为CGPoint以便我可以更改中心,但数字似乎已经过时了.这是我正在使用的:
// Convert to MKMapPoint
CLLocationCoordinate2D coord;
coord.latitude = [loc.latitude doubleValue];
coord.longitude = [loc.longitude doubleValue];
MKMapPoint point = MKMapPointForCoordinate(coord);
// Move our image
CGFloat newXPos = point.x;
CGFloat newYPos = point.y;
CGPoint newCenter = {newXPos, newYPos};
self.movingMarker.center = newCenter;
//self.movingMarker.frame.origin.x = point.x;
//self.movingMarker.frame.origin.y = point.y;
Run Code Online (Sandbox Code Playgroud)
关于如何使我的MKMapPoint成为我的图像的中心属性的可行值的想法?
我试图理解在使用BerkeleyDB时应该选择哪种访问方法:B-Tree与HashTable.Hashtable提供O(1)查找,但插入是昂贵的(使用线性/可扩展散列我们得到分摊O(1)插入).但B-Trees提供log N(base B)查找和插入时间.B-Tree还可以支持范围查询并允许按排序顺序进行访问.
我正在开发一个名为Enchanting的应用程序.该应用程序基于Scratch,发出Java源代码并编译它以便上传到LEGO Mindstorms NXT机器人.
虽然应用程序很早,但用户很难安装它.
现在Windows用户必须:
如果我可以提供包含JDK和LeJOS的安装程序,我可以在运行时找出环境变量,并且该过程变为:
有没有办法重新分配JDK?
(顺便说一下,Processing(简化的基于文本的编程环境)似乎提供了JDK附带的一个版本,因此看起来有一种合法的方式).
附录:我希望没有安装java的Windows用户能够运行单个.exe文件来安装JDK,LeJOS和Enchanting.
我想知道公司使用的当前标准C编译器是什么.我知道以下编译器,并不了解哪一个用于学习目的.
我现在正在学习C并参考K&R书.
任何人都可以指导我使用哪个编译器?
我心不在焉地在我的svn主干中找到一个文件夹而不是分支它.我可以把它还给我,但我担心我会失去历史.这怎么回事最好?
编辑:我应该清楚我在存储库上进行了移动,而不是我的工作副本,因此它是一个自动提交.
我知道有两种方法可以"漂亮地打印"或格式化xml:
shell工具 Hack 38 Pretty-Print XML使用通用标识样式表和Xalan
有什么其他免费(如啤酒)格式化器?(除了使用javascript)