Ejemplo n.º 1
0
        public void RegisterKeyInput(InputStyle style, KeyCode up, KeyCode down)
        {
            KeyHandler handler = new KeyHandler(style, up, down);

            inputEnableDicts[style] = true;
            handlerList.Add(handler);
        }
Ejemplo n.º 2
0
        protected IIonReader ReaderFromFile(FileInfo file, InputStyle style)
        {
            _stream?.Dispose();
            switch (style)
            {
            case InputStyle.MemoryStream:
                var bytes = File.ReadAllBytes(file.FullName);
                _stream = new MemoryStream(bytes);
                return(IonReaderBuilder.Build(_stream));

            case InputStyle.FileStream:
                _stream = file.OpenRead();
                return(IonReaderBuilder.Build(_stream));

            case InputStyle.Text:
                var str = File.ReadAllText(file.FullName, Encoding.UTF8);
                return(IonReaderBuilder.Build(str));

            case InputStyle.NoSeekStream:
                var b = File.ReadAllBytes(file.FullName);
                _stream = new NoSeekMemStream(b);
                return(IonReaderBuilder.Build(_stream));

            default:
                throw new ArgumentOutOfRangeException(nameof(style), style, null);
            }
        }
Ejemplo n.º 3
0
        public void Decimal64BitBoundary(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(18446744073709551615m, reader.DecimalValue().ToDecimal());

                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(-18446744073709551615.0m, reader.DecimalValue().ToDecimal());

                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(18446744073709551616.0m, reader.DecimalValue().ToDecimal());

                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(-18446744073709551616.0m, reader.DecimalValue().ToDecimal());
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteDecimal(18446744073709551615m);
                writer.WriteDecimal(-18446744073709551615m);
                writer.WriteDecimal(18446744073709551616m);
                writer.WriteDecimal(-18446744073709551616m);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/decimal64BitBoundary.ion");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 4
0
        private void ToggleInputStyle(InputStyle style)
        {
            var controller = (PlayerController)playerPaddle.GetController();
            var enable     = controller.GetEnableInputStyle(style);

            controller.EnableInputStyle(style, !enable);
        }
Ejemplo n.º 5
0
        public void RegisterMouseInput(InputStyle style, string axis)
        {
            MouseHandler handler = new MouseHandler(style, axis);

            inputEnableDicts[style] = true;
            handlerList.Add(handler);
        }
Ejemplo n.º 6
0
 public void SetInitalValues(string keyName, float timeUp, float timeDown, InputStyle inputStyle, KeyCode key)
 {
     KeyName    = keyName;
     TimeDown   = timeDown;
     TimeUp     = timeUp;
     InputStyle = inputStyle;
     Key        = key;
 }
Ejemplo n.º 7
0
 public Play(int inputLayerSize, int OutPutLayerSize, int[] LayersSize, double learningRate, InputStyle IS, int PCAout, int NofIteration, double PCAlearningRate)
 {
     this.PCAout = PCAout;
     this.PCAlearningRate = PCAlearningRate;
     this.NofIteration = NofIteration;
     NW = new NetWork(inputLayerSize, OutPutLayerSize, LayersSize,learningRate,IS);
     RI = new ReadImages();
 }
Ejemplo n.º 8
0
        public void EnableInputStyle(InputStyle style, bool enable)
        {
            if (inputEnableDicts.ContainsKey(style))
            {
                inputEnableDicts[style] = enable;
            }

            Debug.LogWarning("No Input Style: " + style + "in this controller");
        }
Ejemplo n.º 9
0
        public bool GetEnableInputStyle(InputStyle style)
        {
            if (inputEnableDicts.ContainsKey(style))
            {
                return(inputEnableDicts[style]);
            }

            Debug.LogWarning("No Input Style: " + style + "in this controller");
            return(false);
        }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        UIH = GameObject.FindGameObjectWithTag("UIHandler").GetComponent <UIHandler>();
        GM  = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();

        inputStyle  = this.gameObject.GetComponent <InputStyle>();
        inputNormal = this.gameObject.GetComponent <InputNormal>();

        // TODO change to Normal Mode at first
        // Initiall set our input mode to Selection
        inputMode = Mode.Style;
    }
Ejemplo n.º 11
0
 protected override void OnInitialized()
 {
     InputType  = InputType.OrDefault(GetInputType());
     Id         = string.IsNullOrWhiteSpace(Id) ? Guid.NewGuid().ToString().Substring(0, 10) : Id;
     Name       = string.IsNullOrWhiteSpace(Name) ? Id : Name;
     GroupClass = GroupClass.OrDefault(Class).OrDefault("form-group");
     InputClass = InputClass.OrDefault(Class).OrDefault("form-control");
     LabelClass = LabelClass.OrDefault(Class);
     GroupStyle = GroupStyle.OrDefault(Style);
     InputStyle = InputStyle.OrDefault(Style);
     LabelStyle = LabelStyle.OrDefault(Style);
 }
Ejemplo n.º 12
0
        public override void LoadContent()
        {
            ChatLines = new List <ChatMessage>();

            WithZoom(zoom, (b) =>
            {
                // Chat input style
                InputStyle style         = new InputStyle();
                style.Texture            = Primitives.Rectangle(1, 1, Color.Transparent);
                style.Font               = Content.Load <SpriteFont>("fonts/goldfish_font");
                style.TextMaxWidth       = Settings.GameWindowWidth - (int)(7 * b + 4 * b + 7 * b);
                style.RecSources         = new RecSourceCollection();
                style.RecSources.Sources = new List <Rectangle>()
                {
                    new Rectangle(0, 0, style.TextMaxWidth, (int)(13 * b)),
                    new Rectangle(0, 0, style.TextMaxWidth, (int)(13 * b))
                };
                style.FontPosition  = new Vector2(4, 4 * b);
                style.StripPosition = new Vector2(4, 4 * b);
                style.StripTexture  = Primitives.Rectangle(3, 9, Color.White);
                // Char input
                _inputChat       = new Input(style, SpriteBatch);
                _inputChat.Color = Color.White;
                // Chat font
                _chatLinesFont           = new Font(style.Font, SpriteBatch);
                _chatLinesFont.UpperCase = false;
                // Open socket connection
                Settings.Socket.Connection.Open();
                // Add initial message
                ChatLines.Add(new ChatMessage()
                {
                    Text = "Attempting to join lobby chat...", Color = Color.IndianRed
                });
                // Initial message to get bounding
                _chatLinesFont.Text = ChatLines[0].Text;
                // Counter to safety time
                _counterConnecting = new Counter()
                {
                    EndTime = 2000
                };
                _counterConnecting.Finished += (s, e) => ChatLines.Insert(0, new ChatMessage()
                {
                    Text = "The game is trying to connect to the server has been 5 seconds...", Color = Color.IndianRed
                });
                Adjust(b);
            });
        }
Ejemplo n.º 13
0
 public Input(InputStyle style, SpriteBatch spriteBatch) : base(style, spriteBatch)
 {
     Style           = style;
     RectangleSource = style.RecSources.Get(0);
     // We have to do this to change focus status and strip
     Activated  += (s, e) => { Focused = true; ResetStrip(true); };
     StripSprite = new Sprite(style.StripTexture, SpriteBatch);
     Font        = new Font(style.Font, SpriteBatch);
     // We have lowercase here too
     Font.UpperCase  = false;
     Color           = Color.Black;
     _stripInterval  = 500;
     _bufferInterval = 100;
     _buffers        = new List <KeyBuffer>();
     Text            = string.Empty;
     Type            = InputType.Text;
 }
Ejemplo n.º 14
0
        public static List <InputStyle> GetInputStyles(SiteInfo siteInfo, ChannelInfo channelInfo)
        {
            var items = new List <InputStyle>();

            var styleInfoList = ContentUtility.GetAllTableStyleInfoList(TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo));

            foreach (var styleInfo in styleInfoList)
            {
                var listitem = new InputStyle
                {
                    DisplayName   = styleInfo.DisplayName,
                    AttributeName = styleInfo.AttributeName
                };
                items.Add(listitem);
            }

            return(items);
        }
Ejemplo n.º 15
0
        public void Float_values(InputStyle inputStyle)
        {
            var file = DirStructure.IonTestFile("good/float_values.ion");
            var nums = new List <double>();

            using (var fileStream = file.OpenRead())
            {
                using (var streamReader = new StreamReader(fileStream))
                {
                    string line;
                    while ((line = streamReader.ReadLine()) != null)
                    {
                        nums.Add(double.Parse(line));
                    }
                }
            }

            void assertReader(IIonReader reader)
            {
                foreach (var num in nums)
                {
                    var type = reader.MoveNext();
                    Assert.AreEqual(IonType.Float, type);
                    Assert.AreEqual(num, reader.DoubleValue());
                }
            }

            void writerFunc(IIonWriter writer)
            {
                foreach (var num in nums)
                {
                    writer.WriteFloat(num);
                }

                writer.Finish();
            }

            var r = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 16
0
        public void NullBoolBinary(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Bool, reader.MoveNext());
                Assert.IsTrue(reader.CurrentIsNull);
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteNull(IonType.Bool);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/nullBool.10n");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 17
0
        public void DecimalWithTerminatingEof(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(1.23m, reader.DecimalValue().ToDecimal());
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteDecimal(1.23m);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/decimalWithTerminatingEof.ion");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 18
0
        public void DecimalNegativeOneDotTwoEight(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Decimal, reader.MoveNext());
                Assert.AreEqual(-1.28m, reader.DecimalValue().ToDecimal());
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteDecimal(-1.28m);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/decimalNegativeOneDotTwoEight.ion");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 19
0
 public InputStyle IS;// define the way you get input from PCA or from Images !
 public NetWork(int InputLayerSize, int OutPutLayerSize, int[] HiddenLayersSize, double LearningRate,InputStyle IS)
 {
     // Construction of network ! input Layers ! Hidden Layers ! output Layers
     this.IS = IS;
     Target = new Desired(OutPutLayerSize);
     this.LearningRate = LearningRate;
     Target.Creat();// Create Desired output for each class;
     NoOfHiddenLayers = HiddenLayersSize.Length;
     InputLayer = new Neuron[InputLayerSize];
     OutputLayer = new Neuron[OutPutLayerSize];
     HiddenLayers = new Neuron[NoOfHiddenLayers][];
     // intilize Size of hidden layers;
     for (int j = 0; j < NoOfHiddenLayers; j++)
     {
         HiddenLayers[j] = new Neuron[HiddenLayersSize[j]];
     }
     // initlize Input Layer With Objects To be Trained;
     for (int j = 0; j < InputLayerSize; j++)
     {
         InputLayer[j] = new Neuron(HiddenLayers[0].Length);
     }
     // initlize outPut Layer with objects;
     for (int j = 0; j < OutPutLayerSize; j++)
     {
         OutputLayer[j] = new Neuron();
     }
     // intilize Hidden layers with objects except last one because it depends on outputlayer;
     for (int j = 0; j < NoOfHiddenLayers - 1; j++)
     {
         for (int i = 0; i < HiddenLayersSize[j]; i++)
         {
             HiddenLayers[j][i] = new Neuron(HiddenLayersSize[j + 1]);
         }
     }
     // intilize last Layer in network with objects
     for (int j = 0; j < HiddenLayersSize[NoOfHiddenLayers - 1]; j++)
     {
         HiddenLayers[NoOfHiddenLayers - 1][j] = new Neuron(OutPutLayerSize);
     }
 }
Ejemplo n.º 20
0
        public void HexWithTerminatingEof(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Int, reader.MoveNext());
                Assert.AreEqual(3, reader.IntValue());
                Assert.AreEqual(IonType.None, reader.MoveNext());
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteInt(3);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/hexWithTerminatingEof.ion");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
Ejemplo n.º 21
0
        public void BooleanText(InputStyle inputStyle)
        {
            void assertReader(IIonReader reader)
            {
                Assert.AreEqual(IonType.Bool, reader.MoveNext());
                Assert.AreEqual(true, reader.BoolValue());
                Assert.AreEqual(IonType.Bool, reader.MoveNext());
                Assert.AreEqual(false, reader.BoolValue());
            }

            void writerFunc(IIonWriter writer)
            {
                writer.WriteBool(true);
                writer.WriteBool(false);
                writer.Finish();
            }

            var file = DirStructure.IonTestFile("good/booleans.ion");
            var r    = ReaderFromFile(file, inputStyle);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
        public OneLineTextInputDialog(
            Window parent, String caption, String initialValue,
            Func <String, String?> validator,
            Func <String, Task <String?> > onOk,
            InputStyle inputRestriction = InputStyle.None
            )
        {
            this.Owner = parent;
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.SourceInitialized    += (x, y) => this.HideMinimizeAndMaximizeButtons();

            this.initialValue = initialValue;
            this.validator    = validator;

            InitializeComponent();

            switch (inputRestriction)
            {
            default:
                break;

            case InputStyle.RoomUrl:

                // タッチキーボードの文字種を変更する
                var scope = new InputScope();
                scope.Names.Add(new InputScopeName {
                    NameValue = InputScopeNameValue.Url
                });
                tbContent.InputScope = scope;

                break;
            }

            lbCaption.Content = caption;
            tbContent.Text    = initialValue;

            tbContent.Focus();

            updateOkButton();

            tbContent.TextChanged += (sender, e) => updateOkButton();
            btnCancel.Click       += (sender, e) => Close();
            tbContent.KeyDown     += (sender, e) => {
                if (e.Key == Key.Enter)
                {
                    btnOk.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
                }
            };

            btnOk.Click += async(sender, e) => {
                if (!updateOkButton())
                {
                    return;
                }

                var text  = tbContent.Text.ToString().Trim();
                var error = await onOk(text);

                if (error != null)
                {
                    tbError.textOrGone(error ?? "");
                    btnOk.IsEnabled = false;
                }
                else
                {
                    Close();
                }
            };
        }
Ejemplo n.º 23
0
 public static void SetInputStyle(InputStyle style)
 {
     inputStyle = style;
 }
Ejemplo n.º 24
0
 public InputHandler(InputStyle style)
 {
     InputStyle = style;
 }
Ejemplo n.º 25
0
 public MouseHandler(InputStyle style, string axisName) : base(style)
 {
     this.axisName = axisName;
 }
Ejemplo n.º 26
0
 public void SetInputStyle(InputStyle style)
 {
     GameSettings.SetInputStyle(style);
 }
Ejemplo n.º 27
0
 public static void SetInputStyle(int styleInt)
 {
     styleInt   = Mathf.Clamp(styleInt, 1, 2);
     inputStyle = (InputStyle)styleInt;
 }
Ejemplo n.º 28
0
 public KeyHandler(InputStyle style, KeyCode up, KeyCode down) : base(style)
 {
     upKey   = up;
     downKey = down;
 }