コード例 #1
0
ファイル: ModelManager.cs プロジェクト: jTitor/leek
 /**
  * true iff model successfully written
  */
 public bool SaveModel(string path)
 {
     if (!FileSystemOps.PathIsValid(path))
     {
         return(false);
     }
     ImporterOps.ExportModel(path, 1);
     updateLog();
     return(true);
 }
コード例 #2
0
ファイル: ModelManager.cs プロジェクト: jTitor/leek
        /*
         * private void readMeshFields(int meshIdx)
         * {
         *      if (meshIdx < 0)
         *      {
         *              return;
         *      }
         *      DiffuseColorBox.SetValues(LColor.FromNativeArray(NativeFunctions.GetMeshMaterialDiffuseColor(1, meshIdx)));
         *      SpecularColorBox.SetValues(LColor.FromNativeArray(NativeFunctions.GetMeshMaterialSpecularColor(1, meshIdx)));
         *      EmissiveColorBox.SetValues(LColor.FromNativeArray(NativeFunctions.GetMeshMaterialEmissiveColor(1, meshIdx)));
         *
         *      DiffuseTexGUIDBox.Text = NativeFunctions.GetMeshMaterialDiffuseMapGUID(1, meshIdx);
         *      SpecularTexGUIDBox.Text = NativeFunctions.GetMeshMaterialSpecularMapGUID(1, meshIdx);
         *      NormalMapGUIDBox.Text = NativeFunctions.GetMeshMaterialDiffuseMapGUID(1, meshIdx);
         *      GlowMapGUIDBox.Text = NativeFunctions.GetMeshMaterialEmissiveMapGUID(1, meshIdx);
         * }
         *
         * private void populateMeshSubsec(int numMeshes)
         * {
         *      selectorElems.Clear();
         *      for (int i = 0; i < numMeshes; ++i)
         *      {
         *              selectorElems.Add(i);
         *      }
         *      MeshSelector.SelectedIndex = 0;
         *      readMeshFields(MeshSelector.SelectedIndex);
         * }
         *
         * private void populateEditorFields()
         * {
         *      if (NativeFunctions.GetNumModelsLoaded() > 0)
         *      {
         *              Vector3 aabbBnd = Vector3.FromNativeArray(NativeFunctions.GetModelAABBBounds(1));
         *              float bndRad = NativeFunctions.GetModelRadius(1);
         *              int numMeshes = NativeFunctions.GetMeshCount(1);
         *
         *              AABBBoundsBox.SetValues(aabbBnd);
         *              BoundingRadiusBox.Text = bndRad.ToString();
         *
         *              populateMeshSubsec(numMeshes);
         *      }
         * }
         */

        /**
         * Return value is an enum; its values are self explanatory
         */
        public async Task <OpenFSElemResult> OpenFSElement(FileSystemInfo elem)
        {
            if (elem != null)
            {
                if (FileSystemOps.IsDirectory(elem))
                {
                    //move into the directory
                    cwd = new DirectoryInfo(elem.FullName);
                    //refreshWindow();
                    updateLog();
                    return(OpenFSElemResult.DirectoryChanged);
                }
                //else it must be some kind of file.
                //may need to reset the loaded model,
                //or (in the future) ask the user
                //if they want to export the current model.
                //check file:
                //is it a .lmdl?
                openedFileName = elem.Name;
                if (elem.Extension.Equals(FileFilters.EngineModel))
                {
                    //...have to quit, since there's no exposed function for
                    //LOADING a .lmdl.
                    updateLog();
                    isModelLoaded = true;
                    return(OpenFSElemResult.FileOpened);
                }
                else
                {
                    //try importing it?
                    int modelIdx = await ImporterOps.ImportModelAsync(elem.FullName, fileProgress);

                    if (modelIdx < 0)
                    {
                        //import failed!
                        openedFileName = "";
                        updateLog();
                        return(OpenFSElemResult.Failure);
                    }
                    buildModelInfo(modelIdx, currVer);
                    updateLog();
                    isModelLoaded = true;
                    return(OpenFSElemResult.FileOpened);
                }
            }
            return(OpenFSElemResult.NoAction);
        }
コード例 #3
0
ファイル: ModelManager.cs プロジェクト: jTitor/leek
        /**
         * true iff directory successfully changed
         */
        public bool ChangeCWD(string newPath)
        {
            //reset if the address is obviously invalid
            if (!FileSystemOps.PathIsValid(newPath))
            {
                return(false);
            }
            var newCwd = new DirectoryInfo(newPath);

            if (!newCwd.Exists)
            {
                return(false);
            }
            //otherwise go to where the address bar is pointing
            cwd = new DirectoryInfo(newPath);
            return(true);
        }
コード例 #4
0
ファイル: Presenter.cs プロジェクト: jTitor/leek
        private void updateFSData()
        {
            //first, the address displayed
            resetAddressBar();
            dirListing.Clear();
            var newList      = FileSystemOps.ListContents(CWD.FullName, true);
            var detailedList = new List <DetailedFSElement>();

            foreach (var elem in newList)
            {
                detailedList.Add(new DetailedFSElement(elem));
            }
            dirListing.AddRange(detailedList);
            //NotifyPropertyChanged("DirListing");
            //dirListView.Refresh();
            //NotifyPropertyChanged("DirListView");
            cwdWatcher.Path = CWD.FullName;
        }
コード例 #5
0
ファイル: ExplorerElement.cs プロジェクト: jTitor/leek
        private void initHeader()
        {
            //Whatever's in the Header is displayed,
            //so to display icons by the name, you can do a StackView
            //starting with the icon, then label.
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            panel.Margin      = padding;
            //load the element's shell icon
            Image elemIcon = new Image();

            elemIcon.Margin = padding;
            try
            {
                System.Drawing.Icon iconRes = FileSystemOps.GetIcon(info.FullName);
                //now convert that into a WPF source and connect it to the image
                elemIcon.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(iconRes.Handle,
                                                                                             Int32Rect.Empty,
                                                                                             BitmapSizeOptions.FromWidthAndHeight(iconSize, iconSize));
            }
            catch
            {
                //set to no source, and default icon size
                elemIcon.Source = null;
                elemIcon.Width  = iconSize;
                elemIcon.Height = iconSize;
            }
            //Set the element's text label too
            TextBlock text = new TextBlock();

            text.Text = info.Name;
            text.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            //text.FontSize = ((double)iconSize) * fontScale;
            //Put those in the stackpanel
            panel.Children.Add(elemIcon);
            panel.Children.Add(text);

            //And set THAT as header.
            Header = panel;
        }
コード例 #6
0
ファイル: DetailedFSElement.cs プロジェクト: jTitor/leek
        public DetailedFSElement(FileSystemInfo pFSInf)
        {
            fsInf       = pFSInf;
            isDirectory = FileSystemOps.IsDirectory(fsInf);
            foreach (string filter in FileFilters.AssimpCompatible)
            {
                if (fsInf.Extension == filter)
                {
                    isImportable = true;
                    break;
                }
            }
            if (fsInf.Extension == FileFilters.EngineModel)
            {
                isEngineModelFile = true;
            }

            //try to load an icon if possible!
            fsIconSource = FileSystemOps.GetImageFromIcon(fsInf.FullName, iconSize);
            //TODO: set a default
        }