コード例 #1
0
ファイル: Time Tracker.cs プロジェクト: MJB288/Mabi-Tools
 private void btnSave_Click(object sender, EventArgs e)
 {
     commerceCaller.TimeData = TimeData;
     CommerceDataHandler.saveTimeData(Settings.Default.TimeFilePath, TimeData);
     updateBelvastTime();
     this.Close();
 }
コード例 #2
0
ファイル: Commerce.cs プロジェクト: MJB288/Mabi-Tools
        /// <summary>
        /// A method for regenerating the graphs from the TimeData dictionary. Used both at startup and for instaces where the TimeData may be altered.
        /// </summary>
        private void generateGraphs()
        {
            SingletonGraphFactory graphFactory = SingletonGraphFactory.getFactory();

            GraphsbyTransport = new Dictionary <String, Graph>();
            foreach (KeyValuePair <String, Dictionary <String, List <TimeSpan> > > transportToTime in TimeData)
            {
                GraphsbyTransport[transportToTime.Key] = graphFactory.constructGraph(CommerceDataHandler.compressTimeData(transportToTime.Value));
            }
        }
コード例 #3
0
ファイル: Commerce.cs プロジェクト: MJB288/Mabi-Tools
        /// <summary>
        /// A function that loads all of the data at startup time
        /// </summary>
        private void loadDataStartup()
        {
            //Todo:Have some sort of settings to allow the user to specify which file they use for each set of data
            try
            {
                CityData = CommerceDataHandler.loadCommerceData(Settings.Default.CityFilePath);
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("Error while loading City data : \n" + ex.Message, "Error");
                //We can't proceed without city data - close
                this.Close();
            }

            try
            {
                TransportData = CommerceDataHandler.loadTransportData(Settings.Default.TransportFilePath);
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("Error while loading Transport Data : \n" + ex.Message, "Error");
                this.Close();
            }

            try
            {
                TimeData = CommerceDataHandler.loadTimeData(Settings.Default.TimeFilePath);
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("Error while loading Transport Data : \n" + ex.Message, "Error");
                this.Close();
            }

            try
            {
                MasteryData = CommerceDataHandler.loadCMasteryData(Settings.Default.MasteryFilePath);
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("Error while loading Mastery Data : \n" + ex.Message, "Error");
                this.Close();
            }
        }
コード例 #4
0
ファイル: Transport Editor.cs プロジェクト: MJB288/Mabi-Tools
        private void btnSave_Click(object sender, EventArgs e)
        {
            Dictionary <String, Transport> newData = new Dictionary <string, Transport>();

            //This will be very similar to the Commerce City Editor save method - only this time we don't need to check for goods being equal to 0
            for (int i = 0; i < clboxTransport.Items.Count; i++)
            {
                //Check if item is null or has a good count of 0
                if (TransportData[clboxTransport.Items[i].ToString()] == null)
                {
                    //Set it to null (nothing is changed if already null) so that save function doesn't write it
                    TransportData[clboxTransport.Items[i].ToString()] = null;
                    continue;
                }
                //Since the only order to dictionary keys are the order they are inserted and can't be rearranged - we have to construct a new dictionary with the user intended order
                //for the order change to show up in frmCommerce
                newData[clboxTransport.Items[i].ToString()] = TransportData[clboxTransport.Items[i].ToString()];
            }
            Commerce.TransportData = newData;
            CommerceDataHandler.saveTransportDataOrdered(Settings.Default.TransportFilePath, TransportData, clboxTransport);
            this.Close();
        }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Save the data and apply it to the form sent to us
            Dictionary <String, City> newData = new Dictionary <string, City>();


            //TODO-Add a check before saving that all cities have at least one good
            for (int i = 0; i < clboxCities.Items.Count; i++)
            {
                //Check if item is null or has a good count of 0
                if (CityData[clboxCities.Items[i].ToString()] == null || CityData[clboxCities.Items[i].ToString()].goods.Count == 0)
                {
                    //Set it to null (nothing is changed if already null) so that save function doesn't write it
                    CityData[clboxCities.Items[i].ToString()] = null;
                    continue;
                }
                //Since the only order to dictionary keys are the order they are inserted and can't be rearranged - we have to construct a new dictionary with the user intended order
                //for the order change to show up in frmCommerce
                newData[clboxCities.Items[i].ToString()] = CityData[clboxCities.Items[i].ToString()];
            }
            commerce.CityData = newData;
            CommerceDataHandler.saveCommerceDataOrdered(Settings.Default.CityFilePath, CityData, clboxCities);
            this.Close();
        }