예제 #1
0
        public void SetFile(string filename)
        {
            Proposal action;

            try
            {
                StringBuilder sb = new StringBuilder();
                using (var sr = new System.IO.StreamReader(filename))
                {
                    String line;
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        sb.AppendLine(line);
                    }
                }
                string source = sb.ToString();
                action = new SetFile(filename, source);
            }
            catch (Exception e)
            {
                action = new ShowError("Failed to read the file", e);
            }

            _model.Present(action);
            _display(_model);
        }
예제 #2
0
        public void RefreshFromFile()
        {
            Proposal action;

            if (string.IsNullOrEmpty(_model.FileName))
            {
                action = new ShowError("Please select a file first!", null);
            }
            else
            {
                SetFile(_model.FileName);
                return;
            }

            _model.Present(action);
            _display(_model);
        }