/// <summary>
 /// Constructor for config items created by the Manager as copies of
 /// an existing item.
 /// </summary>
 /// <param name="source"></param>
 public DictConfigItem(DictConfigItem source)
 {
     UniqueCode       = CreateUniqueIdCode(source.DispName);
     IsProtected      = false;
     UserMarkedDelete = false;
     CopyOf           = source.UniqueCode;
     DispName         = String.Format(xWorksStrings.ksDictConfigCopyOf, source.DispName);
     m_initialName    = DispName;
 }
        private void InternalCopyConfigItem(DictConfigItem source)
        {
            var newItem = new DictConfigItem(source);

            EnsureUniqueLabel(newItem);
            var newCode = newItem.UniqueCode;

            m_configList.Add(newCode, newItem);
            UpdateCurrentView(newCode);
        }
 private bool IsConfigNew(string code, out DictConfigItem item)
 {
     if (!m_configList.TryGetValue(code, out item))
     {
         Debug.Assert(false, String.Format("Code {0} not found.", code));
         // ReSharper disable HeuristicUnreachableCode
         return(true);                // Should get here if we didn't have a valid item selected!
         // ReSharper restore HeuristicUnreachableCode
     }
     return(item.IsNew);
 }
        private void EnsureUniqueLabel(DictConfigItem newItem)
        {
            var counter = 1;

            while ((from item in m_configList where item.Value.DispName == newItem.DispName select item).Count() > 0)
            {
                counter++;
                // change DispName on newItem using ksDictConfigMultiCopyOf
                DictConfigItem origItem;
                m_configList.TryGetValue(newItem.CopyOf, out origItem);
                var origName = origItem.DispName;
                newItem.DispName = String.Format(xWorksStrings.ksDictConfigMultiCopyOf, origName, counter);
            }
        }
 protected void LoadInternalDictionary(IEnumerable <Tuple <string, string, bool> > configList)
 {
     // Tuples are <uniqueCode, dispName, IsProtected>
     foreach (var config in configList)
     {
         var            code = config.Item1;
         DictConfigItem item;
         if (m_configList.TryGetValue(code, out item))
         {
             Debug.Assert(false, String.Format("The 'configList' code {0} is NOT unique!", code));
             // ReSharper disable HeuristicUnreachableCode
             continue;
             // ReSharper restore HeuristicUnreachableCode
         }
         item = new DictConfigItem(code, config.Item2, config.Item3);
         m_configList.Add(code, item);
     }
 }
		protected void LoadInternalDictionary(IEnumerable<Tuple<string, string, bool>> configList)
		{
			// Tuples are <uniqueCode, dispName, IsProtected>
			foreach (var config in configList)
			{
				var code = config.Item1;
				DictConfigItem item;
				if (m_configList.TryGetValue(code, out item))
				{
					Debug.Assert(false, String.Format("The 'configList' code {0} is NOT unique!", code));
					// ReSharper disable HeuristicUnreachableCode
					continue;
					// ReSharper restore HeuristicUnreachableCode
				}
				item = new DictConfigItem(code, config.Item2, config.Item3);
				m_configList.Add(code, item);
			}
		}
		/// <summary>
		/// Constructor for config items created by the Manager as copies of
		/// an existing item.
		/// </summary>
		/// <param name="source"></param>
		public DictConfigItem(DictConfigItem source)
		{
			UniqueCode = CreateUniqueIdCode(source.DispName);
			IsProtected = false;
			UserMarkedDelete = false;
			CopyOf = source.UniqueCode;
			DispName = String.Format(xWorksStrings.ksDictConfigCopyOf, source.DispName);
			m_initialName = DispName;
		}
		private bool IsConfigNew(string code, out DictConfigItem item)
		{
			if (!m_configList.TryGetValue(code, out item))
			{
				Debug.Assert(false, String.Format("Code {0} not found.", code));
				// ReSharper disable HeuristicUnreachableCode
				return true; // Should get here if we didn't have a valid item selected!
				// ReSharper restore HeuristicUnreachableCode
			}
			return item.IsNew;
		}
		private void EnsureUniqueLabel(DictConfigItem newItem)
		{
			var counter = 1;
			while ((from item in m_configList where item.Value.DispName == newItem.DispName select item).Count() > 0)
			{
				counter++;
				// change DispName on newItem using ksDictConfigMultiCopyOf
				DictConfigItem origItem;
				m_configList.TryGetValue(newItem.CopyOf, out origItem);
				var origName = origItem.DispName;
				newItem.DispName = String.Format(xWorksStrings.ksDictConfigMultiCopyOf, origName, counter);
			}
		}
		private void InternalCopyConfigItem(DictConfigItem source)
		{
			var newItem = new DictConfigItem(source);
			EnsureUniqueLabel(newItem);
			var newCode = newItem.UniqueCode;
			m_configList.Add(newCode, newItem);
			UpdateCurrentView(newCode);
		}