private void ItemsListBox_DoubleClick(object sender, EventArgs e) { PropertiesBox.Clear(); foreach (int i in RequirementsCheckedListBox.CheckedIndices) { RequirementsCheckedListBox.SetItemChecked(i, false); } Item Selected = (Item)ItemsListBox.SelectedItem; NameBox.Text = Selected.Name; TypeBox.Text = Selected.Type; DescriptionBox.Text = Selected.Description; MightBox.Text = Selected.Bonus.Find(t => t.Item1 == "Might").Item2.ToString(); DefenceBox.Text = Selected.Bonus.Find(t => t.Item1 == "Defence").Item2.ToString(); WeightBox.Text = Selected.Bonus.Find(t => t.Item1 == "CarryWeight").Item2.ToString(); ItemWeightBox.Text = Selected.Weight.ToString(); for (int i = 0; i < Selected.Requirements.Count; i++) { for (int j = 0; j < RequirementsCheckedListBox.Items.Count; j++) { if (Selected.Requirements[i] == RequirementsCheckedListBox.Items[j].ToString()) { RequirementsCheckedListBox.SetItemChecked(j, true); } } } foreach (string property in Selected.Properties) { PropertiesBox.AppendText(property + "\n"); } }
private void EntityTreeview_AfterSelect(object sender, TreeViewEventArgs e) { WindWakerEntityData.BaseChunk chunk = e.Node.Tag as WindWakerEntityData.BaseChunk; if (chunk != null) { //Temp e.Node.ContextMenuStrip = contextEntityTreeRoot; contextEntityTreeRoot.Tag = chunk; //Find the Editor Type attribute. EntEditorType editorType = null; WindWakerEntityData.PlyrChunk plyr = chunk as WindWakerEntityData.PlyrChunk;; if (chunk.GetType().IsDefined(typeof(EntEditorType), true)) { Console.WriteLine("Yes!"); editorType = (EntEditorType)chunk.GetType().GetCustomAttributes(typeof(EntEditorType), false)[0]; } Type editType = null; if (editorType == null) { editType = typeof(UnsupportedEntity); } else { editType = editorType.EditorType(); } UserControl obj = Activator.CreateInstance(editType) as UserControl; obj.Dock = DockStyle.Fill; PropertiesBox.SuspendLayout(); //Dispose of the control manually right now so that they un-register their event //handler to MainForm::SelectedEntityChanged foreach (Control control in PropertiesBox.Controls) { control.Dispose(); } PropertiesBox.Controls.Clear(); PropertiesBox.Controls.Add(obj); PropertiesBox.ResumeLayout(true); if (editorType != null && MainSplitter.Panel2.Width < editorType.MinEditorWidth) { MainSplitter.SplitterDistance = MainSplitter.Width - editorType.MinEditorWidth; } if (SelectedEntityChanged != null) { SelectedEntityChanged(chunk); } } }
public void ShowProperties() { if (!FormPropertiesOpen) { FormProperties = new PropertiesBox(conf); } else if (FormProperties.WindowState == FormWindowState.Minimized) { FormProperties.WindowState = FormWindowState.Normal; } FormProperties.Show(); FormProperties.Focus(); }
private void ItemDetailsForm_Load(object sender, EventArgs e) { NameBox.Text = CurrentItem.Name; TypeBox.Text = CurrentItem.Type; DescriptionBox.Text = CurrentItem.Description; MightBox.Text = CurrentItem.Bonus.Find(t => t.Item1 == "Might").Item2.ToString(); DefenceBox.Text = CurrentItem.Bonus.Find(t => t.Item1 == "Defence").Item2.ToString(); WeightBox.Text = CurrentItem.Bonus.Find(t => t.Item1 == "CarryWeight").Item2.ToString(); ItemWeightBox.Text = CurrentItem.Weight.ToString(); foreach (string req in CurrentItem.Requirements) { RequirementsBox.AppendText(req + Environment.NewLine); } foreach (string prop in CurrentItem.Properties) { PropertiesBox.AppendText(prop + Environment.NewLine); } }
private void DeleteButton_Click(object sender, EventArgs e) { ItemsList.RemoveAt(ItemsListBox.SelectedIndex); ListBind.DataSource = null; ListBind.DataSource = ItemsList; NameBox.Clear(); TypeBox.Clear(); DescriptionBox.Clear(); MightBox.Clear(); DefenceBox.Clear(); WeightBox.Clear(); ItemWeightBox.Clear(); PropertiesBox.Clear(); foreach (int i in RequirementsCheckedListBox.CheckedIndices) { RequirementsCheckedListBox.SetItemChecked(i, false); } }
private void AddButton_Click(object sender, EventArgs e) { string name, type, description; int weight, might, defence, carryweight; List <string> requirements = new List <string>(); List <string> properties; List <Tuple <string, int> > bonus = new List <Tuple <string, int> >(); if (NameBox.Text == "") { MessageBox.Show("Puste pole na imię!"); return; } else { name = NameBox.Text; } if (TypeBox.Text == "") { MessageBox.Show("Puste pole określające typ przedmiotu!"); return; } else { type = TypeBox.Text; } if (DescriptionBox.Text == "") { MessageBox.Show("Puste pole opisu!"); return; } else { description = DescriptionBox.Text; } int.TryParse(ItemWeightBox.Text, out weight); if (weight == 0) { MessageBox.Show("Błąd w polu określającym wagę przedmiotu!"); return; } bool might_result = int.TryParse(MightBox.Text, out might); bool defence_result = int.TryParse(DefenceBox.Text, out defence); bool carryweight_result = int.TryParse(WeightBox.Text, out carryweight); if (!might_result || !defence_result || !carryweight_result) { MessageBox.Show("Błąd w polach określających bonusy!"); return; } else { Tuple <string, int> MightTuple = new Tuple <string, int>("Might", might); Tuple <string, int> DefenceTuple = new Tuple <string, int>("Defence", defence); Tuple <string, int> CarryWeightTuple = new Tuple <string, int>("CarryWeight", carryweight); bonus.Add(MightTuple); bonus.Add(DefenceTuple); bonus.Add(CarryWeightTuple); } if (RequirementsCheckedListBox.CheckedItems.Count == 0) { requirements.Add("Any"); } else { foreach (object item in RequirementsCheckedListBox.CheckedItems) { requirements.Add(item.ToString()); } } properties = new List <string>(PropertiesBox.Lines); Item New_Item = new Item(name, type, description, requirements, bonus, properties, weight); ItemsList.Add(New_Item); ListBind.DataSource = null; ListBind.DataSource = ItemsList; NameBox.Clear(); TypeBox.Clear(); DescriptionBox.Clear(); MightBox.Clear(); DefenceBox.Clear(); WeightBox.Clear(); ItemWeightBox.Clear(); PropertiesBox.Clear(); foreach (int i in RequirementsCheckedListBox.CheckedIndices) { RequirementsCheckedListBox.SetItemChecked(i, false); } }