void Start()
    {
        hub = GameObject.Find("hub").GetComponent<Hub>();

        Looper =  GetComponent<Looper>();

        startZone = hub.player.GetComponent<Looper>().LoopCounter;
        GameObject Projection = new GameObject ();
        Clone_Props = Projection.AddComponent<CloneProperties>();
        Projection.AddComponent <MeshRenderer> ();
        Projection.renderer.material = renderer.material;
        Mesh mesh = GetComponent<MeshFilter> ().mesh;
        Projection.AddComponent<MeshFilter> ().mesh = mesh;
        renderer.enabled=false;;
        Projection.transform.localScale = transform.localScale;
        Projection.name = this.gameObject.name + "_Projection";
        Clone_Props.Original = transform;
        Clone_Props.self = Projection;
        renderer.enabled=false;
        Vector3 loop = Looper.LoopCounter;
        if(Clone_Props!=null){
            Vector3 Offset = loop  - (hub.player.GetComponent<Looper>().LoopCounter-startZone);
            Clone_Props.self.transform.position = hub.LaticeBox.transform.localToWorldMatrix.MultiplyPoint (Offset + hub.LaticeBox.transform.InverseTransformPoint (transform.position));
        }
    }
		internal MotionActivityNotification(Looper looper, Smotion motion)
		{
			// TODO Auto-generated constructor stub
			mActivityNotification = new SmotionActivityNotification(looper, motion);
			mFilter = null;
			initialize();
		}
 public SimplifierHandler(MapView mapView, Looper looper, IList<Point> points, IList<GeoPoint> data , int epsilon )
 {
     this.mapView = mapView;
     _points = points;
     _data = data;
     _epsilon = epsilon;
 }
Beispiel #4
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.systemControls = SystemMediaTransportControls.GetForCurrentView();
            this.systemControls.ButtonPressed += systemControls_ButtonPressed;
            this.systemControls.IsPlayEnabled = true;
            this.systemControls.IsPauseEnabled = true;

            this.renderer = await AudioRenderer.CreateAsync();

            var rootPath = Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\Sounds\\";
            this.drumPad = new DrumPad();
            this.drumPad.SetDrumSound(DrumKind.Bass, rootPath + "Drum-Bass.wav");
            this.drumPad.SetDrumSound(DrumKind.Snare, rootPath + "Drum-Snare.wav");
            this.drumPad.SetDrumSound(DrumKind.Shaker, rootPath + "Drum-Shaker.wav");
            this.drumPad.SetDrumSound(DrumKind.ClosedHiHat, rootPath + "Drum-Closed-Hi-Hat.wav");
            this.drumPad.SetDrumSound(DrumKind.Cowbell, rootPath + "Cowbell.wav");
            this.drumPad.SetDrumSound(DrumKind.OpenHiHat, rootPath + "Drum-Open-Hi-Hat.wav");
            this.drumPad.SetDrumSound(DrumKind.RideCymbal, rootPath + "Drum-Ride-Cymbal.wav");
            this.drumPad.SetDrumSound(DrumKind.FloorTom, rootPath + "developer_loud.wav");
            this.drumPad.SetDrumSound(DrumKind.HighTom, rootPath + "satya_fantastic.wav");

            this.oscillator = new Oscillator();
            this.looper = new Looper();
            this.demultiplexer = new AudioDemultiplexer();

            this.looper.ListenTo(this.drumPad);
            this.demultiplexer.ListenTo(this.looper);
            this.demultiplexer.ListenTo(this.oscillator);
            this.renderer.ListenTo(this.demultiplexer);

            Play();
        }
Beispiel #5
0
	void Start () {
		
		loop=gameObject.GetComponentInChildren<Looper>();


		size = renderer.bounds.size;



		pos=new Vector3(this.transform.position.x,this.transform.position.y,-1220);



		GameObject instance = Instantiate(first, pos, transform.rotation) as GameObject;


	}
    void Start()
    {
        hub = GameObject.Find("hub").GetComponent<Hub>();
        latice = hub.latice;
        Looper =  GetComponent<Looper>();

        zoneController = hub.player.GetComponent<ZoneController>();
        startZone = hub.player.GetComponent<Looper>().LoopCounter;
        GameObject Projection = new GameObject ();
        Clone_Props = new CloneProperties ();
        Projection.AddComponent <MeshRenderer> ();
        Projection.renderer.material = renderer.material;
        Mesh mesh = GetComponent<MeshFilter> ().mesh;
        Projection.AddComponent<MeshFilter> ().mesh = mesh;
        renderer.enabled=false;;
        Projection.transform.localScale = transform.localScale;
        Projection.name = this.gameObject.name + "_Projection";
        Clone_Props.Original = transform;
        Clone_Props.self = Projection;
    }
		public virtual void Run (Action<ActionArguments, ActionResult> callback, Looper looper)
		{
			Run (new ActionCompletionCallback (callback), looper);
		}
Beispiel #8
0
 public ServiceHandler(BikrActivityService svc, Looper looper)
     : base(looper)
 {
     this.svc = svc;
 }
Beispiel #9
0
        protected override void OnResume()
        {
            base.OnResume();
            var UserInfoo = DataBase.MEMBER_DATA_GETIR();

            if (UserInfoo.Count > 0)
            {
                if (FusedLocationProviderClient1 != null)
                {
                    FusedLocationProviderClient1.RequestLocationUpdates(LocationRequest1, LocationCallback1, Looper.MyLooper());
                }
            }
        }
Beispiel #10
0
 private bool GetHasThreadAccess() => Looper.MyLooper() == Android.OS.Looper.MainLooper;
        public override void OnCreate()
        {
            // TODO: It would be nice to have an option to hold a partial wakelock
            // during processing, and to have a static startService(Context, Intent)
            // method that would launch the service & hand off a wakelock.

            base.OnCreate();
            HandlerThread thread = new HandlerThread("IntentService[" + mName + "]");
            thread.Start();

            mServiceLooper = thread.Looper;
            mServiceHandler = new ServiceHandler(mServiceLooper, this);
        }
		internal MotionActivity(Looper looper, Smotion motion)
		{
			mActivity = new SmotionActivity(looper, motion);
			initialize();
		}
Beispiel #13
0
 /// <summary>
 ///         初始化<see cref="Receiver{T}" />的新实例.
 /// </summary>
 /// <param name="parent">上级对象</param>
 /// <param name="id">标识</param>
 protected Receiver(IdentityObject parent, string id = "接收器")
     : base(parent, id)
 {
     ReceiveLooper = new Looper(this, "接收循环", Enqueue);
 }
Beispiel #14
0
        static void Main(string[] args)
        {
            var looper = new Looper();

            looper.Loop();
        }
Beispiel #15
0
        /// <summary>
        /// 处理未处理异常
        /// </summary>
        /// <param name="e"></param>
        private void UnhandledExceptionHandler(Exception ex, RaiseThrowableEventArgs e)
        {
            #region 处理程序(记录 异常、设备信息、时间等重要信息)

            try
            {
                string errorMsg = ex.GetFullInfo();
                System.Diagnostics.Debug.WriteLine(errorMsg);

                #region (选做) 信息上传到服务器

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("账号信息:");

                if (Client.Common.StaticInfo.CurrentUser == null)
                {
                    Client.Common.StaticInfo.CurrentUser = new DL.Model.User()
                    {
                        ID           = Guid.Empty,
                        LoginAccount = "D3333",
                        UserName     = "******",
                        DeviceInfo   = Util.JsonUtils.SerializeObject(Common.StaticInfo.DeviceInfo)
                    };
                }

                sb.AppendLine(Client.Common.StaticInfo.CurrentUser.ID.ToString());
                sb.AppendLine(Client.Common.StaticInfo.CurrentUser.LoginAccount);
                sb.AppendLine(Client.Common.StaticInfo.CurrentUser.UserName);
                sb.AppendLine();
                sb.AppendLine("设备信息:");
                sb.AppendLine(Client.Common.StaticInfo.DeviceInfo.ToString());
                sb.AppendLine();
                sb.AppendLine("异常信息:");
                sb.AppendLine(errorMsg);

                Android.Util.Log.Error("UnhandledEx", errorMsg);

                new WebService().CollectUnhandleException
                (
                    sb.ToString(),
                    Client.Common.StaticInfo.CurrentUser
                );

                #endregion

                Android.Util.Log.Error("UnhandledEx", errorMsg);

                Util.LogUtils.Log
                (
                    content: $"AndroidEnvironment.UnhandledExceptionRaiser\r\n{errorMsg}",
                    baseDirectory: mLogDirectory
                );
            }
            catch (Exception ex2)
            {
                string msg = "{0}".FormatWith(ex2.GetFullInfo());
                System.Diagnostics.Debug.WriteLine(msg);
            }

            #endregion

            Xamarin.Essentials.MainThread.BeginInvokeOnMainThread(() =>
            {
                Looper.Prepare();
                Toast.MakeText(this, "程序捕获到异常。", ToastLength.Long).Show();
                Looper.Loop();
            });

            e.Handled = true;
        }
Beispiel #16
0
        /// <summary>
        /// Reads the current block and converts the block type to the specific model type found in the model tag.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="objectType"></param>
        /// <param name="existingValue"></param>
        /// <param name="serializer"></param>
        /// <returns></returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jsonObject = JObject.Load(reader);
            Block   modelBlock;

            if (objectType == typeof(Block))
            {
                modelBlock = default(Block);
                string modelType = (string)jsonObject["@model"] ?? string.Empty;
                switch (modelType)
                {
                    #region Amp
                case ConstAmp.MODEL_ARCHETYPE_CLEAN:
                    modelBlock = new ArchetypeClean();
                    break;

                case ConstAmp.MODEL_ARCHETYPE_LEAD:
                    modelBlock = new ArchetypeLead();
                    break;

                case ConstAmp.MODEL_ANGL_METEOR:
                    modelBlock = new ANGLMeteor();
                    break;

                case ConstAmp.MODEL_GERMAN_MAHADEVA:
                    modelBlock = new GermanMahadeva();
                    break;

                case ConstAmp.MODEL_JAZZ_RIVET_120:
                    modelBlock = new JazzRivet120();
                    break;

                case ConstAmp.MODEL_US_SMALL_TWEED:
                    modelBlock = new USSmallTweed();
                    break;

                case ConstAmp.MODEL_GERMAN_UBERSONIC:
                    modelBlock = new GermanUbersonic();
                    break;

                case ConstAmp.MODEL_MATCHSTICK_CH1:
                    modelBlock = new MatchstickCh1();
                    break;

                case ConstAmp.MODEL_MATCHSTICK_CH2:
                    modelBlock = new MatchstickCh2();
                    break;

                case ConstAmp.MODEL_MATCHSTICK_JUMP:
                    modelBlock = new MatchstickJump();
                    break;

                case ConstAmp.MODEL_ESSEX_A15:
                    modelBlock = new EssexA15();
                    break;

                case ConstAmp.MODEL_ESSEX_A30:
                    modelBlock = new EssexA30();
                    break;

                case ConstAmp.MODEL_WHO_WATT_100:
                    modelBlock = new WhoWatt100();
                    break;

                case ConstAmp.MODEL_SOUP_PRO:
                    modelBlock = new SoupPro();
                    break;

                case ConstAmp.MODEL_STONE_AGE_185:
                    modelBlock = new StoneAge185();
                    break;

                case ConstAmp.MODEL_VOLTAGE_QUEEN:
                    modelBlock = new VoltageQueen();
                    break;

                case ConstAmp.DISP_TWEED_BLUES_NRM:
                    modelBlock = new TweedBluesNrm();
                    break;

                case ConstAmp.MODEL_TWEED_BLUES_BRT:
                    modelBlock = new TweedBluesBrt();
                    break;

                case ConstAmp.MODEL_US_DELUXE_NRM:
                    modelBlock = new USDeluxeNrm();
                    break;

                case ConstAmp.MODEL_US_DELUXE_VIB:
                    modelBlock = new USDeluxeVib();
                    break;

                case ConstAmp.MODEL_US_DOUBLE_NRM:
                    modelBlock = new USDoubleNrm();
                    break;

                case ConstAmp.MODEL_US_DOUBLE_VIB:
                    modelBlock = new USDoubleVib();
                    break;

                case ConstAmp.MODEL_MAIL_ORDER_TWIN:
                    modelBlock = new MailOrderTwin();
                    break;

                case ConstAmp.MODEL_DIVIDED_DUO:
                    modelBlock = new DividedDuo();
                    break;

                case ConstAmp.MODEL_INTERSTATE_ZED:
                    modelBlock = new InterstateZed();
                    break;

                case ConstAmp.MODEL_DERAILED_INGRID:
                    modelBlock = new DerailedIngrid();
                    break;

                case ConstAmp.MODEL_MANDARIN_80:
                    modelBlock = new Mandarin80();
                    break;

                case ConstAmp.MODEL_CALI_RECTIFIRE:
                    modelBlock = new CaliRectifire();
                    break;

                case ConstAmp.DISP_CALI_IV_LEAD:
                    modelBlock = new CaliIVLead();
                    break;

                case ConstAmp.MODEL_CALI_IV_R1:
                    modelBlock = new CaliIVR1();
                    break;

                case ConstAmp.MODEL_CALI_IV_R2:
                    modelBlock = new CaliIVR2();
                    break;

                case ConstAmp.MODEL_CALI_TEXAS_CH1:
                    modelBlock = new CaliTexasCh1();
                    break;

                case ConstAmp.MODEL_CALI_TEXAS_CH2:
                    modelBlock = new CaliTexasCh2();
                    break;

                case ConstAmp.MODEL_BRIT_PLEXI_BRT:
                    modelBlock = new BritPlexiBrt();
                    break;

                case ConstAmp.MODEL_BRIT_PLEXI_NRM:
                    modelBlock = new BritPlexiNrm();
                    break;

                case ConstAmp.MODEL_PLACATER_DIRTY:
                    modelBlock = new PlacaterDirty();
                    break;

                case ConstAmp.MODEL_PLACATER_CLEAN:
                    modelBlock = new PlacaterClean();
                    break;

                case ConstAmp.MODEL_BRIT_2204:
                    modelBlock = new Brit2204();
                    break;

                case ConstAmp.MODEL_BRIT_J45_NRM:
                    modelBlock = new BritJ45Nrm();
                    break;

                case ConstAmp.MODEL_BRIT_J45_BRT:
                    modelBlock = new BritJ45Brt();
                    break;

                case ConstAmp.MODEL_BRIT_PLEXI_JUMP:
                    modelBlock = new BritPlexiJump();
                    break;

                case ConstAmp.MODEL_BRIT_TREM_NRM:
                    modelBlock = new BritTremNrm();
                    break;

                case ConstAmp.MODEL_BRIT_TREM_BRT:
                    modelBlock = new BritTremBrt();
                    break;

                case ConstAmp.MODEL_BRIT_TREM_JUMP:
                    modelBlock = new BritTremJump();
                    break;

                case ConstAmp.MODEL_BRIT_P75_NRM:
                    modelBlock = new BritP75Nrm();
                    break;

                case ConstAmp.MODEL_BRIT_P75_BRT:
                    modelBlock = new BritPlexiBrt();
                    break;

                case ConstAmp.MODEL_SOLO_LEAD_CLEAN:
                    modelBlock = new SoloLeadClean();
                    break;

                case ConstAmp.MODEL_SOLO_LEAD_CRUNCH:
                    modelBlock = new SoloLeadCrunch();
                    break;

                case ConstAmp.MODEL_SOLO_LEAD_OD:
                    modelBlock = new SoloLeadOD();
                    break;

                case ConstAmp.MODEL_A30_FAWN_NRM:
                    modelBlock = new A30FawnNrm();
                    break;

                case ConstAmp.MODEL_A30_FAWN_BRT:
                    modelBlock = new A30FawnBrt();
                    break;

                case ConstAmp.MODEL_PV_PANAMA:
                    modelBlock = new PVPanama();
                    break;

                case ConstAmp.MODEL_CARTOGRAPHER:
                    modelBlock = new Cartographer();
                    break;

                case ConstAmp.MODEL_AGUA_51:
                    modelBlock = new Agua51();
                    break;

                case ConstAmp.MODEL_SV_BEAST_BRT:
                    modelBlock = new SVBeastBrt();
                    break;

                case ConstAmp.DISP_GCOUGAR_800:
                    modelBlock = new GCougar800();
                    break;

                case ConstAmp.DISP_DEL_SOL_300:
                    modelBlock = new DelSol300();
                    break;

                case ConstAmp.MODEL_LINE6_BADONK:
                    modelBlock = new Line6Badonk();
                    break;

                case ConstAmp.MODEL_LINE6_LITIGATOR:
                    modelBlock = new Line6Litigator();
                    break;

                case ConstAmp.MODEL_LINE6_FATALITY:
                    modelBlock = new Line6Fatality();
                    break;

                case ConstAmp.MODEL_LINE6_ELEKTRIK:
                    modelBlock = new Line6Elektrik();
                    break;

                case ConstAmp.MODEL_LINE6_DOOM:
                    modelBlock = new Line6Doom();
                    break;

                case ConstAmp.MODEL_LINE6_2204_MOD:
                    modelBlock = new Line62204Mod();
                    break;

                case ConstAmp.MODEL_LINE6_EPIC:
                    modelBlock = new Line6Epic();
                    break;

                case ConstAmp.MODEL_REVV_GEN_RED:
                    modelBlock = new RevvGenRed();
                    break;

                case ConstAmp.MODEL_FULLERTON_NRM:
                    modelBlock = new FullertonNrm();
                    break;

                case ConstAmp.MODEL_FULLERTON_BRT:
                    modelBlock = new FullertonBrt();
                    break;

                case ConstAmp.MODEL_FULLERTON_JUMP:
                    modelBlock = new FullertonJump();
                    break;

                case ConstAmp.MODEL_GRAMMATICO_NRM:
                    modelBlock = new GrammaticoNrm();
                    break;

                case ConstAmp.MODEL_GRAMMATICO_BRT:
                    modelBlock = new GrammaticoBrt();
                    break;

                case ConstAmp.MODEL_GRAMMATICO_JUMP:
                    modelBlock = new GrammaticoJump();
                    break;
                    #endregion Amp



                    #region Cab
                case ConstCab.MODEL_4X12_GREENBACK_20:
                    modelBlock = new Cab4x12Greenback20();
                    break;

                case ConstCab.MODEL_4X12_GREENBACK_25:
                    modelBlock = new Cab4x12Greenback25();
                    break;

                case ConstCab.MODEL_1X12_LEAD_80:
                    modelBlock = new Cab1x12Lead80();
                    break;

                case ConstCab.MODEL_1X12_MATCH_H30:
                    modelBlock = new Cab1x12MatchH30();
                    break;

                case ConstCab.MODEL_1X12_MATCH_G25:
                    modelBlock = new Cab1x12MatchG25();
                    break;

                case ConstCab.MODEL_1X12_BLUE_BELL:
                    modelBlock = new Cab1x12BlueBell();
                    break;

                case ConstCab.MODEL_4X12_WHO_WATT_100:
                    modelBlock = new Cab4x12WhoWatt100();
                    break;

                case ConstCab.MODEL_1X6X9_SOUP_PRO_ELLIPSE:
                    modelBlock = new Cab1x6x9SoupProEllipse();
                    break;

                case ConstCab.MODEL_1X12_FIELD_COIL:
                    modelBlock = new Cab1x12FieldCoil();
                    break;

                case ConstCab.MODEL_1X12_US_DELUXE:
                    modelBlock = new Cab1x12USDeluxe();
                    break;

                case ConstCab.MODEL_4X10_TWEED_P10R:
                    modelBlock = new Cab4x10TweedP10R();
                    break;

                case ConstCab.MODEL_2X12_DOUBLE_C12N:
                    modelBlock = new Cab2x12DoubleC12N();
                    break;

                case ConstCab.MODEL_2X12_MAIL_C12Q:
                    modelBlock = new Cab2x12MailC12Q();
                    break;

                case ConstCab.MODEL_1X12_CELEST_12H:
                    modelBlock = new Cab1x12Celest12H();
                    break;

                case ConstCab.MODEL_2X12_INTERSTATE:
                    modelBlock = new Cab2x12Interstate();
                    break;

                case ConstCab.MODEL_4X12_CALI_V30:
                    modelBlock = new Cab4X12CaliV30();
                    break;

                case ConstCab.MODEL_4X12_SOLO_LEAD_EM:
                    modelBlock = new Cab4x12SoloLeadEM();
                    break;

                case ConstCab.MODEL_2X12_BLUE_BELL:
                    modelBlock = new Cab2x12BlueBell();
                    break;

                case ConstCab.MODEL_2X12_SILVER_BELL:
                    modelBlock = new Cab2x12SilverBell();
                    break;

                case ConstCab.MODEL_4X12_UBER_V30:
                    modelBlock = new Cab4x12UberV30();
                    break;

                case ConstCab.MODEL_4X12_BLACKBACK_30:
                    modelBlock = new Cab4x12Blackback30();
                    break;

                case ConstCab.MODEL_4X12_1960_T75:
                    modelBlock = new Cab4x121960T75();
                    break;

                case ConstCab.MODEL_8X10_SV_BEAST:
                    modelBlock = new Cab8x10SVBeast();
                    break;

                case ConstCab.MODEL_6X10_CALI_POWER:
                    modelBlock = new Cab6x10CaliPower();
                    break;
                    #endregion Cab



                    #region Delay
                case ConstDelay.MODEL_ADRIATIC_DELAY:
                    modelBlock = new AdriaticDelay();
                    break;

                case ConstDelay.MODEL_ADRIATIC_SWELL:
                    modelBlock = new AdriaticSwell();
                    break;

                case ConstDelay.MODEL_DUAL_DELAY:
                    modelBlock = new DualDelay();
                    break;

                case ConstDelay.MODEL_VINTAGE_DIGITAL_V2:
                    modelBlock = new VintageDigitalV2();
                    break;

                case ConstDelay.MODEL_SIMPLE_DELAY:
                    modelBlock = new SimpleDelay();
                    break;

                case ConstDelay.MODEL_TRANSISTOR_TAPE:
                    modelBlock = new TransistorTape();
                    break;

                case ConstDelay.MODEL_DELAY_COSMOS_ECHO:
                    modelBlock = new CosmosEcho();
                    break;

                case ConstDelay.MODEL_DELAY_PITCH:
                    modelBlock = new DelayPitch();
                    break;

                case ConstDelay.MODEL_HARMONY_DELAY:
                    modelBlock = new HarmonyDelay();
                    break;

                case ConstDelay.MODEL_ELEPHANT_MAN:
                    modelBlock = new ElephantMan();
                    break;

                case ConstDelay.MODEL_BUCKET_BRIGADE:
                    modelBlock = new BucketBrigade();
                    break;

                case ConstDelay.MODEL_PING_PONG:
                    modelBlock = new PingPong();
                    break;

                case ConstDelay.MODEL_SWELL_VINTAGE_DIGITAL:
                    modelBlock = new SwellVintageDigital();
                    break;

                case ConstDelay.MODEL_DUCKED_DELAY:
                    modelBlock = new DuckedDelay();
                    break;

                case ConstDelay.MODEL_MOD_CHORUS_ECHO:
                    modelBlock = new ModChorusEcho();
                    break;

                case ConstDelay.MODEL_SWEEP_ECHO:
                    modelBlock = new SweepEcho();
                    break;

                case ConstDelay.MODEL_REVERSE_DELAY:
                    modelBlock = new ReverseDelay();
                    break;

                case ConstDelay.MODEL_DELAY_MULTI_PASS:
                    modelBlock = new MultiPass();
                    break;

                case ConstDelay.MODEL_LOW_RES:
                    modelBlock = new LowRes();
                    break;

                case ConstDelay.MODEL_MULTITAP_4:
                    modelBlock = new Multitap4();
                    break;

                case ConstDelay.MODEL_MULTITAP_6:
                    modelBlock = new Multitap6();
                    break;

                case ConstDelay.MODEL_DL4_PING_PONG:
                    modelBlock = new DL4PingPong();
                    break;

                case ConstDelay.MODEL_DYNAMIC_DELAY_STEREO:
                    modelBlock = new DynamicDelayStereo();
                    break;

                case ConstDelay.MODEL_STEREO_DELAY:
                    modelBlock = new StereoDelay();
                    break;

                case ConstDelay.MODEL_DL4_DIGITAL_DELAY:
                    modelBlock = new DL4DigitalDelay();
                    break;

                case ConstDelay.MODEL_DELAY_WITH_MOD:
                    modelBlock = new DelayWithMod();
                    break;

                case ConstDelay.MODEL_DL4_REVERSE_DELAY:
                    modelBlock = new DL4ReverseDelay();
                    break;

                case ConstDelay.MODEL_TUBE_ECHO_STEREO:
                    modelBlock = new TubeEchoStereo();
                    break;

                case ConstDelay.MODEL_TAPE_ECHO_STEREO:
                    modelBlock = new TapeEchoStereo();
                    break;

                case ConstDelay.MODEL_SWEEP_ECHO_STEREO:
                    modelBlock = new SweepEchoStereo();
                    break;

                case ConstDelay.MODEL_ECHO_PLATTER:
                    modelBlock = new EchoPlatter();
                    break;

                case ConstDelay.MODEL_ANALOG_DELAY:
                    modelBlock = new AnalogDelay();
                    break;

                case ConstDelay.MODEL_ANALOG_DELAY_MOD:
                    modelBlock = new AnalogDelayMod();
                    break;

                case ConstDelay.MODEL_AUTO_VOL_DELAY:
                    modelBlock = new AutoVolDelay();
                    break;

                case ConstDelay.MODEL_MULTIHEAD_DELAY:
                    modelBlock = new MultiheadDelay();
                    break;
                    #endregion Delay



                    #region Distortion
                case ConstDistortion.MODEL_ARBITRATOR_FUZZ:
                    modelBlock = new ArbitratorFuzz();
                    break;

                case ConstDistortion.MODEL_BIT_CRUSHER:
                    modelBlock = new BitCrusher();
                    break;

                case ConstDistortion.MODEL_SCREAM_808:
                    modelBlock = new Scream808();
                    break;

                case ConstDistortion.MODEL_COMPULSIVE_DRIVE:
                    modelBlock = new CompulsiveDrive();
                    break;

                case ConstDistortion.MODEL_CLAWTHORN_DRIVE:
                    modelBlock = new ClawthornDrive();
                    break;

                case ConstDistortion.MODEL_DEEZ_ONE_MOD:
                    modelBlock = new DeezOneMod();
                    break;

                case ConstDistortion.MODEL_DEEZ_ONE_VINTAGE:
                    modelBlock = new DeezOneVintage();
                    break;

                case ConstDistortion.MODEL_DERANGEDMASTER:
                    modelBlock = new DerangedMaster();
                    break;

                case ConstDistortion.MODEL_KINKY_BOOST:
                    modelBlock = new KinkyBoost();
                    break;

                case ConstDistortion.MODEL_KWB:
                    modelBlock = new KWB();
                    break;

                case ConstDistortion.MODEL_MEGAPHONE:
                    modelBlock = new Megaphone();
                    break;

                case ConstDistortion.MODEL_FACIAL_FUZZ:
                    modelBlock = new FacialFuzz();
                    break;

                case ConstDistortion.MODEL_MINOTAUR:
                    modelBlock = new Minotaur();
                    break;

                case ConstDistortion.MODEL_HEDGEHOG_D9:
                    modelBlock = new HedgehogD9();
                    break;

                case ConstDistortion.MODEL_TEEMAH:
                    modelBlock = new Teemah();
                    break;

                case ConstDistortion.MODEL_HEAVY_DISTORTION:
                    modelBlock = new HeavyDistortion();
                    break;

                case ConstDistortion.MODEL_INDUSTRIAL_FUZZ:
                    modelBlock = new IndustrialFuzz();
                    break;

                case ConstDistortion.MODEL_THRIFTER_FUZZ:
                    modelBlock = new ThrifterFuzz();
                    break;

                case ConstDistortion.MODEL_TOP_SECRET_OD:
                    modelBlock = new TopSecretOD();
                    break;

                case ConstDistortion.MODEL_TRIANGLE_FUZZ:
                    modelBlock = new TriangleFuzz();
                    break;

                case ConstDistortion.MODEL_TYCOCTAVIA_FUZZ:
                    modelBlock = new TycoctaviaFuzz();
                    break;

                case ConstDistortion.MODEL_VERMIN_DIST:
                    modelBlock = new VerminDist();
                    break;

                case ConstDistortion.MODEL_VALVE_DRIVER:
                    modelBlock = new ValveDriver();
                    break;

                case ConstDistortion.MODEL_OBSIDIAN_7000:
                    modelBlock = new Obsidian7000();
                    break;

                case ConstDistortion.MODEL_WRINGER_FUZZ:
                    modelBlock = new WringerFuzz();
                    break;

                case ConstDistortion.MODEL_TUBE_DRIVE:
                    modelBlock = new TubeDrive();
                    break;

                case ConstDistortion.MODEL_SCREAMER:
                    modelBlock = new Screamer();
                    break;

                case ConstDistortion.MODEL_OVERDRIVE:
                    modelBlock = new Overdrive();
                    break;

                case ConstDistortion.MODEL_CLASSIC_DISTORTION:
                    modelBlock = new ClassicDistortion();
                    break;

                case ConstDistortion.MODEL_COLOR_DRIVE:
                    modelBlock = new ColorDrive();
                    break;

                case ConstDistortion.MODEL_BUZZ_SAW:
                    modelBlock = new BuzzSaw();
                    break;

                case ConstDistortion.MODEL_JUMBO_FUZZ:
                    modelBlock = new JumboFuzz();
                    break;

                case ConstDistortion.MODEL_OCTAVE_FUZZ:
                    modelBlock = new OctaveFuzz();
                    break;

                case ConstDistortion.MODEL_FUZZ_PI:
                    modelBlock = new FuzzPi();
                    break;

                case ConstDistortion.MODEL_JET_FUZZ:
                    modelBlock = new JetFuzz();
                    break;

                case ConstDistortion.MODEL_LINE_6_DRIVE:
                    modelBlock = new Line6Drive();
                    break;

                case ConstDistortion.MODEL_LINE_6_DISTORTION:
                    modelBlock = new Line6Distortion();
                    break;

                case ConstDistortion.MODEL_SUB_OCTAVE_FUZZ:
                    modelBlock = new SubOctaveFuzz();
                    break;

                case ConstDistortion.MODEL_HEIR_APPARENT:
                    modelBlock = new HeirApparent();
                    break;

                case ConstDistortion.MODEL_TONE_SOVEREIGN:
                    modelBlock = new ToneSovereign();
                    break;

                case ConstDistortion.MODEL_DHYANA_DRIVE:
                    modelBlock = new DhyanaDrive();
                    break;

                case ConstDistortion.MODEL_ZERO_AMP_BASS_DI:
                    modelBlock = new ZeroAmpBassDI();
                    break;

                case ConstDistortion.MODEL_AMPEG_SCRAMBLER_OD:
                    modelBlock = new AmpegScramblerOD();
                    break;
                    #endregion Distortion



                    #region Dynamics
                case ConstDynamics.MODEL_LA_STUDIO_COMP:
                    modelBlock = new LASutdioComp();
                    break;

                case ConstDynamics.MODEL_NOISE_GATE:
                    modelBlock = new NoiseGate();
                    break;

                case ConstDynamics.MODEL_HARD_GATE:
                    modelBlock = new HardGate();
                    break;

                case ConstDynamics.MODEL_AUTO_SWELL:
                    modelBlock = new AutoSwell();
                    break;

                case ConstDynamics.MODEL_RED_SQUEEZE:
                    modelBlock = new RedSqueeze();
                    break;

                case ConstDynamics.MODEL_DELUXE_COMP:
                    modelBlock = new DeluxeComp();
                    break;

                case ConstDynamics.MODEL_3_BAND_COMP:
                    modelBlock = new Comp3BandComp();
                    break;

                case ConstDynamics.MODEL_KINKY_COMP:
                    modelBlock = new KinkyComp();
                    break;

                case ConstDynamics.MODEL_TUBE_COMP:
                    modelBlock = new TubeComp();
                    break;

                case ConstDynamics.MODEL_RED_COMP:
                    modelBlock = new RedComp();
                    break;

                case ConstDynamics.MODEL_BLUE_COMP:
                    modelBlock = new BlueComp();
                    break;

                case ConstDynamics.MODEL_BLUE_COMP_TREB:
                    modelBlock = new BlueCompTreb();
                    break;

                case ConstDynamics.MODEL_VETTA_COMP:
                    modelBlock = new VettaComp();
                    break;

                case ConstDynamics.MODEL_VETTA_JUICE:
                    modelBlock = new VettaJuice();
                    break;

                case ConstDynamics.MODEL_BOOST_COMP:
                    modelBlock = new BoostComp();
                    break;
                    #endregion Dynamics



                    #region EQ
                case ConstEQ.MODEL_LOW_CUT_HIGH_CUT:
                    modelBlock = new LowCutHighCut();
                    break;

                case ConstEQ.MODEL_LOW_SHELF_HIGH_SHELF:
                    modelBlock = new LowShelfHighShelf();
                    break;

                case ConstEQ.MODEL_GRAPHIC_10_BAND:
                    modelBlock = new Graphic10Band();
                    break;

                case ConstEQ.MODEL_SIMPLE_3_BAND:
                    modelBlock = new Simple3Band();
                    break;

                case ConstEQ.MODEL_PARAMETRIC:
                    modelBlock = new Parametric();
                    break;

                case ConstEQ.MODEL_CALI_Q:
                    modelBlock = new CaliQ();
                    break;

                case ConstEQ.DISP_SIMPLE_TILT:
                    modelBlock = new SimpleTilt();
                    break;
                    #endregion EQ



                    #region FX Loop
                case ConstFxLoop.MODEL_FX_LOOP_MONO_1:
                    modelBlock = new FXLoopLeft();
                    break;

                case ConstFxLoop.MODEL_FX_LOOP_MONO_2:
                    modelBlock = new FXLoopRight();
                    break;

                case ConstFxLoop.MODEL_FX_LOOP_STEREO:
                    modelBlock = new FXLoopStereo();
                    break;
                    #endregion FX Loop



                    #region Filter
                case ConstFilter.DISP_ASHEVILLE_PATTRN:
                    modelBlock = new AshevillePattrn();
                    break;

                case ConstFilter.MODEL_AUTO_FILTER:
                    modelBlock = new AutoFilter();
                    break;

                case ConstFilter.MODEL_MUTANT_FILTER:
                    modelBlock = new MutantFilter();
                    break;

                case ConstFilter.MODEL_MYSTERY_FILTER:
                    modelBlock = new MysteryFilter();
                    break;

                case ConstFilter.MODEL_VOICE_BOX:
                    modelBlock = new VoiceBox();
                    break;

                case ConstFilter.MODEL_TRON:
                    modelBlock = new Tron();
                    break;

                case ConstFilter.MODEL_Q_FILTER:
                    modelBlock = new QFilter();
                    break;

                case ConstFilter.MODEL_SEEKER:
                    modelBlock = new Seeker();
                    break;

                case ConstFilter.MODEL_OBI_WAH:
                    modelBlock = new ObiWah();
                    break;

                case ConstFilter.MODEL_TRON_UP:
                    modelBlock = new TronUp();
                    break;

                case ConstFilter.MODEL_TRON_DOWN:
                    modelBlock = new TronDown();
                    break;

                case ConstFilter.MODEL_THROBBER:
                    modelBlock = new Throbber();
                    break;

                case ConstFilter.MODEL_SLOW_FILTER:
                    modelBlock = new SlowFilter();
                    break;

                case ConstFilter.MODEL_SPIN_CYCLE:
                    modelBlock = new SpinCycle();
                    break;

                case ConstFilter.MODEL_COMET_TRAILS:
                    modelBlock = new CometTrails();
                    break;
                    #endregion Filter



                    #region  Looper
                case ConstLooper.MODEL_LOOPER:
                    modelBlock = new Looper();
                    break;
                    #endregion Looper



                    #region Impulse response
                case ConstIR.MODEL_IMPULSE_RESPONSE_1024:
                    modelBlock = new ImpulseResponse1024();
                    break;

                case ConstIR.MODEL_IMPULSE_RESPONSE_2048:
                    modelBlock = new ImpulseResponse2048();
                    break;
                    #endregion Impulse Response



                    #region Modulation
                case ConstModulation.MODEL_60S_BIAS_TRAM:
                    modelBlock = new Mod60sBiasTrem();
                    break;

                case ConstModulation.MODEL_70S_CHORUS:
                    modelBlock = new Chorus70sChorus();
                    break;

                case ConstModulation.MODEL_AM_RING_MOD:
                    modelBlock = new AMRingMod();
                    break;

                case ConstModulation.MODEL_BUBBLE_VIBRATO:
                    modelBlock = new BubbleVibrato();
                    break;

                case ConstModulation.MODEL_COURTESAN_FLANGE:
                    modelBlock = new CourtesanFlange();
                    break;

                case ConstModulation.MODEL_DELUXE_PHASER:
                    modelBlock = new DeluxePhaser();
                    break;

                case ConstModulation.MODEL_DOUBLT_TAKE:
                    modelBlock = new DoubleTake();
                    break;

                case ConstModulation.MODEL_DYNAMIX_FLANGER:
                    modelBlock = new DynamixFlanger();
                    break;

                case ConstModulation.MODEL_TRINITY_CHORUS:
                    modelBlock = new TrinityChorus();
                    break;

                case ConstModulation.MODEL_GRAY_FLANGER:
                    modelBlock = new GrayFlanger();
                    break;

                case ConstModulation.MODEL_UBIQUITOUS_VIBE:
                    modelBlock = new UbiquitousVibe();
                    break;

                case ConstModulation.MODEL_SCRIPT_MOD_PHASE:
                    modelBlock = new ScriptModPhase();
                    break;

                case ConstModulation.DISP_HARMONIC_TREM:
                    modelBlock = new HarmonicTremolo();
                    break;

                case ConstModulation.MODEL_OPTICAL_TREM:
                    modelBlock = new OpticalTrem();
                    break;

                case ConstModulation.MODEL_PLASTI_CHORUS:
                    modelBlock = new PlastiChorus();
                    break;

                case ConstModulation.MODEL_PITCH_RING_MOD:
                    modelBlock = new PitchRingMod();
                    break;

                case ConstModulation.MODEL_CHORUS:
                    modelBlock = new Chorus();
                    break;

                case ConstModulation.MODEL_ROTARY_122:
                    modelBlock = new Rotary122();
                    break;

                case ConstModulation.MODEL_ROTARY_145:
                    modelBlock = new Rotary145();
                    break;

                case ConstModulation.MODEL_ROTARY_VIBE:
                    modelBlock = new RotaryVibe();
                    break;

                case ConstModulation.MODEL_HARMONIC_FLANGER:
                    modelBlock = new HarmonicFlanger();
                    break;

                case ConstModulation.MODEL_BLEAT_CHOP_TREM:
                    modelBlock = new BleatChopTrem();
                    break;

                case ConstModulation.MODEL_TREMOLO:
                    modelBlock = new Tremolo();
                    break;

                case ConstModulation.MODEL_PATTERN_TREM:
                    modelBlock = new PatternTrem();
                    break;

                case ConstModulation.MODEL_PANNER:
                    modelBlock = new Panner();
                    break;

                case ConstModulation.MODEL_BIAS_TREMOLO:
                    modelBlock = new BiasTremolo();
                    break;

                case ConstModulation.MODEL_OPTO_TREMOLO:
                    modelBlock = new OptoTremolo();
                    break;

                case ConstModulation.MODEL_SCRIPT_PHASE:
                    modelBlock = new ScriptPhase();
                    break;

                case ConstModulation.MODEL_PANNED_PHASER:
                    modelBlock = new PannedPhaser();
                    break;

                case ConstModulation.MODEL_BARBERPOLE_PHASER:
                    modelBlock = new BarberpolePhaser();
                    break;

                case ConstModulation.MODEL_DUAL_PHASER:
                    modelBlock = new DualPhaser();
                    break;

                case ConstModulation.MODEL_U_VIBE:
                    modelBlock = new UVibe();
                    break;

                case ConstModulation.MODEL_PHASER:
                    modelBlock = new Phaser();
                    break;

                case ConstModulation.MODEL_PITCH_VIBRATO:
                    modelBlock = new PitchVibrato();
                    break;

                case ConstModulation.MODEL_DIMMENSION:
                    modelBlock = new Dimmension();
                    break;

                case ConstModulation.MODEL_ANALOG_CHORUS:
                    modelBlock = new AnalogChorus();
                    break;

                case ConstModulation.MODEL_TRI_CHORUS:
                    modelBlock = new TriChorus();
                    break;

                case ConstModulation.MODEL_ANALOG_FLANGER:
                    modelBlock = new AnalogFlanger();
                    break;

                case ConstModulation.MODEL_JET_FLANGER:
                    modelBlock = new JetFlanger();
                    break;

                case ConstModulation.MODEL_AC_FLANGER:
                    modelBlock = new ACFlanger();
                    break;

                case ConstModulation.MODEL_80A_FLANGER:
                    modelBlock = new ADAFlanger();
                    break;

                case ConstModulation.MODEL_FREQUENCY_SHIFTER:
                    modelBlock = new FrequencyShifter();
                    break;

                case ConstModulation.MODEL_RING_MODULATOR:
                    modelBlock = new RingModulator();
                    break;

                case ConstModulation.MODEL_ROTARY_DRUM:
                    modelBlock = new RotaryDrum();
                    break;

                case ConstModulation.MODEL_ROTARY_DRUM_HORN:
                    modelBlock = new RotaryDrumHorn();
                    break;
                    #endregion Modulation



                    #region Pitch/Synth
                case ConstPitch.MODEL_PITCH_WHAM:
                    modelBlock = new PitchWham();
                    break;

                case ConstPitch.MODEL_DUAL_PITCH:
                    modelBlock = new DualPitch();
                    break;

                case ConstPitch.MODEL_SIMPLE_PITCH:
                    modelBlock = new SimplePitch();
                    break;

                case ConstPitch.MODEL_TWIN_HARMONY:
                    modelBlock = new TwinHarmony();
                    break;

                case ConstPitch.MODEL_3_NOTE_GENERATOR:
                    modelBlock = new Synth3NoteGenerator();
                    break;

                case ConstPitch.MODEL_4_OSC_GENERATOR:
                    modelBlock = new Synth4OSCGenerator();
                    break;

                case ConstPitch.MODEL_3_OSC_SYNTH:
                    modelBlock = new Synth3OSCSynth();
                    break;

                case ConstPitch.MODEL_BASS_OCTAVER:
                    modelBlock = new BassOctaver();
                    break;

                case ConstPitch.MODEL_TWO_VOICE_HARMONY:
                    modelBlock = new TwoVoiceHarmony();
                    break;

                case ConstPitch.MODEL_OCTI_SYNTH:
                    modelBlock = new OctiSynth();
                    break;

                case ConstPitch.MODEL_SYNTH_OMATIC:
                    modelBlock = new SynthOMatic();
                    break;

                case ConstPitch.MODEL_ATTACK_SYNTH:
                    modelBlock = new AttackSynth();
                    break;

                case ConstPitch.MODEL_SYNTH_STRING:
                    modelBlock = new SynthString();
                    break;

                case ConstPitch.MODEL_GROWLER:
                    modelBlock = new Growler();
                    break;
                    #endregion Pitch/Synth



                    #region Reverb
                case ConstReverb.MODEL_SPRING:
                    modelBlock = new Spring();
                    break;

                case ConstReverb.MODEL_63_SPRING:
                    modelBlock = new Reverb63Spring();
                    break;

                case ConstReverb.MODEL_CAVE:
                    modelBlock = new Cave();
                    break;

                case ConstReverb.MODEL_CHAMBER:
                    modelBlock = new Chamber();
                    break;

                case ConstReverb.MODEL_DUCKING:
                    modelBlock = new Ducking();
                    break;

                case ConstReverb.MODEL_ECHO:
                    modelBlock = new Echo();
                    break;

                case ConstReverb.MODEL_HALL:
                    modelBlock = new Hall();
                    break;

                case ConstReverb.MODEL_GLITZ:
                    modelBlock = new Glitz();
                    break;

                case ConstReverb.MODEL_ROOM:
                    modelBlock = new Room();
                    break;

                case ConstReverb.MODEL_DOUBLE_TANK:
                    modelBlock = new DoubleTank();
                    break;

                case ConstReverb.MODEL_GANYMEDE:
                    modelBlock = new Ganymede();
                    break;

                case ConstReverb.MODEL_PARTICLE:
                    modelBlock = new Particle();
                    break;

                case ConstReverb.MODEL_PLATE:
                    modelBlock = new Plate();
                    break;

                case ConstReverb.MODEL_OCTO:
                    modelBlock = new Octo();
                    break;

                case ConstReverb.MODEL_PLATEAUX:
                    modelBlock = new Plateaux();
                    break;

                case ConstReverb.MODEL_SEARCHLIGHTS:
                    modelBlock = new Searchlights();
                    break;

                case ConstReverb.MODEL_TILE:
                    modelBlock = new Tile();
                    break;
                    #endregion Reverb



                    #region Send/Return
                case ConstSendReturn.MODEL_SEND_MONO_1:
                    modelBlock = new SendLeft();
                    break;

                case ConstSendReturn.MODEL_SEND_MONO_2:
                    modelBlock = new SendRight();
                    break;

                case ConstSendReturn.MODEL_RETURN_MONO_1:
                    modelBlock = new ReturnLeft();
                    break;

                case ConstSendReturn.MODEL_RETURN_MONO_2:
                    modelBlock = new ReturnRight();
                    break;

                case ConstSendReturn.MODEL_SEND_STEREO_1_2:
                    modelBlock = new SendStereoLR();
                    break;

                case ConstSendReturn.MODEL_RETURN_STEREO_1_2:
                    modelBlock = new ReturnStereoLR();
                    break;
                    #endregion Send/Return



                    #region Volume/Pan
                case ConstVolPan.MODEL_VOLUME:
                    modelBlock = new Volume();
                    break;

                case ConstVolPan.MODEL_GAIN:
                    modelBlock = new Gain();
                    break;
                    #endregion Volume/Pan



                    #region Wah
                case ConstWah.MODEL_CHROME:
                    modelBlock = new Chrome();
                    break;

                case ConstWah.MODEL_CHROME_CUSTOM:
                    modelBlock = new ChromeCustom();
                    break;

                case ConstWah.MODEL_COLORFUL:
                    modelBlock = new Colorful();
                    break;

                case ConstWah.MODEL_CONDUCTOR:
                    modelBlock = new Conductor();
                    break;

                case ConstWah.MODEL_TEARDROP_310:
                    modelBlock = new Teardrop310();
                    break;

                case ConstWah.MODEL_THROATY:
                    modelBlock = new Throaty();
                    break;

                case ConstWah.MODEL_WEEPER:
                    modelBlock = new Weeper();
                    break;

                case ConstWah.MODEL_FASSEL:
                    modelBlock = new Fassel();
                    break;

                case ConstWah.MODEL_UK_WAH_846:
                    modelBlock = new UkWah846();
                    break;

                case ConstWah.MODEL_VETTA_WAH:
                    modelBlock = new Vetta();
                    break;
                    #endregion Wah

                default:
                    modelBlock = new Block();
                    break;
                }
                serializer.Populate(jsonObject.CreateReader(), modelBlock);
                return(modelBlock);
            }
            else
            {
                return(default(Block));
            }
        }
Beispiel #17
0
        /// <inheritdoc/>
        public async Task <Position> GetPositionAsync(int timeoutMilliseconds = Timeout.Infinite, CancellationToken?cancelToken = null, bool includeHeading = false)
        {
            var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permissions.Abstractions.Permission.Location).ConfigureAwait(false);

            if (status != Permissions.Abstractions.PermissionStatus.Granted)
            {
                Console.WriteLine("Currently does not have Location permissions, requesting permissions");

                var request = await CrossPermissions.Current.RequestPermissionsAsync(Permissions.Abstractions.Permission.Location);

                if (request[Permissions.Abstractions.Permission.Location] != Permissions.Abstractions.PermissionStatus.Granted)
                {
                    Console.WriteLine("Location permission denied, can not get positions async.");
                    return(null);
                }
                providers = manager.GetProviders(enabledOnly: false).Where(s => s != LocationManager.PassiveProvider).ToArray();
            }

            if (providers.Length == 0)
            {
                providers = manager.GetProviders(enabledOnly: false).Where(s => s != LocationManager.PassiveProvider).ToArray();
            }


            if (timeoutMilliseconds <= 0 && timeoutMilliseconds != Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException("timeoutMilliseconds", "timeout must be greater than or equal to 0");
            }

            if (!cancelToken.HasValue)
            {
                cancelToken = CancellationToken.None;
            }


            var tcs = new TaskCompletionSource <Position>();

            if (!IsListening)
            {
                GeolocationSingleListener singleListener = null;
                singleListener = new GeolocationSingleListener((float)DesiredAccuracy, timeoutMilliseconds, providers.Where(manager.IsProviderEnabled),
                                                               finishedCallback: () =>
                {
                    for (int i = 0; i < providers.Length; ++i)
                    {
                        manager.RemoveUpdates(singleListener);
                    }
                });

                if (cancelToken != CancellationToken.None)
                {
                    cancelToken.Value.Register(() =>
                    {
                        singleListener.Cancel();

                        for (int i = 0; i < providers.Length; ++i)
                        {
                            manager.RemoveUpdates(singleListener);
                        }
                    }, true);
                }

                try
                {
                    Looper looper = Looper.MyLooper() ?? Looper.MainLooper;

                    int enabled = 0;
                    for (int i = 0; i < providers.Length; ++i)
                    {
                        if (manager.IsProviderEnabled(providers[i]))
                        {
                            enabled++;
                        }

                        manager.RequestLocationUpdates(providers[i], 0, 0, singleListener, looper);
                    }

                    if (enabled == 0)
                    {
                        for (int i = 0; i < providers.Length; ++i)
                        {
                            manager.RemoveUpdates(singleListener);
                        }

                        tcs.SetException(new GeolocationException(GeolocationError.PositionUnavailable));
                        return(await tcs.Task.ConfigureAwait(false));
                    }
                }
                catch (Java.Lang.SecurityException ex)
                {
                    tcs.SetException(new GeolocationException(GeolocationError.Unauthorized, ex));
                    return(await tcs.Task.ConfigureAwait(false));
                }

                return(await singleListener.Task.ConfigureAwait(false));
            }

            // If we're already listening, just use the current listener
            lock (positionSync)
            {
                if (lastPosition == null)
                {
                    if (cancelToken != CancellationToken.None)
                    {
                        cancelToken.Value.Register(() => tcs.TrySetCanceled());
                    }

                    EventHandler <PositionEventArgs> gotPosition = null;
                    gotPosition = (s, e) =>
                    {
                        tcs.TrySetResult(e.Position);
                        PositionChanged -= gotPosition;
                    };

                    PositionChanged += gotPosition;
                }
                else
                {
                    tcs.SetResult(lastPosition);
                }
            }

            return(await tcs.Task.ConfigureAwait(false));
        }
		public override void onCreate()
		{
			base.onCreate();
			mAccessory = new SA();
			try
			{
				mAccessory.initialize(this);
			}
			catch (SsdkUnsupportedException e)
			{
				// try to handle SsdkUnsupportedException
				if (processUnsupportedException(e) == true)
				{
					return;
				}
			}
			catch (Exception e1)
			{
				Console.WriteLine(e1.ToString());
				Console.Write(e1.StackTrace);
				/*
				 * Your application can not use Samsung Accessory SDK. Your application should work smoothly
				 * without using this SDK, or you may want to notify user and close your application gracefully
				 * (release resources, stop Service threads, close UI thread, etc.)
				 */
				stopSelf();
			}
			mThread = new HandlerThread("GalleryProvider");
			mThread.start();
			mLooper = mThread.Looper;
			if (mLooper != null)
			{
				mBackgroundHandler = new Handler(mLooper);
			}
			else
			{
				throw new Exception("Could not get Looper from Handler Thread");
			}
		}
		internal MotionPedometer(Looper looper, Smotion motion, bool isUpDownAvailable)
		{
			mPedometer = new SmotionPedometer(looper, motion);
			mIsUpDownAvailable = isUpDownAvailable;
			initialize();
		}
 public static ICancelable Shared(Action<UAirship> callback, Looper looper)
 {
     return Shared (new AirshipReadyCallback (callback), looper);
 }
Beispiel #21
0
        /// <inheritdoc />
        public async Task <Geoposition> GetGeopositionAsync(TimeSpan maximumAge, TimeSpan timeout)
        {
            var tcs = new TaskCompletionSource <Geoposition>();

            var access = await this.RequestAccessAsync();

            if (access == GeolocationAccessStatus.Allowed)
            {
                LocationRetriever[] retriever = { null };
                retriever[0] = new LocationRetriever(
                    this.DesiredAccuracyInMeters,
                    timeout,
                    this.locationProviders.Where(this.locationManager.IsProviderEnabled),
                    () =>
                {
                    try
                    {
                        this.locationManager.RemoveUpdates(retriever[0]);
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(ex.ToString());
#endif
                    }
                });

                try
                {
                    var looperThread = Looper.MyLooper() ?? Looper.MainLooper;

                    var numEnabledProviders = 0;
                    foreach (var provider in this.locationProviders)
                    {
                        if (this.locationManager.IsProviderEnabled(provider))
                        {
                            numEnabledProviders++;
                        }

                        this.locationManager.RequestLocationUpdates(provider, 0, 0, retriever[0], looperThread);
                    }

                    if (numEnabledProviders == 0)
                    {
                        try
                        {
                            this.locationManager.RemoveUpdates(retriever[0]);
                        }
                        catch (Exception ex)
                        {
#if DEBUG
                            System.Diagnostics.Debug.WriteLine(ex.ToString());
#endif
                        }

                        tcs.TrySetException(
                            new GeolocatorException("A location cannot be retrieved as the provider is unavailable."));
                        return(await tcs.Task);
                    }
                }
                catch (Java.Lang.SecurityException ex)
                {
                    tcs.TrySetException(
                        new GeolocatorException("A location cannot be retrieved as the access was unauthorized.", ex));
                    return(await tcs.Task);
                }

                return(await retriever[0].Task);
            }

            lock (this.obj)
            {
                if (this.LastKnownPosition == null ||
                    (this.LastKnownPosition.Coordinate != null &&
                     !this.LastKnownPosition.Coordinate.Timestamp.IsValid(maximumAge)))
                {
                    // Attempts to get the current location based on the event handler of this Geolocator.
                    TypedEventHandler <IGeolocator, PositionChangedEventArgs> positionResponse = null;
                    positionResponse = (s, e) =>
                    {
                        tcs.TrySetResult(e.Position);
                        this.PositionChanged -= positionResponse;
                    };

                    this.PositionChanged += positionResponse;
                }
                else
                {
                    tcs.SetResult(this.LastKnownPosition);
                }
            }

            return(await tcs.Task);
        }
        public static global::System.Windows.Forms.DialogResult Show(string text, string caption)
        {
            // or are we called on a background thread?
            // for java, we can block a worker thread until ui is shown. for javascript cannot do it without async?
            // assume we are activity based..
            var context = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as Activity;
            var ui      = context.getMainLooper() == Looper.myLooper();

            Console.WriteLine("enter MessageBox.Show " + new { ui });

            var value   = default(global::System.Windows.Forms.DialogResult);
            var thread0 = Thread.CurrentThread;
            var sync    = new AutoResetEvent(false);

            context.runOnUiThread(
                a =>
            {
                //thread0 = Thread.CurrentThread;
                //sync0ui.Set();

                // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141025
                // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs


                var alertDialog = new AlertDialog.Builder(context);

                alertDialog.setTitle(caption);

                if (!string.IsNullOrEmpty(caption))
                {
                    alertDialog.setMessage(text);
                }

                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141026


                alertDialog.setPositiveButton("OK",
                                              new xDialogInterface_OnClickListener
                {
                    yield = delegate
                    {
                        Console.WriteLine(" alertDialog.setPositiveButton");
                        value = global::System.Windows.Forms.DialogResult.OK;
                        //sync.Set();
                    }
                }
                                              );

                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);
                var dialog = alertDialog.create();

                dialog.setOnDismissListener(
                    new xDialogInterface_OnDismissListener
                {
                    yield = delegate
                    {
                        Console.WriteLine("  dialog.setOnDismissListener");
                        sync.Set();

                        if (ui)
                        {
                            throw null;
                        }
                    }
                }
                    );

                dialog.show();


                // http://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android
                // http://developer.android.com/reference/android/os/Looper.html



                //sync.Set();
            }
                );



            // need to poll? discard?


            if (ui)
            {
                try
                {
                    // loop until we throw null
                    // where is it thrown?
                    android.os.Looper.loop();
                }
                catch
                {
                }
            }
            else
            {
                sync.WaitOne();
            }

            Console.WriteLine("exit MessageBox.Show " + new { ui, value });
            return(value);
        }
Beispiel #23
0
        /// <summary>
        /// Esta función se ejecuta cuando algun proceso se manda en segundo plano
        /// para no interrumpir las actividades que tiene prioridad el telefono.
        /// La finalidad de esta función es enviar los resultados de las encuestas contestadas.
        /// </summary>
        public void Run()
        {
            //System.Console.WriteLine("Inicio Run");
            Looper.Prepare();
            if (bandera == 1)
            {
                bool result   = false;
                int  intentos = 0;
                while (result == false)
                {
                    try
                    {
                        this.MoveTaskToBack(true);
                        int idDisp = IdDispositivo;
                        int idEnc  = Servicio.ClsVariables.IdEncuesta;
                        result = asmxEM.GuardaEncuestaContestada(idDisp, idEnc, Servicio.ClsVariables.arrayIds, Servicio.ClsVariables.NumeroTel);
                        //System.Console.WriteLine("Valores IDDISP= " + idDisp + "Valores IDENC= " + idEnc + "Resultado: "  + result);
                    }
                    catch (WebException catchExep)
                    {
                        //System.Console.WriteLine("Error: " + catchExep.Message);
                        int    cuentapr = 0;
                        string pr       = "";
                        foreach (string presp in Servicio.ClsVariables.arrayIds)
                        {
                            cuentapr++;
                            int totalResp = Servicio.ClsVariables.arrayIds.Length;
                            if (presp != null)
                            {
                                if (totalResp == cuentapr)
                                {
                                    pr += presp.ToString();
                                }
                                else
                                {
                                    pr += presp.ToString() + "&";
                                }
                            }
                        }
                        SqliteCommand contentsInsert = connection.CreateCommand();
                        String        strQuery       = "INSERT INTO [DatosEncuestaEnvia] ([IdDispositivo],[IdEncuesta],[IdsPreguntaRespuesta]) values('" + Servicio.ClsVariables.IdDispositivo.ToString() + "','" + Servicio.ClsVariables.IdEncuesta.ToString() + "','" + pr + "');";
                        contentsInsert.CommandText = strQuery;
                        contentsInsert.ExecuteNonQuery();
                        int codigo = this.GetHashCode();
                        StartService(new Intent(this, typeof(Servicio.ClsEnviaDatosProgramados)));
                        threadEnviaDatos.Stop();
                        result = true;

                        this.Finish();
                    }
                    if (result == true)
                    {
                        SqliteCommand contents = connection.CreateCommand();
                        contents.CommandText = "DELETE from [DatosEncuesta]";
                        contents.ExecuteNonQuery();
                        threadEnviaDatos.Stop();
                        this.Finish();
                    }
                    intentos++;
                    if (intentos == 3)
                    {
                        //System.Console.WriteLine("Se programo envio automatico");
                        int    cuentapr = 0;
                        string pr       = "";
                        foreach (string presp in Servicio.ClsVariables.arrayIds)
                        {
                            cuentapr++;
                            int totalResp = Servicio.ClsVariables.arrayIds.Length;
                            if (presp != null)
                            {
                                if (totalResp == cuentapr)
                                {
                                    pr += presp.ToString();
                                }
                                else
                                {
                                    pr += presp.ToString() + "&";
                                }
                            }
                        }
                        SqliteCommand contentsInsert = connection.CreateCommand();
                        String        strQuery       = "INSERT INTO [DatosEncuestaEnvia] ([IdDispositivo],[IdEncuesta],[IdsPreguntaRespuesta]) values('" + Servicio.ClsVariables.IdDispositivo.ToString() + "','" + Servicio.ClsVariables.IdEncuesta.ToString() + "','" + pr + "');";
                        contentsInsert.CommandText = strQuery;
                        contentsInsert.ExecuteNonQuery();
                        int codigo = this.GetHashCode();
                        StartService(new Intent(this, typeof(Servicio.ClsEnviaDatosProgramados)));
                        threadEnviaDatos.Stop();
                        result = true;
                        this.Finish();
                    }
                }
            }
            Looper.Loop();
            Looper.MyLooper().Quit();
        }
Beispiel #24
0
 public static Java.Lang.Thread getThread(this Looper looper)
 {
     return(looper.Thread);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceHandler"/> class.
 /// </summary>
 /// <param name="looper">
 /// The looper.
 /// </param>
 /// <param name="customIntentService">
 /// The customIntentService.
 /// </param>
 public ServiceHandler(Looper looper, CustomIntentService customIntentService)
     : base(looper)
 {
     this.customIntentService = customIntentService;
 }
        private void PostAccidentToDBwithoutImage()
        {
            Looper.Prepare();

            HttpClientHandler handler = new HttpClientHandler();

            //    CookieContainer cookies = new CookieContainer();

            //   handler.CookieContainer = cookies;

            var client = new System.Net.Http.HttpClient(handler, false);
            {
                try
                {
                    EncrypConnection encryp = new EncrypConnection();

                    MultipartFormDataContent form = new MultipartFormDataContent();

                    mFinalCryptPassword = encryp.Encrypt();

                    StringContent number      = new StringContent(mPhoneNumber.Text.ToString());
                    StringContent description = new StringContent(mDescription.Text.ToString());
                    StringContent city        = new StringContent(mCity.Text.ToString());
                    StringContent address     = new StringContent(mAddress.Text.ToString());
                    StringContent name        = new StringContent(mFullName.Text.ToString());
                    StringContent key         = new StringContent(mFinalCryptPassword);
                    // StringContent key = new StringContent("test");

                    form.Add(number, "number");
                    form.Add(description, "description");
                    form.Add(city, "city");
                    form.Add(address, "address");
                    form.Add(name, "name");
                    form.Add(key, "key");

                    HttpResponseMessage response = client.PostAsync(ConnectToApi.urlAPI + apiCommand, form).Result;

                    if (response.StatusCode == HttpStatusCode.OK)  // response.IsSuccessStatusCode
                    {
                        RunOnUiThread(() => { Toast.MakeText(this, "Успешно изпратихте сигнал", ToastLength.Long).Show(); });
                        var intent = new Intent(this, typeof(MainActivity));
                        StartActivity(intent);
                    }
                    //HttpResponseMessage response =
                    //   client.PostAsync("http://192.168.2.222/VIKWebApi/api/postimage", form).Result;
                    else
                    {
                        RunOnUiThread(() => { RefreshProgressDialogAndToastWhenCanNotSentSignalWithOutImage(); });
                    }
                }
                catch (Exception ex)
                {
                    //string error =(ex.InnerException.Message);

                    //String innerMessage = (ex.InnerException != null)
                    //    ? ex.InnerException.Message
                    //    : "";

                    RunOnUiThread(() => { RefreshProgressDialogAndToastWhenCanNotSentSignalWithOutImage(); });
                }
            }
        }
Beispiel #27
0
 public ServiceHandler(Looper looper)
     : base(looper)
 {                
 }
 /// <summary>
 /// The on create.
 /// </summary>
 public override void OnCreate()
 {
     base.OnCreate();
     var localHandlerThread = new HandlerThread("IntentService[" + this.name + "]");
     localHandlerThread.Start();
     this.serviceLooper = localHandlerThread.Looper;
     this.serviceHandler = new ServiceHandler(this.serviceLooper, this);
 }
 public ServiceHandler(Looper looper, StickyIntentService sis)
     : base(looper)
 {
     this.sis = sis;
 }
Beispiel #30
0
 public MyHandler(Looper looper) : base(looper)
 {
 }
Beispiel #31
0
 public void OnSuccess(Java.Lang.Object result)
 {
     Log.Info(Activity.Tag, "All location settings are satisfied.");
     Activity.mFusedLocationClient.RequestLocationUpdates(Activity.mLocationRequest, Activity.mLocationCallback, Looper.MyLooper());
     Activity.UpdateUi();
 }
Beispiel #32
0
 public ICancelable FetchMessages(Action <bool> callback, Looper looper)
 {
     return(FetchMessages(new FetchMessagesCallback(callback), looper));
 }
Beispiel #33
0
 public override void OnCreate()
 {
     base.OnCreate ();
     if (prefs == null)
         prefs = new PreferenceManager (this);
     var thread = new HandlerThread ("IntentService[BikrActivityService]");
     thread.Start ();
     serviceLooper = thread.Looper;
     serviceHandler = new ServiceHandler (this, serviceLooper);
 }
Beispiel #34
0
        /// <summary>
        ///     Gets the position asynchronous.
        /// </summary>
        /// <param name="timeout">The timeout.</param>
        /// <param name="cancelToken">The cancel token.</param>
        /// <param name="includeHeading">if set to <c>true</c> [include heading].</param>
        /// <returns>Task&lt;Position&gt;.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">timeout;timeout must be greater than or equal to 0</exception>
        public Task <Position> GetPositionAsync(int timeout, CancellationToken cancelToken, bool includeHeading)
        {
            if (timeout <= 0 && timeout != Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException("timeout", "timeout must be greater than or equal to 0");
            }

            var tcs = new TaskCompletionSource <Position>();

            if (!IsListening)
            {
                GeolocationSingleListener singleListener = null;
                singleListener = new GeolocationSingleListener(
                    (float)DesiredAccuracy,
                    timeout,
                    _providers.Where(_manager.IsProviderEnabled),
                    () =>
                {
                    for (var i = 0; i < _providers.Length; ++i)
                    {
                        _manager.RemoveUpdates(singleListener);
                    }
                });

                if (cancelToken != CancellationToken.None)
                {
                    cancelToken.Register(
                        () =>
                    {
                        singleListener.Cancel();

                        for (var i = 0; i < _providers.Length; ++i)
                        {
                            _manager.RemoveUpdates(singleListener);
                        }
                    },
                        true);
                }

                try
                {
                    var looper = Looper.MyLooper() ?? Looper.MainLooper;

                    var enabled = 0;
                    for (var i = 0; i < _providers.Length; ++i)
                    {
                        if (_manager.IsProviderEnabled(_providers[i]))
                        {
                            enabled++;
                        }

                        _manager.RequestLocationUpdates(_providers[i], 0, 0, singleListener, looper);
                    }

                    if (enabled == 0)
                    {
                        for (var i = 0; i < _providers.Length; ++i)
                        {
                            _manager.RemoveUpdates(singleListener);
                        }

                        tcs.SetException(new GeolocationException(GeolocationError.PositionUnavailable));
                        return(tcs.Task);
                    }
                }
                catch (SecurityException ex)
                {
                    tcs.SetException(new GeolocationException(GeolocationError.Unauthorized, ex));
                    return(tcs.Task);
                }

                return(singleListener.Task);
            }

            // If we're already listening, just use the current listener
            lock (_positionSync)
            {
                if (_lastPosition == null)
                {
                    if (cancelToken != CancellationToken.None)
                    {
                        cancelToken.Register(() => tcs.TrySetCanceled());
                    }

                    EventHandler <PositionEventArgs> gotPosition = null;
                    gotPosition = (s, e) =>
                    {
                        tcs.TrySetResult(e.Position);
                        PositionChanged -= gotPosition;
                    };

                    PositionChanged += gotPosition;
                }
                else
                {
                    tcs.SetResult(_lastPosition);
                }
            }

            return(tcs.Task);
        }
Beispiel #35
0
        /// <summary>
        /// Start listening for changes
        /// </summary>
        /// <param name="minimumTime">Time</param>
        /// <param name="minimumDistance">Distance</param>
        /// <param name="includeHeading">Include heading or not</param>
        /// <param name="listenerSettings">Optional settings (iOS only)</param>
        public async Task <bool> StartListeningAsync(TimeSpan minimumTime, double minimumDistance, bool includeHeading = false, ListenerSettings listenerSettings = null)
        {
            var hasPermission = false;

            if (listenerSettings?.RequireLocationAlwaysPermission ?? false)
            {
                hasPermission = await CheckAlwaysPermissions();
            }
            else
            {
                hasPermission = await CheckWhenInUsePermission();
            }

            if (!hasPermission)
            {
                throw new GeolocationException(GeolocationError.Unauthorized);
            }


            var minTimeMilliseconds = minimumTime.TotalMilliseconds;

            if (minTimeMilliseconds < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(minimumTime));
            }
            if (minimumDistance < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(minimumDistance));
            }
            if (IsListening)
            {
                throw new InvalidOperationException("This Geolocator is already listening");
            }

            var providers = Providers;

            listener = new GeolocationContinuousListener(Manager, minimumTime, providers);
            listener.PositionChanged += OnListenerPositionChanged;
            listener.PositionError   += OnListenerPositionError;

            var looper = Looper.MyLooper() ?? Looper.MainLooper;

            ListeningProviders.Clear();
            for (var i = 0; i < providers.Length; ++i)
            {
                var provider = providers[i];

                //we have limited set of providers
                if (ProvidersToUseWhileListening != null &&
                    ProvidersToUseWhileListening.Length > 0)
                {
                    //the provider is not in the list, so don't use it.
                    if (!ProvidersToUseWhileListening.Contains(provider))
                    {
                        continue;
                    }
                }


                ListeningProviders.Add(provider);
                Manager.RequestLocationUpdates(provider, (long)minTimeMilliseconds, (float)minimumDistance, listener, looper);
            }
            return(true);
        }
 public ICancelable FetchMessages(Action<bool> callback, Looper looper)
 {
     return FetchMessages (new FetchMessagesCallback (callback), looper);
 }
        /// <summary>
        /// Raises the element property changed event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == Label.HorizontalTextAlignmentProperty.PropertyName || e.PropertyName == Label.VerticalTextAlignmentProperty.PropertyName)
            {
                if (Looper.MyLooper() == Looper.MainLooper)
                {
                    Control.Gravity = Element.HorizontalTextAlignment.ToHorizontalGravityFlags() | Element.VerticalTextAlignment.ToVerticalGravityFlags();
                }
                else
                {
                    ((Android.App.Activity)Settings.Context).RunOnUiThread(() =>
                    {
                        Control.Gravity = Element.HorizontalTextAlignment.ToHorizontalGravityFlags() | Element.VerticalTextAlignment.ToVerticalGravityFlags();
                    });
                }
            }
            else if (e.PropertyName == Label.TextColorProperty.PropertyName)
            {
                UpdateColor();
            }
            else if (e.PropertyName == Label.FontSizeProperty.PropertyName)
            {
                UpdateFontSize();
            }
            else if (e.PropertyName == Forms9Patch.Label.MinFontSizeProperty.PropertyName)
            {
                UpdateMinFontSize();
            }
            else if (e.PropertyName == Label.FontProperty.PropertyName || e.PropertyName == Label.FontFamilyProperty.PropertyName || e.PropertyName == Label.FontAttributesProperty.PropertyName)
            {
                UpdateFont();
            }
            else if (e.PropertyName == Label.LineBreakModeProperty.PropertyName)
            {
                UpdateLineBreakMode();
            }
            else if (e.PropertyName == Label.TextProperty.PropertyName || e.PropertyName == Label.HtmlTextProperty.PropertyName)
            {
                UpdateText();
            }
            else if (e.PropertyName == Label.AutoFitProperty.PropertyName)
            {
                UpdateFit();
            }
            else if (e.PropertyName == Label.LinesProperty.PropertyName)
            {
                UpdateLines();
            }
            else if (e.PropertyName == Label.MinFontSizeProperty.PropertyName)
            {
                UpdateMinFontSize();
            }
            else if (e.PropertyName == VisualElement.HeightProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName)
            {
                /*
                 *              //TODO: EVALUATE THE NECESSITY AND EFFICACY OF THIS BLOCK
                 *              if (Element.Width > -1 && Element.Height > -1 && Element.IsVisible)
                 *                      if (Element.Width != _lastControlState.AvailWidth || Element.Height != _lastControlState.AvailHeight)
                 *                      {
                 *                              _lastSizeRequest = null;
                 *                              LayoutForSize((int)(Element.Width * Forms9Patch.Display.Scale), (int)(Element.Height * Forms9Patch.Display.Scale));
                 *                      }
                 */
                Layout();
            }
            else if (e.PropertyName == Label.SynchronizedFontSizeProperty.PropertyName)
            {
                //if (_currentControlState.TextSize > 0)
                //{
                //    var syncFontSize = ((ILabel)Element).SynchronizedFontSize;
                //    if (syncFontSize >= 0 && _currentControlState.TextSize != syncFontSize)
                //    {
                //        _currentControlState.TextSize = -200;
                _currentControlState.SyncFontSize = (float)Element.SynchronizedFontSize;
                Layout();
                //    }
                //}
            }
        }
 /**
  * Makes a request for location updates. Note that in this sample we merely log the
  * {@link SecurityException}.
  */
 public void RequestLocationUpdates()
 {
     Log.Info(Tag, "Requesting location updates");
     Utils.SetRequestingLocationUpdates(this, true);
     StartService(new Intent(ApplicationContext, typeof(LocationUpdatesService)));
     try {
         FusedLocationClient.RequestLocationUpdates(LocationRequest, LocationCallback, Looper.MyLooper());
     } catch (SecurityException unlikely) {
         Utils.SetRequestingLocationUpdates(this, false);
         Log.Error(Tag, "Lost location permission. Could not request updates. " + unlikely);
     }
 }
		internal MotionCall(Looper looper, Smotion motion)
		{
			mCall = new SmotionCall(looper, motion);
		}
Beispiel #40
0
        private async void RetrieveNoticeData()
        {
            await Task.Run(() =>
            {
                try
                {
                    Looper.Prepare();
                }
                catch { }

                Looper l = Looper.MyLooper();

                XDocument doc = null;

                try
                {
                    if (notices == null)
                    {
                        WebClient wc = new WebClient();
                        wc.Headers.Add("User-Agent: UniHub");
                        wc.Proxy = null;
                        doc      = XDocument.Parse(wc.DownloadString("http://abesit.in/category/notices/feed/"));
                    }
                    else
                    {
                        ShowNotices();
                        l.Quit();

                        return;
                    }
                }
                catch
                {
                    RunOnUiThread(() =>
                    {
                        ShowLoader = false;

                        if (IsFinishing)
                        {
                            return;
                        }

                        new AlertDialog.Builder(new ContextThemeWrapper(this, Resource.Style.Dialog))
                        .SetPositiveButton("Okay", (sender, args) =>
                        {
                            l.Quit();

                            this.Finish();
                        })
                        .SetCancelable(false)
                        .SetMessage("Unable to connect to services. Please check your internet connection and try again.")
                        .SetTitle("Connection Error")
                        .Show();

                        return;
                    });
                }

                notices = new List <Notices>();

                if (doc != null)
                {
                    notices = ParseData.ReadNotices.GetNotices(ApplicationContext, doc);
                }
                else
                {
                    ShowLoader = false;

                    l.Quit();

                    StartProcess();

                    return;
                }

                ShowNotices();              // Populate The Notices List

                l.Quit();
            });
        }
        /// <inheritdoc/>
        public async Task <Position> GetPositionAsync(TimeSpan?timeout, CancellationToken?cancelToken = null, bool includeHeading = false)
        {
            var timeoutMilliseconds = timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : Timeout.Infinite;

            if (timeoutMilliseconds <= 0 && timeoutMilliseconds != Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout), "timeout must be greater than or equal to 0");
            }

            if (!cancelToken.HasValue)
            {
                cancelToken = CancellationToken.None;
            }

            var hasPermission = await CheckPermissions();

            if (!hasPermission)
            {
                throw new GeolocationException(GeolocationError.Unauthorized);
            }

            var tcs = new TaskCompletionSource <Position>();

            if (!IsListening)
            {
                var providers = Providers;
                GeolocationSingleListener singleListener = null;
                singleListener = new GeolocationSingleListener(Manager, (float)DesiredAccuracy, timeoutMilliseconds, providers.Where(Manager.IsProviderEnabled),
                                                               finishedCallback: () =>
                {
                    for (int i = 0; i < providers.Length; ++i)
                    {
                        Manager.RemoveUpdates(singleListener);
                    }
                });

                if (cancelToken != CancellationToken.None)
                {
                    cancelToken.Value.Register(() =>
                    {
                        singleListener.Cancel();

                        for (int i = 0; i < providers.Length; ++i)
                        {
                            Manager.RemoveUpdates(singleListener);
                        }
                    }, true);
                }

                try
                {
                    var looper = Looper.MyLooper() ?? Looper.MainLooper;

                    int enabled = 0;
                    for (int i = 0; i < providers.Length; ++i)
                    {
                        if (Manager.IsProviderEnabled(providers[i]))
                        {
                            enabled++;
                        }

                        Manager.RequestLocationUpdates(providers[i], 0, 0, singleListener, looper);
                    }

                    if (enabled == 0)
                    {
                        for (int i = 0; i < providers.Length; ++i)
                        {
                            Manager.RemoveUpdates(singleListener);
                        }

                        tcs.SetException(new GeolocationException(GeolocationError.PositionUnavailable));
                        return(await tcs.Task);
                    }
                }
                catch (Java.Lang.SecurityException ex)
                {
                    tcs.SetException(new GeolocationException(GeolocationError.Unauthorized, ex));
                    return(await tcs.Task);
                }

                return(await singleListener.Task);
            }

            // If we're already listening, just use the current listener
            lock (positionSync)
            {
                if (lastPosition == null)
                {
                    if (cancelToken != CancellationToken.None)
                    {
                        cancelToken.Value.Register(() => tcs.TrySetCanceled());
                    }

                    EventHandler <PositionEventArgs> gotPosition = null;
                    gotPosition = (s, e) =>
                    {
                        tcs.TrySetResult(e.Position);
                        PositionChanged -= gotPosition;
                    };

                    PositionChanged += gotPosition;
                }
                else
                {
                    tcs.SetResult(lastPosition);
                }
            }

            return(await tcs.Task);
        }
Beispiel #42
0
        public async void DownloadPlaylist(List <DownloadFile> files, long LocalID, bool keepDeleted)
        {
            if (LocalID != -1)
            {
                List <Song> songs = await PlaylistManager.GetTracksFromLocalPlaylist(LocalID);

                await Task.Run(() =>
                {
                    foreach (Song song in songs)
                    {
                        LocalManager.CompleteItem(song);
                    }
                });

                for (int i = 0; i < files.Count; i++)
                {
                    Song song = songs.Find(x => x.YoutubeID == files[i].YoutubeID);
                    if (song != null)
                    {
                        //Video is already in the playlist, we want to check if this item has been reordered.
                        if (int.Parse(song.TrackID) != i)
                        {
                            //The plus one is because android playlists have one-based indexes.
                            PlaylistManager.SetQueueSlot(LocalID, song.LocalID, i + 1);
                        }

                        //Video is already downloaded:
                        if (files[i].State == DownloadState.None)
                        {
                            files[i].State = DownloadState.UpToDate;
                        }

                        currentStrike++;
                        songs.Remove(song);
                    }
                }

                queue.RemoveAll(x => x.State == DownloadState.Completed || x.State == DownloadState.UpToDate || x.State == DownloadState.Canceled);
                if (files.Count(x => x.State == DownloadState.None) > 0)
                {
                    queue.AddRange(files);
                    StartDownload();
                }
                else
                {
                    Toast.MakeText(MainActivity.instance, Resource.String.playlist_uptodate, ToastLength.Long).Show();
                }

                await Task.Run(() =>
                {
                    if (Looper.MyLooper() == null)
                    {
                        Looper.Prepare();
                    }

                    for (int i = 0; i < songs.Count; i++)
                    {
                        //Video has been removed from the playlist but still exist on local storage
                        ContentResolver resolver = Application.ContentResolver;
                        Uri uri = Playlists.Members.GetContentUri("external", LocalID);
                        resolver.Delete(uri, Playlists.Members.Id + "=?", new string[] { songs[i].LocalID.ToString() });

                        if (!keepDeleted)
                        {
                            File.Delete(songs[i].Path);
                        }
                    }
                });
            }

            await Task.Delay(1000);

            Playlist.instance?.CheckForSync();
        }
Beispiel #43
0
        public async Task <Position> GetPositionAsync(TimeSpan?timeout = null, CancellationToken?cancelToken = null)
        {
            var timeoutMilliseconds = timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : Timeout.Infinite;

            if (timeoutMilliseconds <= 0 && timeoutMilliseconds != Timeout.Infinite)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout), "Timeout must be greater than or equal to 0");
            }

            if (!cancelToken.HasValue)
            {
                cancelToken = CancellationToken.None;
            }

            var hasPermission = await CheckPermissionsAsync();

            if (!hasPermission)
            {
                throw new GeolocationException(GeolocationError.Unauthorized);
            }

            var tcs = new TaskCompletionSource <Position>();

            var providers = new List <string>();

            if (ProvidersToUse == null || ProvidersToUse.Length == 0)
            {
                providers.AddRange(Providers);
            }
            else
            {
                foreach (var provider in Providers)
                {
                    if (ProvidersToUse?.Contains(provider) ?? false)
                    {
                        continue;
                    }
                    providers.Add(provider);
                }
            }

            void SingleListenerFinishCallback()
            {
                if (_singleListener == null)
                {
                    return;
                }

                for (int i = 0; i < providers.Count; ++i)
                {
                    Manager.RemoveUpdates(_singleListener);
                }
            }

            _singleListener = new GeolocationSingleListener(Manager, (float)DesiredAccuracy, timeoutMilliseconds, providers.Where(Manager.IsProviderEnabled), finishedCallback: SingleListenerFinishCallback);
            if (cancelToken != CancellationToken.None)
            {
                cancelToken.Value.Register(() =>
                {
                    _singleListener.Cancel();

                    for (int i = 0; i < providers.Count; ++i)
                    {
                        Manager.RemoveUpdates(_singleListener);
                    }
                }, true);
            }

            try
            {
                var looper  = Looper.MyLooper() ?? Looper.MainLooper;
                int enabled = 0;
                for (var i = 0; i < providers.Count; ++i)
                {
                    if (Manager.IsProviderEnabled(providers[i]))
                    {
                        enabled++;
                    }

                    Manager.RequestLocationUpdates(providers[i], 0, 0, _singleListener, looper);
                }

                if (enabled == 0)
                {
                    for (int i = 0; i < providers.Count; ++i)
                    {
                        Manager.RemoveUpdates(_singleListener);
                    }

                    tcs.SetException(new GeolocationException(GeolocationError.PositionUnavailable));
                    return(await tcs.Task);
                }
            }
            catch (Java.Lang.SecurityException ex)
            {
                tcs.SetException(new GeolocationException(GeolocationError.Unauthorized, ex));
                return(await tcs.Task);
            }
            return(await _singleListener.Task);
        }
Beispiel #44
0
 public virtual void Run(Action <ActionArguments, ActionResult> callback, Looper looper)
 {
     Run(new ActionCompletionCallback(callback), looper);
 }
Beispiel #45
0
        static async Task <Location> PlatformLocationAsync(GeolocationRequest request, CancellationToken cancellationToken)
        {
            await Permissions.RequireAsync(PermissionType.LocationWhenInUse);

            var locationManager = Platform.LocationManager;

            var enabledProviders = locationManager.GetProviders(true);
            var hasProviders     = enabledProviders.Any(p => !ignoredProviders.Contains(p));

            if (!hasProviders)
            {
                throw new FeatureNotEnabledException("Location services are not enabled on device.");
            }

            // get the best possible provider for the requested accuracy
            var providerInfo = GetBestProvider(locationManager, request.DesiredAccuracy);

            // if no providers exist, we can't get a location
            // let's punt and try to get the last known location
            if (string.IsNullOrEmpty(providerInfo.Provider))
            {
                return(await GetLastKnownLocationAsync());
            }

            var tcs = new TaskCompletionSource <AndroidLocation>();

            var allProviders = locationManager.GetProviders(false);

            var providers = new List <string>();

            if (allProviders.Contains(LocationManager.GpsProvider))
            {
                providers.Add(LocationManager.GpsProvider);
            }
            if (allProviders.Contains(LocationManager.NetworkProvider))
            {
                providers.Add(LocationManager.NetworkProvider);
            }

            if (providers.Count == 0)
            {
                providers.Add(providerInfo.Provider);
            }

            var listener = new SingleLocationListener(locationManager, providerInfo.Accuracy, providers);

            listener.LocationHandler = HandleLocation;

            cancellationToken = Utils.TimeoutToken(cancellationToken, request.Timeout);
            cancellationToken.Register(Cancel);

            // start getting location updates
            // make sure to use a thread with a looper
            var looper = Looper.MyLooper() ?? Looper.MainLooper;

            foreach (var provider in providers)
            {
                locationManager.RequestLocationUpdates(provider, 0, 0, listener, looper);
            }

            var androidLocation = await tcs.Task;

            if (androidLocation == null)
            {
                return(null);
            }

            return(androidLocation.ToLocation());

            void HandleLocation(AndroidLocation location)
            {
                RemoveUpdates();
                tcs.TrySetResult(location);
            }

            void Cancel()
            {
                RemoveUpdates();
                tcs.TrySetResult(listener.BestLocation);
            }

            void RemoveUpdates()
            {
                for (var i = 0; i < providers.Count; i++)
                {
                    locationManager.RemoveUpdates(listener);
                }
            }
        }
 public RenderingHandler(Looper looper, PdfView pdfView) : base(looper)
 {
     this.pdfView = pdfView;
 }
 void Start()
 {
     Looper = new Looper(1.0f, true, CheckAlive);
 }
        public void StartLocationRequest()
        {
            if (activity != null)
            {
                LocationRequest request = new LocationRequest()
                                          .SetPriority(LocationRequest.PriorityHighAccuracy)
                                          .SetFastestInterval(1000)
                                          .SetInterval(10000);

                LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
                builder.AddLocationRequest(request);
                LocationServices.GetSettingsClient(activity).CheckLocationSettings(builder.Build());

                LocationServices.GetFusedLocationProviderClient(activity).RequestLocationUpdates(request, mCallback, Looper.MyLooper());
            }
        }
Beispiel #49
0
 void GPS_StatusChange()
 {
     try
     {
         if (_locationService is null)
         {
             _locationManager = (LocationManager)GetSystemService(Context.LocationService);
             Criteria criteriaForLocationService = new Criteria
             {
                 Accuracy = Accuracy.Fine
             };
             IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);
             if (acceptableLocationProviders.Any())
             {
                 _locationManager.RequestLocationUpdates(acceptableLocationProviders.First(), 0, 0, this);
             }
             _locationService = LocationServices.GetFusedLocationProviderClient(this);
             var locationRequest = new LocationRequest();
             locationRequest.SetInterval(180000);
             locationRequest.SetFastestInterval(90000);
             locationRequest.SetPriority(LocationRequest.PriorityHighAccuracy);
             _providerCallback = new FusedLocationProviderCallback();
             _locationService.RequestLocationUpdates(locationRequest, _providerCallback, Looper.MyLooper());
         }
     }
     catch (Exception e)
     {
         //Crashes.TrackError(e);
     }
 }
 public static ICancelable Shared(Action <UAirship> callback, Looper looper)
 {
     return(Shared(new AirshipReadyCallback(callback), looper));
 }