/// <summary> /// Sets the Drawstate of the window. Can the user draw or interact with desktop and/or see what was drawn earlier. /// </summary> /// <param name="state"></param> internal void ShowState(DrawState state) { switch (state) { case DrawState.TransparentCanDrawNoDesktopInteraction: //This first state is not really transparent, a bitmap of the desktop is used as //background. Necessary to use the InkCanvas to draw. InkCanvas cannot be used if the //window is truly transparent DrawArea.EditingMode = InkCanvasEditingMode.Ink; MakeOpaqueToEvents(); IsHitTestVisible = true; Opacity = 1; using (BitmapHandler handler = new BitmapHandler()) { BackGroundImage.Source = handler.GetDesktopBitmapSource((int)Left, (int)Top, (int)Width, (int)Height); } ClearValue(Window.BackgroundProperty); Show(); CurrentState = state; break; case DrawState.SemitransparentDrawingFixed: //Changes to a semitransparent state where the drawing is fixed. But it is possible to interact //with the desktop. DrawArea.EditingMode = InkCanvasEditingMode.Ink; MakeTransparentToEvents(); IsHitTestVisible = false; Opacity = 0.5; BackGroundImage.ClearValue(Image.SourceProperty); Background = Brushes.White; Show(); CurrentState = state; break; case DrawState.TransparentNoDrawing: DrawArea.EditingMode = InkCanvasEditingMode.Ink; MakeOpaqueToEvents(); IsHitTestVisible = true; Opacity = 0; BackGroundImage.ClearValue(Image.SourceProperty); Background = Brushes.Transparent; Show(); CurrentState = state; break; default: throw new ArgumentOutOfRangeException("state"); } }
public static void Load() { _objs = new BaseObject[30]; for (int i = 0; i < _objs.Length; i++) { if (i % 2 == 0) { _objs[i] = new BaseObject(new Point(600, i * 20), new Point(-i, -i), new Size(30, 30)); } else { _objs[i] = new Star(new Point(600, i * 20), new Point(-i, 0), new Size(5, 5)); } } plnt = new BackGroundImage(Width, Height); }