Esempio n. 1
0
        private void Mnu_reGroupData_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Regrouping the set can remove any groups that you have created thus far, do you want to proceed?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Stop);

            if (result == MessageBoxResult.Yes)
            {
                CarboSettings settings = new CarboSettings().Load();

                //CarboGroupSettings groupSettings = new CarboGroupSettings();
                //groupSettings = groupSettings.DeSerializeXML();

                GroupWindow importGroupWindow = new GroupWindow(CarboLifeProject.getAllElements, CarboLifeProject.CarboDatabase, settings);
                importGroupWindow.ShowDialog();
                if (importGroupWindow.dialogOk == true)
                {
                    //Save non-element items;

                    ObservableCollection <CarboGroup> userGroups = new ObservableCollection <CarboGroup>();
                    userGroups = CarboLifeProject.GetGroupsWithoutElements();

                    CarboLifeProject.SetGroups(importGroupWindow.carboGroupList);
                    CarboLifeProject.AddGroups(userGroups);
                    refreshData();
                }
            }
        }
        public CarboSettingsMenu()
        {
            // templatePath = "";

            settings = new CarboSettings().Load();


            InitializeComponent();
        }
Esempio n. 3
0
        public GroupWindow(ObservableCollection <CarboElement> elementList, CarboDatabase userMaterialData, CarboSettings groupSettings)
        {
            dialogOk           = false;
            carboElementList   = elementList;
            carboGroupList     = new ObservableCollection <CarboGroup>();
            carboGroupSettings = groupSettings;

            materialData = userMaterialData;
            InitializeComponent();
        }
Esempio n. 4
0
        /// <summary>
        /// Finds the location of the Carbo Life Calculator Template File
        /// </summary>
        /// <returns>Template Path</returns>
        public static string getTemplateFolder(bool local = true)
        {
            try
            {
                CarboSettings settings = new CarboSettings().Load();

                string templatetarget = settings.templatePath;
                string myLocalPath    = getAssemblyPath() + "\\db\\" + "UserMaterials.cxml";

                if (File.Exists(templatetarget))
                {
                    return(templatetarget);
                }
                else if (File.Exists(myLocalPath))
                {
                    //Fix the setting;
                    settings.templatePath = myLocalPath;
                    settings.Save();
                    MessageBox.Show("The template file could not be found at: " + templatetarget + Environment.NewLine + "The local template file will be used at: " + myLocalPath, "Warning", MessageBoxButton.OK);
                    return(myLocalPath);
                }
                else
                {
                    MessageBox.Show("Could not find a path reference to the template file, you possibly have to re-install the software" + Environment.NewLine +
                                    "Target: " + templatetarget + Environment.NewLine +
                                    "Target: " + myLocalPath, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return("");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return("");
            }
            //return "";
        }
Esempio n. 5
0
        public static void CheckFileLocations()
        {
            string log = "";

            string pathDatabase = Utils.getAssemblyPath() + "\\db\\";
            string bufferPath   = pathDatabase + "MaterialBuffer.cxml";
            string targetPath   = pathDatabase + "UserMaterials.cxml";

            //This bit will prevent the user files to be ever overwritten
            if (!(File.Exists(targetPath)))
            {
                if (File.Exists(bufferPath))
                {
                    File.Copy(bufferPath, targetPath);
                }
            }

            //All userfiles need to move to the local folder:
            string appdatafolder     = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\";
            string TemplateFile      = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\UserMaterials.cxml";
            string SettingsFile      = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\CarboSettings.xml";
            string RevitSettingsFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\RevitImportSettings.xml";
            //string GroupSettingsFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\GroupSettings.xml";

            bool firstLaunch = false;

            try
            {
                //Directory
                if (!Directory.Exists(appdatafolder))
                {
                    //This must be the first time you load Carbo Life Calc, we will be copying the template file to:
                    MessageBox.Show("Hi, this must be the first time you are using Carbo Life Calculator, I will now copy a material template file to: " + appdatafolder + Environment.NewLine + " This will be your default template file ", "Welcome", MessageBoxButton.OK);
                    Directory.CreateDirectory(appdatafolder);
                    Directory.CreateDirectory(appdatafolder + "\\online\\");

                    log += appdatafolder + " created" + Environment.NewLine;
                    log += appdatafolder + "\\online\\" + " created" + Environment.NewLine;

                    firstLaunch = true;
                }

                //SettingsFile
                if (!(File.Exists(SettingsFile)))
                {
                    if (File.Exists(pathDatabase + "CarboSettings.xml"))
                    {
                        File.Copy(pathDatabase + "CarboSettings.xml", SettingsFile);
                        log += SettingsFile + " Copied" + Environment.NewLine;
                    }
                }

                //Revit Import Settings
                if (!(File.Exists(RevitSettingsFile)))
                {
                    if (File.Exists(pathDatabase + "RevitImportSettings.xml"))
                    {
                        File.Copy(pathDatabase + "RevitImportSettings.xml", RevitSettingsFile);
                        log += RevitSettingsFile + " Copied" + Environment.NewLine;
                    }
                }

                //Material Template
                if (!(File.Exists(TemplateFile)))
                {
                    if (File.Exists(bufferPath))
                    {
                        File.Copy(bufferPath, TemplateFile);
                        log += TemplateFile + " Copied" + Environment.NewLine;
                    }
                }

                //Set the path to the template, ONLY when it's the first launch.
                if (firstLaunch == true)
                {
                    CarboSettings settings = new CarboSettings().Load();
                    settings.templatePath = appdatafolder + "UserMaterials.cxml";
                    settings.Save();
                    log += settings.templatePath + " Set as template file" + Environment.NewLine;
                }
                if (log != "")
                {
                    log += "Successfully Created Project Files: " + Environment.NewLine;
                    MessageBox.Show(log);
                }
            }
            catch (Exception ex)
            {
                log += "Error: " + ex.Message + Environment.NewLine;

                MessageBox.Show(log);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Sets and prepares the usermaterials and settings File
        /// </summary>
        public static void CheckFileLocationsNew()
        {
            bool okSettingFile      = false;
            bool okTemplate         = false;
            bool okRevitSettingFile = false;
            bool firstLaunch        = false;

            string log = "";

            string pathDatabase = Utils.getAssemblyPath() + "\\db\\";

            string bufferPath = pathDatabase + "MaterialBuffer.cxml";


            //All the following three files bust be present:
            string TemplateFile      = pathDatabase + "UserMaterials.cxml";
            string SettingsFile      = pathDatabase + "CarboSettings.xml";
            string RevitSettingsFile = pathDatabase + "RevitImportSettings.xml";

            //string GroupSettingsFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\CarboLifeCalc\\GroupSettings.xml";


            try
            {
                //This bit will prevent the user files to be ever overwritten
                if (!(File.Exists(TemplateFile)))
                {
                    //If we dont have a template, create one:
                    if (File.Exists(bufferPath))
                    {
                        File.Copy(bufferPath, TemplateFile);
                        okTemplate  = true;
                        firstLaunch = true;
                    }
                }

                //SettingsFile
                if (File.Exists(SettingsFile))
                {
                    okSettingFile = true;
                    CarboSettings settings = new CarboSettings().Load();
                    if (settings.firstLaunch == true)
                    {
                        firstLaunch = true;
                    }
                }
                else
                {
                    log += SettingsFile + " Not Found" + Environment.NewLine;
                }

                //Revit Import Settings
                if (File.Exists(RevitSettingsFile))
                {
                    okRevitSettingFile = true;
                }
                else
                {
                    log += RevitSettingsFile + " Not Found" + Environment.NewLine;
                }

                //If the app was downloaded from the Autodesk store we need to set the template file as it will always be part of the application:


                //Set the path to the template, ONLY when it's the first launch.
                if (firstLaunch == true)
                {
                    CarboSettings settings = new CarboSettings().Load();
                    settings.templatePath = TemplateFile;
                    settings.Save();
                    log += "Hi, this is most likely the first time you started Carbo Life Calculator. " + Environment.NewLine + " To store all your embodied carbon materials this program needs a template file." + Environment.NewLine + "This has been set to the following file: " + Environment.NewLine
                           + settings.templatePath + Environment.NewLine
                           + "You are all good to go now, good luck!";

                    settings.firstLaunch = false;
                    settings.Save();
                }

                if (log != "")
                {
                    MessageBox.Show(log);
                }
            }
            catch (Exception ex)
            {
                log += "Error: " + ex.Message + Environment.NewLine;

                MessageBox.Show(log);
            }
        }