示例#1
0
        public void ReadUserPosShapes()
        {
            string userFolder     = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "RebarPos");
            string userShapesFile = System.IO.Path.Combine(userFolder, "ShapeList.txt");

            try
            {
                if (System.IO.File.Exists(userShapesFile))
                {
                    PosShape.ClearPosShapes();
                    PosShape.ReadPosShapesFromFile(userShapesFile);
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "RebarPos", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void ApplyChanges()
        {
            string userFolder     = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "RebarPos");
            string userShapesFile = System.IO.Path.Combine(userFolder, "ShapeList.txt");
            string newShapesFile  = System.IO.Path.Combine(userFolder, "ShapeList.new");

            foreach (PosShape copy in m_Copies)
            {
                if (!copy.IsBuiltIn)
                {
                    if (PosShape.HasPosShape(copy.Name))
                    {
                        PosShape org = PosShape.GetPosShape(copy.Name);
                        org.Fields         = copy.Fields;
                        org.Formula        = copy.Formula;
                        org.FormulaBending = copy.FormulaBending;
                        org.Priority       = copy.Priority;
                        org.Items.Clear();
                        for (int i = 0; i < copy.Items.Count; i++)
                        {
                            org.Items.Add(copy.Items[i].Clone());
                        }
                    }
                    else
                    {
                        PosShape.AddPosShape(copy);
                    }
                }
            }

            try
            {
                PosShape.SavePosShapesToFile(newShapesFile);
                System.IO.File.Delete(userShapesFile);
                System.IO.File.Move(newShapesFile, userShapesFile);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Error: " + ex.Message, "RebarPos", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }

            PosShape.ReadPosShapesFromFile(userShapesFile);
        }