static void Main(string[] args) { FigureRectangle figRect = new FigureRectangle(); figRect.NomForme(); FigureTriangle figTri = new FigureTriangle(); figTri.NomForme(); Console.WriteLine("**********************************"); Figures figS = new Figures(); figS.Add(figRect); figS.Add(figTri); figS.NomForme(); Console.WriteLine("**********************************"); //mafigure.Accept(new Visiteur()); -> aura pour consequence d'afficher le message VisiteurFigurePourConsole iv = new VisiteurFigurePourConsole(); FigureRectangle figRect2 = new FigureRectangle(); iv.Visit(figRect2); }
private void bindNodeFigure(Node node) { var figure = new FigureRectangle(); figure.DataContext = node; BindingFunctions.BindProperty(figure, node, "FigureType", FigureRectangle.FigureTypeProperty, BindingMode.TwoWay); BindingFunctions.BindProperty(figure, node, "IsSelected", FigureBase.TrackerVisibleProperty, BindingMode.TwoWay); this.Children.Add(figure); }
static IEnumerable <Figure> GetRandomFigures(int count) { const int MinWidth = 10; const int MaxWidth = 50; const int MinHeight = 10; const int MaxHeight = 50; var random = new Random(); while (0 < count--) { var W = random.Next(MinWidth, MaxWidth); var H = random.Next(MinHeight, MaxHeight); Figure figure = null; switch (random.Next(0, 5)) { case 0: figure = new FigureQuadre(W, RandomColor(random)); break; case 1: figure = new FigureRectangle(W, H, RandomColor(random)); break; case 2: figure = new FigureCircle(W, RandomColor(random)); break; case 3: figure = new FigureEllipse(W, H, RandomColor(random)); break; case 4: figure = new FigureTriangle(W, H, RandomColor(random)); break; default: throw new Exception("Не удалось создать игуру"); } Figure.ToolTipEnable(figure); yield return(figure); } }
public void DessineFigure(int deplace) { SolidBrush myBrush = new SolidBrush(Color.Red); Graphics formGraphics; formGraphics = this.CreateGraphics(); VisiteurFigurePourWinForms ivwf = new VisiteurFigurePourWinForms(); FigureRectangle figRect = new FigureRectangle(); FigureRectangle figRectV1 = (FigureRectangle)ivwf.Visit(figRect); figRectV1.X = 10 + deplace; figRectV1.Y = 10 + deplace; figRectV1.Largeur = 50; figRectV1.Longueur = 100; formGraphics.FillRectangle(myBrush, new Rectangle(figRectV1.X, figRectV1.Y, figRectV1.Largeur, figRectV1.Longueur)); myBrush.Dispose(); formGraphics.Dispose(); }
public bool Visit(FigureRectangle _f) { Console.WriteLine(_f.ToString()); return(true); }
public object Visit(FigureRectangle _f) { return(_f); }