コード例 #1
0
 //opening window with rules of this game
 private void MenuRules_Click(object sender, RoutedEventArgs e)
 {
     if (rulesWindow == null)
     {
         rulesWindow = new RulesWindow.RulesWindow()
         {
             Owner = this,
         };
         rulesWindow.WindowClosing += RulesWindow_WindowClosing;
         rulesWindow.Show();
     }
     else
     {
         rulesWindow.Activate();
     }
     MemoryManagement.FlushMemory();
 }
コード例 #2
0
        //constructor
        public MainWindow()
        {
            InitializeComponent();

            //seting default user data (ID and login)
            playerDBID = 0;

            //inicialize datapleceholders
            SavedDataPlaceholder = new SavedDataClass();

            //variables for logging unhandled exceptions
            AppDomain currentDomain = default;

            currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

            //Synchronization context
            SynchCont = SynchronizationContext.Current;

            //NLOG configutation methos
            string logsLocation = logLocationString + @"MakaoGameLogs" + DateTime.Now.ToString() + ".txt";

            NLogConfigMethod(logsLocation);

            //setting directory of avatars used in game location
            avatarTempLocation = logLocationString.Substring(0, logLocationString.Length - 5) + @"AvatarsTemp\";

            //reading saved data at the start of application
            ReadDataFromSettings(DefaultUserSettings.GetDefaultSettings());

            //Avatar
            AssignAvatar(SavedDataPlaceholder.CurrentAvatarPicture);

            //assign background
            AssignMainWindowBackgroundGraphics();

            //generate cliend endpoint Uri
            thisClientEndpoint = MakaoGameClientServiceAddresObtainer.GetClientServiceEndpoint();

            //delete host endpoint - assign null
            makaoGameHostEndpoint = null;

            //deleting old logs in new task
            Task deleteOldLogs = new Task(new Action(DeleteOldLogFiles));

            deleteOldLogs.Start();

            //subscription of event - the event is fired, when host user deleted the room
            DataPlaceholder.TheRoomWasDeleted += DataPlaceholder_TheRoomWasDeleted;

            //subscription for an event of opening new window game command from game host service
            DataPlaceholder.NewGameStarted += DataPlaceholder_NewGameStarted;

            //changing status of application (host, client or none)
            ApplicationStatusChanged += MainWindow_ApplicationStatusChanged;

            //start client service
            StartMakaoGameClientService();

            //assign rules window as null
            rulesWindow = null;

            //assign local IP address of endpoint of this devce
            UserIPString.Text = $"IP: {MakaoGameClientServiceAddresObtainer.GetLocalIPAddressString()}, ";
        }
コード例 #3
0
 //event for closing rulew window
 private void RulesWindow_WindowClosing(object sender, EventArgs e)
 {
     rulesWindow.WindowClosing -= RulesWindow_WindowClosing;
     rulesWindow = null;
 }