Ejemplo n.º 1
0
        private void AddShape_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Filter = "All supported files|*.jpeg;*.jpg;*.png;*.bmp;*.dat;*.cor;|Image files|*.jpeg;*.jpg;*.png;*.bmp|Coordinate files|*.dat;*.cor;";

            var useHeightmap = false;

            if (dlg.ShowDialog().Value)
            {
                var filename = dlg.FileName;
                if (useHeightmap)
                {
                    var reliefShape = _factory.LoadRelief(filename, out var name);
                    if (reliefShape != null)
                    {
                        var reliefShapeItem = new MillingShapeItemRelief(name, reliefShape);
                        reliefShapeItem.MetricHeight = 100;
                        Workspace.Children.Add(reliefShapeItem);
                    }
                }
                else
                {
                    var flatShape = _factory.Load(filename, out var name);
                    if (flatShape != null)
                    {
                        var shapeItem = new MillingShapeItem2D(name, flatShape);
                        shapeItem.MetricHeight = 100;
                        Workspace.Children.Add(shapeItem);
                    }
                }
            }
        }
Ejemplo n.º 2
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);
        }