예제 #1
0
        internal void Write(ListCases cases)
        {
            writer.WriteStartElement(XmlTags.ListCases);
            cases.WriteXml(writer);
            writer.WriteEndElement();

            writer.Close();
        }
예제 #2
0
 internal void CopyContent(ListCases sourceList)
 {
     ClearItems();
     foreach (AbstractCase c in sourceList)
     {
         Add(c.Clone());
     }
 }
예제 #3
0
        /// <summary>
        /// Might throw an exception if it cannot read the file.
        /// </summary>
        /// <param name="filePath"></param>
        public void Load(string filePath) // TODO should be a command
        {
            // Read file
            ListCasesXmlReaderParser fileParser = new ListCasesXmlReaderParser(new FileInfo(filePath));
            ListCases loadedFileData            = fileParser.Read();

            DoCommand(new LoadCommand(this, filePath, loadedFileData));
        }
예제 #4
0
        /*public FileInfo DataFilePath
         * {
         *  get
         *  {
         *      return mDataFilePath;
         *  }
         *  set
         *  {
         *      mDataFilePath = value;
         *      OnPropertyChanged("DataFilePath");
         *  }
         * }
         * private FileInfo mDataFilePath = new FileInfo(Path.Combine(
         *                                              Directory.GetCurrentDirectory(),
         *                                              "d_accounting_data.xml"));*/

        /// <summary>
        /// Default constructor of the main VM
        /// </summary>
        public MainViewModel()
        {
            try
            {
                ListCasesXmlReaderParser readParser = new ListCasesXmlReaderParser(mSettings.DataFilePath);
                mCases = readParser.Read();
            }
            catch (Exception)
            {
                mCases = new ListCases();
            }
        }
예제 #5
0
        public object Clone()
        {
            ListCases newCases = new ListCases();

            newCases.ClearItems();

            foreach (AbstractCase c in this)
            {
                newCases.Add(c.Clone() as AbstractCase);
            }

            return(newCases);
        }
        internal ListCases Read()
        {
            try
            {
                ListCases c = new ListCases(reader);
                reader.Close();

                return(c);
            }
            catch (XmlException e)
            {
                throw e;
            }
        }
예제 #7
0
        private void UpdateMainDataGridLayout()
        {
            Grid      grid = MainDataGrid;
            ListCases list = ViewModel.Cases;

            if (grid == null || list == null)
            {
                return;
            }

            grid.RowDefinitions.Clear();
            grid.ColumnDefinitions.Clear();

            int rowNumber    = list.RowCount;
            int columnNumber = list.ColumnCount;

            // Add rows
            Parallel.For(0, rowNumber, delegate(int i)
            {
                Application.Current.Dispatcher.InvokeAsync(new Action(() =>
                {
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                }));
            });

            // Add columns
            for (int i = 0; i < columnNumber - 1; ++i)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Auto)
                });
            }
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            UpdateLayout();
        }
예제 #8
0
 public LoadDataCommand(MainViewModel vm, ListCases lc, System.IO.FileInfo dataFile) : base(vm, lc)
 {
     OldCases = lc.Clone() as ListCases;
     NewCases = new ListCasesXmlReaderParser(dataFile).Read();
 }