我之前从未使用过InkCanvas
控件.我需要的是加载一个文件InkCanvas
,绘制一些涂鸦并得到结果图像.我想用获得的图像做一些额外的操作.
如我错了请纠正我.我找到了一个链接:http://www.centrolutions.com/Blog/post/2008/12/09/Convert-WPF-InkCanvas-to-Bitmap.aspx 根据帖子将加载图片考虑除了用户涂鸦.或者它只将涂鸦转换为位图?
如何使用OpenFileDialog加载图像?我不想使用ISF.
谢谢!
我收到Uncaught ReferenceError
了文字:我没有定义例外
Uncaught ReferenceError: Id is not defined
(anonymous function)
y.templateunderscore-min.js:5
Backbone.View.extend.renderProductView.js:13
Backbone.View.extend.renderProductListView.js:15
Backbone.View.extend.initializeProductListView.js:4
g.Viewbackbone-min.js:34
dbackbone-min.js:38
appRouter.on.productsList.fetch.successAppRouter.js:18
f.extend.fetch.a.successbackbone-min.js:23
f.Callbacks.ojquery-1.7.2.min.js:2
f.Callbacks.p.fireWithjquery-1.7.2.min.js:2
wjquery-1.7.2.min.js:4
f.support.ajax.f.ajaxTransport.send.d
Run Code Online (Sandbox Code Playgroud)
存储在外部文件中,模板如下所示:
<a class="thumbnail" href="#/products/<%= Id %>">
<img alt="" src="/Content/img/<%= Thumbnail %>" />
<h5><%= Title %></h5>
<p><%= Price %></p>
<p><%= Details %></p>
</a>
Run Code Online (Sandbox Code Playgroud)
其对应的视图将render
方法定义为:
define(['jquery', 'underscore', 'backbone', 'text!templates/product.html'], function ($, _, Backbone, productTemplate) {
var ProductView =
...
render: function() {
var data = {};
var compiledTemplate = _.template(productTemplate, data);
this.$el.append(compiledTemplate);
}
... …
Run Code Online (Sandbox Code Playgroud) 我一直在学习CQRS/ES.看一下小例子项目,我经常看到事件改变了实体状态.例如,如果我们查看Order
聚合根:
public class Order : AggregateRoot {
private void Apply(OrderLineAddedEvent @event) {
var existingLine = this.OrderLines.FirstOrDefault(
i => i.ProductId == @event.ProductId);
if(existingLine != null) {
existingLine.AddToQuantity(@event.Quantity);
return;
}
this.OrderLines.Add(new OrderLine(@event.ProductId, @event.ProductTitle, @event.PricePerUnit, @event.Quantity));
}
public ICollection<OrderLine> OrderLines { get; private set; }
public void AddOrderLine(/*parameters*/) {
this.Apply(new OrderLineAddedEvent(/*parameters*/));
}
public Order() {
this.OrderLines = new List<OrderLine>();
}
public Order(IEnumerable<IEvent> history) {
foreach(IEvent @event in history) {
this.ApplyChange(@event, false);
}
}
} …
Run Code Online (Sandbox Code Playgroud) 所以这是我的问题:
我有界面:
public interface ICell<Feature>
where Feature: struct, IComparable<ICell<Feature>>
{
List<ICell<Feature>> Window { get; set; }
Feature GenusFeature { get; set; }
Double VitalityRatio { get; set; }
String PopulationMarker { get; set; }
Boolean Captured { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
并希望以ISubstratum
这种方式实现接口:
public interface ISubstratum<K,T> : IDisposable
where K : IDisposable
where T : struct
{
ICell<T> this[Int32 i, Int32 j] { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
但编译器说:
The type 'T' cannot be used as type parameter 'Feature' in …
我无法理解一件事.假设我已经拥有这些编码实体:
[Table(Name = "Rates")]
public class Rate
{
private EntityRef<Product> _Product;
[Column(IsPrimaryKey = true)]
public String RateID
{ get; set; }
[Column]
public String ProductID
{ get; set; }
[Column]
public Double VolumeInTons
{ get; set; }
[Column]
public Decimal Volume
{ get; set; }
[Column]
public Decimal Cost
{ get; set; }
[Column]
public UInt32 Year
{ get; set; }
[Association(Storage = "_Product", OtherKey = "ProductID")]
public Product Product
{
get { return this._Product.Entity; }
set { this._Product.Entity = …
Run Code Online (Sandbox Code Playgroud) 使用默认策略是否正常,如下面的代码所示:
public abstract class ClContext
{
protected sealed class InitialAlgorithm : IClAlgorithm
{
public void Initialize()
{
return;
}
public void Execute()
{
return;
}
public Byte[] Result
{
get { return new Byte[1]{0}; }
}
}
protected IClAlgorithm algorithm;
protected ClContext(IClAlgorithm algorithm = null)
{
this.algorithm = algorithm ?? new ClContext.InitialAlgorithm();
}
public void Execute()
{
this.algorithm.Execute();
}
}
Run Code Online (Sandbox Code Playgroud)
提供自动实现的属性也是正常的,例如:
public IClAlgorithm Algorithm
{
get;
set;
}
Run Code Online (Sandbox Code Playgroud)
从设计的角度来看,我只是好奇,这是可以接受的.
谢谢!
拥有一个通用的存储库
public class Repository<T>
where T: Entity<T>
{
/*anything else*/
}
Run Code Online (Sandbox Code Playgroud)
应该是每个聚合根的具体存储库
class ProductRepository : Repository<Product>
{
}
class CategoryRepository : Repository<Category>
{
}
Run Code Online (Sandbox Code Playgroud)
被创造?
另外,我如何使用DI(Ninject
)与存储库的通用实现.
样品是apreciated!
谢谢!
关于此条目使用RequireJS加载Backbone和Underscore,我很清楚如何配置Backbone
特定脚本和JQuery
.
但我该怎么做:
Twitter bootstrap.js
?json2.js
?谢谢!
我已经阅读了官方文档,但我不太确定我是否理解如何应用他们所说的内容。我也看过这个 QA,我也使用了工厂模式。只是看不到全貌。
连接池以及其他 redis/huey 设置可能会根据给定的环境(开发、生产)而有所不同。我们如何连接huey以便我们可以像Flask应用程序一样配置它?
只要我了解从视图触发任务,我们就需要导入任务模块并调用特定任务(调用传递敏感参数的函数)。我们应该在哪里实例化,保留huey实例?
任务应该了解应用程序的依赖关系吗?对于这个问题,我们是否应该考虑另一个精简的Flask应用程序?
你能帮忙一点吗?
可以在应用程序工厂内定义共享请求挂钩吗?
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
db.init_app(app)
csrf.init_app(app)
login_manager.init_app(app)
babel.init_app(app)
@app.before_request
def before_request_callback():
if request.view_args and 'locale' in request.view_args:
if request.view_args['locale'] not in app.config['SUPPORTED_LOCALES']:
return abort(404)
g.locale = request.view_args['locale']
request.view_args.pop('locale')
from . app_area__main import main as main_blueprint
app.register_blueprint(main_blueprint)
from . app_area__admin import admin as admin_blueprint
app.register_blueprint(admin_blueprint, url_prefix='/admin')
Run Code Online (Sandbox Code Playgroud) c# ×6
backbone.js ×2
flask ×2
javascript ×2
jquery ×2
python ×2
requirejs ×2
architecture ×1
bitmap ×1
cqrs ×1
database ×1
file ×1
generics ×1
inkcanvas ×1
interface ×1
linq-to-sql ×1
ninject ×1
python-huey ×1
repository ×1
servicebus ×1
windows ×1
wpf ×1