Exemplo n.º 1
0
 public void pressButton(FighterState.Input key, KeyMode mode)
 {
     if (mode == KeyMode.RELEASE)
     {
         if (held.Contains(key))
         {
             held.Remove(key);
         }
         if (pressed.Contains(key))
         {
             pressed.Remove(key);
         }
     }
     else if (mode == KeyMode.HOLD)
     {
         if (!held.Contains(key))
         {
             held.Add(key);
         }
         if (!pressed.Contains(key))
         {
             pressed.Add(key);
         }
     }
     else
     {
         if (!pressed.Contains(key))
         {
             pressed.Add(key);
         }
     }
 }
Exemplo n.º 2
0
 public void QueueData(KeyMode mode, ConsoleKey key)
 {
     // 0byte: mode (0: down, 1: up)
     // 1byte: KeyCode
     bytes.Add((byte)mode);
     bytes.Add((byte)key);
 }
Exemplo n.º 3
0
        void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.tag.Equals(Constants.PlayerTag))
            {
                if (_mode == KeyMode.NotConnected)
                {
                    var targetRigidbody = other.gameObject.GetComponent <Rigidbody>();
                    CreateSpringJoint(targetRigidbody);
                    _joinedPlayer = targetRigidbody.gameObject;

                    _mode = KeyMode.ConnectedToPlayer;
                    SetColor();
                }
            }
            else if (other.gameObject.tag.Equals(Constants.KeyHoleTag))
            {
                if (_mode == KeyMode.ConnectedToPlayer)
                {
                    RemoveOldJoint();

                    var targetRigidbody = other.gameObject.GetComponent <Rigidbody>();
                    CreateSpringJoint(targetRigidbody);

                    _mode = KeyMode.FlyingToDoor;
                    SetColor();
                }
            }
        }
Exemplo n.º 4
0
    public bool GetKey(KeyMode km, Key_Hub key)
    {
        if (!gameObject.activeSelf)
        {
            return(false);
        }

        bool flag = false;

        switch (km)
        {
        case KeyMode.Enter:
        {
            flag = GetEnter(key, hard);
        }
        break;

        case KeyMode.Stay:
        {
            flag = GetStay(key, hard);
        }
        break;

        case KeyMode.Exit:
        {
            flag = GetExit(key, hard);
        }
        break;
        }

        return(flag);
    }
Exemplo n.º 5
0
 public void UpdateMode(KeyMode mode)
 {
     if (onUpdateKeyMode != null)
     {
         onUpdateKeyMode(mode);
     }
 }
Exemplo n.º 6
0
        public string GetKeyString(byte[] key, KeyMode keyMode)
        {
            var sb = new StringBuilder();

            if (keyMode == KeyMode.Bytes)
            {
                foreach (var b in key)
                {
                    sb.Append(b + ", ");
                }

                return(sb.ToString().Remove(sb.ToString().Length - 2));
            }
            if (keyMode == KeyMode.Chars)
            {
                const string avlChars = "aąbcćdeęfghijklmnoópqrstuvwxyzżźAĄBCĆDEĘFGHIJKLMNOÓPQRSTUVWXYZŻŹ~!@#$%^&*()-_=+,./;\'[]<>?:\"|\\{}";
                var          enc      = new UTF8Encoding();
                var          b        = 0;

                while (enc.GetByteCount(sb.ToString()) != key.Length)
                {
                    sb.Append(avlChars[key[b++ % key.Length] % avlChars.Length]);

                    while (enc.GetByteCount(sb.ToString()) > key.Length)
                    {
                        sb.Length--;
                    }
                }

                return(sb.ToString());
            }
            throw new Exception("Incorrect way of key input. ");
        }
Exemplo n.º 7
0
Arquivo: Key2.cs Projeto: wjk17/WSA
 public Key2(Vector2 v, Vector2 inT, Vector2 outT, KeyMode inMode, KeyMode outMode)
 {
     vector       = v;
     inTan        = inT;
     outTan       = outT;
     this.inMode  = inMode;
     this.outMode = outMode;
 }
Exemplo n.º 8
0
 public override void ReadPayload(NetDataReader message)
 {
     base.ReadPayload(message);
     Key     = message.GetUInt();
     Shift   = message.GetBool();
     Control = message.GetBool();
     Alt     = message.GetBool();
     Mode    = (KeyMode)message.GetInt();
 }
Exemplo n.º 9
0
        public KeyboardBar(IKeyboardWindow _window, Range _range, KeySize _size, KeyMode _mode)
        {
            window = _window;
            mode   = _mode;
            InitializeComponent();
            setKeyboardSize(_range, _size);

            mouseKey = null;
        }
Exemplo n.º 10
0
        /// <summary>
        /// This hack allows to disable keymode when opened new window over current with pressed ctrl, alt or shift
        /// </summary>
        public void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            var title = GetActiveWindowTitle();

            if (!string.Equals(title, this.Title))
            {
                _keyMode = KeyMode.None;
                border.SetKeyMode(_keyMode);
            }
        }
Exemplo n.º 11
0
 public void Update(Keyboard keyboard, KeyMode mode)
 {
     if (FKeyboard != keyboard || FKeyMode != mode)
     {
         Unsubscribe();
         FKeyboard = keyboard;
         FKeyMode  = mode;
         Subscribe();
     }
 }
Exemplo n.º 12
0
        public static IDictionary <string, Texture2D> GetIcons(string class_name, KeyMode key_mode = KeyMode.Normal)
        {
            string label        = class_name + ".HierarchyIcon";
            var    asset_guids  = AssetDatabase.FindAssets("t:texture2D l:" + label);
            var    asset_paths  = asset_guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid));
            var    key_function = GetKeyFunction(key_mode);

            return(asset_paths.ToDictionary(
                       path => key_function(Path.GetFileName(path)),
                       path => AssetDatabase.LoadAssetAtPath <Texture2D>(path)));
        }
Exemplo n.º 13
0
        private void LoadMesh(double fieldOfView)
        {
            if ((myViewport3D != null) && (modelGroup.Children.Count > 0))
            {
                myViewport3D.Children.Remove(modelsVisual);
                modelGroup.Children.Clear();
            }

            ((PerspectiveCamera)myViewport3D.Camera).FieldOfView = fieldOfView;

            // Define the material for the model.
            SolidColorBrush brush         = new SolidColorBrush(Colors.Cyan);
            DiffuseMaterial colorMaterial = new DiffuseMaterial(brush);

            // Load the mesh for the model.
            MeshGeometry3D objMesh = (MeshGeometry3D)Application.Current.Resources[_mesh];

            objModel = new GeometryModel3D(objMesh, colorMaterial);

            // Define the projection camera and add to the model.
            SetProjectionCamera(myViewport3D, modelGroup);

            modelGroup.Children.Add(objModel);

            // Add ambient light to the model group.
            if (checkBoxAmbientLight.IsChecked == true)
            {
                myLights.ShowAmbientLight(true, modelGroup);
            }

            // Add directional lights to the model group.
            if (checkBoxDirLightOne.IsChecked == true)
            {
                myLights.ShowDirLight(0, true, modelGroup);
            }
            if (checkBoxDirLightTwo.IsChecked == true)
            {
                myLights.ShowDirLight(1, true, modelGroup);
            }

            // Add the model group data to the viewport.
            modelsVisual.Content = modelGroup;
            myViewport3D.Children.Add(modelsVisual);

            checkBoxPointLight.IsChecked = false;
            xyzPointLight.Foreground     = System.Windows.Media.Brushes.LightGray;
            currKeyMode           = KeyMode.Camera;
            rbPosition1.IsChecked = true;
        }
Exemplo n.º 14
0
        public bool Check(KeyMode mode = KeyMode.PressDown)
        {
            if (modifiers.Count == 0 && keys.Count == 0)
            {
                return(false);
            }

            return(modifiers.All(key => Input.GetKey(key)) &&
                   keys.All(key => (mode == KeyMode.Press
                                    ? Input.GetKey(key)
                                    : (mode == KeyMode.PressDown
                                        ? Input.GetKeyDown(key)
                                        : Input.GetKeyUp(key)))) &&
                   MODIFIER_LIST.Except(modifiers).All(invalidModifier => !Input.GetKey(invalidModifier)));
        }
Exemplo n.º 15
0
        private static Func <string, string> GetKeyFunction(KeyMode key_mode)
        {
            switch (key_mode)
            {
            default:
            case KeyMode.Normal:
                return(Plain);

            case KeyMode.LowerCase:
                return(ToLower);

            case KeyMode.UpperCase:
                return(ToUpper);
            }
        }
Exemplo n.º 16
0
        public HKC(string variable, string displayText, uint key, KeyMode mode, Vector2 pos, Color boxColor)
        {
            VarToCheck = variable;
            DisplayText = displayText;
            SetMode = mode;
            BoxPosition = pos;
            BoxColor = boxColor;
            Key = key;

            keyToggleT = 0;

            //Event subs
            Game.OnWndProc += HKC_WndProc;
            Drawing.OnDraw += HKC_Draw;
            Game.OnUpdate += HKC_Update;
        }
Exemplo n.º 17
0
        public HKC(string variable, string displayText, uint key, KeyMode mode, Vector2 pos, Color boxColor)
        {
            VarToCheck  = variable;
            DisplayText = displayText;
            SetMode     = mode;
            BoxPosition = pos;
            BoxColor    = boxColor;
            Key         = key;
            OrigKey     = key;

            keyToggleT = 0;

            //Event subs
            Game.OnUpdate  += HKC_Update;
            Game.OnWndProc += HKC_WndProc;
            Drawing.OnDraw += HKC_Draw;
        }
Exemplo n.º 18
0
        void picPreview_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu || e.KeyCode == Keys.ControlKey)
            {
                return;
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (mode == EditingMode.TopLeft)
                {
                    mode = EditingMode.BottomRight;
                }
                else
                {
                    mode = EditingMode.TopLeft;
                }
                return;
            }
            Point loc = rectangle.GetPoint(mode);
            int   dif = e.Control ? 10 : 1;

            if (e.KeyCode == Keys.Left)
            {
                key |= KeyMode.Left;
            }
            else if (e.KeyCode == Keys.Right)
            {
                key |= KeyMode.Right;
            }
            else if (e.KeyCode == Keys.Up)
            {
                key |= KeyMode.Up;
            }
            else if (e.KeyCode == Keys.Down)
            {
                key |= KeyMode.Down;
            }
            loc.Offset(
                (key & KeyMode.Horizontal) != 0 ? (key.HasFlag(KeyMode.Left) ? -dif : dif) : 0,
                (key & KeyMode.Vertical) != 0 ? (key.HasFlag(KeyMode.Up) ? -dif : dif) : 0);
            loc = GetVerifiedLocation(loc);
            rectangle.SetPoint(e.Shift ? EditingMode.TopLeft | EditingMode.BottomRight : mode, loc);
            picPreview.Invalidate();
        }
Exemplo n.º 19
0
 void picPreview_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Left)
     {
         key &= ~KeyMode.Left;
     }
     else if (e.KeyCode == Keys.Right)
     {
         key &= ~KeyMode.Right;
     }
     else if (e.KeyCode == Keys.Up)
     {
         key &= ~KeyMode.Up;
     }
     else if (e.KeyCode == Keys.Down)
     {
         key &= ~KeyMode.Down;
     }
 }
Exemplo n.º 20
0
        //</SnippetShow3DLights3DN8>
        private void OnPositionChecked(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;

            if (rb.Name == "rbPosition1")
            {
                currKeyMode = KeyMode.Camera;
            }

            if (rb.Name == "rbPosition2")
            {
                currKeyMode = KeyMode.PointLight;
            }

            if (myViewport3D != null)
            {
                myViewport3D.Focus();
            }
        }
Exemplo n.º 21
0
        // Add or remove a point light from the 3D viewport.
        private void OnPointLight(object sender, EventArgs e)
        {
            if (checkBoxPointLight.IsChecked == true)
            {
                currKeyMode           = KeyMode.PointLight;
                rbPosition2.IsChecked = true;
                myLights.ShowPointLight(1, true, modelGroup);
                xyzPointLight.Foreground = System.Windows.Media.Brushes.Black;
                xyzPointLight.Content    = "x: " + myLights.PointLightPosition.X + "  y: " + myLights.PointLightPosition.Y + "  z: " + myLights.PointLightPosition.Z;
            }
            else
            {
                currKeyMode           = KeyMode.Camera;
                rbPosition1.IsChecked = true;
                myLights.ShowPointLight(1, false, modelGroup);
                xyzPointLight.Foreground = System.Windows.Media.Brushes.LightGray;
            }

            myViewport3D.Focus();
        }
Exemplo n.º 22
0
            public static ElementKey FromElement(XElement elem, KeyMode mode)
            {
                if (mode == KeyMode.ItemId)
                {
                    if (elem.Attribute("id") != null)
                    {
                        return(new ElementKey(elem.Attribute("id").Value));
                    }
                    else if (elem.Attribute("idlist") != null)
                    {
                        return(new ElementKey(elem.Attribute("idlist").Value));
                    }
                    else if (elem.Attribute("where") != null)
                    {
                        return(new ElementKey(elem.Attribute("where").Value));
                    }
                    else if (elem.Element("related_id") != null)
                    {
                        var textNode = elem.Element("related_id").Nodes().OfType <XText>().FirstOrDefault();
                        if (textNode == null)
                        {
                            var item = elem.Element("related_id").Element("Item");
                            if (item != null && item.Attribute("id") != null)
                            {
                                return(new ElementKey(item.Attribute("id").Value));
                            }
                        }
                        else
                        {
                            return(new ElementKey(textNode.Value));
                        }
                    }

                    return(new ElementKey(elem.Name.LocalName + "[" + ElementIndex(elem).ToString() + "]"));
                }
                else
                {
                    var lang = elem.Attribute(XNamespace.Xml + "lang");
                    return(new ElementKey(elem.Name.LocalName + (lang == null ? "" : "[" + lang.Value + "]")));
                }
            }
Exemplo n.º 23
0
        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            Key key = (e.Key == Key.System ? e.SystemKey : e.Key);

            if (key == Key.LeftAlt ||
                key == Key.RightAlt)
            {
                _keyMode |= KeyMode.Alt;
            }
            if (key == Key.LeftShift ||
                key == Key.RightShift)
            {
                _keyMode |= KeyMode.Shift;
            }
            if (key == Key.LeftCtrl ||
                key == Key.RightCtrl)
            {
                _keyMode |= KeyMode.Ctrl;
            }
            border.SetKeyMode(_keyMode);
        }
Exemplo n.º 24
0
            internal Key(Pitch root, KeyMode keyMode)
            {
                Root    = root;
                KeyMode = keyMode;

                ActualMode = KeyMode == KeyMode.Major
                    ? Major
                    : NaturalMinor;
                Scale = new Scale(Root, ActualMode);

                var accidentals = new List <Pitch>();

                foreach (var accidental in SignatureAccidentals)
                {
                    if (Scale.ScalePitches.Contains(accidental))
                    {
                        accidentals.Add(accidental);
                    }
                }

                KeySignatureAccidentals = accidentals;
            }
Exemplo n.º 25
0
        public void pressButton(FighterState.Input key, KeyMode mode)
        {

            if (mode == KeyMode.RELEASE)
            {
                if (held.Contains(key))
                    held.Remove(key);
                if (pressed.Contains(key))
                    pressed.Remove(key);
            }
            else if (mode == KeyMode.HOLD)
            {
                if (!held.Contains(key))
                    held.Add(key);
                if (!pressed.Contains(key))
                    pressed.Add(key);
            }
            else
            {
                if (!pressed.Contains(key))
                    pressed.Add(key);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Permet à une liste de touches d'effectuer la même action enfonction d'un mode d'appui.
        /// </summary>
        /// <param name="keyCodes"></param>
        /// <param name="keyMode"></param>
        /// <returns></returns>
        public static bool MultipleKey(List <KeyCode> keyCodes, KeyMode keyMode = KeyMode.DownOnce)
        {
            if (keyCodes.Count > 0 && Input.anyKey)
            {
                foreach (KeyCode kc in keyCodes)
                {
                    switch (keyMode)
                    {
                    case KeyMode.Continuous:
                        if (Input.GetKey(kc))
                        {
                            return(true);
                        }
                        break;

                    case KeyMode.DownOnce:
                        if (Input.GetKeyDown(kc))
                        {
                            return(true);
                        }
                        break;
                    }
                }
            }
            else if (keyCodes.Count > 0 && keyMode == KeyMode.Up)
            {
                foreach (KeyCode kc in keyCodes)
                {
                    if (Input.GetKeyUp(kc))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 27
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            Console.Clear();
            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            // We don't want stdout redirected, we want it sent to the screen.
            var standardOutput = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = true
            };

            Console.SetOut(standardOutput);

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler  = null,
                BellStyle            = PSConsoleReadlineOptions.DefaultBellStyle,
                CompletionQueryItems = PSConsoleReadlineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt   = PSConsoleReadlineOptions.DefaultContinuationPrompt,
                ContinuationPromptBackgroundColor = Console.BackgroundColor,
                ContinuationPromptForegroundColor = Console.ForegroundColor,
                DingDuration                  = 1,      // Make tests virtually silent when they ding
                DingTone                      = 37,     // Make tests virtually silent when they ding
                EmphasisBackgroundColor       = Console.BackgroundColor,
                EmphasisForegroundColor       = PSConsoleReadlineOptions.DefaultEmphasisForegroundColor,
                ExtraPromptLineCount          = PSConsoleReadlineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates           = PSConsoleReadlineOptions.DefaultHistoryNoDuplicates,
                HistorySearchCaseSensitive    = PSConsoleReadlineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd = PSConsoleReadlineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount           = PSConsoleReadlineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount          = PSConsoleReadlineOptions.DefaultMaximumKillRingCount,
                ResetTokenColors              = true,
                ShowToolTips                  = PSConsoleReadlineOptions.DefaultShowToolTips,
                WordDelimiters                = PSConsoleReadlineOptions.DefaultWordDelimiters,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;

            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;

#if FALSE
            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
#endif
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] { keyHandler.Chord }, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();
            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind       = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }
Exemplo n.º 28
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            Skip.If(WindowsConsoleFixtureHelper.GetKeyboardLayout() != this.Fixture.Lang,
                    $"Keyboard layout must be set to {this.Fixture.Lang}");

            _console       = new TestConsole(_);
            _mockedMethods = new MockedMethods();
            var instance = (PSConsoleReadLine)typeof(PSConsoleReadLine)
                           .GetField("_singleton", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

            typeof(PSConsoleReadLine)
            .GetField("_mockableMethods", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(instance, _mockedMethods);
            typeof(PSConsoleReadLine)
            .GetField("_console", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(instance, _console);

            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            var options = new SetPSReadLineOption
            {
                AddToHistoryHandler           = PSConsoleReadLineOptions.DefaultAddToHistoryHandler,
                AnsiEscapeTimeout             = 0,
                BellStyle                     = PSConsoleReadLineOptions.DefaultBellStyle,
                CompletionQueryItems          = PSConsoleReadLineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt            = PSConsoleReadLineOptions.DefaultContinuationPrompt,
                DingDuration                  = 1,      // Make tests virtually silent when they ding
                DingTone                      = 37,     // Make tests virtually silent when they ding
                ExtraPromptLineCount          = PSConsoleReadLineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates           = PSConsoleReadLineOptions.DefaultHistoryNoDuplicates,
                HistorySaveStyle              = HistorySaveStyle.SaveNothing,
                HistorySearchCaseSensitive    = PSConsoleReadLineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd = PSConsoleReadLineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount           = PSConsoleReadLineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount          = PSConsoleReadLineOptions.DefaultMaximumKillRingCount,
                ShowToolTips                  = PSConsoleReadLineOptions.DefaultShowToolTips,
                WordDelimiters                = PSConsoleReadLineOptions.DefaultWordDelimiters,
                PromptText                    = new [] { "" },
                Colors = new Hashtable {
                    { "ContinuationPrompt", MakeCombinedColor(_console.ForegroundColor, _console.BackgroundColor) },
                    { "Emphasis", MakeCombinedColor(PSConsoleReadLineOptions.DefaultEmphasisColor, _console.BackgroundColor) },
                    { "Error", MakeCombinedColor(ConsoleColor.Red, ConsoleColor.DarkRed) },
                }
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;

            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;

            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] { keyHandler.Chord }, keyHandler.Handler, "", "");
            }

            var tokenTypes = new[]
            {
                "Default", "Comment", "Keyword", "String", "Operator", "Variable",
                "Command", "Parameter", "Type", "Number", "Member", "Selection",
                "InlinePrediction", "ListPrediction", "ListPredictionSelected"
            };
            var colors = new Hashtable();

            for (var i = 0; i < tokenTypes.Length; i++)
            {
                colors.Add(tokenTypes[i], MakeCombinedColor(Colors[i], BackgroundColors[i]));
            }
            var colorOptions = new SetPSReadLineOption {
                Colors = colors
            };

            PSConsoleReadLine.SetOptions(colorOptions);
        }
Exemplo n.º 29
0
 private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
 {
     TestSetup(console: null, keyMode, keyHandlers);
 }
Exemplo n.º 30
0
 public XmlKeyStroke(string strokeString, KeyMode mode = KeyMode.PressUp)
 {
     CheckMode = mode;
     Keys      = strokeString;
 }
Exemplo n.º 31
0
		void picPreview_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu || e.KeyCode == Keys.ControlKey)
				return;
			else if (e.KeyCode == Keys.Enter)
			{
				if (mode == EditingMode.TopLeft)
					mode = EditingMode.BottomRight;
				else
					mode = EditingMode.TopLeft;
				return;
			}
			Point loc = rectangle.GetPoint(mode);
			int dif = e.Control ? 10 : 1;
			if (e.KeyCode == Keys.Left)
				key |= KeyMode.Left;
			else if (e.KeyCode == Keys.Right)
				key |= KeyMode.Right;
			else if (e.KeyCode == Keys.Up)
				key |= KeyMode.Up;
			else if (e.KeyCode == Keys.Down)
				key |= KeyMode.Down;
			loc.Offset(
				(key & KeyMode.Horizontal) != 0 ? (key.HasFlag(KeyMode.Left) ? -dif : dif) : 0,
				(key & KeyMode.Vertical) != 0 ? (key.HasFlag(KeyMode.Up) ? -dif : dif) : 0);
			loc = GetVerifiedLocation(loc);
			rectangle.SetPoint(e.Shift ? EditingMode.TopLeft | EditingMode.BottomRight : mode, loc);
			picPreview.Invalidate();
		}
Exemplo n.º 32
0
        private void LoadMesh(double fieldOfView)
        {
            if ((myViewport3D != null) && (modelGroup.Children.Count > 0))
            {
                myViewport3D.Children.Remove(modelsVisual);
                modelGroup.Children.Clear();
            }

            ((PerspectiveCamera)myViewport3D.Camera).FieldOfView = fieldOfView;

            // Define the material for the model.
            SolidColorBrush brush = new SolidColorBrush(Colors.Cyan);
            DiffuseMaterial colorMaterial = new DiffuseMaterial(brush);

            // Load the mesh for the model.
            MeshGeometry3D objMesh = (MeshGeometry3D)Application.Current.Resources[_mesh];
            objModel = new GeometryModel3D(objMesh, colorMaterial);

            // Define the projection camera and add to the model.
            SetProjectionCamera(myViewport3D, modelGroup);

            modelGroup.Children.Add(objModel);

            // Add ambient light to the model group.
            if (checkBoxAmbientLight.IsChecked == true)
            {
                myLights.ShowAmbientLight(true, modelGroup);
            }

            // Add directional lights to the model group.
            if (checkBoxDirLightOne.IsChecked == true)
            {
                myLights.ShowDirLight(0, true, modelGroup);
            }
            if (checkBoxDirLightTwo.IsChecked == true)
            {
                myLights.ShowDirLight(1, true, modelGroup);
            }

            // Add the model group data to the viewport.
            modelsVisual.Content = modelGroup;
            myViewport3D.Children.Add(modelsVisual);

            checkBoxPointLight.IsChecked = false;
            xyzPointLight.Foreground = System.Windows.Media.Brushes.LightGray;
            currKeyMode = KeyMode.Camera;
            rbPosition1.IsChecked = true;
        }
Exemplo n.º 33
0
        // Add or remove a point light from the 3D viewport.
        private void OnPointLight(object sender, EventArgs e)
        {
            if (checkBoxPointLight.IsChecked == true)
            {
                currKeyMode = KeyMode.PointLight;
                rbPosition2.IsChecked = true;
                myLights.ShowPointLight(1, true, modelGroup);
                xyzPointLight.Foreground = System.Windows.Media.Brushes.Black;
                xyzPointLight.Content = "x: " + myLights.PointLightPosition.X + "  y: " + myLights.PointLightPosition.Y + "  z: " + myLights.PointLightPosition.Z;
            }
            else
            {
                currKeyMode = KeyMode.Camera;
                rbPosition1.IsChecked = true;
                myLights.ShowPointLight(1, false, modelGroup);
                xyzPointLight.Foreground = System.Windows.Media.Brushes.LightGray;
            }

            myViewport3D.Focus();
        }
Exemplo n.º 34
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            ClearScreen();
            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler         = null,
                HistoryNoDuplicates         = PSConsoleReadLine.DefaultHistoryNoDuplicates,
                MinimumHistoryCommandLength = PSConsoleReadLine.DefaultMinimumHistoryCommandLength,
                MaximumHistoryCount         = PSConsoleReadLine.DefaultMaximumHistoryCount,
                MaximumKillRingCount        = PSConsoleReadLine.DefaultMaximumKillRingCount,
                ResetTokenColors            = true,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;
            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;
            #if FALSE
            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            #endif
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(keyHandler.Key, false, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();
            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }
        protected override void OnSceneGUI()
        {
            {
                Rect rArea = new Rect(0, 0, 500, 100);
                Handles.BeginGUI();
                GUILayout.BeginArea(rArea);
                //if (GUILayout.Button("Reset Area"))
                //    Debug.Log("test");
                GUILayout.Box("Please choose key mode and then press space to add keys for selected points");
                GUILayout.Box((keyMode == KeyMode.COLOR_KEY ? "->" :"") +"mode: Color key");
                GUILayout.Box((keyMode == KeyMode.XY_KEY ? "->" : "") + "mode: X Y key");
                GUILayout.Box((keyMode == KeyMode.Z_KEY ? "->" : "") + "mode: Z key");
                GUILayout.EndArea();
                Handles.EndGUI();
            }
            bool dontBase = false;
            if (Event.current.type == EventType.mouseDown)
            {
                if ((new Rect(0, 25, 90, 25).Contains(Event.current.mousePosition)))
                {
                    keyMode = KeyMode.COLOR_KEY;
                    dontBase = true;
                   
                }
                else if ((new Rect(0, 50, 90, 25).Contains(Event.current.mousePosition)))
                {
                    keyMode = KeyMode.XY_KEY;
                    dontBase = true;
                }
                else if ((new Rect(0, 75, 90, 25).Contains(Event.current.mousePosition)))
                {
                    keyMode = KeyMode.Z_KEY;
                    dontBase = true;
                }
            }
            if (!dontBase) base.OnSceneGUI();
            if (Event.current.keyCode == KeyCode.Space && Event.current.type == EventType.keyDown && !isSpace)
            { 
                if(keyMode == KeyMode.COLOR_KEY)
                {
                    setColorKeyStart();
                }
                if (keyMode == KeyMode.XY_KEY)
                {
                    setPointKeyStart(true, true, false);
                }
                if (keyMode == KeyMode.Z_KEY)
                {
                    setPointKeyStart(false, false, true);
                }
                isSpace = true;
            }
            if (Event.current.keyCode == KeyCode.Space && Event.current.type == EventType.keyUp)
            {
                isSpace = false;
                if (keyMode == KeyMode.COLOR_KEY)
                {
                    setColorKeyEnd();
                }
                if (keyMode == KeyMode.XY_KEY)
                {
                    setPointKeyEnd(true, true, false);
                }
                if (keyMode == KeyMode.Z_KEY)
                {
                    setPointKeyEnd(false, false, true);
                }

            }
        }
Exemplo n.º 36
0
		void picPreview_KeyUp(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Left)
				key &= ~KeyMode.Left;
			else if (e.KeyCode == Keys.Right)
				key &= ~KeyMode.Right;
			else if (e.KeyCode == Keys.Up)
				key &= ~KeyMode.Up;
			else if (e.KeyCode == Keys.Down)
				key &= ~KeyMode.Down;
		}
        protected override void OnSceneGUI()
        {
            bool dontBase = false;

            if (spriteDeformer.editorProps.mainToolBar == MainToolBarInspector.EDIT_VERTICS)
            {
                {
                    Rect rArea = new Rect(0, 0, 500, 100);
                    Handles.BeginGUI();
                    GUILayout.BeginArea(rArea);
                    //if (GUILayout.Button("Reset Area"))
                    //    Debug.Log("test");
                    GUILayout.Box("Please choose key mode and then press space to add keys for selected points");
                    GUILayout.Box((keyMode == KeyMode.COLOR_KEY ? "->" : "") + "mode: Color key");
                    GUILayout.Box((keyMode == KeyMode.XY_KEY ? "->" : "") + "mode: X Y key");
                    GUILayout.Box((keyMode == KeyMode.Z_KEY ? "->" : "") + "mode: Z key");
                    GUILayout.EndArea();
                    Handles.EndGUI();
                }
                if (Event.current.type == EventType.mouseDown)
                {
                    if ((new Rect(0, 25, 90, 25).Contains(Event.current.mousePosition)))
                    {
                        keyMode  = KeyMode.COLOR_KEY;
                        dontBase = true;
                    }
                    else if ((new Rect(0, 50, 90, 25).Contains(Event.current.mousePosition)))
                    {
                        keyMode  = KeyMode.XY_KEY;
                        dontBase = true;
                    }
                    else if ((new Rect(0, 75, 90, 25).Contains(Event.current.mousePosition)))
                    {
                        keyMode  = KeyMode.Z_KEY;
                        dontBase = true;
                    }
                }
            }
            if (!dontBase)
            {
                base.OnSceneGUI();
            }
            if (Event.current.keyCode == KeyCode.Space && Event.current.type == EventType.keyDown && !isSpace)
            {
                if (keyMode == KeyMode.COLOR_KEY)
                {
                    setColorKeyStart();
                }
                if (keyMode == KeyMode.XY_KEY)
                {
                    setPointKeyStart(true, true, false);
                }
                if (keyMode == KeyMode.Z_KEY)
                {
                    setPointKeyStart(false, false, true);
                }
                isSpace = true;
            }
            if (Event.current.keyCode == KeyCode.Space && Event.current.type == EventType.keyUp)
            {
                isSpace = false;
                if (keyMode == KeyMode.COLOR_KEY)
                {
                    setColorKeyEnd();
                }
                if (keyMode == KeyMode.XY_KEY)
                {
                    setPointKeyEnd(true, true, false);
                }
                if (keyMode == KeyMode.Z_KEY)
                {
                    setPointKeyEnd(false, false, true);
                }
            }
        }
Exemplo n.º 38
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            _console       = new TestConsole();
            _mockedMethods = new MockedMethods();
            var instance = (PSConsoleReadLine)typeof(PSConsoleReadLine)
                           .GetField("_singleton", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

            typeof(PSConsoleReadLine)
            .GetField("_mockableMethods", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(instance, _mockedMethods);
            typeof(PSConsoleReadLine)
            .GetField("_console", BindingFlags.Instance | BindingFlags.NonPublic)
            .SetValue(instance, _console);

            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler  = null,
                BellStyle            = PSConsoleReadlineOptions.DefaultBellStyle,
                CompletionQueryItems = PSConsoleReadlineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt   = PSConsoleReadlineOptions.DefaultContinuationPrompt,
                ContinuationPromptBackgroundColor = _console.BackgroundColor,
                ContinuationPromptForegroundColor = _console.ForegroundColor,
                DingDuration                  = 1,      // Make tests virtually silent when they ding
                DingTone                      = 37,     // Make tests virtually silent when they ding
                EmphasisBackgroundColor       = _console.BackgroundColor,
                EmphasisForegroundColor       = PSConsoleReadlineOptions.DefaultEmphasisForegroundColor,
                ErrorBackgroundColor          = ConsoleColor.DarkRed,
                ErrorForegroundColor          = ConsoleColor.Red,
                ExtraPromptLineCount          = PSConsoleReadlineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates           = PSConsoleReadlineOptions.DefaultHistoryNoDuplicates,
                HistorySaveStyle              = HistorySaveStyle.SaveNothing,
                HistorySearchCaseSensitive    = PSConsoleReadlineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd = PSConsoleReadlineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount           = PSConsoleReadlineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount          = PSConsoleReadlineOptions.DefaultMaximumKillRingCount,
                ResetTokenColors              = true,
                ShowToolTips                  = PSConsoleReadlineOptions.DefaultShowToolTips,
                WordDelimiters                = PSConsoleReadlineOptions.DefaultWordDelimiters,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;

            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;

            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] { keyHandler.Chord }, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();

            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind       = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }
Exemplo n.º 39
0
 internal void OnDestroy( KeyMode k )
 {
     foreach( Layout l in _layouts.Values )
     {
         l.DestroyConfig( k, true );
     }
 }
Exemplo n.º 40
0
        private void OnPositionChecked(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;

            if (rb.Name == "rbPosition1")
            {
                currKeyMode = KeyMode.Camera;
            }

            if (rb.Name == "rbPosition2")
            {
                currKeyMode = KeyMode.PointLight;
            }

            if (myViewport3D != null)
            {
                myViewport3D.Focus();
            }
        }
Exemplo n.º 41
0
		public Key(KeyMode mode, int fifths)
		{
			Mode = mode;
			Fifths = fifths;
		}
Exemplo n.º 42
0
      public static ElementKey FromElement(XElement elem, KeyMode mode)
      {
        if (mode == KeyMode.ItemId)
        {
          if (elem.Attribute("id") != null)
          {
            return new ElementKey(elem.Attribute("id").Value);
          }
          else if (elem.Attribute("idlist") != null)
          {
            return new ElementKey(elem.Attribute("idlist").Value);
          }
          else if (elem.Attribute("where") != null)
          {
            return new ElementKey(elem.Attribute("where").Value);
          }
          else if (elem.Element("related_id") != null)
          {
            var textNode = elem.Element("related_id").Nodes().OfType<XText>().FirstOrDefault();
            if (textNode == null)
            {
              var item = elem.Element("related_id").Element("Item");
              if (item != null && item.Attribute("id") != null)
                return new ElementKey(item.Attribute("id").Value);
            }
            else
            {
              return new ElementKey(textNode.Value);
            }
          }

          return new ElementKey(elem.Name.LocalName + "[" + ElementIndex(elem).ToString() + "]");
        }
        else
        {
          var lang = elem.Attribute(XNamespace.Xml + "lang");
          return new ElementKey(elem.Name.LocalName + (lang == null ? "" : "[" + lang.Value + "]"));
        }
      }
Exemplo n.º 43
0
        private void TestSetup(KeyMode keyMode, params KeyHandler[] keyHandlers)
        {
            Console.Clear();
            PSConsoleReadLine.ClearHistory();
            PSConsoleReadLine.ClearKillRing();

            // We don't want stdout redirected, we want it sent to the screen.
            var standardOutput = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = true};
            Console.SetOut(standardOutput);

            var options = new SetPSReadlineOption
            {
                AddToHistoryHandler               = null,
                BellStyle                         = PSConsoleReadlineOptions.DefaultBellStyle,
                CompletionQueryItems              = PSConsoleReadlineOptions.DefaultCompletionQueryItems,
                ContinuationPrompt                = PSConsoleReadlineOptions.DefaultContinuationPrompt,
                ContinuationPromptBackgroundColor = Console.BackgroundColor,
                ContinuationPromptForegroundColor = Console.ForegroundColor,
                DingDuration                      = 1,  // Make tests virtually silent when they ding
                DingTone                          = 37, // Make tests virtually silent when they ding
                EmphasisBackgroundColor           = Console.BackgroundColor,
                EmphasisForegroundColor           = PSConsoleReadlineOptions.DefaultEmphasisForegroundColor,
                ExtraPromptLineCount              = PSConsoleReadlineOptions.DefaultExtraPromptLineCount,
                HistoryNoDuplicates               = PSConsoleReadlineOptions.DefaultHistoryNoDuplicates,
                HistorySaveStyle                  = HistorySaveStyle.SaveNothing,
                HistorySearchCaseSensitive        = PSConsoleReadlineOptions.DefaultHistorySearchCaseSensitive,
                HistorySearchCursorMovesToEnd     = PSConsoleReadlineOptions.DefaultHistorySearchCursorMovesToEnd,
                MaximumHistoryCount               = PSConsoleReadlineOptions.DefaultMaximumHistoryCount,
                MaximumKillRingCount              = PSConsoleReadlineOptions.DefaultMaximumKillRingCount,
                ResetTokenColors                  = true,
                ShowToolTips                      = PSConsoleReadlineOptions.DefaultShowToolTips,
                WordDelimiters                    = PSConsoleReadlineOptions.DefaultWordDelimiters,
            };

            switch (keyMode)
            {
            case KeyMode.Cmd:
                options.EditMode = EditMode.Windows;
                break;
            case KeyMode.Emacs:
                options.EditMode = EditMode.Emacs;
                break;
            #if FALSE
            case KeyMode.Vi:
                options.EditMode = EditMode.Vi;
                break;
            #endif
            }

            PSConsoleReadLine.SetOptions(options);

            foreach (var keyHandler in keyHandlers)
            {
                PSConsoleReadLine.SetKeyHandler(new [] {keyHandler.Chord}, keyHandler.Handler, "", "");
            }

            var colorOptions = new SetPSReadlineOption();
            foreach (var val in typeof(TokenClassification).GetEnumValues())
            {
                colorOptions.TokenKind = (TokenClassification)val;
                colorOptions.ForegroundColor = ForegroundColors[(int)val];
                colorOptions.BackgroundColor = BackgroundColors[(int)val];
                PSConsoleReadLine.SetOptions(colorOptions);
            }
        }
Exemplo n.º 44
0
        /// <summary>
        ///   Loads the given mode data into this <see cref="ChannelModesCreator" />
        /// </summary>
        public void Parse(string modeChanges, IList<string> modeArguments)
        {
            if (string.IsNullOrEmpty(modeChanges))
            {
                return;
            }
            if (modeArguments == null)
            {
                modeArguments = new List<string>();
            }

            this._modes.Clear();
            var currentAction = ModeAction.Add;
            int argIndex = 0;
            foreach (char c in modeChanges)
            {
                switch (c)
                {
                    case '+':
                        currentAction = ModeAction.Add;
                        break;
                    case '-':
                        currentAction = ModeAction.Remove;
                        break;

                        // PONDER This probably won't correctly parse incorrect mode messages, should I?
                    case 'a':
                        this._modes.Add(new AnonymousMode(currentAction));
                        break;
                    case 'b':
                        var banMode = new BanMode(currentAction, new User(modeArguments[argIndex]));
                        argIndex++;
                        this._modes.Add(banMode);
                        break;
                    case 'e':
                        var banExceptionMode = new BanExceptionMode(currentAction, new User(modeArguments[argIndex]));
                        argIndex++;
                        this._modes.Add(banExceptionMode);
                        break;
                    case 'h':
                        var halfOpMode = new HalfOpMode(currentAction, modeArguments[argIndex]);
                        argIndex++;
                        this._modes.Add(halfOpMode);
                        break;
                    case 'I':
                        var invitationExceptionMode = new InvitationExceptionMode(currentAction, new User(modeArguments[argIndex]));
                        argIndex++;
                        this._modes.Add(invitationExceptionMode);
                        break;
                    case 'i':
                        var inviteOnlyMode = new InviteOnlyMode(currentAction);
                        this._modes.Add(inviteOnlyMode);
                        break;
                    case 'k':
                        var keyMode = new KeyMode(currentAction);
                        if (currentAction == ModeAction.Add)
                        {
                            keyMode.Password = modeArguments[argIndex];
                            argIndex++;
                        }
                        this._modes.Add(keyMode);
                        break;
                    case 'l':
                        var limitMode = new LimitMode(currentAction);
                        if (currentAction == ModeAction.Add)
                        {
                            limitMode.UserLimit = Convert.ToInt32(modeArguments[argIndex], CultureInfo.InvariantCulture);
                            argIndex++;
                        }
                        this._modes.Add(limitMode);
                        break;
                    case 'm':
                        this._modes.Add(new ModeratedMode(currentAction));
                        break;
                    case 'n':
                        this._modes.Add(new NoOutsideMessagesMode(currentAction));
                        break;
                    case 'O':
                        var creatorMode = new CreatorMode(currentAction, modeArguments[argIndex]);
                        argIndex++;
                        this._modes.Add(creatorMode);
                        break;
                    case 'o':
                        var operatorMode = new OperatorMode(currentAction, modeArguments[argIndex]);
                        argIndex++;
                        this._modes.Add(operatorMode);
                        break;
                    case 'p':
                        this._modes.Add(new PrivateMode(currentAction));
                        break;
                    case 'q':
                        this._modes.Add(new QuietMode(currentAction));
                        break;
                    case 's':
                        this._modes.Add(new SecretMode(currentAction));
                        break;
                    case 'r':
                        this._modes.Add(new ServerReopMode(currentAction));
                        break;
                    case 'R':
                        this._modes.Add(new RegisteredNicksOnlyMode(currentAction));
                        break;
                    case 't':
                        this._modes.Add(new TopicGuardedMode(currentAction));
                        break;
                    case 'v':
                        var voiceMode = new VoiceMode(currentAction, modeArguments[argIndex]);
                        argIndex++;
                        this._modes.Add(voiceMode);
                        break;
                    default:
                        string unknownMode = c.ToString(CultureInfo.InvariantCulture);
                        if (this._serverSupports.ModesWithParameters.Contains(unknownMode) || (this._serverSupports.ModesWithParametersWhenSet.Contains(unknownMode) && currentAction == ModeAction.Add))
                        {
                            // I want to yank a parameter
                            this._modes.Add(new UnknownChannelMode(currentAction, unknownMode, modeArguments[argIndex]));
                            argIndex++;
                        }
                        else
                        {
                            // I don't
                            this._modes.Add(new UnknownChannelMode(currentAction, unknownMode));
                        }
                        break;
                }
            }
            this.CollapseModes();
        }