Click here to Skip to main content
15,881,715 members
Home / Discussions / C#
   

C#

 
GeneralRe: casting at runtime in c# Pin
Simon_Whale1-Nov-12 0:45
Simon_Whale1-Nov-12 0:45 
GeneralRe: casting at runtime in c# Pin
prasadbuddhika1-Nov-12 4:24
prasadbuddhika1-Nov-12 4:24 
GeneralRe: casting at runtime in c# Pin
Simon_Whale1-Nov-12 5:05
Simon_Whale1-Nov-12 5:05 
GeneralRe: casting at runtime in c# Pin
prasadbuddhika1-Nov-12 5:25
prasadbuddhika1-Nov-12 5:25 
GeneralRe: casting at runtime in c# Pin
BobJanova1-Nov-12 5:19
BobJanova1-Nov-12 5:19 
GeneralRe: casting at runtime in c# Pin
prasadbuddhika1-Nov-12 5:28
prasadbuddhika1-Nov-12 5:28 
QuestionC# Experts Pin
Member 955692930-Oct-12 19:32
Member 955692930-Oct-12 19:32 
AnswerRe: C# Experts Pin
Pete O'Hanlon30-Oct-12 21:29
mvePete O'Hanlon30-Oct-12 21:29 
Unfortunately, this functionality isn't built into .NET, but it is relatively straightforward to implement. If I were doing this, I would look to create a SceneManager class which was responsible for managing the child items. In other words, it would create the item and maintain them in some form of collection. For example:
C#
public sealed class SceneManager
{
  private List<SceneItem> children = new List<SceneItem>();

  public T AddVisual<T>(T visual) where T : SceneItem
  {
    children.Add(visual);
  }
}
I would then wrap the RichTextBox and polygons up into somethnig that can be added to the list, and which knows how to position and draw itself. This wouuld then enable you to add a single point of entry to allow you to draw the scene. It would look something like this in the SceneManager class.
C#
public void Draw()
{
  foreach(SceneItem child in children)
  {
    child.Draw();
  }
}
Obviously this is all very simplistic, but it should serve to give you some idea of how to implement it. The point is - this class and the classes for the items you are going to draw on the screen simply contain the data that is needed to draw the items. By changing the data, you can change the underlying elements. Suppose, for instance, that you had a method called Offset that you wanted to use to move the children by a certain amount. It simply becomes a case of doing this:
C#
public void Offset(int x, int y)
{
  foreach (SceneItem child in children)
  {
    child.Top += x;
    child.Left += y;
    child.Draw();
  }
}

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

QuestionSocket read deserialization exception (fyi - problem already resolved) Pin
devvvy30-Oct-12 17:19
devvvy30-Oct-12 17:19 
QuestionMaking Serial Port Visible Pin
C-P-User-330-Oct-12 11:35
C-P-User-330-Oct-12 11:35 
AnswerRe: Making Serial Port Visible Pin
Pete O'Hanlon30-Oct-12 11:59
mvePete O'Hanlon30-Oct-12 11:59 
AnswerRe: Making Serial Port Visible Pin
Big Daddy Farang30-Oct-12 12:05
Big Daddy Farang30-Oct-12 12:05 
GeneralRe: Making Serial Port Visible Pin
C-P-User-330-Oct-12 12:33
C-P-User-330-Oct-12 12:33 
GeneralRe: Making Serial Port Visible Pin
C-P-User-330-Oct-12 13:09
C-P-User-330-Oct-12 13:09 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang30-Oct-12 13:42
Big Daddy Farang30-Oct-12 13:42 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 4:43
C-P-User-331-Oct-12 4:43 
GeneralRe: Making Serial Port Visible Pin
Pete O'Hanlon31-Oct-12 5:02
mvePete O'Hanlon31-Oct-12 5:02 
GeneralRe: Making Serial Port Visible Pin
C-P-User-32-Nov-12 6:47
C-P-User-32-Nov-12 6:47 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang31-Oct-12 5:38
Big Daddy Farang31-Oct-12 5:38 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 6:56
C-P-User-331-Oct-12 6:56 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 7:02
C-P-User-331-Oct-12 7:02 
GeneralRe: Making Serial Port Visible Pin
David Knechtges31-Oct-12 7:16
David Knechtges31-Oct-12 7:16 
GeneralRe: Making Serial Port Visible Pin
C-P-User-331-Oct-12 7:39
C-P-User-331-Oct-12 7:39 
GeneralRe: Making Serial Port Visible Pin
Big Daddy Farang31-Oct-12 8:26
Big Daddy Farang31-Oct-12 8:26 
GeneralRe: Making Serial Port Visible Pin
C-P-User-32-Nov-12 7:52
C-P-User-32-Nov-12 7:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.