问题列表 - 第33195页

如何使用x/y坐标而不是索引访问Grid中的子项?

我有一个Grid对象,想要从中获取一个特定的复选框.

我可以使用这种语法:

CheckBox cbChange = grid.Children[4] as CheckBox;
Run Code Online (Sandbox Code Playgroud)

但是如何通过x/y坐标来访问这个孩子,例如:

CheckBox cbChange = grid.GetXYChild(2,3) as CheckBox; //PSEUDO-CODE
Run Code Online (Sandbox Code Playgroud)

替代文字

using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;

namespace TestGrid92292
{
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            List<string> rowNames = new List<string>
            {
                "Marketing",
                "Sales",
                "Development"
            };

            Grid grid = new Grid();
            grid.Margin = new Thickness(5);

            ColumnDefinition col1 = new ColumnDefinition();
            col1.Width = new GridLength(100, GridUnitType.Pixel);
            grid.ColumnDefinitions.Add(col1);

            ColumnDefinition col2 = new ColumnDefinition();
            col2.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col2);

            ColumnDefinition …
Run Code Online (Sandbox Code Playgroud)

c# wpf grid

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

_Bool和bool:如何解决使用_Bool的C库的问题?

我在C中编写了一组数据结构和函数,其中一些使用_Bool数据类型.当我开始时,该项目将是纯粹的C.现在我正在研究使用基于C++的GUI工具包并将后端代码放入库中.

但是,在编译C++ GUI时,编译器会发出以下错误:

ISO C++ forbids declaration of '_Bool' with no type

我最初以为我可以搜索和替换_Bool,以bool创造:

/* mybool.h */
#ifndef MYBOOL_H
#define MYBOOL_H

typedef _Bool bool;

#endif /* MYBOOL_H */
Run Code Online (Sandbox Code Playgroud)

然后在任何使用_Bool的标头中

#ifdef __cplusplus
extern "C" {
#else
#include "mybool.h"
#endif

/* rest of header... */
Run Code Online (Sandbox Code Playgroud)

直到我意识到这将使用一个布尔(C _Bool)数据类型编译库,并使用另一个(C++ bool)链接库.实际上,这可能无关紧要,但从理论上讲,它可能确实存在(可能会有一些模糊的系统,这样做会导致宇宙向内翻).

我想我可以使用一个int并使用0表示false,将1表示为true,并使用类似的方法对其进行类型设置typedef int mybool,但它似乎没有吸引力.

有没有更好/惯用/标准的方法来做到这一点?

c c++ boolean

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

如何让Android应用程序无限期运行?

我正在编写一个Android应用程序,必须始终在后台运行,直到用户从应用程序菜单中退出.但是现在我注意到在一段时间后我的应用程序在没有用户干预的情况下自行停止.

知道如何确保我的应用程序将始终在后台运行吗?

service android

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

使用.NET通过HTTP发送base64编码的字符串

好吧,问题是我试图通过HTTP编码为base64发送一个字节数组.虽然我在另一端接收的字符串与原始字符串的大小相同,但字符串本身并不相同,因此我无法将字符串解码回原始字节数组.

另外,在发送字符串之前,我已经完成了对客户端base64的转换,一切正常.它发送后发生问题.

有什么我想念的吗?任何特定的格式类型?我尝试过使用EscapeData(),但字符串太大了.

先感谢您

编辑:代码

System.Net.WebRequest rq = System.Net.WebRequest.Create("http://localhost:53399/TestSite/Default.aspx");
rq.Method = "POST";
rq.ContentType = "application/x-www-form-urlencoded";
string request = string.Empty;
string image =             Convert.ToBase64String(System.IO.File.ReadAllBytes("c:\\temp.png"));            
request += "image=" + image;
int length = image.Length;
byte[] array = new UTF8Encoding().GetBytes(request);
rq.ContentLength = request.Length;
System.IO.Stream str = rq.GetRequestStream();                        
str.Write(array, 0, array.Length);            
System.Net.WebResponse rs = rq.GetResponse();
System.IO.StreamReader reader = new System.IO.StreamReader(rs.GetResponseStream());
string response = reader.ReadToEnd();
reader.Close();
str.Close();            
System.IO.File.WriteAllText("c:\\temp\\response.txt", response);
Run Code Online (Sandbox Code Playgroud)

.net base64 http transmission

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

Drupal:自动将新节点添加到节点队列

在创建节点时,我可以以某种方式自动将节点添加到特定节点队列吗?

(我正在使用nodequeue模块:drupal.org/project/nodequeue)

谢谢

drupal drupal-6

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

为什么这个XPath查询不返回任何节点?

我正在查询Sharepoint服务器端并将结果作为Xml返回.我希望在将Xml通过WebMethod发送到jQuery之前将其缩小为更轻量级的东西.

但是我的XPath查询无效.我认为以下代码将返回所有Document节点,但它不返回任何内容.我以前曾经使用过XPath,我想//Document这就是诀窍.

C#XPath查询

XmlDocument xmlResults = new XmlDocument();
xmlResults.LoadXml(xml); // XML is a string containing the XML source shown below
XmlNodeList results = xmlResults.SelectNodes("//Document");
Run Code Online (Sandbox Code Playgroud)

正在查询XML

<ResponsePacket xmlns="urn:Microsoft.Search.Response">
      <Response domain="QDomain">
            <Range>
                  <StartAt>1</StartAt>
                  <Count>2</Count>
                  <TotalAvailable>2</TotalAvailable>
                  <Results>
                        <Document relevance="126" xmlns="urn:Microsoft.Search.Response.Document">
                              <Title>Example 1.doc</Title>
                              <Action>
                                    <LinkUrl size="32256" fileExt="doc">http://hqiis99/Mercury/Mercury documents/Example 1.doc</LinkUrl>
                              </Action>
                              <Description />
                              <Date>2010-08-19T14:44:56+01:00</Date>
                        </Document>
                        <Document relevance="31" xmlns="urn:Microsoft.Search.Response.Document">
                              <Title>Mercury documents</Title>
                              <Action>
                                    <LinkUrl size="0" fileExt="aspx">http://hqiis99/mercury/Mercury documents/Forms/AllItems.aspx</LinkUrl>
                              </Action>
                              <Description />
                              <Date>2010-08-19T14:49:39+01:00</Date>
                        </Document>
                  </Results>
            </Range>
            <Status>SUCCESS</Status>
      </Response>
</ResponsePacket>
Run Code Online (Sandbox Code Playgroud)

c# xml xpath

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

从1回到1,从2回到2,...,从11回到11,

是否有Objective-c函数NSString *从a 返回a NSUInteger,即:

  • 1 - > 1
  • 2 - > 2
  • ...
  • 10 - > 10
  • 21 - > 21
  • ...
  • 31 - > 31

范围从1到31.谢谢!

iphone cocoa-touch

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

Oracle Char类型和Hibernate

我有一个oracle表,其中包含几列的char(n)类型.我使用hibernate工具创建实体objets,并使用此工具在String中映射char类型.

但是当我部署我的应用程序时,我收到一个错误,因为Hibernate等待varchar2类型而不是char类型:

Wrong column type in ARBOR.CMF for column CHG_WHO. Found: char, expected: varchar2(30 char)
Run Code Online (Sandbox Code Playgroud)

我必须使用什么样的java类型来映射实体中的char(n)类型?

谢谢.

java hibernate oracle10g

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

面向对象的设计 - 最简单的情况,但无论如何我都很困惑!

当我在一个类中包含一些过程代码时(在我的情况下是c ++,但这可能不是我感兴趣的)我常常对最好的方法感到困惑.使用过程代码我的意思是你可以很容易地放入一个过程中,你使用周围的对象主要是为了清晰和易用(错误处理,日志记录,事务处理......).

例如,我想编写一些代码,从数据库中读取内容,对其进行一些计算并对数据库进行一些更改.为了能够这样做,它需要来自呼叫者的数据.

这些数据如何以最佳方式进入对象.我们假设它需要7个值和一个整数列表.

我的想法是:

  • 构造函数的参数列表
  • 设置功能
  • 中央功能的参数列表

第一种解决方案的优点是调用者必须准确地提供类所需的工作,并确保在创建类之后数据可用.然后可以将对象存储在某处,并且可以在没有任何与对象的进一步交互的情况下由调用者触发中心函数.

它在第二个例子中几乎相同,但现在中央功能必须检查调用者是否已传送所有必要的数据.问题是,如果您对每个数据的和平有一个单一的功能,或者如果您只有一个.

Last解决方案的唯一优势是,在执行之前不会存储数据.但是它看起来像一个正常的函数调用,并且类接近的好处消失了.

你怎么做那样的?我的考虑是否正确?我错过了一些优点/缺点?

这个东西很简单,但我找不到任何资源.

编辑:我不是在谈论数据库连接.我的意思是完成程序所需的所有数据.例如,簿记交易的所有信息.

让我们做一个民意调查,你更喜欢什么:

class WriteAdress {
  WriteAdress(string name, string street, string city);
  void Execute();
}
Run Code Online (Sandbox Code Playgroud)

要么

class WriteAdress {
  void Execute(string name, string street, string city);
}
Run Code Online (Sandbox Code Playgroud)

要么

class WriteAdress {
  void SetName(string Name);
  void SetStreet(string Street);
  void SetCity(string City);
  void Execute();
}
Run Code Online (Sandbox Code Playgroud)

要么

class WriteAdress {
  void SetData(string name, string street, string city);
  void Execute();
}
Run Code Online (Sandbox Code Playgroud)

c++ oop

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

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