Exemplo n.º 1
0
        public static void PushModalDialog(Window window, string windowId)
        {
            window.PushModal();
            if (string.IsNullOrEmpty(windowId))
            {
                return;
            }

            WindowSettings settings = WindowSettings.GetByWindowId(windowId);

            if (settings == null)
            {
                return;
            }

            window.Resize(settings.Width, settings.Height);
            foreach (Paned pane in ComponentHelper.GetChildWidgetsByType <Paned> (window))
            {
                PaneSettings pair = settings.Panes.FirstOrDefault(p => p.Name == pane.Name);
                if (pair != null)
                {
                    pane.Position = pair.Position;
                }
            }

            ColumnSerializer.LoadColumnSettings(window, settings);
        }
        public static void SaveColumnSettings(Container container, WindowSettings settings)
        {
            settings.Columns.Clear();
            foreach (ListView listView in ComponentHelper.GetChildWidgetsByType <ListView> (container))
            {
                foreach (Column column in listView.ColumnController)
                {
                    settings.Columns.Add(new ColumnSettings
                    {
                        Owner         = listView.Name,
                        Key           = column.ListCell.PropertyName,
                        IsSortable    = column.IsSortable,
                        SortDirection = column.SortDirection,
                        SortKey       = column.SortKey,
                        Width         = column.Width
                    });
                }
            }

            settings.CommitChanges();
        }
        public static void LoadColumnSettings(Container container, WindowSettings settings)
        {
            foreach (ListView grid in ComponentHelper.GetChildWidgetsByType <ListView> (container))
            {
                Column   sortedColumn = null;
                ListView local        = grid;
                List <ColumnSettings> columnSettings = settings.Columns.FindAll(p => p.Owner == local.Name);
                List <Column>         gridColumns    = new List <Column> (grid.ColumnController);

                foreach (ColumnSettings columnSetting in columnSettings)
                {
                    string key        = columnSetting.Key;
                    Column gridColumn = gridColumns.Find(c => c.ListCell.PropertyName == key);
                    if (gridColumn == null)
                    {
                        continue;
                    }

                    gridColumn.IsSortable    = columnSetting.IsSortable;
                    gridColumn.SortDirection = columnSetting.SortDirection;
                    gridColumn.SortKey       = columnSetting.SortKey;
                    gridColumn.Width         = columnSetting.Width;
                    if (gridColumn.SortDirection != SortDirection.None)
                    {
                        sortedColumn = gridColumn;
                    }
                }

                if (sortedColumn == null || !sortedColumn.IsSortable)
                {
                    continue;
                }

                ISortable sortable = grid.Model as ISortable;
                if (sortable != null)
                {
                    sortable.Sort(sortedColumn);
                }
            }
        }
Exemplo n.º 4
0
        public static void PopModalDialog(Window window, string windowId)
        {
            window.PopModal();
            if (string.IsNullOrEmpty(windowId))
            {
                return;
            }

            WindowSettings settings = WindowSettings.GetByWindowId(windowId) ?? new WindowSettings {
                WindowId = windowId
            };

            settings.Width  = window.Allocation.Width;
            settings.Height = window.Allocation.Height;
            settings.Panes.Clear();
            foreach (Paned pane in ComponentHelper.GetChildWidgetsByType <Paned> (window))
            {
                settings.Panes.Add(new PaneSettings {
                    Name = pane.Name, Position = pane.Position
                });
            }

            ColumnSerializer.SaveColumnSettings(window, settings);
        }