public InstanceFlyout(InstanceObject instance, Flyout flyout)
 {
     InitializeComponent();
     _instance = instance;
     _flyout   = flyout;
     this.AttributeNameField.Text = instance.AttributeName ?? "";
 }
Beispiel #2
0
 protected virtual void Awake()
 {
     _instanceObject = gameObject;
     _name           = InstanceObject.name;
     _rigidbody      = InstanceObject.GetComponent <Rigidbody>();
     _myTransform    = InstanceObject.transform;
 }
Beispiel #3
0
        public SceneNode(InstanceObject instance, int depth)
        {
            switch (instance.ClassObject.VisualShape)
            {
            case VisualShape.Ellipse: Face = new Ellipse();
                break;

            case VisualShape.Rectangle: Face = new Rectangle();
                break;
            }
            Face.Fill = instance.ClassObject.Brush;
            Position  = instance.Position;
            Scale     = instance.Scale;
            Size      = new Point()
            {
                X = instance.ClassObject.Size.X,
                Y = instance.ClassObject.Size.Y
            };
            Children = new List <SceneNode>();
            foreach (InstanceObject inst in instance.ClassObject.Attributes)
            {
                if (depth > 20)
                {
                    break;
                }
                Children.Add(new SceneNode(inst, depth + 1));
            }
            Face.Tapped += (object sender, TappedRoutedEventArgs args) => {
                OnTapped(sender, args);
            };

            Instance = instance;
        }
        /// <summary>
        /// Export an a Rhino instance reference using the 'instance' plugin
        /// </summary>
        /// <param name="parent">The parent node in the output XML document</param>
        /// <param name="obj">The InstanceObject instance to be exported</param>
        /// <returns>true if any content was exported</returns>
        private bool ExportInstanceRef(XmlElement parent, InstanceObject inst)
        {
            Guid guid = inst.InstanceDefinition.Id;

            if (!m_idMap.ContainsKey(guid))
            {
                Log("Warning: no content found -- perhaps the instance definition was empty?");
                return(false);
            }

            XmlElement shapeElement = m_xmlDocument.CreateElement("shape");

            if (inst.Name != null && inst.Name.Length > 0)
            {
                shapeElement.AppendChild(m_xmlDocument.CreateComment(" Rhino object '" + inst.Name + "' "));
            }
            if (inst.InstanceDefinition.Name.Length > 0)
            {
                shapeElement.AppendChild(m_xmlDocument.CreateComment(" (references '"
                                                                     + inst.InstanceDefinition.Name + "') "));
            }

            shapeElement.SetAttribute("type", "instance");

            string id = m_idMap[guid];

            shapeElement.AppendChild(MakeReference(id));
            parent.AppendChild(shapeElement);
            shapeElement.AppendChild(MakeProperty("toWorld", inst.InstanceXform));
            return(true);
        }
Beispiel #5
0
 /// <summary>
 /// Получение урона
 /// </summary>
 /// <param name="damage">Количество урона</param>
 public void SetDamage(int damage)
 {
     _lives -= damage;
     if (!isAlive)
     {
         InstanceObject.SetActive(false);
     }
 }
Beispiel #6
0
        public void DrawClass(DrawableClassObject clObject)
        {
            MainCanvas.Children.Clear();
            InstanceObject        instance  = clObject.Instances.First();
            List <InstanceObject> instances = new List <InstanceObject>();

            instances.Add(instance);
            new Angelina().ExploreAfrica(new SceneGraph(instances), MainCanvas);
        }
 public void AddInstanceToClass(InstanceObject attribute, InstanceObject parent)
 {
     parent.ClassObject.AddAttribute(attribute);
     if (_rootObject.Attributes.Contains(attribute))
     {
         _rootObject.RemoveAttribute(attribute);
     }
     StartTranslation();
 }
Beispiel #8
0
        public virtual void Update()
        {
            if (!isDead)
            {
                return;
            }

            Destroy(InstanceObject.GetComponent <Collider>());
            Destroy(InstanceObject, 1f);
        }
 protected virtual void Awake()
 {
     InstanceObject = gameObject;
     Name           = InstanceObject.name;
     if (GetComponent <Renderer>())
     {
         Material = GetComponent <Renderer>().material;
     }
     Rigidbody   = InstanceObject.GetComponent <Rigidbody>();
     MyTransform = InstanceObject.transform;
 }
        public DrawableClassObject CreateNewClass(Point size, Brush brush, VisualShape shape, Point position, double scale)
        {
            DrawableClassObject newClass = new DrawableClassObject(size, brush, shape);

            _classes.Add(newClass);
            InstanceObject newInstance = new InstanceObject(newClass, position, scale);

            newClass.Instances.Add(newInstance);
            StartTranslation();
            return(newClass);
        }
Beispiel #11
0
        public void InstanceWithConstuctorParameters()
        {
            var i = new InstanceObject();

            ServiceRegistry.Current.RegisterInstance(i);

            Assert.IsTrue(ServiceRegistry.HasRegister <InstanceObject>());

            var i2 = ServiceLocator.Get <InstanceObject>();

            Assert.AreSame(i, i2);
        }
Beispiel #12
0
 /// <summary>
 /// Rigidbody On for object and his childs
 /// </summary>
 public void EnableRigidBody()
 {
     if (!IsRigitBody())
     {
         return;
     }
     Rigidbody[] rigidbodies = InstanceObject.GetComponentsInChildren <Rigidbody>();
     foreach (var rb in rigidbodies)
     {
         rb.isKinematic = false;
     }
 }
        public InstanceObject CreateInstanceOfClass(DrawableClassObject classObject, Point position, double scale)
        {
            InstanceObject newInstance = new InstanceObject(classObject, new Point(position.X, position.Y), scale);

            classObject.Instances.Add(newInstance);

            // Check for collisions?
            AddInstanceToRoot(newInstance);

            StartTranslation();

            return(newInstance);
        }
        public void AttributeNameChanged(InstanceObject changedObject)
        {
            InstancePropertyChangeEvent newEvent = new InstancePropertyChangeEvent()
            {
                ChangedInstance = changedObject
            };

            foreach (var handler in _attributeNameChangedHandlers)
            {
                if (handler == null)
                {
                    continue;
                }
                handler(newEvent);
            }
        }
Beispiel #15
0
        private void RecursivelyParseObjectInstance(RhinoObject[] InObjects, RhinoSceneHierarchyNode ParentNode)
        {
            foreach (RhinoObject CurrentObject in InObjects)
            {
                if (CurrentObject == null ||
                    IsObjectIgnoredBySelection(CurrentObject, ParentNode) ||
                    IsUnsupportedObject(CurrentObject))
                {
                    // Skip the object.
                    continue;
                }

                RhinoSceneHierarchyNode DefinitionRootNode = null;
                if (CurrentObject.ObjectType == ObjectType.InstanceReference)
                {
                    InstanceObject CurrentInstance = CurrentObject as InstanceObject;
                    DefinitionRootNode = GetOrCreateDefinitionRootNode(CurrentInstance.InstanceDefinition);

                    if (DefinitionRootNode.GetChildrenCount() == 0)
                    {
                        // Don't instantiate empty definitions.
                        continue;
                    }
                }

                int MaterialIndex = GetObjectMaterialIndex(CurrentObject, ParentNode.Info);
                RhinoSceneHierarchyNodeInfo ObjectNodeInfo = GenerateNodeInfo(CurrentObject, ParentNode.bIsInstanceDefinition, MaterialIndex, ParentNode.Info.WorldTransform);
                RhinoSceneHierarchyNode     ObjectNode;
                if (ParentNode.bIsRoot && ParentNode.bIsInstanceDefinition)
                {
                    // The objects inside a Block definitions may be defined in a different layer than the one we are currently in.
                    ObjectNode = ParentNode.AddChild(ObjectNodeInfo, GetOrCreateLayerIndexHierarchy(CurrentObject.Attributes.LayerIndex));
                }
                else
                {
                    ObjectNode = ParentNode.AddChild(ObjectNodeInfo);
                }
                GuidToHierarchyNodeDictionary.Add(CurrentObject.Id, ObjectNode);
                AddObjectMaterialReference(CurrentObject, MaterialIndex);

                if (DefinitionRootNode != null)
                {
                    InstanciateDefinition(ObjectNode, DefinitionRootNode);
                }
            }
        }
Beispiel #16
0
 public void Update()
 {
     if (_isDead)
     {
         Color color = GetMaterial.color;
         if (color.a > 0)
         {
             color.a -= step / 100;
             Color    = color;
         }
         if (color.a < 1)
         {
             Destroy(InstanceObject.GetComponent <Collider>());
             Destroy(InstanceObject, _timeToDestroy);
         }
     }
 }
Beispiel #17
0
 void Update()
 {
     if (_isDead)             //запускаем анимацию смерти
     {
         Color color = GetMaterial.color;
         if (color.a > 0)                 // понижаем альфа-канал (плавное затухание)
         {
             color.a -= _step / 100;
             Color    = color;
         }
         if (color.a < 1)
         {
             Destroy(InstanceObject.GetComponent <Collider> ());
             Destroy(InstanceObject, 5f);
         }
     }
 }
Beispiel #18
0
        public static void DrawInstanceObject(this DisplayPipeline display, InstanceObject instanceObject, Transform xForm, bool highlight)
        {
            instanceObject.Explode(false, out var pieces, out _,
                                   out var pieceTransforms);
            var geo = instanceObject.Geometry;

            for (int i = 0; i < pieces.Length; i++)
            {
                if (highlight)
                {
                    display.DrawObjectHighlighted(pieces[i], xForm * pieceTransforms[i]);
                }
                else
                {
                    display.DrawObject(pieces[i], xForm * pieceTransforms[i]);
                }
            }
        }
Beispiel #19
0
        public override void OnClick(object sender, TappedRoutedEventArgs e)
        {
            if (!(sender is Shape))
            {
                return;
            }
            InstanceObject obj = ((sender as Shape).Tag as SceneNode).Parent.Instance;

            if (obj == null)
            {
                ModelManager.GetInstance().RemoveClass(((sender as Shape).Tag as SceneNode).Instance.ClassObject);
                EditPage.Instance.Redraw();
            }
            else
            {
                obj.ClassObject.RemoveAttribute(((sender as Shape).Tag as SceneNode).Instance);
                EditPage.Instance.Redraw();
            }
        }
        private void AbandonObject()
        {
            var body = new InstanceGroupManagersAbandonInstancesRequest
            {
                Instances = InstanceObject.Select(i => i.SelfLink).ToList()
            };

            if (ShouldProcess("Abandoning instances: " + JoinInstanceNames(body.Instances), null,
                              $"Managed Instance Group {Project}/{Zone}/{Name}"))
            {
                InstanceGroupManagersResource.AbandonInstancesRequest request =
                    Service.InstanceGroupManagers.AbandonInstances(body, Project, Zone, Name);
                Operation operation = request.Execute();
                AddZoneOperation(Project, Zone, operation, () =>
                {
                    WriteObject(Service.InstanceGroupManagers.Get(Project, Zone, Name));
                });
            }
        }
Beispiel #21
0
        public override void Update()
        {
            if (!isDead)
            {
                return;
            }

            var scale = transform.localScale;

            if (!scale.Less(_deathScale))
            {
                transform.localScale = scale.Subtraction(step);
            }
            else
            {
                Destroy(InstanceObject.GetComponent <Collider>());
                Destroy(InstanceObject, 1f);
            }
        }
Beispiel #22
0
        private static void ExplodeRecursive(InstanceObject instanceObject, Transform instanceTransform, List <RhinoObject> pieces, List <Transform> transforms)
        {
            for (int i = 0; i < instanceObject.InstanceDefinition.ObjectCount; i++)
            {
                RhinoObject rhinoObject = instanceObject.InstanceDefinition.Object(i);

                if (rhinoObject is InstanceObject nestedObject)
                {
                    Transform nestedTransform = instanceTransform * nestedObject.InstanceXform;

                    ExplodeRecursive(nestedObject, nestedTransform, pieces, transforms);
                }
                else
                {
                    pieces.Add(rhinoObject);

                    transforms.Add(instanceTransform);
                }
            }
        }
Beispiel #23
0
        private int GetObjectMaterialIndex(RhinoObject InRhinoObject, RhinoSceneHierarchyNodeInfo ParentNodeInfo)
        {
            ObjectMaterialSource MaterialSource = InRhinoObject.Attributes.MaterialSource;

            if (MaterialSource == ObjectMaterialSource.MaterialFromParent)
            {
                // Special use-case for block instances with the source material set to "Parent".
                // The material source in this case is actually the layer in which the definition objects are.
                if (InRhinoObject is InstanceObject)
                {
                    InstanceObject Instance          = InRhinoObject as InstanceObject;
                    RhinoObject[]  DefinitionObjects = Instance.InstanceDefinition.GetObjects();
                    if (DefinitionObjects != null && DefinitionObjects.Length > 0)
                    {
                        Layer ObjectLayer = RhinoDocument.Layers.FindIndex(InRhinoObject.Attributes.LayerIndex);
                        return(ObjectLayer.RenderMaterialIndex);
                    }
                }
                else if (ParentNodeInfo == null)
                {
                    MaterialSource = ObjectMaterialSource.MaterialFromLayer;
                }
            }

            switch (MaterialSource)
            {
            case ObjectMaterialSource.MaterialFromLayer:
                Layer ObjectLayer = RhinoDocument.Layers.FindIndex(InRhinoObject.Attributes.LayerIndex);
                return(ObjectLayer.RenderMaterialIndex);

            case ObjectMaterialSource.MaterialFromParent:
                return(ParentNodeInfo.MaterialIndex);

            case ObjectMaterialSource.MaterialFromObject:
            default:
                return(InRhinoObject.Attributes.MaterialIndex);
            }
        }
        public void FillClasses()
        {
            List <DrawableClassObject> classes = Model.ModelManager.GetInstance().GetClasses();

            _icons = new List <GalleryIcon>();
            PreviewGridView.Items.Clear();
            foreach (DrawableClassObject cl in classes)
            {
                InstanceObject        instance  = cl.Instances.First();
                List <InstanceObject> instances = new List <InstanceObject>();
                instances.Add(instance);
                Canvas canvas = new Canvas();
                new Angelina().ExploreAfrica(new SceneGraph(instances), canvas);
                canvas.RenderTransform = new ScaleTransform()
                {
                    ScaleX = 0.1, ScaleY = 0.1
                };
                canvas.HorizontalAlignment = HorizontalAlignment.Center;
                GalleryIcon icon = new GalleryIcon(this, canvas, cl);
                _icons.Add(icon);
                PreviewGridView.Items.Add(icon);
            }
        }
Beispiel #25
0
        public override void BeforeGenerateObject(PatternInstance instance, InstanceObject instanceObject)
        {
            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeGenerateObject Begin {0}", DateTime.Now.ToString()));
                CommonServices.Output.AddLine(String.Format(">>> instanceObject.Name {0}", instanceObject.Name));
            }
            HPatternInstance wwInstance = null;
            if (instanceObject.Instance != null)
                wwInstance = HPatternInstance.Load(instanceObject.Instance);

            //TESTS

            HPatternSettings settings = HPatternSettings.Get(instanceObject.Model);

            if (instanceObject.Object == HPatternObject.ListPrograms && !settings.Template.GenerateListPrograms)
            {
                instanceObject.Generate = false;
                return;
            }

            // 0.- Se temos a view, vamos verificar se é para gerar, se não, vamos apagar :D
            if (instanceObject.Object == HPatternObject.View
                || instanceObject.Object == HPatternObject.TabTabular
                || instanceObject.Object == HPatternObject.TabGrid
                || instanceObject.Object == HPatternObject.TabGridTrn
                || instanceObject.Object == HPatternObject.ExportTabGrid
                || instanceObject.Object == HPatternObject.TabGridSDT)
            {
                if (wwInstance != null)
                {
                    if (wwInstance.Transaction != null)
                    {
                        if (settings.Template.GenerateViewOnlyBC)
                        {
                            if (wwInstance.Levels != null)
                            {
                                if (wwInstance.Levels.Count > 0)
                                {
                                    if (!wwInstance.Transaction.WebBC)
                                    {

                                        instanceObject.Generate = false;
                                        return;

                                    }
                                }
                            }
                        } else {
                            if (instanceObject.Object == HPatternObject.TabGridTrn) {
                                if (wwInstance.Levels != null)
                                {
                                    if (wwInstance.Levels.Count > 0)
                                    {
                                        if (!wwInstance.Transaction.WebBC)
                                        {

                                            instanceObject.Generate = false;
                                            return;

                                        }
                                    }
                                }
                            }
                            if (instanceObject.Object == HPatternObject.TabTabular && settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor && wwInstance.Levels != null && wwInstance.Levels.Count > 0)
                            {
                                instanceObject.Generate = false;
                            }
                        }
                    }
                }
            }

            if (instanceObject.Object == HPatternObject.DataProviderGridModel || instanceObject.Object == HPatternObject.DataProviderGrid || instanceObject.Object == HPatternObject.SDTGrid || instanceObject.Object == HPatternObject.ProcedureGrid)
            {
                if (settings.Grid.GridType != HPattern.SettingsGridElement.GridTypeValue.Gxui)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            string trnName = "";
            if (wwInstance != null)
            {
                if (wwInstance.Transaction != null)
                {
                    trnName = wwInstance.Transaction.TransactionName.ToLower();
                }
            }

            // Gera BC
            if (instanceObject.Object == HPatternObject.TransactionBC || instanceObject.Object == HPatternObject.TransactionBCTab  || instanceObject.Object == HPatternObject.SDTBC || instanceObject.Object == HPatternObject.DataProviderBC || instanceObject.Object == HPatternObject.ProcedureBC || instanceObject.Object == HPatternObject.ProcedureSaveBC)
            {
                bool gera = wwInstance.Transaction.WebBC;
                /*
                bool gera = settings.Template.DataEntryWebPanelBC;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                    gera = true;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                b    gera = false;
                */

                if (gera)
                {
                    if (instanceObject.Object == HPatternObject.TransactionBC)
                    {
                        if (wwInstance.Transaction.Form.Tabs.Count > 0)
                            gera = false;
                    }
                    if (instanceObject.Object == HPatternObject.TransactionBCTab)
                    {
                        if (wwInstance.Transaction.Form.Tabs.Count <= 0)
                            gera = false;
                    }
                }

                if (gera)
                {
                    if (instanceObject.Object == HPatternObject.DataProviderBC) {

                    }

                } else {

                    instanceObject.Generate = false;
                    return;
                }
            }

            if (instanceObject.Object == HPatternObject.DataProviderDSM)
            {
                bool geraAba = false;
                bool gera = false;
                if (wwInstance.Transaction != null && wwInstance.Transaction.WebBC)
                    gera = true;
                /*
                bool gera = settings.Template.DataEntryWebPanelBC;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                    gera = true;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                    gera = false;
                */

                if (gera)
                {
                    if (wwInstance.Levels != null && wwInstance.Levels.Count > 0)
                    {
                        LevelElement l = wwInstance.Levels[0];
                        if (l.View != null)
                        {
                            if (l.View.Tabs.Count > 0)
                            {
                                geraAba = true;
                            }
                        }
                    }
                }

                if (!geraAba)
                {
                    if (wwInstance.WebObject.Form.Tabs != null)
                    {
                        if (wwInstance.WebObject.Form.Tabs.Count > 0)
                        {
                            geraAba = true;
                        }
                    }
                }
                if (geraAba)
                {
                    if (settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor)
                    {
                        geraAba = false;
                    }

                }
                if (!geraAba)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            // Customize generation of export procedure.
            if (instanceObject.Object == HPatternObject.ExportSelection || instanceObject.Object == HPatternObject.ExportTabGrid)
            {
                IGridObject gridObject = wwInstance.GetElement<IGridObject>(instanceObject.Element);
                if (gridObject.Actions.Export == null)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            // Customize names.
            if (instanceObject.Object == HPatternObject.Selection)
            {
                SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                instanceObject.Name = settings.Objects.SelectionName(selec);
                instanceObject.Description = selec.Description;
            }

            if (instanceObject.Object == HPatternObject.Prompt)
            {
                PromptElement prompt = wwInstance.GetElement<PromptElement>(instanceObject.Element);
                instanceObject.Name = settings.Objects.PromptName(prompt);
                instanceObject.Description = prompt.Description;
            }

            if (instanceObject.Object == HPatternObject.View)
            {

                ViewElement view = wwInstance.GetElement<ViewElement>(instanceObject.Element);
                if (view != null)
                {
                    if (view.Tabs.Count > 0)
                    {
                        bool gera2 = wwInstance.Transaction.WebBC;
                        /*
                        bool gera2 = settings.Template.DataEntryWebPanelBC;
                        if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                            gera2 = true;
                        if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                            gera2 = false;
                        */

                        if (gera2)
                            instanceObject.Generate = false;
                    }

                    instanceObject.Name = settings.Objects.ViewName(view);

                }

            }

            if (!settings.Template.LoadSDTWithDataProvider)
            {
                if (instanceObject.Object == HPatternObject.DataProviderBC)
                {
                    instanceObject.Generate = false;
                }
            }

            if (instanceObject.Object == HPatternObject.ExportSelection || instanceObject.Object == HPatternObject.ExportTabGrid)
                instanceObject.Name = settings.Objects.ExportProcedureName(wwInstance.GetElement<IGridObject>(instanceObject.Element));

            if (instanceObject.Object == HPatternObject.GridSDT || instanceObject.Object == HPatternObject.TabGridSDT)
                instanceObject.Name = settings.Objects.GridSdtName(wwInstance.GetElement<IGridObject>(instanceObject.Element));

            if (instanceObject.Object == HPatternObject.TabGridTrn)
            {
                TabElement tabtrn = wwInstance.GetElement<TabElement>(instanceObject.Element);
                if (tabtrn.GetCallMethod != TabElement.CallMethodValue.Popup)
                {
                    instanceObject.Generate = false;
                }
            }

            // Vamos colocar os nomes conforme arquivo separado por ";"
            if (!String.IsNullOrEmpty(settings.Template.ObjectsNamesName))
            {
                if (instanceObject.Generate)
                {
                    if (instanceObject.Object == HPatternObject.Selection)
                    {
                        /*
                        string tmpN = GetSugestName(trnName, settings);
                        if (!String.IsNullOrEmpty(tmpN))
                        {
                            instanceObject.Name = tmpN;
                            SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                            selec.ObjectName = tmpN;

                        }
                        */
                        SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                        if (!String.IsNullOrEmpty(selec.ObjName))
                        {
                            instanceObject.Name = selec.ObjName;
                        }

                    }

                    if (wwInstance != null)
                    {
                        if (wwInstance.Transaction.WebBC)
                        {

                            if (instanceObject.Object == HPatternObject.TransactionBC)
                            {
                                /*
                                string tmpN = GetSugestName(trnName, settings);
                                if (!String.IsNullOrEmpty(tmpN))
                                {
                                    instanceObject.Name = tmpN;
                                    TransactionElement selec = wwInstance.GetElement<TransactionElement>(instanceObject.Element);
                                    selec.ObjectName = tmpN;
                                }
                                */
                                TransactionElement selec = wwInstance.GetElement<TransactionElement>(instanceObject.Element);
                                if (!String.IsNullOrEmpty(selec.ObjName))
                                {
                                    instanceObject.Name = selec.ObjName;
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TransactionBCTab)
                            {
                                if (wwInstance.Transaction.Form.Tabs.Count > 0)
                                {
                                    /*
                                    string tmpN = GetSugestName(trnName, settings);
                                    if (!String.IsNullOrEmpty(tmpN))
                                    {
                                        instanceObject.Name = tmpN;
                                        TabFormElement selec = wwInstance.GetElement<TabFormElement>(instanceObject.Element);
                                        selec.ObjectName = tmpN;

                                    }
                                    */
                                    TabFormElement selec = wwInstance.GetElement<TabFormElement>(instanceObject.Element);
                                    if (!String.IsNullOrEmpty(selec.ObjName))
                                    {
                                        instanceObject.Name = selec.ObjName;
                                    }
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TabGrid)
                            {
                                if (wwInstance.Levels[0].View != null)
                                {
                                    ViewElement v = wwInstance.Levels[0].View;
                                    if (v.Tabs.Count > 0)
                                    {
                                        TabElement selec = wwInstance.GetElement<TabElement>(instanceObject.Element);
                                        if (!String.IsNullOrEmpty(selec.ObjName))
                                        {
                                            instanceObject.Name = selec.ObjName;
                                        }
                                    }
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TabGridTrn)
                            {
                                if (wwInstance.Levels[0].View != null)
                                {
                                    ViewElement v = wwInstance.Levels[0].View;
                                    if (v.Tabs.Count > 0)
                                    {
                                        TabElement selec = wwInstance.GetElement<TabElement>(instanceObject.Element);
                                        if (!String.IsNullOrEmpty(selec.ObjNameTrn))
                                        {
                                            instanceObject.Name = selec.ObjNameTrn;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            /*
            if (wwInstance != null)
            {
                if (instanceObject.Generate && (!settings.Template.WebPanelBCDefault) && wwInstance.UpdateWebPanelBC == HPatternInstance.UpdateWebPanelBCValue.Default)
                {
                    if (instanceObject.Object == HPatternObject.TransactionBC || instanceObject.Object == HPatternObject.TransactionBCTab)
                    {
                        WebPanel web3 = WebPanel.Get(instance.Model, instanceObject.Name);
                        if (web3 != null)
                        {
                            web3.Rules.IsDefault = true;
                            web3.Events.IsDefault = true;
                            web3.Conditions.IsDefault = true;
                            web3.Variables.IsDefault = true;
                            web3.WebForm.IsDefault = true;
                            web3.Save();

                        }
                    }
                }
            }
            */

            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeGenerateObject End {0}", DateTime.Now.ToString()));
            }
        }
 public void AddInstanceToRoot(InstanceObject instance)
 {
     _rootObject.AddAttribute(instance);
 }
Beispiel #27
0
        /// <summary>
        /// Takes varying RhinoObjects and returns a RhinoMesh, and a RhinoMaterial for each.
        /// Handles
        /// </summary>
        /// <param name="rhinoObjects"></param>
        /// <returns></returns>
        public static List <ObjectExportData> SanitizeRhinoObjects(IEnumerable <RhinoObject> rhinoObjects)
        {
            var rhinoObjectsRes = new List <ObjectExportData>();

            foreach (var rhinoObject in rhinoObjects)
            {
                if (!rhinoObject.IsMeshable(MeshType.Any))
                {
                    RhinoApp.WriteLine("Skipping " + GetDebugName(rhinoObject) + ", object is not meshable. Object is a " + rhinoObject.ObjectType.ToString());
                    continue;
                }

                // FIXME: This is broken. Even though objects use the same material, different Materials are returned here.
                var mat = rhinoObject.RenderMaterial;

                // This is always true when called from the Main plugin command, as it uses the same ObjectType array as filter.
                // Keeping it around in case someone calls this from somewhere else.
                var isValidGeometry = Constants.ValidObjectTypes.Contains(rhinoObject.ObjectType);

                if (isValidGeometry && rhinoObject.ObjectType != ObjectType.InstanceReference)
                {
                    var meshes = GetMeshes(rhinoObject);

                    if (meshes.Length > 0) //Objects need a mesh to export
                    {
                        rhinoObjectsRes.Add(new ObjectExportData()
                        {
                            Meshes         = meshes,
                            RenderMaterial = mat,
                            Object         = rhinoObject,
                        });
                    }
                }
                else if (rhinoObject.ObjectType == ObjectType.InstanceReference)
                {
                    InstanceObject instanceObject = rhinoObject as InstanceObject;

                    List <RhinoObject> objects    = new List <RhinoObject>();
                    List <Transform>   transforms = new List <Transform>();

                    ExplodeRecursive(instanceObject, instanceObject.InstanceXform, objects, transforms);

                    // Transform the exploded geo into its correct place
                    foreach (var item in objects.Zip(transforms, (rObj, trans) => (rhinoObject: rObj, trans)))
                    {
                        var meshes = GetMeshes(item.rhinoObject);

                        foreach (var mesh in meshes)
                        {
                            mesh.Transform(item.trans);
                        }

                        if (meshes.Length > 0) //Objects need a mesh to export
                        {
                            rhinoObjectsRes.Add(new ObjectExportData()
                            {
                                Meshes         = meshes,
                                RenderMaterial = mat,
                                Object         = item.rhinoObject,
                            });
                        }
                    }
                }
                else
                {
                    RhinoApp.WriteLine("Unknown geo type encountered.");
                }
            }

            return(rhinoObjectsRes);
        }
 /// <summary>
 /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
 /// </summary>
 /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
 /// <returns>
 /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
 /// </returns>
 /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
 public override bool Equals(object obj)
 {
     return(InstanceObject.GetHashCode() == obj.GetHashCode());
 }
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 public override int GetHashCode()
 {
     return(InstanceObject.GetHashCode());
 }
 public ObjectWithInjection(InstanceObject obj)
 {
     NotInjectionFromConstructor = obj;
 }
        public override void OnClick(object sender, TappedRoutedEventArgs e)
        {
            if (sender is GalleryIcon)
            {
                GalleryIcon icon = sender as GalleryIcon;

                if (!_clicked)
                {
                    _clicked = true;
                    // select instance to add

                    EditPage.Instance.CurrentCanvas.Opacity          = 1;
                    EditPage.Instance.CurrentCanvas.IsHitTestVisible = true;

                    InstanceObject instance = icon.ClassObject.Instances.First();

                    _node = new SceneNode(instance, 1);

                    _clObject = icon.ClassObject;
                }
            }
            else if (sender is DrawingCanvas)
            {
                DrawingCanvas canvas = sender as DrawingCanvas;

                if (_clicked)
                {
                    // create new instance


                    Point pos = new Point()
                    {
                        X = e.GetPosition(canvas).X - _clObject.Size.X / 2,
                        Y = e.GetPosition(canvas).Y - _clObject.Size.Y / 2
                    };

                    Model.ModelManager.GetInstance().CreateInstanceOfClass(_clObject, pos, 1);
                    EditPage.Instance.Redraw();
                    _clicked = false;
                    _node    = null;
                    return;
                }
            }
            else if (sender is Shape && _clicked)
            {
                //    _node.Instance.Scale = 1;
                Point pos = new Point()
                {
                    X = e.GetPosition(sender as Shape).X - _clObject.Size.X / 2,
                    Y = e.GetPosition(sender as Shape).Y - _clObject.Size.Y / 2
                };
                InstanceObject inst = new InstanceObject(_node.Instance.ClassObject, pos, 1);
                ((sender as Shape).Tag as SceneNode).Instance.ClassObject.AddAttribute(inst);
                EditPage.Instance.Redraw();
                _clicked = false;
                _node    = null;
                return;
            }

            //  Debug.WriteLine(_clicked + "");
        }
	void Start () 
	{
		instancePosY = wood03.localPosition.y;
		instanceObject = FindObjectOfType<InstanceObject>();
		playFlagManager = FindObjectOfType<PlayFlagManager> ();
	}
    internal static RhinoObject CreateRhinoObjectHelper(IntPtr pRhinoObject)
    {
      if (IntPtr.Zero == pRhinoObject)
        return null;

      uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(pRhinoObject);
      if (sn < 1)
        return null;

      int type = UnsafeNativeMethods.CRhinoRhinoObject_GetRhinoObjectType(pRhinoObject);
      if (type < 0)
        return null;
      RhinoObject rc;
      switch (type)
      {
        case idxCRhinoPointObject: //1
          rc = new PointObject(sn);
          break;
        case idxCRhinoCurveObject: //2
          rc = new CurveObject(sn);
          break;
        case idxCRhinoMeshObject: //3
          rc = new MeshObject(sn);
          break;
        case idxCRhinoBrepObject: //4
          rc = new BrepObject(sn);
          break;
        case idxCRhinoPointCloudObject: //5
          rc = new PointCloudObject(sn);
          break;
        case idxCRhinoAnnotationTextObject: //6
          rc = new TextObject(sn);
          break;
        case idxCRhinoSurfaceObject: //7
          rc = new SurfaceObject(sn);
          break;
        case idxCRhinoInstanceObject: //8
          rc = new InstanceObject(sn);
          break;
        case idxCRhinoHatchObject: //9
          rc = new HatchObject(sn);
          break;
        case idxCRhinoDetailViewObject: //10
          rc = new DetailViewObject(sn);
          break;
        case idxCRhinoClippingPlaneObject: //11
          rc = new ClippingPlaneObject(sn);
          break;
        case idxCRhinoTextDot: //12
          rc = new TextDotObject(sn);
          break;
        case idxCRhinoGripObject: //13
          rc = new GripObject(sn);
          break;
#if USING_V5_SDK
        case idxCRhinoExtrusionObject: //14
          rc = new ExtrusionObject(sn);
          break;
#endif
        case idxCRhinoLinearDimension: //15
          rc = new LinearDimensionObject(sn);
          break;
        case idxCRhinoAnnotationObject: //16
          rc = new AnnotationObjectBase(sn);
          break;
        case idxCRhinoLight: //17
          rc = new LightObject(sn);
          break;
        case idxCRhinoMorphControl: //18
          rc = new MorphControlObject(sn);
          break;
        case idxCRhinoRadialDimension: //19
          rc = new RadialDimensionObject(sn);
          break;
        case idxCRhinoAngularDimension: //20
          rc = new AngularDimensionObject(sn);
          break;
        default:
          rc = new RhinoObject(sn);
          break;
      }
      return rc;
    }
Beispiel #34
0
 public ParserFactory(PatternInstance instance, InstanceObject io, ManualResetEvent doneEvent)
 {
     mInstance = instance;
     mIo = io;
     mDoneEvent = doneEvent;
 }