Exemplo n.º 1
0
        public MobiseModel LoadModel(MobiseModel baseModel)
        {
            string filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path);

            if (baseModel != null)
            {
                if (System.IO.File.Exists(filePath))
                {
                    baseModel.LoadDate = System.IO.File.GetLastWriteTime(filePath);
                    for (int count = 0; count < 3; count++)
                    {
                        try
                        {
                            XDocument doc = XDocument.Load(filePath);
                            baseModel.FromXml(doc.Root);
                            break;
                        }
                        catch (Exception ex)
                        {
                            Thread.Sleep(100);
                        }
                    }
                }
            }

            return(baseModel);
        }
Exemplo n.º 2
0
        public void SaveModel(MobiseModel model)
        {
            string filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path);

            if (model != null)
            {
                if (model.LoadDate != null && model.LoadDate.Value < System.IO.File.GetLastWriteTime(filePath))
                {
                    if (MessageBox.Show("The existing project is newer than the current version. Are you sure you want to override it?", "Warning!", MessageBoxButton.YesNo) == MessageBoxResult.No)
                    {
                        return; // cancel save
                    }
                }
                XDocument doc = new XDocument();
                doc.Add(model.ToXml());
                for (int i = 0; i < 3; i++)
                {
                    try
                    {
                        doc.Save(filePath);
                        break;
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(100);
                    }
                }
                model.LoadDate = System.IO.File.GetLastWriteTime(filePath);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the model.
        /// </summary>
        /// <returns></returns>
        public MobiseModel LoadModel()
        {
            System.Diagnostics.Debug.Assert(this.ParentProject != null, "Parent Project shouldn't be null");
            System.Diagnostics.Debug.Assert(this.ParentProject.mobiseConfiguration != null, "Mobise configuration shouldn't be null");

            string      filePath = System.IO.Path.Combine(this.ParentProject.Path, this.Path);
            MobiseModel model    = null;

            switch (this.FileType)
            {
            case Models.FileType.Model:
                model      = new DatabaseModel(this.ParentProject);
                model.Name = this.Name;
                ((DatabaseModel)model).Path = filePath;
                break;

            case Models.FileType.Style:
                model      = new ProjectThemesModel();
                model.Name = this.Name;
                break;

            case FileType.ScreenDefinition:
                var def = this.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(c => c.Name.Equals("screen", StringComparison.OrdinalIgnoreCase));
                model                = new ScreenModel(def, this.ParentProject);
                model.Name           = this.Name;
                model.MobiseObjectID = this.MobiseObjectID;
                break;

            case FileType.CustomControl:
                def                  = this.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(c => c.Name.Equals("view", StringComparison.OrdinalIgnoreCase));
                model                = new ScreenModel(def, this.ParentProject);
                model.Name           = this.Name;
                model.MobiseObjectID = this.MobiseObjectID;
                break;

            case FileType.Controller:
            {
                string modelpath = System.IO.Path.Combine(this.ParentProject.Path, this.Path);
                if (System.IO.File.Exists(modelpath))
                {
                    XDocument doc            = XDocument.Load(filePath);
                    string    controllerType = doc.Root.Attribute("type") != null?doc.Root.Attribute("type").Value : string.Empty;

                    var cntDef = this.ParentProject.mobiseConfiguration.ControllerDefinitons.FirstOrDefault(c => c.Name.Equals(controllerType, StringComparison.OrdinalIgnoreCase));
                    if (cntDef != null)
                    {
                        model = new ControllerModel(cntDef, this.ParentProject);
                    }
                }
            }
            break;

            default:
                model = null;
                break;
            }

            return(this.LoadModel(model));
        }
 public UIControlDefinitionModel(MobiseModel parent, bool addDefaultAttributes)
     : base(parent)
 {
     this.AttributeCategories = new TrulyObservableCollection <AttributeCategoryModel>();
     this.DesignerAttributes  = new Dictionary <string, string>();
     this.VisualStates        = new TrulyObservableCollection <VisualStateDefinitionModel>();
     if (addDefaultAttributes)
     {
         this.CreateDefaultAttributes();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptableFunctionModel"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public ScriptableFunctionModel(MobiseModel parent)
     : base(parent)
 {
     this.Parameters = new TrulyObservableCollection <FunctionParamModel>();
 }
Exemplo n.º 6
0
 public StyleAttributeDefaultValueModel(MobiseModel parent)
     : base(parent)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptablePropertyModel"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public ScriptablePropertyModel(MobiseModel parent)
     : base(parent)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleSchemaMappingModel"/> class.
 /// </summary>
 public StyleSchemaMappingModel(MobiseModel parent)
     : base(parent)
 {
     this.Exceptions = new Dictionary <string, List <string> >();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MBObjectModel"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public MBObjectModel(MobiseModel parent)
     : base(parent)
 {
     this.Properties = new TrulyObservableCollection <ScriptablePropertyModel>();
     this.Functions  = new TrulyObservableCollection <ScriptableFunctionModel>();
 }
Exemplo n.º 10
0
        // public TrulyObservableCollection<StyleNodeModel> attributes;

        /// <summary>
        /// Initializes a new instance of the <see cref="ClassStyleModel"/> class.
        /// </summary>
        public ClassStyleModel(MobiseModel parent)
            : base(parent)
        {
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UIControlDefinitionModel"/> class.
 /// </summary>
 public UIControlDefinitionModel(MobiseModel parent)
     : this(parent, true)
 {
 }
Exemplo n.º 12
0
 public UIControlInstanceModel(MobiseModel parent, ScreenModel parentScreen, UIControlDefinitionModel definition)
     : this(definition)
 {
     this.Parent       = parent;
     this.ParentScreen = parentScreen;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationModel"/> class.
 /// </summary>
 public ValidationModel(MobiseModel parent)
     : base(parent)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ControllerDefinitionModel"/> class.
 /// </summary>
 /// <param name="parent"></param>
 public ControllerDefinitionModel(MobiseModel parent)
     : base(parent, false)
 {
 }
Exemplo n.º 15
0
 public AttributeCategoryModel(MobiseModel parent)
     : base(parent)
 {
     this.Name = string.Empty;
     this.ControlAttributes = new TrulyObservableCollection <AttributeModel>();
 }
Exemplo n.º 16
0
 public ThemeModel(MobiseModel parent)
     : base(parent)
 {
     this.Classes = new TrulyObservableCollection <ClassStyleModel>();
 }
Exemplo n.º 17
0
 public FunctionParamModel(MobiseModel parent)
     : base(parent)
 {
 }