private void Refresh() { using (DrawingContext dc = this.m_drawingGroup.Open()) { m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle); } this.ImgMain.Source = this.ImageSource; }
public FailOverWindow(MainWindow mainWindow, GoHInterface goHInterface, Rect zoneDessinRectangle) { //this.ImgLogo.Source = new BitmapImage(new Uri(@"..\Images\Logo.png")); //this.ImgStatus.Source = new BitmapImage(new Uri(@"..\Images\Status.png")); this.ZoneDessinRectangle = zoneDessinRectangle; goHInterface.IsBackground = true; this.m_goHInterface = goHInterface; //this.m_mainWindow = mainWindow; InitializeComponent(); // Create the drawing group we'll use for drawing this.m_drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.ImageSource = new DrawingImage(this.m_drawingGroup); using (DrawingContext dc = this.m_drawingGroup.Open()) { m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle); } Refresh(); this.ImgMain.MouseMove += ImgMain_MouseMove; this.ImgMain.MouseDown += ImgMain_MouseMove; this.ImgMain.MouseUp += ImgMain_MouseMove; mainWindow.Hide(); }
private void ImgMain_MouseMove(object sender, MouseEventArgs e) { //Console.WriteLine(@" debut moseMove "); UIElement element = sender as UIElement; if (element != null) { UIElement ele = element; MouseDevice mouse = e.MouseDevice; Point point = mouse.GetPosition(ele); //Console.WriteLine(@" emouse.GetPosition : " + point); using (DrawingContext dc = this.m_drawingGroup.Open()) { m_goHInterface.AddVisualInterface(dc, this.ZoneDessinRectangle); if (mouse.LeftButton.Equals(MouseButtonState.Pressed)) { m_goHInterface.AddMainFermer(point, dc, this.ZoneDessinRectangle); } else { m_goHInterface.AddMainOuverte(point, dc, ImageSource.Width, ImageSource.Height); } } } else { Console.WriteLine(@" element <=> null "); } Refresh(); //Console.WriteLine(@" fin mouseMove "); }