public StartMirroringForm(IntPtr parentHandle, MirrorState mirrorState, Action startMirroringAction, Action stopMirroringAction) : base(parentHandle) { InitializeComponent(); this.mirrorState = mirrorState; this.startMirroringAction = startMirroringAction; this.stopMirroringAction = stopMirroringAction; this.ShowInTaskbar = false; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); InjectorFactory injectorFactory = new InjectorFactory(); IFormInjector makeFormInjector = injectorFactory.MakeFormInjector(new[] { new DefaultProcessSelector("explorer", Process.GetCurrentProcess().ProcessName, "devenv", "ApplicationFrameHost", "ScriptedSandbox64") }); MirrorState stateObject = new MirrorState(); stateObject.Active = false; OriginalForm originalForm = new OriginalForm(stateObject, makeFormInjector); makeFormInjector.Inject(ptr => new StartMirroringForm(ptr, stateObject, originalForm.StartMirroring, originalForm.StopMirroring)); Application.Run(originalForm); }
public OriginalForm(MirrorState stateObj, IFormInjector injector) { InitializeComponent(); _mirrorState = stateObj; this.injector = injector; MenuItem itemClose = new MenuItem(); MenuItem itemCheckSecond = new MenuItem(); MenuItem itemMoveWindows = new MenuItem(); _notifyContextMenu.MenuItems.Add(itemClose); _notifyContextMenu.MenuItems.Add(itemCheckSecond); _notifyContextMenu.MenuItems.Add(itemMoveWindows); _notifyContextMenu.MenuItems.Add(_itemStop); itemClose.Index = 3; itemClose.Text = "Schließen"; itemClose.Click += new EventHandler(this.itemClose_Click); _itemStop.Index = 0; _itemStop.Text = "Spiegelung beenden"; _itemStop.Enabled = false; _itemStop.Click += new EventHandler(this.itemStop_Click); itemCheckSecond.Index = 1; itemCheckSecond.Text = "Zweiten Bildschirm anzeigen"; itemCheckSecond.Click += new EventHandler(this.itemCheckSecond_Click); itemMoveWindows.Index = 2; itemMoveWindows.Text = "Alle Fenster auf Hauptbildschirm schieben"; itemMoveWindows.Click += new EventHandler(this.itemMoveWindows_Click); notifyIcon1.ContextMenu = _notifyContextMenu; //CreatePinBtnForm(); //_pinBtnForm.PositionButton(); FirstStartCheck(); HK = new HotKey(); HK.enable(this.Handle, 0, GetHotkeyFromRegistry()); GetExcludedWindowsFromRegistry(); GetScreenshotWindowsFromRegistry(); _defaultMirrorIndex = GetMirrorScreenIndexFromRegistry(); timer1.Stop(); Screen[] screens = Screen.AllScreens; if (screens.Length > 1) { CreateMirrorForm(); } else { MessageBox.Show("Single monitor nicht unterstützt.\r\nSpiegelung funtkioniert nicht wie gewünscht."); Environment.Exit(0); } this.WindowState = FormWindowState.Minimized; this.Hide(); }