コード例 #1
0
        private void btnCreateProject_Click(object sender, RoutedEventArgs e)
        {
            if (currentHousePlan != null)
            {
                if (currentHousePlan.GetWalls().Count == 0)
                {
                    HousePlanControl currentHousePlanControl = listViewHousePlans.SelectedItem as HousePlanControl;
                    if (currentHousePlanControl == null)
                    {
                        MessageBox.Show("Select a house plan!");
                        return;
                    }

                    currentHousePlan = currentHousePlanControl.GetCurrentHousePlan();
                }

                if (projectProperties.CheckEmptyFields() == true)
                {
                    MessageBox.Show("Complete mandatory fields!");
                    return;
                }

                if (projectProperties.CheckValidFields() == false)
                {
                    return;
                }

                List <Wall> walls = currentHousePlan.GetWalls();
                Project.UnitOfMeasurement measurementUnit = Project.UnitOfMeasurement.mm;
                float wallsHeight = Convert.ToSingle(projectProperties.textBoxWallsHeight.Text);

                if (projectProperties.comboBoxMeasurementUnits.Text == Project.UnitOfMeasurement.m.ToString())
                {
                    wallsHeight    *= 1000;
                    measurementUnit = Project.UnitOfMeasurement.m;
                }
                if (projectProperties.comboBoxMeasurementUnits.Text == Project.UnitOfMeasurement.cm.ToString())
                {
                    wallsHeight    *= 10;
                    measurementUnit = Project.UnitOfMeasurement.cm;
                }
                Client client = new Client(projectProperties.textBoxClientName.Text, Convert.ToInt64(projectProperties.textBoxTelephoneNumber.Text),
                                           projectProperties.textBoxEmailAddress.Text);
                Decimal budget = Convert.ToDecimal(projectProperties.textBoxBudget.Text);
                String  notes  = projectProperties.textBoxNotes.Text;
                Scene   scene  = new Scene();
                scene.MainCamera.Translate = new Point3d(0, 500, 0);
                scene.MainCamera.Rotate    = new Point3d(-90, 180, 0);
                for (int i = 0; i < walls.Count; i++)
                {
                    WallObject wall = new WallObject(walls[i], wallsHeight);
                    scene.AddWall(wall);
                }
                currentProject = new Project(client, scene, configuration, CurrencyHelper.GetProjectCurrency(), wallsHeight, budget,
                                             notes, measurementUnit);

                this.Close();
            }
        }
コード例 #2
0
        public void InitializeHousePlans()
        {
            try
            {
                string[] files = Directory.GetFiles(housePlansDirectory, "*.hpl");
                foreach (string file in files)
                {
                    String[]  tokens = file.Split('.');
                    String[]  currentDirectoryPath = tokens[0].Split('\\');
                    String    fileName             = currentDirectoryPath[currentDirectoryPath.GetLength(0) - 1];
                    HousePlan housePlan            = new HousePlan(fileName);
                    housePlans.Add(housePlan);
                    HousePlanControl housePlanControl = new HousePlanControl(housePlan);
                    housePlanControl.MouseLeftButtonDown += housePlanControl_MouseLeftButtonDown;

                    listViewHousePlans.Items.Add(housePlanControl);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }