I am working on an app with a designer, in which can resize some shape items. To resize different shapes in only one 'ResizeThumb' type, I have this two programs:
switch(Mode)
{
case Mode.CircleCenter:
if (item is Circle circle1)
{
// ...
}
break;
case Mode.CircleRadius:
if (item is Circle circle2)
{
// ...
}
break;
case Mode.RectTopLeft:
if (item is MyRect rect1)
{
// ...
}
break;
// many cases...
default: break;
}
or
if (item is Circle circle)
{
switch (Mode) // just 2 cases
{
case Mode.CircleCenter:
// ...
break;
case Mode.CircleRadius:
// ...
break;
default: break;
}
}
else if (item is MyRect rect)
{
switch (Mode)
{
case Mode.RectTopLeft:
// ...
break;
// 8 cases of every border and corner
default: break;
}
}
else if (item is MyEllipse ellipse)
{
switch (Mode) { /* 8 cases of every border and corner */ }
}
else if (item is Line ellipse)
{
switch (Mode) { /* 2 cases of every endpoint */ }
}
else
{
// No Code
}
When I have many shapes to resize, which will be faster and more stable? It seems that the first one will be faster, but I'm not sure. And the second one will be simple and convenient (no need use rect1, rect2 , ... ,rect8
). Which should be used in my app?