示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            LabelStatus.Visibility         = Visibility.Hidden;
            LabelStatusTop.Visibility      = Visibility.Hidden;
            ButtonRestartUpdate.Visibility = Visibility.Hidden;
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            _version    = $"{version.Major}.{version.Minor}.{version.Build}";
            this.Title += $" - {_version}";

            SyncMlProgress   = new SyncMlProgress();
            SyncMlSessions   = new ObservableCollection <SyncMlSession>();
            SyncMlMlMessages = new ObservableCollection <SyncMlMessage>();

            _rs = RunspaceFactory.CreateRunspace();
            _rs.Open();

            _backgroundWorker = new BackgroundWorker
            {
                WorkerReportsProgress = true
            };
            _backgroundWorker.DoWork          += WorkerTraceEvents;
            _backgroundWorker.ProgressChanged += WorkerProgressChanged;
            _backgroundWorker.RunWorkerAsync();

            DataContext = this;

            this.Loaded += delegate { MenuItemCheckUpdate_OnClick(null, new RoutedEventArgs()); };

            ListBoxSessions.ItemsSource       = SyncMlSessions;
            ListBoxSessions.DisplayMemberPath = "Entry";

            ListBoxMessages.ItemsSource       = SyncMlMlMessages;
            ListBoxMessages.DisplayMemberPath = "Entry";

            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorStream);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorMessages);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorCodes);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorDiagnostics);
            _foldingManager  = FoldingManager.Install(TextEditorMessages.TextArea);
            _foldingStrategy = new XmlFoldingStrategy();
            _foldingStrategy.UpdateFoldings(_foldingManager, TextEditorMessages.Document);

            LabelDeviceName.Content = Environment.MachineName;
            _updateStarted          = false;
            _updateCheckInitial     = true;

            TextEditorStream.Options.HighlightCurrentLine   = true;
            TextEditorMessages.Options.HighlightCurrentLine = true;

            TextEditorCodes.Options.EnableHyperlinks = true;
            TextEditorCodes.Options.RequireControlModifierForHyperlinkClick = false;
            TextEditorCodes.Text = Properties.Resources.StatusCodes;

            TextEditorAbout.Options.EnableHyperlinks = true;
            TextEditorAbout.Options.RequireControlModifierForHyperlinkClick = false;
            TextEditorAbout.Text = Properties.Resources.About;

            TextEditorDiagnostics.Text +=
                $"Hostname:           {MdmDiagnostics.Hostname}\r\n" +
                $"OS Version:         {MdmDiagnostics.OsVersion} (x{MdmDiagnostics.Bits})\r\n" +
                $"Version:            {MdmDiagnostics.Version}\r\n" +
                $"Current Build:      {MdmDiagnostics.CurrentBuild}.{MdmDiagnostics.BuildRevision}\r\n" +
                $"Release ID:         {MdmDiagnostics.ReleaseId}\r\n" +
                $"Build Branch:       {MdmDiagnostics.BuildBranch}\r\n" +
                $"Enrollment UPN:     {_mdmDiagnostics.Upn}\r\n" +
                $"AAD TenantID:       {_mdmDiagnostics.AadTenantId}\r\n" +
                $"OMA-DM AccountID:   {_mdmDiagnostics.OmaDmAccountId}";
        }
        public MainWindow()
        {
            InitializeComponent();

            LabelStatus.Visibility         = Visibility.Hidden;
            LabelStatusTop.Visibility      = Visibility.Hidden;
            ButtonRestartUpdate.Visibility = Visibility.Hidden;
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            _version    = $"{version.Major}.{version.Minor}.{version.Build}";
            this.Title += $" - {_version}";

            // based on this: https://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/
            _notifyIcon = new System.Windows.Forms.NotifyIcon
            {
                BalloonTipText  = "The app has been minimised. Click the tray icon to show.",
                BalloonTipTitle = "SyncML Viewer",
                Text            = "SyncML Viewer"
            };
            Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/;component/sync-icon.ico")).Stream;

            _notifyIcon.Icon           = new System.Drawing.Icon(iconStream);
            _notifyIcon.Click         += new EventHandler(NotifyIcon_Click);
            _notifyIconBallonShownOnce = false;

            SyncMlProgress = new SyncMlProgress();
            SyncMlSessions = new ObservableCollection <SyncMlSession>();

            _rs = RunspaceFactory.CreateRunspace();
            _rs.Open();

            _backgroundWorker = new BackgroundWorker
            {
                WorkerReportsProgress = true
            };
            _backgroundWorker.DoWork          += WorkerTraceEvents;
            _backgroundWorker.ProgressChanged += WorkerProgressChanged;
            _backgroundWorker.RunWorkerAsync();

            DataContext = this;

            this.Loaded += delegate { MenuItemCheckUpdate_OnClick(null, new RoutedEventArgs()); };

            ListBoxSessions.ItemsSource       = SyncMlSessions;
            ListBoxSessions.DisplayMemberPath = "Entry";

            ListBoxMessages.DisplayMemberPath = "Entry";

            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorStream);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorMessages);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorCodes);
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(TextEditorDiagnostics);
            _foldingManager  = FoldingManager.Install(TextEditorMessages.TextArea);
            _foldingStrategy = new XmlFoldingStrategy();
            _foldingStrategy.UpdateFoldings(_foldingManager, TextEditorMessages.Document);

            LabelDeviceName.Content = Environment.MachineName;
            _updateStarted          = false;
            _updateCheckInitial     = true;

            TextEditorStream.Options.HighlightCurrentLine   = true;
            TextEditorMessages.Options.HighlightCurrentLine = true;

            TextEditorCodes.Options.EnableHyperlinks = true;
            TextEditorCodes.Options.RequireControlModifierForHyperlinkClick = false;
            TextEditorCodes.Text = Properties.Resources.StatusCodes;

            TextEditorAbout.Options.EnableHyperlinks = true;
            TextEditorAbout.Options.RequireControlModifierForHyperlinkClick = false;
            TextEditorAbout.Text = Properties.Resources.About;

            TextEditorDiagnostics.Text +=
                $"Hostname:           {MdmDiagnostics.Hostname}\r\n" +
                $"OS Version:         {MdmDiagnostics.OsVersion} (x{MdmDiagnostics.Bits})\r\n" +
                $"Display Version:    {MdmDiagnostics.DisplayVersion}\r\n" +
                $"Version:            {MdmDiagnostics.Version}\r\n" +
                $"Current Build:      {MdmDiagnostics.CurrentBuild}.{MdmDiagnostics.BuildRevision}\r\n" +
                $"Release ID:         {MdmDiagnostics.ReleaseId}\r\n" +
                $"Build Branch:       {MdmDiagnostics.BuildBranch}\r\n" +
                $"Enrollment UPN:     {_mdmDiagnostics.Upn}\r\n" +
                $"AAD TenantID:       {_mdmDiagnostics.AadTenantId}\r\n" +
                $"OMA-DM AccountID:   {_mdmDiagnostics.OmaDmAccountId}";
        }