public void SelectDocumentationItem(DocumentationItemVm itemToSelect)
        {
            foreach (var item in this.DocumentationItems)
            {
                if (item.ExpandButtonVisibility == Visibility.Visible)
                {
                    item.IsExpanded = false;
                }
            }

            foreach (var item in this.DocumentationItems)
            {
                if (Equals(item, itemToSelect))
                {
                    item.IsExpanded = true;
                    return;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DocumentationVm" /> class.
        /// </summary>
        public DocumentationVm()
        {
            this.DocumentationItems = new ObservableCollection <DocumentationItemVm>();

            // ReSharper disable LocalizableElement
            this.DocumentationItems.Add(new DocumentationItemVm(this, @"HART", @"FXA195", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, @"/EH.ImsOpcBridge.Configurator.Wpf;component/Resources/TestPic.jpg", 618, false, @"HART"));

            var item = new DocumentationItemVm(this, @"PROFIBUS", @"USB or PCMCIA", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, @"/EH.ImsOpcBridge.Configurator.Wpf;component/Resources/TestPic.jpg", 618, true, @"PROFIBUS");

            item.IsExpanded = true;

            this.DocumentationItems.Add(item);
            this.DocumentationItems.Add(new DocumentationItemVm(this, null, @"Your Benefits", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, null, 0, true, @"Your Benefits"));
            this.DocumentationItems.Add(new DocumentationItemVm(this, @"Foundation Fieldbus", @"USB or PCMCIA", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, @"/EH.ImsOpcBridge.Configurator.Wpf;component/Resources/TestPic.jpg", 618, true, @"Foundation Fieldbus"));
            this.DocumentationItems.Add(new DocumentationItemVm(this, @"CDI", @"FXA291, Ethernet, USB", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, @"/EH.ImsOpcBridge.Configurator.Wpf;component/Resources/TestPic.jpg", 618, true, @"CDI"));
            this.DocumentationItems.Add(new DocumentationItemVm(this, @"Service Interfaces", @"IPC, ISS, PCP", @"EH.ImsOpcBridge.Configurator.Resources.Documents.TestDocument.xaml", 200, @"/EH.ImsOpcBridge.Configurator.Wpf;component/Resources/TestPic.jpg", 618, true, @"Service Interfaces"));

            // ReSharper restore LocalizableElement
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HowToUseVm"/> class.
        /// </summary>
        /// <param name="mainWindowVm">The main window vm.</param>
        /// <exception cref="System.ArgumentNullException">@ mainWindowVm</exception>
        public HowToUseVm(MainWindowVm mainWindowVm)
        {
            if (mainWindowVm == null)
            {
                throw new ArgumentNullException(@"mainWindowVm");
            }

            this.Choice = new BaseSelectorControlViewModel();
            this.Choice.SelectedItemChanged += this.ChoiceSelectedItemChangedHandler;

            this.Choice.Items.Add(new BaseSelectorItemViewModel(Resources.HowToUseCommandManual, string.Empty, string.Empty, "automId_Manual", HowToUsePage.Manual, 1));
            this.Choice.Items.Add(new BaseSelectorItemViewModel(Resources.HowToUseCommandAbout, string.Empty, string.Empty, "automId_About", HowToUsePage.About, 2));

            // About documentation view model
            this.AboutDocumentationViewModel = new DocumentationVm(0);

            var documentationItem = new DocumentationItemVm(this.AboutDocumentationViewModel, Resources.Imprint, Resources.EndressHauser, @"EH.ImsOpcBridge.Configurator.Resources.Documents.HowToUseAboutImprintDocument.xaml", 230, null, 0, true, @"Imprint");

            documentationItem.IsExpanded = false;
            this.AboutDocumentationViewModel.DocumentationItems.Add(documentationItem);

            documentationItem            = new DocumentationItemVm(this.AboutDocumentationViewModel, Resources.OpenSource, Resources.OpenSourceSoftware, @"EH.ImsOpcBridge.Configurator.Resources.Documents.HowToUseAboutOpenSourceDocument.xaml", 100, null, 0, true, @"OpenSource");
            documentationItem.IsExpanded = false;

            var link = documentationItem.Document.FindName(@"LoggingServices") as Hyperlink;

            if (link != null)
            {
                link.RequestNavigate += this.HyperlinkRequestNavigate;
            }

            link = documentationItem.Document.FindName(@"ZIPComponent") as Hyperlink;

            if (link != null)
            {
                link.RequestNavigate += this.HyperlinkRequestNavigate;
            }

            this.AboutDocumentationViewModel.DocumentationItems.Add(documentationItem);

            using (var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"EH.ImsOpcBridge.Configurator.Resources.Documents.HowToUseAboutVersionDocument.xaml"))
            {
                if (resourceStream != null)
                {
                    var flowDocument = XamlReader.Load(resourceStream) as FlowDocument;

                    if (flowDocument != null)
                    {
                        var stringBuiler = new StringBuilder();
                        var firstItem    = true;

                        // ReSharper disable LocalizableElement
                        var sortedQuery = from item in AssemblyManagement.LoadedAssemblies orderby item.Name select item;
                        foreach (var assemblyInformation in sortedQuery.ToArray())
                        {
                            if (!firstItem)
                            {
                                stringBuiler.Append(@", ");
                            }

                            stringBuiler.Append(assemblyInformation.Name);
                            stringBuiler.Append(@"[");
                            stringBuiler.Append(assemblyInformation.Version);
                            stringBuiler.Append(@"]");
                            firstItem = false;
                        }

                        // ReSharper restore LocalizableElement
                        var paragraph = new Paragraph(new Run(stringBuiler.ToString()));
                        paragraph.TextAlignment = TextAlignment.Left;
                        flowDocument.Blocks.Add(paragraph);

                        documentationItem            = new DocumentationItemVm(this.AboutDocumentationViewModel, Resources.Version, Assembly.GetEntryAssembly().GetName().Version.ToString(), flowDocument, 200, null, 0, true, @"Version");
                        documentationItem.IsExpanded = false;
                        this.AboutDocumentationViewModel.DocumentationItems.Add(documentationItem);
                    }
                }
            }

            // Manual documentation view model
            this.ManualDocumentationViewModel = new DocumentationVm(0);

            documentationItem            = new DocumentationItemVm(this.ManualDocumentationViewModel, Resources.HowToUseCommandManual, Resources.ViewManual, @"EH.ImsOpcBridge.Configurator.Resources.Documents.HowToUseAboutManualDocument.xaml", 100, null, 0, true, @"OpenSource");
            documentationItem.IsExpanded = true;

            var helpFolder   = Path.Combine(this.AssemblyDirectory, Constants.HelpFolder);
            var languageName = Thread.CurrentThread.CurrentUICulture;

            helpFolder = Path.Combine(helpFolder, languageName.ToString());
            var manualPath = string.Empty;

            if (Directory.Exists(helpFolder))
            {
                var files = Directory.GetFiles(helpFolder, Constants.ManualFileNameExtension);
                if (files.Length > 0)
                {
                    manualPath = files[0];
                }
            }

            link = documentationItem.Document.FindName(@"Manual") as Hyperlink;

            if (link != null)
            {
                if (File.Exists(manualPath))
                {
                    var uri = new Uri(manualPath);
                    link.NavigateUri      = uri;
                    link.IsEnabled        = true;
                    link.RequestNavigate += this.HyperlinkRequestNavigateManual;
                }
                else
                {
                    link.IsEnabled = false;
                }
            }

            this.ManualDocumentationViewModel.DocumentationItems.Add(documentationItem);

            this.Choice.SelectItem(HowToUsePage.Manual);
            this.SettingsViewModel = mainWindowVm.SettingsViewModel;

            this.contactSupportCommand = new DelegateCommand(this.ContactSupportPressed);
        }