Exemple #1
0
        /// <summary>
        /// Saves the current linetype to the specified file, if the file does not exist it creates a new one.
        /// </summary>
        /// <param name="file">File where the current linetype will be saved.</param>
        public void Save(string file)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("*{0},{1}", this.Name, this.description));
            foreach (LinetypeSegment s in this.segments)
            {
                switch (s.Type)
                {
                case LinetypeSegmentType.Simple:
                    sb.Append(string.Format("A,{0}", s.Length));
                    break;

                case LinetypeSegmentType.Text:
                    LinetypeTextSegment ts = (LinetypeTextSegment)s;
                    string trt             = "R=";
                    switch (ts.RotationType)
                    {
                    case LinetypeSegmentRotationType.Absolute:
                        trt = "A=";
                        break;

                    case LinetypeSegmentRotationType.Relative:
                        trt = "R=";
                        break;

                    case LinetypeSegmentRotationType.Upright:
                        trt = "U=";
                        break;
                    }

                    sb.Append(string.Format("A,{0},[\"{1}\",{2},S={3},{4}{5},X={6},Y={7}]", ts.Length, ts.Text, ts.Style.Name, ts.Scale, trt, ts.Rotation, ts.Offset.X, ts.Offset.Y));
                    break;

                case LinetypeSegmentType.Shape:
                    LinetypeShapeSegment ss = (LinetypeShapeSegment)s;
                    string srt = "R=";
                    switch (ss.RotationType)
                    {
                    case LinetypeSegmentRotationType.Absolute:
                        srt = "A=";
                        break;

                    case LinetypeSegmentRotationType.Relative:
                        srt = "R=";
                        break;

                    case LinetypeSegmentRotationType.Upright:
                        srt = "U=";
                        break;
                    }

                    sb.Append(string.Format("A,{0},[{1},{2},S={3},{4}{5},X={6},Y={7}]", ss.Length, ss.Name, ss.Style.File, ss.Scale, srt, ss.Rotation, ss.Offset.X, ss.Offset.Y));
                    break;
                }
            }
            sb.Append(Environment.NewLine);

            File.AppendAllText(file, sb.ToString());
        }
Exemple #2
0
 private void LinetypeTextSegment_StyleChanged(LinetypeTextSegment sender, TableObjectChangedEventArgs <TextStyle> e)
 {
     e.NewValue = this.OnLinetypeTextSegmentStyleChangedEvent(e.OldValue, e.NewValue);
 }