Пример #1
0
        /// <summary>
        /// convert from ScreenDefnModel to ScreenDefn.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType,
                                  object parameter, CultureInfo culture)
        {
            var model = value as ScreenDefnModel;
            var defn  = new ScreenDefn(model);

            return(defn);
        }
    /// <summary>
    /// convert screenDefn model class to ScreenDefn class.
    /// </summary>
    /// <returns></returns>
    public ScreenDefn ToScreenDefn()
    {
      var defn = new ScreenDefn(
        this.ScreenName, this.NamespaceName, this.ScreenGuid, this.ScreenDim, this.ModelItems);

      var jj = from a in this.ModelItems
               select ScreenItem.Factory(a);
      defn.Items = jj.ToList();

      return defn;
    }
 /// <summary>
 /// see the ModelChanged event of the ScreenDefnControl control.
 /// When the Model property of ScreenDefnControl changes, the code behind of that control
 /// signals its ModelChanged event. This collection control monitors that event. When the
 /// model changes ( item is clicked in the listview of screen defn models. ) want to
 /// apply changes back to the list of screen definitions.
 /// </summary>
 /// <param name="obj"></param>
 private void ScreenDefnControl_ModelChanged(IScreenDefn obj)
 {
     if (obj != null)
     {
         var item = this.ScreenDefnObservableList.FirstOrDefault(c => c.ScreenName == obj.ScreenName);
         if (item != null)
         {
             var ix   = this.ScreenDefnObservableList.IndexOf(item);
             var defn = new ScreenDefn(obj);
             this.ScreenDefnObservableList.Insert(ix, defn);
             this.ScreenDefnObservableList.Remove(item);
         }
     }
 }