예제 #1
0
파일: MapBehavior.cs 프로젝트: cramt/deenee
        public override void OnUpdate(OnUpdateProperties onUpdateProperties)
        {
            base.OnUpdate(onUpdateProperties);

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.L))
            {
                ExtensionFilter objFilter   = new ExtensionFilter("3D files", "3D", "3DS", "3MF", "AC", "AC3D", "ACC", "AMF", "AMJ", "ASE", "ASK", "B3D", "BLEND", "BVH", "COB", "DAE", "DXF", "ENFF", "FBX", "IRR", "LWO", "LWS", "LXO", "MD2", "MD3", "MD5", "MDC", "MDL", "MESH", "MOT", "MS3D", "NDO", "NFF", "OBJ", "OFF", "OGEX", "PLY", "PMX", "PRJ", "Q3O", "Q3S", "RAW", "SCN", "SIB", "SMD", "STL", "TER", "UC", "VTA", "X", "X3D", "XGL", "ZGL");
                ExtensionFilter imageFilter = new ExtensionFilter("Image files", "png", "jpg", "jpeg");
                StandaloneFileBrowser.OpenFilePanelAsync("Load File", "", new ExtensionFilter[] { objFilter, imageFilter }, true, (string[] paths) => {
                    paths.ToList().ForEach(path => {
                        string name      = new FileInfo(path).Name;
                        string[] split   = name.Split('.');
                        string nameWOext = split[0];
                        string ext       = split[1];
                        if (objFilter.Extensions.Contains(ext.ToUpper()))
                        {
                            byte[] data = File.ReadAllBytes(path);
                            Main.campaign.AddObject(name, data);
                            //TODO: actually do this
                        }
                        else
                        {
                        }
                    });
                });
            }
        }
    public bool OpenFilePanel(ExtensionFilter filter, string defExt, out string resultPath)
    {
        resultPath = string.Empty;
        resultPath = UnityEditor.EditorUtility.OpenFilePanel("Open file", "", defExt);

        return(!string.IsNullOrEmpty(resultPath));
    }
예제 #3
0
    private string SaveDataSentences(string fileContent, GUI_TextFieldButton currentButton, string sentences)
    {
        ExtensionFilter[] filter = new ExtensionFilter[]
        {
            new ExtensionFilter("Sentence", sentences),
        };

        var path = currentButton.SavePath;

        if (string.IsNullOrEmpty(path))
        {
            path = StandaloneFileBrowser.SaveFilePanel("Save Sentence", GetRootDirectory(), currentButton.GetButtonName(), filter);
        }
        else if (_showDialog)
        {
            var directory = Path.GetDirectoryName(path);
            path = StandaloneFileBrowser.SaveFilePanel("Save Sentence", directory, currentButton.GetButtonName(), filter);
        }

        if (!string.IsNullOrEmpty(path))
        {
            if (!Path.HasExtension(path) || Path.GetExtension(path) != "." + SENTENCES)
            {
                path += "." + SENTENCES;
            }
            File.WriteAllText(path, fileContent);
            _lastChoosenDirectory = Path.GetDirectoryName(path);
            currentButton.SetSavePath(path);
        }

        return(path);
    }
예제 #4
0
    private string SaveDataWorld(string fileContent, string world, Board board, string defaultName = "")
    {
        ExtensionFilter[] filter = new ExtensionFilter[]
        {
            new ExtensionFilter("World", world),
        };

        var path = board.SavePath;

        if (string.IsNullOrEmpty(path))
        {
            path = StandaloneFileBrowser.SaveFilePanel("Save World", GetRootDirectory(), defaultName, filter);
        }
        else if (_showDialog)
        {
            var directory = Path.GetDirectoryName(path);
            path = StandaloneFileBrowser.SaveFilePanel("Save World", directory, defaultName, filter);
        }

        if (!string.IsNullOrEmpty(path))
        {
            if (!Path.HasExtension(path) || Path.GetExtension(path) != "." + WORLD)
            {
                path += "." + WORLD;
            }
            File.WriteAllText(path, fileContent);
            _lastChoosenDirectory = Path.GetDirectoryName(path);
            board.SetSavePath(path);
        }

        return(path);
    }
    static string ParseExtentionFilter(ExtensionFilter exFilter)
    {
        // "Chart files (*.chart, *.mid)\0*.chart;*.mid"
        StringBuilder sb = new StringBuilder();

        sb.Append(exFilter.name);
        sb.Append(" (");

        for (int i = 0; i < exFilter.extensions.Length; ++i)
        {
            sb.Append("*.");
            sb.Append(exFilter.extensions[i]);

            if (i < exFilter.extensions.Length - 1)
            {
                sb.Append(", ");
            }
        }

        sb.Append(")\0");

        for (int i = 0; i < exFilter.extensions.Length; ++i)
        {
            sb.Append("*.");
            sb.Append(exFilter.extensions[i]);

            if (i < exFilter.extensions.Length - 1)
            {
                sb.Append(";");
            }
        }

        return(sb.ToString());
    }
예제 #6
0
        public bool CanExecute(IList <object> items)
        {
            if (items == null || items.Count == 0)
            {
                return(false);
            }

            if (items.Count > 1 && SelectionFilter == SelectionFilter.Single)
            {
                return(false);
            }

            if (items.Count == 1 && SelectionFilter == SelectionFilter.Multiple)
            {
                return(false);
            }

            if (items.OfType <FileModel>().Any(x => x.IsDirectory) && ItemTypeFilter == ItemTypeFilter.File)
            {
                return(false);
            }

            if (items.OfType <FileModel>().Any(x => !x.IsDirectory) && ItemTypeFilter == ItemTypeFilter.Folder)
            {
                return(false);
            }

            if (items.OfType <FileModel>().Any(x => ExtensionFilter != null && ExtensionFilter.Split('|').Any(y => x.FullName.OrdinalEndsWith(y)) == false))
            {
                return(false);
            }

            return(true);
        }
 public static void OpenExcel()
 {
     ExtensionFilter[] filter = new ExtensionFilter[1] {
         new ExtensionFilter("xls", "xls")
     };
     StandaloneFileBrowser.OpenFilePanelAsync("Choose xls file", Application.streamingAssetsPath, filter, false, OnSuccess);
 }
    public bool SaveFilePanel(ExtensionFilter filter, string defaultFileName, string defExt, out string resultPath)
    {
        var fd = new VistaSaveFileDialog();

        fd.Title = "Save As";

        var finalFilename = "";

        if (!string.IsNullOrEmpty(defaultFileName))
        {
            finalFilename += defaultFileName;
        }

        fd.FileName     = finalFilename;
        fd.Filter       = GetFilterFromFileExtensionList(filter);
        fd.FilterIndex  = 1;
        fd.DefaultExt   = defExt;
        fd.AddExtension = true;

        var res      = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
        var filename = res == DialogResult.OK ? fd.FileName : string.Empty;

        fd.Dispose();
        resultPath = filename;

        return(!string.IsNullOrEmpty(resultPath));
    }
예제 #9
0
 /**
  * @brief 오픈할 모션파일에 대한 선택 브라우저를 띄우고, 선택한 파일을 표시합니다.
  */
 public void OpenMotionFile()
 {
     ExtensionFilter[] extensions = new ExtensionFilter[1];
     extensions[0] = new ExtensionFilter(string.Empty, "bvh");
     //m_MotionFilePath = FileBrowser.OpenSingleFile("Open File", "", extensions);
     m_MotionPathLB.text = FileBrowser.OpenSingleFile("Open File", "", extensions);
 }
예제 #10
0
    protected override void ButtonClickedListener()
    {
        var extensions = new ExtensionFilter[]
        {
            new ExtensionFilter("World/Sentence", GUI_SaveCurrentGame.WORLD, GUI_SaveCurrentGame.SENTENCES),
            new ExtensionFilter("World", GUI_SaveCurrentGame.WORLD),
            new ExtensionFilter("Sentence", GUI_SaveCurrentGame.SENTENCES)
        };

        var pathSelection = StandaloneFileBrowser.OpenFilePanel("Load World/Sentence", GetDirectory(), extensions, false);

        if (pathSelection != null && pathSelection.Length > 0)
        {
            var filePath  = pathSelection[0];
            var extension = Path.GetExtension(filePath).Trim('.');
            _lastChoosenDirectory = Path.GetDirectoryName(filePath);

            switch (extension)
            {
            case GUI_SaveCurrentGame.SENTENCES:
                LoadSentences(filePath);
                break;

            case GUI_SaveCurrentGame.WORLD:
                LoadWorldObj(filePath);
                break;
            }
        }
    }
예제 #11
0
    public void Test()
    {
        ExtensionFilter[] extenstions = new ExtensionFilter[1];
        extenstions[0] = new ExtensionFilter("Images", "png", "jpg");

        path = StandaloneFileBrowser.OpenFilePanel("Open Image", "", extenstions, false)[0];
    }
예제 #12
0
        /// <summary>
        /// Gets metadata describing all extensions of the input <paramref name="extensionPoint"/>,
        /// matching the given <paramref name="filter"/>.
        /// </summary>
        /// <param name="extensionPoint">The <see cref="ExtensionPoint"/> whose extension metadata is to be retrieved.</param>
        /// <param name="filter">An <see cref="ExtensionFilter"/> used to filter out extensions with particular characteristics.</param>
        /// <returns></returns>
        public virtual ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
        {
            if (extensionPoint == null)
            {
                throw new ArgumentNullException("extensionPoint");
            }

            var extensionPointType = extensionPoint.GetType();

            if (!_extensionMap.ContainsKey(extensionPointType))
            {
                return(new ExtensionInfo[0]);
            }

            var extensions = new List <ExtensionInfo>();

            foreach (var extensionType  in _extensionMap[extensionPointType])
            {
                var extensionInfo = new ExtensionInfo(extensionType, extensionPointType, extensionType.Name, extensionType.AssemblyQualifiedName, true);
                if (filter == null || filter.Test(extensionInfo))
                {
                    extensions.Add(extensionInfo);
                }
            }
            return(extensions.ToArray());
        }
			public ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
			{
				Console.WriteLine(extensionPoint);
				if (extensionPoint is ExpressionFactoryExtensionPoint)
					return new[] { new ExtensionInfo(typeof(ConstantExpressionFactory), extensionPoint.GetType(), null, null, true),  };

				return new ExtensionInfo[0];
			}
			public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
			{
				Console.WriteLine(extensionPoint);
				if (extensionPoint is ExpressionFactoryExtensionPoint)
					return new object[] { new ConstantExpressionFactory() };

				return new object[0];
			}
예제 #15
0
        public void BuildTest2()
        {
            ExtensionFilter ef = ExtensionFilter.Build("docx?");

            Assert.IsTrue(ef.Accepts("test.doc"));
            Assert.IsTrue(ef.Accepts("test.docx"));
            Assert.IsFalse(ef.Accepts("test.mkv"));
        }
예제 #16
0
 public ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
 {
     if (extensionPoint is CacheProviderExtensionPoint)
     {
         return(new[] { new ExtensionInfo(typeof(TestCacheProvider), typeof(CacheProviderExtensionPoint), null, null, true) });
     }
     throw new NotImplementedException();
 }
예제 #17
0
        public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
        {
            if (extensionPoint.GetType() == typeof(ProcedureStepBuilderExtensionPoint))
            {
                return(new object[] { new ModalityProcedureStepBuilder() });
            }

            return(new object[] { });
        }
예제 #18
0
            public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
            {
                if (extensionPoint is CacheProviderExtensionPoint)
                {
                    return(new[] { new TestCacheProvider() });
                }

                throw new NotImplementedException();
            }
예제 #19
0
 public Crawler(string url, int depth, Verbose verbose, string extensions) : this(url)
 {
     this.url             = url;
     this.depth           = depth;
     this.verbose         = verbose;
     this.extensions      = extensions;
     this.extensionFilter = new ExtensionFilter(extensions);
     this.verboseFilter   = new VerboseFilter(verbose, baseUri);
 }
    public bool SaveFilePanel(ExtensionFilter filter, string defaultFileName, string defExt, out string resultPath)
    {
        resultPath = string.Empty;

        defaultFileName = FileExplorer.StripIllegalChars(defaultFileName);
        resultPath      = UnityEditor.EditorUtility.SaveFilePanel("Save as...", "", defaultFileName, defExt);

        return(!string.IsNullOrEmpty(resultPath));
    }
예제 #21
0
 public void RenderImage()
 {
     ExtensionFilter[] exts = new ExtensionFilter[] { new ExtensionFilter("PNG image", "png"), new ExtensionFilter("JPG image", "jpg", "jpeg"), new ExtensionFilter("TrueVision TGA", "tga"), new ExtensionFilter("OpenEXR", "exr") };
     _screenshotPath = FileBrowser.SaveFile("Render image", SettingsBehaviour.Instance.Settings.ImageExportDirectory, "", exts);
     if (!string.IsNullOrEmpty(_screenshotPath))
     {
         SettingsBehaviour.Instance.Settings.ImageExportDirectory = _screenshotPath;
         _takeScreenshot = true;
     }
 }
예제 #22
0
    public bool SaveFilePanel(ExtensionFilter filter, string defaultFileName, string defExt, out string resultPath)
    {
        resultPath = Marshal.PtrToStringAnsi(noc_file_dialog_open(
                                                 NOC_FILE_DIALOG_SAVE | NOC_FILE_DIALOG_OVERWRITE_CONFIRMATION,
                                                 GetFilterFromFileExtensionList(new ExtensionFilter[] { filter, new ExtensionFilter("All Files", "*") }),
                                                 null,
                                                 $"{defaultFileName}.{defExt}"));

        return(!string.IsNullOrEmpty(resultPath));
    }
예제 #23
0
    public bool OpenFilePanel(ExtensionFilter filter, string defExt, out string resultPath)
    {
        resultPath = Marshal.PtrToStringAnsi(noc_file_dialog_open(
                                                 NOC_FILE_DIALOG_OPEN,
                                                 GetFilterFromFileExtensionList(new ExtensionFilter[] { filter, new ExtensionFilter("All Files", "*") }),
                                                 null,
                                                 null));

        return(!string.IsNullOrEmpty(resultPath));
    }
예제 #24
0
        /// <summary>
        /// Creates one of each type of object that extends the input <paramref name="extensionPoint" />,
        /// matching the input <paramref name="filter" />; creates a single extension if <paramref name="justOne"/> is true.
        /// </summary>
        /// <param name="extensionPoint">The <see cref="ExtensionPoint"/> to create extensions for.</param>
        /// <param name="filter">The filter used to match each extension that is discovered.</param>
        /// <param name="justOne">Indicates whether or not to return only the first matching extension that is found.</param>
        /// <returns></returns>
        public virtual object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
        {
            var extensions = ListExtensionsCore(extensionPoint, filter);

            if (justOne)
            {
                extensions = extensions.Take(1);
            }
            return(extensions.Select(x => x.CreateInstance()).ToArray());
        }
예제 #25
0
			public ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
			{
				Console.WriteLine(extensionPoint);
				if (extensionPoint.GetType() == typeof(ExpressionFactoryExtensionPoint))
					return new ExtensionInfo[] { new ExtensionInfo(typeof(ConstantExpressionFactory), extensionPoint.GetType(), null, null, true),  };
				if (extensionPoint.GetType() == typeof(XmlSpecificationCompilerOperatorExtensionPoint))
					return new ExtensionInfo[] { };

				return new ExtensionInfo[0];
			}
예제 #26
0
			public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
			{
				Console.WriteLine(extensionPoint);
				if (extensionPoint.GetType() == typeof(ExpressionFactoryExtensionPoint))
					return new object[] { new ConstantExpressionFactory() };
				if (extensionPoint.GetType() == typeof(XmlSpecificationCompilerOperatorExtensionPoint))
					return new object[]{};

				return new object[0];
			}
예제 #27
0
            public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
            {
                if (extensionPoint.GetType() == typeof(DicomCodecFactoryExtensionPoint))
                {
                    return new object[] { new DicomRleCodecFactory() }
                }
                ;

                return(new object[0]);
            }
예제 #28
0
        public void BuildTest1()
        {
            ExtensionFilter ef = ExtensionFilter.Build(new List <string>()
            {
                "txt", "doc", "avi"
            });

            Assert.IsTrue(ef.Accepts("test.txt"));
            Assert.IsTrue(ef.Accepts("test.doc"));
            Assert.IsFalse(ef.Accepts("test.mkv"));
        }
예제 #29
0
        /// <summary>Shows the file picker for loading a skybox from the local file-system.</summary>
        public void LoadSkyboxFromFile()
        {
            SetLoading(false);
            var title      = "Select a skybox image";
            var extensions = new ExtensionFilter[]
            {
                new ExtensionFilter("Radiance HDR Image (hdr)", "hdr")
            };

            StandaloneFileBrowser.OpenFilePanelAsync(title, null, extensions, true, OnSkyboxStreamSelected);
        }
예제 #30
0
 private static bool HasExtension(string path, ExtensionFilter filter)
 {
     foreach (string ext in filter.Extensions)
     {
         if (path.EndsWith('.' + ext))
         {
             return(true);
         }
     }
     return(false);
 }
            public object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
            {
                Console.WriteLine(extensionPoint);
                if (extensionPoint is ExpressionFactoryExtensionPoint)
                {
                    return new object[] { new ConstantExpressionFactory() }
                }
                ;

                return(new object[0]);
            }
예제 #32
0
        /// <summary>
        /// Creates one of each type of object that extends the input <paramref name="extensionPoint" />,
        /// matching the input <paramref name="filter" />; creates a single extension if <paramref name="justOne"/> is true.
        /// </summary>
        /// <param name="extensionPoint">The <see cref="ExtensionPoint"/> to create extensions for.</param>
        /// <param name="filter">The filter used to match each extension that is discovered.</param>
        /// <param name="justOne">Indicates whether or not to return only the first matching extension that is found.</param>
        /// <returns></returns>
        public virtual object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
        {
            var extensionInfos = ListExtensions(extensionPoint, filter);

            if (justOne && extensionInfos.Length > 1)
            {
                extensionInfos = new[] { extensionInfos[0] }
            }
            ;
            return(CollectionUtils.Map <ExtensionInfo, object>(extensionInfos, extensionInfo => Activator.CreateInstance(extensionInfo.ExtensionClass)).ToArray());
        }
    private void SelectFiles(Action <string[]> cb)
    {
        List <string> allExtensions = new List <string>();

        allExtensions.Add("shp");
        var formats    = Interpreter.DataFormats;
        var extFilters = new ExtensionFilter[1];

        extFilters[0] = new ExtensionFilter("Shapefile" + " ", allExtensions.ToArray());

        StandaloneFileBrowser.OpenFilePanelAsync(translator.Get("Select shape file"), "", extFilters, false, cb);
    }
            public ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
            {
                Console.WriteLine(extensionPoint);
                if (extensionPoint is ExpressionFactoryExtensionPoint)
                {
                    return new[] { new ExtensionInfo(typeof(ConstantExpressionFactory), extensionPoint.GetType(), null, null, true), }
                }
                ;

                return(new ExtensionInfo[0]);
            }
        }
예제 #35
0
 /// <summary>
 /// Returns an empty array.
 /// </summary>
 public virtual ExtensionInfo[] ListExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter)
 {
     return new ExtensionInfo[] { };
 }
예제 #36
0
 /// <summary>
 /// Return an empty array.
 /// </summary>
 public virtual object[] CreateExtensions(ExtensionPoint extensionPoint, ExtensionFilter filter, bool justOne)
 {
     return new object[] { };
 }