프로젝트

일반

사용자정보

개정판 1620ca9c

ID1620ca9c91b7e7a7526971357b8b028444ab7758
상위 0e98d54b
하위 2851ca5b, 85d51ecc

백흠경이(가) 11달 전에 추가함

Feature: 사용자가 지정한 텍스트는 Compare에서 제외

Change-Id: I2a8b83a95b6d20ddee409c79384d3ba21faccf30

차이점 보기:

ID2.Manager/ID2.Manager.Compare/Model/MyModel.cs
2 2
using devDept.Eyeshot;
3 3
using devDept.Eyeshot.Entities;
4 4
using devDept.Graphics;
5
using ID2.Manager.Controls;
5 6
using System;
6 7
using System.Collections.Generic;
7 8
using System.ComponentModel;
8 9
using System.Diagnostics;
9 10
using System.Drawing;
11
using System.IO;
10 12
using System.Linq;
13
using System.Runtime.CompilerServices;
11 14
using System.Text;
12 15
using System.Threading.Tasks;
13 16
using System.Windows.Forms;
14 17

  
15 18
namespace Xtractor.Viewer
16 19
{
20
    public class FixedText : IEquatable<FixedText>
21
    {
22
        public FixedText(int x, int y, string text)
23
        {
24
            X = x;
25
            Y = y;
26
            TextString = text.Replace(System.Environment.NewLine, string.Empty);
27
        }
28

  
29
        public int X { get; set; }
30
        public int Y { get; set; }
31
        public string TextString { get; set; }
32

  
33
        public bool Equals(FixedText other)
34
        {
35
            return this.X == other.X 
36
                && this.Y == other.Y 
37
                && this.TextString.Equals(other.TextString);
38
        }
39

  
40
        public bool Equals(Text text)
41
        {
42
            return this.X == Convert.ToInt32(text.InsertionPoint.X)
43
                            && this.Y == Convert.ToInt32(text.InsertionPoint.Y)
44
                            && this.TextString.Equals(text.TextString.Replace(System.Environment.NewLine, string.Empty));
45
        }
46

  
47
        public override string ToString()
48
        {
49
            return $"{X},{Y},{TextString}";
50
        }
51
    }
52

  
17 53
    public partial class MyModel : Design
18 54
    {
19 55
        private int entityUnderMouseID;
20 56
        private Entity selEntity = null;
21 57

  
58
        public string FilePath { get; set; }
59

  
60
        public List<FixedText> FixedTexts { get; } = new List<FixedText>();
61

  
22 62
        /// <summary>
23 63
        /// WorkUnit Queue
24 64
        /// </summary>
......
84 124
                AdjustNearAndFarPlanes();
85 125
                Invalidate();
86 126
            }
127
            else if (e.KeyCode == Keys.X && !string.IsNullOrEmpty(FilePath) && File.Exists(FilePath))
128
            {
129
                #region 선택한 텍스트들을 파일로 저장한다.
130
                var selection = this.GetSelectedEntities().Where(x => x is devDept.Eyeshot.Entities.Text || x is devDept.Eyeshot.Entities.MultilineText)
131
                    .ToList()
132
                    .ConvertAll(x => 
133
                    {
134
                        if (x is devDept.Eyeshot.Entities.Text text)
135
                        {
136
                            return new FixedText(Convert.ToInt32(text.InsertionPoint.X), Convert.ToInt32(text.InsertionPoint.Y), text.TextString);
137
                        }
138
                        else if (x is devDept.Eyeshot.Entities.MultilineText multitext)
139
                        {
140
                            return new FixedText(Convert.ToInt32(multitext.InsertionPoint.X), Convert.ToInt32(multitext.InsertionPoint.Y), multitext.TextString);
141
                        }
142

  
143
                        return null;
144
                    });
145
                selection.RemoveAll(x => x is null);
146

  
147
                var excluded = selection.Where(x => !FixedTexts.Exists(y => y.Equals(x))).ToList();
148
                string FixedFilePath = $"{FilePath}.txt";
149
                using (var sw = new StreamWriter(FixedFilePath, append:true))
150
                {
151
                    excluded.ForEach(x => sw.WriteLine(x.ToString()));
152
                }
153
                #endregion
154
            }
87 155
            else
88 156
            {
89 157
                base.OnKeyDown(e);

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)