Example #1
0
        //private void mnuFontFamilies_MeasureItem(object sender, MeasureItemEventArgs e)
        //{
        //  //throw new NotImplementedException();
        //}

        private void mnuFontFamilies_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                statFontFile.Text = mnuFontFamilies.SelectedItem.ToString();
                string[] strArr = new string[Properties.Settings.Default.CharacterList.Count];
                Properties.Settings.Default.CharacterList.CopyTo(strArr, 0);
                Project = new FontToPathModel(statFontFile.Text, strArr);
                // Clear TreeView
                trvCharacters.Nodes.Clear();
                TreeNode tRoot = trvCharacters.Nodes.Add("Characters");
                foreach (CharacterPath item in Project.CharacterLibrary)
                {
                    tRoot.Nodes.Add(item.Character).Tag = item;
                }
                trvCharacters.ExpandAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void Sv_FileOk_InputText(object sender, CancelEventArgs e)
        {
            List <string> lstChars = new List <string>();

            Cursor = Cursors.WaitCursor;
            SaveFileDialog sv    = (SaveFileDialog)sender;
            string         input = Microsoft.VisualBasic.Interaction.InputBox("Text To G-Code", "Enter text to convert to incremental G-Code:");

            if (!String.IsNullOrEmpty(input))
            {
                FontToPathModel ftp       = new FontToPathModel(mnuFontFamilies.SelectedItem.ToString(), input.ToCharArray().Select(c => c.ToString()).ToArray());
                var             strOut    = new StringBuilder();
                var             strHead   = new StringBuilder();
                var             strMacros = new StringBuilder();
                strHead.AppendLine("O" + Properties.Settings.Default.GCodeProgram);
                strHead.AppendLine("(MACRO: " + mnuFontFamilies.SelectedItem.ToString() + " - " + input + " " + Properties.Settings.Default.FontSize + "em)");
                strHead.AppendLine("(DATE: " + DateTime.Now.ToString("yyyy-MM-dd hh-mm tt") + ")");
                strHead.AppendLine();
                strHead.AppendLine("(-- USAGE --)");
                strHead.AppendLine("( - USE G65 TO CALL THIS PROGRAM)");
                strHead.AppendLine("(EXAMPLES - G65 P" + Properties.Settings.Default.GCodeProgram + " Z0.1 S1 (" + input + " 0.1 DEEP 1:1 SCALE))");
                strHead.AppendLine("(           G65 P" + Properties.Settings.Default.GCodeProgram + " Z0.2 S1 (" + input + " 0.2 DEEP 1:1 SCALE))");
                strHead.AppendLine("(           G65 P" + Properties.Settings.Default.GCodeProgram + " S1      (" + input + " 0.1 DEEP 1:1 SCALE))");
                strHead.AppendLine("(           G65 P" + Properties.Settings.Default.GCodeProgram + "         (" + input + " 0.1 DEEP 1:1 SCALE))");
                strHead.AppendLine();
                strHead.AppendLine("(-- VARIABLE DEFINITIONS --)");
                strHead.AppendLine("([S]#19 = SCALE PATTERN IN XY)");
                strHead.AppendLine("([Z]#26 = DEPTH OF CUT)");
                strHead.AppendLine();
                strHead.AppendLine("IF[#19NE0]GOTO10 (SCALE PASSED IN MACRO CALL)");
                strHead.AppendLine("#19 = 1 (SET DEFAULT SCALE)");
                strHead.AppendLine("N10 (SKIPPED DEFAULT SCALE)");
                strHead.AppendLine("IF[#26NE0]GOTO11 (DEPTH PASSED IN MACRO CALL)");
                strHead.AppendLine("#26 = " + Convert.ToDouble(Properties.Settings.Default.GCodeDepth).ToString() + " (SET DEFAULT DEPTH)");
                strHead.AppendLine("N11 (SKIPPED DEFAULT DEPTH)");
                foreach (CharacterPath cp in ftp.CharacterLibrary)
                {
                    if (!lstChars.Contains(cp.Character))
                    {
                        lstChars.Add(cp.Character);
                        strHead.Append("(" + ((int)cp.Character[0]).ToString());
                        strHead.AppendFormat("{0:5}\r\n", " = " + cp.Character + ")");
                        cp.Draw(true);
                        strOut.AppendLine("N" + ((int)cp.Character[0]).ToString() + " (BEGIN CHARACTER " + cp.Character + ")");
                        strOut.AppendLine(Properties.Settings.Default.GCodeInit + " (INITIALIZE)");
                        strOut.AppendLine(CharacterToGCode(cp));
                        strOut.AppendLine("M99");
                    }
                    strMacros.Append("M98 H" + ((int)cp.Character[0]).ToString());
                    strMacros.AppendFormat("{0:10}\r\n", "(" + cp.Character + ")");
                }
                strHead.AppendLine(strMacros.ToString());
                strHead.AppendLine("GOTO200 (SKIP ALL SUBS)");
                strOut.Insert(0, strHead);
                strOut.AppendLine("N200 (SKIPPED SUBS)");
                strOut.AppendLine("M99 (END)");

                // Save file out
                System.IO.File.WriteAllText(sv.FileName, strOut.ToString());
                statStatus.Text = "Saved!";
            }
            else
            {
                statStatus.Text = "String cannot be empty!";
            }
            Cursor = Cursors.Default;
        }