private FileData GetFileDataFactory(string path) { string extension = System.IO.Path.GetExtension(path); switch (extension) { case ".qb": QubicleFileData qubicleFile = new QubicleFileData(path); qubicleFile.AddLinkingJsonFile(this); qubicleFile.RelatedFiles.Add(this); qubicleFile.Load(); return(qubicleFile); case ".png": ImageFileData imageFile = new ImageFileData(path); imageFile.AddLinkingJsonFile(this); imageFile.RelatedFiles.Add(this); return(imageFile); case ".json": JsonFileData jsonFileData = new JsonFileData(path); jsonFileData.Load(); jsonFileData.RelatedFiles.Add(this); return(jsonFileData); } return(null); }
protected override void LoadInternal() { if (mIsQb) { // see if the qmo exists string qmoPath = GetQmoPath(); if (System.IO.File.Exists(qmoPath)) { mHasQmo = true; QubicleFileData qmoFile = new QubicleFileData(qmoPath); LinkedFileData.Add(qmoPath, qmoFile); } } }
private void OnJsonFileDataSelected() { JsonFileData fileData = mSelectedFileData as JsonFileData; if (fileData.TreeNode != null) { treeView.SelectedNode = fileData.TreeNode; } List <string> addedOpenFiles = new List <string>(); bool hasImage = false; foreach (FileData openedFile in fileData.OpenedFiles) { TabPage newTabPage = new TabPage(); newTabPage.Text = openedFile.FileName; if (ModuleDataManager.GetInstance().ModifiedFiles.Contains(openedFile)) { newTabPage.Text = newTabPage.Text + "*"; } if (openedFile.HasErrors) { newTabPage.ImageIndex = 0; newTabPage.ToolTipText = openedFile.Errors; } FilePreview filePreview = new FilePreview(this, openedFile); filePreview.Dock = DockStyle.Fill; newTabPage.Controls.Add(filePreview); filePreviewTabs.TabPages.Add(newTabPage); foreach (KeyValuePair <string, FileData> linkedFile in openedFile.LinkedFileData) { if (addedOpenFiles.Contains(linkedFile.Key)) { continue; } addedOpenFiles.Add(linkedFile.Key); if (linkedFile.Value is QubicleFileData) { QubicleFileData qbFileData = linkedFile.Value as QubicleFileData; string fileName = qbFileData.FileName; Button openFileButton = new Button(); openFileButton.Name = qbFileData.GetOpenFilePath(); openFileButton.BackgroundImage = global::StonehearthEditor.Properties.Resources.qmofileicon_small; openFileButton.BackgroundImageLayout = ImageLayout.None; openFileButton.Text = Path.GetFileName(openFileButton.Name); openFileButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight; openFileButton.UseVisualStyleBackColor = true; openFileButton.Click += new System.EventHandler(openFileButton_Click); openFileButton.Padding = new Padding(22, 2, 2, 2); openFileButton.AutoSize = true; openFileButtonPanel.Controls.Add(openFileButton); } else if (linkedFile.Value is ImageFileData) { string imageFilePath = linkedFile.Value.Path; if (System.IO.File.Exists(imageFilePath)) { if (!hasImage) { iconView.ImageLocation = imageFilePath; hasImage = true; } Button openFileButton = new Button(); openFileButton.Name = imageFilePath; Image thumbnail = ThumbnailCache.GetThumbnail(imageFilePath); openFileButton.BackgroundImage = thumbnail; openFileButton.BackgroundImageLayout = ImageLayout.None; openFileButton.Text = Path.GetFileName(openFileButton.Name); openFileButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight; openFileButton.UseVisualStyleBackColor = true; openFileButton.Click += new System.EventHandler(openFileButton_Click); openFileButton.Padding = new Padding(22, 2, 2, 2); openFileButton.AutoSize = true; openFileButtonPanel.Controls.Add(openFileButton); } } } } }