我想要做的是使用DrawString()方法将字符串绘制到位图.为此,我需要创建一个位图并从位图中获取Graphics对象,然后在该Graphics对象上调用DrawString().
问题是,我怎么知道,在我创建初始位图时,有多少像素宽和长来制作我的位图?
我知道这与MeasureString()有关,但是为了使用MeasureString(),我需要从位图中获取Graphics对象.在我创建位图之前我无法做到这一点,直到我知道尺寸才能做到这一点.这似乎是一个循环的悖论!
有人请帮我解决这个问题吗?
当我这样做时svn status .,我明白了:
! C auto-complete-config.elc
> local edit, incoming delete upon update
! + C auto-complete.elc
> local edit, incoming delete upon update
! + C popup.elc
> local edit, incoming delete upon update
! + C fuzzy.elc
> local edit, incoming delete upon update
Run Code Online (Sandbox Code Playgroud)
基本上,这些文件不应该在存储库中.开发人员已将其删除.然后,我认为我svn rm ...错误地做了一件事(应该完成了svn update .).
所以现在,当我这样做时svn status .,我得到了这些树冲突消息.
我在这里找到了doc 但不确定如何根据doc"合并"它.
如何摆脱它们?
我认为我的工作副本与存储库同步.不知道为什么这些消息会显示出来.据我所知,这些文件应该删除并删除.我尝试过svn update .,svn revert .但是当我这样做时,我仍然会收到此信息svn status ..
所以我正在尝试将Dialog与Tabs UI组件结合起来形成jQuery UI我几乎就在那里但我似乎无法将对话框关闭按钮从Dialog UI标题栏移动到Tabs UI中.
我试图将现有的Dialog UI标题栏关闭按钮移动到Tabs UI栏,但是这会出现很多问题并且鼠标悬停时按钮会移动.我尝试在Tabs UI栏中创建带有关闭图标的按钮,但事实证明这很难将按钮放在最右侧,具有按钮的外观(上面有关闭图标).
问题是Tabs UI栏只接受<li>因为它是a <ul>.如果我想在那里添加其他内容,我需要将其包含在内<li>,这会导致很多问题,或者我没有看到简单的解决方案.
谁能帮我吗?
这是我目前的代码:
<script type="text/javascript">
$(document).ready(function() {
$('#dialog-movie-info').dialog({
draggable: false,
resizable: false,
show: 'fade',
hide: 'fade',
modal: true,
height: 370,
width: 650,
position: ['center', 35],
open: function() {
//$('.ui-dialog-titlebar-close').appendTo('#ui-tab-dialog-close');
$(this).parent().children('.ui-dialog-titlebar').remove();
$('#tabs-movie').tabs();
},
close: function() {
$(this).find('#tab-info').children().remove();
$(this).dialog('destroy');
}
});
}
</script>
<div id="dialog-movie-info" class="ui-helper-hidden">
<div id="tabs-movie">
<ul>
<li><a href="#tab-info"><img src="template/images/icon-block.png" alt="" />Information</a></li>
<li><a href="#tab-cast"><img src="template/images/icon-block.png" alt="" />Cast List</a></li>
</ul>
<div id="tab-info">
<em>Info tab...</em>
</div> …Run Code Online (Sandbox Code Playgroud) 我有一个方法,比如说method1(),需要一段时间才能运行.在执行期间,如果再次调用method1(),则应该忽略它.我大概有这样的事情
boolean mFlag = false;
void method1()
{
if(!mFlag)
{
mFlag=true;
// do Stuff
mFlag=false;
}
}
Run Code Online (Sandbox Code Playgroud)
这有效.但我想知道是否有更好的方法来做到这一点,最好不要涉及任何标志.
我正在努力将sqrt函数(对于64位双精度数)从fdlibm移植到我目前正在使用的模型检查器工具(cbmc).
作为我的一部分,我阅读了很多关于ieee-754标准的内容,但我认为我不理解基本操作(包括sqrt)的精度保证.
测试我的fdlibm的sqrt端口,我在64位double上使用sqrt进行了以下计算:
sqrt(1977061516825203605555216616167125005658976571589721139027150498657494589171970335387417823661417383745964289845929120708819092392090053015474001800648403714048.0) = 44464159913633855548904943164666890000299422761159637702558734139742800916250624.0
Run Code Online (Sandbox Code Playgroud)
(这个案例在我的测试中打破了关于精度的简单后置条件;我不确定是否可以使用IEEE-754来实现这种后置条件)
为了进行比较,几个多精度工具计算如下:
sqrt(1977061516825203605555216616167125005658976571589721139027150498657494589171970335387417823661417383745964289845929120708819092392090053015474001800648403714048.0) =44464159913633852501611468455197640079591886932526256694498106717014555047373210.truncated
Run Code Online (Sandbox Code Playgroud)
可以看出,左起第17个数字是不同的,意味着如下错误:
3047293474709469249920707535828633381008060627422728245868877413.0
Run Code Online (Sandbox Code Playgroud)
问题1:是否允许这么大的错误?
标准是说每个基本操作(+, - ,*,/,sqrt)应该在0.5 ulps之内,这意味着它应该等于数学上精确的结果四舍五入到最近的fp表示(维基说的是一些库)只保证1 ulp,但目前并不重要).
问题2:这是否意味着,每个基本操作都应该有一个错误<2.220446e-16,64位双精度(机器epsilon)?
我用x86-32 linux系统(glibc/eglibc)计算了相同的结果,并得到了与fdlibm相同的结果,让我想到:
printf将成为候选人,但我不知道是否可能是这个原因)floating-point glibc floating-accuracy double-precision ieee-754
出于好奇,为什么我收到IllegalArgumentException了MONTH在下面的测试案例?
public class Testing {
public static void main(String args[]) {
Calendar c = Calendar.getInstance(Locale.getDefault());
c.setLenient(false);
Date d = new Date();
c.set(Calendar.MONTH, Calendar.FEBRUARY);
c.set(Calendar.DAY_OF_MONTH, 30);
c.set(Calendar.YEAR, 2010);
d = c.getTime(); //Exception is not thrown until this line
System.out.println(d.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
我查看了GregorianCalendar,它是我系统的默认值,并且意识到该MONTH字段实际上是第一个在2月30日与3月2日相比有所不同的字段,但这不IllegalArgumentException应该是导致溢出的原因,还是仅仅被认为难以"发现"?
我有两张桌子.一个是提交给我们的报告表.另一个是临时表,其中包含最终应提交给我们的报告记录.我想只显示临时表中与报告表中的记录不匹配的记录(因此显示仍然必须提交的报告).
示例数据是:
Reports table:
CREATE TABLE [dbo].[Reports]
(
[ReportID] [int] IDENTITY(1,1) NOT NULL,
[ReportDate] [date] NULL,
[AssessmentID] [int] NOT NULL,
[ReportType] [varchar](50) NULL
);
AssessmentID ReportType ReportID
1 1st Quarterly 27
2 1st Quarterly 30
2 2nd Quarterly 31
2 3rd Quarterly 32
QuarterlyReportsDue table:
CREATE TABLE #QuarterlyReportsDue
(
AssessmentID INT,
InstallationDate DATE,
QuarterlyReportType VARCHAR(50)
);
AssessmentID InstallationDate QuarterlyReportType
1 2009-08-14 1st Quarterly
1 2009-08-14 2nd Quarterly
1 2009-08-14 3rd Quarterly
1 2009-08-14 4th Quarterly
2 2008-05-16 4th Quarterly
2 …Run Code Online (Sandbox Code Playgroud) 我想知道在iPhone启动时允许在后台/前台启动什么类型的应用程序,它们是否仅限于iOS 4?
我试图通过jQuery的$ .ajax()方法发送html,然后将html转储到新的.html文件中,但内容因某种原因被切断了.
我已经设置了一个测试用例:
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script >
$(document).ready(function(){
var contents = $('html').html();
var filename = "test/000.html";
$.ajax({
type: "POST",
url: "/file.php",
data: "content="+contents+"&fn="+filename,
dataType: "html",
success: function(msg, ts, xh){
console.log(msg);
console.log(ts);
console.log(xh);
alert("success");
},
processData: false,
error: function(X, textStatus, error){
alert("Error saving... please try again now.")
}
});
});
</script>
</head>
<body>
<div id="rteContainer" class="dev">
<div id="textEditor">
<form>
<textarea name="balh" id="balh" rows="25" cols="103"></textarea>
<input type="button" id="updateContent" value="Update Changes">
<input type="button" id="closeEditor" value="Close Without Saving">
</form>
</div>
</div> …Run Code Online (Sandbox Code Playgroud) 我有一个C#MVC应用程序,我按以下方式分解:View - > Controller - > Service - > Repository
我使用瘦控制器练习,每个视图都有一个从相关服务返回的唯一视图模型.
快速示例:查看:/ NewAppointment/Step1
它的控制器看起来像这样:
public ActionResult Step1()
{
return View(_appointmentService.Step1GetModel() );
}
Run Code Online (Sandbox Code Playgroud)
约会服务层看起来像这样:
public Step1Model Step1GetModel()
{
return new Step1Model();
}
Run Code Online (Sandbox Code Playgroud)
因此,我在整个应用程序中使用了几个不同的服务层,每个服务层实现了一个独特的界面.
当我需要让一个服务层与另一个服务层交互时,我的问题就出现了.在这种情况下,是不是更好的做法是通过一个接口引用服务调用,或者我应该让控制器手柄收集所有数据,然后通过相关结果反馈给服务?
例:
假设我想默认使用客户的信息填充我的视图模型.我看到这样做的两种方式是:
传递一个用户界面参考预约服务,然后让预约服务呼叫客户服务适当GETCUSTOMER方法...
在代码中:
private ICustomerService _customerService;
private IAppointmentService _appointmentService;
public ActionResult Step1()
{
var viewModel = _appointmentService.Step1GetModel( _customerService );
return View(viewModel);
}
Run Code Online (Sandbox Code Playgroud)
要么
让控制器处理获取客户的逻辑,然后将该结果传递给约会服务.
在代码中:
private ICustomerService _customerService;
private IAppointmentService _appointmentService;
public ActionResult Step1()
{
var customer = _customerService.GetCustomer();
var viewModel = _appointmentService.Step1GetModel( customer );
return …Run Code Online (Sandbox Code Playgroud)