Example #1
0
        /// <summary>
        /// Получить данные о формах из файла.
        /// </summary>
        /// <returns></returns>
        public static List <FormsData> GetFormsDatas()
        {
            var fomatter = new BinaryFormatter();

            using (var fs = new FileStream("FormsDatas.dat", FileMode.OpenOrCreate))
            {
                try
                {
                    if (fomatter.Deserialize(fs) is List <FormsData> formsDatas)
                    {
                        return(formsDatas);
                    }
                    return(new List <FormsData>());
                }
                catch
                {
                    var tmp = new FormsData
                    {
                        Name        = 0,
                        X           = 500,
                        Y           = 200,
                        Height      = 500,
                        Widht       = 1000,
                        WindowState = System.Windows.Forms.FormWindowState.Normal
                    };
                    FormsDatas.Add(tmp);
                    fomatter.Serialize(fs, FormsDatas);
                    return(FormsDatas);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Saves the form in the visitor's profile.
        /// Must be called after post back (Ajax or normal)
        /// </summary>
        public void Save()
        {
            var formData = JsonConvert.SerializeObject(
                Request,
                Formatting.None,
                new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                Converters            = new List <JsonConverter>
                {
                    new JavaScriptDateTimeConverter()
                }
            }
                );
            var thisForm = WebContext.Profile.FormsData.Where(f => f.FormId == this.ID);

            if (thisForm.Count() > 0)
            {
                thisForm.Single().JSonData = formData;
            }
            else
            {
                var obj = new FormsData();
                obj.FormId   = this.ID;
                obj.JSonData = formData;
                WebContext.Profile.FormsData.Add(obj);
            }
            WebContext.Profile.Save();
        }
Example #3
0
        public ApplicationViewModel(Action updateContentControl)
        {
            BindingDataForms          = new FormsData();
            BindingDataForms.Task     = new Model.TaskForm();
            BindingDataForms.TestTask = new Model.TestTaskForm();
            BindingDataForms.Test     = new Model.TestForm();

            _editorSelector       = new EditorSelector();
            _updateContentControl = updateContentControl;
        }