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

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

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

pcinfogmach

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

פוסטים

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

  • איך ליצור childform יותר יפה כאשר משתמשים בmdi
    pcinfogmachP pcinfogmach

    שיחקתי עם זה קצת והוספתי לו תכונות snap פשוטות (לקצוות של הparentform ולקצוות של אחד לשני)

    static class MyDictionary
    {
        public static List<SizeableUserControl> userControlCollection = new List<SizeableUserControl>();
    }
    
    class SizeableUserControl : UserControl
    {
        Form parentForm;
        private const int grab = 16;
        public SizeableUserControl(Form form)
        {
            parentForm = form;
            MyDictionary.userControlCollection.Add(this);
            this.ResizeRedraw = true;
            InitializeComponent();
        }
    
        private void InitializeComponent()
        {
            this.SuspendLayout();
            this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Name = "SizeableUserControl";
            this.Size = new System.Drawing.Size(100, 100);
            
            Panel titleBar = new Panel();
            titleBar.Dock = DockStyle.Top;
            titleBar.BackColor = Color.White;
    
            titleBar.Height = 20;
            Controls.Add(titleBar);
            titleBar.MouseDown += TitleBar_MouseDown;
            titleBar.MouseMove += TitleBar_MouseMove;
            titleBar.MouseUp += TitleBar_MouseUp;
    
            // Minimize button
            Button minimizeButton = new Button();
            minimizeButton.Text = "─";
            minimizeButton.TextAlign = ContentAlignment.MiddleCenter;
            minimizeButton.Width = 20;
            minimizeButton.Height = 20;
            minimizeButton.Dock = DockStyle.Right;
            minimizeButton.FlatStyle = FlatStyle.Flat;
            minimizeButton.FlatAppearance.BorderSize = 0;
            titleBar.Controls.Add(minimizeButton);
    
            minimizeButton.Click += (sender, e) =>
            {
                if (minimizeButton.Text == "─")
                { 
                minimizeButton.Text = "+";
                this.Height = 20;
                this.Width = 60;
                }
                else
                {
                    minimizeButton.Text = "─";
                    this.Height = 100;
                    this.Width = 100;
                }
            };
    
            // Maximize button
            Button maximizeButton = new Button();
            maximizeButton.Text = "⬜"; // Larger square Unicode character
            maximizeButton.TextAlign = ContentAlignment.MiddleCenter;
            maximizeButton.Width = 20;
            maximizeButton.Height = 20;
            maximizeButton.Dock = DockStyle.Right;
            maximizeButton.FlatStyle = FlatStyle.Flat;
            maximizeButton.FlatAppearance.BorderSize = 0;
    
            // Store the original DockStyle
            DockStyle originalDockStyle = DockStyle.None;
    
            maximizeButton.Click += (sender, e) =>
            {
                if (this.Dock == DockStyle.None)
                {
                    // Maximize the form
                    originalDockStyle = this.Dock;
                    this.Dock = DockStyle.Fill;
                    maximizeButton.Text = "❐"; // Change text to indicate restore
                }
                else
                {
                    // Restore the original DockStyle
                    this.Dock = originalDockStyle;
                    maximizeButton.Text = "⬜"; // Change text to indicate maximize
                }
            };
    
            titleBar.Controls.Add(maximizeButton);
    
    
            // X button
            Button xButton = new Button();
            xButton.Text = "X";
            xButton.Dock = DockStyle.Right;
            xButton.Width = 20;
            xButton.Height = 20;
            xButton.FlatStyle = FlatStyle.Flat;
            xButton.FlatAppearance.BorderSize = 0;
            xButton.Click += (sender, e) => this.Dispose();
            titleBar.Controls.Add(xButton);
    
            this.ResumeLayout(false);
        }
    
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            const int WM_NCHITTEST = 0x84;
            const int HT_LEFT = 10;
            const int HT_RIGHT = 11;
            const int HT_TOP = 12;
            const int HT_TOPLEFT = 13;
            const int HT_TOPRIGHT = 14;
            const int HT_BOTTOM = 15;
            const int HT_BOTTOMLEFT = 16;
            const int HT_BOTTOMRIGHT = 17;
    
            if (m.Msg == WM_NCHITTEST)
            {
                var pos = this.PointToClient(new Point(m.LParam.ToInt32()));
    
                if (pos.X <= grab && pos.Y <= grab)
                    m.Result = new IntPtr(HT_TOPLEFT);
                else if (pos.X >= this.ClientSize.Width - grab && pos.Y <= grab)
                    m.Result = new IntPtr(HT_TOPRIGHT);
                else if (pos.X <= grab && pos.Y >= this.ClientSize.Height - grab)
                    m.Result = new IntPtr(HT_BOTTOMLEFT);
                else if (pos.X >= this.ClientSize.Width - grab && pos.Y >= this.ClientSize.Height - grab)
                    m.Result = new IntPtr(HT_BOTTOMRIGHT);
                else if (pos.X <= grab)
                    m.Result = new IntPtr(HT_LEFT);
                else if (pos.X >= this.ClientSize.Width - grab)
                    m.Result = new IntPtr(HT_RIGHT);
                else if (pos.Y <= grab)
                    m.Result = new IntPtr(HT_TOP);
                else if (pos.Y >= this.ClientSize.Height - grab)
                    m.Result = new IntPtr(HT_BOTTOM);
            }
        }
    
    
    
        bool isMouseDown = false;
        private Point mouseDownLocation;
    
        private void TitleBar_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;
        }
    
        private void TitleBar_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                // Check proximity on all sides (adjust the threshold as needed)
                int proximityThreshold = 10;
    
                // Calculate the new position of the control based on the mouse movement
                int newX = this.Left - mouseDownLocation.X + e.X;
                int newY = this.Top - mouseDownLocation.Y + e.Y;
    
                // Ensure the new position is within the boundaries of the parent form
                newX = Math.Max(0, Math.Min(newX, parentForm.ClientSize.Width - this.Width));
                newY = Math.Max(0, Math.Min(newY, parentForm.ClientSize.Height - this.Height));
    
                // Iterate through other controls and check if snapping is possible
                foreach (var kvp in MyDictionary.userControlCollection)
                {
                    if (kvp != this)
                    {
                        // Check top side
                        if (Math.Abs(newY - kvp.Bottom) < proximityThreshold)
                        {
                            newY = kvp.Bottom + 1;
    
                            // Align right and left if they are close enough
                            if (Math.Abs(newX - kvp.Left) < proximityThreshold)
                            {
                                newX = kvp.Left;
                            }
                            else if (Math.Abs(newX + this.Width - kvp.Right) < proximityThreshold)
                            {
                                newX = kvp.Right - this.Width;
                            }
                        }
    
                        // Check bottom side
                        else if (Math.Abs(newY + this.Height - kvp.Top) < proximityThreshold)
                        {
                            newY = kvp.Top - this.Height - 1;
    
                            // Align right and left if they are close enough
                            if (Math.Abs(newX - kvp.Left) < proximityThreshold)
                            {
                                newX = kvp.Left;
                            }
                            else if (Math.Abs(newX + this.Width - kvp.Right) < proximityThreshold)
                            {
                                newX = kvp.Right - this.Width;
                            }
                        }
    
                        // Check left side
                        if (Math.Abs(newX - kvp.Right) < proximityThreshold)
                        {
                            newX = kvp.Right + 1;
    
                            // Align tops if they are close enough
                            if (Math.Abs(newY - kvp.Top) < proximityThreshold)
                            {
                                newY = kvp.Top;
                            }
                            // Align bottoms if they are close enough
                            else if (Math.Abs(newY + this.Height - kvp.Bottom) < proximityThreshold)
                            {
                                newY = kvp.Bottom - this.Height;
                            }
                        }
    
                        // Check right side
                        else if (Math.Abs(newX + this.Width - kvp.Left) < proximityThreshold)
                        {
                            newX = kvp.Left - this.Width - 1;
    
                            // Align tops if they are close enough
                            if (Math.Abs(newY - kvp.Top) < proximityThreshold)
                            {
                                newY = kvp.Top;
                            }
                            // Align bottoms if they are close enough
                            else if (Math.Abs(newY + this.Height - kvp.Bottom) < proximityThreshold)
                            {
                                newY = kvp.Bottom - this.Height;
                            }
                        }
                    }
                }
    
                // Snap to parent form edges
                if (Math.Abs(newX) < proximityThreshold)
                {
                    newX = 0;
                }
                else if (Math.Abs(newX + this.Width - parentForm.ClientSize.Width) < proximityThreshold)
                {
                    newX = parentForm.ClientSize.Width - this.Width;
                }
    
                if (Math.Abs(newY) < proximityThreshold)
                {
                    newY = 0;
                }
                else if (Math.Abs(newY + this.Height - parentForm.ClientSize.Height) < proximityThreshold)
                {
                    newY = parentForm.ClientSize.Height - this.Height;
                }
    
                this.Location = new Point(newX, newY);
    
                // Forces the control to repaint for a smoother visual experience
                this.Invalidate();
            }
        }
    
    
    
        
    
        private void TitleBar_MouseDown(object sender, MouseEventArgs e)
        {
            isMouseDown = true;
            mouseDownLocation = e.Location;
        }
    }
    

  • איך ליצור childform יותר יפה כאשר משתמשים בmdi
    pcinfogmachP pcinfogmach

    לבינתיים השלמתי את המלאכה בwinform אולי יהיה שימושי למישהו

    c9c8cd46-4e3f-40d4-a126-47b877024225-image.png

    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace ResizableTextBox
    {
        class SizeableUserControl : UserControl
        {
            private const int grab = 16;
    
            public SizeableUserControl()
            {
                this.ResizeRedraw = true;
                InitializeComponent();
            }
    
            protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);
                const int WM_NCHITTEST = 0x84;
                const int HT_LEFT = 10;
                const int HT_RIGHT = 11;
                const int HT_TOP = 12;
                const int HT_TOPLEFT = 13;
                const int HT_TOPRIGHT = 14;
                const int HT_BOTTOM = 15;
                const int HT_BOTTOMLEFT = 16;
                const int HT_BOTTOMRIGHT = 17;
    
                if (m.Msg == WM_NCHITTEST)
                {
                    var pos = this.PointToClient(new Point(m.LParam.ToInt32()));
    
                    if (pos.X <= grab && pos.Y <= grab)
                        m.Result = new IntPtr(HT_TOPLEFT);
                    else if (pos.X >= this.ClientSize.Width - grab && pos.Y <= grab)
                        m.Result = new IntPtr(HT_TOPRIGHT);
                    else if (pos.X <= grab && pos.Y >= this.ClientSize.Height - grab)
                        m.Result = new IntPtr(HT_BOTTOMLEFT);
                    else if (pos.X >= this.ClientSize.Width - grab && pos.Y >= this.ClientSize.Height - grab)
                        m.Result = new IntPtr(HT_BOTTOMRIGHT);
                    else if (pos.X <= grab)
                        m.Result = new IntPtr(HT_LEFT);
                    else if (pos.X >= this.ClientSize.Width - grab)
                        m.Result = new IntPtr(HT_RIGHT);
                    else if (pos.Y <= grab)
                        m.Result = new IntPtr(HT_TOP);
                    else if (pos.Y >= this.ClientSize.Height - grab)
                        m.Result = new IntPtr(HT_BOTTOM);
                }
            }
    
            private void InitializeComponent()
            {
                this.SuspendLayout();
                this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                this.Name = "SizeableUserControl";
                this.Size = new System.Drawing.Size(100, 100);
                
                Panel titleBar = new Panel();
                titleBar.Dock = DockStyle.Top;
                titleBar.BackColor = Color.White;
    
                titleBar.Height = 20;
                Controls.Add(titleBar);
                titleBar.MouseDown += TitleBar_MouseDown;
                titleBar.MouseMove += TitleBar_MouseMove;
                titleBar.MouseUp += TitleBar_MouseUp;
    
                // Minimize button
                Button minimizeButton = new Button();
                minimizeButton.Text = "─";
                minimizeButton.TextAlign = ContentAlignment.MiddleCenter;
                minimizeButton.Width = 20;
                minimizeButton.Height = 20;
                minimizeButton.Dock = DockStyle.Right;
                minimizeButton.FlatStyle = FlatStyle.Flat;
                minimizeButton.FlatAppearance.BorderSize = 0;
                titleBar.Controls.Add(minimizeButton);
    
                minimizeButton.Click += (sender, e) =>
                {
                    if (minimizeButton.Text == "─")
                    { 
                    minimizeButton.Text = "+";
                    this.Height = 20;
                    this.Width = 60;
                    }
                    else
                    {
                        minimizeButton.Text = "─";
                        this.Height = 100;
                        this.Width = 100;
                    }
                };
    
                // Maximize button
                Button maximizeButton = new Button();
                maximizeButton.Text = "⬜"; // Larger square Unicode character
                maximizeButton.TextAlign = ContentAlignment.MiddleCenter;
                maximizeButton.Width = 20;
                maximizeButton.Height = 20;
                maximizeButton.Dock = DockStyle.Right;
                maximizeButton.FlatStyle = FlatStyle.Flat;
                maximizeButton.FlatAppearance.BorderSize = 0;
    
                // Store the original DockStyle
                DockStyle originalDockStyle = DockStyle.None;
    
                maximizeButton.Click += (sender, e) =>
                {
                    if (this.Dock == DockStyle.None)
                    {
                        // Maximize the form
                        originalDockStyle = this.Dock;
                        this.Dock = DockStyle.Fill;
                        maximizeButton.Text = "❐"; // Change text to indicate restore
                    }
                    else
                    {
                        // Restore the original DockStyle
                        this.Dock = originalDockStyle;
                        maximizeButton.Text = "⬜"; // Change text to indicate maximize
                    }
                };
    
                titleBar.Controls.Add(maximizeButton);
    
    
                // X button
                Button xButton = new Button();
                xButton.Text = "X";
                xButton.Dock = DockStyle.Right;
                xButton.Width = 20;
                xButton.Height = 20;
                xButton.FlatStyle = FlatStyle.Flat;
                xButton.FlatAppearance.BorderSize = 0;
                xButton.Click += (sender, e) => this.Dispose();
                titleBar.Controls.Add(xButton);
    
                this.ResumeLayout(false);
            }
    
            bool isMouseDown = false;
            private Point mouseDownLocation;
    
            private void TitleBar_MouseUp(object sender, MouseEventArgs e)
            {
                isMouseDown = false;
            }
    
            private void TitleBar_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown)
                {
                    if (isMouseDown)
                    {
                        // Calculate the new position of the form based on the mouse movement
                        this.Location = new Point(
                            (this.Location.X - mouseDownLocation.X) + e.X,
                            (this.Location.Y - mouseDownLocation.Y) + e.Y);
    
                        this.Update(); // Forces the form to repaint for a smoother visual experience
                    }
                }
            }
    
            private void TitleBar_MouseDown(object sender, MouseEventArgs e)
            {
                isMouseDown = true;
                mouseDownLocation = e.Location;
            }
        }
    }
    
    

  • איך ליצור childform יותר יפה כאשר משתמשים בmdi
    pcinfogmachP pcinfogmach

    הבעיה שנסיון לעשות כזה דבר בwpf עלה לי ממש בתוהו פה לפחות הגעתי לאן שהוא
    עריכה:
    עכשיו ראיתי את זה בwpf צריך לשבת לראות מה יצא
    http://csharphelper.com/howtos/howto_wpf_resize_rectangle.html


  • איך ליצור childform יותר יפה כאשר משתמשים בmdi
    pcinfogmachP pcinfogmach

    מסתבר שאפשר להשתמש עם usercontrol
    הנה משהו בתור התחלה אזמח אם מישהו יוכל לעבור על זה ואולי גם לעזור לי לשפר את זה - נתקעתי עם הרחבה בצד שמאל ולמעלה - ועם כפתור minimize

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace TestC
    {
        public partial class Form1 : Form
        {
            private ResizeableControl resizeableControl;
    
            public Form1()
            {
                InitializeComponent();
                InitializeResizeableControl();
            }
    
            private void InitializeResizeableControl()
            {
                resizeableControl = new ResizeableControl();
                Controls.Add(resizeableControl);
    
                // Handle the Resize event of the form to update the size of the control
                Resize += (sender, e) => resizeableControl.Size = ClientSize;
            }
        }
    
        public class ResizeableControl : UserControl
        {
            private const int BorderSize = 8;
            private bool isResizing = false;
            private bool isResizingHorizontal = false;
            private bool isResizingVertical = false;
            private Point lastMousePosition;
    
            bool isMouseDown = false;
            private Point mouseDownLocation;
    
            public ResizeableControl()
            {
                // Set the initial size
                Size = new Size(200, 200);
                BorderStyle = BorderStyle.FixedSingle;
                // Handle mouse events
                MouseDown += OnMouseDown;
                MouseMove += OnMouseMove;
                MouseUp += OnMouseUp;
                InitializeComponents();
            }
    
            private void InitializeComponents()
            {
                Panel titleBar = new Panel();
                titleBar.Dock = DockStyle.Top;
                titleBar.BackColor = Color.White;
    
                titleBar.Height = 20;
                Controls.Add(titleBar);
                titleBar.MouseDown += TitleBar_MouseDown;
                titleBar.MouseMove += TitleBar_MouseMove;
                titleBar.MouseUp += TitleBar_MouseUp;
    
                // Maximize button
                Button maximizeButton = new Button();
                maximizeButton.Text = "⬜"; // Larger square Unicode character
                maximizeButton.Width = 20;
                maximizeButton.Height = 20;
                maximizeButton.Dock = DockStyle.Right;
                maximizeButton.FlatStyle = FlatStyle.Flat;
                maximizeButton.FlatAppearance.BorderSize = 0;
    
                // Store the original DockStyle
                DockStyle originalDockStyle = DockStyle.None;
    
                maximizeButton.Click += (sender, e) =>
                {
                    if (this.Dock == DockStyle.None)
                    {
                        // Maximize the form
                        originalDockStyle = this.Dock;
                        this.Dock = DockStyle.Fill;
                        maximizeButton.Text = "❐"; // Change text to indicate restore
                    }
                    else
                    {
                        // Restore the original DockStyle
                        this.Dock = originalDockStyle;
                        maximizeButton.Text = "□"; // Change text to indicate maximize
                    }
                };
    
                titleBar.Controls.Add(maximizeButton);
    
    
                // X button
                Button xButton = new Button();
                xButton.Text = "X";
                xButton.Dock = DockStyle.Right;
                xButton.Width = 20;
                xButton.Height = 20;
                xButton.FlatStyle = FlatStyle.Flat;
                xButton.FlatAppearance.BorderSize = 0;
                xButton.Click += (sender, e) => this.Dispose();
                titleBar.Controls.Add(xButton);
            }
    
    
            private void TitleBar_MouseUp(object sender, MouseEventArgs e)
            {
                isMouseDown = false;
            }
    
            private void TitleBar_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown)
                {
                    if (isMouseDown)
                    {
                        // Calculate the new position of the form based on the mouse movement
                        this.Location = new Point(
                            (this.Location.X - mouseDownLocation.X) + e.X,
                            (this.Location.Y - mouseDownLocation.Y) + e.Y);
    
                        this.Update(); // Forces the form to repaint for a smoother visual experience
                    }
                }
            }
    
            private void TitleBar_MouseDown(object sender, MouseEventArgs e)
            {
                isMouseDown = true;
                mouseDownLocation = e.Location;
            }
    
            private void OnMouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left && IsOnBorder(e.Location))
                {
                    isResizing = true;
                    lastMousePosition = e.Location;
    
                    isResizingHorizontal = e.X <= BorderSize || e.X >= Width - BorderSize;
                    isResizingVertical = e.Y <= BorderSize || e.Y >= Height - BorderSize;
                }
            }
    
            private void OnMouseMove(object sender, MouseEventArgs e)
            {
                if (isResizing)
                {
                    int deltaX = e.X - lastMousePosition.X;
                    int deltaY = e.Y - lastMousePosition.Y;
    
                    if (isResizingHorizontal && isResizingVertical)
                    {
                        // Diagonal resizing
                        Width += deltaX;
                        Height += deltaY;
                    }
                    else if (isResizingHorizontal)
                    {
                        // Horizontal resizing
                        Width += deltaX;
                    }
                    else if (isResizingVertical)
                    {
                        // Vertical resizing
                        Height += deltaY;
                    }
    
                    lastMousePosition = e.Location;
                }
                else
                {
                    if (IsOnCorner(e.Location))
                    {
                        Cursor = Cursors.SizeNWSE;
                    }
                    else if (e.X >= Width - BorderSize && e.Y >= Height - BorderSize)
                    {
                        // Cursor is in the bottom-right corner, allowing diagonal resizing
                        Cursor = Cursors.SizeNWSE;
                    }
                    else if (e.X >= Width - BorderSize)
                    {
                        // Cursor is on the right border, allowing horizontal resizing
                        Cursor = Cursors.SizeWE;
                    }
                    else if (e.Y >= Height - BorderSize)
                    {
                        // Cursor is on the bottom border, allowing vertical resizing
                        Cursor = Cursors.SizeNS;
                    }
                    else
                    {
                        Cursor = Cursors.Default;
                    }
                }
            }
    
    
            private void OnMouseUp(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    isResizing = false;
                    Cursor = Cursors.Default;
                }
            }
    
            private bool IsOnBorder(Point mouseLocation)
            {
                return mouseLocation.X <= BorderSize || mouseLocation.Y <= BorderSize ||
                       mouseLocation.X >= Width - BorderSize || mouseLocation.Y >= Height - BorderSize;
            }
    
            private bool IsOnCorner(Point mouseLocation)
            {
                return mouseLocation.X <= BorderSize && mouseLocation.Y <= BorderSize ||
                       mouseLocation.X >= Width - BorderSize && mouseLocation.Y >= Height - BorderSize;
            }
        }
    }
    

  • שאלה בc# בvisualstudio: איך משתמשים עם קבצי טקסט שהוספתי לפרוייקט שלי?
    pcinfogmachP pcinfogmach

    ראיתי שיש אפשרות להוסיף תיקיות וגם קבצי טקסט לפרוייקט אבל אני לא מצליח להשתמש בהם אחרי שאני מוסיף אותם. (כי הם לא נכנסנים אוטמטית לתיקיית הדיבאג).
    23610ca4-7f74-4586-83f8-29400ac947f9-image.png


  • שאלה: איך עושים דחיסה לקובץ בודד בC#?
    pcinfogmachP pcinfogmach

    @dovid
    הקוד שלך עשה שגיאה ולכן תיקנתי ואז לא היה שגיאה אולי חסר לי איזהו רפרנס?
    (אגב מה באמת ההבדל בין optimal ל-smallestsize?)


  • שאלה: איך עושים דחיסה לקובץ בודד בC#?
    pcinfogmachP pcinfogmach

    @dovid
    במקום

    using (var compressor = new GZipStream(fileOutput, CompressionLevel.SmallestSize))
    

    יש לעשות

    using (var compressor = new GZipStream(fileOutput, CompressionLevel.Optimal))
    

  • איך ליצור childform יותר יפה כאשר משתמשים בmdi
    pcinfogmachP pcinfogmach

    אני רוצה להשתמש בmdichild
    או לחילופין פשוט להדגיר ככה

    var childForm = new ChildForm();
    //childForm.TopLevel = false;
    

    (ואז אין את החסרוננות של mdi ואיכמ"ל)

    בכל אופן הרעיון הוא להכניס כמה forms בתוך form אחד
    דומה למה שיש בבר אילן.
    הבעיה היא שכשעושים ככה אז הforms הפנימיים נהיים מגעילים ומיושנים.
    השאלה היא אם יש דרך לעשות אותם יותר יפים?
    מצו:ב תמונה
    9ee94e11-9488-41f8-a1ef-0ab25619dae8-image.png


  • שאלה: איך עושים דחיסה לקובץ בודד בC#?
    pcinfogmachP pcinfogmach

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


  • שלום. מתמחים טופ חסום לי
    pcinfogmachP pcinfogmach

    אם עדיין בעיה תעשה רענון עמוק (cntrl +F5) (אצלי זה עזר בעבר)
    כמו"כ תבדוק אם האנטי וירוס חוסם את זה (אצלי ההיתי צריך לעשות החרגה לאתר)


  • בקשת עזרה בקוד מאקרו
    pcinfogmachP pcinfogmach

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

    Sub SelectPages()
        
    
    Dim allPages As Range, firstPage As Range, lastPage As Range, iPage As Long, xPage As Long
    
    Set allPages = Selection.Range
    Set firstPage = Selection.Range
    Set lastPage = Selection.Range
    
    firstPage.Collapse Direction:=wdCollapseStart
    lastPage.Collapse Direction:=wdCollapseEnd
    
    iPage = firstPage.Information(wdActiveEndPageNumber)
    xPage = lastPage.Information(wdActiveEndPageNumber)
        
    With ActiveDocument
    
      Set firstPage = .GoTo(What:=wdGoToPage, Name:=iPage)
      Set firstPage = firstPage.GoTo(What:=wdGoToBookmark, Name:="\page")
      
      firstPage.Collapse Direction:=wdCollapseStart
      firstPage.InsertBreak Type:=wdSectionBreakNextPage
        
       Set lastPage = .GoTo(What:=wdGoToPage, Name:=xPage)
       Set lastPage = lastPage.GoTo(What:=wdGoToBookmark, Name:="\page")
       
       lastPage.Collapse Direction:=wdCollapseEnd
       lastPage.InsertBreak Type:=wdSectionBreakNextPage
    
    End With
    
    
    lastPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
     Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
    lastPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
     Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
    
    firstPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
     Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
    firstPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.Delete
    
    firstPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
     Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
    Selection.Delete
    firstPage.Select
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Selection.Delete
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
        
    End Sub
    

  • בקשת עזרה בלוגיקה של קוד בC# ליצירת כפתורי "צעד אחורה / קדימה"
    pcinfogmachP pcinfogmach

    אני מנסה ליצור כפתורי אחורה קדיימה כמו שיש ב visual studio

    3163cc3b-3ac2-47c1-84f8-bb485f8f6089-image.png

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

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

    הסבר:
    כשפותחים קובץ חדש נוסף פריט לרשימה.
    עכשיו בוא נגיד יש למשתמש 5 מסמכים פתוחים והרשימה מסודרת מ-1 עד 5
    אם המשתמש ילחץ על כפתור אחרוה הרי הוא יחזור למסמך 4 וכו'. -EASY!

    אבל מה קורה כשהמשתמש עבר באופן ידני למסמך3 שלוש ואז הוא לוחץ על הכפתור חזור אחורה - מה שאני רוצה שיקרה הוא שיחזור למסמך האחרון בו ביקר המשתמש. ולא למסמך מספר 2 ברשימה.

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

    תודה מראש
    מקווה ששאלתי מספיק ברור


  • שאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?
    pcinfogmachP pcinfogmach

    לגבי הוקד רגקס הנ"ל אם אני רוצה לחפש מילים לא לפי סדר מסויים
    ראיתי מישהו שעשה ככה https://rubular.com/r/QFEfj9lMn3
    האם צורה כזו של חיפוש יעילה? כלומר האם זה מכביד מדאי אם אני יעשה כך המון פעמים ברצף

    אגב בלי רגקס אפשר לעשות ככה

    private bool containsAll(string[] words, string text)
    {
        bool searchMatch = words.All(word => text.Contains(word));
        return searchMatch;
    }
    

  • שאלה: איך עושים בתוסף vsto לוורד שtaskpane יישאר תמיד בחלונית האקטיבית
    pcinfogmachP pcinfogmach

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

    זה קורה רק כאשר יש פקד webbrowser עם מסמך פתוח בתוכו (עד היום זה לא קרה) מצו"ב מסמך דוגמא
    מסמך דוגמא.html

    יצרתי גם עוד פרוייקט עם כלום חוץ מפקד toolstrip וwebbroser כדי לבדוק מה קורה שם וזה גם קרה.

    רק חבל לי לא להשתמש עם הקוד הנ"ל אחרי כל הטירחה. ובפרט שבעבר הוא כן עבד ועכשיו פתאום לא.


  • שאלה בwinforms tabcontrol בעברית
    pcinfogmachP pcinfogmach

    @dovid
    הפקדים של wpf יותר כבדים מבחינת המערכת והזכרון או יותר קלילים?


  • שאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?
    pcinfogmachP pcinfogmach

    @dovid
    אוקיי בוא נניח את הנושא המרכזי בצד לעת עתה
    הייתי כן רוצה להתמקד בקוד של הgpt כי אני צריך אותו גם במקום אחר.
    אני משתמש איתו לבניית האינדקס שלי.
    כלומר האינדקס של תוכנת החיפוש lucene
    מה שאני עושה זה חלוקה של המסמך מראש לגזירים והאינדקס שומר את הגזירים ומחפש בתוך הגזירים.
    האם יש דרך יותר טובה לחלק מסמך לגזירים של 30 מילים (עם חפיפה של 10 מכל צד שזה אומר בעצם 10 מילים ישנות ועשרים חדשים כל פעם)


  • שאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?
    pcinfogmachP pcinfogmach

    @dovid
    בוא נתעלם מבעיית האינדוקס - יש לי סיבה טובה למה במקרה זה אני לא הולך על אינדקס (למרות שיש לי משהו כבר מוכן).

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

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

    30 או 21 זה לא באמת משנה. רק זה קצת מקל על הקוד של הgpt לעשות גזירים קצת יותר ארוכים כי אז יש לו פחות פעולות לעשות.


  • שאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?
    pcinfogmachP pcinfogmach

    @dovid

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

    כמות המופעים היה במאות או אם חיפשתי מילה כמו "כי" אז באלפים.

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

    בכל אופן מצו"ב הקודים של שני הבדיקות

    1. קוד הרגקס
    string pattern = "(\\b\\w+\\W+){0,10}" + Regex.Escape(searchTerm) + "(\\W+\\w+\\b){0,10}";
    MatchCollection matches = Regex.Matches(textToSearch, pattern);
    
    if (matches.Count > 0)
    {
        foreach (Match match in matches)
        {
            string result = match.Value;
            result = Regex.Replace(result, @"<.*?>|[^א-ת\.""':, \(\)[]\{\}]", " ");
            result = result.Replace(searchTerm, "<span style=\"color: red;\">" + searchTerm + "</span>");
            fileIndexes[filePath].Add($"<li><a href='#{HttpUtility.HtmlEncode(fileName)}%{HttpUtility.HtmlEncode(chapterName)}' onclick='showMessage(this)'>{fileName} {chapterName}</a><br>{result}</li>");
            resultPagesSum++;
        }
    }
    
    1. הקוד של gpt
    List<string> snippets = SplitStringIntoSnippets(textToSearch, 30);
    
    foreach (string snippet in snippets)
    {
        if (snippet.Contains(searchTerm))
        {
            string result = Regex.Replace(snippet, @"<.*?>|[^א-ת\.""':, \(\)[]\{\}]", " ");
            result = result.Replace(searchTerm, "<span style=\"color: red;\">" + searchTerm + "</span>");
            fileIndexes[filePath].Add($"<li><a href='#{HttpUtility.HtmlEncode(fileName)}%{HttpUtility.HtmlEncode(chapterName)}' onclick='showMessage(this)'>{fileName} {chapterName}</a><br>{result}</li>");
            resultPagesSum++;
        }
    }
    
    static List<string> SplitStringIntoSnippets(string input, int maxSnippetLength)
    {
        List<string> snippets = new List<string>();
    
        string[] words = input.Split(new char[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);
        int wordCount = 0;
        int currentIndex = 0;
    
        for (int i = 0; i < words.Length; i++)
        {
            wordCount++;
            if (wordCount >= maxSnippetLength)
            {
                snippets.Add(string.Join(" ", words, currentIndex, maxSnippetLength));
                currentIndex = i + 1;
                wordCount = 0;
            }
        }
    
        if (currentIndex < words.Length)
        {
            snippets.Add(string.Join(" ", words, currentIndex, words.Length - currentIndex));
        }
    
        return snippets;
    }
    

    ועוד שאלה:
    @dovid כתב בשאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?:

    קוד טוב יהיה טוב יותר מרגקס (נכון להיום בדוטנט)

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


  • שאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?
    pcinfogmachP pcinfogmach

    @dovid כתב בשאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?:

    ההפרש זניח פר פעולה

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

    @dovid כתב בשאלה בC#: מה הדרך הכי טובה להוציא גזירים מתוך קטע טקסט?:

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

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

  • 1
  • 2
  • 24
  • 25
  • 26
  • 27
  • 28
  • 33
  • 34
  • 26 / 34
  • התחברות

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

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