Ejemplo n.º 1
0
        public LayoutSelector()
        {
            Logger.Debug("Instance created successfully");

            Logger.Debug("Loading all available layouts");
            Layouts = Layouts ?? LoadLayouts();

            Logger.Debug("{0} layouts loaded from the configured path", Layouts.Count);

            SelectedLayout = SelectedLayout ?? GetSelectedLayout();
        }
Ejemplo n.º 2
0
        public void DeleteLayout(BaseLayoutElement layout)
        {
            CheckAndConnect();

            if (!ContainsKey(layout.Id))
            {
                throw new Exception(string.Format("No layout exists with key [{0}]", layout.Id));
            }

            AllLayouts.Delete(l => l.LayoutKey == layout.Id);
            Logger.Debug("Layout [{0}] has been deleted successfully", layout);
        }
Ejemplo n.º 3
0
        //constructor
        #region
        public TsColumn(XElement SourceXml, int PageIndex, BaseLayoutElement Parent) : base(Parent)
        {
            this.Index                    = PageIndex;
            this._columnpanel             = new Grid();
            this._columnpanel.Name        = "_columnpanel";
            this._columnpanel.DataContext = this;
            this._columnpanel.SetBinding(Grid.IsEnabledProperty, new Binding("IsEnabled"));
            this._columnpanel.SetBinding(Grid.VisibilityProperty, new Binding("Visibility"));
            this._columnpanel.SetBinding(Grid.ShowGridLinesProperty, new Binding("ShowGridLines"));
            this._columnpanel.SetBinding(Grid.WidthProperty, new Binding("Width"));

            this.LoadXml(SourceXml);
        }
Ejemplo n.º 4
0
        public void InsertLayout(BaseLayoutElement layout)
        {
            CheckAndConnect();

            if (ContainsKey(layout.Id))
            {
                throw new Exception(string.Format("Layout [{0}] with key [{1}] already exists", layout.Name, layout.Id));
            }

            LayoutRecord layoutObject = new LayoutRecord(layout.Id, layout.Name, layout.IsSelected, layout.PathToXml);

            AllLayouts.Insert(layoutObject);

            Logger.Debug("Layout [{0}] has been inserted successfully", layoutObject);
        }
Ejemplo n.º 5
0
        public void SaveLayout(BaseLayoutElement layout)
        {
            if (ContainsKey(layout.Id))
            {
                LayoutRecord layoutObject = AllLayouts.FindOne(l => l.LayoutKey == layout.Id);
                layoutObject.Name       = layout.Name;
                layoutObject.IsSelected = layout.IsSelected;
                layoutObject.PathToXml  = layout.PathToXml;

                AllLayouts.Update(layoutObject);
                Logger.Debug("Layout [{0}] has been updated successfully", layoutObject);
            }
            else
            {
                LayoutRecord layoutObject = new LayoutRecord(layout.Id, layout.Name, layout.IsSelected, layout.PathToXml);
                AllLayouts.Insert(layoutObject);

                Logger.Debug("Layout [{0}] has been inserted successfully", layoutObject);
            }
        }
Ejemplo n.º 6
0
 BaseLayoutElement GetSelectedLayout()
 {
     if (Layouts.Count(l => l.IsSelected == true) > 0)
     {
         BaseLayoutElement selectedLayout = Layouts.Where(l => l.IsSelected == true)
                                            .ToList().SingleOrDefault();
         return(selectedLayout);
     }
     else
     {
         Layouts[0].IsSelected = true;
         if (Get.i.Layouts.ContainsKey(Layouts[0].Id))
         {
             Get.i.Layouts.SaveLayout(Layouts[0]);
         }
         else
         {
             Get.i.Layouts.InsertLayout(Layouts[0]);
         }
     }
     return(Layouts[0]);
 }
Ejemplo n.º 7
0
        public void SelectLayout(Guid key)
        {
            Layouts.Where(w => w.IsSelected == true)
            .ToList()
            .ForEach(f => f.IsSelected = false);

            Get.i.Layouts.UnselectAll();

            SelectedLayout            = Layouts.Where(w => w.Id == key).ToList().Single();
            SelectedLayout.IsSelected = true;

            if (Get.i.Layouts.ContainsKey(key))
            {
                Get.i.Layouts.SaveLayout(SelectedLayout);
            }
            else
            {
                Get.i.Layouts.InsertLayout(SelectedLayout);
            }

            SelectedLayout.SerializeToXml();

            Logger.Debug("Selected layout changed to: {0}", SelectedLayout.Name);
        }