我想Glyphs在WP7 上使用来创建一个合理的文本行,即触摸周围矩形的左右边框.
var glyphs = new Glyphs();
glyphs.FontUri = new Uri("/MyAssembly;component/MyPath/MyFont.ttf", UriKind.Relative);
glyphs.FontRenderingEmSize = 20;
glyphs.Fill = new SolidColorBrush(Colors.Red);
// measue width of space
glyphs.UnicodeString = " ";
glyphs.Measure(availableSize);
double spaceWidth = glyphs.DesiredSize.Width;
glyphs.InvalidateMeasure();
// setup justified text
string text = "Lorem Ipsum is dummy text of the printing and typesetting industry.";
int spaceCount = 10; // number of spaces in above text
glyphs.UnicodeString = text;
glyphs.Measure(availableSize); // now DesiredSize.Width = width of left aligned text …Run Code Online (Sandbox Code Playgroud) 我正在尝试改变PickerView的高度
self.pickerView = [[UIPickerView alloc] init];
self.pickerView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
Run Code Online (Sandbox Code Playgroud)
Xcode日志显示以下消息:
-[UIPickerView setFrame:]: invalid height value 274.0 pinned to 216.0
Run Code Online (Sandbox Code Playgroud)
我怎样才能改变它的高度?
由于缺少SQL枚举类型,不幸的是有些流行的数据库设计模式似乎是为所有枚举值创建一个表(感谢您的链接,Nathan).多年来我看到了很多这种变化,但我目前正在努力解决的问题看起来像这样:
ID | ENUM | VALUE
-----+-------------+----------
1 | DAY_OF_WEEK | SUNDAY
2 | DAY_OF_WEEK | MONDAY
...
7 | DAY_OF_WEEK | SATURDAY
...
18 | PERSON_TYPE | EMPLOYEE
19 | PERSON_TYPE | MANAGER
Run Code Online (Sandbox Code Playgroud)
然后将其用于此类 - 例如在人员表中:
ID | NAME | TYPE
----+----------+------
1 | Jane Doe | 19
Run Code Online (Sandbox Code Playgroud)
这意味着Jane是一个管理器,因为19是enum表中人员类型"manager"的主键.
使用JPA(2.1),是否有一种优雅的方法将此构造映射到propper Java枚举?
重要提示:我的"枚举表"有许多版本在野外,具有不同的主键值,即"经理"有时可能是第19行,但有时排第231行.但是,值在运行时永远不会更改.遗憾的是,更改数据库模式也不是一种选择,但使用任何JPA提供程序的专有功能都是一种选择.
我实际上找到了一个有效的解决方案,但这对我来说太难了:
public enum PersonType { EMPLOYEE, MANAGER }
@Table(name="PERSONS") @Entity public class Persons {
@Id …Run Code Online (Sandbox Code Playgroud) 我正在学习Haskell并编写了这个函数:
continueWith :: [a] -> a -> [a]
continueWith [] y = repeat y
continueWith (x:xs) y = x : (continueWith xs y)
Run Code Online (Sandbox Code Playgroud)
现在,我不明白GHCi的行为:
GHCi> let x = continueWith [1, 2] 3
x :: [Integer]
GHCi> :sp x
x = _
GHCi> take 3 x
[1,2,3]
it :: [Integer]
GHCi> :sp x
Run Code Online (Sandbox Code Playgroud)
最后一个sprint没有终止,但我预计返回的thunk repeat只能评估到第一个缺点:
...
GHCi> take 3 x
[1,2,3]
it :: [Integer]
GHCi> :sp x
x = 1 : 2 : 3 : _ <= This …Run Code Online (Sandbox Code Playgroud) 我正在阅读这个JavaFX教程,使用Scala作为实现语言,并遇到了一个问题,我的隐式转换未被提取:
class HelloApplication extends Application {
import HelloApplication._
override def start(stage: Stage) {
stage.setTitle("Hello World!")
val btn = new Button()
btn.setText("Say 'Hello World'")
btn.setOnAction(function2EventHandler(buttonPressed))
val root = new StackPane()
root.getChildren.add(btn)
stage.setScene(new Scene(root, 300, 250))
stage.show()
}
def buttonPressed(ev: ActionEvent) {
println("Hello World!")
}
}
object HelloApplication {
implicit def function2EventHandler[A <: Event](f: A => Unit): EventHandler[A] =
new EventHandler[A] {
override def handle(t: A) = f(t)
}
}
Run Code Online (Sandbox Code Playgroud)
当我改变这一行
btn.setOnAction(function2EventHandler(buttonPressed))
Run Code Online (Sandbox Code Playgroud)
至
btn.setOnAction(buttonPressed)
Run Code Online (Sandbox Code Playgroud)
我收到了编译错误.你能指出我做错了什么吗?
我正在使用JDK 7和Scala 2.11.4附带的JavaFX.