private void OnMenuGoToCode(object sender, EventArgs e) { if (ObjectModelBrowser.SelectedNode is EFModelElementTreeNode elementNode) { switch (elementNode.RepresentedElement) { case ModelClass modelClass: if (!EFModelDocData.OpenFileFor(modelClass)) { EFModelDocData.ShowError(modelClass.Store, $"Can't open generated file for {modelClass.Name}"); } break; case ModelAttribute modelAttribute: if (!EFModelDocData.OpenFileFor(modelAttribute.ModelClass)) { EFModelDocData.ShowError(modelAttribute.Store, $"Can't open generated file for {modelAttribute.ModelClass.Name}"); } break; case ModelEnum modelEnum: if (!EFModelDocData.OpenFileFor(modelEnum)) { EFModelDocData.ShowError(modelEnum.Store, $"Can't open generated file for {modelEnum.Name}"); } break; case ModelEnumValue modelEnumValue: if (!EFModelDocData.OpenFileFor(modelEnumValue.Enum)) { EFModelDocData.ShowError(modelEnumValue.Store, $"Can't open generated file for {modelEnumValue.Enum.Name}"); } break; } } }
/// <summary>Raises the <see cref="E:System.Windows.Forms.Control.DoubleClick" /> event.</summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param> protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); // let's make this a switch so we can more easily extend it to different element types later switch (SelectedElement) { case ModelClass modelClass: EFModelDocData.OpenFileFor(modelClass); break; case ModelAttribute modelAttribute: EFModelDocData.OpenFileFor(modelAttribute.ModelClass); break; case ModelEnum modelEnum: EFModelDocData.OpenFileFor(modelEnum); break; case ModelEnumValue modelEnumValue: EFModelDocData.OpenFileFor(modelEnumValue.Enum); break; } }