Пример #1
0
        //public List<CommandCombo> currentcombos = new List<CommandCombo>();
        //public Dictionary<string, List<CommandCombo>> currentcombosbycommand = new Dictionary<string, List<CommandCombo>>();
        //public List<string> _CurrentPressedKeys = new List<String>();

        KeyCombos()
        {
            config = Config.GetInstance();

            KeyNameCache.GetInstance().KeyDown += new KeyNameCache.KeyDownHandler(KeyCombos_KeyDown);
            KeyNameCache.GetInstance().KeyUp   += new KeyNameCache.KeyUpHandler(KeyCombos_KeyUp);
        }
Пример #2
0
            bool GetNewDown()
            {
                if (!KeyCombos.GetInstance().IsPressed(command))
                {
                    return(false);
                }
                List <string> allkeysforcommand = new List <string>();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (commandcombo.command == command)
                    {
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!allkeysforcommand.Contains(key))
                            {
                                allkeysforcommand.Add(key);
                            }
                        }
                    }
                }

                // check if eligible commands have any extra keys
                foreach (string key in KeyNameCache.GetInstance().keynamesdown)
                {
                    if (!allkeysforcommand.Contains(key))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Пример #3
0
        //void ContextMenuCommand(string command, bool down)
        //{
        //  if (down)
        //{
        //  OpenContextMenu();
        //MouseCache.GetInstance().OnRightMouseUp();
        //}
        //}

        void UIContextMenu_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.Button == MouseButton.SecondaryButton &&
                KeyNameCache.GetInstance().keynamesdown.Count == 1)
            {
                //MouseCache.GetInstance().OnRightMouseUp();
                OpenContextMenu();
            }
        }
Пример #4
0
        void CheckCombos()
        {
            List <string> newcombos = new List <string>();

            foreach (CommandCombo commandcombo in config.CommandCombos)
            {
                if (commandcombo.Matches(KeyNameCache.GetInstance().keynamesdown))
                {
                    if (!newcombos.Contains(commandcombo.command))
                    {
                        newcombos.Add(commandcombo.command);
                    }
                }
            }
            List <string> combosdown = new List <string>();
            List <string> combosup   = new List <string>();

            foreach (string command in newcombos)
            {
                if (!currentcommands.Contains(command))
                {
                    //LogFile.WriteLine("combo down: " + command);
                    combosdown.Add(command);
                }
            }
            foreach (string command in currentcommands)
            {
                if (!newcombos.Contains(command))
                {
                    //LogFile.WriteLine("combo up: " + command);
                    combosup.Add(command);
                }
            }
            currentcommands = newcombos;
            if (ComboUp != null)
            {
                foreach (string command in combosup)
                {
                    ComboUp(command);
                }
            }
            if (ComboDown != null)
            {
                foreach (string command in combosdown)
                {
                    ComboDown(command);
                }
            }
        }
Пример #5
0
        MainTerrainWindow()
        {
            Glade.XML app = new Glade.XML(EnvironmentHelper.GetExeDirectory() + "/TerrainEditing.glade", "mainwindow", "");
            app.Autoconnect(this);
            //raiselower.Activate();
            MetaverseClient.GetInstance().worldstorage.terrainmodel.TerrainModified += new TerrainModel.TerrainModifiedHandler(MainUIWindow_TerrainModified);
            HideWindow();

            mainwindow.Destroyed += new EventHandler(mainwindow_Destroyed);
            ViewerState.GetInstance().StateChanged += new ViewerState.StateChangedHandler(MainTerrainWindow_StateChanged);

            ContextMenuController.GetInstance().RegisterPersistentContextMenu(new string[] { "Edit Terrain..." },
                                                                              new ContextMenuHandler(EditTerrainContextMenuHandler));

            //inittime = DateTime.Now;
            //MetaverseClient.GetInstance().Tick += new MetaverseClient.TickHandler( MainTerrainWindow_Tick );
            KeyNameCache.GetInstance().KeyDown += new KeyNameCache.KeyDownHandler(MainTerrainWindow_KeyDown);
        }
Пример #6
0
            // we filter all keys out that dont match our commands
            // then we check if any commands exactly match the down keys, with no additional keys
            public override void Check()
            {
                // get allowed keys
                List <string> correspondingkeys = new List <string>();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (commands.Contains(commandcombo.command))
                    {
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!correspondingkeys.Contains(key))
                            {
                                correspondingkeys.Add(key);
                            }
                        }
                    }
                }
                // get eligible commands, must be down
                List <string> newdowncommands = new List <string>();

                foreach (string command in commands)
                {
                    if (KeyCombos.GetInstance().IsPressed(command))
                    {
                        newdowncommands.Add(command);
                    }
                }

                // build list of all possible keys for each command
                Dictionary <string, List <string> > allkeysforeachcommand = new Dictionary <string, List <string> >();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (newdowncommands.Contains(commandcombo.command))
                    {
                        if (!allkeysforeachcommand.ContainsKey(commandcombo.command))
                        {
                            allkeysforeachcommand.Add(commandcombo.command, new List <string>());
                        }
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!allkeysforeachcommand[commandcombo.command].Contains(key))
                            {
                                allkeysforeachcommand[commandcombo.command].Add(key);
                            }
                        }
                    }
                }

                // check if eligible commands have any extra keys
                foreach (string key in KeyNameCache.GetInstance().keynamesdown)
                {
                    if (correspondingkeys.Contains(key))
                    {
                        foreach (string command in allkeysforeachcommand.Keys)
                        {
                            if (!allkeysforeachcommand[command].Contains(key))
                            {
                                if (newdowncommands.Contains(command))
                                {
                                    newdowncommands.Remove(command);
                                }
                            }
                        }
                    }
                }

                foreach (string command in currentdowncommands)
                {
                    if (!newdowncommands.Contains(command))
                    {
                        //LogFile.WriteLine("Commandcombo up: " + command);
                        handler(command, false);
                    }
                }
                foreach (string command in newdowncommands)
                {
                    if (!currentdowncommands.Contains(command))
                    {
                        //LogFile.WriteLine("Commandcombo down: " + command);
                        handler(command, true);
                    }
                }
                currentdowncommands = newdowncommands;
            }