public ObservableCollection <BaseLayoutElement> LoadLayouts()
        {
            string path = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, Properties.Layouts.Get("SavePath"));

            Logger.Debug("Layouts will be loaded from the following path: {0}", path);

            ObservableCollection <BaseLayoutElement> layoutObjects = Get.i.Assemblies.GetCollectionOfObjects <BaseLayoutElement>(path);

            foreach (BaseLayoutElement layout in layoutObjects)
            {
                if (Get.i.Layouts.ContainsKey(layout.Id))
                {
                    //restore the selection status for each item from DB
                    LayoutRecord metadata = Get.i.Layouts.LoadLayout(layout.Id);
                    layout.IsSelected = metadata.IsSelected;

                    //store back all other attributes to db
                }
                else
                {
                    Get.i.Layouts.InsertLayout(layout);
                }
            }
            return(layoutObjects);
        }
Beispiel #2
0
        private void UpdateLayoutProperties(string entityName, ref LayoutRecord layout, string category, string settingName, IEnumerable <string> pickedFileds)
        {
            var          allFields       = _contentDefinitionManager.GetPartDefinition(entityName).Fields.ToList();
            const string fieldTypeFormat = "{0}.{1}.";

            foreach (var property in pickedFileds)
            {
                var names         = property.Split('.');
                var propertyMatch = string.Format(fieldTypeFormat, names[0], names[1]);
                var field         = allFields.FirstOrDefault(c =>
                                                             string.Format(fieldTypeFormat, entityName, c.Name) == propertyMatch);
                if (field == null)
                {
                    continue;
                }
                var fieldStateProvider = _fieldToPropertyStateProviders.FirstOrDefault(provider => provider.CanHandle(field.FieldDefinition.Name));
                if (fieldStateProvider == null)
                {
                    throw new NotSupportedException("The field type \"" + field.FieldDefinition.Name + "\" is not supported!");
                }
                var propertyRecord = new PropertyRecord {
                    Category      = category,
                    Type          = property,
                    Description   = field.DisplayName,
                    Position      = layout.Properties.Count,
                    State         = fieldStateProvider.GetPropertyState(field.FieldDefinition.Name, property, field.Settings),
                    LinkToContent = field.Settings.ContainsKey(settingName) && bool.Parse(field.Settings[settingName])
                };
                layout.Properties.Add(propertyRecord);
            }
        }
Beispiel #3
0
        private void LayoutStaffProfileQuery(QueryPart staffProfileQuery)
        {
            var layoutDictionary = new Dictionary <string, string>();

            layoutDictionary.Add("QueryId", staffProfileQuery.Id.ToString());
            layoutDictionary.Add("Category", "Html");
            layoutDictionary.Add("Type", "List");
            layoutDictionary.Add("Description", "List");
            layoutDictionary.Add("Display", "0");
            layoutDictionary.Add("DisplayType", "Summary");

            LayoutRecord layout = staffProfileQuery.Layouts.FirstOrDefault();

            if (layout == null)
            {
                layout = new LayoutRecord()
                {
                    Category    = "Html",
                    Type        = "List",
                    Description = "List",
                    Display     = 0,
                    DisplayType = "Summary",
                };
                staffProfileQuery.Layouts.Add(layout);
            }
            layout.State = FormParametersHelper.ToString(layoutDictionary);
        }
Beispiel #4
0
        public override void OnLoad()
        {
            Update    += OnUpdate;
            Paint     += OnPaint;
            MouseDown += OnMouseDown;
            Unloaded  += OnUnloaded;

            LayoutRecords = new LayoutRecord(HipsterEngine);
            Planet        = new PlanetStart(HipsterEngine, Width / 2, Height / 4, Height / 8);
            var triangleRadius = Planet.Radius / 4;
            var y = Planet.Transform.Y - Planet.Radius - triangleRadius + 2;

            Triangle     = new Triangle(HipsterEngine, Width / 2, y, triangleRadius);
            LabelTouchMe = new Label(HipsterEngine, Width / 2, Height / 2 + 10, "1234 нажмите на hello", new SKPaint
            {
                Color       = new SKColor(150, 150, 150, 100),
                IsAntialias = true,
                TextAlign   = SKTextAlign.Center,
                Typeface    = Assets.Typeface,
                TextSize    = 20
            }, 1);
            BackgroundColor = new SKColor(50, 50, 50);
            _time           = 0;

            paint = new SKPaint
            {
                IsAntialias = true,
                Color       = new SKColor(0, 0, 0)
            };

            AnimationEndGame = new AnimationFloat();
            AnimationEndGame.Start(255, 0, 5);

            LoadProfile();
        }
Beispiel #5
0
        private ProjectionPart CreateProjection(string typeName, IEnumerable <string> properties)
        {
            var projectionItem = _contentManager.New("ProjectionPage");
            var queryItem      = _contentManager.New("Query");
            var projectionPart = projectionItem.As <ProjectionPart>();
            var queryPart      = queryItem.As <QueryPart>();

            _contentManager.Create(queryItem);

            projectionPart.Record.QueryPartRecord = queryPart.Record;
            _contentManager.Create(projectionItem);

            var layoutRecord = new LayoutRecord {
                Category = "Html", Type = "ngGrid"
            };

            queryPart.Record.Layouts.Add(layoutRecord);
            projectionPart.Record.LayoutRecord = layoutRecord;

            var filterGroup = new FilterGroupRecord();

            queryPart.Record.FilterGroups.Clear();
            queryPart.Record.FilterGroups.Add(filterGroup);
            var filterRecord = new FilterRecord {
                Category = "Content",
                Type     = "ContentTypes",
                Position = filterGroup.Filters.Count,
                State    = string.Format("<Form><ContentTypes>{0}</ContentTypes></Form>", typeName)
            };

            filterGroup.Filters.Add(filterRecord);

            UpdateLayoutProperties(typeName, layoutRecord, properties);
            return(projectionPart);
        }
Beispiel #6
0
        private void UpdateLayoutProperties(string typeName, LayoutRecord layoutRecord, IEnumerable <string> properties)
        {
            layoutRecord.Properties.Clear();
            if (properties == null)
            {
                return;
            }
            string       category    = typeName + "ContentFields";
            const string settingName = "CoeveryTextFieldSettings.IsDispalyField";
            var          allFields   = _contentDefinitionManager.GetPartDefinition(typeName).Fields.ToList();

            foreach (var property in properties)
            {
                var field = allFields.FirstOrDefault(c => c.Name == property);
                if (field == null)
                {
                    continue;
                }
                var propertyRecord = new PropertyRecord {
                    Category      = category,
                    Type          = string.Format("{0}.{1}.", typeName, property),
                    Description   = field.DisplayName,
                    Position      = layoutRecord.Properties.Count,
                    LinkToContent = field.Settings.ContainsKey(settingName) && bool.Parse(field.Settings[settingName])
                };
                layoutRecord.Properties.Add(propertyRecord);
            }
        }
Beispiel #7
0
        private QueryPart CreateProjectAttachableItemsQuery(string title, string contentType, string shapeName, string layoutName, bool createDefaultSortCriteria)
        {
            var query = this.GetQuery(title);

            if (query != null)
            {
                return(query.As <QueryPart>());
            }

            query = this.contentManager.Create("Query");
            query.As <TitlePart>().Title = title;
            this.contentManager.Publish(query);
            QueryPart queryPart   = query.As <QueryPart>();
            var       filterGroup = queryPart.Record.FilterGroups.FirstOrDefault();

            // AttachToProject
            string state = string.Format(CultureInfo.InvariantCulture, "<Form><Description></Description><Project_Id>{0}</Project_Id></Form>", "{AttachToProject.ProjectId}");

            this.CreateFilter(AttachToProjectFilter.CategoryName, AttachToProjectFilter.IdFilterType, state, filterGroup);
            this.filterRepository.Flush();

            // ticket ContentType filter
            this.CreateContentTypeFilter(contentType, filterGroup);

            // All items visible by current user
            this.CreateFilter(ContentItemPermissionFilter.CategoryName, ContentItemPermissionFilter.CurrentUserPermissions, state, filterGroup);

            if (createDefaultSortCriteria)
            {
                this.CreateSortRecord("CommonPartRecord", "PublishedUtc", "<Form><Sort>false</Sort></Form>", queryPart.Record);
            }

            string layoutState = string.Format(
                CultureInfo.InvariantCulture,
                "<Form><Category>Html</Category><Type>{0}</Type><Display>0</Display><DisplayType>Summary</DisplayType><ShapeType>{1}</ShapeType></Form>",
                layoutName,
                shapeName);

            // create layout
            LayoutRecord layout = new LayoutRecord
            {
                Type            = "Shape",
                Category        = "Html",
                QueryPartRecord = queryPart.Record,
                DisplayType     = "Summary",
                Display         = 0,
                State           = layoutState
            };

            this.layoutRepository.Create(layout);
            this.layoutRepository.Flush();
            this.filterRepository.Flush();

            return(queryPart);
        }
        public QueryPart CreateQuery(string title, string contentType, string shapeName, string layoutName, string itemDisplayType, bool createDefaultSortCriteria, bool filterToItemsVisibleByCurrentUser)
        {
            var queryPart = this.GetQuery(title);

            if (queryPart != null)
            {
                return(queryPart);
            }

            var query = this.contentManager.Create("Query");

            query.As <TitlePart>().Title = title;
            this.contentManager.Publish(query);
            queryPart = query.As <QueryPart>();
            var filterGroup = queryPart.Record.FilterGroups.FirstOrDefault();

            // ticket ContentType filter
            this.CreateContentTypeFilter(contentType, filterGroup);

            // All items visible by current user
            if (filterToItemsVisibleByCurrentUser)
            {
                string state = string.Empty;
                this.CreateFilter(ContentItemPermissionFilter.CategoryName, ContentItemPermissionFilter.CurrentUserPermissions, state, filterGroup);
            }

            if (createDefaultSortCriteria)
            {
                this.CreateSortRecord("CommonPartRecord", "PublishedUtc", "<Form><Sort>false</Sort></Form>", queryPart.Record);
            }

            string layoutState = string.Format(
                CultureInfo.InvariantCulture,
                "<Form><Category>Html</Category><Type>{0}</Type><Display>0</Display><DisplayType>{1}</DisplayType><ShapeType>{2}</ShapeType></Form>",
                layoutName,
                itemDisplayType,
                shapeName);

            // create layout
            LayoutRecord layout = new LayoutRecord
            {
                Type            = "Shape",
                Category        = "Html",
                QueryPartRecord = queryPart.Record,
                DisplayType     = itemDisplayType,
                Display         = 0,
                State           = layoutState
            };

            this.layoutRepository.Create(layout);
            this.layoutRepository.Flush();
            this.filterRepository.Flush();

            return(queryPart);
        }
        public ActionResult CreatePost(LayoutEditViewModel model, FormCollection formCollection)
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage queries")))
            {
                return(new HttpUnauthorizedResult());
            }

            // validating form values
            model.Layout = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == model.Category && x.Type == model.Type);

            _formManager.Validate(new ValidatingContext {
                FormName = model.Layout.Form, ModelState = ModelState, ValueProvider = ValueProvider
            });

            var form = _formManager.Build(model.Layout.Form) ?? Services.New.EmptyForm();

            _formManager.Bind(form, formCollection);

            model.Form = form;

            if (ModelState.IsValid)
            {
                var layoutRecord = new LayoutRecord {
                    Category = model.Category, Type = model.Type
                };
                var query = _queryService.GetQuery(model.QueryId);
                query.Layouts.Add(layoutRecord);

                var dictionary = formCollection.AllKeys.ToDictionary(key => key, formCollection.Get);

                // save form parameters
                layoutRecord.State       = FormParametersHelper.ToString(dictionary);
                layoutRecord.Description = model.Description;
                layoutRecord.Display     = model.Display;
                layoutRecord.DisplayType = model.DisplayType;

                Services.ContentManager.Flush();

                Services.Notifier.Information(T("Layout Created"));

                return(RedirectToAction("Edit", new { id = layoutRecord.Id }));
            }

            return(View(model));
        }
Beispiel #10
0
        public override void OnLoad()
        {
            Update    += OnUpdate;
            Paint     += OnPaint;
            MouseDown += OnMouseDown;
            Unloaded  += OnUnloaded;

            LayoutRecords = new LayoutRecord(HipsterEngine);
            LayoutTop     = new LayoutTop(HipsterEngine);
            PlanetStart   = new PlanetStart(HipsterEngine, Width / 2, Height / 4, Height / 8);
            PlanetStart.AngularVelocity = 0.04f;

            HipsterEngine.Particles.AddParticleSystem(new ParticlesControllerFire(HipsterEngine));

            var triangleRadius = PlanetStart.Radius / 4;
            var y = PlanetStart.Transform.Y - PlanetStart.Radius - triangleRadius + 2;

            Triangle = new Triangle(HipsterEngine, Width / 2, y, triangleRadius);
            Triangle.SetPlanet(PlanetStart);

            HipsterEngine.Particles.AddParticleSystem(new TriangleParticlesController(HipsterEngine, Triangle));

            HipsterEngine.Surface.Canvas.Camera.X = -Width / 2;
            HipsterEngine.Surface.Canvas.Camera.Y = Height / 2;
            HipsterEngine.Surface.Canvas.Camera.SetTarget(PlanetStart.Transform.X - Width / 2, PlanetStart.Transform.Y + Height / 4);

            var profile = LoadProfile();

            Map = new MapPlanets(HipsterEngine, Triangle);
            Map.Generate(profile.Level);
            Map.EndGame += TriangleOnEndGame;

            AnimationEndGame = new AnimationFloat();
            AnimationEndGame.Timer.Complated += tick =>
            {
                HipsterEngine.Screens.SetScreen(new MenuScreen());
            };

            LayoutRecords.TextRecord = profile.Balls.ToString();
            PlanetStart.Text         = profile.Level.ToString();

            Background = new ParallaxBackground(HipsterEngine, Triangle);
        }
Beispiel #11
0
 public void MainWindow_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.T) //Transform
     {
         List <BriefElecComp> A             = GetAllComp();
         SimplifiedPic        simplifiedPic = new SimplifiedPic(A, this);
     }
     else if (e.Key == Key.I)
     {
         MessageBox.Show(elecCompSet.ToString());
     }
     else if (e.Key == Key.R && elecCompSet.pressedElecComp != null)
     {
         //MessageBox.Show("Rotating!");
         elecCompSet.pressedElecComp.RotateLeft();
     }
     else if (e.Key == Key.D && elecCompSet.pressedElecComp != null)
     {
         if (elecCompSet.pressedElecComp.IsWire)
         {
             elecCompSet.pressedElecComp.State = ElecComp.State_AdjRight;
         }
     }
     else if (e.Key == Key.S)
     {
         LayoutRecord.Save(elecCompSet);
     }
     if (e.Key == Key.O)
     {
         /*List<BriefElecComp> A = GetAllComp();
          * String str = "";
          * foreach (BriefElecComp b in A)
          * {
          *  str += b + "\n";
          * }
          * MessageBox.Show(str); //之前写的演示用的,注释掉,现在是打开文件*/
         LayoutRecord.Read(elecCompSet, Mycanvas);
     }
     if (e.Key == Key.C)
     {
         OnClosing();
     }
 }
        public LayoutRecord AddLayout(string layoutState, string itemDisplayType, QueryPart queryPart)
        {
            // create layout
            LayoutRecord layout = new LayoutRecord
            {
                Type            = "Shape",
                Category        = "Html",
                QueryPartRecord = queryPart.Record,
                DisplayType     = itemDisplayType,
                Display         = 0,
                State           = layoutState
            };

            this.layoutRepository.Create(layout);
            this.layoutRepository.Flush();
            this.filterRepository.Flush();

            return(layout);
        }
Beispiel #13
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            writer.WriteStartObject();

            LayoutRecord record = value as LayoutRecord;

            // Id
            Utility.WriteProperty("Id", record.Id, writer, serializer);

            // DisplayType
            Utility.WriteProperty("DisplayType", record.DisplayType, writer, serializer);

            // Category
            Utility.WriteProperty("Category", record.Category, writer, serializer);

            // Type
            Utility.WriteProperty("Type", record.Type, writer, serializer);

            // State
            Utility.WriteProperty("State", record.State, writer, serializer);

            writer.WriteEnd();
        }
        private static string GetLayoutDescription(IEnumerable <LayoutDescriptor> layouts, LayoutRecord l)
        {
            var descriptor = layouts.FirstOrDefault(x => l.Category == x.Category && l.Type == x.Type);

            return(String.IsNullOrWhiteSpace(l.Description) ? descriptor.Display(new LayoutContext {
                State = FormParametersHelper.ToDynamic(l.State)
            }).Text : l.Description);
        }
        public ActionResult Edit(int id)
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage queries")))
            {
                return(new HttpUnauthorizedResult());
            }

            LayoutRecord layoutRecord = _repository.Get(id);

            if (layoutRecord == null)
            {
                return(HttpNotFound());
            }

            var layoutDescriptor = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == layoutRecord.Category && x.Type == layoutRecord.Type);

            // build the form, and let external components alter it
            var form = _formManager.Build(layoutDescriptor.Form) ?? Services.New.EmptyForm();

            var viewModel = new LayoutEditViewModel {
                Id              = id,
                QueryId         = layoutRecord.QueryPartRecord.Id,
                Category        = layoutDescriptor.Category,
                Type            = layoutDescriptor.Type,
                Description     = layoutRecord.Description,
                Display         = layoutRecord.Display,
                DisplayType     = String.IsNullOrWhiteSpace(layoutRecord.DisplayType) ? "Summary" : layoutRecord.DisplayType,
                Layout          = layoutDescriptor,
                Form            = form,
                GroupPropertyId = layoutRecord.GroupProperty == null ? 0 : layoutRecord.GroupProperty.Id
            };

            // bind form with existing values
            var parameters = FormParametersHelper.FromString(layoutRecord.State);

            _formManager.Bind(form, new DictionaryValueProvider <string>(parameters, CultureInfo.InvariantCulture));

            #region Load Fields

            var fieldEntries = new List <PropertyEntry>();
            var allFields    = _projectionManager.DescribeProperties().SelectMany(x => x.Descriptors);

            foreach (var field in layoutRecord.Properties)
            {
                var fieldCategory = field.Category;
                var fieldType     = field.Type;

                var f = allFields.FirstOrDefault(x => fieldCategory == x.Category && fieldType == x.Type);
                if (f != null)
                {
                    fieldEntries.Add(
                        new PropertyEntry {
                        Category         = f.Category,
                        Type             = f.Type,
                        PropertyRecordId = field.Id,
                        DisplayText      = String.IsNullOrWhiteSpace(field.Description) ? f.Display(new PropertyContext {
                            State = FormParametersHelper.ToDynamic(field.State)
                        }).Text : field.Description,
                        Position = field.Position
                    });
                }
            }

            viewModel.Properties = fieldEntries.OrderBy(f => f.Position);

            #endregion

            return(View(viewModel));
        }
Beispiel #16
0
        public int EditPost(int id, ProjectionEditViewModel viewModel, IEnumerable <string> pickedFileds)
        {
            ListViewPart   listViewPart;
            ProjectionPart projectionPart;
            QueryPart      queryPart;

            if (id == 0)
            {
                listViewPart = _contentManager.New <ListViewPart>("ListViewPage");
                listViewPart.ItemContentType = viewModel.ItemContentType;
                queryPart = _contentManager.New <QueryPart>("Query");

                var layout = new LayoutRecord {
                    Category    = "Html",
                    Type        = "ngGrid",
                    Description = "DefaultLayoutFor" + queryPart.Name,
                    Display     = 1
                };

                queryPart.Layouts.Add(layout);
                projectionPart = listViewPart.As <ProjectionPart>();
                projectionPart.Record.LayoutRecord    = layout;
                projectionPart.Record.QueryPartRecord = queryPart.Record;

                var filterGroup = new FilterGroupRecord();
                queryPart.Record.FilterGroups.Add(filterGroup);
                var filterRecord = new FilterRecord {
                    Category = "Content",
                    Type     = "ContentTypes",
                    Position = filterGroup.Filters.Count,
                    State    = GetContentTypeFilterState(viewModel.ItemContentType)
                };
                filterGroup.Filters.Add(filterRecord);

                _contentManager.Create(queryPart.ContentItem);
                _contentManager.Create(projectionPart.ContentItem);
            }
            else
            {
                listViewPart   = _contentManager.Get <ListViewPart>(id, VersionOptions.Latest);
                projectionPart = listViewPart.As <ProjectionPart>();
                var queryId = projectionPart.Record.QueryPartRecord.Id;
                queryPart = _contentManager.Get <QueryPart>(queryId, VersionOptions.Latest);
            }

            if (pickedFileds == null)
            {
                pickedFileds = new List <string>();
            }

            listViewPart.VisableTo = viewModel.VisableTo;
            listViewPart.As <TitlePart>().Title = viewModel.DisplayName;
            listViewPart.IsDefault = viewModel.IsDefault;
            queryPart.Name         = "Query for Public View";

            projectionPart.Record.ItemsPerPage = viewModel.PageRowCount;
            //Post Selected Fields
            var layoutRecord = projectionPart.Record.LayoutRecord;

            layoutRecord.Properties.Clear();

            var          category    = viewModel.ItemContentType + "ContentFields";
            const string settingName = "CoeveryTextFieldSettings.IsDispalyField";

            try {
                UpdateLayoutProperties(viewModel.ItemContentType, ref layoutRecord, category, settingName, pickedFileds);
            }
            catch (Exception exception) {
                Services.Notifier.Add(NotifyType.Error, T(exception.Message));
            }
            layoutRecord.State = GetLayoutState(queryPart.Id, layoutRecord.Properties.Count, layoutRecord.Description);
            // sort
            queryPart.SortCriteria.Clear();
            if (!string.IsNullOrEmpty(viewModel.SortedBy))
            {
                var sortCriterionRecord = new SortCriterionRecord {
                    Category    = category,
                    Type        = viewModel.SortedBy,
                    Position    = queryPart.SortCriteria.Count,
                    State       = GetSortState(viewModel.SortedBy, viewModel.SortMode),
                    Description = viewModel.SortedBy + " " + viewModel.SortMode
                };
                queryPart.SortCriteria.Add(sortCriterionRecord);
            }
            return(listViewPart.Id);
        }