/// <summary> /// Cargar datos del comboBox de sonido en interfaz. /// </summary> protected SoundFileModel loadDataCellSoundFile(SoundFileModel soundFile, String soundFilePath) { //string soundDir = BaseUtils.validateEntriesUtils.getMyDocumentsPath() + "\\" + Properties.Settings.Default.soundFolderName + "\\" + Properties.Settings.Default.generalSounds; string soundDir = BaseUtils.validateEntriesUtils.getMyDocumentsPath() + "\\" + Properties.Settings.Default.soundFolderName + "\\" + soundFilePath; SoundFileModel soundFileRef = null; if (Dialog.SelectSoundFile("Tonos disponibles", "Seleccione el tono:", soundFile, ref soundFileRef, soundDir) == DialogResult.OK) { soundFile = soundFileRef; } return(soundFile); }
/// <summary> /// Cargar datos del comboBox de sonido en interfaz. /// </summary> protected SoundFileModel loadDataCellSoundFile(SoundFileModel soundFile) { return(loadDataCellSoundFile(soundFile, Properties.Settings.Default.horarySounds)); }
static public DialogResult SelectSoundFile(string title, string promptText, SoundFileModel soundFile, ref SoundFileModel soundFileRef, string soundDir) { Form form = new Form(); Label label = new Label(); ComboBox comboBox = new ComboBox(); Button buttonOk = new Button(); Button buttonCancel = new Button(); PictureBox pictureBox = new PictureBox(); form.Text = title; label.Text = promptText; try { List <SoundFileModel> soundFileList = new List <SoundFileModel>(); DirectoryInfo dirInfo = new DirectoryInfo(soundDir); dirInfo.GetFiles().ForEach(f => { SoundFileModel soundFileModel = new SoundFileModel(); soundFileModel.name = ((FileInfo)f).Name; soundFileModel.targetPath = ((FileInfo)f).FullName; soundFileList.Add(soundFileModel); }); comboBox.DataSource = soundFileList; comboBox.DropDownStyle = ComboBoxStyle.DropDownList; form.Shown += (s, e) => { if (soundFile != null) { SoundFileModel selectedItem = soundFileList.Find(sf => sf.name.Equals(soundFile.name)); if (selectedItem != null) { comboBox.SelectedItem = selectedItem; } } }; } catch (Exception er) { BaseUtils.log.Error(er); } buttonOk.Text = "OK"; buttonCancel.Text = "Cancel"; buttonOk.DialogResult = DialogResult.OK; buttonCancel.DialogResult = DialogResult.Cancel; label.SetBounds(9, 20, 372, 13); comboBox.SetBounds(12, 36, 372, 20); buttonOk.SetBounds(228, 72, 75, 23); buttonCancel.SetBounds(309, 72, 75, 23); label.AutoSize = true; comboBox.Anchor = comboBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, comboBox, buttonOk, buttonCancel }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.None; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.AcceptButton = buttonOk; form.CancelButton = buttonCancel; DialogResult dialogResult = form.ShowDialog(); soundFileRef = (SoundFileModel)comboBox.SelectedValue; return(dialogResult); }
static void Main() { MainController.log.Info("App started!"); Boolean run = true; if (!run) { //crear archivo JSON ValidateEntriesUtils validateEntriesUtils = new ValidateEntriesUtils(); AutomaticRingSystemModel automaticRingSystem = new AutomaticRingSystemModel(); automaticRingSystem.registrationRequired = true; automaticRingSystem.domainHost = "100.50.40.3"; automaticRingSystem.domainPort = 5060; for (int i = 0; i < 1; i++) { ConnectionCallServerModel connectionCallServer = new ConnectionCallServerModel(); connectionCallServer.displayName = "1230"; connectionCallServer.userName = "******"; connectionCallServer.registerName = "1230"; connectionCallServer.registerPassword = "******"; HoraryModel horary = new HoraryModel("h" + i, connectionCallServer); for (int a = 0; a < 2; a++) { int s = i + a; String sec = s < 10 ? "0" : "" + s; SoundFileModel soundFile = new SoundFileModel(); String filename = "helloworld" + a + ".mp3"; soundFile.name = filename; soundFile.targetPath = validateEntriesUtils.getMyDocumentsPath() + "\\" + Properties.Settings.Default.soundFolderName + "\\" + Properties.Settings.Default.horarySounds + "\\" + filename; CallServerModel callServer = new CallServerModel(a + 1, "23:54:" + sec, 5, soundFile, true, "1300", "llamada " + a); horary.callServerList.Add(callServer); } automaticRingSystem.horaryList.Add(horary); } string outputJSON = JsonConvert.SerializeObject(automaticRingSystem); String jsonFileFullPath = validateEntriesUtils.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonFileName + Properties.Settings.Default.jsonExtension; File.WriteAllText(jsonFileFullPath, outputJSON); try { MainController.cypherUtils.FileEncrypt(jsonFileFullPath, Properties.Settings.Default.cypherPassword); System.IO.File.Delete(jsonFileFullPath); } catch (Exception e) { MainController.log.Error("Intentando guardar archivo json", e); } //crear archivo JSON FIN } if (run) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } catch (Exception e) { BaseUtils.log.Error(e); } } }