public void UpdateLastSelectedResourcePath(string resourcePath, TreeNode node = null) { Canvas.Enabled = true; Canvas.Shapes.Clear(); int X0 = 20; int Y0 = 20; int textLineHeight = 20; ResourceObjectEditor objectEditor = JxResApp.Instance.ResourceObjectEditor; if (objectEditor is EntityTypeResourceEditor) { EntityTypeResourceEditor entityTypeEditor = objectEditor as EntityTypeResourceEditor; Jx.Drawing.Base.Text text = new Jx.Drawing.Base.Text(); text.DisplayedText = resourcePath; text.Location = new PointF(10, 10); text.Font = new Font("Courier New", 10, FontStyle.Regular); Canvas.Shapes.Add(text); } else { int x = X0, y = Y0; List <string> textMessages = new List <string>(); textMessages.Add( string.Format("路径: {0}", resourcePath) ); textMessages.Add( "Ok" ); for (int i = 0; i < textMessages.Count; i++) { PointF pt = new PointF(x, y); Text tx = CreateCanvasText(textMessages[i], pt); if (tx != null) { tx.Transformer.Translate(x, y); } y += textLineHeight; } //Canvas.Enabled = false; } #if DEBUG_RES Log.Info(">> Update Last Selected ResourcePath: {0}", resourcePath); #endif Canvas.Invalidate(); }
public bool ChangeResourceObjectEditor(string fileName) { this.currentResourcePath = fileName; this.currentResourceFileSize = 0L; try { if (!string.IsNullOrEmpty(this.currentResourcePath)) { this.currentResourceFileSize = VirtualFile.GetLength(this.currentResourcePath); } } catch { } this.currentResourceIsArchive = false; try { if (!string.IsNullOrEmpty(this.currentResourcePath)) { this.currentResourceIsArchive = VirtualFile.IsArchive(this.currentResourcePath); } } catch { } this.currentResourceIsInArchive = false; try { if (!string.IsNullOrEmpty(this.currentResourcePath)) { this.currentResourceIsInArchive = VirtualFile.IsInArchive(this.currentResourcePath); } } catch { } if (this.currentResourceObjectEditor != null) { if (fileName != null && string.Compare(this.currentResourceObjectEditor.FileName, fileName, true) == 0) { return(true); } if (this.currentResourceObjectEditor.EditModeActive && !this.currentResourceObjectEditor.EndEditMode()) { return(false); } this.currentResourceObjectEditor.Dispose(); this.currentResourceObjectEditor = null; } if (fileName != null) { string text = Path.GetExtension(fileName); if (!string.IsNullOrEmpty(text)) { text = text.Substring(1); if (ResourceTypeManager.Instance != null) { ResourceType byExtension = ResourceTypeManager.Instance.GetByExtension(text); if (byExtension != null) { Type resourceObjectEditorType = byExtension.ResourceObjectEditorType; ConstructorInfo constructor = resourceObjectEditorType.GetConstructor(new Type[0]); this.currentResourceObjectEditor = (ResourceObjectEditor)constructor.Invoke(new object[0]); this.currentResourceObjectEditor.Create(byExtension, fileName); } } } } if (MainForm.Instance != null && this.currentResourceObjectEditor == null) { MainForm.Instance.PropertiesForm.SelectObjects(null); } return(true); }