private void lvwResults_DoubleClick(object sender, System.EventArgs e) { if (lvwResults.SelectedItems.Count == 1) { ListViewItem item = lvwResults.SelectedItems[0]; // If there is an exception or extra information then show it. Result result = item.Tag as Result; if (result != null) { if (result.Exception != null) { new ExceptionDialog(result.Exception, "The following exception has occurred:").ShowDialog(); } else if (result.ExtraInfo != null) { EditorDialog dialog = new EditorDialog(); dialog.CurrentEditorType = typeof(BasicTypeEditor); dialog.DisplayValue(result.ExtraInfo); dialog.ShowDialog(); } } } }
/// <summary> /// Loads the blueprints of all files of the current project.. /// </summary> public void LoadBlueprints() { var blueprintManager = new HierarchicalBlueprintManager(); foreach (var blueprintFile in this.ProjectSettings.BlueprintFiles) { blueprintManager.AddChild(blueprintFile.BlueprintManager); } // Load all blueprints. this.BlueprintManagerViewModel = new BlueprintManagerViewModel( this.AvailableComponentTypes, blueprintManager); // Setup blueprint parent hierarchy. if (this.BlueprintManagerViewModel != null) { try { this.BlueprintManagerViewModel.SetupBlueprintHierarchy(); } catch (AggregateException exception) { EditorDialog.Warning("Blueprint hierarchy not properly set up", exception.InnerExceptions); } } }
public override void OnDoubleClick(Object sender, EventArgs e) { DrawArea drawArea = (DrawArea)sender; EditorDialog dlg = new EditorDialog(_logicIDTail, this, "", drawArea.GraphicsList.BomVerify, DeviceTypeEnum.BOM, DeviceTypeEnum.BOM, drawArea.GraphicsList.IPVerify); if (dlg.ShowDialog() == DialogResult.OK) { if (this._tagIDBase != 0) { drawArea.GraphicsList.BomVerify.Remove(_logicIDTail); } _logicIDTail = dlg.IDvalues; this.x_axis = dlg.X_axis; this.y_axis = dlg.Y_axis; this.width = dlg.RWidth; this.height = dlg.RHeight; RecID = dlg.RecID; DeviceID = dlg.DeviceID; DeviceName = dlg.DeviceName; IpAdd = dlg.IpAdd; this.Device_H = dlg.Device_H; this.Device_W = dlg.Device_W; if (_tagIDBase == 0) _flag = _objIdInc++; if (drawArea.AddText(this)) { _tagIDBase = _flag; this.SetRectangle(x_axis, y_axis, width, height); drawArea.SetDirty(); drawArea.Refresh(); } } }
private void Cancel_OnClick(object sender, RoutedEventArgs e) { this.DialogResult = false; this.Close(); EditorDialog.Info("CSV Import Cancelled", "No data imported."); }
public void LoadLanguages() { this.languages.Clear(); if (this.context.ProjectSettings == null) { return; } foreach (var languageFile in this.context.ProjectSettings.LanguageFiles) { var fileInfo = new FileInfo(languageFile.Path); try { using (var stream = fileInfo.OpenRead()) { var languageTag = languageFile.LanguageTag; var localizationTable = this.localizationTableSerializer.Deserialize(stream); this.languages.Add(languageTag, localizationTable); } } catch (AggregateException e) { EditorDialog.Error( "Loading localization data failed", string.Format( "Please fix the following errors in {0} and re-load the project:\r\n\r\n{1}", fileInfo.Name, e.Messages)); } } }
private void remove_Click(object sender, EventArgs e) { EditorDialog editorDialog = FindForm() as EditorDialog; if (editorDialog != null) { editorDialog.RemoveItem(this); } }
private void add_Click(object sender, EventArgs e) { EditorDialog editorDialog = FindForm() as EditorDialog; if (editorDialog != null) { editorDialog.AddNewItem(this); } }
private void m_memberTextBox_TextChanged(object sender, EventArgs e) { EditorDialog editorDialog = FindForm() as EditorDialog; if (editorDialog != null) { editorDialog.ValidateMemberName(this, m_lastMemberName); } m_lastMemberName = m_memberTextBox.Text; }
private void m_exploreButton_Click(object sender, System.EventArgs e) { EditorDialog dialog = new EditorDialog(m_collectonType, m_creator); dialog.JsonString = JsonValue; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { JsonValue = dialog.JsonString; } }
private void BackgroundLoadContextCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { EditorDialog.Error("Unable to load project", e.Error.Message); } else if (!e.Cancelled) { // Update custom imports. this.MenuDataCustomImport.Items.Clear(); foreach (var customImport in this.Context.ProjectSettings.CustomImports) { var menuItem = new MenuItem(); menuItem.Header = string.Format("Import _{0}...", customImport.BlueprintParentId); menuItem.Tag = customImport; menuItem.Click += this.ExecutedCustomImport; this.MenuDataCustomImport.Items.Add(menuItem); } // Update available languages. var languageTags = this.Context.ProjectSettings.LanguageFiles.Select(languageFile => languageFile.LanguageTag); this.Context.SetAvailableLanguages(languageTags); // Load blueprints. try { this.Context.LoadBlueprints(); } catch (FileNotFoundException ex) { EditorDialog.Error("Unable to load blueprints", ex.Message); } this.UpdateWindowTitle(); } // Hide progress bar. this.progressWindow.Close(); // Update recent projects. this.UpdateRecentProjects(); }
public void Initialize(EditSession session) { this.subtype = ((ObjectTypeDecorator)session.Instance).ObjectType; var currentSupertypes = session.Property.GetValue(session.Instance); var text = SuperinterfacesConverter.ToString((ObjectType[])currentSupertypes); this.label = new Label(text); this.PackStart(this.label); var labelLayout = (BoxChild)this[this.label]; labelLayout.Expand = false; var button = new Button("..."); this.PackEnd(button); var buttonLayout = (BoxChild)this[button]; buttonLayout.Expand = false; button.Clicked += delegate { var dialog = new EditorDialog(this.repository, this.subtype); dialog.Response += (o, args) => { if (args.ResponseId == ResponseType.Ok) { this.Value = dialog.Interfaces; var valueChanged = this.ValueChanged; if (valueChanged != null) { valueChanged(this, EventArgs.Empty); } } }; dialog.Run(); dialog.Destroy(); }; this.ShowAll(); }
private void ImportCSVData(CsvImportData importData) { // Show open file dialog box. OpenFileDialog openFileDialog = new OpenFileDialog { AddExtension = true, CheckFileExists = true, CheckPathExists = true, DefaultExt = ".csv", Filter = "Comma-separated values (.csv)|*.csv", ValidateNames = true }; var result = openFileDialog.ShowDialog(); if (result != true) { return; } // Open CSV file. try { using (var stream = openFileDialog.OpenFile()) { var streamReader = new StreamReader(stream); var csvReader = new CsvReader(streamReader); csvReader.Configuration.Delimiter = importData != null ? importData.Delimiter : CsvImportData.DefaultDelimiter; var importCsvDataWindow = new ImportCsvDataWindow(this.Context, csvReader, importData) { Owner = this }; importCsvDataWindow.ShowDialog(); } } catch (IOException e) { EditorDialog.Error("Unable to open CSV file", e.Message); } }
public override void OnDoubleClick(Object sender, EventArgs e) { DrawArea drawArea = (DrawArea)sender; EditorDialog dlg = new EditorDialog(logicIDTail, this, "", drawArea.GraphicsList.TVMVerify, DeviceTypeEnum.TVM, DeviceTypeEnum.TVM, drawArea.GraphicsList.IPVerify); dlg.ArrayId = arrayId; if (dlg.ShowDialog() == DialogResult.OK) { if (this.TagIDBase != 0) { drawArea.GraphicsList.TVMVerify.Remove(logicIDTail); } logicIDTail = dlg.IDvalues; arrayId = dlg.ArrayId; this.x_axis = dlg.X_axis; this.y_axis = dlg.Y_axis; this.width = dlg.RWidth; this.height = dlg.RHeight; RecID = dlg.RecID; StationID = dlg.StationID; DeviceID = dlg.DeviceID; DeviceName = dlg.DeviceName; IpAdd = dlg.IpAdd; DeviceType = dlg.DeviceType; DeviceSubType = dlg.DeviceSubType; GroupID = dlg.GroupID; this.Device_H = dlg.Device_H; this.Device_W = dlg.Device_W; if (TagIDBase == 0) { flag = objIdInc++; } if (drawArea.AddText(this)) { TagIDBase = flag;//与颜色变化有关 this.SetRectangle(x_axis, y_axis, width, height); drawArea.SetDirty(); drawArea.SetDirty(); } } }
/// <summary> /// Use this method to show a dialog for setting new workspace directory. /// </summary> public static void SelectWorkspaceDirectory() { // Get valid folder path string folderPath = EditorDialog.OpenDirectory(); if (string.IsNullOrEmpty(folderPath)) { return; } if (!NyanPath.IsStandardProjectPath(folderPath)) { EditorDialog.OpenAlert( "Error", "Workspace must be placed inside the project, but outside of StreamingAssets, Resources, " + "Plugins, and Editor folder." ); return; } // Setup workspace MvcWorkspace.SetWorkspace(folderPath); }
/// <summary> /// Imports CSV data with the current settings into the current project. /// </summary> private void ImportData() { // Create a blueprint for each CSV row. var blueprintManagerViewModel = this.context.BlueprintManagerViewModel; var processedBlueprints = new HashSet <string>(); var errors = new List <Exception>(); var newBlueprints = 0; var updatedBlueprints = 0; var skippedBlueprints = 0; while (this.csvReader.CurrentRecord != null) { try { // Get id of the blueprint to create or update. var blueprintId = this.csvReader[this.BlueprintIdColumn]; // Skip ignored records, such as notes. if (blueprintId == this.IgnoredBlueprintId) { this.csvReader.Read(); continue; } // Check for duplicate blueprints in the CSV file. if (processedBlueprints.Contains(blueprintId)) { throw new InvalidOperationException(string.Format("Duplicate blueprint id: {0}", blueprintId)); } processedBlueprints.Add(blueprintId); // Check whether blueprint already exists. var dataBlueprint = blueprintManagerViewModel.Blueprints.FirstOrDefault( blueprint => blueprint.BlueprintId == blueprintId); var newBlueprint = dataBlueprint == null; if (newBlueprint) { // Create new blueprint. blueprintManagerViewModel.NewBlueprintId = blueprintId; dataBlueprint = blueprintManagerViewModel.CreateNewBlueprint(); // Reparent new blueprint. blueprintManagerViewModel.ReparentBlueprint( dataBlueprint.BlueprintId, this.BlueprintParent.BlueprintId, false); } else { // Check parent of existing blueprint. if (dataBlueprint.Parent != this.BlueprintParent) { throw new InvalidOperationException( string.Format( "Blueprint {0} is child of {1} but should be child of {2}.", dataBlueprint.BlueprintId, dataBlueprint.Parent.BlueprintId, this.BlueprintParent.BlueprintId)); } } // Map attribute table keys to CSV values. foreach (var valueMapping in this.ValueMappings.Where(mapping => !string.IsNullOrWhiteSpace(mapping.MappingTarget))) { var rawValue = this.csvReader[valueMapping.MappingTarget]; // Skip empty entries. if (string.IsNullOrWhiteSpace(rawValue)) { if (!newBlueprint) { // Reset entry to parent value. dataBlueprint.Blueprint.AttributeTable.RemoveValue(valueMapping.MappingSource); } continue; } object convertedValue; if (!valueMapping.InspectorProperty.TryConvertStringToListOrValue(rawValue, out convertedValue) || convertedValue == null) { throw new CsvParserException( string.Format( "{0}: Unable to convert '{1}' to '{2}' ({3}).", blueprintId, rawValue, valueMapping.MappingSource, valueMapping.InspectorProperty.PropertyType)); } // Check for localized values. var stringProperty = valueMapping.InspectorProperty as InspectorStringAttribute; if (stringProperty != null && stringProperty.Localized) { this.context.LocalizationContext.SetLocalizedStringForBlueprint( blueprintId, valueMapping.MappingSource, (string)convertedValue); } else { dataBlueprint.Blueprint.AttributeTable[valueMapping.MappingSource] = convertedValue; } } // Increase counter. if (newBlueprint) { newBlueprints++; } else { updatedBlueprints++; } } catch (Exception exception) { errors.Add(exception); skippedBlueprints++; } // Read next record. this.csvReader.Read(); } // Show import results. if (errors.Count > 0) { EditorDialog.Warning("Some data could not be imported", errors); } var importInfoBuilder = new StringBuilder(); importInfoBuilder.AppendLine(string.Format("{0} blueprint(s) imported.", newBlueprints)); importInfoBuilder.AppendLine(string.Format("{0} blueprint(s) updated.", updatedBlueprints)); importInfoBuilder.AppendLine(string.Format("{0} blueprint(s) skipped.", skippedBlueprints)); var importInfo = importInfoBuilder.ToString(); EditorDialog.Info("CSV Import Complete", importInfo); if (this.SaveSettingsForFutureImports) { this.SaveImportSettings(); } blueprintManagerViewModel.RefreshBlueprintView(); }
private static void DrawOpenedView(MVCEditor editor, MvcConfig config, MvcConfig.View view, int index) { GUILayout.BeginVertical("LightmapEditorSelectedHighlight"); editingName = ViewNameTrim( EditorGUILayout.TextField("View name", editingName) ); editingBaseClassName = EditorGUILayout.TextField("Custom base class", editingBaseClassName); editingLifeType = (MvcLifeType)EditorGUILayout.EnumPopup("Custom lifecycle", editingLifeType); editingRescaleMode = (MvcRescaleType)EditorGUILayout.EnumPopup("View rescale mode", editingRescaleMode); editingInitial = EditorGUILayout.Toggle("Is initial view?", editingInitial); if (GUILayout.Button("Save & Close")) { if (ApplyEdit(config, view)) { ConfigViewEditorFlags.ResetFlags(); } } EditorColors.SetBackgroundColor(Color.red); { if (GUILayout.Button("Danger Zone!")) { ConfigViewEditorFlags.IsDeleteOpen ^= true; } } EditorColors.ResetBackgroundColor(); if (ConfigViewEditorFlags.IsDeleteOpen) { GUILayout.BeginVertical("GroupBox"); EditorGUILayout.HelpBox( "It is highly recommended to apply configurations first before performing any actions here.", MessageType.Warning ); // Red background for danger zone buttons EditorColors.SetBackgroundColor(Color.red); { if (GUILayout.Button("Delete config")) { if (EditorDialog.OpenAlert( "Delete view configuration.", "Are you sure you want to delete this view's configuration? " + DeleteWarning, "Yes", "No")) { // Remove view from views list. MvcViewRemover.RemoveFromConfig(config.Views, index); ConfigViewEditorFlags.Setup(config); ConfigViewEditorFlags.ResetFlags(); } } // If loaded from resources, the user must've already created a prefab or at least scripts. if (view.IsFromResources) { EditorGUILayout.Space(); if (GUILayout.Button("Delete prefab")) { // Confirm prefab deletion if (EditorDialog.OpenAlert( "Delete view prefab", "Are you sure you want to delete this view's prefab? " + DeleteWarning, "Yes", "No")) { MvcViewRemover.RemovePrefab(view); } } EditorGUILayout.Space(); if (GUILayout.Button("Delete all")) { // Confirm deletion of all view-related things if (EditorDialog.OpenAlert( "Delete view config, scripts, prefab", "Are you sure you want to delete this view's config, scripts, and prefab?" + DeleteWarning, "Yes", "No")) { MvcViewRemover.RemoveFromConfig(config.Views, index); MvcViewRemover.RemoveScripts(view); MvcViewRemover.RemovePrefab(view); MvcViewRemover.Finalize(config); ConfigViewEditorFlags.Setup(config); ConfigViewEditorFlags.ResetFlags(); } } } } EditorColors.ResetBackgroundColor(); GUILayout.EndVertical(); } GUILayout.EndVertical(); }
public override void OnDoubleClick(Object sender, EventArgs e) { string entryValue; if (_entry == EDirection.Left) { entryValue = "Left"; } else if (_entry == EDirection.Right) { entryValue = "Right"; } else if (_entry == EDirection.Up) { entryValue = "Up"; } else { entryValue = "Down"; } DrawArea drawArea = (DrawArea)sender; EditorDialog dlg = new EditorDialog(_logicIDTail, this, entryValue, drawArea.GraphicsList.AGMVerify, DeviceTypeEnum.AGM, DeviceTypeEnum.AGM_Sub_AGMChannelDual, drawArea.GraphicsList.IPVerify); // dlg.ArrayId = arrayId; if (dlg.ShowDialog() == DialogResult.OK) { if (this._tagIDBase != 0) { drawArea.GraphicsList.AGMVerify.Remove(_logicIDTail); } _logicIDTail = dlg.IDvalues; arrayId = dlg.ArrayId; this.x_axis = dlg.X_axis; this.y_axis = dlg.Y_axis; this.width = dlg.RWidth; this.height = dlg.RHeight; RecID = dlg.RecID; StationID = dlg.StationID; DeviceID = dlg.DeviceID; DeviceName = dlg.DeviceName; IpAdd = dlg.IpAdd; DeviceType = dlg.DeviceType; DeviceSubType = dlg.DeviceSubType; GroupID = dlg.GroupID; this.Device_H = dlg.Device_H; this.Device_W = dlg.Device_W; if (dlg.Entryvalues == "Left") { this.Entry = EDirection.Left; } else if (dlg.Entryvalues == "Right") { this.Entry = EDirection.Right; } else if (dlg.Entryvalues == "Up") { this.Entry = EDirection.Up; } else { this.Entry = EDirection.Down; } if (_tagIDBase == 0) { _flag = _objIdInc++; } if (drawArea.AddText(this)) { _tagIDBase = _flag; this.SetRectangle(x_axis, y_axis, width, height); drawArea.SetDirty(); drawArea.Refresh(); } } }
// only editor.. show dummy gui void OnGUI() { EditorDialog.Draw(); }
/// <summary> /// Displays the validation result via editor alert message. /// </summary> public static void DisplayAlert(ValidationResult result) { #if UNITY_EDITOR EditorDialog.OpenAlert(result.ToString(), ParseMessage(result)); #endif }
public FieldContainer( EditorDialog dialog, CollectionPropertyEditorUtils.CollectionType collectionType, Func <Dictionary <string, string>, string, PropertyEditor <T> > creator, string jsonValue, string memberName = null ) { m_collectionType = collectionType; m_creator = creator; if (m_creator == null) { throw new Exception("Creator cannot be null!"); } MetroSkinManager.ApplyMetroStyle(this); Height = 0; MetroTile remove = new MetroTile(); MetroSkinManager.ApplyMetroStyle(remove); remove.Text = "-"; remove.TextAlign = ContentAlignment.MiddleCenter; remove.TileTextFontWeight = MetroTileTextWeight.Bold; remove.Width = DEFAULT_BUTTON_SIZE + DEFAULT_BUTTON_SIZE; remove.Height = DEFAULT_BUTTON_SIZE; remove.Left = Width - remove.Width; remove.Anchor = AnchorStyles.Top | AnchorStyles.Right; remove.Click += new EventHandler(remove_Click); Controls.Add(remove); MetroTile add = new MetroTile(); MetroSkinManager.ApplyMetroStyle(add); add.Text = "+"; add.TextAlign = ContentAlignment.MiddleCenter; add.TileTextFontWeight = MetroTileTextWeight.Bold; add.Width = DEFAULT_BUTTON_SIZE + DEFAULT_BUTTON_SIZE; add.Height = DEFAULT_BUTTON_SIZE; add.Left = Width - add.Width - DEFAULT_SEPARATOR - remove.Width; add.Anchor = AnchorStyles.Top | AnchorStyles.Right; add.Click += new EventHandler(add_Click); Controls.Add(add); Height += Math.Max(add.Height, remove.Height); if (m_collectionType == CollectionPropertyEditorUtils.CollectionType.JsonObject) { m_memberTextBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_memberTextBox); m_memberTextBox.Text = memberName; m_memberTextBox.Width = Width; m_memberTextBox.Top = Height; m_memberTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; m_memberTextBox.TextChanged += new EventHandler(m_memberTextBox_TextChanged); Controls.Add(m_memberTextBox); Height += m_memberTextBox.Height; } try { m_propertyEditor = m_creator(m_imHereForNothing, "-.-"); if (m_propertyEditor == null) { throw new Exception("Property editor couldn't be created properly!"); } MetroUserControl editor = m_propertyEditor as MetroUserControl; IEditorJsonValue jvEditor = m_propertyEditor as IEditorJsonValue; if (editor != null && jvEditor != null) { jvEditor.Text = "Item"; jvEditor.JsonValue = jsonValue; jvEditor.UpdateEditorValue(); editor.Width = Width; editor.Top = Height; editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; Controls.Add(editor); Height += editor.Height; } } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } ErrorPropertyEditor editor = new ErrorPropertyEditor("Item", ex.Message); editor.Tag = string.Format("{0}\n{1}\n\nStack trace:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); editor.Width = Width; editor.Top = Height; editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; Controls.Add(editor); Height += editor.Height; } }
private void buttonAdd_Click(object sender, System.EventArgs e) { var tag = new Tag {HighlightColor = Color.Blue}; using (var dialog = new EditorDialog<Tag>()) dialog.ShowDialog(this, tag); if (string.IsNullOrEmpty(tag.Name)) Msg.Inform(this, "Tag name cannot be empty.", MsgSeverity.Warn); else if (TreeView.Nodes.Contains(tag.Name)) Msg.Inform(this, "Tag name already used.", MsgSeverity.Warn); else AddTag(tag); }