//Event handlers

        /**
         * Sets the mod description to a markdown formatted document
         */
        private void SetModDetails(object sender, SelectionChangedEventArgs e)
        {
            Mod mod = (Mod)((DataGrid)sender).SelectedItem;

            if (mod.LogoURL == "")
            {
                LogoImage.Source = (ImageSource) new ImageSourceConverter().ConvertFrom(Properties.Resources.NotFound);
            }
            else
            {
                LogoImage.Source = new BitmapImage(new Uri(mod.LogoURL));
            }

            DownloadButton.IsEnabled = true;

            //Source: https://github.com/Kryptos-FR/markdig.wpf/blob/master/src/Markdig.Xaml.SampleApp/MainWindow.xaml.cs#L36
            //Sets the mod details view with the markdown rendered content
            using MemoryStream stream =
                      new MemoryStream(Encoding.UTF8.GetBytes(
                                           Markdown.ToXaml(mod.FullDescription, new MarkdownPipelineBuilder().UseSupportedExtensions().Build())));
            using XamlXmlReader reader = new XamlXmlReader(stream, new XamlSchemaContext());
            if (XamlReader.Load(reader) is FlowDocument document)
            {
                ModDescription.Document = document;
            }
        }
示例#2
0
 private void AddThemeResource(List <Mubox.View.Themes.ThemeDescriptor> themesList, string themeName)
 {
     try
     {
         var uri          = new Uri("pack://siteoforigin:,,,/View/Themes/" + themeName + ".xaml", UriKind.Absolute);
         var resourceInfo = Application.GetRemoteStream(uri);
         var reader       = new System.Windows.Markup.XamlReader();
         ResourceDictionary resourceDictionary   = (ResourceDictionary)reader.LoadAsync(resourceInfo.Stream);
         Mubox.View.Themes.ThemeDescriptor theme = new Mubox.View.Themes.ThemeDescriptor
         {
             Name      = themeName,
             Resources = resourceDictionary
         };
         themesList.Add(theme);
         if (Mubox.Configuration.MuboxConfigSection.Default.PreferredTheme == themeName)
         {
             Application.Current.Resources.MergedDictionaries.Add(theme.Resources);
             comboThemeSelector.SelectedItem = theme;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         Debug.WriteLine(ex.StackTrace);
     }
 }
        private void SetThemeSource(Uri source, bool useThemeAccentColor)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            ResourceDictionary themeDict;

            if (source.IsAbsoluteUri && source.Scheme.StartsWith("pack"))
            {
                System.Windows.Resources.StreamResourceInfo info   = Application.GetRemoteStream(source);
                System.Windows.Markup.XamlReader            reader = new System.Windows.Markup.XamlReader();
                themeDict = (ResourceDictionary)reader.LoadAsync(info.Stream);
            }
            else
            {
                themeDict = new ResourceDictionary {
                    Source = source
                }
            };

            AddTheme(themeDict, useThemeAccentColor);

            OnPropertyChanged("ThemeSource");
        }
示例#4
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            string language      = UserSettings.PlayerConfig.HunterPie.Language.Split('\\').LastOrDefault().Replace(".xml", "");
            string changelogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Changelog\\changelog-{language}.md");

            if (!File.Exists(changelogPath))
            {
                changelogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Changelog\\changelog-en-us.md");
            }

            if (!File.Exists(changelogPath))
            {
                return;
            }

            var markdown = File.ReadAllText(changelogPath);
            var xaml     = Markdig.Wpf.Markdown.ToXaml(markdown, BuildPipeline());

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
            {
                using (var reader = new XamlXmlReader(stream, new MyXamlSchemaContext()))
                {
                    if (XamlReader.Load(reader) is FlowDocument document)
                    {
                        Viewer.Document = document;
                    }
                }
            }
        }
示例#5
0
        void LoadSkin()
        {
            if (ConfigHelper.Main.Values.Debug.UseInternalSkin)
            {
                return;
            }

            var skinFileName = ConfigHelper.Main.Values.SkinFileName;

            if (!File.Exists(FileContainer.GetFullPathFileName(skinFileName)))
            {
                Log.WriteLine($"Failed to load skin file '{skinFileName}'");
                return;
            }

            m_SkinFile.TryChangeFileName(skinFileName);

            try
            {
                ResourceDictionary resourceDictionary = null;

                using (var streamReader = new StreamReader(m_SkinFile.FullPathFileName, Encoding.UTF8))
                {
                    LoadExternalAssemblies();
                    var xmlReaderSettings = new XamlXmlReaderSettings
                    {
                        LocalAssembly = Assembly.GetExecutingAssembly()
                    };

                    using (var xamlReader = new XamlXmlReader(streamReader.BaseStream, XamlReader.GetWpfSchemaContext(), xmlReaderSettings))
                    {
                        resourceDictionary = XamlReader.Load(xamlReader) as ResourceDictionary;
                    }
                }

                if (resourceDictionary != null)
                {
                    Resources.MergedDictionaries.Clear();
                    Resources.MergedDictionaries.Add(resourceDictionary);

                    if (m_Overlay != null)
                    {
                        m_Overlay.RefreshWidgetsLayout();
                    }

                    Log.WriteLine($"{m_SkinFile.FileName} loaded");
                }
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
            }

            m_LastSkinFileName = skinFileName;
        }
示例#6
0
void Method4()
{
//<SnippetLoadAPageSOOFileManuallyCODE>
// Navigate to xaml page
Uri uri = new Uri("/SiteOfOriginFile.xaml", UriKind.Relative);
StreamResourceInfo info = Application.GetRemoteStream(uri);
System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
Page page = (Page)reader.LoadAsync(info.Stream);
this.pageFrame.Content = page;
//</SnippetLoadAPageSOOFileManuallyCODE>
}
示例#7
0
        private static ResourceDictionary LoadOrDefault(string path, int trial = 0, XamlObjectWriterException exception = null)
        {
            ResourceDictionary resource = null;

            try
            {
                if (!File.Exists(path))
                {
                    return(new ResourceDictionary());
                }

                if (exception != null)
                {
                    var content = File.ReadAllLines(path).ToList();
                    content.RemoveAt(exception.LineNumber - 1);

                    File.WriteAllLines(path, content);
                }

                using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    try
                    {
                        //Read in ResourceDictionary File
                        resource = (ResourceDictionary)XamlReader.Load(fs);
                    }
                    catch (XamlParseException xx)
                    {
                        if (xx.InnerException is XamlObjectWriterException inner && trial < 5)
                        {
                            return(LoadOrDefault(path, trial + 1, inner));
                        }

                        resource = new ResourceDictionary();
                    }
                    catch (Exception ex)
                    {
                        //Sets a default value if null.
                        resource = new ResourceDictionary();
                    }
                }

                //Tries to load the resource from disk.
                //resource = new ResourceDictionary {Source = new Uri(path, UriKind.RelativeOrAbsolute)};
            }
            catch (Exception)
            {
                //Sets a default value if null.
                resource = new ResourceDictionary();
            }

            return(resource);
        }
示例#8
0
        public static T Get <T>(string resourceName)
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var stream = assembly.GetManifestResourceStream("BusyBox.ResourceDictionary.xaml"))
            {
                var reader        = new System.Windows.Markup.XamlReader();
                var resDictionary = (ResourceDictionary)reader.LoadAsync(stream);

                return((T)resDictionary[resourceName]);
            }
        }
示例#9
0
        private void LoadInkCanvas(string inkFileName, List <string> filesName)
        {
            var fs          = File.Open(inkFileName, FileMode.Open, FileAccess.Read);
            var savedCanvas = XamlReader.Load(fs) as InkCanvas;

            fs.Close();
            if (savedCanvas != null)
            {
                DrawingSheet.Strokes.Add(savedCanvas.Strokes);
            }
            filesName.Remove(inkFileName);
        }
示例#10
0
        public void loadXamlTest()
        {
            var root    = Path.GetDirectoryName(typeof(XamlLoadTests).Assembly.Location);
            var dir     = Path.Combine(root, "test_files/xaml");
            var context = XamlReader.GetWpfSchemaContext();

            foreach (var q in Directory.EnumerateFiles(dir))
            {
                Logger.Info($"Loading XAML file {q}");
                var result      = XamlReader.Load(new FileStream(q, FileMode.Open));
                var xt          = context.GetXamlType(result.GetType());
                var logXamlType = new XamlTypeLogger(Logger);
            }
        }
示例#11
0
        private void OnTest(object sender, RoutedEventArgs e)
        {
            //object tree = XamlServices.Load("Demo1.xaml");
            //container1.Children.Add(tree as UIElement);
            FileStream stream = File.OpenRead("Demo1.xaml");
            object     tree   = XamlReader.Load(stream);

            var uiElement = tree as UIElement;

            if (uiElement != null)
            {
                Container1.Children.Add(uiElement);
            }
        }
 //function retranslator resource from uri
 public int add_res_dict(Uri _uri)
 {
     using (MemoryStream _tmpStream = new MemoryStream(Encoding.UTF8.GetBytes(_uri.ToString())))
     {
         System.Windows.Markup.XamlReader xaml_reader = new System.Windows.Markup.XamlReader();
         try
         {
             Dict_Res.MergedDictionaries.Add((ResourceDictionary)xaml_reader.LoadAsync(_tmpStream));
         }
         catch (Exception ex) { return(0); }
         this.Resources = Dict_Res;
     }
     return(1);
 }
示例#13
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var markdown = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "changelog.log"));
            var xaml     = Markdig.Wpf.Markdown.ToXaml(markdown, BuildPipeline());

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml))) {
                using (var reader = new XamlXmlReader(stream, new MyXamlSchemaContext())) {
                    if (XamlReader.Load(reader) is FlowDocument document)
                    {
                        Viewer.Document = document;
                    }
                }
            }
        }
示例#14
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var markdown = File.ReadAllText("Documents/Markdig-readme.md");
            var xaml     = Markdown.ToXaml(markdown, BuildPipeline());

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
            {
                var reader   = new XamlXmlReader(stream, new MyXamlSchemaContext());
                var document = XamlReader.Load(reader) as FlowDocument;
                if (document != null)
                {
                    Viewer.Document = document;
                }
            }
        }
示例#15
0
        public static FlowDocument ToDocument(string markdown)
        {
            string?xaml = Markdig.Wpf.Markdown.ToXaml(markdown, new MarkdownPipelineBuilder().UseSupportedExtensions().Build());

            using MemoryStream? stream  = new MemoryStream(Encoding.UTF8.GetBytes(xaml));
            using XamlXmlReader? reader = new XamlXmlReader(stream, new MyXamlSchemaContext());

            object?document = XamlReader.Load(reader);

            if (document is FlowDocument flowDoc)
            {
                return(flowDoc);
            }

            throw new Exception($"document: {document} was not a flow document");
        }
 private void about_click(object sender, RoutedEventArgs e)
 {
     if (About == null)
     {
         var tab  = uni_tab_creator("About", true);
         var grid = new WrapPanel();
         About = new ContentControl();
         Uri uri = new Uri(RCResourceLibs.vsresources.about, UriKind.Relative);                                              //get content of connector from uri
         ResourceDictionary dict_res = new ResourceDictionary();
         using (MemoryStream tmp_stream = new MemoryStream(Encoding.UTF8.GetBytes(uri.ToString())))                          //translate stream to xaml markup
         {
             System.Windows.Markup.XamlReader xaml_reader = new System.Windows.Markup.XamlReader();
             try
             {
                 dict_res.MergedDictionaries.Add((ResourceDictionary)xaml_reader.LoadAsync(tmp_stream));
             }
             catch (Exception ex) { }
             About.Resources = dict_res;
         }
         tab.Unloaded += delegate
         {
             About = null;
         };
         About.Loaded += delegate
         {
             Hyperlink link = (Hyperlink)About.Template.FindName("Link", About);
             link.RequestNavigate += delegate(object _sender, System.Windows.Navigation.RequestNavigateEventArgs _e)
             {
                 System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(_e.Uri.AbsoluteUri));
                 e.Handled = true;
             };
         };
         About.SetValue(Panel.ZIndexProperty, 110);
         grid.Children.Add(About);
         tab.Content = grid;
     }
     else
     {
         foreach (TabItem it in MainTab.Items)
         {
             if (it.Header == "About")
             {
                 MainTab.SelectedItem = it;
             }
         }
     }
 }
        private void ShowMarkdown()
        {
            string markdown = _mod.FullDescription;

            var xaml = Markdig.Wpf.Markdown.ToXaml(markdown, BuildPipeline());

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
            {
                using (var reader = new XamlXmlReader(stream, new MyXamlSchemaContext()))
                {
                    if (XamlReader.Load(reader) is FlowDocument document)
                    {
                        Viewer.Document = document;
                    }
                }
            }
        }
示例#18
0
        private FlowDocument GenerateDocument(string a_document)
        {
            if (string.IsNullOrEmpty(a_document))
            {
                return(null);
            }

            var xaml = Markdig.Wpf.Markdown.ToXaml(a_document, BuildPipeline());

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(xaml)))
            {
                var reader = new XamlXmlReader(stream, new MyXamlSchemaContext());

                var document = XamlReader.Load(reader) as FlowDocument;

                return(document);
            }
        }
示例#19
0
        private ResourceDictionary AddResources(FileInfo xamlFileInfo)
        {
            ResourceDictionary myResourceDictionary = null;

            try
            {
                Stream stream = File.OpenRead(xamlFileInfo.FullName);
                System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
                myResourceDictionary = (ResourceDictionary)reader.LoadAsync(stream);
                //Application.Current.Resources.MergedDictionaries.Add(myResourceDictionary);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format(Properties.Resources.ErrorImportMessage, xamlFileInfo.FullName,
                                              $"{e.Source} - {e.Message}"), Properties.Resources.ErrorImport, MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            return(myResourceDictionary);
        }
示例#20
0
            public static void show_connector(Panel target_panel)                                                                   //show connector into target_panel
            {
                Target_Panel = target_panel;
                VisualEffectsAndComponents.MainWindowVisualEffects.Curtain.curtain_fx(
                    Target_Panel,
                    System.Windows.Media.Brushes.White
                    );

                Cntr = new ContentControl();
                Uri uri = new Uri(RCResourceLibs.vsresources.connector, UriKind.Relative);                                          //get content of connector from uri
                ResourceDictionary dict_res = new ResourceDictionary();

                using (MemoryStream tmp_stream = new MemoryStream(Encoding.UTF8.GetBytes(uri.ToString())))                          //translate stream to xaml markup
                {
                    System.Windows.Markup.XamlReader xaml_reader = new System.Windows.Markup.XamlReader();
                    try
                    {
                        dict_res.MergedDictionaries.Add((ResourceDictionary)xaml_reader.LoadAsync(tmp_stream));
                    }
                    catch (Exception ex) { }
                    Cntr.Resources = dict_res;
                }

                Cntr.SetValue(Panel.ZIndexProperty, 100);
                Target_Panel.Children.Add(Cntr);
                Grid.SetRow(Cntr, 0);
                Cntr.Margin = new Thickness(
                    ((Target_Panel.ActualWidth / 2) - (Cntr.Width / 2)),
                    ((Target_Panel.ActualHeight / 2) - (Cntr.Height / 2)),
                    0,
                    0);
                XPorter.Bus.Main_Handle.MainMenu.IsEnabled = false;
                XPorter.Bus.Main_Handle.Sidebar.IsEnabled  = false;
                XPorter.Bus.Inner_Height = Target_Panel.ActualHeight - Cntr.Height - 1;
                XPorter.Bus.Inner_Width  = Target_Panel.ActualWidth - Cntr.Width;
                VisualEffectsAndComponents.MainWindowVisualEffects.Curtain.Load_Curtain.IsHitTestVisible = false;

                VisualEffectsAndComponents.Connector.Cntr.Unloaded += delegate(object _object, RoutedEventArgs _e)
                {
                    Target_Panel.Children.Remove(VisualEffectsAndComponents.MainWindowVisualEffects.Curtain.Load_Curtain);          //delete curtain fx after destroying
                    VisualEffectsAndComponents.MainWindowVisualEffects.Curtain.Load_Curtain = null;
                    if (VisualEffectsAndComponents.Connector.Cntr != null)
                    {
                        VisualEffectsAndComponents.Connector.Cntr = null;
                    }
                    Target_Panel.SizeChanged -= target_panel_resize;
                };

                Cntr.Loaded += delegate(object s, RoutedEventArgs ee)
                {
                    var element = ((FrameworkElement)Cntr.Template.FindName("DockHeader", Cntr));
                    element.MouseLeftButtonDown += dock_panel_prev_mouse_down;                                                      //add listener functions for move
                    element.MouseLeftButtonUp   += dock_panel_Prev_mouse_up;
                    element.MouseMove           += dock_panel_prev_mouse_move;
                    ((Button)Cntr.Template.FindName("Cancel", Cntr)).Click  += cn_cancel_click;                           //destroy form button
                    ((Button)Cntr.Template.FindName("Connect", Cntr)).Click += cn_connect_click;
                    Target_Panel.SizeChanged += target_panel_resize;
                    Old_Height = Target_Panel.ActualHeight - Cntr.ActualHeight;
                    Old_Width  = Target_Panel.ActualWidth - Cntr.ActualWidth;
                };
            }
示例#21
0
        static ResultCode ParseLanguages()
        {
            var languagePath = GetPath("Languages");

            if (languagePath != "" && Directory.Exists(languagePath))
            {
                var   langFiles = Directory.GetFiles(languagePath, "*.xaml");
                float count     = langFiles.Length;
                var   done      = 0f;

                foreach (var langFile in langFiles)
                {
                    var imageFile = Path.GetFullPath(languagePath + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(langFile) + ".png");
                    try
                    {
                        var fs  = new FileStream(langFile, FileMode.Open);
                        var dlc = (ResourceDictionary)XamlReader.Load(fs);

                        var language = new Language(dlc, imageFile);
                        if (language.Key == "")
                        {
                            Debug.Log("Configuration", "The language file \"" + langFile + "\" could not be parsed. The LangCode Key is missing.", Debug.Type.Warning);
                        }
                        else
                        {
                            var langKey = language.Key.ToLower();
                            if (!Languages.ContainsKey(langKey))
                            {
                                Languages.Add(langKey, language);
                                Debug.Log("Configuration", "Loaded language \"" + language.Key + "\" successfully.");
                            }
                            else
                            {
                                Debug.Log("Configuration", "The language \"" + language.Key + "\" exists more than once.", Debug.Type.Warning);
                            }
                        }
                    }
                    catch (XamlException e)
                    {
                        Debug.Log("Configuration", "The language file \"" + langFile + "\" could not be parsed. Exception: " + e, Debug.Type.Warning);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("Configuration", "The language file \"" + langFile + "\" could not be parsed. Unexpected exception: " + e, Debug.Type.Warning);
                    }
                    done += 1f;
                    ChangeProgress(50f + (done / count) * 40f);
                }
            }
            else
            {
                Error       = ErrorCode.MalformedConfiguration;
                ErrorString = "Could not find the languages path.";
                Debug.Log("Configuration", ErrorString, Debug.Type.Error);
                return(ResultCode.ERROR);
            }

            Debug.Log("Configuration", Languages.Count + " languages parsed successfully.");
            var ci            = CultureInfo.InstalledUICulture;
            var systemLangKey = ci.TwoLetterISOLanguageName.ToLower();

            if (GetString("Language") != "" && Languages.ContainsKey(GetString("Language")))
            {
                ChangeLanguage(GetString("Language"));
            }
            else if (Languages.ContainsKey(systemLangKey))
            {
                ChangeLanguage(systemLangKey);
            }
            else if (Languages.ContainsKey("en"))
            {
                ChangeLanguage("en");
            }
            else if (Languages.Count > 0)
            {
                ChangeLanguage(Languages.Keys.ToArray()[0]);
            }
            else
            {
                Debug.Log("Configuration", "No suitable language found.", Debug.Type.Warning);
            }

            return(ResultCode.Ok);
        }
示例#22
0
        internal FormPage(InformeResponse data, IEnumerable <LabeledImage> imgs, Size pgSize, Language language, bool useDpi = true)
        {
            InitializeComponent();

            if (data is null || data.serial == 0)
            {
                throw new ArgumentNullException();
            }

            _fltImages = (Floater)FindResource("FltImages");
            Lang       = language;
            switch (Lang)
            {
            case FormRender.Language.Spanish:
                LblTit.Text  = "Reporte de Histopatología";
                LblPac.Text  = "Paciente:";
                LblMed.Text  = "Médico:";
                LblAddr.Text = "Dirección:";
                LblDiag.Text = "Diag. Clínico:";
                LblMat.Text  = "Material Estudiado:";
                LblAge.Text  = "Edad:";
                LblSex.Text  = "  Género:";
                LblDte.Text  = "Fecha:";
                LblRec.Text  = "Recibido:";
                LblNb.Text   = "No. biopsia:";
                LblInf.Text  = "INFORME";
                LblIDt.Text  = "Fecha de informe:";
                _lblPg       = "Página";

                TxtFecha.Text    = data.fecha_biopcia?.ToString("dd/MM/yyyy") ?? string.Empty;
                TxtRecv.Text     = data.fecha_muestra?.ToString("dd/MM/yyyy") ?? string.Empty;
                TxtFechaInf.Text = data.fecha_informe?.ToString("dd/MM/yyyy") ?? string.Empty;

                break;

            case FormRender.Language.English:
                var ci = CultureInfo.CreateSpecificCulture("en-us");

                LblTit.Text  = "Histopathology Report";
                LblPac.Text  = "Patient:";
                LblMed.Text  = "Dr:";
                LblAddr.Text = "Address:";
                LblDiag.Text = "Clinical Diagnosis:";
                LblMat.Text  = "Specimen:";
                LblAge.Text  = "Age:";
                LblSex.Text  = "  Gender:";
                LblDte.Text  = "Date:";
                LblRec.Text  = "Received:";
                LblNb.Text   = "Biopsy N.:";
                LblInf.Text  = "REPORT";
                LblIDt.Text  = "Report date:";
                _lblPg       = "Page";

                TxtFecha.Text    = data.fecha_biopcia?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;
                TxtRecv.Text     = data.fecha_muestra?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;
                TxtFechaInf.Text = data.fecha_informe?.ToString("MMMM dd, yyyy", ci.DateTimeFormat) ?? string.Empty;

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Data = data;
            var labeledImages = imgs.ToList();

            Imgs = labeledImages;

            //Llenar header...
            TxtPaciente.Text  = data.facturas.nombre_completo_cliente;
            TxtMedico.Text    = data.facturas.medico;
            TxtDireccion.Text = data.facturas.direccion_entrega_sede;
            TxtDiag.Text      = data.diagnostico;
            TxtEstudiado.Text = data.muestra;
            TxtEdad.Text      = data.facturas.edad;
            TxtSexo.Text      = data.facturas.sexo;

            TxtBiop.Text    = $"{data.serial ?? 0} - {data.fecha_muestra?.Year.ToString() ?? "N/A"}";
            TxtFactNum.Text = $"C.I. {data.factura_id}";

            // Parsear y extraer texto desde html...
            var oo = XA.Parse(HTC.ConvertHtmlToXaml(data.informe, true)) as FlowDocument;

            while (oo?.Blocks.Any() ?? false)
            {
                oo.Blocks.FirstBlock.FontFamily = (FontFamily)FindResource("FntFmly");
                oo.Blocks.FirstBlock.FontSize   = (double)FindResource("FntSze");
                DocRoot.Blocks.Add(oo.Blocks.FirstBlock);
            }

            if (labeledImages.Any())
            {
                var fb = (Paragraph)DocRoot.Blocks.FirstBlock;
                fb.Inlines.InsertBefore(fb.Inlines.FirstInline, _fltImages);
            }

            _pageSize = pgSize;
            _ctrlSize = useDpi ? new Size(_pageSize.Width * UI.GetXDpi(), _pageSize.Height * UI.GetYDpi()) : pgSize;

            Rsze();

            foreach (var j in labeledImages)
            {
                GetImg(j);
            }
            switch (data.images.Length)
            {
            case 0:
            case 1: break;

            default:
                if (_imgAdjust > DocSize - GrdHead.ActualHeight)
                {
                    _fltImages.Width = 230 * ((DocSize) - GrdHead.ActualHeight) / _imgAdjust;
                }
                break;
            }

            RootContent.Width  = _ctrlSize.Width;
            RootContent.Height = _ctrlSize.Height;
            UpdateLayout();

            _firma             = data.firma;
            _firma2            = data.firma2;
            DocRoot.PageHeight =
                ActualHeight
                - ImgHeader.ActualHeight
                - GrdHead.ActualHeight
                - GrdFooter.ActualHeight
                - LblTit.ActualHeight
                - LblInf.ActualHeight
                - 25
                - GrdPager.ActualHeight;
        }
        private void show_settings(object sender, RoutedEventArgs e)
        {
            if (Settings == null)
            {
                Settings = new ContentControl();
                var tab  = uni_tab_creator("Settings", true);
                var grid = new Grid();
                grid.Background = System.Windows.Media.Brushes.AliceBlue;
                Uri _uri = new Uri(RCResourceLibs.vsresources.settings_style, UriKind.Relative);
                ResourceDictionary local_dict = new ResourceDictionary();
                using (MemoryStream tmp_stream = new MemoryStream(Encoding.UTF8.GetBytes(_uri.ToString())))
                {
                    System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
                    try
                    {
                        local_dict.MergedDictionaries.Add((ResourceDictionary)reader.LoadAsync(tmp_stream));
                        Settings.Resources = local_dict;
                    }
                    catch (Exception ex) { }
                }
                Uri uri = new Uri(RCResourceLibs.vsresources.win_settings, UriKind.Relative);
                //ResourceDictionary dict_res = new ResourceDictionary();
                using (MemoryStream tmp_stream = new MemoryStream(Encoding.UTF8.GetBytes(uri.ToString())))
                {
                    System.Windows.Markup.XamlReader xaml_reader = new System.Windows.Markup.XamlReader();
                    try
                    {
                        local_dict.MergedDictionaries.Add((ResourceDictionary)xaml_reader.LoadAsync(tmp_stream));
                    }
                    catch (Exception ex) { }
                    Settings.Resources = local_dict;
                    Settings.SetValue(Panel.ZIndexProperty, 110);
                    grid.Children.Add(Settings);
                    tab.Content = grid;
                }
                tab.Loaded += delegate
                {
                    ((TabItem)Settings.Template.FindName("General", Settings)).PreviewMouseLeftButtonDown       += label_click;
                    ((TabItem)Settings.Template.FindName("Sounds", Settings)).PreviewMouseLeftButtonDown        += label_click;
                    ((TabItem)Settings.Template.FindName("Video", Settings)).PreviewMouseLeftButtonDown         += label_click;
                    ((TabItem)Settings.Template.FindName("Privacy", Settings)).PreviewMouseLeftButtonDown       += label_click;
                    ((TabItem)Settings.Template.FindName("Notifications", Settings)).PreviewMouseLeftButtonDown += label_click;
                    ((TabItem)Settings.Template.FindName("Advanced", Settings)).PreviewMouseLeftButtonDown      += label_click;
                    TabSettings = (TabControl)Settings.Template.FindName("Settings", Settings);

                    ((Button)Settings.Template.FindName("Default_General1", Settings)).Click += delegate
                    {
                        RCConnectLibrary.set_default_settings();
                        //refresh all settings values
                    };
                    ((Button)Settings.Template.FindName("Default_General2", Settings)).Click += delegate
                    {
                        RCConnectLibrary.set_default_settings();
                        //refresh all settings values
                    };

                    ((Button)Settings.Template.FindName("Apply_General1", Settings)).Click += delegate
                    {
                        GlobalTypes.Settings.IPCatalog.Clear();
                        GlobalTypes.Settings.IPCatalog.Add(new GlobalTypes.IPInterval(
                                                               ((TextBox)Settings.Template.FindName("Left_Range_Ip", Settings)).Text, ((TextBox)Settings.Template.FindName("Left_Range_Ip", Settings)).Text
                                                               ));
                        if (((PasswordBox)Settings.Template.FindName("Password", Settings)).Password == ((PasswordBox)Settings.Template.FindName("Confirm_Password", Settings)).Password)
                        {
                            StatusBarText.Text            = "Password Accepted";
                            GlobalTypes.Settings.Password = ((PasswordBox)Settings.Template.FindName("Password", Settings)).Password;
                        }
                        else
                        {
                            StatusBarText.Text = "Passwords doesn't equals";
                        }
                        GlobalTypes.Settings.TabHeader = ((ComboBoxItem)((ComboBox)Settings.Template.FindName("Host_Name_Format", Settings)).SelectedItem).Content.ToString();
                    };
                    ((Button)Settings.Template.FindName("Apply_General2", Settings)).Click += delegate
                    {
                        GlobalTypes.Settings.TCPPort       = Convert.ToInt32(((TextBox)Settings.Template.FindName("TCP_Port", Settings)).Text);
                        GlobalTypes.Settings.Interval      = Convert.ToInt32(((Slider)Settings.Template.FindName("Refresh_Period", Settings)).Value);
                        GlobalTypes.Settings.TimeToConnect = Convert.ToInt32(((TextBox)Settings.Template.FindName("Connection_Timeout", Settings)).Text);
                        GlobalTypes.Settings.ThreadCount   = Convert.ToInt32(((Slider)Settings.Template.FindName("Thread_Count", Settings)).Value);
                    };
                };
                tab.Unloaded += delegate
                {
                    Settings = null;
                };
            }
            else
            {
                foreach (TabItem it in MainTab.Items)
                {
                    if (it.Header == "Settings")
                    {
                        MainTab.SelectedItem = it;
                    }
                }
            }
        }
        private static GridViewColumn CreateColumn(GridView gridView, ColumnDescriptor columnSource)
        {
            GridViewColumn column = new();

            string       headerTextMember    = GetHeaderTextMember(gridView);
            string       displayMemberMember = GetDisplayMemberMember(gridView);
            bool         checkbox            = columnSource.CheckboxMember;
            string       styleString         = GetColumnHeadStyleName(gridView);
            DataTemplate cellStyleTemplate   = GetColumnCellTemplate(gridView);

            column.Width = 90;
            if (!string.IsNullOrEmpty(headerTextMember))
            {
                column.Header = GetPropertyValue(columnSource, headerTextMember);
            }

            if (!string.IsNullOrEmpty(displayMemberMember) && !checkbox)
            {
                var propertyName = GetPropertyValue(columnSource, displayMemberMember) as string;
                var binding      = new Binding(propertyName);
                if (columnSource.OneTime)
                {
                    binding.Mode = BindingMode.OneTime;
                }

                if (cellStyleTemplate != null)
                {
                    column.CellTemplate = CreateCellTemplate(cellStyleTemplate, binding);
                }
                else
                {
                    column.DisplayMemberBinding = binding;
                }
            }
            else if (checkbox)
            {
                var          propertyName = GetPropertyValue(columnSource, displayMemberMember) as string;
                StringReader stringReader = new(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> 
                    <CheckBox IsChecked=""{Binding " + propertyName + @"}""/> 
                    </DataTemplate>");
                XmlReader    xmlReader = XmlReader.Create(stringReader);
                column.CellTemplate = XamlReader.Load(xmlReader) as DataTemplate;
                column.Width        = 24;
            }

            if (!string.IsNullOrEmpty(styleString))
            {
                Style style = Application.Current.FindResource(styleString) as Style;
                if (style != null)
                {
                    column.HeaderContainerStyle = style;
                }
            }

            if (columnSource.PreferredWidth.HasValue)
            {
                column.Width = columnSource.PreferredWidth.Value;
            }
            else
            {
                // Set Widht to NaN in order to stretch it to match conent
                column.Width = double.NaN;
            }

            return(column);
        }
示例#25
0
 private void AddThemeResource(List<Mubox.View.Themes.ThemeDescriptor> themesList, string themeName)
 {
     try
     {
         var uri = new Uri("pack://siteoforigin:,,,/View/Themes/" + themeName + ".xaml", UriKind.Absolute);
         var resourceInfo = Application.GetRemoteStream(uri);
         var reader = new System.Windows.Markup.XamlReader();
         ResourceDictionary resourceDictionary = (ResourceDictionary)reader.LoadAsync(resourceInfo.Stream);
         Mubox.View.Themes.ThemeDescriptor theme = new Mubox.View.Themes.ThemeDescriptor
         {
             Name = themeName,
             Resources = resourceDictionary
         };
         themesList.Add(theme);
         if (Mubox.Configuration.MuboxConfigSection.Default.PreferredTheme == themeName)
         {
             Application.Current.Resources.MergedDictionaries.Add(theme.Resources);
             comboThemeSelector.SelectedItem = theme;
         }
     }
     catch (Exception ex)
     {
         ex.Log();
     }
 }