private void EditButtonClicked() { Debug.Assert(m_currentValue != null, "m_currentValue != null"); Type editorType = ((CellEditorData)m_currentValue.Tag).GetEditorType(EditorManager); Debug.Assert(editorType != null, "Edit button clicked, but there is no editor for value type '" + m_currentValue.ValueTypeName + "'."); if (m_editorDialog == null) { m_editorDialog = new EditorDialog(MessageBoxButtons.OKCancel); } if (m_editorDialogSettings != null) { m_editorDialogSettings.ApplyToWindow(m_editorDialog); } m_editorDialog.ReadOnly = IsReallyReadOnly(m_currentValue); m_editorDialog.CurrentEditorType = editorType; // Keep the value in the remote AppDomain, if the editor supports this. if (m_editorDialog.IsRemoteEditor) { m_editorDialog.DisplayRemoteValue(m_currentValue.CreateWrapper()); } else { m_editorDialog.DisplayValue(m_currentValue.GetValue()); } m_editorDialog.FocusOnEditor(); // Set focus to the editor every time the dialog is shown. if (m_editorDialog.ShowDialog(DataGridTableStyle.DataGrid) == DialogResult.OK) { m_currentValue.SetValue(m_editorDialog.GetValue()); OnEditorCommitted(new MemberWrapperEventArgs(m_currentValue)); } if (m_editorDialogSettings == null) { m_editorDialogSettings = new WindowSettings(); } m_editorDialogSettings.ReadFromWindow(m_editorDialog); }
private void FindSkinParts() { if (null == _thisType) { _thisType = GetType(); } var parts = SkinParts.Keys; foreach (var id in parts) { object part = null; /** * 1. If this is a mapper skin, * */ if (_isMapperSkin) { part = Skin.GetChildComponent(id); //if (null != part) // Debug.Log("Found mapper skin part: " + part); //else // Debug.Log(Skin + " -> Couldn't find mapper skin part: " + id); } else { if (CoreReflector.HasMember(Skin, id)) { try { part = CoreReflector.GetValue(Skin, id); } catch (InvalidCastException /* ex*/) { Debug.LogError(string.Format("Cannot cast the skin part to InteractiveComponent. Skin: {0}; Part: {1}", Skin, id)); } } //else // Debug.LogWarning("Couldn't find member: " + id); } if (SkinParts[id]) // == true (required part) { if (null == part) { throw new Exception("Required skin part not found: " + id); } } if (null != part) { /** * Note: we've been having a hard-core bug here (20131216)! * The system FREEZED when using Panel with children in designer * For instance, a panel had a single button child as a content child (not tool or control bar child) * This is also the source of bug whereever we add a child prior to adding itself to the display list (both designer and code) * I think it might be related to styles and StyleProtoChain process (?) * This shoould - of course - be fixed * The problem with designer was in ComponentAdapter ("Produce" method): * _component.AddEventListener(FrameworkEvent.PREINITIALIZE, InitializeHandler) * During the PREINITILIZE, child components have not yet been created - so the skin wasn't created * When I changed it to INITILIZE, it started to work properly: * _component.AddEventListener(FrameworkEvent.INITIALIZE, InitializeHandler) * * */ /*if (id == "ContentGroup") * Debug.LogWarning("ContentGroup: " + part);*/ //CoreReflector.SetValue(this, id, part); MemberWrapper wrapper = new MemberWrapper(GetType(), id); wrapper.SetValue(this, part); // If the assigned part has already been instantiated, call partAdded() here, // but only for static parts. try { /* Note: this fails, because the wrapper wraps around the Skin's property, not the Panel's */ //var p = CoreReflector.GetValue(this, id); wrapper = new MemberWrapper(GetType(), id); var p = wrapper.GetValue(this); // TODO: we should get the value silently here, because not to disturb the DoubleGroup.Modified flag //Debug.Log("Just added: " + p); // If the assigned part has already been instantiated, call partAdded() here, // but only for static parts. if (null != p && !(p is IFactory)) { PartAdded(id, p); } } catch (ArgumentException ex) { throw ex; } } } }