/// <summary>
        /// Load the list of recently used templates, and add the default template
        /// </summary>
        public AddTemplateDrawingViewModel()
        {
            //load the default template
            Drawing d = DBCommon.CreateDefaultDrawing();

            _recentTemplates = new ObservableCollection <TemplateDrawingModel>();
            _recentTemplates.Add(new TemplateDrawingModel("(default)", d));

            //read the recent templates, and attempt to load them
            string[] templates = Properties.Settings.Default.RecentTemplates.Split(new char[] { ';' });
            foreach (string file in templates)
            {
                try
                {
                    if (!File.Exists(file))
                    {
                        continue;
                    }
                    _recentTemplates.Add(new TemplateDrawingModel(file));
                }
                //if we have a problem then just ignore it and continue
                //TODO: perhaps log these errors somewhere
                catch { }
            }
        }
Ejemplo n.º 2
0
        public Drawing CreateDefaultDrawingWithFileName()
        {
            try
            {
                Drawing d = DBCommon.CreateDefaultDrawing();
                d.FileName = _db.Filename;
                try
                {
                    d.Number = Path.GetFileNameWithoutExtension(d.FileName);
                    while (DBCommon.DrawingComboExists(d.Number, d.Sheet))
                    {
                        PromptStringOptions pso = new PromptStringOptions(string.Format("Drawing {0} sheet {1} already exists. Please enter a new sheet number:", d.Number, d.Sheet));
                        string str = _ed.DoPrompt(pso).StringResult;
                        _ed.WriteMessage(str + Environment.NewLine);
                        if (str == "")
                        {
                            return(null);
                        }
                        d.Sheet = str;
                    }
                }
                catch (Exception ex) { _ed.WriteMessage(ex.ToString()); }


                return(d);
            }
            catch { return(null); }
        }
        private void AddTemplateExecute()
        {
            Drawing d = DBCommon.CreateDefaultDrawing();

            d.Number = "";
            _recentTemplates.Add(new TemplateDrawingModel("[new template]", d));
        }