Hi everyone!
I have uploaded VS code to
http://s000.tinyupload.com/index.php?file_id=92033472381453312391[
^].
It is simple program to demonstrate how I imagine it would be good practice to move around graphics in WPF.
Here are the questions :
1. As HalfCircleObject grows in functionality, I will eventually want to add new class that extedns HlafCircleObjectMove class which already extends HalfCircleObjectSelect which in turn extends HalfCircleObjectOrigin and so on.
So, to keep using the newest HalfCircleObject I always have to create newest object in button click method. Is there anyway arround this?
For example, my idea would be to create HalfCircleObjectTop class and then do this :
HalfCircleObject->HalfCircleObjectOrigin->HalfCircleObjectSelected->
HalfCircleObjectMove->***->HlafCircleObjectTop
..to put any new class that adds functionality to HalfCircleobject in position *** and never above HalfCircleObjectTop.
That way, in button method and similar ones always use only HalfCircleObjectTop.
(I'm guessing there should be more prudent approach)
2. Please see in static class MoveObject that I am forced to cast ISelect type of Object to IMove type. Is there any to avoid need for casting? (I know that is it mandatory if program stays structured as it is now).
For example :
I imagined that it would be good practice to separate HalfCircleObject by its functionality. So I have written program keeping in mind just that
HlafCircleObjectOrigin should implement only IOrigin and IHit interface,
HlafCircleObjectSelect should implement only ISelect interface,
HlafCircleObjectMove should implement only IMove interface,
and so on.
So I hope I gave you feeling what my problem is and why I can't work around it. It may be that my approach is completely off the tack and that it needs to build from scratch. Any advice is much appreciated.
Thank you!
In short :
class A : UserControl
{
public A() { InitializeComponent(); }
}
class B : A
{
Point Origin;
}
class C : B
{
bool IsSelected {get; set;}
}
class D : C
{
MoveAround(Point mousePosition)
{
Origin = mousePosition;
}
}
--------------------
class E : D
{
TextBox Tb;
MoveAroundText(Point mousePosition) { ... }
}
--------------------
static class MoveObject(Point mousePosition)
{
foreach(D Obj in SomeKindOfList)
if(Obj.IsSelected) Obj.MoveAround(mousePosition);
}
How do I use MoveAroundText with already developed MoveObject method without changing it?