private void RefreshWorker_Namespace() { ThreadPool.QueueUserWorkItem(delegate(object state) { List <IoTHubConnection> sbNamespaces = null; this.InvokeEx(delegate() { sbNamespaces = this.IoTHubNamespaces; this.dataGridViewNamespaces.Enabled = false; this.buttonOK.Enabled = false; this.buttonRefresh.Enabled = false; this.buttonRefresh.Text = "Loading"; }); using (var progress = new ProgressButton(this, this.buttonRefresh, 1, 0)) { int rowIndex = 0; foreach (IoTHubConnection item in sbNamespaces) { string errorText = string.Empty; try { if (!string.IsNullOrEmpty(item.Namespace) && !string.IsNullOrEmpty(item.ConnectionString)) { string iothubNamespace = SharedAccessSignatureBuilder.GetHostNameNamespaceFromConnectionString(item.ConnectionString); if (string.Compare(iothubNamespace, item.Namespace, true) != 0) { throw new Exception("Wrong namespace name"); } var devices = ServiceHelper.GetDevicesAsync(item.ConnectionString).Result; } } catch (Exception ex) { errorText = ex.InnerMessage(); } this.InvokeEx(delegate() { this.dataGridViewNamespaces.Rows[rowIndex].Cells[this.ColumnStatus.Name].ErrorText = errorText == null ? string.Empty : errorText; }); rowIndex++; } } this.InvokeEx(delegate() { this.dataGridViewNamespaces.Enabled = true; this.buttonRefresh.Text = "Refresh"; this.buttonRefresh.Enabled = true; if (this.dataGridViewNamespaces.SelectedRows.Count > 0) { string errText = this.dataGridViewNamespaces.Rows[this.dataGridViewNamespaces.SelectedRows[0].Index].Cells[this.ColumnStatus.Name].ErrorText; this.buttonOK.Enabled = string.IsNullOrEmpty(errText) && this.dataGridViewNamespaces.SelectedRows[0].Index != this.dataGridViewNamespaces.Rows.Count - 1; } }); }); }
private ProgressButton AddProgressButton(LinearLayout container) { var layoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WrapContent, 1.0f); var progressButton = new ProgressButton(this); progressButton.LayoutParameters = layoutParams; container.AddView(progressButton); return(progressButton); }
private void UpdateProgressButton(ProgressButton progressButton, SeekBar progressSeekBar) { if (progressButton.Indeterminante) { return; } progressButton.Progress = progressSeekBar.Progress; UpdatePinProgressContentDescription(progressButton); }
public void initializeComponentRefs() { progressButton = actionUI.GetComponentInChildren <ProgressButton>(); labelButton = actionUI.GetComponentInChildren <Button>(); c = Camera.main; actionUIRect = actionUI.GetComponent <RectTransform>(); var textList = actionUI.GetComponentsInChildren <TMPro.TextMeshProUGUI>(); actionUITextMesh = textList[0]; persistentLabel = textList[1]; labelRect = persistentLabel.gameObject.GetComponent <RectTransform>(); labelPosition = labelRect.anchoredPosition; actionTextRect = actionUITextMesh.gameObject.GetComponent <RectTransform>(); parentCanvas = actionUI.GetComponentInParent <Canvas>(); parentCanvasRect = parentCanvas.gameObject.GetComponent <RectTransform>(); screenspaceAction = HUDManager.Instance.GetComponentInChildren <HUD.ScreenspaceActionUI>(); progressButtonRect = progressButton.gameObject.GetComponent <RectTransform>(); progressPosition = new Vector3(0, 0, 0); trackerRect = actionUI.gameObject.GetComponentsInChildren <Canvas>(true)[2].gameObject.GetComponent <RectTransform>(); scaler = actionUI.GetComponentInChildren <UIScaler>(); playerTransform = GameObject.FindWithTag("Player").transform; }
private void UpdatePinProgressContentDescription(ProgressButton button) { if (button.Progress <= 0) { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_not_downloaded : Resource.String.content_desc_unpinned_not_downloaded); } else if (button.Progress >= 100) { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_downloaded : Resource.String.content_desc_unpinned_downloaded); } else { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_downloading : Resource.String.content_desc_unpinned_downloading); } }
private void ProgressButton_Click(object sender, EventArgs e) { if (ProgressButton.Text == "Stop") { if (Job != null) { #pragma warning disable CS0618 // Type or member is obsolete Job.Suspend(); EnabledComp(); ProgressButton.Text = "Resume"; ProgressButton.Refresh(); #pragma warning restore CS0618 // Type or member is obsolete return; } } else { if (Job != null) { #pragma warning disable CS0618 // Type or member is obsolete Job.Resume(); ProgressButton.Text = "Stop"; DisabledComp(); #pragma warning restore CS0618 // Type or member is obsolete return; } } try { new Uri(TxtPostID.Text); } catch (Exception) { this.FlatAlertBox.kind = FlatAlertBox._Kind.Error; this.FlatAlertBox.Visible = true; this.FlatAlertBox.Text = "Please enter Post ID"; return; } if (IntVoteOption.Value <= 0) { this.FlatAlertBox.kind = FlatAlertBox._Kind.Error; this.FlatAlertBox.Visible = true; this.FlatAlertBox.Text = "Please enter Vote Option"; return; } if (AccountsData.Count <= 0) { this.FlatAlertBox.kind = FlatAlertBox._Kind.Error; this.FlatAlertBox.Visible = true; this.FlatAlertBox.Text = "Please add Accounts"; return; } if (!int.TryParse(TxtFrom.Text, out int validFrom)) { TxtFrom.Text = "0"; } if (!int.TryParse(TxtTo.Text, out int validTo)) { TxtTo.Text = AccountsData.Count.ToString(); } this.FlatAlertBox.kind = FlatAlertBox._Kind.Success; this.FlatAlertBox.Visible = true; this.FlatAlertBox.Text = "Start ..."; if (!this.ProgressOngoing) { DisabledComp(); this.ProgressOngoing = true; this.FlatProgressBar.Value = 0; int.TryParse(TxtTo.Text, out int VoteNumber); int.TryParse(TxtFrom.Text, out int from); SetText($"Twitter Auto Voter ({(VoteNumber == 0 ? (AccountsData.Count - from) : (VoteNumber - from))} / 0)"); DoWork(); } }
private void EnabledComp() { TxtPostID.Enabled = TxtTo.Enabled = TxtFrom.Enabled = BtnAddAccounts.Enabled = BtnDeleteAccounts.Enabled = BtnRemoveCookies.Enabled = IntInterval.Enabled = IntVoteOption.Enabled = true; ProgressButton.Text = "Start"; ProgressButton.Refresh(); }
private void UpdatePinProgressContentDescription(ProgressButton button) { if (button.Progress <= 0) { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_not_downloaded : Resource.String.content_desc_unpinned_not_downloaded); } else if (button.Progress >= 100) { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_downloaded : Resource.String.content_desc_unpinned_downloaded); } else { button.ContentDescription = GetString(button.Pinned ? Resource.String.content_desc_pinned_downloading : Resource.String.content_desc_unpinned_downloading); } }
private ProgressButton AddProgressButton(LinearLayout container) { var layoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WrapContent, 1.0f); var progressButton = new ProgressButton(this); progressButton.LayoutParameters = layoutParams; container.AddView(progressButton); return progressButton; }
private void UpdateProgressButton(ProgressButton progressButton, SeekBar progressSeekBar) { if (progressButton.Indeterminante) return; progressButton.Progress = progressSeekBar.Progress; UpdatePinProgressContentDescription(progressButton); }