Пример #1
0
        private Xceed.Wpf.AvalonDock.Layout.LayoutDocument FindDocWithContentID(Xceed.Wpf.AvalonDock.Layout.ILayoutElement root, string contentID)
        {
            Xceed.Wpf.AvalonDock.Layout.LayoutDocument content = null;

            if (root is Xceed.Wpf.AvalonDock.Layout.ILayoutContainer)
            {
                Xceed.Wpf.AvalonDock.Layout.ILayoutContainer ic = root as Xceed.Wpf.AvalonDock.Layout.ILayoutContainer;
                foreach (Xceed.Wpf.AvalonDock.Layout.ILayoutElement ie in ic.Children)
                {
                    Xceed.Wpf.AvalonDock.Layout.LayoutDocument f = FindDocWithContentID(ie, contentID);
                    if (f != null)
                    {
                        content = f;
                        break;
                    }
                }
            }
            else
            {
                if (root is Xceed.Wpf.AvalonDock.Layout.LayoutDocument)
                {
                    Xceed.Wpf.AvalonDock.Layout.LayoutDocument i = root as Xceed.Wpf.AvalonDock.Layout.LayoutDocument;
                    if (i.ContentId == contentID)
                    {
                        content = i;
                    }
                }
            }
            return(content);
        }
Пример #2
0
        public MainWindow()
        {
            OutputLog.Info("Starting App..");
            AppWindow = this;

            InitializeComponent();


            string dockManagerLayoutName = AppDomain.CurrentDomain.BaseDirectory + @"\Layout.dat";

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

            RegionLayoutDoc = FindDocWithContentID(dockManager.Layout, "MapRegionContentID");

/*            // now update the RegionLayoutDoc because the layout loading breaks the binding
 *          foreach (Xceed.Wpf.AvalonDock.Layout.ILayoutElement ile in dockManager.Layout.Children)
 *          {
 *              if(ile is Xceed.Wpf.AvalonDock.Layout.ILayoutContainer )
 *              {
 *                  Xceed.Wpf.AvalonDock.Layout.ILayoutContainer ilc = ile as Xceed.Wpf.AvalonDock.Layout.ILayoutContainer;
 *
 *                  foreach (Xceed.Wpf.AvalonDock.Layout.LayoutDocumentPane ldp in ilc.Children.OfType<Xceed.Wpf.AvalonDock.Layout.LayoutDocumentPane>())
 *                  {
 *                      foreach (Xceed.Wpf.AvalonDock.Layout.LayoutDocument ld in ldp.Children.OfType<Xceed.Wpf.AvalonDock.Layout.LayoutDocument>())
 *                      {
 *                          if (ld.ContentId == "MapRegionContentID")
 *                          {
 *                              RegionLayoutDoc = ld;
 *                          }
 *                      }
 *                  }
 *
 *              }
 *
 *          }
 */

            // load any custom map settings off disk
            string mapConfigFileName = AppDomain.CurrentDomain.BaseDirectory + @"\MapConfig.dat";

            OutputLog.Info("Loading Map config from {0}", mapConfigFileName);


            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.MapColours = new List <MapColours>();
                    MapConf.SetDefaultColours();
                }
            }
            else
            {
                MapConf            = new MapConfig();
                MapConf.MapColours = new List <MapColours>();
                MapConf.SetDefaultColours();
            }

            EVEManager = new EVEData.EveManager();
            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();


            ColourListDropdown.ItemsSource = MapConf.MapColours;
            CharactersList.ItemsSource     = EVEManager.LocalCharacters;

            TheraConnectionsList.ItemsSource = EVEManager.TheraConnections;

            MapColours selectedColours = MapConf.MapColours[0];

            // find the matching active colour scheme
            foreach (MapColours mc in MapConf.MapColours)
            {
                if (MapConf.DefaultColourSchemeName == mc.Name)
                {
                    selectedColours = mc;
                }
            }



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


            RegionRC.RegionChanged             += RegionRC_RegionChanged;
            RegionRC.CharacterSelectionChanged += RegionRC_CharacterSelectionChanged;


            // load the anom data
            string anomDataFilename = AppDomain.CurrentDomain.BaseDirectory + @"\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();
            }

            MainAnomGrid.DataContext = ANOMManager;
            RegionRC.ANOMManager     = ANOMManager;

            MainRouteGrid.DataContext = RegionRC;


            AppStatusBar.DataContext = EVEManager.ServerInfo;


            // ColourListDropdown.SelectedItem = selectedColours;
            ColoursPropertyGrid.SelectedObject       = selectedColours;
            MapConf.ActiveColourScheme               = selectedColours;
            ColoursPropertyGrid.PropertyChanged     += ColoursPropertyGrid_PropertyChanged;
            MapConf.PropertyChanged                 += MapConf_PropertyChanged;
            MapControlsPropertyGrid.PropertyChanged += ColoursPropertyGrid_PropertyChanged;


            Closed += MainWindow_Closed;

            EVEManager.IntelAddedEvent += OnIntelAdded;
            //MapConf.PropertyChanged += RegionRC.MapObjectChanged;

            AddRegionsToUniverse();


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



            ZKBFeed.ItemsSource = EVEManager.ZKillFeed.KillStream;


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

            zKBFeedview.Filter = ZKBFeedFilter;



            MapControlsPropertyGrid.SelectedObject = MapConf;
        }