Esempio n. 1
0
        internal ShapeItem Load(string path)
        {
            var extension  = Path.GetExtension(path).ToLowerInvariant();
            var name       = Path.GetFileNameWithoutExtension(path);
            var identifier = new ReadableIdentifier(name);

            if (_panel != null)
            {
                identifier = _panel.UnusedVersion(identifier);
            }

            if (!_loaders.ContainsKey(extension))
            {
                ShowError("No available loader found.");
                return(null);
            }

            try
            {
                return(_loaders[extension].Load(path, identifier));
            }
            catch (Exception ex)
            {
                ShowError("Loading failed with an error: " + ex.Message);
                return(null);
            }
        }
Esempio n. 2
0
        public double[,] LoadRelief(string path, out ReadableIdentifier identifier)
        {
            var imageLoader = new ImageLoader();
            var map         = imageLoader.LoadRelief(path);

            var extension = Path.GetExtension(path).ToLowerInvariant();
            var name      = Path.GetFileNameWithoutExtension(path);

            identifier = new ReadableIdentifier(name);

            if (_panel != null)
            {
                identifier = _panel.UnusedVersion(identifier);
            }

            return(map);
        }
Esempio n. 3
0
        public MillingItem Load(string path)
        {
            var extension = Path.GetExtension(path);

            if (extension == ".gcode" || extension == ".nc")
            {
                var name       = Path.GetFileNameWithoutExtension(path);
                var identifier = new ReadableIdentifier(name);

                if (_provider != null)
                {
                    identifier = _provider.UnusedVersion(identifier);
                }

                return(new MillingShapeItemGCode(File.ReadAllText(path), identifier));
            }


            var useHeightmap = false;

            if (useHeightmap)
            {
                var reliefShape = _factory.LoadRelief(path, out var name);
                if (reliefShape != null)
                {
                    var reliefShapeItem = new MillingShapeItemRelief(name, reliefShape);
                    reliefShapeItem.MetricHeight = 100;
                    return(reliefShapeItem);
                }
            }
            else
            {
                var flatShape = _factory.Load(path, out var name);
                if (flatShape != null)
                {
                    var shapeItem = new MillingShapeItem2D(name, flatShape);
                    shapeItem.MetricHeight = 100;
                    return(shapeItem);
                }
            }

            return(null);
        }