コード例 #1
0
ファイル: Extensions.cs プロジェクト: nuthrash/Minax
        /// <summary>
        /// Convert docking XML string to layout data to this DockingManager
        /// </summary>
        /// <param name="dockManager">Target DockingManager</param>
        /// <param name="layoutXml">Layout XML string</param>
        public static void LayoutFromString(this DockingManager dockManager, string layoutXml)
        {
            StringReader sr         = new StringReader(layoutXml);
            var          serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);

            serializer.Deserialize(sr);
        }
コード例 #2
0
        private void Manager_Loaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("Deserialize the layout...");
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(this.Manager);

            // the handler is required even if it is empty
            serializer.LayoutSerializationCallback += Serializer_LayoutSerializationCallback;
            serializer.Deserialize(layoutXmlFile);
        }
コード例 #3
0
        private void LoadDockingLayout()
        {
            var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(
                dockingManager);

            //serializer.LayoutSerializationCallback += serializer_LayoutSerializationCallback;
            using (var stream = System.IO.File.OpenRead("AvalonLayoutConfig.xml"))
            {
                serializer.Deserialize(stream);
            }
        }
コード例 #4
0
        public static void LoadLayout(this DockingManager dockingManager)
        {
            var layoutFileName = ApplicationPaths.AvalonDockLayoutFile;

            if (!File.Exists(layoutFileName))
            {
                return;                               // exit here if the saved layout file does not exist
            }
            using (StreamReader sr = new StreamReader(layoutFileName))
            {
                var ls = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
                //var ls = new DockingManagerJsonLayoutSerializer(dm);
                ls.Deserialize(sr);
            }
        }
コード例 #5
0
 // load/restore the layout
 private void DockManager_Loaded(object sender, RoutedEventArgs e)
 {
     if (!File.Exists(layoutXmlFile))
     {
         Debug.WriteLine($"File not exists: {layoutXmlFile}");
         return;
     }
     // note that, in MVVM, the view can know the viewmodel (but not vice versa)
     if (DataContext is ShellViewModel vm)
     {
         // try to retrieve the viewmodel of a LayoutContent for the ContentId
         var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);
         serializer.LayoutSerializationCallback += RestoreLayoutContent;
         // the method below will set the `Layout` property (of type LayoutRoot) of the DockingManager
         serializer.Deserialize(layoutXmlFile);
         // TODO: ActiveContent
     }
 }
コード例 #6
0
        //--------------------------------------------------------------------------------------------------

        void _LoadWindowLayout(string name)
        {
            // Load window layout
            try
            {
                var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(DockingManager);
                serializer.LayoutSerializationCallback += (s, args) =>
                {
                    args.Content = args.Content;
                };

                var filename = Path.Combine(AppContext.Current.LocalAppDataDirectory, "WindowLayouts", $"{name}.xml");
                if (File.Exists(filename))
                {
                    serializer.Deserialize(filename);
                }
            }
            catch (Exception exception)
            {
                Messages.Exception("Error loading window layout. The default layout was loaded instead.", exception);
            }
        }
コード例 #7
0
        public static void RestoreDefaultLayout(this DockingManager dockingManager)
        {
            var thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();

            using (Stream strm = thisAssembly.GetManifestResourceStream(Constants.AvalonDockDefaultLayoutFile))
            {
                // check if default layout was found
                if (strm == null)
                {
                    return;
                }

                var ls = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockingManager);
                ls.Deserialize(strm);
            }

            // delete the saved layout file if it exists
            var layoutFileName = ApplicationPaths.AvalonDockLayoutFile;

            if (File.Exists(layoutFileName))
            {
                File.Delete(layoutFileName);
            }
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: Nimos/SMT
        /// <summary>
        /// Main Window
        /// </summary>
        public MainWindow()
        {
            AppWindow   = this;
            DataContext = this;

            mediaPlayer = new MediaPlayer();
            Uri woopUri = new Uri(AppDomain.CurrentDomain.BaseDirectory + @"\Sounds\woop.mp3");

            mediaPlayer.Open(woopUri);



            InitializeComponent();

            Title = "SMT (Crystal Vagooey : " + SMT_VERSION + ")";

            CheckGitHubVersion();

            // Load the Dock Manager Layout file
            string dockManagerLayoutName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\SMT\\" + SMT_VERSION + "\\Layout.dat";

            if (File.Exists(dockManagerLayoutName))
            {
                try
                {
                    AvalonDock.Layout.Serialization.XmlLayoutSerializer ls = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(dockManager);
                    using (var sr = new StreamReader(dockManagerLayoutName))
                    {
                        ls.Deserialize(sr);
                    }
                }
                catch
                {
                }
            }

            // Due to bugs in the Dock manager patch up the content id's for the 2 main views
            RegionLayoutDoc   = FindDocWithContentID(dockManager.Layout, "MapRegionContentID");
            UniverseLayoutDoc = FindDocWithContentID(dockManager.Layout, "FullUniverseViewID");

            // load any custom map settings off disk
            string mapConfigFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\SMT\\" + SMT_VERSION + "\\MapConfig.dat";

            if (File.Exists(mapConfigFileName))
            {
                try
                {
                    XmlSerializer xms  = new XmlSerializer(typeof(MapConfig));
                    FileStream    fs   = new FileStream(mapConfigFileName, FileMode.Open);
                    XmlReader     xmlr = XmlReader.Create(fs);

                    MapConf = (MapConfig)xms.Deserialize(xmlr);
                    fs.Close();
                }
                catch
                {
                    MapConf = new MapConfig();
                    MapConf.SetDefaultColours();
                }
            }
            else
            {
                MapConf = new MapConfig();
                MapConf.SetDefaultColours();
            }

            // Create the main EVE manager

            EVEManager = new EVEData.EveManager(SMT_VERSION);
            EVEData.EveManager.Instance = EVEManager;

            // if we want to re-build the data as we've changed the format, recreate it all from scratch
            bool initFromScratch = false;

            if (initFromScratch)
            {
                EVEManager.CreateFromScratch();
            }
            else
            {
                EVEManager.LoadFromDisk();
            }

            EVEManager.SetupIntelWatcher();
            RawIntelBox.ItemsSource = EVEManager.IntelDataList;

            // load jump bridge data
            EVEManager.LoadJumpBridgeData();
            EVEManager.UpdateESIUniverseData();
            EVEManager.InitNavigation();

            CharactersList.ItemsSource = EVEManager.LocalCharacters;
            CurrentActiveCharacterCombo.ItemsSource = EVEManager.LocalCharacters;

            TheraConnectionsList.ItemsSource = EVEManager.TheraConnections;
            JumpBridgeList.ItemsSource       = EVEManager.JumpBridges;

            SovCampaignList.ItemsSource = EVEManager.ActiveSovCampaigns;
            EVEManager.ActiveSovCampaigns.CollectionChanged += ActiveSovCampaigns_CollectionChanged;

            RegionUC.MapConf = MapConf;
            RegionUC.Init();
            RegionUC.SelectRegion(MapConf.DefaultRegion);

            RegionUC.RegionChanged        += RegionUC_RegionChanged;
            RegionUC.UniverseSystemSelect += RegionUC_UniverseSystemSelect;

            UniverseUC.MapConf = MapConf;
            UniverseUC.Init();
            UniverseUC.RequestRegionSystem += UniverseUC_RequestRegionSystem;

            RegionsViewUC.MapConf = MapConf;
            RegionsViewUC.Init();
            RegionsViewUC.RequestRegion += RegionsViewUC_RequestRegion;

            AppStatusBar.DataContext = EVEManager.ServerInfo;

            // load the anom data
            string anomDataFilename = EVEManager.SaveDataVersionFolder + @"\Anoms.dat";

            if (File.Exists(anomDataFilename))
            {
                try
                {
                    XmlSerializer xms = new XmlSerializer(typeof(EVEData.AnomManager));

                    FileStream fs   = new FileStream(anomDataFilename, FileMode.Open);
                    XmlReader  xmlr = XmlReader.Create(fs);

                    ANOMManager = (EVEData.AnomManager)xms.Deserialize(xmlr);
                    fs.Close();
                }
                catch
                {
                    ANOMManager = new EVEData.AnomManager();
                }
            }
            else
            {
                ANOMManager = new EVEData.AnomManager();
            }

            RegionUC.ANOMManager = ANOMManager;


            List <EVEData.System> globalSystemList = new List <EVEData.System>(EVEManager.Systems);

            globalSystemList.Sort((a, b) => string.Compare(a.Name, b.Name));
            RouteSystemDropDownAC.ItemsSource = globalSystemList;

            ColoursPropertyGrid.SelectedObject        = MapConf.ActiveColourScheme;
            ColoursPropertyGrid.PropertyValueChanged += ColoursPropertyGrid_PropertyValueChanged;;
            MapConf.PropertyChanged += MapConf_PropertyChanged;

            Closed += MainWindow_Closed;

            EVEManager.IntelAddedEvent += OnIntelAdded;



            uiRefreshTimer          = new System.Windows.Threading.DispatcherTimer();
            uiRefreshTimer.Tick    += UiRefreshTimer_Tick;
            uiRefreshTimer.Interval = new TimeSpan(0, 0, 1);
            uiRefreshTimer.Start();

            ZKBFeed.ItemsSource = EVEManager.ZKillFeed.KillStream;

            CollectionView zKBFeedview = (CollectionView)CollectionViewSource.GetDefaultView(ZKBFeed.ItemsSource);

            zKBFeedview.Refresh();
            zKBFeedview.Filter = ZKBFeedFilter;

            foreach (EVEData.LocalCharacter lc in EVEManager.LocalCharacters)
            {
                lc.WarningSystemRange = MapConf.WarningRange;
                lc.Location           = "";
            }
        }
コード例 #9
0
 private void LoadDockingLayout()
 {
     var serializer = new AvalonDock.Layout.Serialization.XmlLayoutSerializer(
         dockingManager);
     //serializer.LayoutSerializationCallback += serializer_LayoutSerializationCallback;
     using (var stream = System.IO.File.OpenRead("AvalonLayoutConfig.xml"))
     {
         serializer.Deserialize(stream);
     }
 }