I'm currently creating a drawing software using WPF Shapes on canvas. I've created a system allowing the user to move and rotate shapes on a Canvas using a transparent canvas upon the shape (which rotate with the shape) : The green point is used to rotate the shape, the blue zone upon the rectangle is used to move the shape. I'd like to use my 4 red points to re-size the shape.
我目前正在使用WPF Shapes在画布上创建绘图软件。 我创建了一个系统,允许用户在形状上使用透明画布移动和旋转Canvas上的形状(与形状一起旋转): 绿色点用于旋转形状,矩形上的蓝色区域用于移动形状。 我想用我的4个红点重新调整形状。 但形状是可旋转的,所以角度坐标与调整形状不完全相关。 在我看来,只有当旋转等于0时才有意义,因为在180度旋转之后,左上角可以是右下角。 现在,我使用RotateTransform实现了旋
This will be so easy for some of you programming geniuses out there but I am a student who recently began learning about C# (and programming in general) and I find myself.... stuck. This is an assessment I am working on so I am not looking for a copy/paste answer, it would be preferable if I could find out where I am going wrong/where to start so I can fix it myself. The aim of the assessment
这对于你们中的一些编程天才来说非常容易,但我是一个最近开始学习C#(以及一般编程)的学生,并且我发现自己......卡住了。 这是我正在进行的一项评估,因此我不在寻找复制/粘贴的答案,如果我能够找出我要出错的地方/从哪里开始,那么我可以自己修复它。 评估的目的是: 使用随机数发生器产生4个数字 - 对于玩家1和玩家2来说是2。 将玩家2号码添加在一起,将经销商2号码添加在一起(在屏幕上显示结果) 这是我陷入
So I am trying to learn the SOLID principles and Dependency Injection. I have read some blog posts on the subject and I am starting to understand a bit. However, there is one case that I can't find an answer for and will try to explain it here. I have developed a library to do text matching, it contains a class Matcher that has a function called Match which returns the result in a MatchRe
所以我正在尝试学习SOLID原理和依赖注入。 我已经阅读了关于这个主题的一些博客文章,并且我开始了解了一些。 但是,有一种情况我找不到答案,并会在这里尝试解释。 我开发了一个库来进行文本匹配,它包含一个Matcher类,它有一个名为Match的函数,它将结果返回给MatchResult对象。 此对象包含百分比,已过时间,是否成功等信息。 现在从我在依赖注入中理解的是,高级类不应该“知道”低级类或模块。 所以,我建立了我的图
I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this: public MyClass(Container con) for every class? What are the downsides? If I do this, it feels like I'm using a glorified stat
我发现我的构造函数开始看起来像这样: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) 不断增加参数列表。 由于“容器”是我的依赖注入容器,为什么我不能这样做: public MyClass(Container con) 为每个班级? 有什么缺点? 如果我这样做,感觉就像我正在使用一个荣耀的静态。 请分享你对IoC和依赖注入疯狂的想法。 你是对的,如果你使用容器作为服务定位器,它或多或少是一个美化的静态工厂
I will have the following components in my application DataAccess DataAccess.Test Business Business.Test Application I was hoping to use Castle Windsor as IoC to glue the layers together but I am bit uncertain about the design of the gluing. My question is who should be responsible for registering the objects into Windsor? I have a couple of ideas; Each layer can register its own
我的应用程序中将包含以下组件 数据访问 DataAccess.Test 商业 Business.Test 应用 我希望使用Castle Windsor作为IoC将各层粘合在一起,但我对粘合的设计有点不确定。 我的问题是谁应该负责将物体注册到温莎? 我有几个想法; 每个图层都可以注册自己的对象。 为了测试BL,测试台可以为DAL注册模拟类。 每个层都可以注册其依赖关系的对象,例如业务层注册数据访问层的组件。 为了测试BL,测试台将不得不卸载
I have two versions of a factory class designed based on the article http://www.oodesign.com/factory-pattern.html public abstract class Employee { public string Name { get; set; } protected string Role { get; set; } public abstract string GetRole(); } public class Manager : Employee { public Manager() { Role = "MGR"; } public override string GetRole() {
我有两个基于文章设计的工厂类版本 http://www.oodesign.com/factory-pattern.html public abstract class Employee { public string Name { get; set; } protected string Role { get; set; } public abstract string GetRole(); } public class Manager : Employee { public Manager() { Role = "MGR"; } public override string GetRole() { return this.Role; } }
*I am not an expert on spring or IoC - I would like to have my client app "select" different implementations of an interface based on some conditions. I believe Spring (or other IoC containers) allow doing this, however all examples show that the concrete class is configured in some configuration file, which is not what i am after. I would like to (somehow) allow the container to de
*我不是Spring或IoC的专家 - 我希望我的客户端应用程序根据某些条件“选择”不同的接口实现。 我相信Spring(或其他IoC容器)允许这样做,但是所有示例都显示具体类是在某个配置文件中配置的,这不是我所追求的。 我想(以某种方式)允许容器决定从哪个实现中进行选择(基于某些条件和给定的一组类以供选择)。 这可能吗? (我很确定它是)。 你可以使用一个工厂类(它可以是静态的或实例工厂)。
Ok, So I have the following situation. I originally had some code like this: public class MainBoard { private BoardType1 bt1; private BoardType2 bt2; private BoardType3 bt3; ... private readonly Size boardSize; public MainBoard(Size boardSize) { this.boardSize = boardSize; bt1 = new BoardType1(boardSize); bt2 = new BoardType2(boardSize);
好的,所以我有以下情况。 我原来有这样的代码: public class MainBoard { private BoardType1 bt1; private BoardType2 bt2; private BoardType3 bt3; ... private readonly Size boardSize; public MainBoard(Size boardSize) { this.boardSize = boardSize; bt1 = new BoardType1(boardSize); bt2 = new BoardType2(boardSize); bt3 = new BoardType3(boardSize
I am currently weighing up the advantages and disadvantages between DI and SL. However, I have found myself in the following catch 22 which implies that I should just use SL for everything, and only inject an IoC container into each class. DI Catch 22: Some dependencies, like Log4Net, simply do not suit DI. I call these meta-dependencies and feel they should be opaque to calling code. My j
我目前正在权衡DI和SL之间的优缺点。 但是,我发现自己在下面的catch 22中,这意味着我应该对所有内容都使用SL,并且只将IoC容器注入到每个类中。 DI Catch 22: 一些依赖性,如Log4Net,根本不适合DI。 我将这些元依赖称为“调用代码”,并认为它们应该是不透明的。 我的理由是,如果一个简单的类“d”不记录最初实施,然后长到需要的日志记录,那么相关的类“A”,“B”和“C”,现在必须以某种方式获得这种依赖和它向下传递'
This question already has an answer here: Dependency Injection vs Factory Pattern 26 answers I think these 2 are slightly different topics, however both about software design. DIP is more about how you should arrange your dependencies in a class, and Factory is a pattern which you can use to instantiate those dependencies. There is a good article from Bob Martin on principles of object ori
这个问题在这里已经有了答案: 依赖注入VS工厂模式26个答案 我认为这两个主题略有不同,但都涉及软件设计。 DIP更多的是,你应该如何安排在一个类你的依赖,和工厂是你可以用它来实例化这些依赖的模式。 Bob Martin有一篇关于面向对象设计原理的文章(包括SOLID) - http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod 另外,请考虑阅读Martin Fowler关于控制和依赖注入反转的文章。