小编Har*_*9pl的帖子

如何从Texture2D XNA c#获取颜色和坐标(x,y)?

我想要做的是检查具有黑色边缘的 2 个纹理的完美像素碰撞,例如:此纹理之一是圆形,第二个可以是三角形或矩形。

这是我的代码,它只给我颜色数组,没有我需要的坐标

Color[] playerColorArray = new Color[texturePlayer.Width * texturePlayer.Height];
Color[] secondColorArray = new Color[secondTexture.Width * sencondTexture.Height];
texturePlayer.GetData(playerColorArray);
secondTexture.GetData(secondTextureArray);
Run Code Online (Sandbox Code Playgroud)

我的问题是如何从 Texture2D 获取此 Texture2D 中每个黑色像素的坐标。

感谢提前:)

c# xna xna-4.0

4
推荐指数
1
解决办法
1万
查看次数

MVC和jQuery datepicker

我正在尝试将datepicker应用于具有class属性equals的文本框中datepicker.

所以我这样做: _Layout.cshtml

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <script src="@Url.Content("~/Scripts/jquery-2.0.2.js")" 
    type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.core.css")" 
    rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" 
    rel="stylesheet"  type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" 
    rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-ui-1.10.3.js")" 
    type="text/javascript"></script>

</head>
<body>
    <header>
        <div class="content-wrapper">
            <div class="float-right">
                <nav>
                    <ul id="menu">
                        <li>@Html.ActionLink("Home", "Index", "Home")</li>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </header>
    <div id="body">
        @RenderSection("featured", required: false)
        <section class="content-wrapper main-content clear-fix">
            @RenderBody()
        </section>
    </div> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc jquery-ui jquery-ui-datepicker asp.net-mvc-4

4
推荐指数
1
解决办法
1万
查看次数

如何在c#中使用openFileDialog打开文件.txt?

我必须打开并从.txt文件中读取,这是我正在使用的代码:

Stream myStream;
openFileDialog1.FileName = string.Empty; 
openFileDialog1.InitialDirectory = "F:\\";
if (openFileDialog1.ShowDialog() == DialogResult.OK) 
{
    var compareType = StringComparison.InvariantCultureIgnoreCase;
    var fileName = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
    var extension = Path.GetExtension(openFileDialog1.FileName);
    if (extension.Equals(".txt", compareType))
    {
        try 
        { 
            using (myStream = openFileDialog1.OpenFile()) 
            { 
                string file = Path.GetFileName(openFileDialog1.FileName);
                string path = Path.GetFullPath(file); //when i did it like this it's work fine but all the time give me same path whatever where my "*.txt" file is
                //Insert code to read the stream here. 
                //fileName = openFileDialog1.FileName; …
Run Code Online (Sandbox Code Playgroud)

.net c# winforms

3
推荐指数
3
解决办法
2万
查看次数

使用条件PL/SQL INSERT ALL

我想做的是写一个有三种不同条件的INSERT语句.

这是我到目前为止所做的(但是这段代码得到了ORA-00913太多的值错误):

INSERT ALL
   WHEN SALARY > 20000 THEN
     INTO SPECIAL_SAL13(EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO SAL_HISTORY13(EMPLOYEE_ID,SALARY)
   WHEN SALARY <= 20000 THEN
     INTO MGR_HISTORY13(EMPLOYEE_ID,MANAGER_ID,SALARY)
SELECT EMPLOYEE_ID,HIRE_DATE,MANAGER_ID,SALARY
FROM EMPLOYEES
WHERE EMPLOYEE_ID < 125
Run Code Online (Sandbox Code Playgroud)

oracle plsql

3
推荐指数
1
解决办法
2304
查看次数

从IEnumerable <IEnumerable <object >> linq中选择IEnumerable <object>

我需要做的是选择嵌套元素列表,这是我的查询,returns IEnumerable<IEnumerable<object>>这是我的linq表达式:

from a in (questions.Select(x => x.AnswerList).ToList())
                           select a.Select(x => x.AnswerBasicViewModel);
Run Code Online (Sandbox Code Playgroud)

我应该怎么做,使之return只能IEnumerable<object>代替IEnumerable<IEnumerable<object>>

为了清楚我的样本,我想得到IEnumerable<AnswerBasicViewModel>.

.net c# linq

3
推荐指数
1
解决办法
6260
查看次数

'='sp_executesql附近的语法不正确

我需要delete所有rows的一些table where值是空字符串.(我有多个表有相似的名称).

我试着执行字符串中的那些sql语句:

DECLARE @sql AS NVARCHAR(MAX)
DECLARE @emptyValue AS NVARCHAR(1) =''    
set @sql = N'DELETE FROM SampleTable WHERE Value='+@emptyValue+''
exec sp_executesql @sql
Run Code Online (Sandbox Code Playgroud)

但这让我错了 Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '='.

我试着弄清楚大约一个小时了.任何帮助,将不胜感激.

编辑: 这是删除最后一个配额后得到的内容.@tableNamenvarchar(MAX). 在此输入图像描述

sql t-sql sql-server sp-executesql

3
推荐指数
1
解决办法
2746
查看次数

在c#中序列化嵌套类?

我要做的是序列化嵌套类.我的代码首先:

[Serializable]
public class SampleClass
{
    [Serializable]
    public class Person
    {
        [XmlElement("Name")]
        public string Name { get; set; }
        [XmlElement("Age")]
        public ushort Age { get; set; }
    }
    [Serializable]
    public class Adress 
    {
        [XmlElement("Street")]
        public string Street { get; set; }
        [XmlElement("House number")]
        public int Number { get; set; }
    }
    public SampleClass()
    { 

    }
    public SampleClass(string _name, byte _age, string _street, int _number)
    {
        Person p = new Person();
        p.Name = _name;
        p.Age = _age;
        Adress a = new …
Run Code Online (Sandbox Code Playgroud)

c# xml serialization xml-serialization

2
推荐指数
1
解决办法
2万
查看次数

为什么我在Windows Phone 7 App中看不到按钮?

喜欢标题:)

我在教程中写道:http://msdn.microsoft.com/en-us/wp7trainingcourse_yourfirstwp7applab_topic3可以 做到这一切.我的代码:

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="120"/> <!-- Problem resolved -->
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

     <!-- this i can not see any ideas what is wrong? -->

    <StackPanel Orientation="Vertical" VerticalAlignment="Stretch">
        <Button x:Name = "SolveButton" Content="Solve" Margin="10"
                HorizontalAlignment="Center" Click="SolveButton_Click" />
        <StackPanel x:Name="StatusPanel" Orientation="Horizontal"
                    HorizontalAlignment="Center" Visibility="Collapsed">
            <TextBlock HorizontalAlignment="Center" Text="Your Moves: " TextWrapping="Wrap"
                   Foreground="#FFD0D0D0" FontSize="17.333"/>
            <TextBlock x:Name="TotalMovesTextBlock" HorizontalAlignment="Center" Text="N"
                   TextWrapping="Wrap" Foreground="#FFFFB000" FontSize="17.333"/>
        </StackPanel>
    </StackPanel>
    <!-- Here i can …
Run Code Online (Sandbox Code Playgroud)

silverlight-4.0 windows-phone-7

1
推荐指数
1
解决办法
178
查看次数

在C#中继承,T:new()的含义是什么?

可能重复:
new()是什么意思?

喜欢标题.我想知道代码中的这种语法是什么意思.我在一些样品中找到它,但没有解释,我真的不知道它做了什么.

public class SomeClass<T> where T: new()  // what does it mean?
Run Code Online (Sandbox Code Playgroud)

任何人都能解释一下吗?

c# new-operator

1
推荐指数
1
解决办法
1422
查看次数

从字符串获取枚举类型

我要做的是从字符串中获取Enum Type.

例:

//enum which can be changed I'll know only string name of it at runtime ("Color")
public enum Color
{ 
   Black,
   Green,
   Yellow
}
Run Code Online (Sandbox Code Playgroud)

我已经对谷歌进行了一些研究,但无法找到能满足我需要的东西.有谁在过去解决了这个问题

c# enums types

1
推荐指数
1
解决办法
1万
查看次数

使用MVVM处理WPF TreeView鼠标双击

我创建了一个Dependency Property来处理树视图的鼠标双击事件.部分工作是当你双击树视图项时,在我的视图模型中调用所需的方法,现在我想要做的是将点击的项(XmlElement)传递给此方法.我添加了另一个Dependency属性对于参数,但每次我双击树视图项时,方法中的XmlElement参数是null.

有许多外部库,例如:

1)Expression.Sample.Interactivity

2)附加命令行为

但是我被要求自己实施一些东西,如果有人可以建议我哪里出错,我真的很感激.我已经在下面列出了必要的资料:

处理依赖项属性的类:

  public static class CommandBehavior
  {

  public static readonly DependencyProperty DoubleClickCommand =
  EventBehaviourFactory.CreateCommandExecutionEventBehaviour(
  TreeView.MouseDoubleClickEvent,
  "DoubleClickCommand",
 typeof(CommandBehavior));

public static void SetDoubleClickCommand(DependencyObject o, ICommand value)
{
    o.SetValue(DoubleClickCommand, value);
}

public static ICommand GetDoubleClickCommand(DependencyObject o)
{
    return o.GetValue(DoubleClickCommand) as ICommand;
}

public static readonly DependencyProperty CommandParameterProperty =
DependencyProperty.RegisterAttached("CommandParameter", 
typeof(object),
typeof(CommandBehavior),
new FrameworkPropertyMetadata((object)null,
    new PropertyChangedCallback(OnCommandParameterChanged)));

public static object GetCommandParameter(DependencyObject d)
{
    return (object)d.GetValue(CommandParameterProperty);
}

public static void SetCommandParameter(DependencyObject d, object value)
{
    d.SetValue(CommandParameterProperty, …
Run Code Online (Sandbox Code Playgroud)

c# wpf .net-4.0 mvvm

1
推荐指数
1
解决办法
3567
查看次数

如何检查数字是否是二进制和的结果?

我有这样的情况:

拿到 enum

enum MyType{
    None = 0,
    First = 1,
    Second = 2,
    Third = 4,
    //and so on 
}
Run Code Online (Sandbox Code Playgroud)

现在我不想检查给定的数字是否是二进制和的结果

int givenNumber = 3;
int result = 
//how to get that it's sum of 2 enums in this particular case would be (int)Type.First & (int)Type.Second == 3;
Run Code Online (Sandbox Code Playgroud)

希望我的问题足够清楚,有人可以帮助解决这个问题.

编辑

  1. 枚举值始终由2提供

  2. 我想写一个方法,应该检查给定的数字可以是一个不同的二元和例子:int givenNumber = 1; //1 , 3 ,5 and 7 will be the answer

  3. 真实生活样本:我在我的数据库中有承包商,每个承包商都可以生产者= 1,供应商= 2,服务= 4在db中我只能存储1个值int在这种情况下是最聪明的选择.当我将项目加载到我的服务组合框 - 承包商时,我想加载每一行,例如值为4或5或7(因为7 = 1 + 2 + 4,5 = …

c# enums

0
推荐指数
1
解决办法
175
查看次数