首先请说明一下,是的,这里有大量"与分辨率无关的C#WPF布局"相关问题.我的问题与此没有直接关系,我已经阅读了大部分内容,并阅读了几个教程.
目标:
由于我是WPF的新手,我的目标是有一个明确的方法来设计一个独立的屏幕分辨率的复杂,逼真的GUI,并在用户调整窗口大小时适当缩放.
混乱的原因:
我对许多教程和stackoverflow帖子建议的大量选项感到困惑,使用Viewbox,流动布局,相对布局,使用不同类型的容器,以及WPF应该是设计独立于分辨率的事实.
题:
我没有任何打算开始辩论的意图,我知道不是为了这个.我只是想知道我计划用来设计我的真实GUI的这个程序是否正确.
1>在Illustrator中设计一个样机(或直接在Blend中设计,我不知道应该使用哪个)
2>使用(不知道哪个)布局设计1024 x 768分辨率时,通过WPF中的拖放设计复制它
3>当我的用户启动我的应用程序时,获取屏幕大小并通过做一些数学来调整每个控件的大小(Yukh!这真的是我必须这样做吗?WPF的独立性是什么意思,那不是真的拖累和滴设计是吗?)
我的大多数应用程序都是数据库驱动的数据输入和操作表单 我使用的是业内常见的正确策略,还是我错过了什么?
非常感谢
我只是在表单上输入名称和年龄,并将其发布到我的家庭控制器中的ListAll操作.但是控制器不记得输入的所有名称和年龄,即它不会持久存在.
Ps对长代码感到抱歉,但它非常基本,不应该复杂化
这是我的Index.Html中的代码(我可以输入一个人的姓名和年龄)
@using(Html.BeginForm())
{
@Html.ValidationSummary();
@Html.LabelFor(p=>p.Name)
@Html.EditorFor(p=>p.Name)
@Html.LabelFor(p=>p.Age)
@Html.EditorFor(p=>p.Age)
<input type="submit" value="Add" />
}
@Html.ActionLink("View All Person", "ListAll");
Run Code Online (Sandbox Code Playgroud)
这是我的DBContext类,
public class TheDB: DbContext
{
public List<Person> persons = new List<Person>();
}
Run Code Online (Sandbox Code Playgroud)
我的班级
public class Person
{
[Required]
public string Name { get; set; }
[Required]
public string Age{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我的控制器
public class HomeController : Controller
{
TheDB myDB ;
public HomeController()
{
myDB = new TheDB();
}
public ActionResult Index()
{
return View();
}
[HttpPost] …Run Code Online (Sandbox Code Playgroud) 这是来自Microsoft套接字教程的示例http://msdn.microsoft.com/en-us/library/6y0e13d3.aspx
我有点困惑.第一个while(true)无限循环后跟第二个4行向下,但我们只使用一个break语句.在第二个while循环中使用break应该继续第一个while循环...不是吗? http://msdn.microsoft.com/en-us/library/6y0e13d3.aspx
while (true) {
Console.WriteLine("Waiting for a connection...");
// Program is suspended while waiting for an incoming connection.
Socket handler = listener.Accept();
data = null;
// An incoming connection needs to be processed.
while (true) {
bytes = new byte[1024];
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes,0,bytesRec);
if (data.IndexOf("<EOF>") > -1) {
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 这应该是一件相对简单的事情.基本上我有SQL Server 2008,我已经附加了NorthWind数据库.这是我的查询工作正常.
SELECT [Customers].[CompanyName], [Orders].[OrderID]
FROM [Northwind].[dbo].[Customers]
LEFT JOIN [Northwind].[dbo].[Orders]
ON Orders.CustomerID=Customers.CustomerID
ORDER BY Customers.CompanyName;
Run Code Online (Sandbox Code Playgroud)
在第二个SQL行中,我该怎么做才能做到
FROM [Customers]
Run Code Online (Sandbox Code Playgroud)
代替
FROM [Northwind].[dbo].[Customers]
Run Code Online (Sandbox Code Playgroud)
可能吗?或者这不是正确的方法吗?顺便提一下,我还有3个附加到SQL Server的数据库,NorthWind而不是唯一的数据库.我用谷歌搜索了,但我不太确定谷歌的条款.我只是想缩短我的疑问.谢谢
我有一个简单的测验模型,我试图让用户从一个强类型视图中分组的两个单选按钮中选择正确答案/替代答案.但我使用的lambda表达式不起作用.我有两个空白的单选按钮.我在这里看过几个问题,在线但我的模型是IList <>,我找不到合适的例子.我找到的所有示例都使用非IList <>.
这是我的模特
模型:
public partial class Question
{
public int QuestionID { get; set; }
public string QuestionBody { get; set; }
public string CorrectAnswer { get; set; }
public string AlternativeAnswer { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的控制器
public ActionResult Index()
{
QuizSimpleEntities quizEntities = new QuizSimpleEntities();
var questions = from p in quizEntities.Questions
select p;
return View(questions.ToList());
}
Run Code Online (Sandbox Code Playgroud)
我的型号:
@model IList<Quiz.Models.Question>
<h2>Welcome to the Quiz</h2>
@Html.BeginForm(method:FormMethod.Post,controllerName:"Home",actionName:"index")
{
@foreach (var questions in Model)
{
<p>@questions.QuestionBody</p>
@* How to …Run Code Online (Sandbox Code Playgroud) 我在SQL server中有这样的表
UsageTime Website
10:45:08 yahoo.co.uk
10:24:06 msn.co.uk
09:45:08 lycos.co.uk
Run Code Online (Sandbox Code Playgroud)
我需要得到这样的东西
BusiestHour NoOfWebsitesVisited
10:00 2
Run Code Online (Sandbox Code Playgroud)
我试过这个
SELECT TOP 3 UsageTime as BusiestHour, COUNT(Website) FROM NoOfWebsitesVisited
GROUP BY BusiestHour
Run Code Online (Sandbox Code Playgroud)
但这不太对.它不会检查整个小时,只是一个特定的值.
任何帮助将不胜感激:)谢谢
我有这个方法的asmx webserice
[WebMethod]
double GetBookPrice(int bookID)
{
//instantiates a DiscountService,DeliveryService and a couple of other services
//uses various methods of these services to calculate the price
//e.g. DiscountService.CalculateDiscount(book)
}
Run Code Online (Sandbox Code Playgroud)
有4种服务是此方法的依赖项.
现在如何测试这种方法?我需要注入这些依赖项?或者我应该这样做?客户端只是发送一个int来检查价格.
谢谢
"Cracking the Coding Interview"一书,这个Stack Overflow问题讨论了一个确定字符串是否包含所有唯一字符的函数.本书使用位移的答案在问题链接中(请参见页面顶部的答案),我在此不再赘述.
Java答案有O(N)的复杂性,我无法理解O(N)实际意味着什么.我实际上想知道我刚刚写的这个实现的时间复杂度是多少.是O(N)?如何判断复杂性?
static void Main(string[] args)
{
string stringToCheck ;
bool hasAllUniqueChars = false;
stringToCheck = "Test";
hasAllUniqueChars = CheckForUniqueChars(stringToCheck);
Console.WriteLine("String is Unique {0}", hasAllUniqueChars);
Console.Read();
}
private static bool CheckForUniqueChars(string stringToCheck)
{
for (int i = 0; i < stringToCheck.Length - 1; i++)
{
for (int j = i; j < stringToCheck.Length - 1; j++)
{
if (Char.ToUpper(stringToCheck.ElementAt(i)) ==
Char.ToUpper(stringToCheck.ElementAt(j+1)))
{
return false;
}
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
对于SuperMan,SpiderMan和Sponge,它为Test,test,Hello和true返回false,并且工作正常.
谢谢