//public string GetWidgetInstanceOwnerName(int widgetInstanceId)
        //{
        //    return this.widgetInstanceRepository.GetWidgetInstanceOwnerName(widgetInstanceId);
        //}

        public void CreateDefaultWidgetsOnTab(string userName, int pageId)
        {
            List<Widget> defaultWidgets = null;

            defaultWidgets = (System.Web.Security.Roles.Enabled && !string.IsNullOrEmpty(userName)) ?
                this.GetWidgetList(userName, Enumerations.WidgetType.PersonalTab).Where(w => w.IsDefault).ToList() :
                this.widgetRepository.GetWidgetByIsDefault(true);
            
            var widgetsPerColumn = (int)Math.Ceiling((float)defaultWidgets.Count / 3.0);

            var row = 0;
            var col = 0;

            var widgetZone = this.widgetZoneRepository.GetWidgetZoneByTabId_ColumnNo(pageId, col);
            List<WidgetInstance> wis = defaultWidgets.ConvertAll<WidgetInstance>(widget =>
                {
                    var instance = new WidgetInstance();

                    instance.WidgetZone = new WidgetZone { ID = widgetZone.ID };
                    instance.OrderNo = row;
                    instance.CreatedDate = DateTime.Now;
                    instance.Expanded = true;
                    instance.Title = widget.Name;
                    instance.VersionNo = 1;
                    instance.Widget = new Widget { ID = widget.ID };
                    instance.State = widget.DefaultState;

                    row++;
                    if (row >= widgetsPerColumn)
                    {
                        row = 0;
                        col++;
                    }

                    return instance;
                });
            this.widgetInstanceRepository.InsertList(wis);
        }
 private void Widget_Deleted(WidgetInstance wi, IWidgetHost host)
 {
     if (host is Control)
         this.WidgetHolderPanel.Controls.Remove(host as Control);
     this.RefreshZoneUpdatePanel();
 }
    public void AddNewWidget(EventBrokerService eventBroker, WidgetInstance instance)
    {
        var widgetHost = CreateWidgetContainerFromWidgetInstance(eventBroker, instance);
        var widgetContainer = widgetHost as Control;

        var existingControls = this.WidgetHolderPanel.Controls;
        if (existingControls == null || existingControls.Count == 0)
        {
            this.WidgetHolderPanel.Controls.Add(widgetContainer);
        }
        else
        {
            var position = 0;
            foreach (Control existingControl in existingControls)
            {
                if (existingControl is IWidgetHost)
                {
                    var existingHost = existingControl as IWidgetHost;
                    if (existingHost.WidgetInstance.OrderNo >= instance.OrderNo)
                    {
                        break;
                    }
                }

                
            }
            existingControls.AddAt(position, widgetContainer);
        }

        this.Refresh();
    }
    private IWidgetHost CreateWidgetContainerFromWidgetInstance(EventBrokerService eventBroker, WidgetInstance instance)
    {
        var widget = LoadControl(this.WidgetContainerPath) as Control;
        widget.ID = "WidgetContainer" + instance.Id.ToString();

        var widgetHost = widget as IWidgetHost;
        widgetHost.WidgetInstance = instance;
        widgetHost.IsLocked = this.IsLocked;
        widgetHost.EventBroker = eventBroker;

        widgetHost.Deleted += new Action<WidgetInstance, IWidgetHost>(Widget_Deleted);

        return widgetHost;
    }
Beispiel #5
0
        public WidgetInstance CloneWidgetInstance(int widgetZoneId, WidgetInstance wiToClone)
        {
            var newWidgetInstance = this.widgetInstanceRepository.Insert(new WidgetInstance
            {
                CreatedDate = wiToClone.CreatedDate,
                Expanded = wiToClone.Expanded,
                Height = wiToClone.Height,
                LastUpdate = wiToClone.LastUpdate,
                Maximized = wiToClone.Maximized,
                OrderNo = wiToClone.OrderNo,
                Resized = wiToClone.Resized,
                State = wiToClone.State,
                Title = wiToClone.Title,
                VersionNo = wiToClone.VersionNo,
                Widget = new Widget { ID = wiToClone.Widget.ID },
                WidgetZone = new WidgetZone { ID = widgetZoneId },
                Width = wiToClone.Width
            });           

            return newWidgetInstance;
        }
 public void AddNewWidget(WidgetInstance wi)
 {
     var widgetZoneControl = this.FindControl(GetWidgetZoneControlId(wi.WidgetZone.ID)) as WidgetInstanceZone;
     widgetZoneControl.AddNewWidget(_EventBroker, wi);       
 }
Beispiel #7
0
 public void NewWidgetAdded(WidgetInstance newWidget)
 {
     this.WidgetTabHost.AddNewWidget(newWidget);
 }