コード例 #1
0
        private void DuplicateTexture_Execute(object parameter)
        {
            PssgTextureViewModel   texView = (PssgTextureViewModel)parameter;
            DuplicateTextureWindow dtw     = new DuplicateTextureWindow();

            dtw.TextureName = texView.DisplayName + "_2";

            if (dtw.ShowDialog() == true)
            {
                // Copy and Edit Name
                PssgNode nodeToCopy = texView.Texture;
                PssgNode newTexture = new PssgNode(nodeToCopy);
                newTexture.Attributes["id"].Value = dtw.TextureName;

                // Add to Library
                if (nodeToCopy.ParentNode != null)
                {
                    nodeToCopy.ParentNode.AppendChild(newTexture);
                    PssgNodeViewModel newNodeView = new PssgNodeViewModel(newTexture, texView.NodeView.Parent);
                    texView.NodeView.Parent.Children.Add(newNodeView);
                    Textures.Add(new PssgTextureViewModel(newNodeView));
                }
                else
                {
                    nodeToCopy.AppendChild(newTexture);
                    PssgNodeViewModel newNodeView = new PssgNodeViewModel(newTexture, texView.NodeView);
                    texView.NodeView.Children.Add(newNodeView);
                    Textures.Add(new PssgTextureViewModel(newNodeView));
                }
            }
        }
コード例 #2
0
        private void RemoveTextureC_Execute(object parameter)
        {
            PssgTextureViewModel texView = (PssgTextureViewModel)parameter;

            texView.Texture.ParentNode.RemoveChild(texView.Texture);
            texView.NodeView.Parent.Children.Remove(texView.NodeView);
            RemoveTexture(texView.NodeView);
        }
コード例 #3
0
        private void Import_Execute(object parameter)
        {
            PssgTextureViewModel texView = (PssgTextureViewModel)parameter;
            PssgNode             node    = texView.Texture;
            OpenFileDialog       dialog  = new OpenFileDialog();

            dialog.Filter   = "Dds files|*.dds|All files|*.*";
            dialog.Title    = "Select a dds file";
            dialog.FileName = node.Attributes["id"].DisplayValue + ".dds";
            if (dialog.ShowDialog() == true)
            {
                try
                {
                    DdsFile dds = new DdsFile(File.Open(dialog.FileName, FileMode.Open));
                    dds.Write(node);
                    texView.GetPreview();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not import texture!" + Environment.NewLine + Environment.NewLine +
                                    ex.Message, "Import Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }