프로젝트

일반

사용자정보

개정판 a0bab669

IDa0bab669c4ef11fb91c4e652c68919048d5748f7
상위 7ca218b3
하위 5ce56a3a

KangIngu 이(가) 약 7년 전에 추가함

상단 이미지 변경 추가

차이점 보기:

KCOM/Views/MainMenu.xaml.cs
54 54
        }
55 55
    }
56 56

  
57
    public class MyConsole
58
    {
59
        private readonly System.Threading.ManualResetEvent _readLineSignal;
60
        private string _lastLine;
61
        public MyConsole()
62
        {
63
            _readLineSignal = new System.Threading.ManualResetEvent(false);
64
            Gui = new TextBox();
65
            Gui.AcceptsReturn = true;
66
            Gui.KeyUp += OnKeyUp;
67
        }
68

  
69
        private void OnKeyUp(object sender, KeyEventArgs e)
70
        {
71
            // this is always fired on UI thread
72
            if (e.Key == Key.Enter)
73
            {
74
                // quick and dirty, but that is not relevant to your question
75
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
76
                // now, when you detected that user typed a line, set signal
77
                _readLineSignal.Set();
78
            }
79
        }
80

  
81
        public TextBox Gui { get; private set; }
82

  
83
        public string ReadLine()
84
        {
85
            // that should always be called from non-ui thread
86
            if (Gui.Dispatcher.CheckAccess())
87
                throw new Exception("Cannot be called on UI thread");
88
            // reset signal
89
            _readLineSignal.Reset();
90
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
91
            _readLineSignal.WaitOne();
92
            // we got signalled - return line user typed.
93
            return _lastLine;
94
        }
95

  
96
        public void WriteLine(string line)
97
        {
98
            if (!Gui.Dispatcher.CheckAccess())
99
            {
100
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
101
                return;
102
            }
103

  
104
            Gui.Text += line + Environment.NewLine;
105
        }
106
    }
107

  
57 108
    /// <summary>
58 109
    /// MainMenu.xaml에 대한 상호 작용 논리
59 110
    /// </summary>
......
232 283
            InitializeComponent();
233 284
            this.Loaded += MainMenu_Loaded;
234 285
            //UndoDataList = new List<Undo_data>();
286

  
287
            //var console = new MyConsole();
288
            //this.Content = console.Gui;
289
            //var read = console.ReadLine();
290
            //console.WriteLine(read);
291

  
235 292
        }
236 293
        private void SetCursor()
237 294
        {
......
2077 2134
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2078 2135
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2079 2136

  
2137

  
2080 2138
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2081 2139

  
2082 2140
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();

내보내기 Unified diff

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