Beispiel #1
0
        public Dinner(IDinnerRepository repo, IInputFilter filter)
        {
            CheckIfValidParameters(repo, filter);

            this.repo = repo;
            this.filter = filter;
        }
Beispiel #2
0
 private static void CheckIfValidParameters(IDinnerRepository repo, IInputFilter filter)
 {
     if (repo == null)
         throw new ArgumentNullException("Needs a valid dinner repository");
     if (filter == null)
         throw new ArgumentNullException("Needs a valid input filter");
 }
Beispiel #3
0
        private static IInputFilter GetTypeInputFilter(Type type)
        {
            IInputFilter filter = null;

            typeFilters.TryGetValue(type, out filter);
            return(filter);
        }
Beispiel #4
0
        private void OnPresence(S22.Xmpp.Im.Presence presence)
        {
            this.IsHasRosterOnline = true;
            foreach (XmppExtension extension in this.extensions)
            {
                IInputFilter <S22.Xmpp.Im.Presence> filter = extension as IInputFilter <S22.Xmpp.Im.Presence>;
                if ((filter != null) && filter.Input(presence))
                {
                    return;
                }
            }
            switch (presence.Type)
            {
            case PresenceType.Available:
            case PresenceType.Unavailable:
                this.ProcessStatusNotification(presence);
                break;

            case PresenceType.Subscribe:
                this.ProcessSubscriptionRequest(presence);
                break;

            case PresenceType.Subscribed:
            case PresenceType.Unsubscribed:
                this.ProcessSubscriptionResult(presence);
                break;

            case PresenceType.Unsubscribe:
                this.ProcessUnsubscribeRequest(presence);
                break;
            }
        }
Beispiel #5
0
        public void Add(string @switch, string parameter)
        {
            IInputFilter inputFilter = _knownInputFilters[@switch];

            inputFilter.Parameter = parameter;
            _filters.Add(inputFilter);
        }
Beispiel #6
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            // Handle presses on the action bar items
            try
            {
                switch (item.ItemId)
                {
                case Resource.Id.action_settings:
                    Intent i = new Intent(this, typeof(SettingsActivity));
                    StartActivityForResult(i, SETTINGS_ACTIVITY_CODE);
                    return(true);

                case Resource.Id.action_goto:
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("Go To ... %");
                    EditText inputGoTo = new EditText(this);
                    inputGoTo.InputType = InputTypes.ClassNumber;
                    IInputFilter[] fa = new IInputFilter[1];
                    fa[0] = new InputFilterLengthFilter(2);
                    inputGoTo.SetFilters(fa);
                    inputGoTo.Text    = Convert.ToString((int)(Math.Min(linesRecyclerView.progress * 100, 99)));
                    inputGoTo.Gravity = GravityFlags.Center;
                    inputGoTo.SetSelection(inputGoTo.Text.Length);
                    builder.SetView(inputGoTo);
                    builder.SetPositiveButton("Go", (sender, e) =>
                    {
                        int newPercent = 0;

                        try
                        {
                            newPercent = Math.Max(0, Math.Min(int.Parse(inputGoTo.Text.ToString()), 100));
                            int newPos = (int)Math.Round((double)textLen * newPercent / 100);
                            Annotate(newPos);
                            ((AlertDialog)sender).Dismiss();
                        }
                        catch (System.FormatException)
                        {
                            Toast.MakeText(this, "Invalid percent number", ToastLength.Long).Show();
                        }
                    });
                    builder.SetNegativeButton("Cancel", (sender, e) =>
                    {
                        ((AlertDialog)sender).Cancel();
                    });

                    AlertDialog dialog = builder.Create();
                    dialog.Window.SetSoftInputMode(SoftInput.StateVisible);

                    dialog.Show();
                    break;
                }
            }
            catch (Exception e)
            {
                Toast.MakeText(this, "Error: " + e.Message, ToastLength.Long).Show();
            }

            return(false);
        }
Beispiel #7
0
        //////////////////////////////////////////////////////////////////////////////////////////////////
        // Helper methods
        //////////////////////////////////////////////////////////////////////////////////////////////////

        protected void AddWillChangeDelegate(EditText editText, Func <string, bool> willChangeDelegate)
        {
            var oldFilters = editText.GetFilters();
            var newFilters = new IInputFilter[oldFilters.Length + 1];

            newFilters[newFilters.Length - 1] = new DelegatedInputFilter(willChangeDelegate);
            editText.SetFilters(newFilters);
        }
Beispiel #8
0
        private void SetDefaultAttributes()
        {
            SetSingleLine(true);
            InputType = InputTypes.ClassNumber;
            var filters    = GetFilters();
            var newFilters = new IInputFilter[filters.Length + 1];

            filters.CopyTo(newFilters, 0);
            var lengthFilter = new InputFilterLengthFilter(MaxCharLengthWithSpaces);

            newFilters[newFilters.Length - 1] = lengthFilter;
            SetFilters(newFilters);
        }
Beispiel #9
0
        public void Play()
        {
            Debug.WriteLine("PL:M: Play");

            if (String.IsNullOrWhiteSpace(CurrentMedia))
            {
                throw new InvalidOperationException("Media Source is not specified.");
            }

            Action playAction;

            if (State == PlaybackState.Playing || State == PlaybackState.Pausing)
            {
                return;
            }
            else if (State == PlaybackState.Paused)
            {
                playAction = new Action(() =>
                {
                    m_outputFilter.Play();
                    State = PlaybackState.Playing;
                });
            }
            else// if (State == State.Stopped)
            {
                playAction = new Action(() =>
                {
                    m_pipeline = new Pipeline();

                    m_inputFilter             = new FileSourceFilter();
                    m_inputFilter.MediaSource = this.CurrentMedia;

                    m_outputFilter = new WaveSinkFilter();
                    m_outputFilter.PlaybackStopped += M_outputFilter_Stopped;

                    //m_pipeline.AddFilter(m_inputFilter, 0);
                    //m_pipeline.AddFilter(m_outputFilter, 1);
                    m_pipeline.AddInputOutputFilters(m_inputFilter, m_outputFilter);

                    m_positionAtLastPause = 0.0;

                    NotifyPropertyChanged(nameof(Length));

                    m_outputFilter.Play();
                    State = PlaybackState.Playing;
                });
            }

            m_threadDispatcher.Invoke(playAction);
        }
        public void SetFilters_WhenCalledWithMultipleFilters_AppliesAllFilters()
        {
            EditText editText = new EditText(MainActivity.Current);

            var filter1 = new MockInputFilter();
            var filter2 = new MockInputFilter();
            var filter3 = new MockInputFilter();
            var filters = new IInputFilter[] { filter1, filter2, filter3 };

            editText.SetFilters(filter1, filter2, filter3);

            var appliedFilters = editText.GetFilters();

            Assert.Equal(filters, appliedFilters);
        }
Beispiel #11
0
 private void OnMessage(S22.Xmpp.Im.Message message)
 {
     foreach (XmppExtension extension in this.extensions)
     {
         IInputFilter <S22.Xmpp.Im.Message> filter = extension as IInputFilter <S22.Xmpp.Im.Message>;
         if ((filter != null) && filter.Input(message))
         {
             return;
         }
     }
     if (message.Data["body"] != null)
     {
         this.Message.Raise <S22.Xmpp.Im.MessageEventArgs>(this, new S22.Xmpp.Im.MessageEventArgs(message.From, message));
     }
 }
        public void SetFilters_WhenCalledWithMultipleFiltersWithNullAndDuplicates_AppliesAllFilters()
        {
            EditText editText = new EditText(MainActivity.Current);

            var filter1    = new MockInputFilter();
            var filter2    = new MockInputFilter();
            var filter3    = new MockInputFilter();
            var nullFilter = null as IInputFilter;
            var filters    = new IInputFilter[] { filter1, filter2, nullFilter, filter3, filter2, nullFilter, filter1, filter2 };

            editText.SetFilters(filter1, filter2, nullFilter, filter3, filter2, nullFilter, filter1, filter2);

            var appliedFilters = editText.GetFilters();

            Assert.Equal(filters, appliedFilters);
        }
        private void ApplyInputFilters(int maxLength)
        {
            IInputFilter[] filterArray;

            if (maxLength > 0)
            {
                filterArray = new IInputFilter[1];

                filterArray[0] = new InputFilterLengthFilter(maxLength);
            }
            else
            {
                filterArray = new IInputFilter[0];
            }

            ((NativeEditText)this.NativeUIElement).SetFilters(filterArray);
        }
Beispiel #14
0
        private void OnIq(Iq iq)
        {
            foreach (XmppExtension extension in this.extensions)
            {
                IInputFilter <Iq> filter = extension as IInputFilter <Iq>;
                if ((filter != null) && filter.Input(iq))
                {
                    return;
                }
            }
            XmlElement element  = iq.Data["query"];
            XmlElement element2 = iq.Data["b"];

            if (element != null)
            {
                string namespaceURI = element.NamespaceURI;
                if ((namespaceURI != null) && (namespaceURI == "jabber:iq:roster"))
                {
                    CommonConfig.Logger.WriteInfo(iq.ToString());
                    this.ProcessRosterIq(iq);
                    return;
                }
            }
            else if (element2 != null)
            {
                CommonConfig.Logger.WriteInfo("收到捷顺beat心跳包");
                this.ProcessBeatIq(iq);
            }
            else
            {
                if (iq.Data["dreq"] != null)
                {
                    CommonConfig.Logger.WriteInfo("IM层收到iq请求消息");
                    this.IqRequestEvents.Raise <S22.Xmpp.Im.IqEventArgs>(this, new S22.Xmpp.Im.IqEventArgs(iq.From, iq));
                    return;
                }
                if (iq.Data["dres"] != null)
                {
                    this.IqResponseEvents.Raise <S22.Xmpp.Im.IqEventArgs>(this, new S22.Xmpp.Im.IqEventArgs(iq.From, iq));
                    return;
                }
            }
            this.IqError(iq, ErrorType.Cancel, ErrorCondition.FeatureNotImplemented, null, new XmlElement[0]);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> ev)
        {
            base.OnElementChanged(ev);

            if (this.Control == null)
            {
                return;
            }

            this.UpdateGravity();
            this.UpdatePadding();

            this.Control.SetIncludeFontPadding(true);

            //make the cursor colour inherit from the text colour
            IntPtr IntPtrtextViewClass        = JNIEnv.FindClass(typeof(TextView));
            IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");

            JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, 0);

            var background = new GradientDrawable();

            background.SetStroke(0, global::Xamarin.Forms.Color.Transparent.ToAndroid());

            this.Control.SetBackground(background);

            if (this.emojiInputFilter == null)
            {
                this.emojiInputFilter = new EmojiInputFilter();
            }
            this.Control.SetFilters(new IInputFilter[] { this.emojiInputFilter });

            if (this.Element == null)
            {
                return;
            }

            float textSize = 12.0f / Resources.DisplayMetrics.Density * (float)Resources.DisplayMetrics.WidthPixels / 480.0f * (this.Element as ICLForms).TextScale;

            this.Control.TextSize = textSize;
        }
        void IniEditText(EditText editText, TextView txtDescription,
                         string descricao, int minCaract, int maxCaract)
        {
            editText.SetTextColor(ContextCompat.GetColorStateList(context, Resource.Color.black));
            editText.SetHintTextColor(ContextCompat.GetColorStateList(context, Resource.Color.black));
            editText.BackgroundTintList = ContextCompat.GetColorStateList(context, Resource.Color.black);
            editText.ImeOptions         = ImeAction.Next;
            editText.SetTextSize(ComplexUnitType.Sp, 20);
            editText.SetEms(10);
            txtDescription.Text = descricao;
            if (maxCaract > 0)
            {
                IInputFilter[] filterArray = new IInputFilter[1];
                filterArray[0] = new InputFilterLengthFilter(maxCaract);
                editText.SetFilters(filterArray);
            }
            if (minCaract > 0)
            {
                txtDescription.Text           += " *";
                editText.OnFocusChangeListener = new OnFocusChange(() =>
                {
                    if (minCaract > editText.Text.Length && editText.Text.Length > 0)
                    {
                        editText.SetTextColor(ContextCompat.GetColorStateList(context,
                                                                              Resource.Color.red));

                        editText.SetHintTextColor(ContextCompat.GetColorStateList(context,
                                                                                  Resource.Color.red));
                    }
                    else
                    {
                        editText.SetTextColor(ContextCompat.GetColorStateList(context,
                                                                              Resource.Color.black));

                        editText.SetHintTextColor(ContextCompat.GetColorStateList(context,
                                                                                  Resource.Color.black));
                    }
                });
            }
        }
Beispiel #17
0
        private void ApplyInputFilters(bool isReadOnly, int maxLength)
        {
            IInputFilter[] filterArray;
            if (maxLength > 0)
            {
                if (isReadOnly)
                {
                    filterArray    = new IInputFilter[2];
                    filterArray[1] = this.readOnlyFilter;
                }
                else
                {
                    filterArray = new IInputFilter[1];
                }
                filterArray[0] = new InputFilterLengthFilter(maxLength);
            }
            else
            {
                if (isReadOnly)
                {
                    filterArray    = new IInputFilter[1];
                    filterArray[0] = this.readOnlyFilter;

                    // It is unclear, what to with the background in readonly mode
                    // Android.Graphics.Drawables.StateListDrawable draw = (Android.Graphics.Drawables.StateListDrawable)Resources.System.GetDrawable(Android.Resource.Drawable.EditBoxBackground);
                    // draw.SetState(new int[1] { Android.Resource.Attribute.DisabledAlpha });
                    // Android.Graphics.Drawables.Drawable draw2 = draw.Current;
                    // ((NativeEditText)this.NativeUIElement).SetBackgroundDrawable(draw2);
                }
                else
                {
                    filterArray = new IInputFilter[0];

                    // It is unclear, what to with the background in readonly mode
                    // ((NativeEditText)this.NativeUIElement).SetBackgroundResource(Android.Resource.Drawable.EditBoxBackground);
                }
            }
            ((NativeEditText)this.NativeUIElement).SetFilters(filterArray);
        }
Beispiel #18
0
        public void AddInputOutputFilters(IInputFilter inputFilter, IOutputFilter outputFilter)
        {
            if (inputFilter == null)
            {
                throw new ArgumentNullException(nameof(inputFilter));
            }
            if (outputFilter == null)
            {
                throw new ArgumentNullException(nameof(outputFilter));
            }


            m_inputFilter  = inputFilter;
            m_outputFilter = outputFilter;


            m_inputFilter.Open();

            m_outputFilter.InSample      = m_inputFilter.OutSample;
            m_outputFilter.DataRequired += Filter;
            m_outputFilter.Open();
        }
Beispiel #19
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var filters = new IInputFilter[] { new CustomInputFilter() };

            var view = SomeTextBox.FindFirstChild <TextBoxView>();

            if (view != null)
            {
                SetFilter(view);
            }
            else
            {
                SomeTextBox.Loaded += (s, e) =>
                {
                    SomeTextBox.ApplyTemplate();
                    SomeTextBox.FindFirstChild <TextBoxView>()?.Apply(SetFilter);
                };
            }

            void SetFilter(TextBoxView tbv) => tbv.SetFilters(new IInputFilter[] { new CustomInputFilter() });
        }
Beispiel #20
0
 public static void RegisterTypeInputFilter(Type type, IInputFilter inputFilter)
 {
     typeFilters.Add(type, inputFilter);
 }
 public IFlowBuilder WhenReceived(IInputFilter filter, IOutputResponse response, IFlowBuilder flow = null)
 {
     return(this);
 }
Beispiel #22
0
        private void ApplyInputFilters(int maxLength)
        {
            IInputFilter[] filterArray;

            if (maxLength > 0)
            {

                filterArray = new IInputFilter[1];

                filterArray[0] = new InputFilterLengthFilter(maxLength);
            }
            else
            {
                filterArray = new IInputFilter[0];
            }

            ((NativeEditText)this.NativeUIElement).SetFilters(filterArray);
        }
Beispiel #23
0
 public void Add(DependencyObject obj, IInputFilter filter)
 {
     jointFilters.Add(new KeyValuePair <DependencyObject, IInputFilter>(obj, filter));
 }
Beispiel #24
0
 public static void SetInputFilter(DependencyObject obj, IInputFilter value)
 {
     obj.SetValue(InputFilterProperty, value);
 }
 public void Add(IInputFilter inputFilter)
 {
     _filters.Add(inputFilter);
 }
Beispiel #26
0
 public void Add(IInputFilter inputFilter)
 {
     _filters.Add(inputFilter);
 }