//private void intList_Changed(object sender, PropertyChangedEventArgs e) //{ // if (e.PropertyName == "Current") // { // selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); // updateUserList(selectedServer); // } //} public void items_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { //your code selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); updateUserList(selectedServer); } if (e.OldItems != null) { foreach (INotifyPropertyChanged item in e.OldItems) { item.PropertyChanged -= new PropertyChangedEventHandler(item_PropertyChanged); } } if (e.NewItems != null) { foreach (INotifyPropertyChanged item in e.NewItems) { item.PropertyChanged += new PropertyChangedEventHandler(item_PropertyChanged); } } }
private void JoinServer(object sender, RoutedEventArgs e) { string appDataPath = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData); string path = System.IO.Path.Combine(appDataPath, "DayZServer"); DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string serverIP = obj.IP_Address; // start the game seperated from this process. using (Process game = new Process()) { string dayzapppath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), path, "dayzapppath.txt"); string dayzpath = readAppPath(dayzapppath); dayzpath = dayzpath.TrimEnd('\r', '\n'); if (File.Exists(dayzpath)) { try { Process thisProc = Process.GetCurrentProcess(); if (IsProcessOpen("DayZ") == false) { ProcessStartInfo startInf = new ProcessStartInfo(dayzpath); startInf.Arguments = "-connect=" + serverIP; game.StartInfo = startInf; game.Start(); } else { Process[] objProcesses = System.Diagnostics.Process.GetProcessesByName("DayZ"); if (objProcesses.Length > 0) { //******Works to bring the app to the foreground but cant pass the server Argument so just commented this. //IntPtr hWnd = IntPtr.Zero; //hWnd = objProcesses[0].MainWindowHandle; //ShowWindowAsync(new HandleRef(null,hWnd), SW_RESTORE); //SetForegroundWindow(objProcesses[0].MainWindowHandle); //******could not get Steam to pass the server Argument so just killed the app and start it up. objProcesses[0].Kill(); ProcessStartInfo startInf = new ProcessStartInfo(dayzpath); startInf.Arguments = "-connect=" + serverIP; game.StartInfo = startInf; game.Start(); } } } catch (Exception err) { Console.WriteLine(err.Message); } } else { browse_dialog.Visibility = Visibility.Visible; } } }
private void ServerHyperlink_RequestNavigate(object sender, MouseButtonEventArgs e) { DataManager.Server obj = ((TextBlock)sender).Tag as DataManager.Server; string FullIP_Address = obj.FullIP_Address; string URL = "https://www.gametracker.com/server_info/" + FullIP_Address + "/"; Process.Start(URL); }
private void server_Details(object sender, RoutedEventArgs e) { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; selectedIP = obj.IP_Address; updateUserList(obj); selectedServer = obj; }
public void Copy_ServerIP(object sender, RoutedEventArgs e) { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string fullAddress = obj.FullIP_Address; Clipboard.SetText(fullAddress); copynotifier.ShowSuccess("Copied: " + fullAddress); }
private void Hyperlink_Click(object sender, RoutedEventArgs e) { DataManager.Server obj = ((Hyperlink)sender).Tag as DataManager.Server; string FullIP_Address = obj.FullIP_Address; string URL = "https://www.gametracker.com/server_info/" + FullIP_Address + "/"; Process.Start(URL); }
public void updateUserList(DataManager.Server obj) { this.Dispatcher.Invoke((Action)(() => { //if (userList.Items.Count != 0) //{ string dgSortDescriptionUser = null; ListSortDirection?dgSortDirectionUser = null; int columnIndexUser = 0; //System.Collections.ObjectModel.ObservableCollection<DataGrid> itemsColl = null; foreach (DataGridColumn column in userList.Columns) { columnIndexUser++; if (column.SortDirection != null) { dgSortDirectionUser = column.SortDirection; dgSortDescriptionUser = column.SortMemberPath; break; } } try { userList.ItemsSource = obj.playersList; } catch (Exception err) { Console.WriteLine(err.Message); } if (!string.IsNullOrEmpty(dgSortDescriptionUser) && dgSortDirectionUser != null) { SortDescription sUser = new SortDescription(dgSortDescriptionUser, dgSortDirectionUser.Value); CollectionView viewUser = (CollectionView)CollectionViewSource.GetDefaultView(userList.ItemsSource); try { viewUser.SortDescriptions.Add(sUser); userList.Columns[columnIndexUser - 1].SortDirection = dgSortDirectionUser; } catch (Exception err) { //Console.WriteLine(err.Message); //DataManager.Server currentServer = dm.getCurrentServerList(); //selectedIP = currentServer.IP_Address; //updateUserList(dm.userList(selectedIP)); } } })); //} //else //{ // userList.ItemsSource = obj.linkItem; //} }
private void delete_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke((Action)(() => { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string deleteServer = obj.IP_Address; dm.deleteServer(deleteServer); })); }
private void favorite_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke((Action)(() => { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string favoriteServer = obj.FullIP_Address; dm.updateFavorite(favoriteServer); updateServerList(); })); }
private void server_Details(object sender, RoutedEventArgs e) { string appDataPath = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData); string path = System.IO.Path.Combine(appDataPath, "DayZServer"); DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; selectedIP = obj.IP_Address; updateUserList(obj); }
public void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Current") { selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); updateUserList(selectedServer); } //if (e.PropertyName == "PingSpeed") //{ //} }
private void JoinServer(object sender, RoutedEventArgs e) { string appDataPath = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData); string path = System.IO.Path.Combine(appDataPath, "DayZServer"); DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string serverIP = obj.IP_Address; string gamePort = obj.Game_Port; // start the game seperated from this process. using (Process game = new Process()) { string dayzapppath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), path, "dayzapppath.txt"); string dayzpath = readAppPath(dayzapppath); dayzpath = dayzpath.TrimEnd('\r', '\n'); if (File.Exists(dayzpath)) { try { Process thisProc = Process.GetCurrentProcess(); if (IsProcessOpen("DayZ") == false) { ProcessStartInfo startInf = new ProcessStartInfo(dayzpath); startInf.Arguments = "-cpuCount=2 -noSplash -exThreads=3 -mod=@cars -connect=" + serverIP + " -port=" + gamePort + ""; game.StartInfo = startInf; game.Start(); } else { Process[] objProcesses = System.Diagnostics.Process.GetProcessesByName("DayZ"); if (objProcesses.Length > 0) { objProcesses[0].Kill(); ProcessStartInfo startInf = new ProcessStartInfo(dayzpath); startInf.Arguments = "-cpuCount=2 -noSplash -exThreads=3 -mod=@cars -connect=" + serverIP + " -port=" + gamePort + ""; game.StartInfo = startInf; game.Start(); } } } catch (Exception err) { Console.WriteLine(err.Message); } } else { browse_dialog.Visibility = Visibility.Visible; } } }
public void updateUserList(DataManager.Server obj) { this.Dispatcher.Invoke((Action)(() => { string dgSortDescriptionUser = null; ListSortDirection?dgSortDirectionUser = null; int columnIndexUser = 0; foreach (DataGridColumn column in userList.Columns) { columnIndexUser++; if (column.SortDirection != null) { dgSortDirectionUser = column.SortDirection; dgSortDescriptionUser = column.SortMemberPath; break; } } try { if (obj != null) { ActiveServerName.Text = obj.ServerName; userList.ItemsSource = obj.playersList; } } catch (Exception err) { Console.WriteLine(err.Message); } if (!string.IsNullOrEmpty(dgSortDescriptionUser) && dgSortDirectionUser != null) { SortDescription sUser = new SortDescription(dgSortDescriptionUser, dgSortDirectionUser.Value); CollectionView viewUser = (CollectionView)CollectionViewSource.GetDefaultView(userList.ItemsSource); try { viewUser.SortDescriptions.Add(sUser); userList.Columns[columnIndexUser - 1].SortDirection = dgSortDirectionUser; } catch (Exception err) { Console.WriteLine(err.Message); } } })); }
public Window1() { InitializeComponent(); updateServerListTimer = new System.Timers.Timer(1000); updateServerListTimer.Elapsed += OnServerListTimedEvent; updateServerListTimer.Enabled = true; checkProfileForNewServerTimer = new System.Timers.Timer(4000); checkProfileForNewServerTimer.Elapsed += OnNewServerTimedEvent; checkProfileForNewServerTimer.Enabled = true; steamLogin.Visibility = Visibility.Hidden; browse_dialog.Visibility = Visibility.Hidden; dm.startDataManager(); DataManager.Server currentServer = dm.getCurrentServerList(); selectedIP = currentServer.IP_Address; }
private void delete_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke((Action)(() => { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; string deleteServer = obj.ServerName; dm.deleteServer(deleteServer); updateServerList(); })); //if (obj.IP_Address == selectedIP) //{ // DataManager.Server serverobj = dm.getCurrentServerList(); // updateUserList(serverobj); // selectedIP = serverobj.IP_Address; //} }
public ServerHistory() { InitializeComponent(); ActiveServerName.MouseLeftButtonDown += new MouseButtonEventHandler(Hyperlink_RequestNavigate); browse_dialog.Visibility = Visibility.Hidden; dm.startDataManager(); //dm.Servers.CollectionChanged += CollectionChangedMethod; //((INotifyPropertyChanged)Servers).PropertyChanged += // new PropertyChangedEventHandler(intList_Changed); DataContext = this; serverList.ItemsSource = dm.Servers; ObservableCollection <INotifyPropertyChanged> items = new ObservableCollection <INotifyPropertyChanged>(); dm.Servers.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler( items_CollectionChanged); //selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); _time = _measureGap; _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Background, delegate { if (selectedServer == null) { selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); } updateUserList(selectedServer); if (_time == TimeSpan.Zero) { _timer.Stop(); _time = _measureGap; _timer.Start(); } _time = _time.Add(TimeSpan.FromSeconds(-1)); }, this.Dispatcher); _timer.Start(); }
private void favorite_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke((Action)(async() => { DataManager.Server obj = ((Button)sender).Tag as DataManager.Server; Button fButton = sender as Button; ImageBrush checkon = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "images/checkon.png"))); ImageBrush checkoff = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "images/checkoff.png"))); //fButton.Background = new ImageBrush(new BitmapImage(new Uri(@"pack://application:,,,/DayZServer;images/checkon.png"))); if (obj.Favorite == "0") { fButton.Background = checkon; } else { fButton.Background = checkoff; } string favoriteServer = obj.FullIP_Address; await dm.updateFavorite(favoriteServer); })); }
private void ClearHistory(object sender, RoutedEventArgs e) { selectedServer = dm.Servers.FirstOrDefault(x => x.Current == "1"); updateUserList(selectedServer); dm.deleteServerHistory(); }