Example #1
0
        public Form1(Data data, ItemChecker ItemC, StartForm startform)
        {
            serialize = new Serialize();
            this.Data = data;
            this.Startform = startform;
            this.itemchecker = ItemC;
            this.GuiC = new GUIControl(this.itemchecker);

            InitializeComponent();
            this.Text = data.getfilename() + " - MCItemChecker";
            GuiC.UpdateListview(lvitems, itemchecker.Items);

            lvitems.ListViewItemSorter = GuiC.ColumnSorter;

            Initlvitems();
            Initlvsubitems();
            Initlvcalculateitems();

            UpdateModPackControls();
            UpdateItemTypeControls();
            cbfiltertype.SelectedItem = "-";
            cbsearchmodpack.SelectedItem = "-";
            cbsearchtype.SelectedItem = "-";

            litemid.Text = "";
            litemname.Text = "";
            litemtype.Text = "";
            lmodpack.Text = "";
        }
Example #2
0
 /// <summary>
 /// Constructor for creating NewItem Form with it's required components.
 /// </summary>
 /// <param name="IC">ItemChecker Class.</param>
 /// <param name="lvwColumnSorter">Columnsorter class, used to sort listviews.</param>
 /// <param name="mainform">MainForm Class, is called to update item information.</param>
 /// <param name="t"abname>Name of the tab that should be opened on start-up.</param>
 public NewItem(ItemChecker IC, GUIControl guic, Form1 mainform, string tabname)
     : this(IC, guic, mainform)
 {
     if (tabname == "Items")
     {
         tabControl1.SelectedTab = TabNewItem;
     }
     else if (tabname == "Modpack")
     {
         tabControl1.SelectedTab = TabModPack;
     }
     else if (tabname == "Types")
     {
         tabControl1.SelectedTab = TabType;
     }
 }
Example #3
0
 /// <summary>
 /// Initialises the Form1 class.
 /// </summary>
 /// <param name="d">The Data Class</param>
 /// <param name="i">The ItemChecker Class</param>
 public void GoToMainForm(Data d, ItemChecker i)
 {
     if (d == null)
     {
         MessageBox.Show("The data file wasn't loaded properly, try restarting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (i == null)
     {
         MessageBox.Show("The .item file wasn''t loaded properly, try re-opening", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Mainform = new Form1(data, ItemC, this);
         this.Hide();
         Mainform.Show();
     }
 }
Example #4
0
        /// <summary>
        /// Constructor for creating NewItem Form with it's required components.
        /// </summary>
        /// <param name="IC">ItemChecker Class.</param>
        /// <param name="lvwColumnSorter">Columnsorter class, used to sort listviews.</param>
        /// <param name="mainform">MainForm Class, is called to update item information.</param>
        public NewItem(ItemChecker IC, GUIControl guic, Form1 mainform)
            : this()
        {
            this.itemchecker = IC;
            this.Mainform = mainform;
            this.GuiC = guic;
            lvitems.ListViewItemSorter = GuiC.ColumnSorter;
            tbadd.Text = "1";
            tbremove.Text = "1";

            this.Text = Mainform.Text;

            UpdateTypeControls();
            UpdateModPackControls();
            cbmodpack.SelectedItem = "-";
            cbsearchmodpack.SelectedItem = "-";
            cbsearchtype.SelectedItem = "-";
            cbtype.SelectedItem = "-";

            Initlvitems();
            Initlvsubitems();
        }
Example #5
0
 public GUIControl(ItemChecker ic)
     : this()
 {
     IC = ic;
 }
Example #6
0
 public void UpdateItemC(ItemChecker I)
 {
     this.ItemC = I;
 }
Example #7
0
 private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog openfiledialog = new OpenFileDialog();
     if (openfiledialog.ShowDialog() == DialogResult.OK)
     {
         if (serializeData.LoadItemChecker(openfiledialog.FileName) != null)
         {
             ItemC = serializeData.LoadItemChecker(openfiledialog.FileName);
             data.Filepath = openfiledialog.FileName;
             if (savedatafile())
             {
                 tbpath.Text = data.Filepath;
             }
             GoToMainForm(this.data, this.ItemC);
         }
         else
         {
             MessageBox.Show("Failed to open .Item file!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #8
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ItemC = new ItemChecker();
     CreateNeworRenameFile(ItemC);
     GoToMainForm(this.data, this.ItemC);
 }
Example #9
0
 /// <summary>
 /// Method used to create, replace or rename an .item file.
 /// </summary>
 /// <param name="ic"></param>
 /// <returns></returns>
 private Boolean CreateNeworRenameFile(ItemChecker ic)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Filter = "ItemList File|*.item";
     saveFileDialog.Title = "Save an .Item File";
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         data.SetFilePath(saveFileDialog.FileName);
     }
     //Tries to create a new Itemchecker file with the user specified filename.
     if (!serializeData.SaveFile(ic, data.Filepath))
     {
         MessageBox.Show("Could not create a new .item file" + Environment.NewLine + "Make sure you have enough rights to create this file in:" + Environment.NewLine + serializeData.Dir, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     else
     {
         if (savedatafile())
         {
             tbpath.Text = data.Filepath;
         }
         return true;
     }
 }
Example #10
0
 /// <summary>
 /// Tries to load the itemchecker class based on the information from the data class.
 /// Creates a new itemchecker class when the data class doesn't specify it's location.
 /// </summary>
 /// <returns>returns false when the itemchecker file couldn't be loaded or created</returns>
 private Boolean CheckItemCheckerFile()
 {
     //Checks if the Filename field is empty.
     if (data.Filepath == null)
     {
         DialogResult dialogResult = MessageBox.Show("No .item file was found!" + Environment.NewLine + "Do tou want to create a new file?", "No File Found!", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             SaveFileDialog saveFileDialog = new SaveFileDialog();
             saveFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
             saveFileDialog.Filter = "ItemList File|*.item";
             saveFileDialog.Title = "Save an .Item File";
             if (saveFileDialog.ShowDialog() == DialogResult.OK)
             {
                 data.SetFilePath(saveFileDialog.FileName);
             }
             ItemC = new ItemChecker();
             //Tries to create a new Itemchecker file with the user specified filename.
             if (!serializeData.SaveFile(ItemC, data.Filepath))
             {
                 MessageBox.Show("Could not create a new .item file" + Environment.NewLine + "Make sure you have enough rights to create this file in:" + Environment.NewLine + serializeData.Dir, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return false;
             }
             else
             {
                 if (savedatafile())
                 {
                     tbpath.Text = data.Filepath;
                 }
                 return true;
             }
         }
     }
     else
     {
         //Tries to load the data file into the data class.
         if (serializeData.LoadItemChecker(data.Filepath) != null)
         {
             ItemC = new ItemChecker();
             ItemC = (serializeData.LoadItemChecker(data.Filepath));
             return true;
         }
         MessageBox.Show("Could not access the .item file" + Environment.NewLine + "Make sure the file is in the correct path. Try opening again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
     return false;
 }