/// <summary>
        /// Initializes a new instance of the <see cref="CustomOperationView"/> class.
        /// </summary>
        public CustomOperationView()
        {
            InitializeComponent();
            _widgetManager = new WidgetManager();
            List<ILayoutPanelElement> elements = _widgetManager.InitializeViews();
            foreach (ILayoutPanelElement layoutPanelElement in elements)
            {
                rootLayout.RootPanel.Children.Add(layoutPanelElement);
            }
            List<String> fileIDs = new List<String>();
            var tempSerializer = new XmlLayoutSerializer(new DockingManager());
            tempSerializer.LayoutSerializationCallback += (sender, args) => fileIDs.Add(args.Model.ContentId);
            if (File.Exists(_layoutFile))
            {
                tempSerializer.Deserialize(_layoutFile);
            }
            bool everthingFound = _widgetManager.Widgets.Select(uiWidget => fileIDs.Any(fileID => fileID.ToLower().Equals(uiWidget.ContentGuid.ToLower()))).All(found => found);
            if (everthingFound)
            {
                var serializer = new XmlLayoutSerializer(dockingManager);
                if (File.Exists(_layoutFile))
                {
                    serializer.Deserialize(_layoutFile);
                }

            }
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            XmlLayoutSerializer serializer = new XmlLayoutSerializer(_dockingManager);

            serializer.LayoutSerializationCallback += (s, args) =>
                {
                    switch (args.Model.ContentId)
                    {
                        case "toolWindow1":
                            args.Content = new System.Windows.Controls.TextBlock() { Text = args.Model.ContentId };
                            break;
                        default:
                            args.Content = new System.Windows.Controls.TextBox() { Text = args.Model.ContentId };
                            break;
                    }

                };

            serializer.Deserialize(
                new System.IO.StringReader(
                AvalonDock.WinFormsTestApp.Properties.Settings.Default.DefaultLayout));


            //LayoutDocument doc = new LayoutDocument() { Title = "test" };
            //dockingManager.Layout.Descendents().OfType<LayoutDocumentPane>().First().Children.Add(doc);

            dockingManagerHost.Child = _dockingManager;
            
            base.OnLoad(e);
        }
Ejemplo n.º 3
0
        private void Serialize()
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);

            serializer.Serialize(@".\AvalonDock.config");

            // AsyncXmlLayoutSerializer may also be used here, as the serialization is not done async
            // due to the XmlSerializer used not having async overloads
            // var serializer = new AvalonDock.Layout.Serialization.AsyncXmlLayoutSerializer(dockManager);
            // serializer.Serialize(@".\AvalonDock.config");
        }
Ejemplo n.º 4
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);
            serializer.LayoutSerializationCallback += (s, args) =>
            {
                args.Content = args.Content;
            };

            if (File.Exists(@".\AvalonDock.config"))
                serializer.Deserialize(@".\AvalonDock.config");
        }
Ejemplo n.º 5
0
        private void Deserialize()
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);

            serializer.LayoutSerializationCallback += (s, args) => { args.Content = args.Content; };

            if (File.Exists(@".\AvalonDock.config"))
            {
                serializer.Deserialize(@".\AvalonDock.config");
            }
        }
Ejemplo n.º 6
0
 private void OnLoadLayout(object parameter)
 {
     var layoutSerializer = new XmlLayoutSerializer(dockManager);
       layoutSerializer.LayoutSerializationCallback += (s, e) =>
       {
     if (e.Model.ContentId == AnchorableViewModel.ToolContentId)
       e.Content = Workspace.This.Tools;
     else if (!string.IsNullOrWhiteSpace(e.Model.ContentId) &&
     File.Exists(e.Model.ContentId))
       e.Content = Workspace.This.Open(e.Model.ContentId);
       };
       layoutSerializer.Deserialize(@".\AvalonDock.Layout.config");
 }
        public void Load(DockingManager dockingManager)
        {
            var serializer = new XmlLayoutSerializer(dockingManager);
            serializer.LayoutSerializationCallback += (s, args) =>
            {
                args.Content = args.Content;
            };

            if (File.Exists(LayoutFileName))
            {
                serializer.Deserialize(LayoutFileName);
            }
        }
Ejemplo n.º 8
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);

            serializer.LayoutSerializationCallback += (s, args) =>
            {
                args.Content = args.Content;
            };

            if (File.Exists(@".\AvalonDock.config"))
            {
                serializer.Deserialize(@".\AvalonDock.config");
            }
        }
Ejemplo n.º 9
0
 public void LoadLayout(DockingManager dockingManager)
 {
     var layoutSerializer = new XmlLayoutSerializer(dockingManager);
     layoutSerializer.LayoutSerializationCallback += (s, e) =>
     {
         e.Content = Application.Current.MainWindow.FindName(e.Model.ContentId);
         //if (e.Model.ContentId == FileStatsViewModel.ToolContentId)
         //    e.Content = Workspace.This.FileStats;
         //else if (!string.IsNullOrWhiteSpace(e.Model.ContentId) &&
         //    File.Exists(e.Model.ContentId))
         //    e.Content = Workspace.This.Open(e.Model.ContentId);
     };
     layoutSerializer.Deserialize(LayoutConfigFile);
 }
Ejemplo n.º 10
0
        public void LoadLayout()
        {
            var layoutSerializer = new XmlLayoutSerializer(dockManager);
            layoutSerializer.LayoutSerializationCallback += (s, e) =>
                                                                {
                                                                    var anchorable = e.Model as LayoutAnchorable;
                                                                    var document = e.Model as LayoutDocument;
                                                                    IWorkspace workspace =
                                                                        _container.Resolve<AbstractWorkspace>();

                                                                    if (anchorable != null)
                                                                    {
                                                                        ToolViewModel model =
                                                                            workspace.Tools.First(
                                                                                f => f.ContentId == e.Model.ContentId);
                                                                        if (model != null)
                                                                        {
                                                                            e.Content = model;
                                                                            model.IsVisible = anchorable.IsVisible;
                                                                            model.IsActive = anchorable.IsActive;
                                                                            model.IsSelected = anchorable.IsSelected;
                                                                        }
                                                                    }
                                                                    if (document != null)
                                                                    {
                                                                        var fileService =
                                                                            _container.Resolve<IOpenFileService>();
                                                                        ContentViewModel model =
                                                                            fileService.OpenFromID(e.Model.ContentId);
                                                                        if (model != null)
                                                                        {
                                                                            e.Content = model;
                                                                            model.IsActive = document.IsActive;
                                                                            model.IsSelected = document.IsSelected;
                                                                        }
                                                                    }
                                                                };
            try
            {
                layoutSerializer.Deserialize(@".\AvalonDock.Layout.config");
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 11
0
 private void OnLoadLayout(object parameter)
 {
     var layoutSerializer = new XmlLayoutSerializer(dockManager);
     //Here I've implemented the LayoutSerializationCallback just to show
     // a way to feed layout desarialization with content loaded at runtime
     //Actually I could in this case let AvalonDock to attach the contents
     //from current layout using the content ids
     //LayoutSerializationCallback should anyway be handled to attach contents
     //not currently loaded
     layoutSerializer.LayoutSerializationCallback += (s, e) =>
         {
             //if (e.Model.ContentId == FileStatsViewModel.ToolContentId)
             //    e.Content = Workspace.This.FileStats;
             //else if (!string.IsNullOrWhiteSpace(e.Model.ContentId) &&
             //    File.Exists(e.Model.ContentId))
             //    e.Content = Workspace.This.Open(e.Model.ContentId);
         };
     layoutSerializer.Deserialize(@".\AvalonDock.Layout.config");
 }
Ejemplo n.º 12
0
        public void LoadLayout()
        {
            if (File.Exists(layoutFile))
            {
                var layoutSerializer = new XmlLayoutSerializer(dockManager);
                layoutSerializer.LayoutSerializationCallback += (s, args) =>
                {
                    if (args.Model is LayoutAnchorable)
                    {
                        var anchorable = args.Model as LayoutAnchorable;
                        string id = string.Empty;
                        Type pt = AnalysisContentIdWithType(args.Model.ContentId, out id);
                        PaneViewModel pm = viewModel.CreatePane(pt, id);
                        if (pm != null)
                        {
                            args.Content = pm;
                            pm.IsVisible = anchorable.IsVisible;
                            pm.IsSelected = anchorable.IsSelected;
                            viewModel.Panes.Add(pm);
                        }
                    }
                    else if (args.Model is LayoutDocument)
                    {
                        var document = args.Model as LayoutDocument;
                        string id = string.Empty;
                        Type dt = AnalysisContentIdWithType(args.Model.ContentId, out id);
                        DocumentViewModel dm = viewModel.CreateDocument(dt, id);
                        if (dm != null)
                        {
                            args.Content = dm;
                            dm.IsVisible = document.IsVisible;
                            dm.IsActive = document.IsActive;
                            dm.IsSelected = document.IsSelected;
                            viewModel.Documents.Add(dm);
                        }
                    }
                };

                layoutSerializer.Deserialize(layoutFile);
            }
        }
Ejemplo n.º 13
0
 private void OnSaveLayout(object parameter)
 {
     var layoutSerializer = new XmlLayoutSerializer(dockManager);
     layoutSerializer.Serialize(@".\AvalonDock.Layout.config");
 }
        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            XmlLayoutSerializer serializer = new XmlLayoutSerializer(dockingManager);

            using (XmlTextWriter writer = new XmlTextWriter(_layoutFile, Encoding.UTF8))
            {
                serializer.Serialize(writer);
            }
        }
        private void InitializeWidgetManager()
        {
            foreach (ILayoutPanelElement layoutPanelElement in _widgetManager.GetInitializedViews())
            {
                rootLayout.RootPanel.Children.Add(layoutPanelElement);
            }

            if (File.Exists(_layoutFile))
            {
                IEnumerable<string> ids = GetIdentifiersInFile();

                bool everthingFound = _widgetManager.Widgets
                    .Select(widget => ids.Any(id => string.Equals(id, widget.ContentGuid, StringComparison.OrdinalIgnoreCase)))
                    .All(found => found);

                if (everthingFound)
                {
                    XmlLayoutSerializer serializer = new XmlLayoutSerializer(dockingManager);
                    serializer.Deserialize(_layoutFile);
                }
            }
        }
        private IEnumerable<string> GetIdentifiersInFile()
        {
            IList<string> ids = new List<string>();

            XmlLayoutSerializer tempSerializer = new XmlLayoutSerializer(new DockingManager());
            tempSerializer.LayoutSerializationCallback += (sender, args) =>
            {
                ids.Add(args.Model.ContentId);
            };

            tempSerializer.Deserialize(_layoutFile);

            return ids;
        }
 public void Save(DockingManager dockingManager)
 {
     var layoutSerializer = new XmlLayoutSerializer(dockingManager);
     layoutSerializer.Serialize(LayoutFileName);
 }
Ejemplo n.º 18
0
 public void SaveLayout()
 {
     foreach (var doc in viewModel.Documents)
     {
         doc.ContentId = BuildContentIdWithType(doc.GetType(), doc.ContentId);
     }
     foreach (var pane in viewModel.Panes)
     {
         pane.ContentId = BuildContentIdWithType(pane.GetType(), pane.ContentId);
     }
     var layoutSerializer = new XmlLayoutSerializer(dockManager);
     layoutSerializer.Serialize(layoutFile);
 }
Ejemplo n.º 19
0
        private void OnLoadLayout(object sender, RoutedEventArgs e)
        {
            var currentContentsList = dockManager.Layout.Descendents().OfType<LayoutContent>().Where(c => c.ContentId != null).ToArray();

            string fileName = (sender as MenuItem).Header.ToString();
            var serializer = new XmlLayoutSerializer(dockManager);
            //serializer.LayoutSerializationCallback += (s, args) =>
            //    {
            //        var prevContent = currentContentsList.FirstOrDefault(c => c.ContentId == args.Model.ContentId);
            //        if (prevContent != null)
            //            args.Content = prevContent.Content;
            //    };
            using (var stream = new StreamReader(string.Format(@".\AvalonDock_{0}.config", fileName)))
                serializer.Deserialize(stream);
        }
Ejemplo n.º 20
0
 public void SaveLayout()
 {
     var layoutSerializer = new XmlLayoutSerializer(dockManager);
     layoutSerializer.Serialize(@".\AvalonDock.Layout.config");
 }
Ejemplo n.º 21
0
 void MainWindow_Unloaded(object sender, RoutedEventArgs e)
 {
     var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);
     serializer.Serialize(@".\AvalonDock.config");
 }
Ejemplo n.º 22
0
 private void UserControl_Unloaded(object sender, RoutedEventArgs e)
 {
     var serializer = new XmlLayoutSerializer(dockingManager);
     XmlTextWriter writer = new XmlTextWriter(_layoutFile, Encoding.UTF8);
     serializer.Serialize(writer);
     writer.Flush();
     writer.Close();
 }
Ejemplo n.º 23
0
 private void OnSaveLayout(object sender, RoutedEventArgs e)
 {
     string fileName = (sender as MenuItem).Header.ToString();
     var serializer = new XmlLayoutSerializer(dockManager);
     using (var stream = new StreamWriter(string.Format(@".\AvalonDock_{0}.config", fileName)))
         serializer.Serialize(stream);
 }
Ejemplo n.º 24
0
        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);

            serializer.Serialize(@".\AvalonDock.config");
        }