public void UpdateValue(Dictionary <UnityViewOptions, object> options, TimerHolder serverTimeHolder) { if (!options.ContainsKey(UnityViewOptions.BlurAnimate)) { gameObject.SetActive(false); return; } UnityField <float?> blurOptions = (UnityField <float?>)options[UnityViewOptions.BlurAnimate]; float?startValue = blurOptions.StartValue; float?endValue = blurOptions.EndValue; if (blurOptions?.StartTime == null || blurOptions?.EndTime == null || serverTimeHolder?.ServerTime == null) { return; } DateTime startTime = blurOptions.StartTime.Value; DateTime endTime = blurOptions.EndTime.Value; DateTime serverCurrentTime = serverTimeHolder.ServerTime.Value; foreach (Image mask in blurMasks) { mask.enabled = true; } this.startValue = startValue ?? 1; this.endValue = endValue ?? 0; this.timeTilStart = (float)startTime.Subtract(serverCurrentTime).TotalSeconds; this.timeTilEnd = (float)endTime.Subtract(serverCurrentTime).TotalSeconds; superBlur.downsample = 0; superBlur.iterations = 6; }
void btnMetronome_Start(object sender, EventArgs e) { int tempo; bool isNumber = int.TryParse(txtMetronome.Text, out tempo); if (!isNumber && tempo <= 0) { lblMetronomeError.IsVisible = true; return; } lblMetronomeError.IsVisible = false; if (tempo > 250) { txtMetronome.Text = "250"; } ToggleMetronomeButtons(true); ToggleMetronomeTextBox(false); // in millieseconds _metronomeSpeed = 60000 / tempo; // close file if file is open, then open file _audioService.CloseFile(); _audioService.OpenFile("click.mp3"); // show the text temporarily til we get sound _metronome = new TimerHolder(_metronomeSpeed, () => { lblMetronome.Text = (_beatCounter++).ToString(); _audioService.PlayAudioFile(); }); }
protected override void OnCreate(Bundle savedInstanceState) { DataUtils.Init(); _timerHolder = new TimerHolder(UpdateInterval, CheckNewData); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); FindViewById <TextView>(Resource.Id.btnSettings) .Click += (sender, args) => StartSettingsActivity(); _pingIndicator = FindViewById <ImageView>(Resource.Id.ivPing); _tvTitle = FindViewById <TextView>(Resource.Id.tvTitle); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); _layoutManager = new LinearLayoutManager(this); _recyclerView.SetLayoutManager(_layoutManager); _adapter = new MachinesAdapter(_machines); _recyclerView.SetAdapter(_adapter); _adapter.ItemClicked += StartSelectedMachineActivity; _scrollListener = new CustomScrollListener(); _recyclerView.AddOnScrollListener(_scrollListener); InitDataUpdating(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _timerHolder = new TimerHolder(UpdateInterval, CheckNewData); SetContentView(Resource.Layout.activity_settings); InitActionBar(Resource.String.settings); _tvCity = FindViewById <TextView>(Resource.Id.tvCityValue); _tvCity.Click += (sender, args) => StartFilterActivity(eFilterType.City); _tvDivision = FindViewById <TextView>(Resource.Id.tvUnitValue); _tvDivision.Click += (sender, args) => StartFilterActivity(eFilterType.Division); _tvFacilityType = FindViewById <TextView>(Resource.Id.tvFacilityTypeValue); _tvFacilityType.Click += (sender, args) => StartFilterActivity(eFilterType.FacilityType); _tvWorkState = FindViewById <TextView>(Resource.Id.tvWorkSateValue); _tvWorkState.Click += (sender, args) => StartFilterActivity(eFilterType.WorkState); _tvServiceState = FindViewById <TextView>(Resource.Id.tvServiceStateValue); _tvServiceState.Click += (sender, args) => StartFilterActivity(eFilterType.ServiceState); _swOnlyMy = FindViewById <Switch>(Resource.Id.swOnlyMy); _swOnlyMy.CheckedChange += SwOnlyMyOnCheckedChange; _ivFacilityType = FindViewById <ImageView>(Resource.Id.ivFacilityType); _ivWorkSate = FindViewById <ImageView>(Resource.Id.ivWorkSate); _ivServiceState = FindViewById <ImageView>(Resource.Id.ivServiceState); _tvUserNameValue = FindViewById <TextView>(Resource.Id.tvUserNameValue); _tvUserNameValue.Text = DataManager.UserName; _tvUserNameValue.Click += (sender, args) => StartUserActivity(); InitDataUpdating(); }
/// <summary> /// Schedules a <see cref="CancellationTokenSource.Cancel()"/> operation on a <see cref="CancellationTokenSource"/> /// after the specified time span. /// </summary> /// <remarks> /// <para>If a previous call to this method scheduled a cancellation, the cancellation time is /// reset to the new <paramref name="delay"/> value. This method has no effect if the /// <see cref="CancellationTokenSource"/> has already been canceled (i.e. the /// <see cref="CancellationTokenSource.IsCancellationRequested"/> property returns /// <see langword="true"/>.</para> /// <para> /// In all versions of .NET, requesting cancellation of a <see cref="CancellationTokenSource"/> will /// not prevent the instance from becoming eligible for garbage collection prior to the timer expiring. /// In .NET 4 and newer, any associated <see cref="T:System.Threading.Timer"/> instance will become eligible for /// garbage collection at the same time as the associated <see cref="CancellationTokenSource"/>. /// </para> /// </remarks> /// <param name="cts">The <see cref="CancellationTokenSource"/> to cancel after a delay.</param> /// <param name="delay">The time span to wait before canceling the <see cref="CancellationTokenSource"/>.</param> /// <exception cref="ArgumentNullException">If <paramref name="cts"/> is <see langword="null"/>.</exception> /// <exception cref="ObjectDisposedException">If <paramref name="cts"/> has been disposed.</exception> /// <exception cref="ArgumentOutOfRangeException">If the <see cref="TimeSpan.TotalMilliseconds"/> property of <paramref name="delay"/> is less than -1 or greater than <see cref="int.MaxValue"/>.</exception> public static void CancelAfter(this CancellationTokenSource cts, TimeSpan delay) { if (cts == null) { throw new ArgumentNullException("cts"); } if (delay.TotalMilliseconds < -1 || delay.TotalMilliseconds > int.MaxValue) { throw new ArgumentOutOfRangeException("delay"); } if (cts.IsCancellationRequested) { return; } #if NET40PLUS TimerHolder holder = _timers.GetOrCreateValue(cts); try { holder.GetOrCreateTimer(cts).Change(delay, TimeSpan.FromMilliseconds(-1)); } catch (ObjectDisposedException) { } #else Timer timer = _timers.GetOrAdd(new HashedWeakReference <CancellationTokenSource>(cts), CreateTimer); timer.Change(delay, TimeSpan.FromMilliseconds(-1)); #endif }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _timerHolder = new TimerHolder(UpdateInterval, CheckNewData); SetContentView(Resource.Layout.activity_service_request); InitActionBar(Resource.String.service_intend); _tvTakeForRepair = FindViewById <TextView>(Resource.Id.tvTakeForRepair); _tvRefuseToRepair = FindViewById <TextView>(Resource.Id.tvRefuseToRepair); _tvTakeForRepair.Click += (sender, args) => TakeForRepair(); _tvRefuseToRepair.Click += (sender, args) => RefuseToRepair(); _tvMachineNumberRequest = FindViewById <TextView>(Resource.Id.tvMachineNumberRequest); _ivStateRequest = FindViewById <ImageView>(Resource.Id.ivStateRequest); _tvStateNameRequest = FindViewById <TextView>(Resource.Id.tvStateNameRequest); _tvStartTimeRequest = FindViewById <TextView>(Resource.Id.tvStartTimeRequest); _tvUserRequest = FindViewById <TextView>(Resource.Id.tvUserRequest); _etRequest = FindViewById <EditText>(Resource.Id.etRequest); InitCurrentMachine(); InitDataUpdating(); }
public void Start() { ioda = GetComponent<IODA.IODAAgent> (); if (timerHolder == null) { timerHolder = gameObject.AddComponent<TimerHolder> (); timerHolder.Prepare(); } }
public void UpdateValue(TimerHolder timerHolder) { DateTime?currentTime = timerHolder.ServerTime; DateTime?endTime = timerHolder.StateEndTime; if (currentTime != null && endTime != null) { timeRemainingInSeconds = ((DateTime)endTime).Subtract((DateTime)currentTime).TotalSeconds; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _timerHolder = new TimerHolder(UpdateInterval, CheckNewData); SetContentView(Resource.Layout.activity_filters_list); InitActionBar(); _listView = FindViewById <ListView>(Resource.Id.lvFilters); _listView.ChoiceMode = ChoiceMode.Single; _listView.ItemClick += OnListItemClick; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _timerHolder = new TimerHolder(UpdateInterval, CheckNewData); SetContentView(Resource.Layout.activity_machine_details); _plotView = FindViewById <HistoryGraphView>(Resource.Id.plotHistory); FindViewById <TextView>(Resource.Id.tvService) .Click += (sender, args) => StartServiceRequestActivity(); FindViewById <ImageView>(Resource.Id.ivSensorAlerts) .Click += (sender, args) => StartSensorAlertsActivity(); InitCurrentMachine(); InitMachineStatesLogListView(); InitDataUpdating(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _timerHolder = new TimerHolder(UpdateInterval, UpdateConnectionStatus); _sensorBorders = new SensorBordersList(); _sensorBorder = new SensorBorder(); SetContentView(Resource.Layout.activity_sensor_alerts); InitActionBar(Resource.String.sensor_alerts); FindViewById <TextView>(Resource.Id.tvSave) .Click += (sender, args) => Save(); FindViewById <TextView>(Resource.Id.tvCancel) .Click += (sender, args) => Cancel(); _tvMachineNumber = FindViewById <TextView>(Resource.Id.tvMachineNumberAlert); _ivMachineIcon = FindViewById <ImageView>(Resource.Id.ivMachineIcon); _tvMachineName = FindViewById <TextView>(Resource.Id.tvMachineNameAlert); _tvDivisionName = FindViewById <TextView>(Resource.Id.tvDescriptionAlert); _etToleranceFromValue = FindViewById <EditText>(Resource.Id.etToleranceFromValue); _ivSensorIcon = FindViewById <ImageView>(Resource.Id.ivSensorIcon); _etToValue = FindViewById <EditText>(Resource.Id.etToValue); _tvValueSymbolFrom = FindViewById <TextView>(Resource.Id.tvValueSymbolFrom); _tvValueSymbolTo = FindViewById <TextView>(Resource.Id.tvValueSymbolTo); _etHour = FindViewById <EditText>(Resource.Id.etHour); _etHour.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(4), new MinMaxInputFilter(0, 9999) }); _etMin = FindViewById <EditText>(Resource.Id.etMin); _etMin.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(2), new MinMaxInputFilter(0, 59) }); _etSec = FindViewById <EditText>(Resource.Id.etSec); _etSec.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(2), new MinMaxInputFilter(0, 59) }); InitCurrentMachine(); InitDataUpdating(); }