Ejemplo n.º 1
0
        private void reachSpecCalculatorThread_Done(object sender, RunWorkerCompletedEventArgs e)
        {
            List <string> badBases = (List <string>)e.Result;

            if (badBases != null && badBases.Count > 0)
            {
                //bad bases were found.
                ListDialog lw = new ListDialog(badBases, "Bad reachspecs found", badBases.Count + " bad ReachSpecs were found.");
                lw.ShowDialog();
            }
            //throw new NotImplementedException();
            recalculateButton.Enabled = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the click event for the "..." data source button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void btnDataSource_Click(object sender, EventArgs e)
        {
            if (ValidateToAddDataSource())
            {
                NamedObjectCollection<Field> columnNamesInLower = new NamedObjectCollection<Field>();
                int selectedIndex = 1;
                DataRowView item;
                string[] selectedViewFields = new string[lbxLinkedFields.SelectedItems.Count + 1];
                selectedViewFields[0] = field.Name;
                for (int i = 0; i < lbxLinkedFields.Items.Count; i++)
                {
                    item = (DataRowView)lbxLinkedFields.Items[i];
                    if (lbxLinkedFields.GetSelected(i))
                    {
                        selectedViewFields[selectedIndex] = item[lbxLinkedFields.DisplayMember].ToString();
                        DataRow selectRow = item.Row;
                        string fieldColumnName = (selectRow[ColumnNames.NAME].ToString());
                        string fieldStringID = (selectRow[ColumnNames.FIELD_ID].ToString());
                        if (DoesFieldNameExistInCollection(fieldColumnName, selectedFields) == false)
                        {
                            selectedFields.Add(page.GetView().GetFieldById(int.Parse(fieldStringID)));
                        }
                        selectedIndex++;
                    }
                }

                ListDialog codesDialog = new ListDialog((TableBasedDropDownField)this.Field, this.MainForm, txtFieldName.Text, this.page, selectedFields);
                DialogResult result = codesDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (!((string.IsNullOrEmpty(codesDialog.SourceTableName) && string.IsNullOrEmpty(codesDialog.TextColumnName))))
                    {
                        txtDataSource.Text = codesDialog.SourceTableName + " :: " + codesDialog.TextColumnName;
                        lbxLinkedFields.Enabled = false;
                        lblSelectFields.Enabled = false;
                        txtFieldName.Enabled = false;
                    }
                    else
                    {
                        //if code table has not been set - set these to empty
                        txtDataSource.Text = string.Empty;
                        field.SourceTableName = string.Empty;
                        field.TextColumnName = string.Empty;
                        lbxLinkedFields.Enabled = true;
                        lblSelectFields.Enabled = true;
                    }

                    this.sourceTableName = codesDialog.SourceTableName;
                    this.textColumnName = codesDialog.TextColumnName;
                    btnOk.Enabled = true;
                }
                btnOk.Enabled = true;
            }
            else
            {
                ShowErrorMessages();
            }
        }
Ejemplo n.º 3
0
		//Build mod to dropzone
		private bool buildMod(Mod mod, Dictionary<string, Mod> modFromPath)
		{
			Console.WriteLine("building mod " + mod.DisplayName);
			Stream readStream;
			try
			{
				readStream = new FileStream(mod.ModPath, FileMode.Open);
			}
			catch (IOException ex)
			{
				MessageBox.Show(ex.Message);
				return false;
			}

			ZipArchive archive = new ZipArchive(readStream, ZipArchiveMode.Read);

			//Get dropzones
			ArrayList dropzones = new ArrayList();
			Regex rx = new Regex("^((.*/)?dropzone)");
			foreach (ZipArchiveEntry ent in archive.Entries)
			{
				Match match = rx.Match(ent.FullName);
				string zone = match.Groups[1].Value;
				if (match.Success && !dropzones.Contains(zone))
				{
					dropzones.Add(zone);
				}
			}

			//Get single dropzone
			string dropzone = "";
			if (dropzones.Count == 0)
			{
				readStream.Close();
				MessageBox.Show("Mod " + mod.DisplayName + " has no dropzone.");
				return false;
			}
			else if (dropzones.Count == 1)
			{
				dropzone = (string)dropzones[0];
			}
			else
			{
				string caption = mod.DisplayName + " has multiple options. Choose one.";
				ListDialog dialog = new ListDialog(mod.DisplayName, caption, dropzones);
				int i = dialog.ShowDialog();
				if (i == -1)
				{
					readStream.Close();
					return false;
				}
				else
				{
					dropzone = (string)dropzones[i];
				}
			}

			foreach (ZipArchiveEntry ent in archive.Entries)
			{
				if (!ent.FullName.StartsWith(dropzone))
				{
					continue;
				}

				string relPath = ent.FullName.Replace(dropzone, "");
				if (relPath[0] == '/')
				{
					relPath = relPath.Substring(1);
				}

				string outPath = Path.Combine(dropzoneDir, relPath);

				//If it's a directory, create it
				if (ent.FullName.EndsWith("/"))
				{
					Console.WriteLine("mkdir " + outPath);
					mkdir(outPath);
				}

				//If not, write the file
				else
				{
					//Check if mod collides with an existing mod
					Mod collidesWith;
					if (modFromPath.TryGetValue(relPath, out collidesWith))
					{
						readStream.Close();
						MessageBox.Show(
							"Mod '" + mod.DisplayName + "'" +
							" collides with '" + collidesWith.DisplayName + "'."
						);
						return false;
					}
					modFromPath.Add(relPath, mod);

					//Write entry to file
					Console.WriteLine("write " + outPath);
					Stream writeStream = File.Create(outPath);
					Stream stream = ent.Open();
					stream.CopyTo(writeStream);
					writeStream.Close();
					stream.Close();
				}
			}

			readStream.Close();
			return true;
		}