private void element_RightClick(GenericElement sender)
        {
            UnSelectAllElement();
            UnSelectAllVariable();
            sender.IsSelected = true;
            UpdateContextMenu(sender.ID, sender.GetType() == typeof(VariableElement));
            Point clientPoint = sender.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));

            ctxMnuElement.Show(sender, clientPoint);
        }
Esempio n. 2
0
        public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch)
        {
            ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>();

            try
            {
                ProcessUnit unit = new ProcessUnit();
                ObservableCollection <GenericElement> elements = batch.Target.Elements;
                for (int i = 0; i < elements.Count; i++)
                {
                    GenericElement element     = elements[i];
                    string         elementType = element.GetType().Name;
                    switch (elementType)
                    {
                    case "OpenModel":
                        OpenModel openModel = element as OpenModel;
                        if (openModel.FileExtension == ".smc")
                        {
                            unit.OpenSolibri = openModel;
                        }
                        else if (openModel.FileExtension == ".ifc")
                        {
                            unit.IfcFiles.Add(openModel);
                        }
                        break;

                    case "BCFReport":
                        unit.BCFReport = element as BCFReport;
                        break;

                    case "SaveModel":
                        unit.SaveSolibri = element as SaveModel;
                        if (unit.IfcFiles.Count > 0)
                        {
                            unit.OpenSolibri = new OpenModel(unit.SaveSolibri.File);
                        }
                        break;

                    case "CloseModel":
                        processUnits.Add(unit);
                        unit = new ProcessUnit();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(processUnits);
        }
        private void addElement(GenericElement sender)
        {
            GenericElement elementToAdd = GetSelectedElement(sender);

            tlpElements.Controls.Add(elementToAdd);
            elementToAdd.Dock                = DockStyle.Fill;
            elementToAdd.IsTemplate          = false;
            elementToAdd.ElementSelect      += new GenericElement.ElementSelectEventHandler(element_OnSelect);
            elementToAdd.ElementRightClick  += new GenericElement.ElementRightClickEventHandler(element_RightClick);
            elementToAdd.ElementDoubleClick += new GenericElement.ElementDoubleClickEventHandler(elements_DoubleClick);
            if (elementToAdd.GetType() == typeof(VariableElement))
            {
                variables.Add((VariableElement)elementToAdd);
            }
            else
            {
                elements.Add(elementToAdd);
            }
        }
Esempio n. 4
0
        public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch)
        {
            ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>();

            try
            {
                ProcessUnit unit = new ProcessUnit();
                ObservableCollection <GenericElement> elements = batch.Target.Elements;
                for (int i = 0; i < elements.Count; i++)
                {
                    GenericElement element     = elements[i];
                    string         elementType = element.GetType().Name;
                    switch (elementType)
                    {
                    case "OpenModel":
                        OpenModel openModel = element as OpenModel;
                        if (openModel.FileExtension == ".smc")
                        {
                            unit.OpenSolibri = openModel;
                        }
                        else if (modelExtensions.Contains(openModel.FileExtension))
                        {
                            InputModel modeltoOpen = new InputModel(openModel);
                            unit.Models.Add(modeltoOpen);
                        }
                        break;

                    case "UpdateModel":
                        UpdateModel updateModel   = element as UpdateModel;
                        InputModel  modeltoUpdate = new InputModel(updateModel);
                        unit.Models.Add(modeltoUpdate);
                        break;

                    case "OpenRuleset":
                        OpenRuleset ruleset = element as OpenRuleset;
                        unit.Rulesets.Add(ruleset);
                        break;

                    case "OpenClassification":
                        OpenClassification classification = element as OpenClassification;
                        unit.Classifications.Add(classification);
                        break;

                    case "Check":
                        Check check = element as Check;
                        check.IsSpecified = true;
                        unit.CheckTask    = check;
                        break;

                    case "AutoComment":
                        AutoComment comment = element as AutoComment;
                        comment.IsSpecified = true;
                        unit.CommentTask    = comment;
                        break;

                    case "WriterReport":
                        unit.CheckingReport = element as WriterReport;
                        break;

                    case "CreatePresentation":
                        CreatePresentation createP = element as CreatePresentation;
                        createP.IsSelected      = true;
                        unit.PresentationCreate = createP;
                        break;

                    case "UpdatePresentation":
                        UpdatePresentation updateP = element as UpdatePresentation;
                        updateP.IsSelected      = true;
                        unit.PresentationUpdate = updateP;
                        break;

                    case "GeneralReport":
                        unit.PresentationReport = element as GeneralReport;
                        break;

                    case "BCFReport":
                        unit.BCFReport = element as BCFReport;
                        break;

                    case "CoordinationReport":
                        unit.CoordReport = element as CoordinationReport;
                        break;

                    case "SaveModel":
                        unit.SaveSolibri = element as SaveModel;
                        unit.TaskName    = System.IO.Path.GetFileNameWithoutExtension(unit.SaveSolibri.File);
                        break;

                    case "CloseModel":
                        processUnits.Add(unit);
                        unit = new ProcessUnit();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(processUnits);
        }