示例#1
0
        internal async void SaveCode()
        {
            FolderPicker folderPicker = new FolderPicker();

            folderPicker.FileTypeFilter.Add("*");
            folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            string ext = (string)BasicLib.GetSetting(SettingsNames.GCODE_FILE_EXT);

            foreach (GcodeFile f in Code)
            {
                try
                {
                    if (System.IO.Path.GetExtension(f.FileName) != ext)
                    {
                        f.FileName = System.IO.Path.ChangeExtension(f.FileName, ext);
                    }

                    StorageFile file = await folder.CreateFileAsync(f.FileName, CreationCollisionOption.ReplaceExisting);

                    if (file != null)
                    {
                        await Windows.Storage.FileIO.WriteTextAsync(file, f.Code);
                    }
                }
                catch (Exception e)
                {
                    CoreWindowDialog dlg = new CoreWindowDialog(e.Message);
                    dlg.ShowAsync();
                }
            }
        }
示例#2
0
        void GenerateCodeInMultipleFiles()
        {
            // first generate subroutines or paths
            // then main program to call them
            StringBuilder sb = new StringBuilder();

            foreach (Shape s in _currentToolPaths.Shapes)
            {
                if (s is Polygon)
                {
                    GenerateSubFromPolygon(ref sb, (s as Polygon));
                }
                else if (s is Windows.UI.Xaml.Shapes.Path)
                {
                    GenerateSubFromPath(ref sb, (s as Windows.UI.Xaml.Shapes.Path));
                }

                string filename = string.Empty;
                string ext      = (string)BasicLib.GetSetting(SettingsNames.GCODE_FILE_EXT);
                // now deal with name and save in code list
                if ((bool)BasicLib.GetSetting(SettingsNames.USE_NAMED_O_WORDS))
                {
                    BindableCodeTemplate tmpl = _context.Templates.SubFilenameTemplate;
                    tmpl.DataContext = _context;
                    filename         = System.IO.Path.ChangeExtension(tmpl.Text, ext);
                }
                else
                {
                    filename = System.IO.Path.ChangeExtension(_context.SubPathName.ToString(), ext);
                }
                Code.Add(new GcodeFile(filename, sb.ToString()));
            }

            GenerateMain();
        }
示例#3
0
 /// <summary>
 /// These properties have been moved from the lattive
 /// </summary>
 public LayoutData()
 {
     _repeatX         = (int)BasicLib.GetSetting(SettingsNames.REPEAT_X);
     _repeatY         = (int)BasicLib.GetSetting(SettingsNames.REPEAT_Y);
     _toolposition    = (double)BasicLib.GetSetting(SettingsNames.TOOL_POSITION);
     _workPieceRadius = (double)BasicLib.GetSetting(SettingsNames.WORK_PIECE_RADIUS);
     _clipRange       = new Range(0, 0.001, _toolposition);
     _width           = (double)BasicLib.GetSetting(SettingsNames.WIDTH);
     _height          = (double)BasicLib.GetSetting(SettingsNames.HEIGHT);
     _margin          = (double)BasicLib.GetSetting(SettingsNames.MARGIN);
     _offsetX         = (double)BasicLib.GetSetting(SettingsNames.OFFSET_X);
     _offsetY         = (double)BasicLib.GetSetting(SettingsNames.OFFSET_Y);
     _clip            = (bool)BasicLib.GetSetting(SettingsNames.CLIP);
     _hypo            = (bool)BasicLib.GetSetting(SettingsNames.HYPO);
     _k = (double)BasicLib.GetSetting(SettingsNames.HYPO_K);
 }
示例#4
0
        private void GenerateMain()
        {
            StringBuilder sb = new StringBuilder();

            Bind(ref sb, _context.Templates.Header_Template);
            Bind(ref sb, _context.Templates.Globals_Template);
            Bind(ref sb, _context.Templates.MainProgramTemplate);
            foreach (Shape s in _currentToolPaths.Shapes)
            {
                Bind(ref sb, _context.Templates.SubCallTemplate);
            }
            Bind(ref sb, _context.Templates.ProgramEndTemplate);

            string ext = (string)BasicLib.GetSetting(SettingsNames.GCODE_FILE_EXT);
            BindableCodeTemplate tmpl = _context.Templates.MainFilenameTemplate;

            tmpl.DataContext = _context;
            Code.Add(new GcodeFile(System.IO.Path.ChangeExtension(tmpl.Text, ext), sb.ToString()));
        }