private void Initialize() { m_PlayingControl = new PlayingControl(); ReadSettings(); Settings.Settings.Instance.MessageFilterLevel = 1; Messages.Instance.MessageReceived += new MessageReceivedHandler(MessageReceived); if (Ares.Settings.Settings.Instance.RecentFiles.GetFiles().Count > 0) { OpenProject(Ares.Settings.FolderFactory.CreateFile(Ares.Settings.Settings.Instance.RecentFiles.GetFiles()[0].FilePath), false); } bool foundAddress = false; bool foundIPv4Address = false; String ipv4Address = String.Empty; String ipAddress = String.Empty; foreach (System.Net.IPAddress address in System.Net.Dns.GetHostAddresses(String.Empty)) { //if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) // continue; if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { foundIPv4Address = true; ipv4Address = address.ToString(); } String s = address.ToString(); if (s == Settings.Settings.Instance.IPAddress) { foundAddress = true; ipAddress = s; } else if (!foundAddress) { ipAddress = s; // take first one } } if (!foundAddress && foundIPv4Address) { ipAddress = ipv4Address; // prefer v4 } if (!String.IsNullOrEmpty(ipAddress)) { Settings.Settings.Instance.IPAddress = ipAddress; } else { Toast.MakeText(this, Resource.String.no_ip_address, ToastLength.Long).Show(); return; } m_Network = new Networks(this, Settings.Settings.Instance.UseLegacyNetwork, Settings.Settings.Instance.UseWebNetwork); m_Network.InitConnectionData(); m_Network.StartUdpBroadcast(); m_BroadcastTimer = new System.Timers.Timer(50); m_BroadcastTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_BroadcastTimer_Elapsed); m_BroadcastTimer.Enabled = true; m_Network.ListenForClient(); }
public void UpdateCardPopupPosition() { if (double.IsNaN(Top) || double.IsNaN(Left) || double.IsNaN(Width) || double.IsNaN(Height)) { return; } var top = (int)Top; var left = (int)Left; var width = (int)Width; DraftingControl.SetCardPopupPosition(ViewModel.Config.ForceCardPopupSide, top, left, width); PlayingControl.SetCardPopupPosition(ViewModel.Config.ForceCardPopupSide, top, left, width); }
private void UpdateCardPopupPosition() { if (double.IsNaN(Top) || double.IsNaN(Left) || double.IsNaN(Width) || double.IsNaN(Height)) { return; } var top = (int)Top; var left = (int)Left; var width = (int)Width; ForceCardPopupSideEnum side = GetCardPopupSide(); DraftingControl.SetCardPopupPosition(side, top, left, width); PlayingControl.SetCardPopupPosition(side, top, left, width); }
public MainWindow( ConfigModel configApp, ICollection <Card> allCards, MainWindowVM viewModel, ProcessMonitor processMonitor, LogFileZipper zipper, ServerApiCaller api, StartupShortcutManager startupManager, LogSplitter logSplitter, MtgaResourcesLocator resourcesLocator, FileMonitor fileMonitor, DraftCardsPicker draftHelper, ReaderMtgaOutputLog readerMtgaOutputLog, InGameTracker2 inMatchTracker, ExternalProviderTokenManager tokenManager, PasswordHasher passwordHasher, CacheSingleton <Dictionary <string, DraftRatings> > draftRatings, DraftHelperRunner draftHelperRunner) { // Set the config model reference ConfigModel = configApp; Reader = readerMtgaOutputLog; processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged; Zipper = zipper; Api = api; StartupManager = startupManager; LogSplitter = logSplitter; ResourcesLocator = resourcesLocator; FileMonitor = fileMonitor; fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText; DraftHelper = draftHelper; //this.logProcessor = logProcessor; InGameTracker = inMatchTracker; TokenManager = tokenManager; PasswordHasher = passwordHasher; DraftRatings = draftRatings; DraftHelperRunner = draftHelperRunner; ResourcesLocator.LocateLogFilePath(ConfigModel); ResourcesLocator.LocateGameClientFilePath(ConfigModel); fileMonitor.SetFilePath(ConfigModel.LogFilePath); // Set the view model MainWindowVM = viewModel; // Set the data context to the view model DataContext = MainWindowVM; InitializeComponent(); WelcomeControl.Init(tokenManager); PlayingControl.Init(MainWindowVM); StatusBarTop.Init(this, MainWindowVM); ReadyControl.Init(ConfigModel.GameFilePath); DraftingControl.Init(allCards, MainWindowVM.DraftingVM); DraftingControl.SetPopupRatingsSource(ConfigModel.ShowLimitedRatings, ConfigModel.ShowLimitedRatingsSource); processMonitor.Start(new System.Threading.CancellationToken()); FileMonitor.Start(new System.Threading.CancellationToken()); var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) }; timer.Tick += (sender, e) => { MainWindowVM.SetCardsDraftFromBuffered(); MainWindowVM.SetCardsInMatchTrackingFromBuffered(); }; timer.Start(); var timerTokenRefresh = new DispatcherTimer { Interval = TimeSpan.FromMinutes(9) }; timerTokenRefresh.Tick += (sender, e) => { RefreshAccessToken(); }; timerTokenRefresh.Start(); }
public Player(Ares.Playing.BassInit init) { m_PlayingControl = new PlayingControl(); m_BassInit = init; }
/// <summary> /// Complete constructor /// </summary> public MainWindow(MainWindowVM viewModel) { mapper = viewModel.Mapper; ViewModel = viewModel; // Set the main window view model actions ViewModel.UploadLogAction = UploadLogAction; ViewModel.ShowOptionsAction = ShowOptionsWindow; ViewModel.LaunchArenaAction = LaunchArenaAction; ViewModel.ValidateUserAction = ValidateUserAction; // Set the resource locator ResourcesLocator = viewModel.ResourcesLocator; // Set the problem action ResourcesLocator.SetProblem = ViewModel.SetProblem; // Locate the log file ResourcesLocator.LocateLogFilePath(ViewModel.Config); // Locate the game path ResourcesLocator.LocateGameClientFilePath(ViewModel.Config); // Set the reference to the draft helper DraftHelperRunner = viewModel.DraftHelperRunner; Reader = viewModel.ReaderMtgaOutputLog; Api = viewModel.Api; StartupManager = viewModel.StartupManager; FileMonitor = viewModel.FileMonitor; FileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText; DraftHelper = viewModel.DraftHelper; //this.logProcessor = logProcessor; InGameTracker = viewModel.InMatchTracker; TokenManager = viewModel.TokenManager; PasswordHasher = viewModel.PasswordHasher; DraftRatings = viewModel.DraftRatings; FileMonitor.SetFilePath(ViewModel.Config.LogFilePath); // Set the data context to the view model DataContext = ViewModel; InitializeComponent(); PlayingControl.Init(ViewModel); DraftingControl.Init(ViewModel.DraftingVM, ViewModel.Config.LimitedRatingsSource); DraftingControl.SetPopupRatingsSource(ViewModel.Config.ShowLimitedRatings, ViewModel.Config.LimitedRatingsSource); // Set the process monitor status changed action viewModel.ProcessMonitor.OnProcessMonitorStatusChanged = OnProcessMonitorStatusChanged; // Start the process monitor without awaiting the task completion _ = viewModel.ProcessMonitor.Start(new System.Threading.CancellationToken()); // Start the file monitor without awaiting the task completion _ = FileMonitor.Start(new System.Threading.CancellationToken()); var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) }; timer.Tick += (sender, e) => { ViewModel.DraftingVM.SetCardsDraftFromBuffered(); ViewModel.InMatchState.SetInMatchStateFromBuffered(); }; timer.Start(); var timerTokenRefresh = new DispatcherTimer { Interval = TimeSpan.FromMinutes(9) }; timerTokenRefresh.Tick += (sender, e) => { RefreshAccessToken(); }; timerTokenRefresh.Start(); }