예제 #1
0
        public static bool TryLoadOverlay(string assemblyPath, BindingRouter br, out OverlayBase ob)
        {
            if (assemblyPath == null)
            {
                ob = LoadOverlay(
                    Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().GetMainModuleFileName()),
                                 "Milvaneth.Overlay.dll"), br);
                LoggingManagementService.WriteLine($"Loaded default overlay", "OvlMgmt");
                return(true);
            }

            try
            {
                ob = LoadOverlay(assemblyPath, br);
                LoggingManagementService.WriteLine($@"Loaded custom overlay at ""{assemblyPath}""", "OvlMgmt");
                return(true);
            }
            catch
            {
                ob = LoadOverlay(
                    Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().GetMainModuleFileName()),
                                 "Milvaneth.Overlay.dll"), br);
            }

            LoggingManagementService.WriteLine($@"Loaded custom overlay failed. Using default overlay", "OvlMgmt");
            return(false);
        }
예제 #2
0
 public LogPage(BindingRouter dataContext)
 {
     InitializeComponent();
     CommandBindings.Add(new CommandBinding(BindingRouter.LogCommandLineEnterCommand, OnCommandLineEnter));
     DataContext = dataContext;
     br          = dataContext;
 }
예제 #3
0
        public MainWindow(Mutex mutex, out bool showUsrDiag)
        {
            // data router
            _mutex = mutex;
            br     = new BindingRouter(env);

            // services
            if (!ApiVendor.TryPrepareRestApi())
            {
                InlineLogic.ServerUnreachableLogic();
            }

            showUsrDiag = SupportStatic.RemoteInitialize(br.ConfAutoUpdate);
            SupportStatic.InitializeAll();

            pool = new DataPool(x => LoggingManagementService.WriteLine(x, "UplMgmt"));

            SubprocessManagementService.OnOverrideRequested += br.SaveConfig;
            LoggingManagementService.OnNewLogLine           += br.DummyListener;
            TransmittingManagementService.OnDataOutput      += pool.SinkData;
            TransmittingManagementService.OnDataOutput      += LocalHandler;

            // user interface
            InitializeComponent();
            InitializeWinformComponent();
            CommandBindings.Add(new CommandBinding(BindingRouter.UiSearchLineEnterCommand, OnCommandLineEnter));
            this.DataContext = br;

#if DEBUG
            Title = "Milvaneth Prélude";
#endif

            // subviews
            ip = new ItemOverviewPage(br);
            sp = new SettingPage(br);
            lp = new LogPage(br);
            ap = new AboutPage(br);

            // custom message
            InlineLogic.GlobalMessageLogic();

            if (!showUsrDiag)
            {
                ShowOverlay();
            }

            // finish initialize
            if (br.ConfAutoAttach)
            {
                SubprocessManagementService.SpawnAll(out _);
            }
            if (!br.ConfNotUseHunter)
            {
                SubprocessManagementService.SpawnHunter();
            }

            br.UiActiveTab = 3;
            MainFrame.Navigate(ap);
        }
예제 #4
0
        public ItemOverviewPage(BindingRouter dataContext)
        {
            opvm = new OverviewPresenterViewModel();

            InitializeComponent();
            DataContext = dataContext;
            this.ElementView.DataContext = opvm;
            br = dataContext;

            dataContext.PropertyChanged += OnPropertyChanged;
        }
예제 #5
0
        private static OverlayBase LoadOverlay(string assemblyPath, BindingRouter br)
        {
            var assembly = Assembly.LoadFile(assemblyPath);
            var types    = GetTypeByName(assembly);

            if (types.Length != 1)
            {
                throw new InvalidOperationException("Unable to determine overlay class based on OverlayBase");
            }
            var type = types[0];

            return((OverlayBase)Activator.CreateInstance(type, br));
        }
예제 #6
0
        public SettingPage(BindingRouter dataContext)
        {
            InitializeComponent();
            DataContext = dataContext;
            br          = dataContext;

            Task.Run(() =>
            {
                for (;;)
                {
                    // use an independent source to maintain process list: less filter, more stable
                    UpdateTask();
                    Thread.Sleep(15000);
                }
            });
        }
예제 #7
0
        public AboutPage(BindingRouter dataContext)
        {
            avm = new AboutViewModel();

            InitializeComponent();

            var aboutStream = Application
                              .GetResourceStream(new Uri("pack://application:,,,/Milvaneth;component/about.txt")).Stream;
            var sr = new StreamReader(aboutStream);

            AboutBox.Text = sr.ReadToEnd();

#if DEBUG
            AboutName.Text = "Milvaneth 客户端 [测试版]";
#endif

            DataContext = avm;
            br          = dataContext;

            avm.FormattedVersionString =
                $"版本 {br.AboutMilvanethVersion} (D-{br.AboutDataVersion} / G-{br.AboutGameVersion})";
            dataContext.PropertyChanged += OnPropertyChanged;
        }
예제 #8
0
        public OverlayWindow(BindingRouter dataContext)
        {
            opvm = new OverlayPresenterViewModel();
            lpvm = new ListingPresenterViewModel();
            hpvm = new HistoryPresenterViewModel();

            ltp = new ListTabPage(lpvm);
            htp = new HistTabPage(hpvm);

            InitializeComponent();
            DataContext = dataContext;
            br          = dataContext;
            dataContext.PropertyChanged += OnPropertyChanged;
            _clickthrough = null;

            this.Header.DataContext = opvm;

            opvm.UpdateData(br.OverlayItemId, br.OverlayOverviewData, br.OverlayListingData, br.OverlayHistoryData);
            lpvm.UpdateData(br.OverlayItemId, br.OverlayListingData);
            hpvm.UpdateData(br.OverlayItemId, br.OverlayHistoryData);

            MainFrame.Navigate(ltp);
        }
예제 #9
0
 public OverlayBase(BindingRouter br)
 {
 }