ShowWindow() публичный Метод

public ShowWindow ( ) : void
Результат void
Пример #1
0
        private void InitializeConstantsAndViewModels()
        {
            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Factory.StartNew((Action)(() =>
            {
                var success = false;
                var failedOnce = false;
                while (!success)
                {
                    success = Constants.Initialize();

                    LoadingWindowViewModel.MainWindowViewModel = MainWindowViewModel.GetInstance();
                    var initialMapPath = $"{LoadingWindowViewModel.Settings.MapDataFolder}/{LoadingWindowViewModel.Settings.InitialMap}";
                    success &= LoadingWindowViewModel.MainWindowViewModel.LoadMap(initialMapPath, true);

                    if (failedOnce)
                    {
                        MessageBox.Show("Loading failed again. Check that resource files exist and try again.");
                        Environment.Exit(1);
                    }
                    else if (!success)
                    {
                        failedOnce = true;
                        MessageBox.Show("Loading failed. Check your settings and try again.");
                        Application.Current?.Dispatcher?.Invoke(() => SettingsWindow.ShowWindow());
                    }
                }
            })).ContinueWith((r) =>
            {
                LoadingWindowViewModel.MainWindow = new MainWindow();
            }, scheduler);
        }
Пример #2
0
 private static void OpenSettings()
 {
     if (SettingsWindow == null)
     {
         SettingsWindow = (SettingsWindow)CreateInstance("SettingsWindow");
     }
     SettingsWindow.ShowWindow();
 }
Пример #3
0
        //public static event PropertyChangedEventHandler ClickThruChanged;
        //public static event PropertyChangedEventHandler TccVisibilityChanged;
        //public static event PropertyChangedEventHandler TccDimChanged;


        //public static bool ClickThru
        //{
        //    get => clickThru;
        //    set
        //    {
        //        if (clickThru != value)
        //        {
        //            clickThru = value;
        //            ClickThruChanged?.Invoke(null, new PropertyChangedEventArgs("ClickThruMode"));
        //        }
        //    }
        //}
        //public static bool IsTccVisible
        //{
        //    get
        //    {
        //        if (SessionManager.Logged && !SessionManager.LoadingScreen && IsFocused)
        //        {
        //            isTccVisible = true;
        //            return isTccVisible;
        //        }
        //        else
        //        {
        //            isTccVisible = false || App.Debug;
        //            return isTccVisible;
        //        }
        //    }
        //    set
        //    {
        //        if (isTccVisible != value)
        //        {
        //            isTccVisible = value;
        //            NotifyVisibilityChanged();
        //        }
        //    }
        //}
        //public static bool IsFocused
        //{
        //    get => isFocused;
        //    set
        //    {
        //        if (!FocusManager.Running) return;
        //        //if (isFocused == value)
        //        //{
        //        //    //if(focusCount > 3)
        //        //    //{
        //        //    //    return;
        //        //    //}
        //        //    return;
        //        //}
        //        isFocused = value;
        //        //if (isFocused)
        //        //{
        //        //    focusCount++;
        //        //}
        //        //else
        //        //{
        //        //    focusCount = 0;
        //        //}
        //        NotifyVisibilityChanged();
        //    }
        //}
        //public static bool SkillsEnded
        //{
        //    get => skillsEnded;
        //    set
        //    {
        //        if (value == false)
        //        {
        //            _undimTimer.Stop();
        //            _undimTimer.Start();
        //        }
        //        if (skillsEnded == value) return;
        //        skillsEnded = value;
        //        CombatChanged?.Invoke();
        //        NotifyDimChanged();
        //    }
        //}
        //public static bool IsTccDim
        //{
        //    get => SkillsEnded && !SessionManager.Encounter; // add more conditions here if needed
        //}

        public static void Init()
        {
            ForegroundManager = new ForegroundManager();
            FocusManager.Init();
            LoadWindows();
            _contextMenu = new ContextMenu();
            // ReSharper disable AssignNullToNotNullAttribute
            DefaultIcon   = new Icon(Application.GetResourceStream(new Uri("resources/tcc-logo.ico", UriKind.Relative))?.Stream);
            ConnectedIcon = new Icon(Application.GetResourceStream(new Uri("resources/tcc-logo-on.ico", UriKind.Relative))?.Stream);
            // ReSharper restore AssignNullToNotNullAttribute
            TrayIcon = new NotifyIcon()
            {
                Icon    = DefaultIcon,
                Visible = true
            };
            TrayIcon.MouseDown        += NI_MouseDown;
            TrayIcon.MouseDoubleClick += TrayIcon_MouseDoubleClick;
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            TrayIcon.Text = $"TCC v{v.Major}.{v.Minor}.{v.Build}";

            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Dashboard", Command = new RelayCommand(o => Dashboard.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Settings", Command = new RelayCommand(o => SettingsWindow.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Close", Command = new RelayCommand(o => App.CloseApp())
            });

            //_undimTimer.Elapsed += _undimTimer_Elapsed;

            //SettingsWindowOld = new SettingsWindowOld();
            SettingsWindow = new SettingsWindow();

            if (SettingsHolder.UseHotkeys)
            {
                KeyboardHook.Instance.RegisterKeyboardHook();
            }
            //TccWindow.RecreateWindow += TccWindow_RecreateWindow;
        }
Пример #4
0
        //private static void LoadCharWindow()
        //{
        //    var charWindowThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        CharacterWindow = new CharacterWindow();
        //        //CharacterWindow.AllowsTransparency = Settings.CharacterWindowSettings.AllowTransparency;

        //        CharacterWindow.Show();
        //        waiting = false;
        //        Dispatcher.Run();
        //    }));
        //    charWindowThread.Name = "Character window thread";
        //    charWindowThread.SetApartmentState(ApartmentState.STA);
        //    charWindowThread.Start();
        //    Debug.WriteLine("Char window loaded");
        //}
        //private static void LoadInfoWindow()
        //{
        //    var infoWindowThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        InfoWindow = new InfoWindow();
        //        waiting = false;
        //        Dispatcher.Run();
        //    }));
        //    infoWindowThread.Name = "Info window thread";
        //    infoWindowThread.SetApartmentState(ApartmentState.STA);
        //    infoWindowThread.Start();
        //    Debug.WriteLine("Info window loaded");
        //}
        //private static void LoadCooldownWindow()
        //{
        //    var cooldownWindowThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        CooldownWindow = new CooldownWindow();
        //        //CooldownWindow.AllowsTransparency = Settings.CooldownWindowSettings.AllowTransparency;

        //        CooldownWindow.Show();
        //        waiting = false;
        //        Dispatcher.Run();
        //    }));
        //    cooldownWindowThread.Name = "Cooldown bar thread";
        //    cooldownWindowThread.SetApartmentState(ApartmentState.STA);
        //    cooldownWindowThread.Start();
        //    Debug.WriteLine("Cd window loaded");


        //}
        //private static void LoadBossGaugeWindow()
        //{

        //    var bossGaugeThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        BossWindow = new BossWindow();

        //        //BossWindow.AllowsTransparency = Settings.BossWindowSettings.AllowTransparency;
        //        BossWindow.Show();
        //        waiting = false;

        //        Dispatcher.Run();
        //    }));
        //    bossGaugeThread.Name = "Boss gauge thread";
        //    bossGaugeThread.SetApartmentState(ApartmentState.STA);
        //    bossGaugeThread.Start();
        //    Debug.WriteLine("Boss window loaded");

        //}
        //private static void LoadBuffBarWindow()
        //{
        //    var buffBarThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        BuffWindow = new BuffWindow();
        //        BuffBarWindowViewModel.Instance.Player = new Data.Player();
        //        BuffWindow.Show();
        //        waiting = false;

        //        Dispatcher.Run();
        //    }));
        //    buffBarThread.Name = "Buff bar thread";
        //    buffBarThread.SetApartmentState(ApartmentState.STA);
        //    buffBarThread.Start();
        //    Debug.WriteLine("Buff window loaded");


        //}
        //private static void LoadGroupWindow()
        //{
        //    var groupWindowThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        GroupWindow = new GroupWindow();
        //        GroupWindow.Show();
        //        waiting = false;

        //        Dispatcher.Run();
        //    }));
        //    groupWindowThread.Name = "Group window thread";
        //    groupWindowThread.SetApartmentState(ApartmentState.STA);
        //    groupWindowThread.Start();
        //    Debug.WriteLine("Group window loaded");

        //}
        //private static void LoadChatWindow()
        //{
        //    var chatWindowThread = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        waiting = false;

        //        Dispatcher.Run();
        //    }));
        //    chatWindowThread.Name = "Chat thread";
        //    chatWindowThread.SetApartmentState(ApartmentState.STA);
        //    chatWindowThread.Start();
        //    Debug.WriteLine("Chat window loaded");

        //}
        //private static void LoadClassWindow()
        //{
        //    var t = new Thread(new ThreadStart(() =>
        //    {
        //        SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
        //        ClassWindow = new ClassWindow();
        //        ClassWindow.Closed += (s, ev) => ClassWindow.Dispatcher.InvokeShutdown();
        //        ClassWindow.Show();
        //        waiting = false;

        //        Dispatcher.Run();
        //    }));
        //    t.Name = "Class bar thread";
        //    t.SetApartmentState(ApartmentState.STA);
        //    t.Start();
        //    Debug.WriteLine("Class window loaded");


        //}
        private static void TrayIcon_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (SettingsWindow == null)
            {
                SettingsWindow = new SettingsWindow()
                {
                    Name = "Settings"
                };
            }
            SettingsWindow.ShowWindow();
        }
Пример #5
0
 public void OpenSettings()
 {
     SettingsWindow.ShowWindow();
 }
Пример #6
0
        public static void Init()
        {
            ForegroundManager = new ForegroundManager();
            ScreenSize        = new Size(SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
            ScreenCorrection  = new Size(1, 1);
            UpdateScreenCorrection();
            FocusManager.Init();
            LoadWindows();
            _contextMenu = new ContextMenu();
            var defaultIconStream = Application.GetResourceStream(new Uri("resources/tcc-logo.ico", UriKind.Relative))?.Stream;

            if (defaultIconStream != null)
            {
                DefaultIcon = new Icon(defaultIconStream);
            }
            var connectedIconStream = Application.GetResourceStream(new Uri("resources/tcc-logo-on.ico", UriKind.Relative))?.Stream;

            if (connectedIconStream != null)
            {
                ConnectedIcon = new Icon(connectedIconStream);
            }
            TrayIcon = new NotifyIcon()
            {
                Icon    = DefaultIcon,
                Visible = true
            };
            TrayIcon.MouseDown        += NI_MouseDown;
            TrayIcon.MouseDoubleClick += TrayIcon_MouseDoubleClick;
            var v = Assembly.GetExecutingAssembly().GetName().Version;

            TrayIcon.Text = $"TCC v{v.Major}.{v.Minor}.{v.Build}";

            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Dashboard", Command = new RelayCommand(o => Dashboard.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header = "Settings", Command = new RelayCommand(o => SettingsWindow.ShowWindow())
            });
            _contextMenu.Items.Add(new MenuItem()
            {
                Header  = "Close",
                Command = new RelayCommand(o =>
                {
                    _contextMenu.Closed += (_, __) => App.Close();
                    _contextMenu.IsOpen  = false;
                })
            });

            SettingsWindow = new SettingsWindow();

            if (SettingsHolder.UseHotkeys)
            {
                KeyboardHook.Instance.RegisterKeyboardHook();
            }

            SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
            //t = new System.Timers.Timer();
            //t.Interval = 1000;
            //t.Elapsed += (_, __) => PrintDispatcher();
            //t.Start();
        }