StonehearthEditor.ManifestView.OnJsonFileDataSelected C# (CSharp) Method

OnJsonFileDataSelected() private method

private OnJsonFileDataSelected ( ) : void
return void
        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);
                        }
                    }
                }
            }
        }