示例#1
0
 /// <summary>
 ///     Extracts text from the HTML code available from the given <see cref="InputSource" />.
 /// </summary>
 /// <param name="inputSource">The <see cref="InputSource" /> containing the HTML.</param>
 /// <returns>The extracted text.</returns>
 /// <exception cref="BoilerpipeProcessingException"></exception>
 public string GetText(InputSource inputSource) {
   try {
     return GetText(new BoilerpipeSAXInput(inputSource).GetTextDocument());
   } catch (Exception ex) {
     throw new BoilerpipeProcessingException(ex.Message, ex);
   }
 }
示例#2
0
 /// <summary>
 /// Automatically set input to 'touchpad' on iOS and Android devices.
 /// </summary>
 void Awake()
 {
     if (Application.platform == RuntimePlatform.Android ||
         Application.platform == RuntimePlatform.IPhonePlayer)
     {
         mInput = InputSource.Touchpad;
     }
 }
示例#3
0
        /// <summary>
        /// Constructs an unsigned transaction by referencing previous unspent outputs.
        /// A change output is added when necessary to return extra value back to the wallet.
        /// </summary>
        /// <param name="outputs">Transaction output array without change.</param>
        /// <param name="changeScript">Output script to pay change to.</param>
        /// <param name="fetchInputsAsync">Input selection source.</param>
        /// <returns>Unsigned transaction and total input amount.</returns>
        /// <exception cref="InsufficientFundsException">Input source was unable to provide enough input value.</exception>
        public static async Task<Tuple<Transaction, Amount>> BuildUnsignedTransaction(Transaction.Output[] outputs,
                                                                                      Amount feePerKb,
                                                                                      InputSource fetchInputsAsync,
                                                                                      ChangeSource fetchChangeAsync)
        {
            if (outputs == null)
                throw new ArgumentNullException(nameof(outputs));
            if (fetchInputsAsync == null)
                throw new ArgumentNullException(nameof(fetchInputsAsync));
            if (fetchChangeAsync == null)
                throw new ArgumentNullException(nameof(fetchChangeAsync));

            var targetAmount = outputs.Sum(o => o.Amount);
            var estimatedSize = Transaction.EstimateSerializeSize(1, outputs, true);
            var targetFee = TransactionFees.FeeForSerializeSize(feePerKb, estimatedSize);

            while (true)
            {
                var funding = await fetchInputsAsync(targetAmount + targetFee);
                var inputAmount = funding.Item1;
                var inputs = funding.Item2;
                if (inputAmount < targetAmount + targetFee)
                {
                    throw new InsufficientFundsException();
                }

                var maxSignedSize = Transaction.EstimateSerializeSize(inputs.Length, outputs, true);
                var maxRequiredFee = TransactionFees.FeeForSerializeSize(feePerKb, maxSignedSize);
                var remainingAmount = inputAmount - targetAmount;
                if (remainingAmount < maxRequiredFee)
                {
                    targetFee = maxRequiredFee;
                    continue;
                }

                var unsignedTransaction = new Transaction(Transaction.SupportedVersion, inputs, outputs, 0, 0);
                var changeAmount = inputAmount - targetAmount - maxRequiredFee;
                if (changeAmount != 0 && !TransactionRules.IsDustAmount(changeAmount, Transaction.PayToPubKeyHashPkScriptSize, feePerKb))
                {
                    var changeScript = await fetchChangeAsync();
                    if (changeScript.Script.Length > Transaction.PayToPubKeyHashPkScriptSize)
                    {
                        throw new Exception("Fee estimation requires change scripts no larger than P2PKH output scripts");
                    }
                    var changeOutput = new Transaction.Output(changeAmount, Transaction.Output.LatestPkScriptVersion, changeScript.Script);

                    var outputList = unsignedTransaction.Outputs.ToList();
                    outputList.Add(changeOutput);
                    var outputsWithChange = outputList.ToArray();

                    unsignedTransaction = new Transaction(unsignedTransaction.Version, unsignedTransaction.Inputs, outputsWithChange,
                        unsignedTransaction.LockTime, unsignedTransaction.Expiry);
                }

                return Tuple.Create(unsignedTransaction, inputAmount);
            }
        }
            public bool Invoke(IEnumerable<object> items, InputSource inputSource, bool preview)
            {
                NamingRuleTreeItemViewModel[] selectedRules = items.OfType<NamingRuleTreeItemViewModel>().ToArray();

                // When a single Naming Rule is invoked using the mouse, expanding/collapse it in the tree
                if (selectedRules.Length == 1)
                {
                    var selectedRule = selectedRules[0];
                    if (selectedRule.NamingStylesViewModel == null)
                    {
                        return false;
                    }

                    var viewModel = new NamingRuleDialogViewModel(
                        selectedRule._title,
                        selectedRule.symbolSpec,
                        selectedRule.NamingStylesViewModel.SymbolSpecificationList,
                        selectedRule.namingStyle,
                        selectedRule.NamingStylesViewModel.NamingStyleList,
                        selectedRule.parent,
                        selectedRule.NamingStylesViewModel.CreateAllowableParentList(selectedRule),
                        selectedRule.EnforcementLevel,
                        selectedRule.NamingStylesViewModel.notificationService);
                    var dialog = new NamingRuleDialog(viewModel, selectedRule.NamingStylesViewModel, selectedRule.NamingStylesViewModel.categories, selectedRule.NamingStylesViewModel.notificationService);
                    var result = dialog.ShowModal();
                    if (result == true)
                    {
                        selectedRule.namingStyle = viewModel.NamingStyleList.GetItemAt(viewModel.NamingStyleIndex) as NamingStyleViewModel;
                        selectedRule.symbolSpec = viewModel.SymbolSpecificationList.GetItemAt(viewModel.SelectedSymbolSpecificationIndex) as SymbolSpecificationViewModel;
                        selectedRule.Title = viewModel.Title;
                        selectedRule.EnforcementLevel = viewModel.EnforcementLevelsList[viewModel.EnforcementLevelIndex];
                        selectedRule.NotifyPropertyChanged(nameof(selectedRule.Text));

                        if (viewModel.ParentRuleIndex == 0)
                        {
                            if (selectedRule.Parent != selectedRule.NamingStylesViewModel.rootNamingRule)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                selectedRule.NamingStylesViewModel.rootNamingRule.Children.Add(selectedRule);
                            }
                        }
                        else
                        {
                            var newParent = viewModel.ParentRuleList.GetItemAt(viewModel.ParentRuleIndex) as NamingRuleTreeItemViewModel;
                            if (newParent != selectedRule.Parent)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                newParent.Children.Add(selectedRule);
                            }
                        }
                    }

                    return true;
                }

                return false;
            }
示例#5
0
 public void Format(String source, Writer writer) {
    try {
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       factory.setValidating(false);
       DocumentBuilder builder = factory.newDocumentBuilder();
       Reader reader = new StringReader(source);
       InputSource input = new InputSource(reader);
       Document document = builder.parse(input);
       Format(document, writer);
   } catch (Exception e) {
       throw new RuntimeException(e);
   }
 }
    public void Parse(InputSource input) {
      var document = new HtmlDocument();
      if (input.Stream != null) {
        document.Load(input.Stream, input.Encoding);
      } else if (input.Reader != null) {
        document.Load(input.Reader);
      } else if (input.PublicId != null) {
        document.Load(input.PublicId);
      } else if (input.SystemId != null) {
        document.Load(input.SystemId);
      }

      ContentHandler.StartDocument();

      TraverseNode(document.DocumentNode);

      ContentHandler.EndDocument();
    }
示例#7
0
 /// <summary>
 /// Switch between Mouse+Keyboard and Joystick input based on what was used last.
 /// </summary>
 void Update()
 {
     if (mInput != InputSource.Touchpad)
     {
         if (Input.GetKeyDown(KeyCode.JoystickButton0) ||
             Input.GetKeyDown(KeyCode.JoystickButton1) ||
             Input.GetKeyDown(KeyCode.JoystickButton2) ||
             Input.GetKeyDown(KeyCode.JoystickButton3) ||
             Input.GetKeyDown(KeyCode.JoystickButton4) ||
             Input.GetKeyDown(KeyCode.JoystickButton5))
         {
             mInput = InputSource.Controller;
         }
         else if (Input.anyKeyDown)
         {
             mInput = InputSource.MouseKeyboard;
         }
     }
 }
示例#8
0
 public XhtmlParser(PeterO.Support.InputStream source, string address, string charset, string lang)
 {
     if(source==null)throw new ArgumentException();
     if(address!=null && address.Length>0){
       URL url=URL.parse(address);
       if(url==null || url.getScheme().Length==0)
     throw new ArgumentException();
     }
     this.contentLang=HeaderParser.getLanguages(lang);
     this.address=address;
     try {
       this.reader=new PeterO.Support.SaxReader();
     } catch (SaxException e) {
       if(e.InnerException is IOException)
     throw (IOException)(e.InnerException);
       throw new IOException("",e);
     }
     handler=new XhtmlContentHandler(this);
     try {
       reader.SetFeature("http://xml.org/sax/features/namespaces",true);
       reader.SetFeature("http://xml.org/sax/features/use-entity-resolver2",true);
       reader.SetFeature("http://xml.org/sax/features/namespace-prefixes",true);
       reader.LexicalHandler=(handler);
     } catch (SaxException e) {
       throw new NotSupportedException("",e);
     }
     reader.ContentHandler=(handler);
     reader.EntityResolver=(handler);
     charset=TextEncoding.resolveEncoding(charset);
     if(charset==null){
       charset=sniffEncoding(source);
       if(charset==null) {
     charset="utf-8";
       }
     }
     this.isource=new InputSource<Stream>(source);
     this.isource.Encoding=(charset);
     this.encoding=charset;
 }
 public void Parse(InputSource source) {
   IXmlReader parser = new HtmlAgilityPackParser();
   parser.ContentHandler = _contentHandler;
   parser.Parse(source);
 }
 public void SetInputSource(InputSource input)
 {
     inputSource = input;
 }
示例#11
0
        protected override void UpdateTool(InputSource inputSource)
        {
            if (_currentTargetBehavior?.Grabbable ?? false)
            {
                _grabTool.Update(inputSource, Target);
                if (_grabTool.GrabActive)
                {
                    // If a grab is active, nothing should change about the current target.
                    return;
                }
            }

            Vector3?hitPoint;
            var     newTarget = FindTarget(inputSource, out hitPoint);

            if (Target == null && newTarget == null)
            {
                return;
            }

            if (Target == newTarget)
            {
                var mwUser = _currentTargetBehavior.GetMWUnityUser(inputSource.UserGameObject);
                if (mwUser == null)
                {
                    return;
                }

                CurrentTargetPoint = hitPoint.Value;
                _currentTargetBehavior.Context.UpdateTargetPoint(mwUser, CurrentTargetPoint);
                return;
            }

            TargetBehavior newBehavior = null;

            if (newTarget != null)
            {
                newBehavior = newTarget.GetBehavior <TargetBehavior>();

                if (newBehavior.GetDesiredToolType() != inputSource.CurrentTool.GetType())
                {
                    inputSource.HoldTool(newBehavior.GetDesiredToolType());
                }
                else
                {
                    OnTargetChanged(
                        Target,
                        CurrentTargetPoint,
                        newTarget,
                        hitPoint.Value,
                        newBehavior,
                        inputSource);
                }
            }
            else
            {
                OnTargetChanged(
                    Target,
                    CurrentTargetPoint,
                    null,
                    Vector3.zero,
                    null,
                    inputSource);

                inputSource.DropTool();
            }
        }
        /**
         * Processes the given sheet
         */
        public void ProcessSheet(
                SheetContentsHandler sheetContentsExtractor,
                StylesTable styles,
                ReadOnlySharedStringsTable strings,
                InputStream sheetInputStream)
        {

            DataFormatter formatter;
            if (locale == null)
            {
                formatter = new DataFormatter();
            }
            else
            {
                formatter = new DataFormatter(locale);
            }

            InputSource sheetSource = new InputSource(sheetInputStream);
            SAXParserFactory saxFactory = SAXParserFactory.newInstance();
            try
            {
                SAXParser saxParser = saxFactory.newSAXParser();
                XMLReader sheetParser = saxParser.GetXMLReader();
                ContentHandler handler = new XSSFSheetXMLHandler(
                      styles, strings, sheetContentsExtractor, formatter, formulasNotResults);
                sheetParser.SetContentHandler(handler);
                sheetParser.Parse(sheetSource);
            }
            catch (ParserConfigurationException e)
            {
                throw new RuntimeException("SAX Parser appears to be broken - " + e.GetMessage());
            }
        }
        private static void extractFunctionData(FunctionDataCollector fdc, InputStream is1)
        {
            XMLReader xr;

            try
            {
                // First up, try the default one
                xr = XMLReaderFactory.CreateXMLReader();
            }
            catch (SAXException e)
            {
                // Try one for java 1.4
                System.SetProperty("org.xml.sax.driver", "org.apache.crimson.Parser.XMLReaderImpl");
                try
                {
                    xr = XMLReaderFactory.CreateXMLReader();
                }
                catch (SAXException e2)
                {
                    throw new RuntimeException(e2);
                }
            }
            xr.SetContentHandler(new EFFDocHandler(fdc));

            InputSource inSrc = new InputSource(is1);

            try
            {
                xr.Parse(inSrc);
                is1.Close();
            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            catch (SAXException e)
            {
                throw new RuntimeException(e);
            }
        }
示例#14
0
		/// <summary>
		/// Advanced. If you want to remove an input source from the root's UI process you
		/// can do that here.
		/// </summary>
		/// <param name="inputSource">The input source to remove.</param>
		/// <remarks>
		/// You will seldom do this unless you are making additions to the piccolo framework.
		/// </remarks>
		public virtual void RemoveInputSource(InputSource inputSource) {
			inputSources.Remove(inputSource);
			FirePropertyChangedEvent(PROPERTY_KEY_INPUT_SOURCES, PROPERTY_CODE_INPUT_SOURCES, null, inputSources);
		}
示例#15
0
 /// <summary>
 /// Gets the current state of the inputTpye.
 /// <para>Implements <see cref="IDevice.Get(InputSource)"/></para>
 /// </summary>
 /// <param name="inputType">Source of input</param>
 /// <returns>Value</returns>
 public double Get(InputSource inputType)
 {
     return(inputType.Value);
 }
示例#16
0
 [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern void input_fire_event(InputSource source, InputState evt, IntPtr pointer);
示例#17
0
 [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern void input_unsubscribe(InputSource source, InputState evt, InputEventCallback event_callback);
示例#18
0
 [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern Pointer input_pointer(int index, InputSource filter = InputSource.Any);
示例#19
0
        /// <summary>
        /// Updates the input state and activates handlers binded to specific actions.
        /// </summary>
        public static void Update(GameTime gameTime, GraphicsDeviceManager graphics)
        {
            KeyboardState keyState   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();

            foreach (GameAction ga in bindings.Keys)
            {
                InputSource source = bindings[ga];

                bool pressed = false;
                if (source is KeyboardInputSource)
                {
                    pressed = keyState[(source as KeyboardInputSource).key] == KeyState.Down;
                }
                else if (source is MouseInputSource)
                {
                    MouseButtons button = (source as MouseInputSource).button;
                    switch (button)
                    {
                    case MouseButtons.Left: pressed = (mouseState.LeftButton == ButtonState.Pressed); break;

                    case MouseButtons.Right: pressed = (mouseState.RightButton == ButtonState.Pressed); break;

                    case MouseButtons.Middle: pressed = (mouseState.MiddleButton == ButtonState.Pressed); break;
                    }
                }

                if (pressed == actionStates[ga].First)
                {
                    actionStates[ga].Second = actionStates[ga].Second + gameTime.ElapsedGameTime.Seconds;
                    if (pressed)
                    {
                        PressingActionArgs args = new PressingActionArgs(actionStates[ga].Second);
                        args.gameTime = gameTime;
                        args.action   = ga;
                        List <ProcessPressingAction> copyPressingDelegates = new List <ProcessPressingAction>(pressingDelegates[ga]);
                        foreach (ProcessPressingAction proc in copyPressingDelegates)
                        {
                            proc(args);
                        }
                    }
                }
                else
                {
                    float time = actionStates[ga].Second;
                    actionStates[ga].Second = 0.0f;
                    actionStates[ga].First  = pressed;

                    if (pressed)
                    {
                        PressedActionArgs args = new PressedActionArgs(time);
                        args.gameTime = gameTime;
                        args.action   = ga;
                        List <ProcessPressedAction> copyPressedDelegates = new List <ProcessPressedAction>(pressedDelegates[ga]);
                        foreach (ProcessPressedAction proc in copyPressedDelegates)
                        {
                            proc(args);
                        }
                    }
                    else
                    {
                        ReleasedActionArgs args = new ReleasedActionArgs(time);
                        args.gameTime = gameTime;
                        args.action   = ga;
                        List <ProcessReleasedAction> copyReleasedDelegates = new List <ProcessReleasedAction>(releasedDelegates[ga]);
                        foreach (ProcessReleasedAction proc in copyReleasedDelegates)
                        {
                            proc(args);
                        }
                    }
                }
            }

            float xMove = (float)(mouseState.X - graphics.PreferredBackBufferWidth / 2) / (float)graphics.PreferredBackBufferWidth * inversionFactorX;
            float yMove = (float)(mouseState.Y - graphics.PreferredBackBufferHeight / 2) / (float)graphics.PreferredBackBufferHeight * inversionFactorY;

            if (xMove * xMove + yMove * yMove > 0.0000001f)
            {
                List <ProcessMouseMove> copyMouseDelegates = new List <ProcessMouseMove>(mouseDelegates);
                foreach (ProcessMouseMove proc in copyMouseDelegates)
                {
                    proc(xMove, yMove, gameTime);
                }
            }
            oldMouseWheelValue = mouseWheelValue;
            mouseWheelValue    = mouseState.ScrollWheelValue;
            Mouse.SetPosition(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2);
        }
示例#20
0
 public AxisViewModel(AxisModel model, InputSource type, int max = 1000) : base(model)
 {
     Model.Type = type;
     Model.Max  = max;
 }
示例#21
0
        /*
         * Parse the content of the given input source as an XML document
         * and return a new DOM {@link Document} object.
         * An <code>IllegalArgumentException</code> is thrown if the
         * <code>InputSource</code> is <code>null</code> null.
         *
         * @param is InputSource containing the content to be parsed.
         * @exception IOException If any IO errors occur.
         * @exception SAXException If any parse errors occur.
         * @see org.xml.sax.DocumentHandler
         * @return A new DOM Document object.
         */

        public abstract Document parse(InputSource isJ);
示例#22
0
		static void DrawBrush (Widget widget, InputSource source, 
					double x, double y, double pressure) 
		{
			/*
			Gdk.GC gc;
			switch (source) {
				case InputSource.Mouse:
					gc = widget.Style.BlackGC;
					break;
				case InputSource.Pen:
					gc = widget.Style.BlackGC;
					break;
				case InputSource.Eraser:
					gc = widget.Style.WhiteGC;
					break;
				default:
					gc = widget.Style.BlackGC;
					break;
    			}
			*/

			Gdk.Rectangle update_rect = new Gdk.Rectangle ();
			update_rect.X = (int) (x - 10.0d * pressure);
			update_rect.Y = (int) (y - 10.0d * pressure);
			update_rect.Width = (int) (20.0d * pressure);
			update_rect.Height = (int) (20.0d * pressure);

			/*
			pixmap.DrawRectangle (gc, true, 
						update_rect.X, update_rect.Y,
						update_rect.Width, update_rect.Height);
			*/
			darea.QueueDrawArea (update_rect.X, update_rect.Y,
						update_rect.Width, update_rect.Height);
			
		}
示例#23
0
 void FireEvent( int vkCode, InputSource source )
 {
     KeyboardDriverEventArg eventArgs = new KeyboardDriverEventArg( vkCode, source );
     if( KeyDown != null ) KeyDown( this, eventArgs );
 }
 /// <summary>
 /// Parse the content of the given input source as an XML document
 /// and return a new DOM <A HREF="../../../org/w3c/dom/Document.html" title="interface in org.w3c.dom"><CODE>Document</CODE></A> object.
 /// </summary>
 abstract public Document parse(InputSource @is);
示例#25
0
 /// <summary>
 ///     Creates a new instance of <see cref="BoilerpipeSAXInput" /> for the given <see cref="InputSource" />.
 /// </summary>
 /// <param name="source"></param>
 public BoilerpipeSAXInput(InputSource source)
 {
     _source = source;
 }
示例#26
0
文件: Ps4Input.cs 项目: bhas/RaidGame
 public Ps4Input(InputSource player)
 {
     this.player = (int)player;
 }
示例#27
0
        // actually pushes a note to sdcard, with optional subdirectory (e.g. backup)
        private static int doPushNote(Note note)
        {
            Note rnote = new Note();
            try {
                File path = new File(Tomdroid.NOTES_PATH);

                if (!path.Exists())
                    path.Mkdir();

                TLog.i(TAG, "Path {0} Exists: {1}", path, path.Exists());

                // Check a second time, if not the most likely cause is the volume doesn't exist
                if(!path.Exists()) {
                    TLog.w(TAG, "Couldn't create {0}", path);
                    return NO_SD_CARD;
                }

                path = new File(Tomdroid.NOTES_PATH + "/"+note.getGuid() + ".note");

                note.createDate = note.getLastChangeDate().Format3339(false);
                note.cursorPos = 0;
                note.width = 0;
                note.height = 0;
                note.X = -1;
                note.Y = -1;

                if (path.Exists()) { // update existing note

                    // Try reading the file first
                    string contents = "";
                    try {
                        char[] buffer = new char[0x1000];
                        contents = readFile(path,buffer);
                    } catch (IOException e) {
                        e.PrintStackTrace();
                        TLog.w(TAG, "Something went wrong trying to read the note");
                        return PARSING_FAILED;
                    }

                    try {
                        // Parsing
                        // XML
                        // Get a SAXParser from the SAXPArserFactory
                        SAXParserFactory spf = SAXParserFactory.newInstance();
                        SAXParser sp = spf.newSAXParser();

                        // Get the XMLReader of the SAXParser we created
                        XMLReader xr = sp.getXMLReader();

                        // Create a new ContentHandler, send it this note to fill and apply it to the XML-Reader
                        NoteHandler xmlHandler = new NoteHandler(rnote);
                        xr.setContentHandler(xmlHandler);

                        // Create the proper input source
                        StringReader sr = new StringReader(contents);
                        InputSource inputSource = new InputSource(sr);

                        TLog.d(TAG, "parsing note. filename: {0}", path.Name());
                        xr.parse(inputSource);

                    // TODO wrap and throw a new exception here
                    } catch (Exception e) {
                        e.PrintStackTrace();
                        if(e as TimeFormatException) TLog.e(TAG, "Problem parsing the note's date and time");
                        return PARSING_FAILED;
                    }

                    note.createDate = rnote.createDate;
                    note.cursorPos = rnote.cursorPos;
                    note.width = rnote.width;
                    note.height = rnote.height;
                    note.X = rnote.X;
                    note.Y = rnote.Y;

                    note.setTags(rnote.getTags());
                }

                string xmlOutput = note.getXmlFileString();

                path.CreateNewFile();
                FileOutputStream fOut = new FileOutputStream(path);
                OutputStreamWriter myOutWriter =
                                        new OutputStreamWriter(fOut);
                myOutWriter.Append(xmlOutput);
                myOutWriter.Close();
                fOut.Close();

            }
            catch (Exception e) {
                TLog.e(TAG, "push to sd card didn't work");
                return NOTE_PUSH_ERROR;
            }
            return NOTE_PUSHED;
        }
示例#28
0
 /// <summary>
 /// Advanced. If you want to remove an input source from the root's UI process you
 /// can do that here.
 /// </summary>
 /// <param name="inputSource">The input source to remove.</param>
 /// <remarks>
 /// You will seldom do this unless you are making additions to the piccolo framework.
 /// </remarks>
 public virtual void RemoveInputSource(InputSource inputSource)
 {
     inputSources.Remove(inputSource);
     FirePropertyChangedEvent(PROPERTY_KEY_INPUT_SOURCES, PROPERTY_CODE_INPUT_SOURCES, null, inputSources);
 }
 public WheelActionEventArgs( int x, int y, ButtonInfo buttonInfo, string extraInfo, InputSource source, int wheelDelta )
     : base(x, y, buttonInfo, extraInfo, source)
 {
     Delta = wheelDelta;
 }
 protected virtual void OnGrabStateChanged(GrabState oldGrabState, GrabState newGrabState, InputSource inputSource)
 {
 }
        protected override void UpdateTool(InputSource inputSource)
        {
            if (_currentTargetBehavior?.Grabbable ?? false)
            {
                _grabTool.Update(inputSource, Target);
                if (_grabTool.GrabActive)
                {
                    // If a grab is active, nothing should change about the current target.
                    return;
                }
            }

            Vector3?hitPoint;
            var     newTarget = FindTarget(inputSource, out hitPoint);

            if ((Target == null || !Godot.Object.IsInstanceValid(Target)) && (newTarget == null || !Godot.Object.IsInstanceValid(newTarget)))
            {
                return;
            }

            if (Target == newTarget)
            {
                var mwUser = _currentTargetBehavior.GetMWUnityUser(inputSource.UserNode);
                if (mwUser == null)
                {
                    return;
                }

                CurrentTargetPoint = hitPoint.Value;
                _currentTargetBehavior.Context.UpdateTargetPoint(mwUser, CurrentTargetPoint);
                return;
            }

            TargetBehavior newBehavior = null;

            if (newTarget != null && Godot.Object.IsInstanceValid(newTarget))
            {
                newBehavior = newTarget.GetBehavior <TargetBehavior>();

                // FIXME: This is workaround. Sometimes newBehavior is null even if new Target is an Actor!
                if (newBehavior == null /*&& newTarget is MixedRealityExtension.Core.Actor*/)
                {
                    return;
                }

                if (newBehavior.GetDesiredToolType() != inputSource.CurrentTool.GetType())
                {
                    inputSource.HoldTool(newBehavior.GetDesiredToolType());
                }
                else
                {
                    OnTargetChanged(
                        Target,
                        CurrentTargetPoint,
                        newTarget,
                        hitPoint.Value,
                        newBehavior,
                        inputSource);
                }
            }
            else
            {
                OnTargetChanged(
                    Target,
                    CurrentTargetPoint,
                    null,
                    Vector3.Zero,
                    null,
                    inputSource);

                inputSource.DropTool();
            }
        }
示例#32
0
 public static int PointerCount(InputSource filter = InputSource.Any)
 {
     return(NativeAPI.input_pointer_count(filter));
 }
 public virtual void ReadInput( Dictionary<int, List<InputSourceCollection>> inputSources,
                               Dictionary<string, VertexSet> vertexSets,
                               XmlNode node, ColladaMeshInfo meshInfo )
 {
     InputSourceCollection input = null;
     string source = node.Attributes[ "source" ].Value;
     // Get the part after the '#'
     source = source.Substring( 1 );
     string semantic = node.Attributes[ "semantic" ].Value;
     int inputIndex = inputSources.Count;
     if( node.Attributes[ "idx" ] != null )
         inputIndex = int.Parse( node.Attributes[ "idx" ].Value );
     if( !inputSources.ContainsKey( inputIndex ) )
         inputSources[ inputIndex ] = new List<InputSourceCollection>();
     if( semantic == "VERTEX" )
     {
         VertexSet vertexSet = vertexSets[ source ];
         // Dereference the vertex input and add that instead.
         if( inputSources != null )
         {
             VertexInputSource vertexInput = new VertexInputSource();
             foreach( InputSourceCollection tmp in vertexSet.vertexEntries )
                 vertexInput.AddSource( tmp );
             inputSources[ inputIndex ].Add( vertexInput );
         }
     }
     else
     {
         if( !Accessors.ContainsKey( source ) )
         {
             Debug.Assert( false, "Missing accessor for source: " + source );
             return;
         }
         Accessor accessor = Accessors[ source ];
         if( inputSources != null )
         {
             input = new InputSource( source, semantic, accessor );
             inputSources[ inputIndex ].Add( input );
         }
     }
 }
示例#34
0
 public static Pointer Pointer(int index, InputSource filter = InputSource.Any)
 {
     return(NativeAPI.input_pointer(index, filter));
 }
示例#35
0
 public PlayerGunController()
 {
     InputSource = new KeyboardInputSource();
 }
示例#36
0
 public InputTriggerEventArgs( InputSource source )
 {
     Source = source;
 }
示例#37
0
 /// <summary>Creates a new <see cref="JoystickEventArgs"/> instance.</summary>
 public JoystickEventArgs(RoutedEvent ev, JoystickGesture gesture, InputSource inputSource) : base(ev) {
    Gesture = gesture;
    InputSource = inputSource;
 }
示例#38
0
 //throws IOException, SAXException
 /**
  * Parse the document.
  *
  * <p>This method will throw an exception if the embedded
  * XMLReader does not support the
  * http://xml.org/sax/features/namespace-prefixes property.</p>
  *
  * @param input An input source for the document.
  * @exception java.io.IOException If there is a problem reading
  *            the raw content of the document.
  * @exception org.xml.sax.SAXException If there is a problem
  *            processing the document.
  * @see #parse(java.lang.String)
  * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
  */
 public void parse(InputSource input)
 {
     setupXMLReader();
     xmlReader.parse(input);
 }
示例#39
0
 public PlayerController(InputSource inputSource)
 {
     InputSource  = inputSource;
     commandQueue = new CommandQueue();
 }
示例#40
0
        /*
         * Push, or skip, a new external input source.
         * The source will be some kind of parsed entity, such as a PE
         * (including the external DTD subset) or content for the body.
         *
         * @param url The java.net.URL object for the entity.
         * @see SaxDriver#resolveEntity
         * @see #pushstring
         * @see #sourceType
         * @see #pushInput
         * @see #detectEncoding
         * @see #sourceType
         * @see #readBuffer
         */
        private void pushURL(bool  isPE, string  ename, string[]  ids,  // public, system, baseURI
            TextReader  reader, Stream stream, string  urlEncodingName, bool  doResolve)
        {
            bool  ignoreEncoding;
              bool isDocument = false;
              string  systemId;
              InputSource source;

              // Check for entity recursion before  we get any further
              checkEntityRecursion(ename);

              if (!isPE)
            dataBufferFlush ();

              // .NET this is now recreated
              InputSource scratch = new InputSource();
              scratch.PublicId = ids [0];
              //!!SSID -K
              scratch.SystemId = handler.absolutize(handler.SystemId, ids [1], false);

              // See if we should skip or substitute the entity.
              // If we're not skipping, resolving reports startEntity()
              // and updates the (handler's) stack of URIs.
              if (doResolve) {
            // assert (stream == null && reader == null && urlEncodingName == null)
            source = handler.resolveEntity (isPE, ename, scratch, ids [2]);
            if (source == null) {
              handler.warn ("skipping entity: " + ename);
              handler.skippedEntity (ename);
              if (isPE)
            skippedPE = true;
              return;
            }

            // we might be using alternate IDs/encoding
            systemId = source.SystemId;
            if (systemId == null) {
              handler.warn ("missing system ID, using " + ids [1]);
              //!!SSID -K
              systemId = handler.absolutize(handler.SystemId, ids [1], false);
            }
              } else {
            // "[document]", or "[dtd]" via getExternalSubset()
            if (reader != null)
              scratch = new InputSource<TextReader>(reader);
            else if (stream != null)
              scratch = new InputSource<Stream>(stream);
            else
              scratch = new InputSource();
            // set the encoding
            scratch. Encoding = urlEncodingName;

            source = scratch;
            //!!SSID
            systemId = handler.absolutize(handler.SystemId, ids [1], false);
            isDocument = ("[document]" == ename);
            handler.startExternalEntity (ename, systemId, isDocument);
              }

              // we may have been given I/O streams directly
              if (source is InputSource<TextReader>) {
            // .NET not applicable if (source.getByteStream () != null)
            //   error ("InputSource has two streams!");
            reader = ((InputSource<TextReader>)source).Source;
              } else if (source is InputSource<Stream>) {
            urlEncodingName = source.Encoding;
            stream = ((InputSource<Stream>)source).Source;
              } else if (systemId == null)
            fatalError ("InputSource has no URI!");

              // .NET scratch the scratch after each use
              scratch = null;

              // Push the existing status.
              pushInput (ename);

              // We are no longer in the internal subset if this is a PE
              if (isPE)
              {
            inInternalSubset = false;
            entityType = ENTITY_TYPE_EXT_PE;
              }
              else if (!isDocument)
            entityType = ENTITY_TYPE_EXT_GE;
              else
            entityType = ENTITY_TYPE_DOCUMENT;

              // Create a new read buffer.
              // (Note the four-character margin)
              readBuffer = new char [READ_BUFFER_MAX + 4];
              readBufferPos = 0;
              readBufferLength = 0;
              readBufferOverflow = -1;
              inputStream = null;
              line = 1;
              column = 0;
              currentByteCount = 0;

              // If there's an explicit character stream, just
              // ignore encoding declarations.
              if (reader != null) {
            sourceType = INPUT_READER;
            this.reader = reader;
            // FIXME: This may be wrong, the reader may be using a
            // different encoding paradigm. For now, just grab the label
            urlEncodingName = tryEncodingDecl (true);
            return;
              }

              // Else we handle the conversion, and need to ensure
              // it's done right.
              sourceType = INPUT_STREAM;
              if (stream != null) {
            inputStream = stream;
              } else {
            // We have to open our own stream to the URL.
            WebRequest url = WebRequest.Create (systemId);
            externalEntity = url.GetResponse();
            inputStream = externalEntity.GetResponseStream ();
              }

              // If we get to here, there must be
              // an InputStream available.
              // .NET this is now eliminated, may prove to optimize further later
              if (!inputStream.CanSeek) {
            inputStream = new BufferedStream (inputStream, READ_BUFFER_MAX);
              }

              // We need to call start document if we haven't
              if (inputStack.Count == 0)
            handler.startDocument ();
              else
            hasExtEntity = true;

              // Get any external encoding label.
              if (urlEncodingName == null && externalEntity != null)
              {
            // External labels can be untrustworthy; filesystems in
            // particular often have the wrong default for content
            // that wasn't locally originated.  Those we autodetect.
            if (!"file".Equals (externalEntity.ResponseUri.Scheme)) {
              int temp;

              // application/xml;charset=something;otherAttr=...
              // ... with many variants on 'something'
              urlEncodingName = externalEntity.ContentType;

              // MHK code (fix for Saxon 5.5.1/007):
              // protect against encoding==null
              if (urlEncodingName == null) {
            temp = -1;
              } else {
            temp = urlEncodingName.IndexOf ("charset");
              }

              // RFC 2376 sez MIME text defaults to ASCII, but since the
              // JDK will create a MIME type out of thin air, we always
              // autodetect when there's no explicit charset attribute.
              if (temp < 0)
            urlEncodingName = null; // autodetect
              else {
            // .NET FIX needed to trim off the mime name
            urlEncodingName = urlEncodingName.Substring(temp);
            // only this one attribute
            if ((temp = urlEncodingName.IndexOf (';')) > 0)
              urlEncodingName = urlEncodingName.Substring (0, temp);

            if ((temp = urlEncodingName.IndexOf ('=', temp + 7)) > 0) {
              urlEncodingName = urlEncodingName.Substring (temp + 1);

              // attributes can have comment fields (RFC 822)
              if ((temp = urlEncodingName.IndexOf ('(')) > 0)
                urlEncodingName = urlEncodingName.Substring (0, temp);
              // ... and values may be quoted
              if ((temp = urlEncodingName.IndexOf ('"')) > 0)
                urlEncodingName = urlEncodingName.Substring (temp + 1,
                  urlEncodingName.IndexOf ('"', temp + 2));
              urlEncodingName.Trim ();
            } else {
              handler.warn ("ignoring illegal MIME attribute: "
                + urlEncodingName);
              urlEncodingName = null;
            }
              }
            }
              }

              // if we got an external encoding label, use it ...
              if (urlEncodingName != null) {
            this.encoding = ENCODING_EXTERNAL;
            setupDecoding (urlEncodingName);
            ignoreEncoding = true;

            // ... else autodetect from first bytes.
              } else {
            detectEncoding ();
            ignoreEncoding = false;
              }

              // Read any Xml or text declaration.
              // If we autodetected, it may tell us the "real" encoding.
              try {
            // Capture the encoding
            urlEncodingName = tryEncodingDecl (ignoreEncoding);
              } catch (AElfredUnsupportedEncodingException x) {
            // .NET switched to the new AElfred model
            urlEncodingName = x.getEncoding();

            // if we don't handle the declared encoding,
            // try letting a TextReader do it
            try
            {
              if (sourceType != INPUT_STREAM)
            throw x;

              //!! Does seeking always work?
              inputStream.Seek (0, SeekOrigin.Begin);
              readBufferPos = 0;
              readBufferLength = 0;
              readBufferOverflow = -1;
              currentByteCount = 0;
              line = 1;
              column = 0;

              System.Text.Encoding enc = System.Text.Encoding.GetEncoding(urlEncodingName);
              switch (this.encoding)
              {
            case ENCODING_UTF_8:
            case ENCODING_ISO_8859_1:
            case ENCODING_ASCII:
              if (enc.GetByteCount("<") != 1)
                fatalError("invalid encoding switch, document is encoded using a single byte encoding but contains an encoding declaration for a multi-byte encoding");
              break;
            case ENCODING_UCS_2_12:
            case ENCODING_UCS_2_21:
              if (enc.GetByteCount("<") != 2)
                fatalError("invalid encoding switch, document is encoded using a two byte encoding but contains an encoding declaration for an alternate length encoding");
              break;
            case ENCODING_UCS_4_1234:
            case ENCODING_UCS_4_4321:
            case ENCODING_UCS_4_2143:
            case ENCODING_UCS_4_3412:
              if (enc.GetByteCount("<") != 4)
                fatalError("invalid encoding switch, document is encoded using a four byte encoding but contains an encoding declaration for an alternate length encoding");
              break;
            default:
              // External encoding declaration no fatal error
              break;
              }

              sourceType = INPUT_READER;
              this.reader = new StreamReader (inputStream, enc);
              inputStream = null;

              // Capture the encoding
              urlEncodingName = tryEncodingDecl (true);

            }
            catch (ArgumentException)
            {
              // This *should* be a NotSupportedException from GetEncoding, however
              // GetEncoding instead returns the amorphous ArgumentException. On
              // Mono it seems that it is a NotSupported exception
              fatalError ("unsupported text encoding",
            urlEncodingName,
            null);
            }
            catch (NotSupportedException)
            {
              // This *should* be a NotSupportedException from GetEncoding, however
              // GetEncoding instead returns the amorphous ArgumentException. On
              // Mono it seems that it is a NotSupported exception
              fatalError ("unsupported text encoding",
            urlEncodingName,
            null);
            }
              }

              // Store this for later
              encodingName = urlEncodingName;
        }
示例#41
0
 public KeyboardDriverEventArg( int keyCode, InputSource inputSource )
 {
     KeyCode = keyCode;
     InputSource = inputSource;
 }
示例#42
0
        /// <summary>
        /// Read hyphenation patterns from an XML file.
        /// </summary>
        /// <param name="source"> the InputSource for the file </param>
        /// <exception cref="IOException"> In case the parsing fails </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void loadPatterns(org.xml.sax.InputSource source) throws java.io.IOException
        public virtual void loadPatterns(InputSource source)
        {
            PatternParser pp = new PatternParser(this);
            ivalues = new TernaryTree();

            pp.parse(source);

            // patterns/values should be now in the tree
            // let's optimize a bit
            trimToSize();
            vspace.trimToSize();
            classmap.trimToSize();

            // get rid of the auxiliary map
            ivalues = null;
        }
示例#43
0
        public OperatorToken(string data, int lineNumber, InputSource source)
        {
            Text       = data;
            LineNumber = lineNumber;
            Source     = source;

            switch (data)
            {
            case "(":
                Type = OperatorType.ExpressionOpen;
                break;

            case ")":
                Type = OperatorType.ExpressionClose;
                break;

            case "[":
                Type = OperatorType.IndirectionOpen;
                break;

            case "]":
                Type = OperatorType.IndirectionClose;
                break;

            case "+":
                Type = OperatorType.Addition;
                break;

            case "-":
                Type = OperatorType.Subtraction;
                break;

            case "*":
                Type = OperatorType.Multiplication;
                break;

            case "/":
                Type = OperatorType.Division;
                break;

            case "%":
                Type = OperatorType.Modulus;
                break;

            case "<<":
                Type = OperatorType.LeftBitShift;
                break;

            case ">>":
                Type = OperatorType.RightBitShift;
                break;

            case "&":
                Type = OperatorType.BitwiseAnd;
                break;

            case "|":
                Type = OperatorType.BitwiseOr;
                break;

            case "^":
                Type = OperatorType.BitwiseXor;
                break;

            case "~":
                Type = OperatorType.BitwiseComplement;
                break;

            case "!=":
                Type = OperatorType.NotEqualTo;
                break;

            case "==":
                Type = OperatorType.EqualTo;
                break;

            case "<":
                Type = OperatorType.LessThan;
                break;

            case ">":
                Type = OperatorType.GreaterThan;
                break;

            case "<=":
                Type = OperatorType.LessThanOrEqualTo;
                break;

            case ">=":
                Type = OperatorType.GreaterThanOrEqualTo;
                break;

            case ",":
                Type = OperatorType.Comma;
                break;

            case "=":
                Type = OperatorType.Assignment;
                break;

            case "\\":
                Type = OperatorType.LineContinuation;
                break;

            default:
                throw new eZasm.Assembler.AssemblerError.UnknownOperatorException(source, lineNumber, null, data);
            }
        }
示例#44
0
 internal OpenGLContext(string name)
 {
     if (GLFW.GlfwInit() == 0)
     {
         Console.Error.WriteLine("GLFW failed to initialize!");
         Environment.Exit(1);
     }
     Window = GLFW.GlfwCreateWindow(1920, 1080, name, null, null);
     if (Window == null)
     {
         Console.Error.WriteLine("GLFW failed to open window!");
         GLFW.GlfwTerminate();
         Environment.Exit(1);
     }
     Input = new InputSource();
     GLFW.GlfwMakeContextCurrent(Window);
     StrongReferences = new List <Delegate>();
     {
         GLFWkeyfun cb = KeyCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetKeyCallback(Window, cb);
     }
     {
         GLFWcharfun cb = CharCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCharCallback(Window, cb);
     }
     {
         GLFWerrorfun cb = ErrorCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetErrorCallback(cb);
     }
     {
         GLFWscrollfun cb = ScrollCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetScrollCallback(Window, cb);
     }
     {
         GLFWcharmodsfun cb = CharModsCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCharModsCallback(Window, cb);
     }
     {
         GLFWcursorposfun cb = CursorPosCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCursorPosCallback(Window, cb);
     }
     {
         GLFWwindowposfun cb = WindowPosCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowPosCallback(Window, cb);
     }
     {
         GLFWwindowsizefun cb = WindowSizeCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowSizeCallback(Window, cb);
     }
     {
         GLFWcursorenterfun cb = CursorEnterCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetCursorEnterCallback(Window, cb);
     }
     {
         GLFWmousebuttonfun cb = MouseButtonCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetMouseButtonCallback(Window, cb);
     }
     {
         GLFWwindowfocusfun cb = WindowFocusCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowFocusCallback(Window, cb);
     }
     {
         GLFWwindowiconifyfun cb = WindowIconifyCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetWindowIconifyCallback(Window, cb);
     }
     {
         GLFWframebuffersizefun cb = FrameBufferSizeCallback;
         StrongReferences.Add(cb);
         GLFW.GlfwSetFramebufferSizeCallback(Window, cb);
     }
 }
示例#45
0
 //throws SAXException, IOException
 /**
  * Parse a document.
  *
  * @param input The input source for the document entity.
  * @exception org.xml.sax.SAXException Any SAX exception, possibly
  *            wrapping another exception.
  * @exception java.io.IOException An IO exception from the parser,
  *            possibly from a byte stream or character stream
  *            supplied by the application.
  */
 public void parse(InputSource input)
 {
     setupParse();
     parent.parse(input);
 }
示例#46
0
 public GenericException(InputSource source, int lineNumber, Exception child, string info)
     : base(source, lineNumber, child, info)
 {
     Info += info;
 }
 public virtual void Inform(ResourceLoader loader)
 {
     InputStream stream = null;
     try
     {
       if (dictFile != null) // the dictionary can be empty.
       {
     dictionary = getWordSet(loader, dictFile, false);
       }
       // TODO: Broken, because we cannot resolve real system id
       // ResourceLoader should also supply method like ClassLoader to get resource URL
       stream = loader.openResource(hypFile);
       InputSource @is = new InputSource(stream);
       @is.Encoding = encoding; // if it's null let xml parser decide
       @is.SystemId = hypFile;
       hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(@is);
     }
     finally
     {
       IOUtils.CloseWhileHandlingException(stream);
     }
 }
示例#48
0
 /*
  * Parse the document.
  *
  * <p>This method will throw an exception if the embedded
  * XMLReader does not support the
  * http://xml.org/sax/features/namespace-prefixes property.</p>
  *
  * @param input An input source for the document.
  * @exception java.io.IOException If there is a problem reading
  *            the raw content of the document.
  * @exception org.xml.sax.SAXException If there is a problem
  *            processing the document.
  * @see #parse(java.lang.String)
  * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
  */
 public void parse(InputSource input)
 //throws IOException, SAXException
 {
     setupXMLReader();
     xmlReader.parse(input);
 }
示例#49
0
 /// <summary>
 /// Read hyphenation patterns from an XML file.
 /// </summary>
 /// <param name="f"> the filename </param>
 /// <exception cref="IOException"> In case the parsing fails </exception>
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void loadPatterns(java.io.File f) throws java.io.IOException
 public virtual void loadPatterns(File f)
 {
     InputSource src = new InputSource(f.toURI().toASCIIString());
     loadPatterns(src);
 }
示例#50
0
        //  public virtual void SetAction(Action actionID)
        //  {
        //      Mode_Activate(ModeEnum.Action, actionID);          //4 is the ID for the Actions
        //  }

        //  public virtual void SetAction(int actionID)
        //  {
        //      Mode_Activate(ModeEnum.Action, actionID);          //4 is the ID for the Actions
        //  }

        //  #region Attacks Commands
        //  /// <summary> Tries to Activate the Primary Attack Mode with an Attack ID Animation</summary>
        //  public virtual void SetAttack(int attackID) { Mode_Activate(ModeEnum.Attack1, attackID); }

        //  /// <summary> Tries to Activate the Primary Attack Mode with an Random Attack Animation</summary>
        //  public virtual void SetAttack() { Mode_Activate(ModeEnum.Attack1, -1); }

        //  ///// <summary> Tries to Activate the Primary Attack Forever... until StopAttack Is Called... usefull for AI</summary>
        //  //public virtual void SetAttack_Endless(int attackID) { Mode_Activate_Endless(ModeEnum.Attack1); }

        //  /// <summary> Stop Primary Attack Animations... usefull for AI</summary>
        //  public virtual void StopAttack() { Mode_Stop(); }

        //  /// <summary> Tries to Activate the Secondary Attack Mode with an Attack ID Animation</summary>
        //  public virtual void SetAttack2(int attackID) { Mode_Activate(ModeEnum.Attack2, attackID); }

        //  /// <summary> Try to Activate the Secondary Attack Mode with an Random Attack Animation</summary>
        //  public virtual void SetAttack2() { Mode_Activate(ModeEnum.Attack2, -1); }

        ////  /// <summary> Try to Activate the Secondary Attack Forever... until StopAttack Is Called... usefull for AI</summary>
        ////  public virtual void SetAttack2_Endless(int attackID) { Mode_Activate_Endless(ModeEnum.Attack2); }

        //  /// <summary> Stop Secondary Attack Animations... usefull for AI</summary>
        //  public virtual void StopAttack2() { Mode_Stop(); }
        #endregion


        #region Movement

        /// <summary> Get the Inputs for the Source to add it to the States </summary>
        internal virtual void GetInputs(bool add)
        {
            InputSource = GetComponentInParent <IInputSource>();

            if (InputSource != null)
            {
                //Enable Disable the Inputs for the States
                foreach (var state in states)
                {
                    if (state.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(state.Input);

                        if (input != null)
                        {
                            if (add)
                            {
                                if (input.GetPressed == InputButton.Down || input.GetPressed == InputButton.Up)
                                {
                                    input.OnInputDown.AddListener(() => { state.ActivatebyInput(true); });
                                    input.OnInputUp.AddListener(() => { state.ActivatebyInput(false); });
                                }
                                else
                                {
                                    input.OnInputChanged.AddListener(state.ActivatebyInput);
                                }
                            }
                            else
                            {
                                if (input.GetPressed == InputButton.Down || input.GetPressed == InputButton.Up)
                                {
                                    input.OnInputDown.RemoveAllListeners();
                                    input.OnInputUp.RemoveAllListeners();
                                }
                                else
                                {
                                    input.OnInputChanged.RemoveListener(state.ActivatebyInput);
                                }
                            }
                        }
                    }
                }


                //Enable Disable the Inputs for the States
                foreach (var mode in modes)
                {
                    if (mode.Input != string.Empty)
                    {
                        var input = InputSource.GetInput(mode.Input);

                        if (input != null)
                        {
                            if (add)
                            {
                                input.OnInputChanged.AddListener(mode.ActivatebyInput);
                            }
                            else
                            {
                                input.OnInputChanged.RemoveListener(mode.ActivatebyInput);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Create a hyphenator tree
 /// </summary>
 /// <param name="hyphenationSource"> the InputSource pointing to the XML grammar </param>
 /// <returns> An object representing the hyphenation patterns </returns>
 /// <exception cref="IOException"> If there is a low-level I/O error. </exception>
 public static HyphenationTree getHyphenationTree(InputSource hyphenationSource)
 {
     var tree = new HyphenationTree();
     tree.loadPatterns(hyphenationSource);
     return tree;
 }
示例#52
0
 public virtual void OnToolHeld(InputSource inputSource)
 {
     IsHeld = true;
 }
示例#53
0
 //throws IOException, SAXException
 /**
  * Parse an XML document.
  *
  * @param input An input source for the document.
  * @exception java.io.IOException If there is a problem reading
  *            the raw content of the document.
  * @exception SAXException If there is a problem
  *            processing the document.
  * @see #parse(java.lang.String)
  * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
  */
 public void parse(InputSource input)
 {
     if (parsing)
     {
         throw new SAXException("Parser is already in use");
     }
     setupParser();
     parsing = true;
     try
     {
         parser.parse(input);
     }
     finally
     {
         parsing = false;
     }
     parsing = false;
 }
示例#54
0
 public virtual void OnToolDropped(InputSource inputSource)
 {
     IsHeld = false;
 }
示例#55
0
            public void run()
            {
                note.setFileName(file.AbsolutePath);
                // the note guid is not stored in the xml but in the filename
                note.setGuid(file.Name.Replace(".note", ""));

                // Try reading the file first
                string contents = "";
                try {
                    contents = readFile(file,buffer);
                } catch (IOException e) {
                    e.PrintStackTrace();
                    TLog.w(TAG, "Something went wrong trying to read the note");
                    SendMessage(PARSING_FAILED, ErrorList.createError(note, e));
                    onWorkDone();
                    return;
                }

                try {
                    // Parsing
                    // XML
                    // Get a SAXParser from the SAXPArserFactory
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp = spf.newSAXParser();

                    // Get the XMLReader of the SAXParser we created
                    XMLReader xr = sp.getXMLReader();

                    // Create a new ContentHandler, send it this note to fill and apply it to the XML-Reader
                    NoteHandler xmlHandler = new NoteHandler(note);
                    xr.setContentHandler(xmlHandler);

                    // Create the proper input source
                    StringReader sr = new StringReader(contents);
                    InputSource inputSource = new InputSource(sr);

                    TLog.d(TAG, "parsing note. filename: {0}", file.Name());
                    xr.parse(inputSource);

                // TODO wrap and throw a new exception here
                } catch (System.Exception e) {
                    e.PrintStackTrace();
                    if(e as TimeFormatException) TLog.e(TAG, "Problem parsing the note's date and time");
                    SendMessage(PARSING_FAILED, ErrorList.createErrorWithContents(note, e, contents));
                    onWorkDone();
                    return;
                }

                // FIXME here we are re-reading the whole note just to grab note-content out, there is probably a better way to do this (I'm talking to you xmlpull.org!)
                Matcher m = note_content.Matcher(contents);
                if (m.Find()) {
                    note.setXmlContent(NoteManager.stripTitleFromContent(m.Group(1),note.getTitle()));
                } else {
                    TLog.w(TAG, "Something went wrong trying to grab the note-content out of a note");
                    SendMessage(PARSING_FAILED, ErrorList.createErrorWithContents(note, "Something went wrong trying to grab the note-content out of a note", contents));
                    onWorkDone();
                    return;
                }

                syncableNotes.add(note);
                onWorkDone();
            }
示例#56
0
 protected abstract void UpdateTool(InputSource inputSource);
 public PointerDeviceEventArgs( int x, int y, ButtonInfo buttonInfo, string extraInfo, InputSource source )
 {
     X = x;
     Y = y;
     Source = source;
     ExtraInfo = extraInfo;
     ButtonInfo = buttonInfo;
 }
示例#58
0
 public DefaultInputSourceManager()
 {
     keyboardSource = new RealKeyBoard();
     activeSource   = keyboardSource;
     defaultSource  = keyboardSource;
 }
示例#59
0
 public void setRegularSource(InputSource inputSource)
 {
     defaultSource = inputSource;
 }
 public void SetInputSource(InputSource newSource)
 {
     Source = newSource;
 }