public static Point GetMousePosition() { NativeMethods.Win32Point w32Mouse = new NativeMethods.Win32Point(); NativeMethods.GetCursorPos(ref w32Mouse); return(new Point(w32Mouse.X, w32Mouse.Y)); }
public MainWindow() { InitializeComponent(); // Checking the config file integrity and processing it if (File.Exists(confPath)) { try { confFile = XDocument.Load(confPath); leftCompIP = (from ips in confFile.Descendants("IPs").Descendants("IP") select ips).ElementAt(0); rightCompIP = (from ips in confFile.Descendants("IPs").Descendants("IP") select ips).ElementAt(1); leftCompIPTB.Text = leftCompIP.Value; rightCompIPTB.Text = rightCompIP.Value; } catch { CreateNewConfigXmlDoc(true); MessageBox.Show("Plik konfiguracyjny był uszkodzony i został nadpisany przez prawidłową, lecz pustą wersję.", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } } else { CreateNewConfigXmlDoc(true); } // Adding shortcut and binding commands RoutedCommand newCmd = new RoutedCommand(); newCmd.InputGestures.Add(new KeyGesture(System.Windows.Input.Key.S, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(newCmd, ControlSExecuted)); newCmd = new RoutedCommand(); newCmd.InputGestures.Add(new KeyGesture(System.Windows.Input.Key.C, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(newCmd, ControlCExecuted)); newCmd = new RoutedCommand(); newCmd.InputGestures.Add(new KeyGesture(System.Windows.Input.Key.V, ModifierKeys.Control)); CommandBindings.Add(new CommandBinding(newCmd, ControlVExecuted)); disposed = false; mainTimer = new DispatcherTimer(); mainTimer.Interval = new TimeSpan(0, 0, 1); mainTimer.Tick += mainTimer_Tick; edgeCheckerTimer = new DispatcherTimer(); edgeCheckerTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); edgeCheckerTimer.Tick += edgeCheckerTimer_Tick; connAliveTimer = new DispatcherTimer(); connAliveTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); connAliveTimer.Tick += connAliveTimer_Tick; w32MousePos = new NativeMethods.Win32Point(); clipboardManager = new ClipboardManagerImpl(new DataObject()); pasteThreadlock = new object(); try { localIPLabel.Content = GetLocalIPAddress(); } catch (ApplicationException) { } RestoreAppToInitialState("Serwer został uruchomiony.", false); }