דילוג לתוכן
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום
כיווץ
תחומים

תחומים - פורום חרדי מקצועי

💡 רוצה לזכור קריאת שמע בזמן? לחץ כאן!
pcinfogmachP

pcinfogmach

@pcinfogmach
אודות
פוסטים
773
נושאים
196
שיתופים
0
קבוצות
0
עוקבים
3
עוקב אחרי
1

פוסטים

פוסטים אחרונים הגבוה ביותר שנוי במחלוקת

  • מדריך: איך לייצר לוקליזציה ב-wpf בצורה פשוטה וקלילה
    pcinfogmachP pcinfogmach

    פתרון פשוט וקליל ללוקליזציה באפליקציות WPF

    (הקוד נמצא בסוף הכתבה)

    קראתי הרבה מדריכים בנושא לוקליזציה ונתקלתי בהרבה ספריות מתקדמות ומורכבות. בסופו של דבר, רוב הפתרונות הללו הופכים את ניהול התרגום למשימה מסובכת, במיוחד כאשר יש צורך לבצע תרגום מחדש או להוסיף שפות חדשות בשלב מאוחר יותר.

    לאחר שחיפשתי פתרון פשוט ויעיל, הגעתי לגישה הבאה. יש לציין כי פתרון זה מתאים בעיקר לאפליקציות קטנות ובינוניות, מאחר שהוא טוען את כל המידע לזיכרון בבת אחת. עבור אפליקציות גדולות, המצריכות פתרון מתוחכם יותר, כמו שימוש במסד נתונים, פתרון זה לא יתאים. (ייתכן שיישום Dictionary מסוג חסכוני יותר בזכרון יפתור את הבעיה ללא צורך במסד, אבל לא בדקתי את זה)

    למעשה, עבור יישומים שאינם דורשים מורכבות כזו, גישה זו יכולה לחסוך הרבה זמן ומאמץ.

    השלבים לבניית הפתרון:
    א. שימוש בקובץ JSON
    קובץ JSON מאפשר לנו לנהל ולערוך את כל המחרוזות של האפליקציה בצורה מסודרת ונוחה. המפתח (Key) מייצג את שם הפריט, והערך (Value) מייצג את המחרוזת המתורגמת.
    עבור כל שפה נייצר קובץ נפרד עם הקידומת של השפה בתוך התיקייה הייעודית (בקוד להלן אני בחרתי "Asstes//Locale").
    הקידומת תהיה בת שני אותיות בלבד ובאותיות קטנות למשל "he" או "en".
    שימו לב! בקוד שכתבתי שפת המערכת מזוהה באופן אוטומטי ייתכן וגישה זו איננה מתאימה לכם.
    ב. שימוש במבנה Dictionary סטטי
    אנו נטען את תוכן ה-JSON לקובץ זיכרון באמצעות מילון (Dictionary) סטטי, שיהיה זמין לכל רכיבי האפליקציה.
    ג. שימוש ב-Markup Extension
    ניצור הרחבה מותאמת אישית (Markup Extension) שתאפשר לנו לגשת למחרוזות מתוך ה-JSON ישירות מתוך ה-XAML. (כמו"כ נוכל לצפות בתוצאות בתצוגה המקדימה של עורך ה-Xaml).

    דגשים חשובים לניהול הפתרון:

    • שמות זהים לשמות הפקדים: הקפידו על כך ששמות המפתחות ב-JSON יהיו זהים לשמות הפקדים שאותם הם מתארים. כך, תוכלו לשמור על עקביות ולמנוע טעויות.

    • מבנה עם תיאור ברור: הוסיפו תיאור לכל מפתח בקובץ ה-JSON, כך שיהיה קל להבין מה הוא מייצג. מומלץ לצורך זה להשתמש בתיאורים המובנים של WPF. לדוגמה:

    {
        "Tooltip.MinimizeButton": "Minimize",
        "Tooltip.CloseButton": "Close",
        "Title.MainWindowTitle": "My Application"
    }
    

    העיקרון הזה יקל עליכם גם בכתיבת ה-JSON וגם בייחוס המפתחות ישירות מתוך ה-XAML.
    סדר אלפא ביתי של המפתחות ייקל על עריכת שינויים והתמצאות כללית ב-JSON.

    להלן הקוד:

    using System.Globalization;
    using System.IO;
    using System.Text.Json;
    using System.Text.RegularExpressions;
    using System.Windows;
    using System.Windows.Markup;
    
    namespace Assets.Locale
    {
     public class LocalizedStringExtension : MarkupExtension
     {
         public string Key { get; set; }
    
         public LocalizedStringExtension() { }
         public LocalizedStringExtension(string key) { Key = key; }
    
         public override object ProvideValue(IServiceProvider serviceProvider)
         {
             if (string.IsNullOrEmpty(Key)) return "[Missing Key]"; 
             else  return LocaleHelper.LocaleDictionary.TryGetValue(Key, out var value) ? value : $"[{Key}]";
         }
     }
    
        public static class LocaleHelper
        {
            private static readonly string LocaleDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "Locale");
            private static string LocalePath =>
                Path.Combine(LocaleDir, $"{CultureInfo.CurrentCulture.TwoLetterISOLanguageName}.json") is string path && File.Exists(path)
                    ? path
                    : Path.Combine(LocaleDir, "en.json");
    
            private static Dictionary<string, string>? _localeDictionary;
            public static Dictionary<string, string> LocaleDictionary => _localeDictionary ??= LoadLocaleDictionary();
    
            private static Dictionary<string, string> LoadLocaleDictionary()
            {
                if (!File.Exists(LocalePath))
                    return new Dictionary<string, string>();
    
                try
                {
                    string json = File.ReadAllText(LocalePath);
                    return JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? new Dictionary<string, string>();
                }
                catch
                {
                    // Return an empty dictionary if reading or deserialization fails
                    return new Dictionary<string, string>();
                }
            }
        }
    }
    
    

    ובתוך ה-xaml יש להוסיף

     xmlns:locale="clr-namespace:Assets.Locale"
    

    ואז תוכלו למשל לעשות כך

      <Button x:Name="MinimizeButton"
      ToolTip="{locale:LocalizedString Key='Tooltip.MinimizeButton'}">
    
    תכנות

  • תורת אמת בוורד - עכשיו בvsto
    pcinfogmachP pcinfogmach

    @שימילה
    תשלח לי מייל אני קצת עמוס מקווה שאתפנה לזה
    לבינתיים תשאל כאן

    אולי תקבל תשובה יותר טובה

    תוכנה

  • תורת אמת בוורד - עכשיו בvsto
    pcinfogmachP pcinfogmach

    @שימילה
    ניסית להתקין על ידי קובץ הVSTO או על ידי-SETUP
    האם הסרת חסימה אינטרנטית מהקובץ
    האם סגרת את וורד לפני ההתקנה

    כמו"כ מומלץ להוריד את הגירסה המעודכנת
    https://mitmachim.top/topic/68192/להורדה-תורת-אמת-בוורד-גרסה-3?_=1732199524654

    תוכנה

  • עיצוב מודרני עבור ScrollBar ב- Wpf
    pcinfogmachP pcinfogmach

    מצו"ב הקוד (מתאים במיוחד עבור DarkTheme)
    b7e2b204-9a70-4b9a-b3f4-bd461ed4d20f-image.png

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:system="clr-namespace:System;assembly=mscorlib">
    
        <system:Double x:Key="ScrollBarWidth">16</system:Double>
        <system:Double x:Key="ScrollBarArrowHeight">4</system:Double>
        <system:Double x:Key="ScrollBarArrowWidth">8</system:Double>
    
        <SolidColorBrush x:Key="ScrollBarButtonBackgroundBrush" Color="#888888" Opacity="0.4" />
        <SolidColorBrush x:Key="ScrollBarButtonHighlightBackgroundBrush" Color="#B0B0B0" Opacity="0.4" />
    
        <Style TargetType="{x:Type ScrollBar}">
            <Setter Property="Foreground" Value="#FF999999"/>
            <Style.Triggers>
                <Trigger Property="Orientation" Value="Vertical">
                    <Setter Property="Width" Value="{StaticResource ScrollBarWidth}"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ScrollBar}">
                                <Border BorderThickness="1">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="#888888" Opacity="0.6"/>
                                    </Border.BorderBrush>
                                    <Border.Background>
                                        <SolidColorBrush Color="#888888" Opacity="0.1"/>
                                    </Border.Background>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
    
                                        <Button Grid.Row="0"
                                            Command="ScrollBar.LineUpCommand"
                                            Height="{StaticResource ScrollBarWidth}">
                                            <Button.Template>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid>
                                                        <Rectangle x:Name="ButtonRectangle" 
                                                               Fill="Transparent"/>
                                                        <Path x:Name="ButtonPath" HorizontalAlignment="Center"
                                                          VerticalAlignment="Center"
                                                          Data="M 0 10 L 10 10 L 5 0 Z" 
                                                          Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollBar}}"
                                                          Stretch="Fill"
                                                          Height="{StaticResource ScrollBarArrowHeight}"
                                                          Width="{StaticResource ScrollBarArrowWidth}" />
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ButtonRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Button.Template>
                                        </Button>
    
                                        <Track Name="PART_Track" IsDirectionReversed="True" VerticalAlignment="Stretch" Grid.Row="1">
                                            <Track.DecreaseRepeatButton>
                                                <RepeatButton Command="ScrollBar.PageUpCommand"
                                                          Background="Transparent">
                                                    <RepeatButton.Template>
                                                        <ControlTemplate TargetType="RepeatButton">
                                                            <Rectangle Fill="{TemplateBinding Background}" 
                                                                   Height="{TemplateBinding ActualHeight}"
                                                                   Width="{TemplateBinding ActualWidth}" />
                                                        </ControlTemplate>
                                                    </RepeatButton.Template>
                                                </RepeatButton>
                                            </Track.DecreaseRepeatButton>
    
                                            <Track.Thumb>
                                                <Thumb>
                                                    <Thumb.Template>
                                                        <ControlTemplate TargetType="Thumb">
                                                            <Rectangle x:Name="ThumbRectangle" 
                                                                   Fill="{StaticResource ScrollBarButtonBackgroundBrush}" 
                                                                   Margin="1,0,1,0"/>
                                                            <ControlTemplate.Triggers>
                                                                <Trigger Property="IsMouseOver" Value="True">
                                                                    <Setter TargetName="ThumbRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                                </Trigger>
                                                            </ControlTemplate.Triggers>
                                                        </ControlTemplate>
                                                    </Thumb.Template>
                                                </Thumb>
                                            </Track.Thumb>
    
                                            <Track.IncreaseRepeatButton>
                                                <RepeatButton Command="ScrollBar.PageDownCommand" 
                                                          Background="Transparent">
                                                    <RepeatButton.Template>
                                                        <ControlTemplate TargetType="RepeatButton">
                                                            <Rectangle Fill="{TemplateBinding Background}" 
                                                                   Height="{TemplateBinding ActualHeight}"
                                                                   Width="{TemplateBinding ActualWidth}" />
                                                        </ControlTemplate>
                                                    </RepeatButton.Template>
                                                </RepeatButton>
                                            </Track.IncreaseRepeatButton>
                                        </Track>
    
                                        <Button Grid.Row="2"
                                            Command="ScrollBar.LineDownCommand"
                                            Height="{StaticResource ScrollBarWidth}">
                                            <Button.Template>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid>
                                                        <Rectangle x:Name="ButtonRectangle" 
                                                               Fill="Transparent"/>
                                                        <Path HorizontalAlignment="Center"
                                                          VerticalAlignment="Center"
                                                          Data="M 0 0 L 10 0 L 5 10 Z"
                                                          Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollBar}}"
                                                          Stretch="Fill"
                                                          Height="{StaticResource ScrollBarArrowHeight}"
                                                          Width="{StaticResource ScrollBarArrowWidth}" />
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ButtonRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Button.Template>
                                        </Button>
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
    
                <Trigger Property="Orientation" Value="Horizontal">
                    <Setter Property="Foreground" Value="#FF999999"/>
                    <Setter Property="Height" Value="{StaticResource ScrollBarWidth}"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ScrollBar}">
                                <Border BorderThickness="1">
                                    <Border.BorderBrush>
                                        <SolidColorBrush Color="#888888" Opacity="0.6"/>
                                    </Border.BorderBrush>
                                    <Border.Background>
                                        <SolidColorBrush Color="#888888" Opacity="0.1"/>
                                    </Border.Background>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
    
                                        <Button Grid.Column="0"
                                            Command="ScrollBar.LineLeftCommand"
                                            Width="{StaticResource ScrollBarWidth}">
                                            <Button.Template>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid>
                                                        <Rectangle x:Name="ButtonRectangle" 
                                                               Fill="Transparent"/>
                                                        <Path HorizontalAlignment="Center"
                                                          VerticalAlignment="Center"
                                                          Data="M 0 5 L 10 0 L 10 10 Z"
                                                          Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollBar}}"
                                                          Stretch="Fill"
                                                          Height="{StaticResource ScrollBarArrowWidth}"
                                                          Width="{StaticResource ScrollBarArrowHeight}" />
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ButtonRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Button.Template>
                                        </Button>
    
                                        <Track Name="PART_Track" IsDirectionReversed="False" HorizontalAlignment="Stretch" Grid.Column="1">
                                            <Track.DecreaseRepeatButton>
                                                <RepeatButton Command="ScrollBar.PageLeftCommand"
                                                          Background="Transparent">
                                                    <RepeatButton.Template>
                                                        <ControlTemplate TargetType="RepeatButton">
                                                            <Rectangle Fill="{TemplateBinding Background}" 
                                                                   Height="{TemplateBinding ActualHeight}"
                                                                   Width="{TemplateBinding ActualWidth}" />
                                                        </ControlTemplate>
                                                    </RepeatButton.Template>
                                                </RepeatButton>
                                            </Track.DecreaseRepeatButton>
    
                                            <Track.Thumb>
                                                <Thumb>
                                                    <Thumb.Template>
                                                        <ControlTemplate TargetType="Thumb">
                                                            <Rectangle x:Name="ThumbRectangle" 
                                                                   Fill="{StaticResource ScrollBarButtonBackgroundBrush}" 
                                                                       Margin="0,1,0,1"/>
                                                            <ControlTemplate.Triggers>
                                                                <Trigger Property="IsMouseOver" Value="True">
                                                                    <Setter TargetName="ThumbRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                                </Trigger>
                                                            </ControlTemplate.Triggers>
                                                        </ControlTemplate>
                                                    </Thumb.Template>
                                                </Thumb>
                                            </Track.Thumb>
    
                                            <Track.IncreaseRepeatButton>
                                                <RepeatButton Command="ScrollBar.PageRightCommand" 
                                                          Background="Transparent">
                                                    <RepeatButton.Template>
                                                        <ControlTemplate TargetType="RepeatButton">
                                                            <Rectangle Fill="{TemplateBinding Background}" 
                                                                   Height="{TemplateBinding ActualHeight}"
                                                                   Width="{TemplateBinding ActualWidth}" />
                                                        </ControlTemplate>
                                                    </RepeatButton.Template>
                                                </RepeatButton>
                                            </Track.IncreaseRepeatButton>
                                        </Track>
    
                                        <Button Grid.Column="2"
                                            Command="ScrollBar.LineRightCommand"
                                            Width="{StaticResource ScrollBarWidth}">
                                            <Button.Template>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid>
                                                        <Rectangle x:Name="ButtonRectangle" 
                                                               Fill="Transparent"/>
                                                        <Path HorizontalAlignment="Center"
                                                          VerticalAlignment="Center"
                                                          Data="M 10 5 L 0 0 L 0 10 Z"
                                                          Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollBar}}"
                                                          Stretch="Fill"
                                                          Height="{StaticResource ScrollBarArrowHeight}"
                                                          Width="{StaticResource ScrollBarArrowWidth}" />
                                                    </Grid>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ButtonRectangle" Property="Fill" Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Button.Template>
                                        </Button>
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </ResourceDictionary>
    
    
    תכנות

  • WPF: ממשק מודרני עבור טאבים בתוך שורת הכותרת (TabControl in TitleBar)
    pcinfogmachP pcinfogmach

    הייתי צריך ממשק מודרני עם טאבים בתוך שורת הכותרת של החלון (בדומה למה שיש בכל דפדפן אינטרנט קלאסי)

    לא מצאתי משהו לרוחי אז יצרתי משהו לעצמי
    מצו"ב הלינק לגיט למקרה שעוד מישהו מעוניין בכזה דבר
    https://github.com/pcinfogmach/ChromeTabs

    הפרוייקט לא נעשה בכל חלקיו לפי הספר ממש אבל הוא עושה את העבודה בצורה יפה.

    37ddc135-96c6-4933-a3da-4dd0fc07ed93-image.png

    תכנות

  • תוכנה מצוינת עם אוסף אייקונים לשימוש חינמי ב-WPF
    pcinfogmachP pcinfogmach

    אם אתם מפתחים אפליקציות ב-WPF ומחפשים אוסף אייקונים לשימוש ב-UI שלכם, מצאתי כלי מעולה שמספק אוסף גדול של אייקונים הניתנים לשימוש בקלות באמצעות תכונת ה-Path ב-XAML.

    https://apps.microsoft.com/detail/9mtbnqsz9nz9?hl=en-US&gl=US

    תכנות

  • המלצה על חנות ארונות זולה
    pcinfogmachP pcinfogmach

    ראיתי אתר של חנות ארונות זולה
    https://www.aluf-haronot.co.il

    מישהו יכול להמליץ לי האם כדאי לי לקנות שם?

    גומלין - כללי

  • קוד ללכידת מסך ב-C# WPF
    pcinfogmachP pcinfogmach

    אוקיי מצאתי איך עשים את זה

    יש מתודה ב-wpf בשם
    PointToScreen שמחשב את המיקום ביחס למסך

    עידכנתי את פוסט המקור עם התוכנה המלאה

    תוכנה

  • קוד ללכידת מסך ב-C# WPF
    pcinfogmachP pcinfogmach

    עריכה:
    קוד \ תוכנה שפיתחתי ללכידת מסך ב-wpf
    כולל OCR של TESSERACT בעברית ובאנגלית
    https://github.com/pcinfogmach/ScreenCapture

    תודה רבה לכל העוזרים בהמשך הפוסט

    תוכנה

  • איך להשתמש ב-pdf.js לפתיחת קבצי pdf מהמחשב ב-C#
    pcinfogmachP pcinfogmach

    בניתי תוכנה שמדגימה את הימוש בספרייה זו ב-C# למי שמעוניין להלן הקישור לגיט האב
    https://github.com/pcinfogmach/PdfJs2
    התוכנה רק מדגימה שימוש בסיס יש עוד המון אפשרויות להתממשקות דרך js

    תכנות

  • איך להשתמש ב-pdf.js לפתיחת קבצי pdf מהמחשב ב-C#
    pcinfogmachP pcinfogmach

    לבינתיים מצאתי פתרון לא מושלם אבל זה עובד:
    יש להעתיק את הקובץ לתוך תיקיית ה-web ומשם אפשר לפתוח אותו (עיין כאן) מצו"ב דוגמא מלאה:
    אני מקווה שאולי מישהו שמבין באמת בנושא יוכל להצביע על הפונציה הנצרכת ברור לי שיש משהו כזה כי יש כפתור שפותח קבצים.

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            webView.CoreWebView2InitializationCompleted += Browser_CoreWebView2InitializationCompleted;
            webView.EnsureCoreWebView2Async();
        }
    
        private void Browser_CoreWebView2InitializationCompleted(object? sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
        {
            string appPath = AppDomain.CurrentDomain.BaseDirectory;
            string fullPath = Path.Combine(appPath, "pdfjs");
            webView.CoreWebView2.SetVirtualHostNameToFolderMapping("pdfjs", fullPath, CoreWebView2HostResourceAccessKind.DenyCors);
        }
    
        private void OpenPdfButton_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog
            {
                Filter = "PDF Files (*.pdf)|*.pdf",
                Title = "Select a PDF File"
            };
    
            if (openFileDialog.ShowDialog() == true)
            {
                string filePath = openFileDialog.FileName;
                string appPath = AppDomain.CurrentDomain.BaseDirectory;
                string targetPath = Path.Combine(appPath, "pdfjs", "web", Path.GetFileName(filePath));
    
                try
                {
                    // Copy the selected PDF file to the pdfjs folder
                    File.Copy(filePath, targetPath, true);
    
                    // Open the copied file in the PDF viewer
                    string fileUri = new Uri($"https://pdfjs/web/viewer.html?file={Path.GetFileName(filePath)}").AbsoluteUri;
                    webView.Source = new Uri(fileUri);;
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error copying file: {ex.Message}");
                }
            }
        }
    }
    
    תכנות

  • איך להשתמש ב-pdf.js לפתיחת קבצי pdf מהמחשב ב-C#
    pcinfogmachP pcinfogmach

    במהלך חיפושי אחרי ספרייה שימושית להצגת מסמכי PDF, נתקלתי ב-pdf.js — מציג ה-PDF של פיירפוקס, שהוא גם חינמי.

    עם זאת, ישנה בעיה: בגלל הגבלות בטיחות של דפדפנים, לא ניתן לטעון את הקורא באופן ישיר. מצאתי פתרון בנושא כאן, שבו מוצע להשתמש בקוד הבא:

    private async void PDFjsViewerWebView_CoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args)
    {
    	string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    	sender.CoreWebView2.SetVirtualHostNameToFolderMapping("pdfjs", path, CoreWebView2HostResourceAccessKind.DenyCors);
    	PDFjsViewerWebView.Source = new("https://pdfjs/web/viewer.html");
    }
    

    הקוד עובד מצוין והקורא נטען בהצלחה. כעת, אני נתקלתי בבעיה — איך אני טוען מסמך לוקאלי דרך הקורא?

    תכנות

  • ביאור עניין ה"קבלה קטנה של עשי"ת - לתשב"ר
    pcinfogmachP pcinfogmach

    קבלה קטנה לתשבר.docx

    המרחב הפרטי

  • שאלה / מערכת הודעות התגוננות מטעם פיקוד העורף בטכנולוגית CB
    pcinfogmachP pcinfogmach

    @אפרים22
    יש לזה הגדרה בפלאפון 4X4?

    מובייל וטבלט

  • איפה משתמשי נטפרי יכולים להתעדכן במצב בזמן אמת?
    pcinfogmachP pcinfogmach

    @chagold
    לא מצאתי שם מידע יעיל מספיק חוץ מעל אזעקות בזמן אמת או הנחיות כלליות.
    אני מחפש מידע יותר ספיציפי נגיד היום בערב אחרי המתקפה רציתי לדעת ממתי אפשר לצאת לקניות שלוקחות זמן.
    או האם יש צפי לעוד מתקפות בחג וכו'.

    גומלין - כללי

  • איפה משתמשי נטפרי יכולים להתעדכן במצב בזמן אמת?
    pcinfogmachP pcinfogmach

    מישהו יודע איפה משתמשי נטפרי יכולים להתעדכן במצב ובפרט בהוראות - בזמן אמת?

    גומלין - כללי

  • הוצאת נתונים מדוח שעון נוכחות
    pcinfogmachP pcinfogmach

    @ששא
    אתה כתבת איזה תוצאות אתה רוצה לא איזה שלבים אתה צריך לעבור כדי להגיע לתוצאות. אני מנסה לעזור לך לחשוב - זה הסיבה שלא הצלחת כי לא ניתחת מה אתה צריך לעשות.

    גומלין - כללי

  • הוצאת נתונים מדוח שעון נוכחות
    pcinfogmachP pcinfogmach

    @ששא
    שלב ראשון תנסה לחשוב איך היית עושה את התרגיל באופן ידני.
    כלומר מה הם השלבים שאתה צריך לעשות כדי לקבל את התוצאה שאתה רוצה:
    איזה מידע אתה צריך לסנן לארגן ולחשב ואיך, לא כל דבר אפשר ישירות על ידי חשבון אקסל לפעמים צריך מאקרו לזה.

    גומלין - כללי

  • קוד עבור WPF PlaceHolder TextBox
    pcinfogmachP pcinfogmach

    מטרת הקוד הזה היא ליצור רכיב מותאם אישית של תיבת טקסט (TextBox) ב-WPF, עם תמיכה בטקסט PlaceHolder, כלומר טקסט שמופיע בתוך תיבת הטקסט כשהיא ריקה ולא ממוקדת (כלומר, המשתמש לא בחר בה עדיין). כאשר המשתמש לוחץ על תיבת הטקסט ומתחיל להקליד, PlaceHolder נעלם, וכשהתיבה ריקה והפוקוס יוצא ממנה, PlaceHolder חוזר.
    בפועל, הקוד משתמש במנגנון שנקרא Adorner כדי להציג את טקסט PlaceHolder כטקסט חיצוני מעל תיבת הטקסט, מבלי להשפיע על התוכן האמיתי שבתיבת הטקסט.

    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Media;
    
    namespace AdvancedControls
    {
        public class PlaceHolderTextBox : TextBox
        {
            private AdornerLayer _adornerLayer;
            private PlaceholderAdorner _placeholderAdorner;
    
            #region PlaceHolder Property
            public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register(
                "PlaceholderText",
                typeof(string),
                typeof(PlaceHolderTextBox),
                new PropertyMetadata(string.Empty, OnPlaceholderTextChanged));
    
            public string PlaceholderText
            {
                get => (string)GetValue(PlaceholderTextProperty);
                set => SetValue(PlaceholderTextProperty, value);
            }
    
            private static void OnPlaceholderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
            {
                var textBox = d as PlaceHolderTextBox;
                textBox?.UpdatePlaceholderVisibility();
            }
            #endregion
    
            public PlaceHolderTextBox()
            {
                Loaded += (s, e) => InitializePlaceholder();
                TextChanged += (s, e) => UpdatePlaceholderVisibility();
                GotFocus += (s, e) => UpdatePlaceholderVisibility();
                LostFocus += (s, e) => UpdatePlaceholderVisibility();
            }
    
            private void InitializePlaceholder()
            {
                _adornerLayer = AdornerLayer.GetAdornerLayer(this);
                UpdatePlaceholderVisibility();
            }
    
            private void UpdatePlaceholderVisibility()
            {
                if (_adornerLayer == null) return;
    
                // Remove existing adorner if any
                var adorners = _adornerLayer.GetAdorners(this);
                if (adorners != null)
                {
                    foreach (var adorner in adorners)
                    {
                        if (adorner is PlaceholderAdorner)
                        {
                            _adornerLayer.Remove(adorner);
                        }
                    }
                }
    
                // Add the adorner only if the TextBox is empty and not focused
                if (string.IsNullOrEmpty(this.Text) && !this.IsFocused)
                {
                    _placeholderAdorner = new PlaceholderAdorner(this, PlaceholderText, this.FontSize);
                    _adornerLayer.Add(_placeholderAdorner);
                }
            }
        }
    
    
        public class PlaceholderAdorner : Adorner
        {
            private readonly TextBlock _placeholderTextBlock;
    
            public PlaceholderAdorner(UIElement adornedElement, string placeholderText, double fontSize) : base(adornedElement)
            {
                _placeholderTextBlock = new TextBlock
                {
                    Text = placeholderText,
                    Foreground = Brushes.Gray,
                    IsHitTestVisible = false,  // Allow clicks to pass through to the TextBox
                    FontSize = fontSize - 1,
                    Padding = new Thickness(2,0,2,0)
                };
    
                AddVisualChild(_placeholderTextBlock);
            }
    
            protected override int VisualChildrenCount => 1;
    
            protected override Visual GetVisualChild(int index) => _placeholderTextBlock;
    
            protected override Size MeasureOverride(Size constraint)
            {
                _placeholderTextBlock.Measure(constraint);
                return AdornedElement.RenderSize;
            }
    
            protected override Size ArrangeOverride(Size finalSize)
            {
                _placeholderTextBlock.Arrange(new Rect(finalSize));
                return finalSize;
            }
        }
    }
    
    
    תכנות

  • איך להסיר ניקוד וטעמים מטקסט בc#
    pcinfogmachP pcinfogmach

    @dovid

    יש בעיה בהסרת ניקוד וטעמים כאשר מופיע מקף עליון שצריך להחליף אותו ברוווח אחרת זה יחבר שני מילים

    הנה הקוד המתוקן עבור שימוש ב- stringbuilder

     public static string RemoveHebrewDiactrics(this string input)
     {
         var sb = new StringBuilder(input.Length);
    
         foreach (var c in input)
             
             if (c == '־')
                 sb.Append(' ');
             else if (c > 1487 || c < 1425)
    
                 sb.Append(c);
    
         return sb.ToString();
     }
    
    תכנות
  • 1
  • 2
  • 13
  • 14
  • 15
  • 16
  • 17
  • 38
  • 39
  • 15 / 39
  • התחברות

  • אין לך חשבון עדיין? הרשמה

  • התחברו או הירשמו כדי לחפש.
  • פוסט ראשון
    פוסט אחרון
0
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום