public void InitializeComponent <TComponentViewModel, TProperty>(VisibleComponent <TComponentViewModel, TProperty> component, TComponentViewModel viewModel, Expression <Func <TComponentViewModel, TProperty> > property) { // Set the Name component.WithName(this.NameResolver.ResolveName(property)); // Set the Value if (!ReferenceEquals(viewModel, null)) { try { component.WithValue(property.Compile().Invoke(viewModel)); } catch (NullReferenceException e) { throw new ComponentRenderingException("Could not set component value, some part of the property chain is null: " + property, e); } } // Set the Id component.WithId(this.IdResolver.ResolveId(property, component.ControlPrefix)); // set the default label, then hide it as it should be hidden by default. component.WithLabel(this.LabelResolver.ResolveLabel(property)).WithoutLabel(); // run the config on the component if (this.configuration != null) { this.configuration.Initialize(component); } component.OnPrepareForRender += component_OnPrepareForRender; }
/// <summary> /// Инициализация класса /// </summary> public override void Init() { _originalPosition = GameObject.Position; _visibleComponent = GameObject.GetComponent <VisibleComponent>(); }
//List<UpdateWinkel> Findassociatedangles(Transform tf) //{ // List<UpdateWinkel> angles = new List<UpdateWinkel>(); // UpdateInfos layer = GetLayerinfo(tf); // foreach(GameObject angleinfo in WinkelInfos.MenuItems) // { // UpdateWinkel angle = angleinfo.GetComponent<UpdateWinkel>(); // if(angle.transform1 == tf || angle.transform2 == tf) // { // angles.Add(angle); // } // } // for (int i = 0; i < GeradenInfos.MenuItems.Count; i++) // { // UpdateInfos info = GeradenInfos.MenuItems[i].GetComponent<UpdateInfos>(); // if (info.Layertransform == tf) // { // SnapSchnittkante schnittkante = info.Layertransform.gameObject.GetComponent<SnapSchnittkante>(); // if (schnittkante != null) // { // foreach (GameObject angleinfo in WinkelInfos.MenuItems) // { // UpdateWinkel angle = angleinfo.GetComponent<UpdateWinkel>(); // if (angle.transform1 == schnittkante.layer1 && angle.transform2 == schnittkante.layer2) // { // angles.Add(angle); // } // } // } // } // } // return angles; //} void Update() { if (Geraden.isopen) { addbutton.SetStatus("Gerade"); } else if (Ebenen.isopen) { addbutton.SetStatus("Ebene"); } else if (Punkte.isopen) { addbutton.SetStatus("Punkt"); } else { addbutton.SetStatus(""); } if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Vector2 pos = touch.position; Ray ray = Camera.main.ScreenPointToRay(pos); RaycastHit hit; VisibleComponent found = null; if (Physics.Raycast(ray, out hit)) { Transform selectedObject = hit.transform; foreach (VisibleComponent visibleComponent in EditableComponents) { if (visibleComponent.GetTransform() == selectedObject) { found = visibleComponent; text.SetText("selected " + visibleComponent.Name); } if (visibleComponent.GetChildren().Exists((VirtualCompnonent obj) => (obj is VisibleComponent) && ((VisibleComponent)obj).Model3D.transform == selectedObject)) { found = (VisibleComponent)visibleComponent.GetChildren().Find((VirtualCompnonent obj) => (obj is VisibleComponent) && ((VisibleComponent)obj).Model3D.transform == selectedObject); text.SetText("selected " + visibleComponent.Name); } } //for (int i =0; i< EbenenInfos.MenuItems.Count; i++) //{ // GameObject ebene = EbenenInfos.MenuItems[i]; // UpdateInfos infos = ebene.GetComponent<UpdateInfos>(); // if (infos.Layertransform == selectedObject) // { // found = selectedObject; // text.SetText("selected layer: " + infos.Name.text); // } // if (infos.Layertransform == selectedObject.parent) // { // found = selectedObject.parent; // text.SetText("selected layer: " + infos.Name.text); // } //} //for(int i = 0; i< GeradenInfos.MenuItems.Count; i++) //{ // GameObject gerade = GeradenInfos.MenuItems[i]; // UpdateInfos infos = gerade.GetComponent<UpdateInfos>(); // if (infos.Layertransform == selectedObject.parent) // { // found = selectedObject.parent; // text.SetText("selected Gerade: " + infos.Name.text); // } //} //for(int i = 0; i< PunkteInfos.MenuItems.Count; i++) //{ // GameObject punkt = PunkteInfos.MenuItems[i]; // UpdateInfos infos = punkt.GetComponent<UpdateInfos>(); // if (infos.Layertransform == selectedObject.parent) // { // found = selectedObject.parent; // text.SetText("selected Punkt: " + infos.Name.text); // } //} /* public Menu Ebenen; * public Menu Ebeneninfos; * public Menu Geraden; * public Menu Geradeninfos; * public Menu Punktinfos; * public Menu Winkelinfos;*/ //text.SetText(selectedObject.name); } if (found == null) { foreach (VisibleComponent compnonent in EditableComponents) { foreach (VisibleComponent child in compnonent.GetChildren()) { foreach (CanvasRenderer cr in child.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(1.0f); } } foreach (CanvasRenderer cr in compnonent.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(1.0f); } } //foreach (GameObject info in EbenenInfos.MenuItems) //{ // foreach(CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } //} //foreach (GameObject info in GeradenInfos.MenuItems) //{ // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } //} //foreach (GameObject info in PunkteInfos.MenuItems) //{ // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } //} //foreach (GameObject info in WinkelInfos.MenuItems) //{ // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } //} text.SetText("selected nothing important"); } else { List <VirtualCompnonent> fields = Findassociated(found); foreach (VirtualCompnonent compnonent in EditableComponents) { foreach (VirtualCompnonent child in compnonent.GetChildren()) { if (fields.Contains(child)) { foreach (CanvasRenderer cr in child.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(1.0f); } } else { foreach (CanvasRenderer cr in compnonent.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(0.0f); } } } if (fields.Contains(compnonent)) { foreach (CanvasRenderer cr in compnonent.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(1.0f); } } else { foreach (CanvasRenderer cr in compnonent.InfoUI.GetComponentsInChildren <CanvasRenderer>()) { cr.SetAlpha(0.0f); } } } //List<UpdateWinkel> angles = Findassociatedangles(found); //foreach (GameObject info in EbenenInfos.MenuItems) //{ // if (fields.Contains(info.GetComponent<UpdateInfos>())) // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } // } else // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(0.0f); // } // } //} //foreach (GameObject info in GeradenInfos.MenuItems) //{ // if (fields.Contains(info.GetComponent<UpdateInfos>())) // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } // } // else // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(0.0f); // } // } //} //foreach (GameObject info in PunkteInfos.MenuItems) //{ // if (fields.Contains(info.GetComponent<UpdateInfos>())) // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } // } // else // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(0.0f); // } // } //} //foreach (GameObject info in WinkelInfos.MenuItems) //{ // if (angles.Contains(info.GetComponent<UpdateWinkel>())) // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(1.0f); // } // } // else // { // foreach (CanvasRenderer cr in info.GetComponentsInChildren<CanvasRenderer>()) // { // cr.SetAlpha(0.0f); // } // } //} } } }
/// <summary> /// Инициализация класса /// </summary> public override void Init() { _visibleComponent = GameObject.GetComponent <VisibleComponent>(); }