public static string Show(string title, string message) { var dialog = new InputBoxDialog(title, message); if (dialog.ShowDialog() == DialogResult.OK) { return dialog.Result; } return null; }
public static string InputBox(string prompt, string title, string defaultValue) { var ib = new InputBoxDialog {FormPrompt = prompt, FormCaption = title, DefaultValue = defaultValue}; ib.ShowDialog(); ib.Close(); return ib.InputResponse; }
public static string InputBox(string prompt, string title) { InputBoxDialog ib = new InputBoxDialog(prompt,title); ib.ShowDialog(); string s = ib.InputResponse; ib.Close(); return s; }
public static bool ShowDialog(string prompt, string title, string defaultValue = null, int? xPos = null, int? yPos = null, bool password = true) { InputBoxDialog form = new InputBoxDialog(prompt, title, defaultValue, xPos, yPos, password); DialogResult result = form.ShowDialog(); if (result == DialogResult.Cancel) return false; else return form.Value.Equals("motion"); }
///// <summary> ///// Replacement for VB InputBox, returns user input string. Requires InputBoxDialog.cs ///// </summary> ///// <param name="prompt"></param> ///// <param name="title"></param> ///// <param name="defaultValue"></param> ///// <returns></returns> public static string InputBox(string prompt, string title, string defaultValue) { InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = prompt; ib.FormCaption = title; ib.DefaultValue = defaultValue; ib.ShowDialog(); string s = ib.InputResponse; ib.Close(); return s; }
static public string Show(string Prompt, string Title, string Default, int xPos, int yPos) { if (Title == null) Title = Application.ProductName; InputBoxDialog dlg = new InputBoxDialog(Prompt, Title, xPos, yPos); if (Default != null) dlg.txtInput.Text = Default; DialogResult result = dlg.ShowDialog(); if (result == DialogResult.Cancel) return null; else return dlg.txtInput.Text; }
/// <summary> /// Verifica la contraseña del perfil para tener acceso a la información /// </summary> private void AccessProfile(string Profile) { string pwdProfile = string.Empty; if (ucProfileSearch.star1Info.Count > 0) { if (!(!string.IsNullOrEmpty(Login.ProfileAllAccess) && Login.ProfileAllAccess.Equals("A"))) { foreach (Star1stLevelInfo line in ucProfileSearch.star1Info) { if (line.Type.Equals(Resources.Profiles.Constants.LINE_TYPE_N) && line.Text.Contains(Resources.Profiles.Constants.PWD_ID)) { string[] password = line.Text.Split(new char[] { '*' }); pwdProfile = password[1]; break; } } } if (!string.IsNullOrEmpty(pwdProfile)) { InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = Resources.Profiles.Constants.INTRODUCE_PASSWORD; ib.FormCaption = string.Concat(Resources.Profiles.Constants.MODAL_PWD_TITLE, " ", Profile); ib.DefaultValue = string.Empty; ib.ModeToShow = InputBoxDialog.ModeTextBox.Password; ib.ShowDialog(); string s = ib.InputResponse.ToUpper(); ib.Close(); if (s.Equals(pwdProfile)) { frmProfiles._ucProfileSearch = null; LoaderProfiles.AddToPanel(LoaderProfiles.Zone.Modal_Profile, this, Resources.Profiles.Constants.UC_PROFILE_INFO_DISPLAY); } else { MessageBox.Show(Resources.Profiles.Constants.PASSWORD_ERROR, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { frmProfiles._ucProfileSearch = null; LoaderProfiles.AddToPanel(LoaderProfiles.Zone.Modal_Profile, this, Resources.Profiles.Constants.UC_PROFILE_INFO_DISPLAY); } } }
private void pbEdit_Click(object sender, EventArgs e) { InputBoxDialog updateMeanDialog = new InputBoxDialog(InputBoxTitle.EditMeaning, InputBoxTipMessage.EditMeaning, false); updateMeanDialog.InputBoxText = this.MeaningObject.Desc; if (updateMeanDialog.ShowDialog(this) == DialogResult.OK) { if (!updateMeanDialog.InputBoxText.TrimEnd().Equals(this.MeaningObject.Desc, StringComparison.Ordinal)) { this.MeaningObject.Desc = updateMeanDialog.InputBoxText.TrimEnd(); this.MeaningObject.Remark = DateTime.Now.ToString(); meaningBLL.InsertOrUpdateMeaning(this.MeaningObject); this.tbMean.Text = this.MeaningObject.Desc; this.tbMean.Enabled = false; } } }
public static string InputBox(string prompt, string title, string defaultValue) { InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = prompt; ib.FormCaption = title; ib.DefaultValue = defaultValue; ib.ShowDialog(); string s = ib.InputResponse; ib.Close(); if (s == string.Empty) { return(""); } else { return(s); } }
private void rinomina() { InputBoxDialog d = new InputBoxDialog(); d.Title = "Inserire il nome dell'azione"; bool?esito = d.ShowDialog(); if (esito != true) { return; } AzioneAuto azione = azioneAutomaticaSelezionata; OrmUtil.forseAttacca <AzioneAuto>(ref azione); azione.nome = d.inputValue.Text; OrmUtil.cambiaStatoModificato(azione); azioneAutomaticaSelezionata = azione; rileggereAzioniAutomatiche(); dialogProvider.ShowMessage("Modifica Effettuata con successo", "Avviso"); }
/// <summary> /// Edit a Favorite Channel selected with a Dialog Box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonEdit_Click(object sender, EventArgs e) { int s = listChannels.SelectedIndex; if (s == -1) return; InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Edit Favorite Channel"; i.FormPrompt = "Enter the new channel name"; i.DefaultValue = listChannels.Items[s].ToString(); i.ShowDialog(); if (i.InputResponse.Length > 0) listChannels.Items[s] = i.InputResponse; WriteSettings(); }
private void buttonAddTheme_Click(object sender, EventArgs e) { //add the current color settings as a new theme //ask for the new theme InputBoxDialog i = new InputBoxDialog(); i.FormPrompt = "New Monody Theme Name"; i.FormCaption = "Add Monody Theme"; if (i.ShowDialog() == DialogResult.OK) //i.ShowDialog(); { if (i.InputResponse.Length > 0) { //make file name theme-name.xml string fileName = i.InputResponse; string colorsFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + fileName + ".xml"; UpdateColors(); XmlSerializer serializer = new XmlSerializer(typeof(IceChatColors)); TextWriter textWriter = new StreamWriter(colorsFile); serializer.Serialize(textWriter, iceChatColors); textWriter.Close(); textWriter.Dispose(); string messageFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + fileName + ".xml"; XmlSerializer serializer2 = new XmlSerializer(typeof(IceChatMessageFormat)); TextWriter textWriter2 = new StreamWriter(messageFile); serializer2.Serialize(textWriter2, iceChatMessages); textWriter2.Close(); textWriter2.Dispose(); //add in the theme name into IceChatOptions //make it the current theme ComboItem item = new ComboItem(); item.ThemeName = fileName; item.ThemeType = "XML"; comboTheme.Items.Add(item); comboTheme.Text = fileName; } } }
private static string InputBox(string texto) { InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = texto; ib.DefaultValue = ""; ib.ShowDialog(); string s = ib.InputResponse; ib.Close(); return(s); }
private void cmChangeIosSlot_Click(object sender, EventArgs e) { if (lvWads.SelectedItems[0].SubItems[8].Text.Contains("IOS")) { if (MessageBox.Show("This might brick your Wii!\nOnly use this feature, if you have BootMii installed as boot2(!) with a NAND Backup(!)\nUse this at your own risk!\nDo you agree?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { int slot = 0; InputBoxDialog ib = new InputBoxDialog(); ib.btnCancel.Text = Messages[27]; ib.FormCaption = Messages[152]; ib.FormPrompt = Messages[153]; if (ib.ShowDialog() == DialogResult.OK) { if (int.TryParse(ib.InputResponse, out slot) == true) { try { string wadfile = lvWads.SelectedItems[0].Group.Tag.ToString() + "\\" + lvWads.SelectedItems[0].Text; byte[] wad = Wii.Tools.LoadFileToByteArray(wadfile); wad = Wii.WadEdit.ChangeIosSlot(wad, slot); Wii.Tools.SaveFileFromByteArray(wad, wadfile); lvWads.SelectedItems[0].Remove(); SaveList(); LoadNew(); } catch (Exception ex) { ErrorBox(ex.Message); } } else { ErrorBox(Messages[154]); } } } } }
private void cmNandPatchReturnTo_Click(object sender, EventArgs e) { if (lvNand.Visible && lvNand.SelectedItems.Count == 1) { InputBoxDialog ib = new InputBoxDialog(); ib.FormCaption = "Enter Title ID"; ib.FormPrompt = "Please enter the ID of the title to return to..."; ib.MaxLength = 4; if (ib.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string stringId = ib.InputResponse; if (stringId.Length != 4) { ErrorBox("The title ID must be 4 characters long!"); return; } uint titleID = (uint)((stringId[0] << 24) | (stringId[1] << 16) | (stringId[2] << 8) | stringId[3]); string path = NandPath + "\\title\\" + lvNand.SelectedItems[0].SubItems[7].Text + "\\content\\"; string[] appFile = Directory.GetFiles(path, "*.app"); bool patched = false; for (int i = 0; i < appFile.Length; i++) { if (Wii.U8.CheckU8(appFile[i])) continue; using (FileStream fs = new FileStream(appFile[i], FileMode.Open, FileAccess.ReadWrite)) { if (ReturnToPatcher.PatchFile(fs, titleID)) { patched = true; break; } } } if (patched) { string[] tmdFile = Directory.GetFiles(path, "title.tmd"); Wii.WadEdit.UpdateTmdContents(tmdFile[0]); InfoBox("Successfully patched title to return to " + stringId); } else ErrorBox("No patterns to patch were found..."); } }
/// <summary> /// Use a Dialog Box to ask for a New Favorite Channel to Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAdd_Click(object sender, EventArgs e) { //ask for a new channel to add InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Add Favorite Channel"; i.FormPrompt = "Enter a channel to add"; i.ShowDialog(); if (i.InputResponse.Length > 0) listChannels.Items.Add(i.InputResponse); //write out the settings file WriteSettings(); }
private void cmChangeTitleVersion_Click(object sender, EventArgs e) { if (MessageBox.Show("This might brick your Wii!\nOnly use this feature, if you have BootMii installed as boot2(!) with a NAND Backup(!)\nUse this at your own risk!\nEspecially, be very careful using this feature with any System Wad!\nDo you agree?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string wadfile = lvWads.SelectedItems[0].Group.Tag.ToString() + "\\" + lvWads.SelectedItems[0].Text; int oldversion = Wii.WadInfo.GetTitleVersion(wadfile); int newversion; InputBoxDialog ib = new InputBoxDialog(); ib.btnCancel.Text = Messages[27]; ib.FormCaption = Messages[149]; ib.FormPrompt = Messages[150].Replace("<s>", "\n"); ib.DefaultValue = oldversion.ToString(); if (ib.ShowDialog() == DialogResult.OK) { if (int.TryParse(ib.InputResponse, out newversion)) { try { byte[] wad = Wii.Tools.LoadFileToByteArray(wadfile); wad = Wii.WadEdit.ChangeTitleVersion(wad, newversion); Wii.Tools.SaveFileFromByteArray(wad, wadfile); lvWads.SelectedItems[0].Remove(); SaveList(); LoadNew(); } catch (Exception ex) { ErrorBox(ex.Message); } } else { ErrorBox(Messages[151]); } } } }
private void toolStripAway_Click(object sender, EventArgs e) { //check if away or not if (FormMain.Instance.InputPanel.CurrentConnection != null) { if (inputPanel.CurrentConnection.ServerSetting.Away) { ParseOutGoingCommand(inputPanel.CurrentConnection, "/away"); } else { //ask for an away reason InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter your away Reason"; i.FormPrompt = "Away Reason"; i.ShowDialog(); if (i.InputResponse.Length > 0) ParseOutGoingCommand(inputPanel.CurrentConnection, "/away " + i.InputResponse); i.Dispose(); } } }
public void InitEvents() { this.btnAddMean.Click += new EventHandler((a, b) => { InputBoxDialog newMeanDialog = new InputBoxDialog(InputBoxTitle.AddMeaning, InputBoxTipMessage.AddMeaning, false); if (newMeanDialog.ShowDialog(this) == DialogResult.OK) { Meanings meaning = new Meanings() { Id = this._meanBll.GetMeaningPKValue() + 1, Desc = newMeanDialog.InputBoxText.TrimEnd(), Remark = DateTime.Now.ToString() }; this._meanBll.InsertOrUpdateMeaning(meaning); this.allMeanings.Add(meaning); if (this.clbMeans != null) { this.clbMeans.AddMean(meaning); } } }); this.btnEditMean.Click += new EventHandler((send, args) => { InputBoxDialog updateMeanDialog = new InputBoxDialog(InputBoxTitle.EditMeaning, InputBoxTipMessage.EditMeaning, false); int selectedMeanId = this.clbMeans.GetCurrentSelectedMean(); Meanings selectedMean = null; if (allMeanings != null) { selectedMean = allMeanings.Where <Meanings>(m => m.Id == selectedMeanId).FirstOrDefault(); } if (selectedMean != null) { updateMeanDialog.InputBoxText = selectedMean.Desc; if (updateMeanDialog.ShowDialog(this) == DialogResult.OK) { if (!updateMeanDialog.InputBoxText.TrimEnd().Equals(selectedMean.Desc, StringComparison.Ordinal)) { selectedMean.Desc = updateMeanDialog.InputBoxText.TrimEnd(); selectedMean.Remark = DateTime.Now.ToString(); this._meanBll.InsertOrUpdateMeaning(selectedMean); this.clbMeans.Refresh(); } } } }); this.btnDeleteMean.Click += new EventHandler((send, args) => { if (DialogResult.Yes == Utils.ShowMessageBox(Messages.DeleteMeaning, Messages.TitleWarning, MessageBoxButtons.YesNo)) { int selectedMeanId = this.clbMeans.GetCurrentSelectedMean(); Meanings selectedMean = null; if (allMeanings != null) { selectedMean = allMeanings.Where <Meanings>(m => m.Id == selectedMeanId).FirstOrDefault(); } if (selectedMean != null) { this._meanBll.DeleteMeaningAndRelation(selectedMean); allMeanings.Remove(selectedMean); this.clbMeans.Items.Remove(selectedMean); foreach (var item in this.newUserRelation.Values) { item.Remove(selectedMeanId); } this.clbMeans.Refresh(); } } }); }
private void btnSaveNewConfig_Click(object sender, EventArgs e) { // no focus gbxPadding.Focus(); // exit modifying modifyingPresetConfigurationExit(); // get name of new configuration InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = "Enter preset name"; ib.FormCaption = "New preset configuration"; ib.DefaultValue = ""; // show the dialog if (ib.ShowDialog() == DialogResult.OK) { // close dialog ib.Close(); // create a new output configuration OutputConfiguration oc = new OutputConfiguration(); // load current form to config loadFormToOutputConfiguration(ref oc); // set display name oc.displayName = ib.InputResponse; // save new configuration to end of list m_outputConfigurationManager.configurationAdd(ref oc); // re-populate dropdown m_outputConfigurationManager.comboboxPopulate(cbxOutputConfigurations); // set selected index cbxOutputConfigurations.SelectedIndex = cbxOutputConfigurations.Items.Count - 1; // re-save m_outputConfigurationManager.saveToFile("OutputConfigs.xml"); } }
/// <summary> /// Add a new group. /// </summary> public void AddNewGroup() { string s; InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = MOE.Utility.GetStringFromRes( "strNewGroup" ); // "Enter new group name"; ib.FormCaption = MOE.Utility.GetStringFromRes("strNewGroupTitle"); // "Add Group"; ib.ShowDialog( this ); s = ib.InputResponse; if( s.Length != 0 ) { try { m_Groups.Add( s, new WOL2Group( s ) ); } catch( Exception e ) { MOE.Logger.DoLog( e.ToString(), Logger.LogLevel.lvlWarning ); } RefreshGroupList(); // Mark the file as changed ChangedHostsFile(); } }
// IRC Indexer Service private void searchForChannelsToolStripMenuItem_Click(object sender, EventArgs e) { //use ircindexer.net //http://ircindexer.net/indexerapi.php?search= InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Search Channels"; i.FormPrompt = "Enter the channel to search for."; i.ShowDialog(); if (i.InputResponse.Length > 0) { //output to an @search searchChannels(i.InputResponse); } i.Dispose(); }
private void searchForNetworksToolStripMenuItem_Click(object sender, EventArgs e) { InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Search IRC Networks"; i.FormPrompt = "Enter the IRC Network to search for."; i.ShowDialog(); if (i.InputResponse.Length > 0) { //output to an @search searchNetworks(i.InputResponse); } i.Dispose(); }
void UploadFiles() { FTP ftplib = new FTP(); try { // there are server, user and password properties // that can be set within the ftplib object as well // those properties are actually set when // you call the Connect(server, user, pass) function String host = Settings.Default.Host; ftplib.Connect("ftp." + host, Settings.Default.Username, Settings.Default.Password); InputBoxDialog inputBox = new InputBoxDialog(); inputBox.FormPrompt = "FTP Directory"; inputBox.FormCaption = "FTP Directory"; inputBox.DefaultValue = Settings.Default.DefaultDir; inputBox.ShowDialog(); String directory = inputBox.InputResponse; inputBox.Close(); if (directory == "" || directory == null) Application.Exit(); // Populate clipboard String clipboard = ""; foreach (String filename in resizedPictureFiles) { FileInfo fileInfo = new FileInfo(filename); clipboard += "http://" + host + "/" + directory + fileInfo.Name + "\r\n"; } Clipboard.SetDataObject(clipboard, true); try { ftplib.ChangeDir(directory); } catch (Exception) { // Directory probably didn't exist. Create it. ftplib.MakeDir(directory,true); } // open the file with resume support if it already exists, the last // peram should be false for no resume foreach (String filename in resizedPictureFiles) { FileInfo fileInfo = new FileInfo(filename); ftplib.OpenUpload(fileInfo.FullName, fileInfo.Name); while (ftplib.DoUpload() > 0) { //perc = (int)((ftplib.BytesTotal * 100) / ftplib.FileSize); //Console.Write("\rDownloading: {0}/{1} {2}%", // ftplib.BytesTotal, ftplib.FileSize, perc); //Console.Out.Flush(); } //Console.WriteLine(""); } MessageBox.Show("Upload Complete!"); Application.Exit(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Rename the current group if any. /// </summary> public void RenameCurrentGroup() { if( m_CurrentGroup != null ) { string sn, s; s = m_CurrentGroup.GetName(); InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = MOE.Utility.GetStringFromRes( "strEditGroup" ); ib.FormCaption = MOE.Utility.GetStringFromRes("strEditGroupTitle"); ib.DefaultValue = s; ib.ShowDialog( this ); sn = ib.InputResponse; if( sn != "" && sn != s ) { m_CurrentGroup.SetName( sn ); // Reorder the hosts Monitor.Enter( m_LockHosts ); foreach( WOL2Host h in m_Hosts ) { string sg = h.GetGroups(), sgn; sgn = sg.Replace( s, sn ); if( sgn != sg ) h.SetGroups( sgn ); } Monitor.Exit( m_LockHosts ); RefreshGroupList(); // Mark the file as changed ChangedHostsFile(); } } }
private void btnCreateKey_Click(object sender, EventArgs e) { if (!File.Exists(Application.StartupPath + "\\common-key.bin") && !File.Exists(Application.StartupPath + "\\key.bin")) { InputBoxDialog ipb = new InputBoxDialog(); ipb.FormPrompt = string.Format(Messages[108], "45e", "common-key.bin"); ipb.FormCaption = Messages[110]; ipb.MaxLength = 3; ipb.btnCancel.Text = Messages[27]; if (ipb.ShowDialog() == DialogResult.OK) { if (ipb.InputResponse == "45e") { Wii.Tools.CreateCommonKey(ipb.InputResponse, Application.StartupPath); } else { ErrorBox(string.Format(Messages[109], "45e")); } } } else { if (File.Exists(Application.StartupPath + "\\common-key.bin")) ErrorBox(string.Format(Messages[111], "common-key.bin")); else if (File.Exists(Application.StartupPath + "\\key.bin")) ErrorBox(string.Format(Messages[111], "key.bin")); } }
private void toolStripButton1_Click(object sender, EventArgs e) { InputBoxDialog input = new InputBoxDialog(); input.DefaultValue = m_sHostFileNote; string msg = MOE.Utility.GetStringFromRes("strEditHostListComment"); string title = MOE.Utility.GetStringFromRes("strEditHostListCommentTitle"); input.FormPrompt = msg; input.FormCaption = title; if( input.ShowDialog(this) == DialogResult.OK ) { m_sHostFileNote = input.InputResponse; tbtnNote.ToolTipText = m_sHostFileNote; } }
private void mnuEnterSQL_Click(object sender, System.EventArgs e) { debugLogger.WriteDebug_3("Begin Method: frmMain.mnuEnterSQL_Click(object,EventArgs) (" + sender.ToString() + "," + e.ToString() + ")"); InputBoxDialog input = new InputBoxDialog(); input.FormPrompt = "Enter Query: "; input.FormCaption = "SQL Query"; input.ShowDialog(); string query = input.InputResponse; input.Close(); debugLogger.WriteDebug_3("InputBox.InputResponse returns " + query); if (query.StartsWith("SELECT")) { debugLogger.WriteDebug_2("SELECT query entered"); TableViewer table = new TableViewer(this,TableViewer.DKPSELECT,query,true); table.Show(); StatusMessage = "Performing SELECT query..."; } else if (query.StartsWith("UPDATE")||query.StartsWith("DELETE")||query.StartsWith("INSERT")) { debugLogger.WriteDebug_2("UPDATE, DELETE, or INSERT query entered"); TableViewer table = new TableViewer(this,TableViewer.DKPUPDATE,query,false); StatusMessage = "Performing UPDATE query..."; } else { debugLogger.WriteDebug_2("Invalid query entered"); MessageBox.Show("Invalid SQL Query","Error"); } debugLogger.WriteDebug_3("End Method: frmMain.mnuEnterSQLQuery_Click()"); }
/// <summary> /// Parse out $identifiers for outgoing commands /// </summary> /// <param name="connection">Which Connection it is for</param> /// <param name="data">The data to be parsed</param> /// <returns></returns> private string ParseIdentifiers(IRCConnection connection, string data, string dataPassed) { string[] changedData = null; try { //parse the initial identifiers data = ParseIdentifier(connection, data); //parse out the $1,$2.. identifiers data = ParseIdentifierValue(data, dataPassed); //$+ is a joiner identifier, great for joining 2 words together data = data.Replace(" $+ ", string.Empty); //split up the data into words string[] parsedData = data.Split(' '); //the data that was passed for parsing identifiers string[] passedData = dataPassed.Split(' '); //will hold the updates message/data after identifiers are parsed changedData = data.Split(' '); int count = -1; string extra = ""; bool askExtra = false; foreach (string word in parsedData) { count++; if (word.StartsWith("//") && count == 0) changedData[count] = word.Substring(1); if (askExtra) { //continueing a $?= extra += " " + word; changedData[count] = null; if (extra[extra.Length - 1] == extra[0]) { askExtra = false; //ask the question InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter Value"; i.FormPrompt = extra.Substring(1,extra.Length-2); i.ShowDialog(); if (i.InputResponse.Length > 0) changedData[count] = i.InputResponse; i.Dispose(); } } //parse out identifiers (start with a $) if (word.StartsWith("$")) { switch (word) { default: int result; if (word.StartsWith("$?=") && word.Length > 5) { //check for 2 quotes (single or double) string ask = word.Substring(3); //check what kind of a quote it is char quote = ask[0]; if (quote == ask[ask.Length - 1]) { //ask the question extra = ask; InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter Value"; i.FormPrompt = extra.Substring(1, extra.Length - 2); i.ShowDialog(); if (i.InputResponse.Length > 0) changedData[count] = i.InputResponse; else changedData[count] = null; i.Dispose(); } else { //go to the next word until we find a quote at the end extra = ask; askExtra = true; changedData[count] = null; } } if (word.StartsWith("$md5(") && word.IndexOf(')') > word.IndexOf('(')) { string input = ReturnBracketValue(word); changedData[count] = MD5(input); } if (word.StartsWith("$read(") && word.IndexOf(')') > word.IndexOf('(')) { string file = ReturnBracketValue(word); //check if we have passed a path or just a filename if (file.IndexOf(System.IO.Path.DirectorySeparatorChar) > -1) { //its a full folder if (File.Exists(file)) { //count the number of lines in the file //load the file in and read a random line from it string[] lines = File.ReadAllLines(file); if (lines.Length > 0) { //pick a random line Random r = new Random(); int line = r.Next(0, lines.Length - 1); changedData[count] = lines[line]; } else changedData[count] = "$null"; } } else { //just check in the Scripts Folder if (File.Exists(scriptsFolder + System.IO.Path.DirectorySeparatorChar + file)) { //load the file in and read a random line from it string[] lines = File.ReadAllLines(scriptsFolder + System.IO.Path.DirectorySeparatorChar + file); if (lines.Length > 0) { //pick a random line Random r = new Random(); int line = r.Next(0, lines.Length - 1); changedData[count] = lines[line]; } else changedData[count] = "$null"; } } } if (connection != null) { if (word.StartsWith("$ial(") && word.IndexOf(')') > word.IndexOf('(')) { string nick = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); InternalAddressList ial = (InternalAddressList)connection.ServerSetting.IAL[nick]; if (ial != null) { if (prop.Length == 0) changedData[count] = ial.Nick; else { switch (prop.ToLower()) { case "nick": changedData[count] = ial.Nick; break; case "host": changedData[count] = ial.Host; break; } } } else changedData[count] = "$null"; } if (word.StartsWith("$nick(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string values = ReturnBracketValue(word); if (values.Split(',').Length == 2) { string channel = values.Split(',')[0]; string nickvalue = values.Split(',')[1]; string prop = ReturnPropertyValue(word); // $nick(#,N) //find then channel IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { User u = null; if (Int32.TryParse(nickvalue, out result)) { if (Convert.ToInt32(nickvalue) == 0) changedData[count] = t.Nicks.Count.ToString(); else u = t.GetNick(Convert.ToInt32(nickvalue)); } else { u = t.GetNick(nickvalue); } if (prop.Length == 0 && u != null) { changedData[count] = u.NickName; } else if (u != null) { //$nick(#channel,1).op , .voice, .halfop, .admin,.owner. //.mode, .host, .nick,.ident InternalAddressList ial = (InternalAddressList)connection.ServerSetting.IAL[u.NickName]; switch (prop.ToLower()) { case "host": if (ial != null && ial.Host != null && ial.Host.Length > 0) changedData[count] = ial.Host.Substring(ial.Host.IndexOf('@') + 1); break; case "ident": if (ial != null && ial.Host != null && ial.Host.Length > 0) changedData[count] = ial.Host.Substring(0,ial.Host.IndexOf('@')); break; case "nick": changedData[count] = u.NickName; break; case "mode": changedData[count] = u.ToString().Replace(u.NickName, ""); break; case "op": for (int i = 0; i < u.Level.Length; i++) { if (connection.ServerSetting.StatusModes[0][i] == 'o') { if (u.Level[i] == true) changedData[count] = "$true"; else changedData[count] = "$false"; } } break; case "voice": for (int i = 0; i < u.Level.Length; i++) { if (connection.ServerSetting.StatusModes[0][i] == 'v') { if (u.Level[i] == true) changedData[count] = "$true"; else changedData[count] = "$false"; } } break; } ial = null; } } } } if (word.StartsWith("$chan(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string channel = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); //find then channel IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { if (prop.Length == 0) { //replace with channel name changedData[count] = t.TabCaption; } else { switch (prop.ToLower()) { case "mode": changedData[count] = t.ChannelModes; break; case "count": changedData[count] = t.Nicks.Count.ToString(); break; default: break; } } } } if (word.StartsWith("$timer(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string timerid = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); //find the timer foreach (IrcTimer timer in connection.IRCTimers) { if (timer.TimerID == timerid) { if (prop.Length == 0) { //replace with timer id changedData[count] = timer.TimerID; } else { switch (prop.ToLower()) { case "id": changedData[count] = timer.TimerID; break; case "reps": changedData[count] = timer.TimerRepetitions.ToString(); break; case "count": changedData[count] = timer.TimerCounter.ToString(); break; case "command": changedData[count] = timer.TimerCommand; break; case "interval": changedData[count] = timer.TimerInterval.ToString(); break; default: break; } } } } } if (word.StartsWith("$mask(") && word.IndexOf(')') > word.IndexOf('(')) { //$mask($host,2) //get the value between and after the brackets string values = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); if (values.Split(',').Length == 2) { string full_host = values.Split(',')[0]; string mask_value = values.Split(',')[1]; if (full_host.Length == 0) break; if (mask_value.Length == 0) break; if (full_host.IndexOf("@") == -1) break; if (full_host.IndexOf("!") == -1) break; switch (mask_value) { case "0": // *!user@host changedData[count] = "*!" + full_host.Substring(full_host.IndexOf("!") + 1); break; case "1": // *!*user@host changedData[count] = "*!*" + full_host.Substring(full_host.IndexOf("!") + 1); break; case "2": // *!*user@*.host changedData[count] = "*!*" + full_host.Substring(full_host.IndexOf("@")); break; case "3": // *!*user@*.host break; case "4": // *!*@*.host break; case "5": // nick!user@host changedData[count] = full_host; break; case "6": // nick!*user@host break; case "7": // nick!*@host break; case "8": // nick!*user@*.host break; case "9": // nick!*@*.host break; case "10": // nick!*@* changedData[count] = full_host.Substring(0, full_host.IndexOf("!")) + "!*@*"; break; case "11": // *!user@* break; } } } } break; } } } } catch (Exception e) { WriteErrorFile(connection, "ParseIdentifiers" + data, e); } //return String.Join(" ", changedData); return JoinString(changedData); }
/// <summary> /// Parse out $identifiers for outgoing commands /// </summary> /// <param name="connection">Which Connection it is for</param> /// <param name="data">The data to be parsed</param> /// <returns></returns> private string ParseIdentifiers(IRCConnection connection, string data, string dataPassed) { string[] changedData = null; try { //parse the initial identifiers data = ParseIdentifier(connection, data); //parse out the $1,$2.. identifiers data = ParseIdentifierValue(data, dataPassed); //$+ is a joiner identifier, great for joining 2 words together data = data.Replace(" $+ ", string.Empty); //parse out the current channel # if (CurrentWindowStyle == IceTabPage.WindowType.Channel) { data = data.Replace(" # ", " " + CurrentWindow.TabCaption + " "); } //split up the data into words string[] parsedData = data.Split(' '); //the data that was passed for parsing identifiers string[] passedData = dataPassed.Split(' '); //will hold the updates message/data after identifiers are parsed changedData = data.Split(' '); int count = -1; string extra = ""; bool askExtra = false; bool askSecure = false; foreach (string word in parsedData) { count++; if (word.StartsWith("//") && count == 0) changedData[count] = word.Substring(1); if (askExtra) { //continueing a $?= extra += " " + word; changedData[count] = null; if (extra[extra.Length - 1] == extra[0]) { askExtra = false; //ask the question InputBoxDialog i = new InputBoxDialog(); i.PasswordChar = askSecure; i.FormCaption = "Enter Value"; i.FormPrompt = extra.Substring(1,extra.Length-2); i.ShowDialog(); if (i.InputResponse.Length > 0) changedData[count] = i.InputResponse; i.Dispose(); } } //parse out identifiers (start with a $) if (word.StartsWith("$")) { switch (word) { default: int result; if (word.StartsWith("$?=") && word.Length > 5) { //check for 2 quotes (single or double) string ask = word.Substring(3); //check what kind of a quote it is char quote = ask[0]; if (quote == ask[ask.Length - 1]) { //ask the question extra = ask; InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter Value"; i.FormPrompt = extra.Substring(1, extra.Length - 2); i.ShowDialog(); if (i.InputResponse.Length > 0) changedData[count] = i.InputResponse; else changedData[count] = null; i.Dispose(); } else { //go to the next word until we find a quote at the end extra = ask; askExtra = true; changedData[count] = null; } } //check for $?*="" // password char if (word.StartsWith("$?*=") && word.Length > 6) { //check for 2 quotes (single or double) string ask = word.Substring(4); //check what kind of a quote it is char quote = ask[0]; if (quote == ask[ask.Length - 1]) { //ask the question extra = ask; InputBoxDialog i = new InputBoxDialog(); i.PasswordChar = true; i.FormCaption = "Enter Value"; i.FormPrompt = extra.Substring(1, extra.Length - 2); i.ShowDialog(); if (i.InputResponse.Length > 0) changedData[count] = i.InputResponse; else changedData[count] = null; i.Dispose(); } else { //go to the next word until we find a quote at the end extra = ask; askExtra = true; askSecure = true; changedData[count] = null; } } if (word.StartsWith("$md5(") && word.IndexOf(')') > word.IndexOf('(')) { string input = ReturnBracketValue(word); changedData[count] = MD5(input); } if (word.StartsWith("$net(") && word.IndexOf(')') > word.IndexOf('(')) { string input = ReturnBracketValue(word); try { // //echo $net(System.Environment.CurrentDirectory) string[] thevalue = input.Split('.'); if (thevalue.Length > 1) { string Class = String.Join(".", thevalue, 0, thevalue.Length - 1); string value = input.Substring(Class.Length + 1); //System.Diagnostics.Debug.WriteLine(Class + "::" + value); if (Class.Length > 0) { //Type.GetType(string for the type).GetProperty(n ame of the property).GetValue(null) Type t = Type.GetType(Class); PropertyInfo info = t.GetProperty(value); if (info != null) { //System.Diagnostics.Debug.WriteLine("name=" +info.Name + ":" + info.GetValue(t, null)); changedData[count] = info.GetValue(t, null).ToString(); } else { //System.Diagnostics.Debug.WriteLine("null info"); changedData[count] = "$null"; } //System.Diagnostics.Debug.WriteLine(t.ToString()); } else changedData[count] = "$null"; } } catch (Exception) { changedData[count] = "$null"; } } if (word.StartsWith("$rand(") && word.IndexOf(')') > word.IndexOf('(')) { string input = ReturnBracketValue(word); //look for a comma (,) if (input.Split(',').Length == 2) { string lownum = input.Split(',')[0]; string hinum = input.Split(',')[1]; int lowNum, hiNum; if (Int32.TryParse(lownum, out lowNum) && Int32.TryParse(hinum, out hiNum)) { //valid numbers Random r = new Random(); int randNumber = r.Next(lowNum, hiNum); changedData[count] = randNumber.ToString(); } else changedData[count] = "$null"; Variable v = new Variable(); } else if (input.IndexOf(',') == -1) { //make it a value from 1 - value int hiNum; if (Int32.TryParse(input, out hiNum)) { //valid number Random r = new Random(); int randNumber = r.Next(1, hiNum); changedData[count]= randNumber.ToString(); } else changedData[count] = "$null"; } else changedData[count] = "$null"; } if (word.StartsWith("$read(") && word.IndexOf(')') > word.IndexOf('(')) { string file = ReturnBracketValue(word); //check if we have passed a path or just a filename if (file.IndexOf(System.IO.Path.DirectorySeparatorChar) > -1) { //its a full folder if (File.Exists(file)) { //count the number of lines in the file //load the file in and read a random line from it string[] lines = File.ReadAllLines(file); if (lines.Length > 0) { //pick a random line Random r = new Random(); int line = r.Next(0, lines.Length - 1); changedData[count] = lines[line]; } else changedData[count] = "$null"; } else { changedData[count] = "$null"; } } else { //just check in the Scripts Folder if (File.Exists(scriptsFolder + System.IO.Path.DirectorySeparatorChar + file)) { //load the file in and read a random line from it string[] lines = File.ReadAllLines(scriptsFolder + System.IO.Path.DirectorySeparatorChar + file); if (lines.Length > 0) { //pick a random line Random r = new Random(); int line = r.Next(0, lines.Length - 1); changedData[count] = lines[line]; } else changedData[count] = "$null"; } else { changedData[count] = "$null"; } } } if (word.StartsWith("$var(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string variable = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); System.Diagnostics.Debug.WriteLine(variable); //check if we have a connection or not if (connection == null) { changedData[count] = _variables.ReturnValue(variable).ToString(); } } if (word.StartsWith("$plugin(") && word.IndexOf(')') > word.IndexOf('(')) { //get the plugin information string pluginid = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); //tryparse if (Int32.TryParse(pluginid, out result)) { for (int i = 0; i < loadedPlugins.Count; i++) { if (i == result) { IPluginIceChat ipc = ((IceChatPlugin)loadedPlugins[i]).plugin; switch (prop.ToLower()) { case "id": changedData[count] = i.ToString(); break; case "name": changedData[count] = ipc.Name; break; case "version": changedData[count] = ipc.Version; break; case "author": changedData[count] = ipc.Author; break; case "enabled": changedData[count] = ipc.Enabled.ToString(); break; case "filename": changedData[count] = ipc.FileName; break; default: changedData[count] = ipc.Name; break; } } } } else { //go by plugin filename, not number for (int i = 0; i < loadedPlugins.Count; i++) { if (((IceChatPlugin)loadedPlugins[i]).plugin.FileName.ToLower() == pluginid.ToLower()) { IPluginIceChat ipc = ((IceChatPlugin)loadedPlugins[i]).plugin; switch (prop.ToLower()) { case "id": changedData[count] = i.ToString(); break; case "name": changedData[count] = ipc.Name; break; case "version": changedData[count] = ipc.Version; break; case "author": changedData[count] = ipc.Author; break; case "enabled": changedData[count] = ipc.Enabled.ToString(); break; case "filename": changedData[count] = ipc.FileName; break; default: changedData[count] = ipc.Name; break; } } } } } if (connection != null) { if (word.StartsWith("$ial(") && word.IndexOf(')') > word.IndexOf('(')) { string nick = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); InternalAddressList ial = (InternalAddressList)connection.ServerSetting.IAL[nick]; if (ial != null) { if (prop.Length == 0) changedData[count] = ial.Nick; else { switch (prop.ToLower()) { case "nick": changedData[count] = ial.Nick; break; case "host": changedData[count] = ial.Host; break; } } } else changedData[count] = "$null"; } if (word.StartsWith("$nick(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string values = ReturnBracketValue(word); if (values.Split(',').Length == 2) { string channel = values.Split(',')[0]; string nickvalue = values.Split(',')[1]; string prop = ReturnPropertyValue(word); // $nick(#,N) //find then channel IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { User u = null; if (Int32.TryParse(nickvalue, out result)) { if (Convert.ToInt32(nickvalue) == 0) changedData[count] = t.Nicks.Count.ToString(); else u = t.GetNick(Convert.ToInt32(nickvalue)); } else { u = t.GetNick(nickvalue); } if (prop.Length == 0 && u != null) { changedData[count] = u.NickName; } else if (u != null) { //$nick(#channel,1).op , .voice, .halfop, .admin,.owner. //.mode, .host, .nick,.ident InternalAddressList ial = (InternalAddressList)connection.ServerSetting.IAL[u.NickName]; switch (prop.ToLower()) { case "host": if (ial != null && ial.Host != null && ial.Host.Length > 0) changedData[count] = ial.Host.Substring(ial.Host.IndexOf('@') + 1); break; case "ident": if (ial != null && ial.Host != null && ial.Host.Length > 0) changedData[count] = ial.Host.Substring(0,ial.Host.IndexOf('@')); break; case "nick": changedData[count] = u.NickName; break; case "mode": changedData[count] = u.ToString().Replace(u.NickName, ""); break; case "op": for (int i = 0; i < u.Level.Length; i++) { if (connection.ServerSetting.StatusModes[0][i] == 'o') { if (u.Level[i] == true) changedData[count] = "$true"; else changedData[count] = "$false"; } } break; case "halfop": for (int i = 0; i < u.Level.Length; i++) { if (connection.ServerSetting.StatusModes[0][i] == 'h') { if (u.Level[i] == true) changedData[count] = "$true"; else changedData[count] = "$false"; } } break; case "voice": for (int i = 0; i < u.Level.Length; i++) { if (connection.ServerSetting.StatusModes[0][i] == 'v') { if (u.Level[i] == true) changedData[count] = "$true"; else changedData[count] = "$false"; } } break; } ial = null; } } } } if (word.StartsWith("$chan(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string channel = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); //find then channel IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel); if (t != null) { if (prop.Length == 0) { //replace with channel name changedData[count] = t.TabCaption; } else { switch (prop.ToLower()) { case "mode": changedData[count] = t.ChannelModes; break; case "count": changedData[count] = t.Nicks.Count.ToString(); break; case "nicks": //return all the nicks seperated by a space string nicks = ""; foreach (string n in t.Nicks.Keys) nicks += n + " "; changedData[count] = nicks.Trim(); break; case "log": changedData[count] = t.TextWindow.LogFileName; break; default: break; } } } } if (word.StartsWith("$timer(") && word.IndexOf(')') > word.IndexOf('(')) { //get the value between and after the brackets string timerid = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); //find the timer foreach (IrcTimer timer in connection.IRCTimers) { if (timer.TimerID == timerid) { if (prop.Length == 0) { //replace with timer id changedData[count] = timer.TimerID; } else { switch (prop.ToLower()) { case "id": changedData[count] = timer.TimerID; break; case "reps": changedData[count] = timer.TimerRepetitions.ToString(); break; case "count": changedData[count] = timer.TimerCounter.ToString(); break; case "command": changedData[count] = timer.TimerCommand; break; case "interval": changedData[count] = timer.TimerInterval.ToString(); break; default: break; } } } } } if (word.StartsWith("$mask(") && word.IndexOf(')') > word.IndexOf('(')) { //$mask($host,2) //get the value between and after the brackets string values = ReturnBracketValue(word); string prop = ReturnPropertyValue(word); if (values.Split(',').Length == 2) { string full_host = values.Split(',')[0]; string mask_value = values.Split(',')[1]; if (full_host.Length == 0) break; if (mask_value.Length == 0) break; if (full_host.IndexOf("@") == -1) break; if (full_host.IndexOf("!") == -1) break; switch (mask_value) { case "0": // *!user@host changedData[count] = "*!" + full_host.Substring(full_host.IndexOf("!") + 1); break; case "1": // *!*user@host changedData[count] = "*!*" + full_host.Substring(full_host.IndexOf("!") + 1); break; case "2": // *!*user@*.host changedData[count] = "*!*" + full_host.Substring(full_host.IndexOf("@")); break; case "3": // *!*user@*.host break; case "4": // *!*@*.host break; case "5": // nick!user@host changedData[count] = full_host; break; case "6": // nick!*user@host break; case "7": // nick!*@host break; case "8": // nick!*user@*.host break; case "9": // nick!*@*.host break; case "10": // nick!*@* changedData[count] = full_host.Substring(0, full_host.IndexOf("!")) + "!*@*"; break; case "11": // *!user@* break; } } } } break; } } } } catch (Exception e) { WriteErrorFile(connection, "ParseIdentifiers" + data, e); } //return String.Join(" ", changedData); return JoinString(changedData); }
/// <summary> /// Renames the given Wad file(s) /// </summary> /// <param name="Wadfile">The Wad file to rename</param> private void RenameWads(System.Windows.Forms.ListView.SelectedListViewItemCollection lvis) { InputBoxDialog ib = new InputBoxDialog(); ib.FormPrompt = Messages[29].Replace("<s>", "\n") + ":\n{channeltitle} {titleid} {hextitleid} {fullhextitleid} {type} {version} {region} {blocks} {size} {iosflag} {content}"; ib.btnCancel.Text = Messages[27]; ib.FormCaption = Messages[28]; ib.DefaultValue = "{type} - {channeltitle} - {titleid}.wad"; ib.ShowDialog(); if (ib.DialogResult == DialogResult.OK) { pbProgress.Value = 0; Cursor.Current = Cursors.WaitCursor; int counter = 0; foreach (ListViewItem lvi in lvis) { pbProgress.Value = (++counter * 100) / lvis.Count; string Wadfile = lvi.Group.Tag.ToString() + "\\" + lvi.Text; if (File.Exists(Wadfile)) { string thispath = Wadfile.Remove(Wadfile.LastIndexOf("\\")); string wadname = Wadfile.Remove(Wadfile.Length - 4).Remove(0, Wadfile.LastIndexOf("\\") + 1); string newname = ib.InputResponse; FileInfo fiWad = new FileInfo(Wadfile); if (!newname.EndsWith(".wad")) newname = newname + ".wad"; if (newname.Contains("{channeltitle}")) newname = newname.Replace("{channeltitle}", lvi.SubItems[10].Text); if (newname.Contains("{titleid}")) newname = newname.Replace("{titleid}", lvi.SubItems[1].Text); if (newname.Contains("{type}")) newname = newname.Replace("{type}", lvi.SubItems[8].Text); if (newname.Contains("{version}")) newname = newname.Replace("{version}", lvi.SubItems[9].Text); if (newname.Contains("{region}")) newname = newname.Replace("{region}", lvi.SubItems[5].Text); if (newname.Contains("{blocks}")) newname = newname.Replace("{blocks}", lvi.SubItems[2].Text); if (newname.Contains("{size}")) newname = newname.Replace("{size}", lvi.SubItems[3].Text); if (newname.Contains("{iosflag}")) newname = newname.Replace("{iosflag}", lvi.SubItems[4].Text); if (newname.Contains("{content}")) newname = newname.Replace("{content}", lvi.SubItems[6].Text); if (newname.Contains("{hextitleid}")) newname = newname.Replace("{hextitleid}", lvi.SubItems[7].Text.Remove(0, lvi.SubItems[7].Text.IndexOf('\\') + 1)); if (newname.Contains("{fullhextitleid}")) newname = newname.Replace("{fullhextitleid}", lvi.SubItems[7].Text.Replace("\\", "")); if (newname.Contains("System: IOS")) newname = newname.Replace("System: IOS", "IOS"); if (newname.Contains("System: MIOS")) newname = newname.Replace("System: MIOS", "MIOS"); if (newname.Contains("System: BC")) newname = newname.Replace("System: BC", "BC"); if (newname.Contains("System: Menu")) newname = newname.Replace("System: Menu", "SystemMenu"); if (newname != wadname + ".wad") { try { string thisfile = thispath + "\\" + newname; if (!File.Exists(thisfile)) fiWad.MoveTo(thisfile); else { int count = 1; bool stop = false; thisfile = thisfile.Insert(thisfile.Length - 4, " (" + count.ToString() + ")"); if (thisfile.Remove(0, thisfile.LastIndexOf('\\') + 1) != wadname + ".wad") { while (File.Exists(thisfile)) { thisfile = thisfile.Replace(" (" + count.ToString() + ")", " (" + (++count).ToString() + ")"); if (thisfile.Remove(0, thisfile.LastIndexOf('\\') + 1) == wadname + ".wad") { stop = true; break; } } if (stop == false) fiWad.MoveTo(thisfile); } } } catch { } } } //else //{ // ErrorBox(Messages[31]); //} } LoadNew(); } Cursor.Current = Cursors.Default; pbProgress.Value = 100; }
private void mnuUnretire_Click(object sender, System.EventArgs e) { debugLogger.WriteDebug_3("Begin Method: frmMain.mnuUnretire_Click(object,EventArgs) (" + sender.ToString() + "," + e.ToString() + ")"); InputBoxDialog input = new InputBoxDialog(); input.FormPrompt = "Who do you want to unretire? "; input.FormCaption = "Unretire Query"; input.ShowDialog(); string person = input.InputResponse; input.Close(); TableViewer table = new TableViewer(this,TableViewer.DKPUPDATE,"UPDATE DKS SET DKS.Name = \"" + person + "\",DKS.Comment = \" \" WHERE (((DKS.Name)=\"zzzDKP Retired\" AND (DKS.Comment=\"" + person + "\")))",false); StatusMessage = "Performing UPDATE query..."; debugLogger.WriteDebug_3("End Method: frmMain.mnuUnretire_Click()"); }
/// <summary> /// Changes the Title ID of the given Wad file /// </summary> /// <param name="wadfile">The Wad file to edit</param> /// <param name="oldid">The old Title ID of the Wad file</param> /// <returns></returns> private bool ChangeTitleID(string wadfile, string oldid) { if (File.Exists(ckey) || File.Exists(key)) { InputBoxDialog ib = new InputBoxDialog(); ib.FormCaption = Messages[41]; ib.FormPrompt = Messages[42]; ib.DefaultValue = oldid; ib.btnCancel.Text = Messages[27]; ib.MaxLength = 4; ib.CaseBox = true; if (ib.ShowDialog() == DialogResult.OK) { string newid = ib.InputResponse; if (newid.Length == 4) { if (newid != oldid) { Regex reg = new Regex("^[0-9A-Za-z]*$"); if (reg.IsMatch(newid)) { Cursor.Current = Cursors.WaitCursor; CreateBackup(wadfile); try { Wii.WadEdit.ChangeTitleID(wadfile, newid); } catch (Exception ex) { InfoBox(ex.Message, Messages[53]); } Cursor.Current = Cursors.Default; return true; } else { ErrorBox(Messages[43]); return false; } } else { return false; } } else { ErrorBox(Messages[44]); return false; } } else { return false; } } else { InfoBox(Messages[52], Messages[53]); return false; } }
public FormMain(string[] args, Form splash) { FormMain.Instance = this; System.Diagnostics.FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); BuildNumber = fv.FileVersion; if (StaticMethods.IsRunningOnMono()) player = new System.Media.SoundPlayer(); else mp3Player = new MP3Player(); bool forceCurrentFolder = false; errorMessages = new List<string>(); _variables = new Variables(); _globalTimers = new List<IrcTimer>(); if (args.Length > 0) { string prevArg = ""; foreach (string arg in args) { if (prevArg.Length == 0) { prevArg = arg; if (arg.ToLower().StartsWith("irc://")) { //parse out the server name and channel name string server = arg.Substring(6).TrimEnd(); if (server.IndexOf("/") != -1) { string host = server.Split('/')[0]; string channel = server.Split('/')[1]; if (channel.StartsWith("#")) autoStartCommand = "/joinserv " + host + " " + channel; else autoStartCommand = "/joinserv " + host + " #" + channel; } else autoStartCommand = "/server " + arg.Substring(6).TrimEnd(); } if (arg.ToLower() == "-disableauto") { disableAutoStart = true; } } else { switch (prevArg.ToLower()) { case "-profile": currentFolder = arg; //check if the folder exists, ir not, create it if (!Directory.Exists(currentFolder)) Directory.CreateDirectory(currentFolder); forceCurrentFolder = true; break; case "-disableauto": disableAutoStart = true; break; } prevArg = ""; } } } //mutex = new System.Threading.Mutex(true, "IceChatMutex"); #region Settings Files //check if the xml settings files exist in current folder if (currentFolder == null) currentFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //check for IceChatPackage.xml in Assembly Folder if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPackage.xml")) { //read the package file //create the IceChatServer.xml file from the package, if it doesnt exist serversFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml"; optionsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatOptions.xml"; if (!File.Exists(serversFile)) { if (!Directory.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings")) Directory.CreateDirectory(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings"); //ask for a Default Nickname InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter Default Nickname"; i.FormPrompt = "Please enter your Nick name"; i.ShowDialog(); if (i.InputResponse.Length > 0) { //changedData[count] = i.InputResponse; System.Diagnostics.Debug.WriteLine("Package Exists - Create Defaults"); XmlSerializer deserializer = new XmlSerializer(typeof(IceChatPackage)); TextReader textReader = new StreamReader(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPackage.xml"); IceChatPackage package = (IceChatPackage)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); IceChatServers servers = new IceChatServers(); foreach (ServerSetting s in package.Servers) { s.NickName = i.InputResponse; s.AltNickName = s.NickName + "_"; s.AwayNickName = s.NickName + "[A]"; servers.AddServer(s); } //save the server(s) to IceChatServer.xml XmlSerializer serializer = new XmlSerializer(typeof(IceChatServers)); TextWriter textWriter = new StreamWriter(serversFile); serializer.Serialize(textWriter, servers); textWriter.Close(); textWriter.Dispose(); servers.listServers.Clear(); serializer = null; textWriter = null; //load the options and save IceChatOptions options = package.Options; serializer = new XmlSerializer(typeof(IceChatOptions)); textWriter = new StreamWriter(optionsFile); serializer.Serialize(textWriter, options); textWriter.Close(); textWriter.Dispose(); currentFolder += System.IO.Path.DirectorySeparatorChar + "Settings"; } i.Dispose(); //change the currentFolder } } //check for Settings/IceChatServer.xml if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml")) { currentFolder += System.IO.Path.DirectorySeparatorChar + "Settings"; } else if (!File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml") && !forceCurrentFolder) { if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody")) Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody"); currentFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody"; } //load all files from the Local AppData folder, unless it exist in the current folder serversFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml"; optionsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatOptions.xml"; messagesFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatMessages.xml"; fontsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatFonts.xml"; colorsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatColors.xml"; soundsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatSounds.xml"; favoriteChannelsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatChannels.xml"; aliasesFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatAliases.xml"; popupsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPopups.xml"; pluginsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPlugins.xml"; emoticonsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Emoticons" + System.IO.Path.DirectorySeparatorChar + "IceChatEmoticons.xml"; channelSettingsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "ChannelSetting.xml"; colorPaletteFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "ColorPalette.xml"; //set a new logs folder logsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Logs"; scriptsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Scripts"; soundsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Sounds"; picturesFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Pictures"; pluginsFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "Plugins"; if (!Directory.Exists(pluginsFolder)) Directory.CreateDirectory(pluginsFolder); if (!Directory.Exists(scriptsFolder)) Directory.CreateDirectory(scriptsFolder); if (!Directory.Exists(soundsFolder)) Directory.CreateDirectory(soundsFolder); if (!Directory.Exists(picturesFolder)) Directory.CreateDirectory(picturesFolder); if (!Directory.Exists(currentFolder + Path.DirectorySeparatorChar + "Update")) Directory.CreateDirectory(currentFolder + Path.DirectorySeparatorChar + "Update"); #endregion languageFiles = new List<LanguageItem>(); DirectoryInfo languageDirectory = null; languageDirectory = new DirectoryInfo(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages"); if (!Directory.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages")) Directory.CreateDirectory(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages"); if (languageDirectory != null) { // scan the language directory for xml files and make LanguageItems for each file FileInfo[] langFiles = languageDirectory.GetFiles("*.xml"); foreach (FileInfo fi in langFiles) { string langFile = languageDirectory.FullName + System.IO.Path.DirectorySeparatorChar + fi.Name; LanguageItem languageItem = LoadLanguageItem(langFile); if (languageItem != null) languageFiles.Add(languageItem); } if (languageFiles.Count == 0) { currentLanguageFile = new LanguageItem(); languageFiles.Add(currentLanguageFile); // default language English } } //load the color palette LoadColorPalette(); LoadOptions(); LoadColors(); LoadSounds(); // use the language saved in options if available, // if not (e.g. user deleted xml file) default is used foreach (LanguageItem li in languageFiles) { if (li.LanguageName == iceChatOptions.Language) { currentLanguageFile = li; break; } } LoadLanguage(); // The language class MUST be loaded before any GUI component is created //set the new log folder if (iceChatOptions.LogFolder.Length > 0) { logsFolder = iceChatOptions.LogFolder; } else { iceChatOptions.LogFolder = logsFolder; } //check if we have any servers/settings saved, if not, load firstrun if (!File.Exists(serversFile)) { FormFirstRun firstRun = new FormFirstRun(currentFolder); firstRun.SaveOptions += new FormFirstRun.SaveOptionsDelegate(FirstRunSaveOptions); firstRun.ShowDialog(this); } InitializeComponent(); //load icons from Embedded Resources or Pictures Image this.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); if (iceChatOptions.SystemTrayIcon == null || iceChatOptions.SystemTrayIcon.Trim().Length == 0) { this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); } else { //make sure the image exists and is an ICO file if (File.Exists(iceChatOptions.SystemTrayIcon)) this.notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(iceChatOptions.SystemTrayIcon); else this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); } //this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); this.notifyIcon.Visible = iceChatOptions.ShowSytemTrayIcon; //disable this by default this.toolStripUpdate.Visible = false; this.updateAvailableToolStripMenuItem1.Visible = false; serverListToolStripMenuItem.Checked = iceChatOptions.ShowServerTree; panelDockLeft.Visible = serverListToolStripMenuItem.Checked; splitterLeft.Visible = serverListToolStripMenuItem.Checked; nickListToolStripMenuItem.Checked = iceChatOptions.ShowNickList; panelDockRight.Visible = nickListToolStripMenuItem.Checked; panelDockRight.TabControl.Alignment = TabAlignment.Right; splitterRight.Visible = nickListToolStripMenuItem.Checked; statusBarToolStripMenuItem.Checked = iceChatOptions.ShowStatusBar; statusStripMain.Visible = statusBarToolStripMenuItem.Checked; toolBarToolStripMenuItem.Checked = iceChatOptions.ShowToolBar; toolStripMain.Visible = toolBarToolStripMenuItem.Checked; viewChannelBarToolStripMenuItem.Checked = iceChatOptions.ShowTabBar; mainChannelBar.Visible = iceChatOptions.ShowTabBar; mainChannelBar.SingleRow = iceChatOptions.SingleRowTabBar; this.Text = ProgramID + " " + VersionID; //this can be customized if (iceChatOptions.SystemTrayText == null || iceChatOptions.SystemTrayText.Trim().Length == 0) this.notifyIcon.Text = ProgramID + " " + VersionID; else this.notifyIcon.Text = iceChatOptions.SystemTrayText; if (!Directory.Exists(logsFolder)) Directory.CreateDirectory(logsFolder); try { errorFile = new StreamWriter(logsFolder + System.IO.Path.DirectorySeparatorChar + "errors.log", true); } catch (IOException io) { System.Diagnostics.Debug.WriteLine("Can not create errors.log:" + io.Message); } catch (Exception eo) { System.Diagnostics.Debug.WriteLine("Can not create errors.log:" + eo.Message); } if (iceChatOptions.WindowSize != null) { if (iceChatOptions.WindowSize.Width > 100 && iceChatOptions.WindowSize.Height > 100) { this.Size = iceChatOptions.WindowSize; this.WindowState = iceChatOptions.WindowState; } else { this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; } } else { this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; } if (iceChatOptions.WindowLocation != null) { //check if the location is valid, could try and place it on a 2nd screen that no longer exists if (Screen.AllScreens.Length == 1) { if (Screen.PrimaryScreen.Bounds.Contains(iceChatOptions.WindowLocation)) this.Location = iceChatOptions.WindowLocation; } else { //check if we are in the bounds of the screen location foreach (Screen screen in Screen.AllScreens) if (screen.Bounds.Contains(iceChatOptions.WindowLocation)) this.Location = iceChatOptions.WindowLocation; } } statusStripMain.Visible = iceChatOptions.ShowStatusBar; LoadAliases(); LoadPopups(); LoadEmoticons(); LoadMessageFormat(); LoadFonts(); bool fileThemeFound = true; if (iceChatOptions.CurrentTheme == null) { iceChatOptions.CurrentTheme = "Default"; defaultToolStripMenuItem.Checked = true; //reload all the theme files } else { //load in the new color theme, if it not Default if (iceChatOptions.CurrentTheme != "Default") { string themeFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + iceChatOptions.CurrentTheme + ".xml"; if (File.Exists(themeFile)) { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatColors)); TextReader textReader = new StreamReader(themeFile); iceChatColors = (IceChatColors)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); colorsFile = themeFile; } else { System.Diagnostics.Debug.WriteLine("Color Theme File not found:" + themeFile); fileThemeFound = false; } themeFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + iceChatOptions.CurrentTheme + ".xml"; if (File.Exists(themeFile)) { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatMessageFormat)); TextReader textReader = new StreamReader(themeFile); iceChatMessages = (IceChatMessageFormat)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); messagesFile = themeFile; } else { System.Diagnostics.Debug.WriteLine("Messages Theme File not found:" + themeFile); fileThemeFound = false; } } else defaultToolStripMenuItem.Checked = true; } if (iceChatOptions.Theme == null) { defaultToolStripMenuItem.Checked = true; iceChatOptions.CurrentTheme = "Default"; DirectoryInfo _currentFolder = new DirectoryInfo(currentFolder); FileInfo[] xmlFiles = _currentFolder.GetFiles("*.xml"); int totalThemes = 1; foreach (FileInfo fi in xmlFiles) { if (fi.Name.StartsWith("Colors-")) { totalThemes++; } } iceChatOptions.Theme = new ThemeItem[totalThemes]; iceChatOptions.Theme[0] = new ThemeItem(); iceChatOptions.Theme[0].ThemeName = "Default"; iceChatOptions.Theme[0].ThemeType = "XML"; int t = 1; foreach (FileInfo fi in xmlFiles) { if (fi.Name.StartsWith("Colors-")) { string themeName = fi.Name.Replace("Colors-", "").Replace(".xml", ""); ; iceChatOptions.Theme[t] = new ThemeItem(); iceChatOptions.Theme[t].ThemeName = themeName; iceChatOptions.Theme[t].ThemeType = "XML"; t++; } } } channelList = new ChannelList(this); channelList.Dock = DockStyle.Fill; buddyList = new BuddyList(this); buddyList.Dock = DockStyle.Fill; toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); serverTree.SetListColors(); nickList.SetListColors(); this.nickList.Header = iceChatLanguage.consoleTabTitle; nickListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; nickListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; serverListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; serverListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; channelListTab = new TabPage("Favorite Channels"); Panel channelPanel = new Panel(); channelPanel.Dock = DockStyle.Fill; channelPanel.Controls.Add(channelList); channelListTab.Controls.Add(channelPanel); channelListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; channelListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; buddyListTab = new TabPage("Buddy List"); Panel buddyPanel = new Panel(); buddyPanel.Dock = DockStyle.Fill; buddyPanel.Controls.Add(buddyList); buddyListTab.Controls.Add(buddyPanel); buddyListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; buddyListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; panelDockLeft.Width = iceChatOptions.LeftPanelWidth; panelDockRight.Width = iceChatOptions.RightPanelWidth; //Load the panel items in order if (iceChatOptions.LeftPanels != null) { foreach (string arrayitem in iceChatOptions.LeftPanels) { if (arrayitem == serverListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(serverListTab); else if (arrayitem == channelListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(channelListTab); else if (arrayitem == nickListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(nickListTab); else if (arrayitem == buddyListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(buddyListTab); } } if (iceChatOptions.RightPanels != null) { foreach (string arrayitem in iceChatOptions.RightPanels) { if (arrayitem == serverListTab.Text) this.panelDockRight.TabControl.TabPages.Add(serverListTab); else if (arrayitem == nickListTab.Text) this.panelDockRight.TabControl.TabPages.Add(nickListTab); else if (arrayitem == channelListTab.Text) this.panelDockRight.TabControl.TabPages.Add(channelListTab); else if (arrayitem == buddyListTab.Text) this.panelDockRight.TabControl.TabPages.Add(buddyListTab); } } //If any panels are missing if (!panelDockLeft.TabControl.TabPages.Contains(serverListTab) && !panelDockRight.TabControl.TabPages.Contains(serverListTab)) this.panelDockLeft.TabControl.TabPages.Add(serverListTab); if (!panelDockLeft.TabControl.TabPages.Contains(nickListTab) && !panelDockRight.TabControl.TabPages.Contains(nickListTab)) this.panelDockRight.TabControl.TabPages.Add(nickListTab); if (!panelDockLeft.TabControl.TabPages.Contains(channelListTab) && !panelDockRight.TabControl.TabPages.Contains(channelListTab)) this.panelDockRight.TabControl.TabPages.Add(channelListTab); if (!panelDockLeft.TabControl.TabPages.Contains(buddyListTab) && !panelDockRight.TabControl.TabPages.Contains(buddyListTab)) this.panelDockRight.TabControl.TabPages.Add(buddyListTab); this.MinimumSize = new Size(panelDockLeft.Width + panelDockRight.Width + 300, 300); //hide the left or right panel if it is empty if (panelDockLeft.TabControl.TabPages.Count == 0) { this.splitterLeft.Visible = false; panelDockLeft.Visible = false; this.MinimumSize = new Size(panelDockRight.Width + 300, 300); } if (panelDockRight.TabControl.TabPages.Count == 0) { this.splitterRight.Visible = false; panelDockRight.Visible = false; if (panelDockLeft.Visible) this.MinimumSize = new Size(panelDockLeft.Width + 300, 300); else this.MinimumSize = new Size(300, 300); } if (iceChatOptions.LockWindowSize) { fixWindowSizeToolStripMenuItem.Checked = true; this.FormBorderStyle = FormBorderStyle.FixedSingle; } nickList.Font = new Font(iceChatFonts.FontSettings[3].FontName, iceChatFonts.FontSettings[3].FontSize); serverTree.Font = new Font(iceChatFonts.FontSettings[4].FontName, iceChatFonts.FontSettings[4].FontSize); mainChannelBar.TabFont = new Font(iceChatFonts.FontSettings[8].FontName, iceChatFonts.FontSettings[8].FontSize); menuMainStrip.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize); toolStripMain.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize); inputPanel.OnCommand +=new InputPanel.OnCommandDelegate(inputPanel_OnCommand); inputPanel.InputBoxFont = new Font(iceChatFonts.FontSettings[5].FontName, iceChatFonts.FontSettings[5].FontSize); inputPanel.ShowColorPicker = iceChatOptions.ShowColorPicker; inputPanel.ShowEmoticonPicker = iceChatOptions.ShowEmoticonPicker; inputPanel.ShowBasicCommands = iceChatOptions.ShowBasicCommands; inputPanel.ShowSendButton = iceChatOptions.ShowSendButton; inputPanel.ShowWideTextPanel = iceChatOptions.ShowMultilineEditbox; if (iceChatOptions.ShowEmoticons == false) inputPanel.ShowEmoticonPicker = false; mainChannelBar.OnTabClosed += new ChannelBar.TabClosedDelegate(OnTabClosed); mainChannelBar.SelectedIndexChanged += new ChannelBar.TabEventHandler(OnTabSelectedIndexChanged); panelDockLeft.Initialize(); panelDockRight.Initialize(); if (iceChatOptions.DockLeftPanel == true) panelDockLeft.DockControl(); if (iceChatOptions.DockRightPanel == true) panelDockRight.DockControl(); LoadChannelSettings(); CreateDefaultConsoleWindow(); //**** WindowMessage(null, "Console", "\x000304Data Folder: " + currentFolder, "", true); WindowMessage(null, "Console", "\x000304Plugins Folder: " + pluginsFolder, "", true); WindowMessage(null, "Console", "\x000304Logs Folder: " + logsFolder, "", true); serverTree.NewServerConnection += new NewServerConnectionDelegate(NewServerConnection); serverTree.SaveDefault += new ServerTree.SaveDefaultDelegate(OnDefaultServerSettings); loadedPluginThemes = new List<IThemeIceChat>(); loadedPlugins = new List<Plugin>(); //load the plugin settings file LoadPluginFiles(); //load any plugin addons LoadPlugins(); //**** WindowMessage(null, "Console", "\x00034Using Theme - " + iceChatOptions.CurrentTheme, "", true); //set any plugins as disabled //add any items to the pluginsFile if they do not exist, or remove any that do not foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { bool found = false; for (int i = 0; i < iceChatPlugins.listPlugins.Count; i++) { if (iceChatPlugins.listPlugins[i].PluginFile.Equals(ipc.plugin.FileName)) { found = true; if (iceChatPlugins.listPlugins[i].Enabled == false) { WindowMessage(null, "Console", "\x000304Disabled Plugin - " + ipc.plugin.Name + " v" + ipc.plugin.Version, "", true); foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems) if (t.ToolTipText.ToLower() == ipc.plugin.FileName.ToLower()) t.Image = StaticMethods.LoadResourceImage("CloseButton.png"); ipc.plugin.Enabled = false; } } } if (found == false) { //plugin file not found in plugin Items file, add it PluginItem item = new PluginItem(); item.Enabled = true; item.PluginFile = ipc.plugin.FileName; iceChatPlugins.AddPlugin(item); SavePluginFiles(); } } } if (iceChatPlugins.listPlugins.Count != loadedPlugins.Count) { //find the file that is missing List<int> removeItems = new List<int>(); for (int i = 0; i < iceChatPlugins.listPlugins.Count; i++) { bool found = false; foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (iceChatPlugins.listPlugins[i].PluginFile.Equals(ipc.plugin.FileName)) found = true; } } if (found == false) removeItems.Add(i); } if (removeItems.Count > 0) { try { foreach (int i in removeItems) iceChatPlugins.listPlugins.Remove(iceChatPlugins.listPlugins[i]); } catch { } SavePluginFiles(); } } //initialize each of the plugins on its own thread foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (ipc.plugin.Enabled == true) { System.Threading.Thread initPlugin = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(InitializePlugin)); initPlugin.Start(ipc.plugin); } } } foreach (string s in errorMessages) { WindowMessage(null, "Console", "\x000304Error: " + s,"", true); } errorMessages.Clear(); pluginsToolStripMenuItem.DropDownOpening += new EventHandler(pluginsToolStripMenuItem_DropDownOpening); if (fileThemeFound == false) { //check for the Plugin File theme foreach (IThemeIceChat theme in IceChatPluginThemes) { if (theme.Name == iceChatOptions.CurrentTheme) { //update, this is the match iceChatColors.ChannelAdminColor = theme.ChannelAdminColor; iceChatColors.ChannelBackColor = theme.ChannelBackColor; iceChatColors.ChannelHalfOpColor = theme.ChannelHalfOpColor; iceChatColors.ChannelJoinColorChange = theme.ChannelJoinColorChange; iceChatColors.ChannelListBackColor = theme.ChannelListBackColor; iceChatColors.ChannelListForeColor = theme.ChannelListForeColor; iceChatColors.ChannelOpColor = theme.ChannelOpColor; iceChatColors.ChannelOwnerColor = theme.ChannelOwnerColor; iceChatColors.ChannelPartColorChange = theme.ChannelPartColorChange; iceChatColors.ChannelRegularColor = theme.ChannelRegularColor; iceChatColors.ChannelVoiceColor = theme.ChannelVoiceColor; iceChatColors.ConsoleBackColor = theme.ConsoleBackColor; iceChatColors.InputboxBackColor = theme.InputboxBackColor; iceChatColors.InputboxForeColor = theme.InputboxForeColor; iceChatColors.MenubarBackColor = theme.MenubarBackColor; iceChatColors.NewMessageColorChange = theme.NewMessageColorChange; iceChatColors.NickListBackColor = theme.NickListBackColor; iceChatColors.OtherMessageColorChange = theme.OtherMessageColorChange; iceChatColors.PanelHeaderBG1 = theme.PanelHeaderBG1; iceChatColors.PanelHeaderBG2 = theme.PanelHeaderBG2; iceChatColors.PanelHeaderForeColor = theme.PanelHeaderForeColor; iceChatColors.QueryBackColor = theme.QueryBackColor; iceChatColors.RandomizeNickColors = theme.RandomizeNickColors; iceChatColors.ServerListBackColor = theme.ServerListBackColor; iceChatColors.ServerMessageColorChange = theme.ServerMessageColorChange; iceChatColors.ServerQuitColorChange = theme.ServerQuitColorChange; iceChatColors.StatusbarBackColor = theme.StatusbarBackColor; iceChatColors.StatusbarForeColor = theme.StatusbarForeColor; iceChatColors.TabBarChannelJoin = theme.TabBarChannelJoin; iceChatColors.TabBarChannelPart = theme.TabBarChannelPart; iceChatColors.TabBarCurrent = theme.TabBarCurrent; iceChatColors.TabBarDefault = theme.TabBarDefault; iceChatColors.TabBarNewMessage = theme.TabBarNewMessage; iceChatColors.TabBarOtherMessage = theme.TabBarOtherMessage; iceChatColors.TabBarServerMessage = theme.TabBarServerMessage; iceChatColors.TabBarServerQuit = theme.TabBarServerQuit; iceChatColors.ToolbarBackColor = theme.ToolbarBackColor; iceChatColors.UnreadTextMarkerColor = theme.UnreadTextMarkerColor; inputPanel.SetInputBoxColors(); toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; serverListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; serverListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; nickListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; nickListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; channelListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; channelListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; buddyListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; buddyListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); nickList.SetListColors(); serverTree.SetListColors(); nickList.Invalidate(); mainChannelBar.Invalidate(); serverTree.Invalidate(); } } } //add the themes to the view menu if (iceChatOptions.Theme != null) { foreach (ThemeItem theme in iceChatOptions.Theme) { if (!theme.ThemeName.Equals("Default")) { ToolStripMenuItem t = new ToolStripMenuItem(theme.ThemeName); if (iceChatOptions.CurrentTheme == theme.ThemeName) t.Checked = true; t.Click += new EventHandler(themeChoice_Click); themesToolStripMenuItem.DropDownItems.Add(t); } } } this.FormClosing += new FormClosingEventHandler(FormMainClosing); this.Resize += new EventHandler(FormMainResize); if (iceChatOptions.IdentServer && !System.Diagnostics.Debugger.IsAttached) identServer = new IdentServer(); if (iceChatLanguage.LanguageName != "English") ApplyLanguage(); // ApplyLanguage can first be called after all child controls are created //get a new router ip if (!System.Diagnostics.Debugger.IsAttached) { if (iceChatOptions.DCCAutogetRouterIP == true) { System.Threading.Thread dccThread = new System.Threading.Thread(getLocalIPAddress); dccThread.Name = "DCCIPAutoUpdate"; dccThread.Start(); } } splash.Close(); splash.Dispose(); this.Activated += new EventHandler(FormMainActivated); nickList.ShowNickButtons = iceChatOptions.ShowNickButtons; serverTree.ShowServerButtons = iceChatOptions.ShowServerButtons; showButtonsNickListToolStripMenuItem.Checked = iceChatOptions.ShowNickButtons; showButtonsServerTreeToolStripMenuItem1.Checked = iceChatOptions.ShowServerButtons; // check for background images for nicklist and server tree if (iceChatOptions.NickListImage != null && iceChatOptions.NickListImage.Length > 0) { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.NickListImage)) this.nickList.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.NickListImage; else if (File.Exists(iceChatOptions.NickListImage)) this.nickList.BackGroundImage = iceChatOptions.NickListImage; } if (iceChatOptions.ServerTreeImage != null && iceChatOptions.ServerTreeImage.Length > 0) { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.ServerTreeImage)) this.serverTree.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.ServerTreeImage; else if (File.Exists(iceChatOptions.NickListImage)) this.serverTree.BackGroundImage = iceChatOptions.ServerTreeImage; } this.flashTrayIconTimer = new System.Timers.Timer(2000); this.flashTrayIconTimer.Enabled = false; this.flashTrayIconTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTrayIconTimer_Elapsed); this.notifyIcon.Tag = "off"; this.flashTrayCount = 0; this.flashTaskBarIconTimer = new System.Timers.Timer(2000); this.flashTaskBarIconTimer.Enabled = false; this.flashTaskBarIconTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTaskBarIconTimer_Elapsed); this.Tag = "off"; this.flashTrayCount = 0; //new toolstrip renderer for the main menu strip menuMainStrip.RenderMode = ToolStripRenderMode.System; toolStripMain.RenderMode = ToolStripRenderMode.System; //setup windowed mode if saved if (iceChatOptions.WindowedMode) { resizeWindowToolStripMenuItem.PerformClick(); } if (!System.Diagnostics.Debugger.IsAttached) { //check for an update and setup DDE, if NOT in debugger System.Threading.Thread checkThread = new System.Threading.Thread(checkForUpdate); checkThread.Start(); } System.Diagnostics.Debug.WriteLine(mainChannelBar.Height + ":" + mainChannelBar.Location.Y + ":" + mainChannelBar.Visible + ":" + mainChannelBar.Parent.Name); foreach (string s in args) { if (s.IndexOf(' ') > -1) _args += " \"" + s + "\""; else _args += " " + s; } }