/// <summary> /// Constructor. /// </summary> public TRtbHyperlinks() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); #region CATALOGI18N // this code has been inserted by GenerateI18N, all changes in this region will be overwritten by GenerateI18N #endregion FDisplayHelper = new DisplayHelper(this); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_EMAILLINK); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_URLLINK); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_URLWITHVALUELINK); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_SECUREDURL); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_FTPLINK); SupportedLinkTypes.Add(THyperLinkHandling.HYPERLINK_PREFIX_SKYPELINK); PlainRTFFormatting(rtbTextWithLinks); WriteLinkRTF(rtbTextWithLinks); rtbTextWithLinks.SelectionStart = 0; rtbTextWithLinks.DetectUrls = false; rtbTextWithLinks.Click += new System.EventHandler(rtbTextWithLinks_Click); rtbTextWithLinks.MouseMove += new System.Windows.Forms.MouseEventHandler(rtbTextWithLinks_MouseMove); }
public async Task <Tuple <bool, IBaseEventTriggerModel> > TriggerProcess <T>(T model, ProcessConfigModel processConfigModel) where T : BaseEventTriggerModel <T> { var isExcute = false; var hWnd = IntPtr.Zero; var applciationData = ObjectExtensions.GetInstance <ApplicationDataManager>().Find(model.ProcessInfo.ProcessName) ?? new ApplicationDataModel(); for (int i = 0; i < processConfigModel.Processes.Count; ++i) { var factor = CalculateFactor(processConfigModel.Processes[i].MainWindowHandle, model, applciationData.IsDynamic); if (string.IsNullOrEmpty(applciationData.HandleName)) { hWnd = processConfigModel.Processes[i].MainWindowHandle; } else { var item = NativeHelper.GetChildHandles(processConfigModel.Processes[i].MainWindowHandle).Where(r => r.Item1.Equals(applciationData.HandleName)).FirstOrDefault(); if (item != null) { hWnd = item.Item2; } else { hWnd = processConfigModel.Processes[i].MainWindowHandle; } } if (model.RepeatInfo.RepeatType == RepeatType.Search && model.SubEventTriggers.Count > 0) { var count = model.RepeatInfo.Count; while (DisplayHelper.ProcessCapture(processConfigModel.Processes[i], out Bitmap bmp, applciationData.IsDynamic) && count-- > 0) { var targetBmp = model.Image.Resize((int)Math.Truncate(model.Image.Width * factor.Item1.Item1), (int)Math.Truncate(model.Image.Height * factor.Item1.Item1)); var similarity = OpenCVHelper.Search(bmp, targetBmp, out Point location, processConfigModel.SearchImageResultDisplay); LogHelper.Debug($"RepeatType[Search : {count}] : >>>> Similarity : {similarity} % max Loc : X : {location.X} Y: {location.Y}"); this.baseContentView.CaptureImage(bmp); if (!await TaskHelper.TokenCheckDelayAsync(model.AfterDelay, processConfigModel.Token) || similarity > processConfigModel.Similarity) { break; } for (int ii = 0; ii < model.SubEventTriggers.Count; ++ii) { await TriggerProcess(model.SubEventTriggers[ii], processConfigModel); if (processConfigModel.Token.IsCancellationRequested) { break; } } factor = CalculateFactor(processConfigModel.Processes[i].MainWindowHandle, model, applciationData.IsDynamic); } } else { var targetBmp = model.Image.Resize((int)Math.Truncate(model.Image.Width * factor.Item1.Item1), (int)Math.Truncate(model.Image.Height * factor.Item1.Item2)); if (model.SameImageDrag == true) { if (DisplayHelper.ProcessCapture(processConfigModel.Processes[i], out Bitmap bmp, applciationData.IsDynamic)) { //Todo for (int ii = 0; ii < model.MaxSameImageCount; ++ii) { var locations = OpenCVHelper.MultipleSearch(bmp, targetBmp, processConfigModel.Similarity, 2, processConfigModel.SearchImageResultDisplay); if (locations.Count > 1) { this.baseContentView.CaptureImage(bmp); SameImageMouseDragTriggerProcess(hWnd, locations[0], locations[1], model, factor.Item2); } else { break; } } } } else if (DisplayHelper.ProcessCapture(processConfigModel.Processes[i], out Bitmap bmp, applciationData.IsDynamic)) { var similarity = OpenCVHelper.Search(bmp, targetBmp, out Point location, processConfigModel.SearchImageResultDisplay); LogHelper.Debug($"Similarity : {similarity} % max Loc : X : {location.X} Y: {location.Y}"); if (model.SameImageDrag == false) { this.baseContentView.CaptureImage(bmp); } if (similarity > processConfigModel.Similarity) { if (model.SubEventTriggers.Count > 0) { if (model.RepeatInfo.RepeatType == RepeatType.Count || model.RepeatInfo.RepeatType == RepeatType.Once) { for (int ii = 0; ii < model.RepeatInfo.Count; ++ii) { if (!await TaskHelper.TokenCheckDelayAsync(model.AfterDelay, processConfigModel.Token)) { break; } for (int iii = 0; iii < model.SubEventTriggers.Count; ++iii) { await TriggerProcess(model.SubEventTriggers[iii], processConfigModel); if (processConfigModel.Token.IsCancellationRequested) { break; } } } } else if (model.RepeatInfo.RepeatType == RepeatType.NoSearch) { while (await TaskHelper.TokenCheckDelayAsync(model.AfterDelay, processConfigModel.Token)) { isExcute = false; for (int ii = 0; ii < model.SubEventTriggers.Count; ++ii) { var childResult = await TriggerProcess(model.SubEventTriggers[ii], processConfigModel); if (processConfigModel.Token.IsCancellationRequested) { break; } if (isExcute == false && childResult.Item1) { isExcute = childResult.Item1; } } if (!isExcute) { break; } } } } else { isExcute = true; if (model.EventType == EventType.Mouse) { location.X = applciationData.OffsetX; location.Y = applciationData.OffsetY; MouseTriggerProcess(hWnd, location, model, factor.Item2, processConfigModel); } else if (model.EventType == EventType.Image) { var percentageX = _random.NextDouble(); var percentageY = _random.NextDouble(); location.X = ((location.X + applciationData.OffsetX) / factor.Item2.Item1) + (targetBmp.Width / factor.Item2.Item1 * percentageX); location.Y = ((location.Y + applciationData.OffsetY) / factor.Item2.Item2) + (targetBmp.Height / factor.Item2.Item1 * percentageY); ImageTriggerProcess(hWnd, location, model); } else if (model.EventType == EventType.RelativeToImage) { location.X = ((location.X + applciationData.OffsetX) / factor.Item2.Item1) + (targetBmp.Width / factor.Item2.Item1 / 2); location.Y = ((location.Y + applciationData.OffsetY) / factor.Item2.Item2) + (targetBmp.Height / factor.Item2.Item2 / 2); ImageTriggerProcess(hWnd, location, model); } else if (model.EventType == EventType.Keyboard) { KeyboardTriggerProcess(processConfigModel.Processes[i].MainWindowHandle, model); } if (!await TaskHelper.TokenCheckDelayAsync(model.AfterDelay, processConfigModel.Token)) { break; } if (model.EventToNext > 0 && model.TriggerIndex != model.EventToNext) { IBaseEventTriggerModel nextModel = null; if (model is GameEventTriggerModel) { nextModel = ObjectExtensions.GetInstance <CacheDataManager>().GetGameEventTriggerModel(model.EventToNext); } else if (model is EventTriggerModel) { nextModel = ObjectExtensions.GetInstance <CacheDataManager>().GetEventTriggerModel(model.EventToNext); } if (nextModel != null) { LogHelper.Debug($">>>>Next Move Event : CurrentIndex [ {model.TriggerIndex} ] NextIndex [ {nextModel.TriggerIndex} ] "); return(Tuple.Create(isExcute, nextModel)); } } } } } } } await TaskHelper.TokenCheckDelayAsync(processConfigModel.ItemDelay, processConfigModel.Token); return(Tuple.Create <bool, IBaseEventTriggerModel>(isExcute, null)); }
public void UpdateAccountDisplay() { Console.Clear(); ViewAllAccounts(); Console.WriteLine("\t\t\tEnter AccountHolderID to update\n\t\t\tEnter B to go back"); string UpdateResponse = ValidatorHelper.StringValidator(120, 13); if (UpdateResponse != "B") { Console.Clear(); InputForm.AddAccountField(); AccountHolder accountHolder = accountService.GetAccountHolderById(UpdateResponse); if (accountHolder != null) { DisplayHelper.PrintTextAtXY(40, 10, accountHolder.FirstName); DisplayHelper.PrintTextAtXY(40, 12, accountHolder.LastName); DisplayHelper.PrintTextAtXY(40, 14, accountHolder.Dob.ToString()); DisplayHelper.PrintTextAtXY(40, 16, accountHolder.Email); DisplayHelper.PrintTextAtXY(40, 18, accountHolder.PanNumber); DisplayHelper.PrintTextAtXY(40, 20, accountHolder.ContactNumber.ToString()); DisplayHelper.PrintTextAtXY(40, 22, accountHolder.address.addressLine1); DisplayHelper.PrintTextAtXY(40, 24, accountHolder.address.addressLine2); DisplayHelper.PrintTextAtXY(40, 26, accountHolder.address.city); DisplayHelper.PrintTextAtXY(40, 28, accountHolder.address.state); DisplayHelper.PrintTextAtXY(40, 30, accountHolder.address.pincode); DisplayHelper.PrintTextAtXY(40, 34, accountHolder.AccountHolderId); DisplayHelper.PrintTextAtXY(40, 36, "**********"); string FieldToUpdate; do { DisplayHelper.PrintTextAtXY(40, 40, "Enter The Field No To Update or Q to go back"); FieldToUpdate = ValidatorHelper.StringValidator(40, 42); if (FieldToUpdate == "1") { accountHolder.FirstName = ValidatorHelper.StringValidator(40, 10); } else if (FieldToUpdate == "2") { accountHolder.LastName = ValidatorHelper.StringValidator(40, 12); } else if (FieldToUpdate == "3") { accountHolder.Dob = ValidatorHelper.DateValidator(40, 14); } else if (FieldToUpdate == "4") { accountHolder.Email = ValidatorHelper.EmailValidator(40, 16); } else if (FieldToUpdate == "5") { accountHolder.PanNumber = ValidatorHelper.PanValidator(40, 18); } else if (FieldToUpdate == "6") { accountHolder.ContactNumber = ValidatorHelper.PhoneValidator(40, 20); } else if (FieldToUpdate == "7") { accountHolder.address.addressLine1 = ValidatorHelper.StringValidator(40, 22); } else if (FieldToUpdate == "8") { accountHolder.address.addressLine2 = ValidatorHelper.StringValidator(40, 24); } else if (FieldToUpdate == "9") { accountHolder.address.city = ValidatorHelper.StringValidator(40, 26); } else if (FieldToUpdate == "10") { accountHolder.address.state = ValidatorHelper.StringValidator(40, 28); } else if (FieldToUpdate == "11") { accountHolder.address.pincode = ValidatorHelper.StringValidator(40, 30); } else if (FieldToUpdate == "12") { DisplayHelper.PrintTextAtXY(40, 42, "CANNOT CHANGE THIS FIELD"); } else if (FieldToUpdate == "13") { DisplayHelper.PrintTextAtXY(40, 42, "CANNOT CHANGE THIS FIELD"); } else if (FieldToUpdate == "Q") { break; } else { DisplayHelper.PrintTextAtXY(40, 42, "INVALID FIELD SELECTED"); } } while (FieldToUpdate != "Q"); } accountService.UpdateAccountHolder(accountHolder); } }
protected override void OnLoad(EventArgs e) { Parent.Dock = DockStyle.Fill; Form form = FindForm(); form.AcceptButton = buttonOK; form.CancelButton = buttonCancel; form.MinimumSize = new Size(536, 320); form.ShowIcon = false; //form.MaximizeBox = true; form.Closing += delegate { if (form.DialogResult == DialogResult.Cancel) { originalState.Restore(); EditorContext.ApplyDecorator(); } else { // This forces the linked image to be updated as well SaveSettingsAndApplyDecorator(); } }; base.OnLoad(e); if (EditorContext.EnforcedAspectRatio == null) { int width = cbAspectRatio.Left - lblAspectRatio.Right; DisplayHelper.AutoFitSystemLabel(lblAspectRatio, 0, int.MaxValue); DisplayHelper.AutoFitSystemCombo(cbAspectRatio, 0, int.MaxValue, false); buttonRotate.Width = buttonRotate.GetPreferredWidth(); bool isButtonRotateVisible = buttonRotate.Visible; buttonRotate.Visible = true; LayoutHelper.DistributeHorizontally(width, lblAspectRatio, cbAspectRatio, buttonRotate); buttonRotate.Visible = isButtonRotateVisible; if (isButtonRotateVisible && (cbAspectRatio.Height + 2) > buttonRotate.Height) { buttonRotate.Height = cbAspectRatio.Height + 2; } } else { lblAspectRatio.Visible = cbAspectRatio.Visible = buttonRotate.Visible = false; } DisplayHelper.AutoFitSystemCheckBox(chkGrid, 0, int.MaxValue); DisplayHelper.AutoFitSystemButton(btnRemoveCrop); LayoutHelper.FixupOKCancel(buttonOK, buttonCancel); chkGrid.Left = buttonCancel.Right - chkGrid.Width; panel1.Height = Math.Max(buttonRotate.Bottom, cbAspectRatio.Bottom) + 3; imageCropControl.Top = panel1.Bottom; imageCropControl.Select(); //int minWidth = buttonRotate.Right + width + (form.ClientSize.Width - buttonOK.Left) + SystemInformation.FrameBorderSize.Width * 2; //form.MinimumSize = new Size(minWidth, form.MinimumSize.Height); }
private void SimulateError() { DisplayHelper.WriteInfo($"{_state.PlayerName} recieved SimulateErrorCommand"); throw new ApplicationException($"Simulated exception in player: {_state.PlayerName}"); }
public bool WndProc(ref Message m) { switch ((uint)m.Msg) { case 0x031E: // WM_DWMCOMPOSITIONCHANGED { // Aero was enabled or disabled. Force the UI to switch to // the glass or non-glass style. DisplayHelper.IsCompositionEnabled(true); ColorizedResources.FireColorChanged(); break; } case WM.SIZE: { uint size = (uint)m.LParam.ToInt32(); switch (m.WParam.ToInt32()) { case SIZE_RESTORED: _overrideSize = new Size((int)(size & 0xFFFF), (int)(size >> 16)); UpdateFrame(); break; case SIZE_MAXIMIZED: UpdateFrame(); break; case SIZE_MAXHIDE: case SIZE_MINIMIZED: case SIZE_MAXSHOW: break; } break; } case WM.NCHITTEST: { // Handling this message gives us an easy way to make // areas of the client region behave as elements of the // non-client region. For example, the edges of the form // can act as sizers. Point p = _form.PointToClient(new Point(m.LParam.ToInt32())); if (_form.ClientRectangle.Contains(p)) { // only override the behavior if the mouse is within the client area if (Frameless) { int result = _sizeBorderHitTester.Test(_form.ClientSize, p); if (result != -1) { m.Result = new IntPtr(result); return(true); } } if (!PointInSystemIcon(p)) { // The rest of the visible areas of the form act like // the caption (click and drag to move, double-click to // maximize/restore). m.Result = new IntPtr(HT.CAPTION); return(true); } } break; } case WM.ENTERMENULOOP: if (Control.MouseButtons == MouseButtons.None) { _inMenuLoop = true; ForceFrame = true; } break; case WM.EXITMENULOOP: if (_inMenuLoop) { _inMenuLoop = false; if (!IsMouseInFrame()) { ForceFrame = false; } else { _mouseFrameTimer.Start(); } } break; } return(false); }
private void RefreshLayout() { if (_auth == null) { return; } SuspendLayout(); ckBoxSavePassword.Width = Width - ckBoxSavePassword.Left - 10; linkLabelCreateMicrosoftAccountID.Width = Width - linkLabelCreateMicrosoftAccountID.Left - 10; LayoutHelper.NaturalizeHeight(pictureBoxLogo, lblUsername, txtUsername, lblEmailExample, lblPassword, txtPassword, ckBoxSavePassword, linkLabelCreateMicrosoftAccountID, linkLabelPrivacy, btnLogin); if (ShowCreateMicrosoftAccountID) { LayoutHelper.DistributeVertically(4, false, pictureBoxLogo, lblUsername, txtUsername, lblEmailExample, lblPassword, txtPassword, ckBoxSavePassword, linkLabelCreateMicrosoftAccountID, linkLabelPrivacy, btnLogin); } else { LayoutHelper.DistributeVertically(4, false, pictureBoxLogo, lblUsername, txtUsername, lblEmailExample, lblPassword, txtPassword, ckBoxSavePassword, btnLogin); } ckBoxSavePassword.Visible = _auth.AllowSavePassword; lblUsername.Width = lblPassword.Width = lblEmailExample.Width = txtUsername.Width; lblUsername.Left = lblPassword.Left = lblEmailExample.Left = txtUsername.Left; if (BidiHelper.IsRightToLeft) { pictureBoxLogo.Left = txtUsername.Right - pictureBoxLogo.Width; } else { pictureBoxLogo.Left = txtUsername.Left; } Controls.Remove(lblStatus); DisplayHelper.AutoFitSystemButton(btnLogin, btnLogin.Width, int.MaxValue); LayoutHelper.FitControlsBelow(10, pictureBoxLogo); LayoutHelper.NaturalizeHeightAndDistribute(3, lblUsername, txtUsername, lblEmailExample); LayoutHelper.FitControlsBelow(10, lblEmailExample); if (ShowCreateMicrosoftAccountID) { LayoutHelper.NaturalizeHeightAndDistribute(3, lblPassword, txtPassword, ckBoxSavePassword); LayoutHelper.NaturalizeHeightAndDistribute(15, ckBoxSavePassword, new ControlGroup(linkLabelCreateMicrosoftAccountID, linkLabelPrivacy), btnLogin); } else { LayoutHelper.NaturalizeHeightAndDistribute(3, lblPassword, txtPassword, ckBoxSavePassword); LayoutHelper.NaturalizeHeightAndDistribute(15, ckBoxSavePassword, btnLogin); } if (BidiHelper.IsRightToLeft) { btnLogin.Left = txtPassword.Left; ckBoxSavePassword.Left = txtPassword.Right - ckBoxSavePassword.Width; linkLabelCreateMicrosoftAccountID.Left = txtPassword.Right - linkLabelCreateMicrosoftAccountID.Width; linkLabelPrivacy.Left = txtPassword.Right - linkLabelPrivacy.Width; } else { btnLogin.Left = txtPassword.Right - btnLogin.Width; ckBoxSavePassword.Left = linkLabelCreateMicrosoftAccountID.Left = linkLabelPrivacy.Left = txtPassword.Left; linkLabelCreateMicrosoftAccountID.Left -= 2; linkLabelPrivacy.Left -= 2; } Controls.Add(lblStatus); ResumeLayout(); }
public Definition(GameObject target, bool singleServing) : base(target.ObjectId, DisplayHelper.ComputeFinalPriceOnObject(target, singleServing), true) { mSingleServing = singleServing; mPath = new string[] { CraftersConsignment.LocalizeString(false, "PurchasePath", new object[0]) + Localization.Ellipsis, Food.GetString(singleServing ? Food.StringIndices.MakeOneSingle : Food.StringIndices.MakeOneGroup) + Localization.Ellipsis }; }
public virtual async Task <ActionResult> Index(ObligatedViewModel viewModel) { if (ModelState.IsValid) { using (var client = apiClient()) { var request = requestCreator.ViewModelToRequest(viewModel); await client.SendAsync(User.GetAccessToken(), request); if (viewModel.Edit) { return(AatfRedirect.ReusedOffSiteSummaryList(viewModel.ReturnId, viewModel.AatfId, viewModel.OrganisationId)); } return(AatfRedirect.ReusedOffSite(viewModel.ReturnId, viewModel.AatfId, viewModel.OrganisationId)); } } await SetBreadcrumb(viewModel.OrganisationId, BreadCrumbConstant.AatfReturn, viewModel.AatfId, DisplayHelper.YearQuarterPeriodFormat(TempData["currentQuarter"] as Quarter, TempData["currentQuarterWindow"] as QuarterWindow)); return(View(viewModel)); }
public virtual async Task <ActionResult> Index(Guid returnId, Guid aatfId) { using (var client = apiClient()) { var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); var model = mapper.Map(new ReturnToObligatedViewModelMapTransfer() { AatfId = aatfId, OrganisationId = @return.OrganisationData.Id, ReturnId = returnId, ReturnData = @return, PastedData = TempData["pastedValues"] as ObligatedCategoryValue }); await SetBreadcrumb(@return.OrganisationData.Id, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); TempData["currentQuarter"] = @return.Quarter; TempData["currentQuarterWindow"] = @return.QuarterWindow; return(View(model)); } }
public virtual async Task <ActionResult> Index(Guid returnId, bool dcf) { using (var client = apiClient()) { var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); var typeHeading = dcf == false ? "Non-obligated WEEE" : "Non-obligated WEEE kept / retained by a DCF"; var viewModel = new NonObligatedValuesCopyPasteViewModel() { ReturnId = returnId, OrganisationId = @return.OrganisationData.Id, Dcf = dcf, TypeHeading = typeHeading }; await SetBreadcrumb(@return.OrganisationData.Id, BreadCrumbConstant.AatfReturn, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); return(View(viewModel)); } }
private async Task <DialogTurnResult> ShowEventsSummary(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var tokenResponse = sc.Result as TokenResponse; var state = await Accessor.GetAsync(sc.Context); var options = sc.Options as ShowMeetingsDialogOptions; if (state.SummaryEvents == null) { // this will lead to error when test if (string.IsNullOrEmpty(state.APIToken)) { state.Clear(); return(await sc.EndDialogAsync(true)); } var calendarService = ServiceManager.InitCalendarService(state.APIToken, state.EventSource); state.SummaryEvents = await GetMeetingToJoin(sc); } if (state.SummaryEvents.Count == 0) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(JoinEventResponses.MeetingNotFound)); state.Clear(); return(await sc.EndDialogAsync(true)); } else if (state.SummaryEvents.Count == 1) { state.ConfirmedMeeting.Add(state.SummaryEvents.First()); return(await sc.ReplaceDialogAsync(Actions.ConfirmNumber, sc.Options)); } // Multiple events var firstEvent = GetCurrentPageMeetings(state.SummaryEvents, state).First(); var responseParams = new StringDictionary() { { "EventName1", firstEvent.Title }, { "EventTime1", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(firstEvent.StartTime, state.GetUserTimeZone()), firstEvent.IsAllDay == true) }, { "Participants1", DisplayHelper.ToDisplayParticipantsStringSummary(firstEvent.Attendees) } }; var reply = await GetGeneralMeetingListResponseAsync(sc, CalendarCommonStrings.MeetingsToJoin, GetCurrentPageMeetings(state.SummaryEvents, state), JoinEventResponses.SelectMeeting, responseParams); return(await sc.PromptAsync(Actions.Prompt, new PromptOptions() { Prompt = reply })); } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
protected override void OnDropDown(EventArgs e) { DisplayHelper.AutoFitSystemComboDropDown(this); base.OnDropDown(e); }
int ScaleY(int y) { return((int)Math.Round(DisplayHelper.ScaleY(y))); }
int ScaleX(int x) { return((int)Math.Round(DisplayHelper.ScaleX(x))); }
/// <summary> /// Override OnLoad /// </summary> /// <param name="e">event args</param> protected override void OnLoad(EventArgs e) { // call base base.OnLoad(e); // scale size of btnOptions based on text if (!_slimOptions) { int existingWidth = btnOptions.Width; int preferredWidth = btnOptions.GetPreferredWidth(); btnOptions.Left = btnOptions.Right - preferredWidth; btnOptions.Width = preferredWidth; textBoxAddress.Width = btnOptions.Left - 5 - textBoxAddress.Left; } else { textBoxAddress.Width = btnOptions.Right - textBoxAddress.Left; btnOptions.Visible = false; labelRel.Visible = false; comboBoxRel.Visible = false; labelTitle.Visible = false; textBoxTitle.Visible = false; ckboxNewWindow.Visible = false; ckBoxGlossary.Visible = false; btnAdvanced.Visible = false; ClientSize = new Size(ClientSize.Width, textBoxLinkText.Bottom + textBoxLinkText.Left); } if (btnRemove != null) { DisplayHelper.AutoFitSystemButton(btnRemove, buttonInsert.Width, int.MaxValue); if (btnAdvanced != null) { btnRemove.Left = btnAdvanced.Left - btnRemove.Width - (int)Math.Round(DisplayHelper.ScaleX(8)); } } using (new AutoGrow(this, AnchorStyles.Right, true)) { LayoutHelper.EqualizeButtonWidthsVert(AnchorStyles.Left, buttonInsert.Width, int.MaxValue, buttonInsert, buttonCancel); } //now, need to move the advanced button over if (btnAdvanced.Visible) { SetAdvancedText(); DisplayHelper.AutoFitSystemButton(btnAdvanced, buttonInsert.Width, int.MaxValue); btnAdvanced.Left = buttonInsert.Right - btnAdvanced.Width; } // install auto-complete on the address text box int result = Shlwapi.SHAutoComplete(textBoxAddress.Handle, SHACF.URLALL | SHACF.AUTOSUGGEST_FORCE_ON); // ensure we installed it successfully (if we didn't, no biggie -- the user will // just not get autocomplete support) Debug.Assert(result == HRESULT.S_OK, "Unexpected failure to install AutoComplete"); // prepopulate the text box w/ http prefix and move the cursor to the end if (textBoxAddress.Text == String.Empty) { try { if (Clipboard.ContainsText()) { string clipboardText = Clipboard.GetText(); if (Regex.IsMatch(clipboardText ?? "", "^https?://", RegexOptions.IgnoreCase) && UrlHelper.IsUrl(clipboardText)) { textBoxAddress.Text = clipboardText; textBoxAddress.Select(0, textBoxAddress.TextLength); } } } catch (ExternalException) { } catch (ThreadStateException) { } } if (textBoxAddress.Text == String.Empty) { textBoxAddress.Text = HTTP_PREFIX; textBoxAddress.Select(HTTP_PREFIX.Length, 0); } //decide whether it should be maximized ShowAdvancedOptions = (LinkSettings.ShowAdvancedOptions || Rel != String.Empty || LinkTitle != String.Empty) && comboBoxRel.Visible; //use new window sticky setting if this isn't an edit if (!_editStyle) { NewWindow = LinkSettings.OpenInNewWindow; } }
protected void submitButton_Click(object sender, EventArgs e) { #region Event Attendance // Logging event attendance string codeValue = codeEntryField.Text; int patronId = (int)ViewState["SubmitAsPatronId"]; var pointsAward = new AwardPoints(patronId); var patron = Patron.FetchObject(patronId); var patronName = DisplayHelper.FormatName(patron.FirstName, patron.LastName, patron.Username); if (codeValue.Length == 0) { Session[SessionKey.PatronMessage] = "Please enter a code."; Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Danger; Session[SessionKey.PatronMessageGlyphicon] = "remove"; return; } else { // verify event code was not previously redeemed if (PatronPoints.HasRedeemedKeywordPoints(patronId, codeValue)) { Session[SessionKey.PatronMessage] = string.Format("{0} has already redeemed this code!", patronName); Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } // get event for that code, get the # points var ds = Event.GetEventByEventCode(pointsAward.pgm.StartDate.ToShortDateString(), DateTime.Now.ToShortDateString(), codeValue); if (ds.Tables[0].Rows.Count == 0) { Session[SessionKey.PatronMessage] = "Sorry, that's an invalid code."; Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } var EID = (int)ds.Tables[0].Rows[0]["EID"]; var evt = Event.GetEvent(EID); var points = evt.NumberPoints; //var newPBID = 0; var earnedBadges = pointsAward.AwardPointsToPatron(points: points, reason: PointAwardReason.EventAttendance, eventCode: codeValue, eventID: EID); // don't show badge earnings to the parent //if(!string.IsNullOrWhiteSpace(earnedBadges)) { // new SessionTools(Session).EarnedBadges(earnedBadges); //} // set message and earned badges string earnedMessage = new PointCalculation().EarnedMessage(earnedBadges, points, patronName); if (string.IsNullOrEmpty(earnedMessage)) { Session[SessionKey.PatronMessage] = string.Format("<strong>Excellent!</strong> Secret code recorded for {0}.", patronName); } else { Session[SessionKey.PatronMessage] = string.Format("<strong>Excellent!</strong> Secret code recorded. <strong>{0}</strong>", earnedMessage); } Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Success; Session[SessionKey.PatronMessageGlyphicon] = "barcode"; this.codeEntryField.Text = string.Empty; } #endregion }
public override bool Run() { Definition interactionDefinition = base.InteractionDefinition as Definition; if (interactionDefinition == null) { return(false); } ObjectGuid mObject = interactionDefinition.mObject; int mCost = interactionDefinition.mCost; if (mObject == ObjectGuid.InvalidObjectGuid) { List <ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target); if (!Autonomous && Actor.IsSelectable) { List <ObjectPicker.RowInfo> list = new List <ObjectPicker.RowInfo>(); foreach (ObjectGuid current in objectsICanBuyInDisplay) { GameObject obj = GlobalFunctions.ConvertGuidToObject <GameObject>(current); ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(current, new List <ObjectPicker.ColumnInfo> { new ObjectPicker.ThumbAndTextColumn(obj.GetThumbnailKey(), obj.GetLocalizedName()), new ObjectPicker.MoneyColumn(DisplayHelper.ComputeFinalPriceOnObject(obj, true)) }); list.Add(item); } List <ObjectPicker.HeaderInfo> list2 = new List <ObjectPicker.HeaderInfo>(); List <ObjectPicker.TabInfo> list3 = new List <ObjectPicker.TabInfo>(); list2.Add(new ObjectPicker.HeaderInfo(ShoppingRegister.sLocalizationKey + ":BuyFoodColumnName", ShoppingRegister.sLocalizationKey + ":BuyFoodColumnTooltip", 200)); list2.Add(new ObjectPicker.HeaderInfo("Ui/Caption/Shopping/Cart:Price", "Ui/Tooltip/Shopping/Cart:Price")); list3.Add(new ObjectPicker.TabInfo("", ShoppingRegister.LocalizeString("AvailableFoods"), list)); List <ObjectPicker.RowInfo> list4 = SimplePurchaseDialog.Show(ShoppingRegister.LocalizeString("BuyFoodTitle"), Actor.FamilyFunds, list3, list2, true); if (list4 == null || list4.Count != 1) { return(false); } mObject = (ObjectGuid)list4[0].Item; mCost = ((ObjectPicker.MoneyColumn)list4[0].ColumnInfo[1]).Value; } else { RandomUtil.RandomizeListOfObjects <ObjectGuid>(objectsICanBuyInDisplay); int familyFunds = base.Actor.FamilyFunds; for (int i = 0; i < objectsICanBuyInDisplay.Count; i++) { int cost = DisplayHelper.ComputeFinalPriceOnObject(objectsICanBuyInDisplay[i]); if (cost <= familyFunds) { //Definition continuationDefinition = new Definition(objectsICanBuyInDisplay[i], cost, false); //base.TryPushAsContinuation(continuationDefinition); //return true; mObject = objectsICanBuyInDisplay[i]; mCost = cost; break; } } //return false; } } if (mObject == ObjectGuid.InvalidObjectGuid) { return(false); } if (!base.Actor.RouteToObjectRadialRange(base.Target, 0f, base.Target.MaxProximityBeforeSwiping())) { return(false); } base.Actor.RouteTurnToFace(base.Target.Position); if (!DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target).Contains(mObject)) { return(false); } if (base.Actor.FamilyFunds < mCost) { return(false); } GameObject target = GlobalFunctions.ConvertGuidToObject <GameObject>(mObject); if (target == null) { return(false); } base.StandardEntry(); base.BeginCommodityUpdates(); string swipeAnimationName = base.Target.GetSwipeAnimationName(target); if (Actor.SimDescription.Child) { swipeAnimationName = "c" + swipeAnimationName.Substring(1); } base.Actor.PlaySoloAnimation(swipeAnimationName, true); VisualEffect effect = VisualEffect.Create(base.Target.GetSwipeVfxName()); Vector3 zero = Vector3.Zero; Vector3 axis = Vector3.Zero; if (Slots.AttachToBone(effect.ObjectId, base.Target.ObjectId, ResourceUtils.HashString32("transformBone"), false, ref zero, ref axis, 0f) == TransformParentingReturnCode.Success) { effect.SetAutoDestroy(true); effect.Start(); } else { effect.Dispose(); effect = null; } //bool flag = false; //bool flag2 = false; bool succeeded = false; bool addInteractions = true; string tnsKey = null; if (target.IsLiveDraggingEnabled() && !target.InUse && (interactionDefinition.mPushEat || (target.ItemComp != null && target.ItemComp.CanAddToInventory(base.Actor.Inventory) && base.Actor.Inventory.CanAdd(target)))) //&& base.Actor.Inventory.TryToAdd(target))) { ServingContainerGroup groupServing = null; if (interactionDefinition.mSingleServing) { groupServing = target as ServingContainerGroup; if (groupServing != null) { target = groupServing.CookingProcess.CreateSingleServingOfFood(groupServing, true, true); addInteractions = false; } } if (interactionDefinition.mPushEat) { target.SetOpacity(0f, 0f); if (Actor.ParentToRightHand(target)) { succeeded = true; CarrySystem.EnterWhileHolding(Actor, target as ICarryable); } target.FadeIn(); } else if (Actor.Inventory.TryToAdd(target)) { succeeded = true; tnsKey = "PlacedInPersonalInventory"; } if (succeeded) { if (groupServing != null) { groupServing.DecrementServings(); if (groupServing.NumServingsLeft == 0) { groupServing.FadeOut(false, true); } } } else if (groupServing != null && target != null) { target.Destroy(); } } else if (!target.InUse && base.Actor.Household.SharedFamilyInventory.Inventory.TryToAdd(target)) { succeeded = true; tnsKey = "PlacedInFamilyInventory"; } //bool succeeded = flag || flag2; if (succeeded) { if (addInteractions) { Target.OnHandToolChildUnslotted(target, Slot.None); if (target is Snack) { target.AddInteraction(Sims3.Gameplay.Objects.CookingObjects.Eat.Singleton, true); target.AddInteraction(Snack_CleanUp.Singleton, true); } } /*if (flag2) * { * base.Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "PlacedInFamilyInventory", new object[] { base.Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive); * } * else * { * base.Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "PlacedInPersonalInventory", new object[] { base.Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive); * }*/ if (tnsKey != null) { Actor.ShowTNSIfSelectable(CraftersConsignment.LocalizeString(Actor.IsFemale, tnsKey, new object[] { Actor, target }), StyledNotification.NotificationStyle.kGameMessagePositive); } base.Target.GiveMarkupBuffs(base.Actor, mObject); base.Actor.ModifyFunds(-mCost); base.Target.GiveLotOwnerMoney(mCost, base.Actor); base.Target.AccumulateRevenue(mCost); if (interactionDefinition.mPushEat) { (target as IFoodContainer).PushEatHeldFoodInteraction(Actor); } } base.EndCommodityUpdates(succeeded); base.StandardExit(); return(succeeded); }
public async Task <DialogTurnResult> ShowEventsSummary(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var tokenResponse = sc.Result as TokenResponse; var state = await Accessor.GetAsync(sc.Context); var options = sc.Options as ShowMeetingsDialogOptions; if (state.SummaryEvents == null) { // this will lead to error when test if (string.IsNullOrEmpty(state.APIToken)) { state.Clear(); return(await sc.EndDialogAsync(true)); } var calendarService = ServiceManager.InitCalendarService(state.APIToken, state.EventSource); var searchDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, state.GetUserTimeZone()); if (state.StartDate.Any()) { searchDate = state.StartDate.Last(); } var results = await GetEventsByTime(new List <DateTime>() { searchDate }, state.StartTime, state.EndDate, state.EndTime, state.GetUserTimeZone(), calendarService); var searchedEvents = new List <EventModel>(); bool searchTodayMeeting = SearchesTodayMeeting(state); foreach (var item in results) { if (!searchTodayMeeting || item.StartTime >= DateTime.UtcNow) { searchedEvents.Add(item); } } if (searchedEvents.Count == 0) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowNoMeetingMessage)); state.Clear(); return(await sc.EndDialogAsync(true)); } else { if (options != null && options.Reason == ShowMeetingReason.ShowOverviewAgain) { var responseParams = new StringDictionary() { { "Count", searchedEvents.Count.ToString() }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.Today } }; if (searchedEvents.Count == 1) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowOneMeetingSummaryAgainMessage, responseParams)); } else { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMeetingSummaryAgainMessage, responseParams)); } } else { var responseParams = new StringDictionary() { { "Count", searchedEvents.Count.ToString() }, { "EventName1", searchedEvents[0].Title }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.Today }, { "EventTime1", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(searchedEvents[0].StartTime, state.GetUserTimeZone()), searchedEvents[0].IsAllDay == true) }, { "Participants1", DisplayHelper.ToDisplayParticipantsStringSummary(searchedEvents[0].Attendees) } }; if (searchedEvents.Count == 1) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowOneMeetingSummaryMessage, responseParams)); } else { responseParams.Add("EventName2", searchedEvents[searchedEvents.Count - 1].Title); responseParams.Add("EventTime2", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(searchedEvents[searchedEvents.Count - 1].StartTime, state.GetUserTimeZone()), searchedEvents[searchedEvents.Count - 1].IsAllDay == true)); responseParams.Add("Participants2", DisplayHelper.ToDisplayParticipantsStringSummary(searchedEvents[searchedEvents.Count - 1].Attendees)); await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMultipleMeetingSummaryMessage, responseParams)); } } } await ShowMeetingList(sc, GetCurrentPageMeetings(searchedEvents, state), !searchTodayMeeting); state.SummaryEvents = searchedEvents; if (state.SummaryEvents.Count == 1) { return(await sc.PromptAsync(Actions.Prompt, new PromptOptions())); } } else { var currentPageMeetings = GetCurrentPageMeetings(state.SummaryEvents, state); if (options != null && options.Reason == ShowMeetingReason.ShowFilteredMeetings) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMultipleFilteredMeetings, new StringDictionary() { { "Count", state.SummaryEvents.Count.ToString() } })); } else { var responseParams = new StringDictionary() { { "Count", state.SummaryEvents.Count.ToString() }, { "EventName1", currentPageMeetings[0].Title }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.Today }, { "EventTime1", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(currentPageMeetings[0].StartTime, state.GetUserTimeZone()), currentPageMeetings[0].IsAllDay == true) }, { "Participants1", DisplayHelper.ToDisplayParticipantsStringSummary(currentPageMeetings[0].Attendees) } }; await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMeetingSummaryNotFirstPageMessage, responseParams)); } await ShowMeetingList(sc, GetCurrentPageMeetings(state.SummaryEvents, state), !SearchesTodayMeeting(state)); } return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(SummaryResponses.ReadOutMorePrompt) })); } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
/// <inheritdoc/> protected override string PropertiesToDbgString(uint n) { var spaces = DisplayHelper.Spaces(n); return($"{spaces}Task!!!!"); }
public virtual async Task <ActionResult> Index(Guid returnId, Guid aatfId, Guid?weeeSentOnId) { using (var client = apiClient()) { var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); WeeeSentOnData weeeSentOn = null; if (weeeSentOnId != null) { weeeSentOn = await client.SendAsync(User.GetAccessToken(), new GetWeeeSentOnById(weeeSentOnId.Value)); } var countryData = await client.SendAsync(User.GetAccessToken(), new GetCountries(false)); var viewModel = mapper.Map(new ReturnAndAatfToSentOnCreateSiteViewModelMapTransfer() { CountryData = countryData, Return = @return, AatfId = aatfId, WeeeSentOnData = weeeSentOn }); await SetBreadcrumb(@return.OrganisationData.Id, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); TempData["currentQuarter"] = @return.Quarter; TempData["currentQuarterWindow"] = @return.QuarterWindow; return(View(viewModel)); } }
private void DisplayPlayerStatus() { DisplayHelper.WriteInfo($"{_state.PlayerName} recieved DisplayStatusCommand"); DisplayHelper.WriteResult($"{_state.PlayerName} has {_state.Health} health"); }
public virtual async Task <ActionResult> Index(SentOnCreateSiteViewModel viewModel, bool?noJavascriptCopy) { if (NoJavascriptCopy(noJavascriptCopy)) { CopySiteAddressToOperatorAddress(viewModel); } else { if (ModelState.IsValid) { using (var client = apiClient()) { var request = requestCreator.ViewModelToRequest(viewModel); var result = await client.SendAsync(User.GetAccessToken(), request); return(AatfRedirect.ObligatedSentOn(viewModel.SiteAddressData.Name, viewModel.OrganisationId, viewModel.AatfId, viewModel.ReturnId, result)); } } } using (var client = apiClient()) { viewModel.SiteAddressData.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false)); viewModel.OperatorAddressData.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false)); } await SetBreadcrumb(viewModel.OrganisationId, BreadCrumbConstant.AatfReturn, viewModel.AatfId, DisplayHelper.YearQuarterPeriodFormat(TempData["currentQuarter"] as Quarter, TempData["currentQuarterWindow"] as QuarterWindow)); return(View(viewModel)); }
public async Task <DialogTurnResult> ConfirmBeforeCreate(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { bool?isLocationSkipByDefault = false; isLocationSkipByDefault = Settings.DefaultValue?.CreateMeeting?.First(item => item.Name == "EventLocation")?.IsSkipByDefault; var state = await Accessor.GetAsync(sc.Context, cancellationToken : cancellationToken); if (state.Location == null && sc.Result != null && (!(state.CreateHasDetail && isLocationSkipByDefault.GetValueOrDefault()) || state.RecreateState == RecreateEventState.Location)) { sc.Context.Activity.Properties.TryGetValue("OriginText", out var content); var luisResult = state.LuisResult; var userInput = content != null?content.ToString() : sc.Context.Activity.Text; var topIntent = luisResult?.TopIntent().intent.ToString(); var promptRecognizerResult = ConfirmRecognizerHelper.ConfirmYesOrNo(userInput, sc.Context.Activity.Locale); // Enable the user to skip providing the location if they say something matching the Cancel intent, say something matching the ConfirmNo recognizer or something matching the NoLocation intent if (CreateEventWhiteList.IsSkip(userInput)) { state.Location = string.Empty; } else { state.Location = userInput; } } else if (state.CreateHasDetail && isLocationSkipByDefault.GetValueOrDefault()) { state.Location = CalendarCommonStrings.DefaultLocation; } var source = state.EventSource; var newEvent = new EventModel(source) { Title = state.Title, Content = state.Content, Attendees = state.Attendees, StartTime = state.StartDateTime.Value, EndTime = state.EndDateTime.Value, TimeZone = TimeZoneInfo.Utc, Location = state.Location, ContentPreview = state.Content }; var attendeeConfirmTextString = string.Empty; if (state.Attendees.Count > 0) { var attendeeConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateAttendees, new StringDictionary() { { "Attendees", DisplayHelper.ToDisplayParticipantsStringSummary(state.Attendees, 5) } }); attendeeConfirmTextString = attendeeConfirmResponse.Text; } var subjectConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Title)) { var subjectConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateSubject, new StringDictionary() { { "Subject", string.IsNullOrEmpty(state.Title) ? CalendarCommonStrings.Empty : state.Title } }); subjectConfirmString = subjectConfirmResponse.Text; } var locationConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Location)) { var subjectConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateLocation, new StringDictionary() { { "Location", string.IsNullOrEmpty(state.Location) ? CalendarCommonStrings.Empty : state.Location }, }); locationConfirmString = subjectConfirmResponse.Text; } var contentConfirmString = string.Empty; if (!string.IsNullOrEmpty(state.Content)) { var contentConfirmResponse = ResponseManager.GetResponse(CreateEventResponses.ConfirmCreateContent, new StringDictionary() { { "Content", string.IsNullOrEmpty(state.Content) ? CalendarCommonStrings.Empty : state.Content }, }); contentConfirmString = contentConfirmResponse.Text; } var startDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.StartDateTime.Value, state.GetUserTimeZone()); var endDateTimeInUserTimeZone = TimeConverter.ConvertUtcToUserTime(state.EndDateTime.Value, state.GetUserTimeZone()); var tokens = new StringDictionary { { "AttendeesConfirm", attendeeConfirmTextString }, { "Date", startDateTimeInUserTimeZone.ToSpeechDateString(false) }, { "Time", startDateTimeInUserTimeZone.ToSpeechTimeString(false) }, { "EndTime", endDateTimeInUserTimeZone.ToSpeechTimeString(false) }, { "SubjectConfirm", subjectConfirmString }, { "LocationConfirm", locationConfirmString }, { "ContentConfirm", contentConfirmString }, }; var prompt = await GetDetailMeetingResponseAsync(sc, newEvent, CreateEventResponses.ConfirmCreate, tokens); await sc.Context.SendActivityAsync(prompt); if (state.Attendees.Count > 5) { return(await sc.BeginDialogAsync(Actions.ShowRestParticipants)); } else { return(await sc.NextAsync()); } } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
protected async Task <DialogTurnResult> ReadEmail(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await EmailStateAccessor.GetAsync(sc.Context); var skillOptions = (EmailSkillDialogOptions)sc.Options; sc.Context.Activity.Properties.TryGetValue("OriginText", out var content); var userInput = content != null?content.ToString() : sc.Context.Activity.Text; var luisResult = state.LuisResult; var topIntent = luisResult?.TopIntent().intent; var generalLuisResult = state.GeneralLuisResult; var generalTopIntent = generalLuisResult?.TopIntent().intent; if (topIntent == null) { return(await sc.EndDialogAsync(true)); } await DigestFocusEmailAsync(sc); var message = state.Message.FirstOrDefault(); if (message == null) { state.Message.Add(state.MessageList[0]); message = state.Message.FirstOrDefault(); } var promptRecognizerResult = ConfirmRecognizerHelper.ConfirmYesOrNo(userInput, sc.Context.Activity.Locale); if ((topIntent == EmailLU.Intent.None || topIntent == EmailLU.Intent.SearchMessages || (topIntent == EmailLU.Intent.ReadAloud && !IsReadMoreIntent(generalTopIntent, sc.Context.Activity.Text)) || (promptRecognizerResult.Succeeded && promptRecognizerResult.Value == true)) && message != null) { var nameListString = DisplayHelper.ToDisplayRecipientsString_Summay(message.ToRecipients); var emailCard = new EmailCardData { Subject = message.Subject, Sender = message.Sender.EmailAddress.Name, NameList = string.Format(EmailCommonStrings.ToFormat, nameListString), EmailContent = message.BodyPreview, EmailLink = message.WebLink, ReceivedDateTime = message?.ReceivedDateTime == null ? CommonStrings.NotAvailable : message.ReceivedDateTime.Value.UtcDateTime.ToRelativeString(state.GetUserTimeZone()), Speak = SpeakHelper.ToSpeechEmailDetailOverallString(message, state.GetUserTimeZone()), }; var tokens = new StringDictionary() { { "EmailDetails", SpeakHelper.ToSpeechEmailDetailString(message, state.GetUserTimeZone()) }, { "EmailDetailsWithContent", SpeakHelper.ToSpeechEmailDetailString(message, state.GetUserTimeZone(), true) }, }; var replyMessage = ResponseManager.GetCardResponse( ShowEmailResponses.ReadOutMessage, new Card("EmailDetailCard", emailCard), tokens); // Set email as read. var service = ServiceManager.InitMailService(state.Token, state.GetUserTimeZone(), state.MailSourceType); await service.MarkMessageAsReadAsync(message.Id); await sc.Context.SendActivityAsync(replyMessage); } return(await sc.NextAsync()); } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
public virtual async Task <ActionResult> Index(SelectReportOptionsDeselectViewModel viewModel) { var selectReportOptionsViewModel = TempData["viewModel"] as SelectReportOptionsViewModel; var deselectViewModel = mapper.Map(selectReportOptionsViewModel); deselectViewModel.SelectedValue = viewModel.SelectedValue; TempData["viewModel"] = selectReportOptionsViewModel; if (ModelState.IsValid) { if (deselectViewModel.SelectedValue == viewModel.YesValue) { using (var client = apiClient()) { var request = requestCreator.ViewModelToRequest(deselectViewModel); await client.SendAsync(User.GetAccessToken(), request); } if (IfWeeeReceivedChangedToSelected(selectReportOptionsViewModel)) { return(AatfRedirect.SelectPcs(deselectViewModel.OrganisationId, deselectViewModel.ReturnId)); } return(AatfRedirect.TaskList(deselectViewModel.ReturnId)); } else { return(AatfRedirect.SelectReportOptions(deselectViewModel.OrganisationId, deselectViewModel.ReturnId)); } } await SetBreadcrumb(deselectViewModel.OrganisationId, BreadCrumbConstant.AatfReturn, DisplayHelper.YearQuarterPeriodFormat(TempData["currentQuarter"] as Quarter, TempData["currentQuarterWindow"] as QuarterWindow)); return(View(deselectViewModel)); }
public async Task <DialogTurnResult> ShowEventsList(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var tokenResponse = sc.Result as TokenResponse; var state = await Accessor.GetAsync(sc.Context); var options = sc.Options as ShowMeetingsDialogOptions; if (state.SummaryEvents == null) { // this will lead to error when test if (string.IsNullOrEmpty(state.APIToken)) { state.Clear(); return(await sc.EndDialogAsync(true)); } var calendarService = ServiceManager.InitCalendarService(state.APIToken, state.EventSource); var searchDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, state.GetUserTimeZone()); if (state.StartDate.Any()) { searchDate = state.StartDate.Last(); } var results = await GetEventsByTime(new List <DateTime>() { searchDate }, state.StartTime, state.EndDate, state.EndTime, state.GetUserTimeZone(), calendarService); var searchedEvents = new List <EventModel>(); bool searchTodayMeeting = SearchesTodayMeeting(state); foreach (var item in results) { if (!searchTodayMeeting || item.StartTime >= DateTime.UtcNow) { searchedEvents.Add(item); } } if (searchedEvents.Count == 0) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowNoMeetingMessage)); state.Clear(); return(await sc.EndDialogAsync(true)); } else { if (options != null && options.Reason == ShowMeetingReason.ShowOverviewAgain) { var responseParams = new StringDictionary() { { "Count", searchedEvents.Count.ToString() }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower } }; if (searchedEvents.Count == 1) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowOneMeetingSummaryAgainMessage, responseParams)); } else { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMeetingSummaryAgainMessage, responseParams)); } } else { var responseParams = new StringDictionary() { { "Count", searchedEvents.Count.ToString() }, { "EventName1", searchedEvents[0].Title }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower }, { "EventTime1", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(searchedEvents[0].StartTime, state.GetUserTimeZone()), searchedEvents[0].IsAllDay == true) }, { "Participants1", DisplayHelper.ToDisplayParticipantsStringSummary(searchedEvents[0].Attendees) } }; if (searchedEvents.Count == 1) { await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowOneMeetingSummaryMessage, responseParams)); } else { responseParams.Add("EventName2", searchedEvents[searchedEvents.Count - 1].Title); responseParams.Add("EventTime2", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(searchedEvents[searchedEvents.Count - 1].StartTime, state.GetUserTimeZone()), searchedEvents[searchedEvents.Count - 1].IsAllDay == true)); responseParams.Add("Participants2", DisplayHelper.ToDisplayParticipantsStringSummary(searchedEvents[searchedEvents.Count - 1].Attendees)); await sc.Context.SendActivityAsync(ResponseManager.GetResponse(SummaryResponses.ShowMultipleMeetingSummaryMessage, responseParams)); } } } // add conflict flag for (int i = 0; i < searchedEvents.Count - 1; i++) { for (int j = i + 1; j < searchedEvents.Count; j++) { if (searchedEvents[i].StartTime <= searchedEvents[j].StartTime && searchedEvents[i].EndTime > searchedEvents[j].StartTime) { searchedEvents[i].IsConflict = true; searchedEvents[j].IsConflict = true; } else { break; } } } // count the conflict meetings int totalConflictCount = 0; foreach (var eventItem in searchedEvents) { if (eventItem.IsConflict) { totalConflictCount++; } } state.TotalConflictCount = totalConflictCount; await sc.Context.SendActivityAsync(await GetOverviewMeetingListResponseAsync( sc, GetCurrentPageMeetings(searchedEvents, state, out int firstIndex, out int lastIndex), firstIndex, lastIndex, searchedEvents.Count, totalConflictCount, null, null)); state.SummaryEvents = searchedEvents; if (state.SummaryEvents.Count == 1) { return(await sc.PromptAsync(Actions.Prompt, new PromptOptions())); } } else { var currentPageMeetings = GetCurrentPageMeetings(state.SummaryEvents, state); if (options != null && ( options.Reason == ShowMeetingReason.ShowFilteredByTitleMeetings || options.Reason == ShowMeetingReason.ShowFilteredByTimeMeetings || options.Reason == ShowMeetingReason.ShowFilteredByParticipantNameMeetings)) { string meetingListTitle = null; if (options.Reason == ShowMeetingReason.ShowFilteredByTitleMeetings) { meetingListTitle = string.Format(CalendarCommonStrings.MeetingsAbout, state.FilterMeetingKeyWord); } else if (options.Reason == ShowMeetingReason.ShowFilteredByTimeMeetings) { meetingListTitle = string.Format(CalendarCommonStrings.MeetingsAt, state.FilterMeetingKeyWord); } else if (options.Reason == ShowMeetingReason.ShowFilteredByParticipantNameMeetings) { meetingListTitle = string.Format(CalendarCommonStrings.MeetingsWith, state.FilterMeetingKeyWord); } var reply = await GetGeneralMeetingListResponseAsync( sc, meetingListTitle, state.SummaryEvents, SummaryResponses.ShowMultipleFilteredMeetings, new StringDictionary() { { "Count", state.SummaryEvents.Count.ToString() } }); await sc.Context.SendActivityAsync(reply); } else { var responseParams = new StringDictionary() { { "Count", state.SummaryEvents.Count.ToString() }, { "EventName1", currentPageMeetings[0].Title }, { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower }, { "EventTime1", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(currentPageMeetings[0].StartTime, state.GetUserTimeZone()), currentPageMeetings[0].IsAllDay == true) }, { "Participants1", DisplayHelper.ToDisplayParticipantsStringSummary(currentPageMeetings[0].Attendees) } }; var reply = await GetOverviewMeetingListResponseAsync( sc, GetCurrentPageMeetings(state.SummaryEvents, state, out int firstIndex, out int lastIndex), firstIndex, lastIndex, state.SummaryEvents.Count, state.TotalConflictCount, SummaryResponses.ShowMeetingSummaryNotFirstPageMessage, responseParams); await sc.Context.SendActivityAsync(reply); } } return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(SummaryResponses.ReadOutMorePrompt) })); } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
public async Task <DialogTurnResult> ConfirmName(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await EmailStateAccessor.GetAsync(sc.Context); if (((state.NameList == null) || (state.NameList.Count == 0)) && state.EmailList.Count == 0) { return(await sc.BeginDialogAsync(Actions.UpdateRecipientName, new UpdateUserDialogOptions(UpdateUserDialogOptions.UpdateReason.NotFound))); } var unionList = new List <Person>(); if (state.FirstEnterFindContact || state.EmailList.Count > 0) { state.FirstEnterFindContact = false; if (state.NameList.Count > 1) { var nameString = await GetReadyToSendNameListStringAsync(sc); await sc.Context.SendActivityAsync(ResponseManager.GetResponse(FindContactResponses.BeforeSendingMessage, new StringDictionary() { { "NameList", nameString } })); } } if (state.EmailList.Count > 0) { foreach (var email in state.EmailList) { var recipient = new Recipient(); var emailAddress = new EmailAddress { Name = email, Address = email, }; recipient.EmailAddress = emailAddress; if (state.Recipients.All(r => r.EmailAddress.Address != emailAddress.Address)) { state.Recipients.Add(recipient); } } state.EmailList.Clear(); if (state.NameList.Count > 0) { return(await sc.ReplaceDialogAsync(Actions.ConfirmName, sc.Options)); } else { return(await sc.EndDialogAsync()); } } if (state.ConfirmRecipientIndex < state.NameList.Count) { var currentRecipientName = state.NameList[state.ConfirmRecipientIndex]; var originPersonList = await GetPeopleWorkWithAsync(sc.Context, currentRecipientName); var originContactList = await GetContactsAsync(sc.Context, currentRecipientName); originPersonList.AddRange(originContactList); var originUserList = new List <Person>(); try { originUserList = await GetUserAsync(sc.Context, currentRecipientName); } catch { // do nothing when get user failed. because can not use token to ensure user use a work account. } (var personList, var userList) = DisplayHelper.FormatRecipientList(originPersonList, originUserList); // people you work with has the distinct email address has the highest priority if (personList.Count == 1 && personList.First().ScoredEmailAddresses.Count() == 1 && personList.First().ScoredEmailAddresses != null && !string.IsNullOrEmpty(personList.First().ScoredEmailAddresses.First().Address)) { state.ConfirmedPerson = personList.First(); return(await sc.ReplaceDialogAsync(Actions.ConfirmEmail, personList.First())); } personList.AddRange(userList); foreach (var person in personList) { if (unionList.Find(p => p.DisplayName == person.DisplayName) == null) { var personWithSameName = personList.FindAll(p => p.DisplayName == person.DisplayName); if (personWithSameName.Count == 1) { unionList.Add(personWithSameName.FirstOrDefault()); } else { var unionPerson = personWithSameName.FirstOrDefault(); var emailList = new List <ScoredEmailAddress>(); foreach (var sameNamePerson in personWithSameName) { sameNamePerson.ScoredEmailAddresses.ToList().ForEach(e => { if (e != null && !string.IsNullOrEmpty(e.Address)) { emailList.Add(e); } }); } unionPerson.ScoredEmailAddresses = emailList; unionList.Add(unionPerson); } } } } else { return(await sc.EndDialogAsync()); } unionList.RemoveAll(person => !person.ScoredEmailAddresses.ToList().Exists(email => email.Address != null)); state.UnconfirmedPerson = unionList; if (unionList.Count == 0) { return(await sc.BeginDialogAsync(Actions.UpdateRecipientName, new UpdateUserDialogOptions(UpdateUserDialogOptions.UpdateReason.NotFound))); } else if (unionList.Count == 1) { state.ConfirmedPerson = unionList.First(); return(await sc.ReplaceDialogAsync(Actions.ConfirmEmail, unionList.First())); } else { var nameString = string.Empty; if (unionList.Count <= ConfigData.GetInstance().MaxDisplaySize) { return(await sc.PromptAsync(Actions.Choice, await GenerateOptionsForName(sc, unionList, sc.Context, true))); } else { return(await sc.PromptAsync(Actions.Choice, await GenerateOptionsForName(sc, unionList, sc.Context, false))); } } } catch (SkillException skillEx) { await HandleDialogExceptions(sc, skillEx); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
public async Task <DialogTurnResult> ReadEvent(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken)) { try { var state = await Accessor.GetAsync(sc.Context); var luisResult = state.LuisResult; var topIntent = luisResult?.TopIntent().intent; var eventItem = state.ReadOutEvents.FirstOrDefault(); if (eventItem != null && topIntent != Luis.CalendarLU.Intent.ChangeCalendarEntry && topIntent != Luis.CalendarLU.Intent.DeleteCalendarEntry) { var tokens = new StringDictionary() { { "Date", eventItem.StartTime.ToString(CommonStrings.DisplayDateFormat_CurrentYear) }, { "Time", SpeakHelper.ToSpeechMeetingTime(TimeConverter.ConvertUtcToUserTime(eventItem.StartTime, state.GetUserTimeZone()), eventItem.IsAllDay == true) }, { "Participants", DisplayHelper.ToDisplayParticipantsStringSummary(eventItem.Attendees) }, { "Subject", eventItem.Title } }; var replyMessage = await GetDetailMeetingResponseAsync(sc, eventItem, SummaryResponses.ReadOutMessage, tokens); await sc.Context.SendActivityAsync(replyMessage); if (eventItem.IsOrganizer) { return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(SummaryResponses.AskForOrgnizerAction, new StringDictionary() { { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower } }) })); } else if (eventItem.IsAccepted) { return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(SummaryResponses.AskForAction, new StringDictionary() { { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower } }) })); } else { return(await sc.PromptAsync(Actions.Prompt, new PromptOptions { Prompt = ResponseManager.GetResponse(SummaryResponses.AskForChangeStatus, new StringDictionary() { { "DateTime", state.StartDateString ?? CalendarCommonStrings.TodayLower } }) })); } } else { return(await sc.NextAsync()); } } catch (SkillException ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } catch (Exception ex) { await HandleDialogExceptions(sc, ex); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
protected string FormatName(string first, string last, string username) { return(DisplayHelper.FormatName(first, last, username)); }
public virtual async Task <ActionResult> Index(Guid organisationId, Guid returnId, Guid aatfId) { using (var client = apiClient()) { var weeeSentOn = await client.SendAsync(User.GetAccessToken(), new GetWeeeSentOn(aatfId, returnId, null)); var model = mapper.Map(new ReturnAndAatfToSentOnSummaryListViewModelMapTransfer() { WeeeSentOnDataItems = weeeSentOn, AatfId = aatfId, ReturnId = returnId, OrganisationId = organisationId, AatfName = (await cache.FetchAatfData(organisationId, aatfId)).Name }); var @return = await client.SendAsync(User.GetAccessToken(), new GetReturn(returnId, false)); await SetBreadcrumb(organisationId, BreadCrumbConstant.AatfReturn, aatfId, DisplayHelper.YearQuarterPeriodFormat(@return.Quarter, @return.QuarterWindow)); return(View(model)); } }