private void button1_Click(object sender, EventArgs e) { if ( MessageBox.Show("Are you sure you want to overwrite:\n'" + currentFile + "'?", "WARNING!!", MessageBoxButtons.OKCancel) == DialogResult.OK) { var dlist = new List <dialog>(); foreach (DataGridViewRow dr in dataGridView1.Rows) { var item = new dialog(); item.offset = (long)dr.Cells["offset"].Value; item.size = (int)dr.Cells["size"].Value; item.text = dr.Cells["text"].Value.ToString(); item.text = item.text.Replace("<LINEEND>", Encoding.UTF8.GetString(new byte[] { 0x0A })); item.text = item.text.Replace("<END>", Encoding.UTF8.GetString(new byte[] { 0x00 })); dlist.Add(item); } if (!ASBTools.injectDialogList(currentFile, dlist)) { MessageBox.Show("An error occurred while inserting!", "ERROR", MessageBoxButtons.OK); } } MessageBox.Show("Done.", "Done.", MessageBoxButtons.OK); }
private void button2_Click(object sender, EventArgs e) { // Create an instance of the open file dialog box. OpenFileDialog openFileDialog1 = new OpenFileDialog(); // Set filter options and filter index. openFileDialog1.Filter = "Text Files (.txt)|*.txt"; openFileDialog1.FilterIndex = 1; // Process input if the user clicked OK. if (openFileDialog1.ShowDialog() == DialogResult.OK) { textBox1.Text = ""; label1.Text = "Characters left: 0"; selectedRowIndex = 0; Stream fileStream = openFileDialog1.OpenFile(); List <dialog> dList = new List <dialog>(); StreamReader file = new StreamReader(fileStream); while (!file.EndOfStream) { dialog d1 = new dialog(); string s = file.ReadLine(); string[] split = s.Split(new char[] { ';' }); d1.offset = Convert.ToInt64(split[0]); d1.size = Convert.ToInt32(split[1]); d1.text = split[2]; dList.Add(d1); } file.Close(); dataGridView1.ReadOnly = true; dataGridView1.DataSource = dList; dataGridView1.AutoResizeColumns(); } }
private void button1_Click(object sender, EventArgs e) { SaveFileDialog sfd1 = new SaveFileDialog(); sfd1.Filter = "Text Files (.txt)|*.txt"; sfd1.FilterIndex = 1; if (sfd1.ShowDialog() == DialogResult.OK) { List <dialog> items = new List <dialog>(); foreach (DataGridViewRow dr in dataGridView1.Rows) { dialog item = new dialog(); item.offset = (long)dr.Cells["offset"].Value; item.size = (int)dr.Cells["size"].Value; item.text = dr.Cells["text"].Value.ToString(); items.Add(item); } using (BinaryWriter writer = new BinaryWriter(File.Open(sfd1.FileName, FileMode.Create))) { foreach (dialog d in items) { writer.Write(Encoding.UTF8.GetBytes(d.offset.ToString())); writer.Write(Encoding.UTF8.GetBytes(";")); writer.Write(Encoding.UTF8.GetBytes(d.size.ToString())); writer.Write(Encoding.UTF8.GetBytes(";")); writer.Write(Encoding.UTF8.GetBytes(d.text.ToString())); writer.Write(Encoding.UTF8.GetBytes(Environment.NewLine)); } } } }
private void button3_Click(object sender, EventArgs e) { dialog obj = (dialog)dataGridView1.Rows[selectedRowIndex].DataBoundItem; obj.text = textBox1.Text; dataGridView1.Refresh(); }
private static void Insert(string cmdFile, string inFile) { List <dialog> dList = new List <dialog>(); using (StreamReader file = new StreamReader(cmdFile)) { while (!file.EndOfStream) { dialog d1 = new dialog(); string s = file.ReadLine(); string[] split = s.Split(';'); d1.offset = Convert.ToInt64(split[0]); d1.size = Convert.ToInt32(split[1]); d1.text = split[2]; d1.text = d1.text.Replace("<LINEEND>", Encoding.UTF8.GetString(new byte[] { 0x0A })); d1.text = d1.text.Replace("<END>", Encoding.UTF8.GetString(new byte[] { 0x00 })); dList.Add(d1); } } Console.WriteLine("Writing to {0}", inFile); if (!ASBTools.injectDialogList(inFile, dList)) { Console.WriteLine("ERROR!!!!!! - Inject failed...\n"); } }
void OnEnable() { Dialog = (dialog)target; for (int i = 0; i < Dialog.dialog_cycles.Count; i++) { show_dialog.Add(false); } }
public IEnumerator showDialog(dialog dialog) { yield return(new WaitForEndOfFrame()); OnDialogOpen?.Invoke(); this.Dialog = dialog; dialogBox.SetActive(true); StartCoroutine(TypeDialog(dialog.Lines[0])); }
public void startDialog(dialog dialogs) { sentences.Clear(); foreach (string sentence in dialogs.sentences) { sentences.Enqueue(sentence); } displayNextSentence(); }
public void StartDialog(dialog dialogg) { animator.SetBool("isOpen", true); animator2.SetBool("isOpen2", false); nameText.text = dialogg.name; sentences.Clear(); foreach (string sentence in dialogg.sentences) { sentences.Enqueue(sentence); } DisplayNextSentence(); }
private void openraildefToolStripMenuItem_Click(object sender, EventArgs e) { // Show the dialog and get result. DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) // Test result. { save_path = null; active_dialog = dialog.rail_def_1; LoadRailXML rail = new LoadRailXML(openFileDialog1.FileName); } System.Diagnostics.Debug.WriteLine(result); // <-- For debugging use. }
private void opencoursemakerToolStripMenuItem_Click(object sender, EventArgs e) { // Show the dialog and get result. DialogResult result = openFileDialog2.ShowDialog(); if (result == DialogResult.OK) // Test result. { save_path = null; active_dialog = dialog.coursemaker_1; LoadSceneryXML scenery = new LoadSceneryXML(openFileDialog2.FileName); } System.Diagnostics.Debug.WriteLine(result); // <-- For debugging use. }
public PromptDialog(dialog objDialog) { m_oDialog = objDialog; this.Visible = false; InitializeComponent(); BPContext = new BrightPlatformEntities(UserSession.EntityConnection); WaitDialog.Show(ParentForm, "Loading subcampaigns..."); SetValidationRules(); BindLookupEdit(); this.Visible = true; textEditDialogname.Text = m_oDialog.name; WaitDialog.Close(); }
void Awake() //싱글톤 패턴으로 어느 씬에서든 접근 가능하게 한다. { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
IEnumerator ShowDialog(dialog d) { DialogBox.SetActive(true); DialogText.text = d.dText; yield return(new WaitForSeconds(d.duration)); if (d.next == -1) { DialogBox.SetActive(false); } else { callShowDialog(Dialogs[d.next]); } }
public static void Save_Asset(string FileName, dialog dlg) { if (!File.Exists(FileName)) { throw new Exception("File does not exist!"); } byte[] xml_file = File.ReadAllBytes(FileName); using (FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write)) { fs.Seek(0, SeekOrigin.Begin); fs.Write(pre_header, 0, pre_header.Length); fs.Seek(0x1000, SeekOrigin.Begin); if (dlg == dialog.rail_def_1 || dlg == dialog.rail_def_2) { byte[] lenght = BitConverter.GetBytes(ID_rail.Length); fs.Write(lenght, 0, lenght.Length); byte[] bytes = Encoding.GetEncoding(ENCODE_TYPE).GetBytes(ID_rail); fs.Write(bytes, 0, bytes.Length); byte[] _lenght = BitConverter.GetBytes(xml_file.Length); fs.Write(_lenght, 0, _lenght.Length); fs.Write(xml_file, 0, xml_file.Length); // Let's fix the lengths fs.Seek(0x04, SeekOrigin.Begin); fs.Write(BitConverter.GetBytes((Int32)fs.Length).Reverse().ToArray(), 0, 4); fs.Seek(0x4C, SeekOrigin.Begin); fs.Write(BitConverter.GetBytes((Int32)(fs.Length - 0x1000)), 0, 4); } else if (dlg == dialog.coursemaker_1 || dlg == dialog.coursemaker_2) { byte[] lenght = BitConverter.GetBytes(ID_scenery.Length); fs.Write(lenght, 0, lenght.Length); byte[] bytes = Encoding.GetEncoding(ENCODE_TYPE).GetBytes(ID_scenery); fs.Write(bytes, 0, bytes.Length); fs.WriteByte(0); byte[] _lenght = BitConverter.GetBytes(xml_file.Length); fs.Write(_lenght, 0, _lenght.Length); fs.Write(xml_file, 0, xml_file.Length); // Let's fix the lengths fs.Seek(0x04, SeekOrigin.Begin); fs.Write(BitConverter.GetBytes((Int32)fs.Length).Reverse().ToArray(), 0, 4); fs.Seek(0x4C, SeekOrigin.Begin); fs.Write(BitConverter.GetBytes((Int32)(fs.Length - 0x1000)), 0, 4); } } }
private static void FolderInsert(string cmdFolder, string asbFolder) { string[] cmdFiles = Directory.GetFiles(cmdFolder); int total = cmdFiles.Count(); int current = 0; Parallel.ForEach(cmdFiles, cmdfileName => { try { List <dialog> dList = new List <dialog>(); using (StreamReader file = new StreamReader(cmdfileName)) { while (!file.EndOfStream) { dialog d1 = new dialog(); string s = file.ReadLine(); string[] split = s.Split(';'); d1.offset = Convert.ToInt64(split[0]); d1.size = Convert.ToInt32(split[1]); d1.text = split[2]; d1.text = d1.text.Replace("<LINEEND>", Encoding.UTF8.GetString(new byte[] { 0x0A })); d1.text = d1.text.Replace("<END>", Encoding.UTF8.GetString(new byte[] { 0x00 })); dList.Add(d1); } } string outfile = asbFolder + "\\" + Path.GetFileNameWithoutExtension(cmdfileName) + ".asb"; Console.WriteLine("Writing to {0}", outfile); if (!ASBTools.injectDialogList(outfile, dList)) { Console.WriteLine("ERROR!!!!!! - Inject failed...\n"); } } finally { Interlocked.Increment(ref current); Console.SetCursorPosition(0, 0); Console.CursorTop = 0; Console.ForegroundColor = ConsoleColor.White; Console.Write("FILE: {0}\r", cmdfileName); DrawProgressBar(current, total, 36, '■'); } }); }
void AccuseOfLying() { dialogType = dialog.accusation; Testimony testimony = testimonyQueue.Peek(); testimonyQueue.Clear(); dialogueQueue.Clear(); if (testimony.truth == false) { speakingNPC.stress = Mathf.Min(speakingNPC.stress + speakingNPC.stressIncrements, 1.0f); displayText("...okay, I'll tell you the truth."); revealTruth(testimony); } else { speakingNPC.lieAccusations--; displayText("How dare you accuse me of such a thing!"); if (speakingNPC.lieAccusations <= 0) lockedOut(); } }
private void openraildef2ToolStripMenuItem_Click(object sender, EventArgs e) { // Show the dialog and get result. DialogResult result = openFileDialog3.ShowDialog(); if (result == DialogResult.OK) // Test result. { using (FileStream fs = new FileStream(openFileDialog3.FileName, FileMode.Open, FileAccess.Read)) { byte[] header = new byte[System.Runtime.InteropServices.Marshal.SizeOf(magic_unity)]; fs.Seek(0L, SeekOrigin.Begin); fs.Read(header, 0, 4); if (BitConverter.ToUInt32(header.Reverse().ToArray(), 0) != magic_unity) { byte[] bytes = Encoding.GetEncoding(ENCODE_TYPE).GetBytes(ID_rail); byte[] array = new byte[bytes.Length]; fs.Seek(0L, SeekOrigin.Begin); fs.Read(array, 0, bytes.Length); for (int i = 0; i < bytes.Length; i++) { if (bytes[i] != array[i]) { throw new Exception("File ID is invalid. \"" + Encoding.UTF8.GetString(array, 0, array.Length) + "\""); } } save_path = null; pack_status = packed.unpacked; active_dialog = dialog.rail_def_2; populateTreeview(openFileDialog3.FileName); } else { save_path = null; pack_status = packed.packed; active_dialog = dialog.rail_def_2; populateTreeview(Unity_Asset_Handler.Load_Asset(openFileDialog3.FileName)); } } } System.Diagnostics.Debug.WriteLine(result); // <-- For debugging use. }
void NPCSuspects() { dialogType = dialog.suspect; Debug.Log("Running npc suspects"); SuspectTestimony st = TestimonyManager.pickASuspect(speakingNPC); if (st != null) { testimonyQueue.Enqueue(st); Npc.Gender suspectGender = st.npc.gender; Npc.Gender victimGender = pg.victim.gender; displayText(string.Format("I think {0} did it.", st.npc.getFullName())); if (st.motive is StoleLover) { StoleLover motive = st.motive as StoleLover; dialogueQueue.Enqueue(string.Format("Not long ago {0} left {1} for {2} and {3} clearly never got over it.", Grammar.selfOrName(motive.lover, speakingNPC), Grammar.getObjectPronoun(st.npc, speakingNPC), pg.victim.firstname, Grammar.getSubjectPronoun(st.npc, speakingNPC))); } else if (st.motive is CompetingForLove) { CompetingForLove motive = st.motive as CompetingForLove; dialogueQueue.Enqueue(string.Format("{0} been fighting {1} for {2}'s affections for a long time now, it was bound to come to a head at some point.", Grammar.getSubjectPronounHave(st.npc, speakingNPC), pg.victim.firstname, Grammar.selfOrNamePossessive(motive.lover, speakingNPC))); } else if (st.motive is BadBreakup) { BadBreakup motive = st.motive as BadBreakup; dialogueQueue.Enqueue(string.Format("It's no secret that {0} and {1} split up, {2} took it very badly.", Grammar.getSubjectPronoun(st.npc, speakingNPC), pg.victim.firstname, Grammar.getSubjectPronoun(st.npc, speakingNPC))); } else if (st.motive is FiredBy) { FiredBy motive = st.motive as FiredBy; dialogueQueue.Enqueue(string.Format("{0} used to work under {1} until {2} was fired, and {3} been looking for work since.", st.npc.firstname, pg.victim.firstname, Grammar.getSubjectPronoun(st.npc, speakingNPC), Grammar.getSubjectPronounHave(st.npc, speakingNPC))); } else if (st.motive is PutOutOfBusiness) { PutOutOfBusiness motive = st.motive as PutOutOfBusiness; dialogueQueue.Enqueue(string.Format("Everyone knows that {0} put {1} out of business, it completely ruined {2} and {3} family.", pg.victim.firstname, st.npc.firstname, Grammar.getObjectPronoun(st.npc, speakingNPC), Grammar.myHisHer(st.npc, speakingNPC))); } else if (st.motive is Nemeses) { Nemeses motive = st.motive as Nemeses; dialogueQueue.Enqueue(string.Format("{0} and {1} have been at eachother's throats for as long as I can remember.", Grammar.getObjectPronoun(st.npc, speakingNPC), pg.victim.firstname, Grammar.getObjectPronoun(st.npc, speakingNPC))); } else if (st.motive is RejectedLove) { Nemeses motive = st.motive as Nemeses; dialogueQueue.Enqueue(string.Format("{0} confessed {1} love to {2} recently, but {3} rejected {4} very harshly.", Grammar.getSubjectPronoun(st.npc, speakingNPC), Grammar.myHisHer(st.npc, speakingNPC), pg.victim.firstname, Grammar.getSubjectPronoun(pg.victim, speakingNPC), Grammar.getObjectPronoun(st.npc, speakingNPC))); } else displayText(string.Format("I think {0} did it, they've been out for revenge ever since {1} did that {2} to them", st.npc.getFullName(), pg.victim.getFullName(), st.motive.GetType())); } else displayText("Sorry, I have no idea"); }
/// <summary> /// View dialog /// </summary> private void ViewDialog() { m_oContactView.gvContact.OptionsFind.AlwaysVisible = true; WaitDialog.CreateWaitDialog("Loading dialog questionnaires..."); #region Populate each JSON questionnaire from dialog text to list object type var selectedContact = m_oContactView.SelectedContact; groupControlDialog.Text = string.Format("Dialog with: {0} {1}, {2}", selectedContact.first_name, selectedContact.last_name, SelectedCompany); m_oDialog = BPContext.dialogs.FirstOrDefault(p => p.subcampaign_id == oAppointment.SubCampaignId && //p.customers_id == oAppointment.CustomerId && p.is_active == true); if (m_oDialog == null) { MessageBox.Show("There is no current dialog created for this customer's subcampaign."); WaitDialog.CloseWaitDialog(); return; //prompt message saying that no dialog for current subcampaign and customer. } var CQList = new List<CampaignQuestionnaire>(); CampaignQuestionnaire oQuestionnaire = null; List<string> cbdList = new List<string>(); DataBindings oBindings = null; if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json)) { var jaDiag = JArray.Parse(m_oDialog.dialog_text_json); jaDiag.ForEach(delegate(JToken jt) { oQuestionnaire = CampaignQuestionnaire.InstanciateWith(jt.ToString(Formatting.None).Unescape()); if (oQuestionnaire != null) { CQList.Add(oQuestionnaire); oBindings = oQuestionnaire.Form.Settings.DataBindings; if (oBindings != null) { if (!string.IsNullOrEmpty(oBindings.questionlayout_id)) { cbdList.Add(oBindings.questionlayout_id); } } } }); } #endregion #region Populate Answers to each questionnaire int? campaign_id = oAppointment.CampaignId; int? account_id = oAppointment.AccountId; int? contact_id = m_oContactView.SelectedContact.id; int? dialog_id = m_oDialog.id; //get all dialog answers based on questionlayout_ids and other params var listDialogAnswers = BPContext.FIGetDialogAnswers( string.Join(",", cbdList.Distinct().ToArray()), campaign_id, account_id, contact_id, dialog_id).ToList().Clone(); layoutControlGroupQuestionnaire.BeginUpdate(); layoutControlGroupQuestionnaire.BeginInit(); DisposeGroupControls(layoutControlGroupQuestionnaire); int rowcount = CQList.Count; CTDialogAnswers dlgAnswer = null; for (int i = 0; i < rowcount; ++i) { oQuestionnaire = CQList[i]; oBindings = oQuestionnaire.Form.Settings.DataBindings; dlgAnswer = listDialogAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(oBindings.questionlayout_id) && p.campaign_id == campaign_id && p.account_id == account_id && p.contact_id == contact_id && p.dialog_id == dialog_id); if (dlgAnswer != null) { oBindings.answer_id = dlgAnswer.id.ToString(); } else { oBindings.account_id = account_id.ToString(); oBindings.campaign_id = campaign_id.ToString(); oBindings.contact_id = contact_id.ToString(); oBindings.dialog_id = dialog_id.ToString(); oBindings.created_by = UserSession.CurrentUser.UserId.ToString(); } switch (oQuestionnaire.Type.ToLower()) { case QuestionTypeConstants.Dropbox: Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire); oDropbox.DisableSelection = true; oDropbox.ToolTipController = defaultToolTipController1; //load answers for this questionnaire if (dlgAnswer != null) { oDropbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire); } else { oDropbox.Questionnaire = oQuestionnaire; } oDropbox.BindControls(); this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup); break; case QuestionTypeConstants.MultipleChoice: Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire); oMultipleChoice.DisableSelection = true; oMultipleChoice.ToolTipController = defaultToolTipController1; //load answers for this questionnaire if (dlgAnswer != null) { oMultipleChoice.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire); } else { oMultipleChoice.Questionnaire = oQuestionnaire; } oMultipleChoice.BindControls(); this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup); break; case QuestionTypeConstants.Textbox: Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire); oTextbox.DisableSelection = true; oTextbox.ToolTipController = defaultToolTipController1; //load answers for this questionnaire if (dlgAnswer != null) { oTextbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire); } else { oTextbox.Questionnaire = oQuestionnaire; } oTextbox.BindControls(); this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup); break; case QuestionTypeConstants.Schedule: Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire); var result = m_oContactView.gcContact.DataSource as List<CTScSubCampaignContactList>; if (result != null) oSchedule.SubCampaignContactList = result; oSchedule.SubcampaignID = oAppointment.SubCampaignId; oSchedule.DisableSelection = true; oSchedule.ToolTipController = defaultToolTipController1; if (m_oContactView.SelectedContact != null) { oSchedule.SetCurrentCaller(m_oContactView.SelectedContact, oAppointment.AccountId); } //load answers for this questionnaire if (dlgAnswer != null) { oSchedule.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire); } else { oSchedule.Questionnaire = oQuestionnaire; } oSchedule.BindControls(); oSchedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick); this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup); break; //case QuestionTypeConstants.Seminar: // Seminar oSeminar = new Seminar(this.layoutControlQuestionnaire); // oSeminar.DisableSelection = true; // oSeminar.ToolTipController = defaultToolTipController1; // //load answers for this questionnaire // if (dlgAnswer != null) { // oSeminar.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire); // } else { // oSeminar.Questionnaire = oQuestionnaire; // } // oSeminar.BindControls(); // this.layoutControlGroupQuestionnaire.Add(oSeminar.ControlGroup); // break; } } EmptySpaceItem emptySpaceItem1 = new EmptySpaceItem(); emptySpaceItem1.CustomizationFormText = "emptySpaceItemBottom"; emptySpaceItem1.Name = "emptySpaceItemBottom"; emptySpaceItem1.ShowInCustomizationForm = false; emptySpaceItem1.Size = new System.Drawing.Size(0, 0); emptySpaceItem1.Text = "emptySpaceItemBottom"; emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0); //add bottom spacer this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1); //set readonly and disabled controls -> for viewing only //this.layoutControlQuestionnaire.OptionsView.IsReadOnly = DevExpress.Utils.DefaultBoolean.True; SetEditableComponent(false); ValidateDialog(); this.layoutControlGroupQuestionnaire.EndInit(); this.layoutControlGroupQuestionnaire.EndUpdate(); this.layoutControlQuestionnaire.BestFit(); #endregion WaitDialog.CloseWaitDialog(); }
/// <summary> /// Load Form_OnLoad() initializations /// </summary> public void OnLoadInitialization() { #region Toggle Buttons Enabled for Contacts grid m_oDialog = BPContext.dialogs.FirstOrDefault(p => p.subcampaign_id == oAppointment.SubCampaignId && //p.customers_id == oAppointment.CustomerId && p.is_active == true); if (m_oDialog == null) { //btnDeleteDialog.Enabled = false; btnEditDialog.Enabled = false; } else { //btnDeleteDialog.Enabled = true; btnEditDialog.Enabled = true; } #endregion #region Load Company Information in Group Tab this.LoadCompanyInformation(); #endregion #region Load Contact Information in Group Tab this.LoadContactInformation(); #endregion this.LoadCustomEvents(); //comboBoxEditCompanyStatus.Text = oAppointment.CompanyAppointmentStatus; m_SelectedPageName = lcgContactInformation.Name; this.SetContactViewButtons(false); //btnDeleteDialog.Enabled = false; btnEditDialog.Enabled = false; btnCallDirect.Enabled = false; btnCallMobile.Enabled = false; btnHangUp.Enabled = false; btnCallNumber.Enabled = true; if (m_oContactView.SelectedContact != null) { this.InitializeFollowUpView(); this.InitEventAndFollowUpObjects(); ViewDialog(); //btnDeleteDialog.Enabled = true; btnEditDialog.Enabled = true; if (!string.IsNullOrEmpty(m_oContactView.SelectedContact.direct_phone)) btnCallDirect.Enabled = true; if (!string.IsNullOrEmpty(m_oContactView.SelectedContact.mobile)) btnCallMobile.Enabled = true; this.SetContactViewButtons(true); } //if (oAppointment.CompanyAppointmentStatus.Equals("Open") || string.IsNullOrEmpty(oAppointment.CompanyAppointmentStatus)) //{ // cmdSaveExitAsOpen.ButtonStyle = BorderStyles.Office2003; // cmdSaveExitAsOpen.Refresh(); //} //else if (oAppointment.CompanyAppointmentStatus.Equals("In Progress")) //{ // cmdSaveExitAsInProgress.ButtonStyle = BorderStyles.Office2003; // cmdSaveExitAsInProgress.Refresh(); //} //else if (oAppointment.CompanyAppointmentStatus.Equals("Follow Up")) //{ // cmdSaveExitAsFollowUp.ButtonStyle = BorderStyles.Office2003; // cmdSaveExitAsFollowUp.Refresh(); //} //else if (oAppointment.CompanyAppointmentStatus.Equals("Finished")) //{ // cmdSaveExitAsFinished.ButtonStyle = BorderStyles.Office2003; // cmdSaveExitAsFinished.Refresh(); //} // finally, set record navigation buttons and style appearance this.SetSaveButtonAppearance(); //this.SetRecordNavigationButtons(false); //dateEditDateLog.DateTime = DateTime.Now; //timeEditStartTime.Time = DateTime.Now; //timeEditEndtime.Time = DateTime.Now; }
void skipText() { StopAllCoroutines(); shownString = fullString; TextArea.text = shownString; if (dialogType == dialog.alibi || dialogType == dialog.eventsWitnessed || dialogType == dialog.suspect || dialogueQueue.Count > 0) { state = conversationState.moreText; } else { setUpDialogOptions(); if (speakingNPC.isAlive) dialogType = dialog.greeting; else dialogType = dialog.corpse; state = conversationState.playerInput; } }
private void LoadDialog(CTSubCampaignDialogs subcampaignDialog) { isSaved = true; textEditDialogname.Text = subcampaignDialog.DialogName; lookUpEditSource.EditValue = subcampaignDialog.SubCampaignID; m_oDialog = BPContext.dialogs.FirstOrDefault(p => p.id == subcampaignDialog.DialogID); var CQList = new List<CampaignQuestionnaire>(); var QLIDs = new List<int>(); var jaDiag = JArray.Parse(m_oDialog.dialog_text_json); CampaignQuestionnaire CQ = null; int qlid; jaDiag.ForEach(delegate(JToken jt) { CQ = CampaignQuestionnaire.InstanciateWith(jt.ToString(Formatting.None).Unescape()); if(CQ != null) { if(int.TryParse(CQ.Form.Settings.DataBindings.questionlayout_id, out qlid)) QLIDs.Add(qlid); CQList.Add(CQ); } }); if (CQList.Count <= 0) { simpleButtonAssignAnswerForm.Enabled = false; return; } DataTable dtDialog = gridControlDialog.DataSource as DataTable; int qid, qtlid; var answerform = (from bp in BPContext.questionlayouts.Include("questionlayout_language") where QLIDs.Contains(bp.id) select bp).ToList(); questionlayout questionLayout = null; CTQuestionTags questiontags = null; DataRow newDr = null; CQList.ForEach(delegate(CampaignQuestionnaire dcq) { var datasource = gridControlQuestions.DataSource as List<CTQuestionTags>; if(int.TryParse(dcq.Form.Settings.DataBindings.question_id, out qid) && int.TryParse(dcq.Form.Settings.DataBindings.questions_text_language_id, out qtlid) && int.TryParse(dcq.Form.Settings.DataBindings.questionlayout_id, out qlid)) { questionLayout = answerform.FirstOrDefault(p => p.questions_id == qid && p.id == qlid); questiontags = datasource.FirstOrDefault(x => x.question_id == qid && x.question_text_language_id == qtlid); } if (questiontags != null) { int rowcount = 0; if (dtDialog != null) { //DataRow[] drs = dtDialog.Select("question_text='" + row.question_text + "'"); //if (drs.Length > 0) { // MessageBox.Show("The selected question has already been added to the dialog list.", "Information"); // return; //} else { DataRow[] last = dtDialog.Select("position = Max(position)"); if (last.Length > 0) { rowcount = Convert.ToInt32(last[0].ItemArray[0]); } //} } newDr = dtDialog.NewRow(); newDr["position"] = rowcount + 1; newDr["question_text"] = questiontags.question_text; newDr["question_id"] = questiontags.question_id; newDr["question_text_language_id"] = questiontags.question_text_language_id; newDr["question_help_text"] = questiontags.question_help_text; newDr["question_description"] = questiontags.question_description; if (questionLayout != null) { newDr["answer_form"] = questionLayout.title; newDr["answer_form_id"] = questionLayout.id; newDr["answer_form_language_id"] = questionLayout.questionlayout_language.FirstOrDefault().id; newDr["content_json"] = questionLayout.content_json; } dtDialog.Rows.Add(newDr); dtDialog.AcceptChanges(); simpleButtonAssignAnswerForm.Enabled = true; } }); }
void NPCIntroduction() { dialogType = dialog.introduction; speakingNPC.nameKnown = true; displayText(string.Format("I am {0}", speakingNPC.getFullName())); Family family = speakingNPC.family; if (family != null) { bool isHusband = false; bool isWife = false; if (family.husband == speakingNPC) isHusband = true; else if (family.wife == speakingNPC) isWife = true; if (isHusband || isWife) { if (isHusband) dialogueQueue.Enqueue(string.Format("{0} is my wife", family.wife.firstname)); else if (isWife) dialogueQueue.Enqueue(string.Format("{0} is my husband", family.husband.firstname)); if (family.children.Count == 1) { if (family.children[0].gender == Npc.Gender.Male) dialogueQueue.Enqueue(string.Format("Our son, {0}, is also here tonight.", family.children[0].firstname)); else dialogueQueue.Enqueue(string.Format("Our daughter, {0}, is also here tonight.", family.children[0].firstname)); } else if (family.children.Count > 1) { string children = "Our children, "; for (int i = 0; i < family.children.Count - 1; i++) { children += String.Format("{0}, ", family.children[i].firstname); } children += String.Format("and {0} are also here tonight.", family.children[family.children.Count - 1].firstname); dialogueQueue.Enqueue(children); } } //If not husband or wife, must be a child else { dialogueQueue.Enqueue(string.Format("{0} and {1} are my parents", family.husband.firstname, family.wife.firstname)); if (family.children.Count == 2) { int childNumber = family.children.IndexOf(speakingNPC); if (childNumber == 0) { if (family.children[1].gender == Npc.Gender.Male) dialogueQueue.Enqueue(string.Format("My brother, {0}, is also here tonight.", family.children[1].firstname)); else dialogueQueue.Enqueue(string.Format("My sister, {0}, is also here tonight.", family.children[1].firstname)); } else { if (family.children[0].gender == Npc.Gender.Male) dialogueQueue.Enqueue(string.Format("My brother, {0}, is also here tonight.", family.children[0].firstname)); else dialogueQueue.Enqueue(string.Format("My sister, {0}, is also here tonight.", family.children[0].firstname)); } } else if (family.children.Count > 2){ string siblings = "My siblings, "; List<Npc> siblingsList = new List<Npc>(family.children); siblingsList.Remove(speakingNPC); for (int i = 0; i < siblingsList.Count - 1; i++) { siblings += String.Format("{0}, ", siblingsList[i].firstname); } siblings += String.Format("and {0} are also here tonight.", siblingsList[siblingsList.Count - 1].firstname); dialogueQueue.Enqueue(siblings); } } } }
private void simpleButtonSaveDialog_Click(object sender, EventArgs e) { if (!dxValidationProvider1.Validate()) return; string _msg = "Dialog already exist for sub-campaign " + lookUpEditSubCampaign.Text.ToUpper() + "." + Environment.NewLine + "Only one(1) dialog per sub-campaign is allowed."; if (SubCampaignDialog == null) { if (!ObjectDialog.CanAddDialog((int)lookUpEditSubCampaign.EditValue)) { MessageBox.Show(_msg, "Dialogs", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } else if (ObjectDialog.Exists(textEditDialogname.Text, (int)lookUpEditSubCampaign.EditValue) && (!m_IsEdit || (m_IsEdit && !SubCampaignDialog.DialogName.Equals(textEditDialogname.Text)))) { MessageBox.Show(_msg, "Dialogs", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } } else if (SubCampaignDialog !=null && ObjectDialog.Exists(textEditDialogname.Text, (int)lookUpEditSubCampaign.EditValue, SubCampaignDialog.DialogID)) { if (!m_IsEdit || (m_IsEdit && !SubCampaignDialog.DialogName.Equals(textEditDialogname.Text))) { MessageBox.Show(_msg, "Dialogs", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } } /** * applied so that when pressing save and then pressing done for new entries, * it should validate as edit mode when pressing done. */ if (!m_IsEdit) m_IsEdit = true; var dtDialog = gridControlDialog.DataSource as DataTable; if (dtDialog != null && dtDialog.Rows.Count > 0) dtDialog.AcceptChanges(); Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; string dialog_text_json = string.Empty; GridView view = gridViewDialog; if (view != null && view.RowCount > 0) { DataRow row; CampaignQuestionnaire oQuestionnaire = null; JArray jaDiag = new JArray(); JObject joDiag = null; for (int i = 0; i < view.RowCount; i++) { row = view.GetDataRow(i); if (row["content_json"] == null || string.IsNullOrEmpty(row["content_json"].ToString())) continue; oQuestionnaire = CampaignQuestionnaire.InstanciateWith(row["content_json"].ToString()); if (oQuestionnaire == null) continue; if (row["question_text"] != null) oQuestionnaire.Form.Settings.QuestionText = row["question_text"].ToString(); if (row["question_help_text"] != null) oQuestionnaire.Form.Settings.QuestionHelp = row["question_help_text"].ToString(); if (row["question_id"] != null) oQuestionnaire.Form.Settings.DataBindings.question_id = row["question_id"].ToString(); if (row["question_text_language_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questions_text_language_id = row["question_text_language_id"].ToString(); if (row["language_code"] != null) oQuestionnaire.Form.Settings.DataBindings.language_code = row["language_code"].ToString(); if (row["answer_form_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questionlayout_id = row["answer_form_id"].ToString(); if (row["answer_form_language_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questionlayout_language_id = row["answer_form_language_id"].ToString(); joDiag = JObject.Parse(oQuestionnaire.ToJSONString()); jaDiag.Add(joDiag); } dialog_text_json = jaDiag.ToString(Formatting.None); } if (!isSaved) { m_oDialog = new dialog(); m_oDialog.created_date = DateTime.Now; } else { if (m_oDialog == null) { if (SubCampaignDialog != null && SubCampaignDialog.DialogID > 0) { m_oDialog = BPContext.dialogs.FirstOrDefault(q => q.id == SubCampaignDialog.DialogID); } } } m_oDialog.subcampaign_id = Convert.ToInt32(lookUpEditSubCampaign.EditValue); m_oDialog.name = textEditDialogname.Text.Trim(); m_oDialog.dialog_text_json = dialog_text_json; m_oDialog.created_by = UserSession.CurrentUser.UserId; m_oDialog.is_active = true; if (!isSaved) { BPContext.dialogs.AddObject(m_oDialog); isSaved = true; } BPContext.SaveChanges(); if (SubCampaignDialog == null) { SubCampaignDialog = new CTSubCampaignDialogs() { DialogID = m_oDialog.id, DateCreated = m_oDialog.created_date, DialogName = m_oDialog.name, SubCampaignID = m_oDialog.subcampaign_id, SubCampaignTitle = m_oDialog.subcampaign.title }; } /** * lets set this so we can determine on the parent controller * which dialog is to be default selected */ ParentController.DefaultSelectedDialogId = m_oDialog.id; Cursor.Current = currentCursor; if(sender != null && sender.ToString() != "skip") MessageBox.Show("Dialog has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //if (this.ParentForm != null) { // this.ParentForm.DialogResult = DialogResult.OK; //} }
public void setDialog(string _name, dialog[] _input) { this.transform.gameObject.GetComponent<CreateDialog>().setDialog(_name, _input); }
void lockedOut() { dialogType = dialog.lockedOut; dialogueQueue.Enqueue("If you're going to keep making these baseless accusations I see no reason to continue this conversation."); displayText(dialogueQueue.Dequeue()); pg.checkNPCKnowledge(); }
IEnumerator RevealString() { foreach (char letter in fullString.ToCharArray()) { shownString += letter; if (state == conversationState.npcSpeaking || state == conversationState.playerInput)audioSource.PlayOneShot(letterSound); if(dialogType != dialog.corpse && dialogType != dialog.murderAccusation) { float combinedLetterDelay = letterDelay; if (letter == ',') combinedLetterDelay += 0.09f; //add a pause to commas else if (letter == '.') combinedLetterDelay += 0.12f; //slightly longer pause to full stops //chance to stammer between each word to indicate stress else if (letter == ' ') { float chanceToStutter = UnityEngine.Random.Range(0.1f, 1.0f); if (chanceToStutter < speakingNPC.stress) { combinedLetterDelay += UnityEngine.Random.Range(0.09f, 0.2f); } } yield return new WaitForSeconds(combinedLetterDelay); } else yield return new WaitForSeconds(letterDelay); } if (shownString == fullString) { if (dialogType == dialog.alibi || dialogType == dialog.eventsWitnessed || dialogType == dialog.suspect || dialogueQueue.Count > 0) { state = conversationState.moreText; } else { setUpDialogOptions(); if (speakingNPC.isAlive) dialogType = dialog.greeting; else dialogType = dialog.corpse; state = conversationState.playerInput; } StopAllCoroutines(); } }
public void LoadDialogQuestionnaires(bool pDisposeQuestionnaire = false) { this.RunAssync(() => { bool _ReloadContacts = false; if (pDisposeQuestionnaire) { m_BrightSalesProperty.CampaignBooking.Questionnaire.State = SelectionProperty.DialogEditorState.Empty; this.DisposeGroupControls(layoutControlGroupQuestionnaire); _ReloadContacts = true; } m_AnswerBindingOnProgress = true; m_HasMustSaveDefaultValues = false; this.ResetToDefaultState(); this.BindDialogManagerData(_ReloadContacts); //marker... using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) { /** * get and set bindings. */ m_oDialog = _efDbContext.dialogs.FirstOrDefault(i => i.subcampaign_id == SubCampaignId && i.is_active == true); if (m_oDialog == null) { bbiEditDialog.Enabled = false; NotificationDialog.Warning("Bright Sales", "There is no current dialog created for this customer's subcampaign."); return; } _efDbContext.Detach(m_oDialog); /** * Populate each JSON questionnaire from dialog text to list object type. */ #region Code Logic m_lstQuestionnaireDialog = new List<CampaignQuestionnaire>(); m_lstQuestionLayoutIds = new List<string>(); CampaignQuestionnaire _Questionnaire = null; DataBindings _BindingData = null; if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json)) { var jaDiag = JArray.Parse(m_oDialog.dialog_text_json); jaDiag.ForEach(delegate(JToken jt) { /** * [@jeff 06.08.2012]: https://brightvision.jira.com/browse/PLATFORM-1467 * added json converter to convert raw json to string, before unescaping. */ string _jsonData = ValidationUtility.StripJsonInvalidChars(JsonConvert.ToString(jt.ToString(Formatting.None)).Unescape()); _Questionnaire = CampaignQuestionnaire.InstanciateWith(_jsonData); if (_Questionnaire != null) { m_lstQuestionnaireDialog.Add(_Questionnaire); _BindingData = _Questionnaire.Form.Settings.DataBindings; if (_BindingData != null) { if (!string.IsNullOrEmpty(_BindingData.questionlayout_id)) m_lstQuestionLayoutIds.Add(_BindingData.questionlayout_id); } } }); } #endregion int? _CampaignId = CampaignId; int? _AccountId = AccountId; int? _ContactId = SelectedContact == null || SelectedContact.id <= 0 ? (int?)null : SelectedContact.id; int? _DialogId = m_oDialog.id; /** * create dialog if not yet been initialized. * we only create dialog once, for the succeeding loads to be faster. */ if (m_BrightSalesProperty.CampaignBooking.Questionnaire.State == SelectionProperty.DialogEditorState.Empty) { this.CreateQuestionnaire(); m_BrightSalesProperty.CampaignBooking.Questionnaire.State = SelectionProperty.DialogEditorState.Loaded; } /** * get the list of answers. */ #region Code Logic var _lstAnswers = _efDbContext.FIGetDialogAnswers( string.Join(",", m_lstQuestionLayoutIds.Distinct().ToArray()), _CampaignId, _AccountId, _ContactId, _DialogId ).ToList().Clone(); IsInitializingDialogComponents = true; IsInitializedComponentsValid = false; List<int> _lstAnswerIds = new List<int>(); CTDialogAnswers _dlgAnswer = null; for (int i = 0; i < m_lstQuestionnaireDialog.Count; ++i) { _Questionnaire = m_lstQuestionnaireDialog[i]; _BindingData = _Questionnaire.Form.Settings.DataBindings; /** * if questionnaire is contact level and there are no contacts, * just by pass saving. */ if (!_BindingData.account_level && m_BrightSalesProperty.CampaignBooking.ContactCount < 1) continue; if (_BindingData.account_level) { _dlgAnswer = _lstAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && p.campaign_id == _CampaignId && p.account_id == _AccountId && p.account_level == true && p.dialog_id == _DialogId ); } else { _dlgAnswer = _lstAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && p.campaign_id == _CampaignId && p.account_id == _AccountId && p.contact_id == _ContactId && p.account_level == false && p.dialog_id == _DialogId ); } if (_dlgAnswer != null) { _BindingData.answer_id = _dlgAnswer.id.ToString(); _BindingData.account_level = _dlgAnswer.account_level; _BindingData.contact_id = _ContactId.ToString(); _lstAnswerIds.Add(_dlgAnswer.id); } else { m_HasMustSaveDefaultValues = true; _BindingData.language_code = "SE"; _BindingData.account_id = _AccountId.ToString(); _BindingData.campaign_id = _CampaignId.ToString(); _BindingData.contact_id = _ContactId.ToString(); _BindingData.dialog_id = _DialogId.ToString(); } _Questionnaire = null; } #endregion /** * assign eash answers to its respective dialog component. */ #region Code Logic int _DialogCount = 0; var _lstDialogAnswers = _efDbContext.answers.Include("sub_answers").Where(i => _lstAnswerIds.Contains(i.id)); IQuestionnaire _IQuestionnaire = null; foreach (BaseLayoutItem item in this.layoutControlGroupQuestionnaire.Items) { if (item.IsGroup) { if (item.Tag != null) { /** * initialize and set defaults. */ _IQuestionnaire = item.Tag as IQuestionnaire; _IQuestionnaire.IsInitializing = false; _IQuestionnaire.InQuestionnaire = false; _IQuestionnaire.DisableSelection = true; _IQuestionnaire.HasMustSaveDefaultValues = false; _IQuestionnaire.AccountId = 0; _IQuestionnaire.ContactId = 0; _IQuestionnaire.ContactPerson = null; _IQuestionnaire.UserId = 0; _IQuestionnaire.UserName = string.Empty; _IQuestionnaire.ContactList = new List<CTScSubCampaignContactList>(); /** * check if questionnaire exists. */ _Questionnaire = m_lstQuestionnaireDialog[_DialogCount]; _BindingData = _Questionnaire.Form.Settings.DataBindings; #region Code //if (_IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.account_level) { // _Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.account_level == true && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() // ); //} //else { // _Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.contact_id == _ContactId.ToString() && // i.Form.Settings.DataBindings.account_level == true && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() // ); //} //if (_BindingData.account_level) //{ // _dlgAnswer = _lstAnswers.FirstOrDefault(p => // p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && // p.campaign_id == _CampaignId && // p.account_id == _AccountId && // p.account_level == true && // p.dialog_id == _DialogId // ); //} //else //{ // _dlgAnswer = _lstAnswers.FirstOrDefault(p => // p.questionlayout_id == int.Parse(_BindingData.questionlayout_id) && // p.campaign_id == _CampaignId && // p.account_id == _AccountId && // p.contact_id == _ContactId && // p.account_level == false && // p.dialog_id == _DialogId // ); //} //_Questionnaire = m_lstQuestionnaireDialog.FirstOrDefault(i => // i.Form.Settings.DataBindings.questionlayout_id == _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings.questionlayout_id && // i.Form.Settings.DataBindings.campaign_id == _CampaignId.ToString() && // i.Form.Settings.DataBindings.account_id == _AccountId.ToString() && // i.Form.Settings.DataBindings.contact_id == _ContactId.ToString() && // i.Form.Settings.DataBindings.dialog_id == _DialogId.ToString() //); //if (_Questionnaire == null) { // _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; // _DialogCount++; // continue; //} //_BindingData = _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings; // = _IQuestionnaire.DefaultQuestionnaire.Form.Settings.DataBindings; //if (!_BindingData.account_level && (_ContactId == null || _ContactId == 0)) { //_BindingData = _Questionnaire.Form.Settings.DataBindings; #endregion if (!_BindingData.account_level && m_BrightSalesProperty.CampaignBooking.ContactCount < 1) { _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; _DialogCount++; continue; } _dlgAnswer = null; if (!string.IsNullOrEmpty(_BindingData.answer_id)) _dlgAnswer = _lstAnswers.FirstOrDefault(e => e.id == int.Parse(_BindingData.answer_id)); _IQuestionnaire.IsInitializing = true; _IQuestionnaire.InQuestionnaire = true; _IQuestionnaire.DisableSelection = true; _IQuestionnaire.HasMustSaveDefaultValues = false; _IQuestionnaire.AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId; _IQuestionnaire.ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId; _IQuestionnaire.ContactPerson = _ContactId == null ? null : (_ContactId > 0 ? SelectedContact : null); _IQuestionnaire.UserId = UserSession.CurrentUser.UserId; _IQuestionnaire.UserName = UserSession.CurrentUser.UserFullName; _IQuestionnaire.ContactList = m_BrightSalesProperty.CampaignBooking.ContactList; if (_IQuestionnaire.ControlGroup.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Never) _IQuestionnaire.ControlGroup.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; if (_dlgAnswer != null) { int _AnswerId = Convert.ToInt32(_BindingData.answer_id); var _AnswerData = _lstDialogAnswers.FirstOrDefault(i => i.id == _AnswerId); _IQuestionnaire.Questionnaire = BusinessAnswer.SetQuestionnaireData(_Questionnaire, _AnswerData); //_IQuestionnaire.Questionnaire = BusinessAnswer.SetQuestionnaireData(_IQuestionnaire.DefaultQuestionnaire, _AnswerData); } else { _IQuestionnaire.Questionnaire = _Questionnaire; // _IQuestionnaire.DefaultQuestionnaire; _IQuestionnaire.HasMustSaveDefaultValues = true; } _IQuestionnaire.Render(); if (_IQuestionnaire.ControlFooter != null && _dlgAnswer != null) _IQuestionnaire.ControlFooter.SetSourceTooltip(_dlgAnswer.source_contact, _dlgAnswer.source_last_modified_by, _dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); _IQuestionnaire.IsInitializing = false; _DialogCount++; } } } #endregion } this.SetEditableComponent(false); IsInitializedComponentsValid = this.ValidateDialog(false); IsInitializingDialogComponents = false; m_AnswerBindingOnProgress = false; if (bbiDialogStatus.EditValue != null) m_CurrentStatus = bbiDialogStatus.EditValue.ToString(); bbiEditDialog.Enabled = true; if (m_BrightSalesProperty.CommonProperty.CompanyLocked) bbiDeleteDialog.Enabled = false; }); }
void Update() { if (Input.GetKeyDown(KeyCode.LeftControl)) { setStateNone(); } if (state == conversationState.npcSpeaking && dialogType != dialog.greeting) { if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)) { skipText(); } } else //More text is set when the current line is finished printing, but there is more dialogue from the NPC waiting to be displayed upon pressing shift if (state == conversationState.moreText) { //Alibi and events witnessed go to more text after each time the NPC speaks, and wait for either continue or accuse if (dialogType == dialog.alibi || dialogType == dialog.eventsWitnessed) { if (Input.GetKeyDown(KeyCode.F)) { AccuseOfLying(); } if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { if (dialogueQueue.Count > 0) { displayText(dialogueQueue.Dequeue()); testimonyQueue.Dequeue(); Testimony testimony = testimonyQueue.Peek(); if (!testimony.truth && testimony.firstTimeTold) speakingNPC.stress += speakingNPC.stressIncrements; } else { dialogType = dialog.greeting; displayText("Can I help you with anything else?"); testimonyQueue.Clear(); state = conversationState.playerInput; } } } else if (dialogType == dialog.suspect || dialogType == dialog.accusation || dialogType == dialog.introduction) { if (dialogueQueue.Count > 0) { if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ) { displayText(dialogueQueue.Dequeue()); } } else { if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ) { dialogType = dialog.greeting; displayText("Can I help you with anything else?"); testimonyQueue.Clear(); state = conversationState.playerInput; } /* else if (Input.GetKeyDown(KeyCode.F)) { AccuseOfLying(); } */ } } else if (dialogType == dialog.lockedOut) { if (dialogueQueue.Count > 0) { if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { displayText(dialogueQueue.Dequeue()); } } else { if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { setStateNone(); } } } } //Player input is when the NPC has finished talking and the player uses the menu to respond to them else if (state == conversationState.playerInput) { if (Input.GetKeyDown("w") || Input.GetKey(KeyCode.UpArrow)) { selected = Math.Max(0, selected - 1); } else if (Input.GetKeyDown("s") || Input.GetKey(KeyCode.DownArrow)) { selected = Math.Min(responses.Count - 1, selected + 1); } if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { selectResponse(selected); } } }
public void callShowDialog(dialog d) { StartCoroutine(ShowDialog(d)); }
private void LoadDialog(CTSubCampaignDialogs subcampaignDialog) { isSaved = true; textEditDialogname.Text = subcampaignDialog.DialogName; lookUpEditCustomer.EditValue = subcampaignDialog.CustomerID; lookUpEditCampaign.EditValue = subcampaignDialog.CampaignID; lookUpEditSubCampaign.EditValue = subcampaignDialog.SubCampaignID; lookUpEditCustomer.Properties.ReadOnly = true; lookUpEditCampaign.Properties.ReadOnly = true; lookUpEditSubCampaign.Properties.ReadOnly = true; m_oDialog = BPContext.dialogs.FirstOrDefault(p => p.id == subcampaignDialog.DialogID); var CQList = new List<CampaignQuestionnaire>(); var QLIDs = new List<int>(); int qlid; if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json)) { var jaDiag = JArray.Parse(m_oDialog.dialog_text_json); CampaignQuestionnaire CQ = null; jaDiag.ForEach(delegate(JToken jt) { /** * https://brightvision.jira.com/browse/PLATFORM-3057 * fixed json text for unwanted characters */ string _json = ValidationUtility.StripJsonInvalidChars(JsonConvert.ToString(jt.ToString(Formatting.None)).Unescape()); //CQ = CampaignQuestionnaire.InstanciateWith(jt.ToString(Formatting.None).Unescape()); CQ = CampaignQuestionnaire.InstanciateWith(_json); if (CQ != null) { if (CQ.Type.ToLower() == QuestionTypeConstants.Schedule) btnCreateSchedule.Enabled = true; if (int.TryParse(CQ.Form.Settings.DataBindings.questionlayout_id, out qlid)) QLIDs.Add(qlid); CQList.Add(CQ); } }); } if (CQList.Count <= 0) { simpleButtonAssignAnswerForm.Enabled = false; return; } DataTable dtDialog = gridControlDialog.DataSource as DataTable; int qid, qtlid; var answerform = (from bp in BPContext.questionlayouts.Include("questionlayout_language") where QLIDs.Contains(bp.id) select bp).ToList(); questionlayout questionLayout = null; questionlayout_language questionLayoutLanguage = null; CTQuestionTags questiontags = null; DataRow newDr = null; var datasource = gridControlQuestions.DataSource as List<CTQuestionTags>; CQList.ForEach(delegate(CampaignQuestionnaire dcq) { if (int.TryParse(dcq.Form.Settings.DataBindings.question_id, out qid) && int.TryParse(dcq.Form.Settings.DataBindings.questions_text_language_id, out qtlid) && int.TryParse(dcq.Form.Settings.DataBindings.questionlayout_id, out qlid)) { questionLayout = answerform.FirstOrDefault(p => p.questions_id == qid && p.id == qlid); if (questionLayout != null) { questionLayoutLanguage = questionLayout.questionlayout_language.FirstOrDefault(p => p.questionlayout_id == questionLayout.id); if(questionLayoutLanguage != null) questiontags = datasource.FirstOrDefault(x => x.question_id == qid && x.question_text_language_id == qtlid); } } if (questiontags != null) { int rowcount = 0; if (dtDialog != null) { //DataRow[] drs = dtDialog.Select("question_text='" + row.question_text + "'"); //if (drs.Length > 0) { // MessageBox.Show("The selected question has already been added to the dialog list.", "Information"); // return; //} else { DataRow[] last = dtDialog.Select("position = Max(position)"); if (last.Length > 0) { rowcount = Convert.ToInt32(last[0].ItemArray[0]); } //} } newDr = dtDialog.NewRow(); newDr["position"] = rowcount + 1; newDr["question_text"] = questiontags.question_text; newDr["question_id"] = questiontags.question_id; newDr["question_text_language_id"] = questiontags.question_text_language_id; newDr["question_help_text"] = questiontags.question_help_text; newDr["question_description"] = questiontags.question_description; newDr["language_code"] = questiontags.language_code; if (questionLayout != null) { newDr["answer_form"] = questionLayout.title; newDr["answer_form_id"] = questionLayout.id; newDr["answer_form_language_id"] = questionLayoutLanguage.id; newDr["content_json"] = questionLayout.content_json; newDr["account_level"] = questionLayout.account_level; } dtDialog.Rows.Add(newDr); dtDialog.AcceptChanges(); simpleButtonAssignAnswerForm.Enabled = true; } }); //show dialog preview simpleButtonShowDialog_Click(null, null); }
void NPCGreeting(Npc npc) { if (npc.lieAccusations > 0) { dialogType = dialog.greeting; displayText("Good evening detective"); } else { dialogType = dialog.lockedOut; displayText("I have nothing more to say to you."); } }
//Collects all the omitted truths from the NPCs memory, and randomly selects one of them void AccuseOfOmission() { dialogType = dialog.accusation; List<EventTestimony> omissions = new List<EventTestimony>(); foreach (KeyValuePair<Event, EventTestimony> entry in speakingNPC.testimonies) { if (entry.Value.omitted) { omissions.Add(entry.Value); } } if (omissions.Count == 0) { if (speakingNPC.testimonies.Count == 0) displayText("But detective, I haven't even given you my testimony yet."); else { speakingNPC.lieAccusations--; displayText("How dare you make such wild accusations. Have you any proof?"); if (speakingNPC.lieAccusations <= 0) lockedOut(); } } else { int r = UnityEngine.Random.Range(0, omissions.Count); speakingNPC.stress = Mathf.Min(speakingNPC.stress + speakingNPC.stressIncrements, 1.0f); displayText("...Yes, there is something I still need to tell you."); revealOmission(omissions[r]); } }
void examineBody(Npc npc) { dialogType = dialog.corpse; displayText(npc.getFullName() + "'s lifeless body lies before you"); }
private void simpleButtonSaveDialog_Click(object sender, EventArgs e) { if (!dxValidationProvider1.Validate()) return; Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; GridView view = gridViewDialog; if (view == null || view.RowCount == 0) return; DataRow row; CampaignQuestionnaire oQuestionnaire = null; JArray jaDiag = new JArray(); JObject joDiag = null; for (int i = 0; i < view.RowCount; i++) { row = view.GetDataRow(i); if (row["content_json"] == null || string.IsNullOrEmpty(row["content_json"].ToString())) continue; oQuestionnaire = CampaignQuestionnaire.InstanciateWith(row["content_json"].ToString()); if (oQuestionnaire == null) continue; if (row["question_text"] != null) oQuestionnaire.Form.Settings.QuestionText = row["question_text"].ToString(); if (row["question_help_text"] != null) oQuestionnaire.Form.Settings.QuestionHelp = row["question_help_text"].ToString(); if (row["question_id"] != null) oQuestionnaire.Form.Settings.DataBindings.question_id = row["question_id"].ToString(); if (row["question_text_language_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questions_text_language_id = row["question_text_language_id"].ToString(); if (row["answer_form_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questionlayout_id = row["answer_form_id"].ToString(); if (row["answer_form_language_id"] != null) oQuestionnaire.Form.Settings.DataBindings.questionlayout_id = row["answer_form_language_id"].ToString(); joDiag = JObject.Parse(oQuestionnaire.ToJSONString()); jaDiag.Add(joDiag); } string dialog_text_json = jaDiag.ToString(Formatting.None); if (!isSaved) { m_oDialog = new dialog(); } else { if (m_oDialog == null) { if (SubCampaignDialog != null && SubCampaignDialog.DialogID > 0) { m_oDialog = BPContext.dialogs.FirstOrDefault(q => q.id == SubCampaignDialog.DialogID); } } } m_oDialog.subcampaign_id = Convert.ToInt32(lookUpEditSource.EditValue); m_oDialog.name = textEditDialogname.Text.Trim(); m_oDialog.dialog_text_json = dialog_text_json; m_oDialog.created_date = DateTime.Now; if (!isSaved) { BPContext.dialogs.AddObject(m_oDialog); isSaved = true; } BPContext.SaveChanges(); if (SubCampaignDialog == null) { SubCampaignDialog = new CTSubCampaignDialogs() { DialogID = m_oDialog.id, DateCreated = m_oDialog.created_date, DialogName = m_oDialog.name, SubCampaignID = m_oDialog.subcampaign_id, SubCampaignTitle = m_oDialog.subcampaign.title }; } Cursor.Current = currentCursor; MessageBox.Show("Dialog has been saved.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//Todo - Make ALL these events into testimonies so they can be lied about void NPCWitnessed(List<Event> events = null, bool tellTruth = false, bool dontDisplay = false) { if (!dontDisplay) dialogType = dialog.eventsWitnessed; if (events == null) events = Timeline.EventsWitnessedDuringTimeframe(speakingNPC, Timeline.murderEvent.time - (pg.timeOfDeathLeeway), Timeline.murderEvent.time + (pg.timeOfDeathLeeway)); if (events.Count == 0) displayText("I haven't seen anything unusual"); else { for (int i = 0; i < events.Count; i++) { if (events[i] is SwitchRooms) { EventTestimony t; if (!speakingNPC.testimonies.TryGetValue(events[i], out t) || tellTruth) { if (tellTruth) t = TestimonyManager.getTrueEventTestimony(speakingNPC, events[i]); else t = TestimonyManager.createTestimony(speakingNPC, events[i]); speakingNPC.addTestimony(t, events[i]); } else t.firstTimeTold = false; testimonyQueue.Enqueue(t); if (!t.omitted) { SwitchRooms e = events[i] as SwitchRooms; dialogueQueue.Enqueue(String.Format("At {0} I saw {1} move into the {2}", Timeline.convertTime(events[i].time), e.npc.getFullName(), e.newRoom.roomName)); } } else if (events[i] is FoundBody) { EventTestimony t; if (!speakingNPC.testimonies.TryGetValue(events[i], out t) || tellTruth) { if (tellTruth) t = TestimonyManager.getTrueEventTestimony(speakingNPC, events[i]); else t = TestimonyManager.createTestimony(speakingNPC, events[i]); speakingNPC.addTestimony(t, events[i]); } else t.firstTimeTold = false; testimonyQueue.Enqueue(t); if (!t.omitted) { FoundBody e = events[i] as FoundBody; dialogueQueue.Enqueue(String.Format("At {0} I found {1}'s body here", Timeline.convertTime(events[i].time), pg.victim.firstname)); } } else if (events[i] is Murder) { EventTestimony t; if (!speakingNPC.testimonies.TryGetValue(events[i], out t) || tellTruth) { if (tellTruth) t = TestimonyManager.getTrueEventTestimony(speakingNPC, events[i]); else t = TestimonyManager.createTestimony(speakingNPC, events[i]); speakingNPC.addTestimony(t, events[i]); } else t.firstTimeTold = false; testimonyQueue.Enqueue(t); if (!t.omitted) { Murder e = events[i] as Murder; dialogueQueue.Enqueue(String.Format("At {0} I saw {1} murder {2} in the {3}! I swear it's true!", Timeline.convertTime(events[i].time), e.npc.getFullName(), e.npc2.getFullName(), e.room.roomName)); } } else if (events[i] is PickupItem) { EventTestimony t; if (!speakingNPC.testimonies.TryGetValue(events[i], out t) || tellTruth) { if (tellTruth) t = TestimonyManager.getTrueEventTestimony(speakingNPC, events[i]); else t = TestimonyManager.createTestimony(speakingNPC, events[i]); speakingNPC.addTestimony(t, events[i]); } else t.firstTimeTold = false; testimonyQueue.Enqueue(t); if (!t.omitted) { PickupItem e = t.e as PickupItem; dialogueQueue.Enqueue(String.Format("At {0} I saw {1} pick up something in the {2}", Timeline.convertTime(e.time), e.npc.getFullName(), e.room.roomName)); } } else if (events[i] is DropItem) { EventTestimony t; if (!speakingNPC.testimonies.TryGetValue(events[i], out t) || tellTruth) { if (tellTruth) t = TestimonyManager.getTrueEventTestimony(speakingNPC, events[i]); else t = TestimonyManager.createTestimony(speakingNPC, events[i]); speakingNPC.addTestimony(t, events[i]); } else t.firstTimeTold = false; testimonyQueue.Enqueue(t); //Todo - Particularly shrewd NPCs have a chance of knowing what the item was if (!t.omitted) { DropItem e = t.e as DropItem; dialogueQueue.Enqueue(String.Format("At {0} I saw {1} put something away in the {3}", Timeline.convertTime(e.time), e.npc.getFullName(), e.item.name, e.room.roomName)); } } } if (!dontDisplay) displayText(dialogueQueue.Dequeue()); } }
private void simpleButtonSave_Click(object sender, EventArgs e) { if (m_oDialog == null) return; if (!dxValidationProvider1.Validate()) return; if (ObjectDialog.Exists(textEditDialogname.Text, (int)lookUpEditSubcampaigns.EditValue)) { MessageBox.Show("Dialog already exist for sub-campaign " + lookUpEditSubcampaigns.Text.ToUpper(), "Dialogs", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; string dialog_text_json = string.Empty; dialog oDialog = new dialog(); oDialog.is_active = true; oDialog.name = textEditDialogname.Text; oDialog.subcampaign_id = Convert.ToInt32(lookUpEditSubcampaigns.EditValue); oDialog.created_date = DateTime.Now; oDialog.dialog_text_json = m_oDialog.dialog_text_json; BPContext.dialogs.AddObject(oDialog); BPContext.SaveChanges(); ParentController.DefaultSelectedDialogId = oDialog.id; Cursor.Current = currentCursor; if (ParentForm != null) { ParentForm.DialogResult = DialogResult.OK; if (ParentForm.Owner != null) ParentForm.Owner.DialogResult = DialogResult.OK; } }
void setStateNone() { state = conversationState.none; dialogType = dialog.none; testimonyQueue.Clear(); dialogueQueue.Clear(); selected = 0; shownString = ""; fullString = ""; }
void accuseOfMurder() { dialogType = dialog.murderAccusation; displayText(String.Format("(Are you sure you want to accuse this person of the murder? This will end the game)")); }
void NPCAlibi() { dialogType = dialog.alibi; List<Event> events = Timeline.locationDuringTimeframe(speakingNPC, Timeline.murderEvent.time - (pg.timeOfDeathLeeway), Timeline.murderEvent.time + (pg.timeOfDeathLeeway)); if (events.Count == 0) { displayText("I've been here the whole evening."); } else { foreach (SwitchRooms e in events) { EventTestimony t; if (speakingNPC.testimonies.TryGetValue(e, out t)) { t.firstTimeTold = false; testimonyQueue.Enqueue(t); } else { t = TestimonyManager.createTestimony(speakingNPC, e); speakingNPC.addTestimony(t, e); testimonyQueue.Enqueue(t); } SwitchRooms switchrooms = t.e as SwitchRooms; string s = String.Format("At {0} I moved to the {1}", Timeline.convertTime(switchrooms.time), switchrooms.newRoom.roomName); List<Npc> peopleInNewRoom = switchrooms.peopleInNewRoom; if (peopleInNewRoom.Count > 0) { if (peopleInNewRoom.Count == 1) { string npcEncounters = String.Format(", {0} was there too.", peopleInNewRoom[0].firstname); s += npcEncounters; } else if (peopleInNewRoom.Count == 2) { s += String.Format(", {0} and {1} were there too.", peopleInNewRoom[0].firstname, peopleInNewRoom[1].firstname); } else { s += ". "; for (int i = 0; i < peopleInNewRoom.Count; i++) { if (i < peopleInNewRoom.Count - 1) { s += String.Format("{0}, ", peopleInNewRoom[i].firstname); } else { s += String.Format("and {0} were there too.", peopleInNewRoom[i].firstname); } } } } dialogueQueue.Enqueue(s); } speakingNPC.timeBuffer = 0; //reset the timebuffer so the lies don't get further and further from the truth displayText(dialogueQueue.Dequeue()); } }
public void ___LoadDialogQuestionnaires() { m_AnswerBindingOnProgress = true; m_HasMustSaveDefaultValues = false; this.ResetToDefaultState(); this.BindDialogManagerData(); using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) { m_oDialog = _efDbContext.dialogs.FirstOrDefault(i => i.subcampaign_id == SubCampaignId && i.is_active == true); if (m_oDialog == null) { bbiEditDialog.Enabled = false; NotificationDialog.Warning("Bright Sales", "There is no current dialog created for this customer's subcampaign."); return; } _efDbContext.Detach(m_oDialog); /** * Populate each JSON questionnaire from dialog text to list object type. */ #region Code Logic var CQList = new List<CampaignQuestionnaire>(); CampaignQuestionnaire oQuestionnaire = null; List<string> cbdList = new List<string>(); DataBindings oBindings = null; if (!string.IsNullOrEmpty(m_oDialog.dialog_text_json)) { var jaDiag = JArray.Parse(m_oDialog.dialog_text_json); jaDiag.ForEach(delegate(JToken jt) { /** * [@jeff 06.08.2012]: https://brightvision.jira.com/browse/PLATFORM-1467 * added json converter to convert raw json to string, before unescaping. */ string _jsonData = ValidationUtility.StripJsonInvalidChars(JsonConvert.ToString(jt.ToString(Formatting.None)).Unescape()); oQuestionnaire = CampaignQuestionnaire.InstanciateWith(_jsonData); if (oQuestionnaire != null) { CQList.Add(oQuestionnaire); oBindings = oQuestionnaire.Form.Settings.DataBindings; if (oBindings != null) { if (!string.IsNullOrEmpty(oBindings.questionlayout_id)) cbdList.Add(oBindings.questionlayout_id); } } }); } #endregion /** * Populate Answers to each questionnaire. */ #region Code Logic int? campaign_id = CampaignId; int? account_id = AccountId; int? contact_id = SelectedContact == null || SelectedContact.id <= 0 ? (int?)null : SelectedContact.id; int? dialog_id = m_oDialog.id; List<int> answerIdList = new List<int>(); //get all dialog answers based on questionlayout_ids and other params var listDialogAnswers = _efDbContext.FIGetDialogAnswers( string.Join(",", cbdList.Distinct().ToArray()), campaign_id, account_id, contact_id, dialog_id ).ToList().Clone(); /* * DAN: FIX for issue: * https://brightvision.jira.com/browse/PLATFORM-2948 * https://brightvision.jira.com/browse/PLATFORM-2952 */ //------------------------------------------------------------------------------------------------ ((System.ComponentModel.ISupportInitialize)(this.groupControlDialog)).BeginInit(); this.groupControlDialog.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlDialog)).BeginInit(); this.layoutControlDialog.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pnlDialogControls)).BeginInit(); this.pnlDialogControls.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlMain)).BeginInit(); this.layoutControlMain.SuspendLayout(); this.SuspendLayout(); //------------------------------------------------------------------------------------------------ //layoutControlGroupQuestionnaire.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; //this.layoutControlQuestionnaire.Visible = false; int rowcount = CQList.Count; IsInitializingDialogComponents = true; IsInitializedComponentsValid = false; var a = from oquestion in CQList select oquestion.Form.Settings.DataBindings; CTDialogAnswers dlgAnswer = null; for (int i = 0; i < rowcount; ++i) { oQuestionnaire = CQList[i]; oBindings = oQuestionnaire.Form.Settings.DataBindings; if (oBindings.account_level) { dlgAnswer = listDialogAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(oBindings.questionlayout_id) && p.campaign_id == campaign_id && p.account_id == account_id && (p.account_level == true) && p.dialog_id == dialog_id); } else { dlgAnswer = listDialogAnswers.FirstOrDefault(p => p.questionlayout_id == int.Parse(oBindings.questionlayout_id) && p.campaign_id == campaign_id && p.account_id == account_id && (p.contact_id == contact_id && p.account_level == false) && p.dialog_id == dialog_id); } if (dlgAnswer != null) { oBindings.answer_id = dlgAnswer.id.ToString(); oBindings.account_level = dlgAnswer.account_level; oBindings.contact_id = contact_id.ToString(); answerIdList.Add(dlgAnswer.id); } else { m_HasMustSaveDefaultValues = true; oBindings.language_code = "SE"; oBindings.account_id = account_id.ToString(); oBindings.campaign_id = campaign_id.ToString(); oBindings.contact_id = contact_id.ToString(); oBindings.dialog_id = dialog_id.ToString(); } } //BPContext = new BrightPlatformEntities(UserSession.EntityConnection); var oQuestionsAnswers = _efDbContext.answers.Include("sub_answers").Where(ans => answerIdList.Contains(ans.id)); //if (oQuestionsAnswers != null) // _efDbContext.Detach(oQuestionsAnswers); for (int i = 0; i < rowcount; ++i) { oQuestionnaire = CQList[i]; oBindings = oQuestionnaire.Form.Settings.DataBindings; if (!oBindings.account_level && (contact_id == null || contact_id == 0)) continue; dlgAnswer = null; if (oBindings.answer_id != null) if (oBindings.answer_id.Length > 0) dlgAnswer = listDialogAnswers.FirstOrDefault(an => an.id == int.Parse(oBindings.answer_id)); switch (oQuestionnaire.Type.ToLower()) { #region Drop Box case QuestionTypeConstants.Dropbox: { Dropbox oDropbox = new Dropbox(this.layoutControlQuestionnaire) { ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId, DisableSelection = true, ToolTipController = defaultToolTipController1, IsInitializing = true, HasMustSaveDefaultValues = false, AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId }; if (dlgAnswer != null) { int ansnwerID = int.Parse(oBindings.answer_id.ToString()); var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID); oDropbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer); } else { oDropbox.Questionnaire = oQuestionnaire; oDropbox.HasMustSaveDefaultValues = true; } oDropbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged); oDropbox.BindControls(); if (oDropbox.ControlFooter != null && dlgAnswer != null) oDropbox.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); this.layoutControlGroupQuestionnaire.Add(oDropbox.ControlGroup); controlsInDialog.Add(oDropbox); oDropbox.IsInitializing = false; break; } #endregion #region Multiple Choice case QuestionTypeConstants.MultipleChoice: { Multiplechoice oMultipleChoice = new Multiplechoice(this.layoutControlQuestionnaire) { ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId, DisableSelection = true, ToolTipController = defaultToolTipController1, IsInitializing = true, HasMustSaveDefaultValues = false, AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId }; if (dlgAnswer != null) { int ansnwerID = int.Parse(oBindings.answer_id.ToString()); var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID); oMultipleChoice.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer); } else { oMultipleChoice.Questionnaire = oQuestionnaire; oMultipleChoice.HasMustSaveDefaultValues = true; } oMultipleChoice.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged); oMultipleChoice.BindControls(); if (oMultipleChoice.ControlFooter != null && dlgAnswer != null) oMultipleChoice.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); this.layoutControlGroupQuestionnaire.Add(oMultipleChoice.ControlGroup); controlsInDialog.Add(oMultipleChoice); oMultipleChoice.IsInitializing = false; break; } #endregion #region Text Box case QuestionTypeConstants.Textbox: { Textbox oTextbox = new Textbox(this.layoutControlQuestionnaire) { ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId, DisableSelection = true, ToolTipController = defaultToolTipController1, IsInitializing = true, HasMustSaveDefaultValues = false, AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId }; if (dlgAnswer != null) { int ansnwerID = int.Parse(oBindings.answer_id.ToString()); var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID); oTextbox.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer); } else { oTextbox.Questionnaire = oQuestionnaire; oTextbox.HasMustSaveDefaultValues = true; } oTextbox.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged); oTextbox.BindControls(); if (oTextbox.ControlFooter != null && dlgAnswer != null) oTextbox.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); this.layoutControlGroupQuestionnaire.Add(oTextbox.ControlGroup); controlsInDialog.Add(oTextbox); oTextbox.IsInitializing = false; break; } #endregion #region Schedule case QuestionTypeConstants.Schedule: { Schedule oSchedule = new Schedule(this.layoutControlQuestionnaire) { ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId, IsInitializing = true, HasMustSaveDefaultValues = false, AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId }; var result = SubCampaignContactList; if (result != null) oSchedule.ContactList = result; oSchedule.SubcampaignID = SubCampaignId; oSchedule.DisableSelection = true; oSchedule.ToolTipController = defaultToolTipController1; if (SelectedContact != null) oSchedule.SetCurrentCaller(SelectedContact, AccountId); if (dlgAnswer != null) { int ansnwerID = int.Parse(oBindings.answer_id.ToString()); var answer = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID); oSchedule.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answer); } else { oSchedule.Questionnaire = oQuestionnaire; oSchedule.HasMustSaveDefaultValues = true; } oSchedule.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged); oSchedule.BindControls(); if (oSchedule.ControlFooter != null && dlgAnswer != null) oSchedule.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); oSchedule.ShowCalendarBookingClick += new EventHandler(oSchedule_ShowCalendarBookingClick); this.layoutControlGroupQuestionnaire.Add(oSchedule.ControlGroup); controlsInDialog.Add(oSchedule); oSchedule.IsInitializing = false; break; } #endregion #region Smart Text case QuestionTypeConstants.SmartText: { SmartText oSmartText = new SmartText(this.layoutControlQuestionnaire) { ContactId = m_BrightSalesProperty.CommonProperty.CurrentWorkedContactId, DisableSelection = true, ToolTipController = defaultToolTipController1, IsInitializing = true, HasMustSaveDefaultValues = false, AccountId = m_BrightSalesProperty.CommonProperty.CurrentWorkedAccountId }; if (dlgAnswer != null) { int ansnwerID = int.Parse(oBindings.answer_id.ToString()); var answerD = oQuestionsAnswers.FirstOrDefault(oa => oa.id == ansnwerID); oSmartText.Questionnaire = BusinessAnswer.BindAnswer(oQuestionnaire, answerD); } else { oSmartText.Questionnaire = oQuestionnaire; oSmartText.HasMustSaveDefaultValues = true; } oSmartText.UserId = UserSession.CurrentUser.UserId; oSmartText.UserName = UserSession.CurrentUser.UserFullName; /** * [jeff 05.16.2012]: https://brightvision.jira.com/browse/PLATFORM-1413 * added checking for null selected contact. */ if (SelectedContact == null) oSmartText.ContactName = ""; else oSmartText.ContactName = SelectedContact.first_name + ", " + SelectedContact.last_name; if (UserSession.CurrentUser.IsSubCampaignManager || UserSession.CurrentUser.IsCampaignOwner) oSmartText.CanEditAllRows = true; else oSmartText.CanEditAllRows = false; oSmartText.OnComponentNotifyChanged += new ComponentDialogNotifyChangedEventHandler(oComponents_OnComponentNotifyChanged); oSmartText.BindControls(); oSmartText.BindPropertyGrid(); if (oSmartText.ControlFooter != null && dlgAnswer != null) oSmartText.ControlFooter.SetSourceTooltip(dlgAnswer.source_contact, dlgAnswer.source_last_modified_by, dlgAnswer.source_last_modified_on.Value.ToString("yyyy-MM-dd")); this.layoutControlGroupQuestionnaire.Add(oSmartText.ControlGroup); controlsInDialog.Add(oSmartText); oSmartText.IsInitializing = false; break; } #endregion } } #endregion } EmptySpaceItem emptySpaceItem1 = new EmptySpaceItem(); emptySpaceItem1.CustomizationFormText = "emptySpaceItemBottom"; emptySpaceItem1.Name = "emptySpaceItemBottom"; emptySpaceItem1.ShowInCustomizationForm = false; emptySpaceItem1.Size = new System.Drawing.Size(0, 0); emptySpaceItem1.Text = "emptySpaceItemBottom"; emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0); this.layoutControlGroupQuestionnaire.AddItem(emptySpaceItem1); /* * DAN: FIX for issue: * https://brightvision.jira.com/browse/PLATFORM-2948 * https://brightvision.jira.com/browse/PLATFORM-2952 */ //------------------------------------------------------------------------------------------------ ((System.ComponentModel.ISupportInitialize)(this.groupControlDialog)).EndInit(); this.groupControlDialog.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.layoutControlDialog)).EndInit(); this.layoutControlDialog.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pnlDialogControls)).EndInit(); this.pnlDialogControls.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.layoutControlMain)).EndInit(); this.layoutControlMain.ResumeLayout(false); this.ResumeLayout(false); //------------------------------------------------------------------------------------------------ this.SetEditableComponent(false); IsInitializedComponentsValid = this.ValidateDialog(false); //this.layoutControlGroupQuestionnaire.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; //this.layoutControlQuestionnaire.BestFit(); //this.layoutControlQuestionnaire.Visible = true; //this.layoutControlQuestionnaire.Update(); //this.layoutControlQuestionnaire.Size = new Size(this.layoutControlQuestionnaire.Size.Width + 1, this.layoutControlQuestionnaire.Size.Height); IsInitializingDialogComponents = false; m_AnswerBindingOnProgress = false; if (bbiDialogStatus.EditValue != null) m_CurrentStatus = bbiDialogStatus.EditValue.ToString(); bbiEditDialog.Enabled = true; if (m_BrightSalesProperty.CommonProperty.CompanyLocked) bbiDeleteDialog.Enabled = false; }
public void setDialog(string _name, dialog[] _input) { sName = _name; conversation = _input; }