コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] ConsolePage consolePage)
        {
            if (id != consolePage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consolePage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsolePageExists(consolePage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(consolePage));
        }
コード例 #2
0
        public NetworkViewModel(Network network) : base(network)
        {
            DateTime start = DateTime.Now;

            Console.WriteLine("Starting initialization of ViewModel for Network " + network.Name);
            Network = network;
            TimeSpan t = DateTime.Now - start;

            ReadSettings();
            UpdateAddressInfo();
            Application.Current.Dispatcher.Invoke(new Action(() => EntityPage        = new NetworkPage(this)));
            Application.Current.Dispatcher.Invoke(new Action(() => ConsolePage       = new ConsolePage(this)));
            Application.Current.Dispatcher.Invoke(new Action(() => SettingsViewModel = new SettingsViewModel(this)));

            DropHandler = new ServerDropHandler(this);

            if (!ApplicationManager.Initialized)
            {
                ApplicationManager.ApplicationInitialized +=
                    () => Application.Current.Dispatcher?.Invoke(StartSettingsReader);
            }
            else
            {
                Application.Current.Dispatcher?.Invoke(StartSettingsReader);
            }

            Console.WriteLine("Server ViewModel for " + network.Name + " initialized in " + t.Seconds + "." +
                              t.Milliseconds + "s");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: MrX13415/CursorAreaLock
 private bool SwitchPage(ConsolePage <Service> _page)
 {
     if (nextPage != null)
     {
         return(false);
     }
     nextPage = _page;
     return(true);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: MrX13415/CursorAreaLock
        private void InitPages()
        {
            //** MAIN PAGE ***********************************

            HotkeyBarItem startStopKey = new HotkeyBarItem(ConsoleKey.F4, "Start / Stop", HotKeyEventHandler_StateToggle);
            HotkeyBarItem optinsKey    = new HotkeyBarItem(ConsoleKey.F6, "Options", HotKeyEventHandler_Options);
            HotkeyBarItem exitKey      = new HotkeyBarItem(ConsoleKey.F10, "Exit", HotKeyEventHandler_Exit, 3);

            HotkeyBar mainBar = new HotkeyBar(4);

            mainBar.Items.Add(startStopKey);
            mainBar.Items.Add(optinsKey);
            mainBar.Items.Add(exitKey);

            mainPage = new ConsolePage <Service>(MainPagePrintHandler, service, mainBar);

            //** OPTIONS PAGE ********************************

            HotkeyBarItem escKey1   = new HotkeyBarItem(ConsoleKey.Escape, "ESC", "Back", HotKeyEventHandler_OptionsCancel);
            HotkeyBarItem addKey    = new HotkeyBarItem(ConsoleKey.Insert, "INS", "Add", HotKeyEventHandler_ListAdd);
            HotkeyBarItem removeKey = new HotkeyBarItem(ConsoleKey.Delete, "DEL", "Remove", HotKeyEventHandler_ListRem);
            HotkeyBarItem upKey     = new HotkeyBarItem(ConsoleKey.UpArrow, "   ↑", "", HotKeyEventHandler_ListUp);
            HotkeyBarItem downKey   = new HotkeyBarItem(ConsoleKey.DownArrow, " ↓", "", HotKeyEventHandler_ListDown);
            HotkeyBarItem homeKey   = new HotkeyBarItem(ConsoleKey.Home, "HOME", "", HotKeyEventHandler_ListStart);

            homeKey.Visible = false;
            HotkeyBarItem endKey = new HotkeyBarItem(ConsoleKey.End, "END", "", HotKeyEventHandler_ListEnd);

            endKey.Visible = false;

            HotkeyBar optionsBar = new HotkeyBar(4);

            optionsBar.Items.Add(escKey1);
            optionsBar.Items.Add(addKey);
            optionsBar.Items.Add(removeKey);
            optionsBar.Items.Add(exitKey);
            optionsBar.Items.Add(upKey);
            optionsBar.Items.Add(downKey);
            optionsBar.Items.Add(homeKey);
            optionsBar.Items.Add(endKey);

            optionsPage = new ConsolePage <Service>(OptionsPagePrintHandler, service, optionsBar);

            //** ADD EXECUTABLE PAGE *************************

            HotkeyBarItem escKey2 = new HotkeyBarItem(ConsoleKey.Escape, "ESC", "Cancel", HotKeyEventHandler_CaptureModeCancel);
            HotkeyBarItem okKey   = new HotkeyBarItem(ConsoleKey.Enter, " ENTER", "Add Executable", HotKeyEventHandler_CaptureModeOK);

            HotkeyBar addExeBar = new HotkeyBar(4);

            addExeBar.Items.Add(escKey2);
            addExeBar.Items.Add(okKey);
            addExeBar.Items.Add(exitKey);

            addExePage = new ConsolePage <Service>(AddExePagePrintHandler, service, addExeBar);
        }
コード例 #5
0
        public ServerViewModel(Server server) : base(server)
        {
            if (Server == null)
            {
                throw new Exception();
            }

            DateTime start = DateTime.Now;

            Console.WriteLine("Starting initialization of ViewModel for Server " + Server.Name);
            if (Server.Version.Type == ServerVersion.VersionType.Vanilla)
            {
                Versions = VersionManager.Instance.VanillaVersions;
            }
            else if (Server.Version.Type == ServerVersion.VersionType.Paper)
            {
                Versions = VersionManager.Instance.PaperVersions;
            }
            else if (Server.Version.Type == ServerVersion.VersionType.Spigot)
            {
                Versions = VersionManager.Instance.SpigotVersions;
            }

            Application.Current.Dispatcher.Invoke(new Action(() => EntityPage  = new ServerPage(this)));
            Application.Current.Dispatcher.Invoke(new Action(() => ConsolePage = new ConsolePage(this)));
            Application.Current.Dispatcher.Invoke(new Action(() => WorldsPage  = new WorldsPage(this)));
            Application.Current.Dispatcher.Invoke(new Action(() =>
                                                             PluginsPage             = new PluginsPage(new PluginViewModel(this))));
            Application.Current.Dispatcher.Invoke(new Action(() => SettingsViewModel = new SettingsViewModel(this)));

            PlayerList.CollectionChanged += PlayerListChanged;
            WhiteList.CollectionChanged  += WhiteListChanged;
            BanList.CollectionChanged    += BanListChanged;
            OPList.CollectionChanged     += OPListChanged;

            Worlds = new ObservableCollection <World>();
            Worlds.CollectionChanged += WorldsChanged;

            InitializeLists(Server);

            if (!ApplicationManager.Initialized)
            {
                ApplicationManager.ApplicationInitialized +=
                    () => Application.Current.Dispatcher?.Invoke(StartSettingsReader);
            }
            else
            {
                Application.Current.Dispatcher?.Invoke(StartSettingsReader);
            }

            TimeSpan t = DateTime.Now - start;

            Console.WriteLine("Server ViewModel for " + Server.Name + " initialized in " + t.Seconds + "." +
                              t.Milliseconds + "s");
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,Name")] ConsolePage consolePage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(consolePage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(consolePage));
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: MrX13415/CursorAreaLock
        private void Initialize()
        {
            //setup exit event handler ...
            handler += new Kernel32.ConsoleCloseEventHandler(ConsoleCloseEvent);
            Kernel32.SetConsoleCtrlHandler(handler, true);

            //make sure we are using default colors ...
            ConsoleEx.ResetColors();

            //set console settings ...
            Console.Title         = String.Format("{0} v{1}", this.Name, this.Version);
            Console.CursorVisible = false;

            //init. console pages ...
            InitPages();

            //set default page;
            page = mainPage;

            //load service options file ...
            service.LoadFromDisk();
        }
コード例 #8
0
 public override void Awake(params object[] paralist)
 {
     m_page = UIUtility.SafeGetComponent <ConsolePage>(Transform);
     AddBtnListener();
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: MrX13415/CursorAreaLock
        private void StartMainLoop()
        {
            //*** MAIN LOOP [START] **********************************************
            while (mainLoopRunning)
            {
                //Wait a bit ...
                Thread.Sleep(10);

                //prepare for exit ...
                if (exitRequested)
                {
                    CleanUp();
                }

                //detact console window size changhes ...
                CheckConsoleWindowSize();

                //make sure the page content will fit ...
                if (ConsoleContentSizeMatching())
                {
                    //PrepareConsole console for page redprint ...
                    PrepareConsole();

                    //*** SERVICE ************************************************
                    service.Update();
                    service.ProcessService();

                    //*** PAGES **************************************************
                    page.Print();

                    //print the current available hotkeys, print "Exit" instead, if exit was requested  ...
                    if (exitRequested)
                    {
                        page.Hotkeys.Print("   Exiting ...", ConsoleColor.Yellow);
                    }
                    else
                    {
                        page.Hotkeys.Print();
                    }
                }

                //handle the current available hotkeys
                if (!exitRequested)
                {
                    page.Hotkeys.Process();
                }

                //switch safely to an other console page ...
                if (nextPage != null)
                {
                    page     = nextPage;
                    nextPage = null;
                    Console.Clear();
                }

                //exit main loop ...
                if (exitRequested && cleanedUp)
                {
                    mainLoopRunning = false;
                }
            }
            //*** MAIN LOOP [END] ************************************************
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: mkibiger/CursorAreaLock
        private void Initialize()
        {
            //setup exit event handler ...
            handler += new Kernel32.ConsoleCloseEventHandler(ConsoleCloseEvent);
            Kernel32.SetConsoleCtrlHandler(handler, true);

            //make sure we are using default colors ...
            ConsoleEx.ResetColors();

            //set console settings ...
            Console.Title = String.Format("{0} v{1}", this.Name, this.Version);
            Console.CursorVisible = false;

            //init. console pages ...
            InitPages();

            //set default page;
            page = mainPage;

            //load service options file ...
            service.LoadFromDisk();
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: mkibiger/CursorAreaLock
        private void StartMainLoop()
        {
            //*** MAIN LOOP [START] **********************************************
            while (mainLoopRunning)
            {
                //Wait a bit ...
                Thread.Sleep(10);

                //prepare for exit ...
                if (exitRequested) CleanUp();

                //detact console window size changhes ...
                CheckConsoleWindowSize();

                //make sure the page content will fit ...
                if (ConsoleContentSizeMatching())
                {
                    //PrepareConsole console for page redprint ...
                    PrepareConsole();

                    //*** SERVICE ************************************************
                    service.Update();
                    service.ProcessService();

                    //*** PAGES **************************************************
                    page.Print();

                    //print the current available hotkeys, print "Exit" instead, if exit was requested  ...
                    if (exitRequested)
                        page.Hotkeys.Print("   Exiting ...", ConsoleColor.Yellow);
                    else 
                        page.Hotkeys.Print();
                }
 
                //handle the current available hotkeys
                if (!exitRequested)
                    page.Hotkeys.Process();

                //switch safely to an other console page ...
                if (nextPage != null)
                {
                    page = nextPage;
                    nextPage = null;
                    Console.Clear();
                }

                //exit main loop ...
                if (exitRequested && cleanedUp) mainLoopRunning = false;
            }
            //*** MAIN LOOP [END] ************************************************
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: mkibiger/CursorAreaLock
 private bool SwitchPage(ConsolePage<Service> _page)
 {
     if (nextPage != null) return false;
     nextPage = _page;
     return true;
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: mkibiger/CursorAreaLock
        private void InitPages(){

            //** MAIN PAGE ***********************************
  
            HotkeyBarItem startStopKey = new HotkeyBarItem(ConsoleKey.F4, "Start / Stop", HotKeyEventHandler_StateToggle);
            HotkeyBarItem optinsKey = new HotkeyBarItem(ConsoleKey.F6, "Options", HotKeyEventHandler_Options);
            HotkeyBarItem exitKey = new HotkeyBarItem(ConsoleKey.F10, "Exit", HotKeyEventHandler_Exit, 3);

            HotkeyBar mainBar = new HotkeyBar(4);
            mainBar.Items.Add(startStopKey);
            mainBar.Items.Add(optinsKey);
            mainBar.Items.Add(exitKey);

            mainPage = new ConsolePage<Service>(MainPagePrintHandler, service, mainBar);

            //** OPTIONS PAGE ********************************

            HotkeyBarItem escKey1 = new HotkeyBarItem(ConsoleKey.Escape, "ESC", "Back", HotKeyEventHandler_OptionsCancel);
            HotkeyBarItem addKey = new HotkeyBarItem(ConsoleKey.Insert, "INS", "Add", HotKeyEventHandler_ListAdd);
            HotkeyBarItem removeKey = new HotkeyBarItem(ConsoleKey.Delete, "DEL", "Remove", HotKeyEventHandler_ListRem);
            HotkeyBarItem upKey = new HotkeyBarItem(ConsoleKey.UpArrow, "   ↑", "", HotKeyEventHandler_ListUp);
            HotkeyBarItem downKey = new HotkeyBarItem(ConsoleKey.DownArrow, " ↓", "", HotKeyEventHandler_ListDown);
            HotkeyBarItem homeKey = new HotkeyBarItem(ConsoleKey.Home, "HOME", "", HotKeyEventHandler_ListStart);
            homeKey.Visible = false;
            HotkeyBarItem endKey = new HotkeyBarItem(ConsoleKey.End, "END", "", HotKeyEventHandler_ListEnd);
            endKey.Visible = false;

            HotkeyBar optionsBar = new HotkeyBar(4);
            optionsBar.Items.Add(escKey1);
            optionsBar.Items.Add(addKey);
            optionsBar.Items.Add(removeKey);
            optionsBar.Items.Add(exitKey);
            optionsBar.Items.Add(upKey);
            optionsBar.Items.Add(downKey);
            optionsBar.Items.Add(homeKey);
            optionsBar.Items.Add(endKey);

            optionsPage = new ConsolePage<Service>(OptionsPagePrintHandler, service, optionsBar);

            //** ADD EXECUTABLE PAGE *************************

            HotkeyBarItem escKey2 = new HotkeyBarItem(ConsoleKey.Escape, "ESC", "Cancel", HotKeyEventHandler_CaptureModeCancel);
            HotkeyBarItem okKey = new HotkeyBarItem(ConsoleKey.Enter, " ENTER","Add Executable", HotKeyEventHandler_CaptureModeOK);

            HotkeyBar addExeBar = new HotkeyBar(4);
            addExeBar.Items.Add(escKey2);
            addExeBar.Items.Add(okKey);
            addExeBar.Items.Add(exitKey);

            addExePage = new ConsolePage<Service>(AddExePagePrintHandler, service, addExeBar);
        }