我正在为民用机器应用编写结构建模工具.我有一个代表整个建筑的巨大模型类,其中包括节点,线元素,载荷等的集合,它们也是自定义类.
我已经编写了一个撤消引擎,它在每次修改模型后都会保存一份深层拷贝.现在我开始考虑是否可以进行不同的编码.我可以使用相应的反向修改器保存每个修改器动作的列表,而不是保存深层副本.这样我就可以将反向修改器应用于要撤消的当前模型,或者将修改器应用于重做.
我可以想象你将如何执行更改对象属性等的简单命令.但复杂命令如何?就像将新节点对象插入模型并添加一些保持对新节点的引用的线对象一样.
如何实现这一目标?
我有自定义网格控件的许多应用程序设置(在用户范围内).其中大多数是颜色设置.我有一个表单,用户可以自定义这些颜色,我想添加一个按钮,以恢复默认颜色设置.如何阅读默认设置?
例如:
CellBackgroundColor
在Properties.Settings
.CellBackgroundColor
为Color.White
使用IDE.CellBackgroundColor
要Color.Black
在我的计划.Properties.Settings.Default.Save()
.Restore Default Colors
按钮.现在,Properties.Settings.Default.CellBackgroundColor
回归Color.Black
.我怎么回去Color.White
?
我的工作线程中有以下代码(ImageListView
下面是派生自的Control
):
if (mImageListView != null &&
mImageListView.IsHandleCreated &&
!mImageListView.IsDisposed)
{
if (mImageListView.InvokeRequired)
mImageListView.Invoke(
new RefreshDelegateInternal(mImageListView.RefreshInternal));
else
mImageListView.RefreshInternal();
}
Run Code Online (Sandbox Code Playgroud)
但是,我ObjectDisposedException
有时会得到Invoke
上面的方法.似乎控制可以在我检查IsDisposed
和呼叫之间处理Invoke
.我怎么能避免这种情况?
我需要构建一个相对简单的XML文档,其中包含一些层次结构和JS对象的一些属性.在选择其中一个模块之前,我现在站了起来:
我应该选择哪个模块?
这个问题可能会被认为不是一个好问题,但我不知道如何以不同的方式提出这个问题.
免责声明:我在每个存储库上发布了相同的问题作为问题
这是我想要构建的XML:
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<order>
<order_orderid>123123</order_orderid>
<order_customerid>345345</order_customerid>
<order_senhcode>7604</order_senhcode>
<order_mediacode>qwert</order_mediacode>
<order_totalshippingcost>0</order_totalshippingcost>
<order_paymentmethod>GB</order_paymentmethod>
<order_paymentnumber />
<order_htmltext />
<order_comment />
<shippingmethodid>02</shippingmethodid>
<order_creditcardnumber />
<order_creditcardnameholder />
<order_creditcardexpiredate />
<order_creditcardsafetycode />
<order_gifttext />
<inv_customer>
<inv_customer_addresstypeid />
<inv_customer_gendermale>0</inv_customer_gendermale>
<inv_customer_firstname>qwerty</inv_customer_firstname>
<inv_customer_initials>Q.W.E</inv_customer_initials>
<inv_customer_prename />
<inv_customer_lastname>Qwerty</inv_customer_lastname>
<inv_customer_company>Some company</inv_customer_company>
<inv_customer_street>Postbus</inv_customer_street>
<inv_customer_housenumber>13</inv_customer_housenumber>
<inv_customer_housenumberadditional />
<inv_customer_postalcode>1234 AB</inv_customer_postalcode>
<inv_customer_city>THERE</inv_customer_city>
<inv_customer_isocodecountry>NL</inv_customer_isocodecountry>
<inv_customer_email>a@b.nl</inv_customer_email>
<inv_customer_telephone>0168-123456</inv_customer_telephone>
<inv_customer_mobilenr>06-12345678</inv_customer_mobilenr>
</inv_customer>
<orderlines>
<orderline>
<orderline_orderrecordid>1234</orderline_orderrecordid>
<orderline_orderid>8765432</orderline_orderid>
<orderline_articlenr>164-05-366</orderline_articlenr>
<orderline_quantity>2</orderline_quantity>
<orderline_productdescription>Some gift voucher</orderline_productdescription>
<orderline_price>1233</orderline_price>
</orderline>
<orderline>
<orderline_orderrecordid>5678</orderline_orderrecordid>
<orderline_orderid>8765432</orderline_orderid>
<orderline_articlenr>164-05-367</orderline_articlenr>
<orderline_quantity>3</orderline_quantity>
<orderline_productdescription>Some other gift voucher</orderline_productdescription> …
Run Code Online (Sandbox Code Playgroud) 我有一个基于输入单词列表生成字符串的算法.如何仅将听起来像英语单词的字符串分开?即.在保留LORD的同时丢弃RDLO.
编辑:澄清一下,他们不需要是字典中的实际单词.他们只需要听起来像英语.例如,KEAL将被接受.
如何从列表中选择唯一元素{0, 1, 2, 2, 2, 3, 4, 4, 5}
以便{0, 1, 3, 5}
有效地删除重复元素的所有实例{2, 4}
?
在设计时修改ListView的列标题时,设计器会生成在运行时序列化列标题的代码:
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2
});
}
Run Code Online (Sandbox Code Playgroud)
表单设计者如何知道它应该为每个列调用构造函数,然后调用ListView的Columns属性的AddRange方法?我需要这个像我正在写的UserControl ListView.
假设我有一个列表,我希望它被安排,以便在其连续元素上运行的某个函数的总和最小.
例如,考虑整个列表中连续对的列表{ 1, 2, 3, 4 }
和总和.即..通过检查,当列表被安排为时,达到最小总和.a^b
(a,b)
1^2 + 2^3 + 3^4 = 90
{ 2, 3, 1, 4 } => (2^3 + 3^1 + 1^4 = 12
注意,总和不是循环的(即,我没有考虑last^first
),并且顺序很重要(2^3 != 3^2)
,也a^b
可以是在任意数量的连续元素上运行的任何函数.
这样的算法是否有名称,是否有实现它的既定方法?
编辑:我已经重新编写了问题,因为我错误地将此标记为排序问题.正如所指出的,这更像是一个优化问题.
我的自定义网格控件中有一个线条颜色属性.我希望它默认为Drawing.SystemColors.InactiveBorder
.我试过了:
[DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")]
public Color LineColor { get; set; }
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.如何使用默认值属性执行此操作?
我在每个渲染上动态生成顶点数组,然后我想删除数组.是否glDrawArrays
立即将顶点数组复制到服务器?因此在调用后删除顶点数组是否安全glDrawArrays
?
float * vp = GetVertices(); // Regenerated on each render
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), vp);
glDrawArrays(GL_TRIANGLES, 0, nVertices);
delete[] vp; // Can I do this?
Run Code Online (Sandbox Code Playgroud)
否则,如何确定何时删除顶点数组是否安全?
我在我的应用程序中使用自定义Matrix类,我经常添加多个矩阵:
Matrix result = a + b + c + d; // a, b, c and d are also Matrices
Run Code Online (Sandbox Code Playgroud)
但是,这为每个加法操作创建了一个中间矩阵.由于这是简单的添加,因此可以通过一次添加所有4个矩阵的元素来避免中间对象并创建结果.我怎么能做到这一点?
注:我知道我可以这样定义多种功能Add3Matrices(a, b, c)
,Add4Matrices(a, b, c, d)
等,但我想保持的优美result = a + b + c + d
.
接口可以包含枚举吗?
我使用的是asp.net 2.0.突然,当我在下面的界面中添加枚举时,我的代码开始出现问题.在其中,LookUpType是一个枚举.
Public Interface ILookup
Property ID() As Int32
Property Text() As String
Property Description() As String
Property Status() As Status
Property OrderID() As Int32
ReadOnly Property LookUpType() As LookUpType
End Interface
Run Code Online (Sandbox Code Playgroud)