달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형

간단한 설정을 저장하고 지정할때 ini파일같은거도 만들기는 하는데

간단하게 설정하는 방법있다.

Settings.settings에 값을 넣어두고 설정하고 빼내기가 가능하다.

이렇게 설정을 하고

이런식으로 사용하면 된다. 

Posted by 유령회사
|
반응형
1
2
3
4
5
6
7
8
9
10
11
12
private void btnDel_Click(object sender, EventArgs e)
{
    this.dataGridView1.AllowUserToAddRows = false;
           
    //데이터그리드뷰 속성중 SelectionMode의 속성을 FullRowSelect로 바꿔주면 
//dataGridView1.SelectedRows 동작함
    foreach (DataGridViewRow item in this.dataGridView1.SelectedRows)
    {              
        dataGridView1.Rows.Remove(item);
    }
 
    this.dataGridView1.AllowUserToAddRows = true;
}
cs

DataGridView의 자동으로 한줄을 추가하는 속성을 사용할려고 하니 삭제시 오류가 발생해서

잠시꺼두고 다시 켜주면 해결됨

Posted by 유령회사
|
반응형

DataGridView 사용시 SelectedRows 속성을 사용할려고 하면

데이터그리드뷰 속성중 SelectionMode의 속성을 FullRowSelect로 바꿔주야 동작함

Posted by 유령회사
|
반응형

출처

http://csharphelper.com/blog/2021/10/remove-all-event-handlers-from-an-event-in-c/

Posted by 유령회사
|
반응형

//출처 https://hellocho.tistory.com/11
//추가 문자 인코딩이기 때문에 인코딩 등록자 지정이 필요하다고 함
var client = new WebClient();
int euckrCode = 51949;
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
client.Encoding = System.Text.Encoding.GetEncoding(euckrCode);

string strHtml = client.DownloadString("http://kind.krx.co.kr/corpgeneral/corpList.do?method=download");








Posted by 유령회사
|
반응형

   생성자에서 생성자 호출하고 싶을때는 위 이미지처럼

   원하는 생성자에 : this( 파라메타 ) 이런식으로 적어 주면된다.

Posted by 유령회사
|
반응형

http://csharphelper.com/blog/2019/07/draw-text-with-colors-reversed-in-its-upper-and-lower-halves-in-c/

 

 

private void Button1_Click(object sender, EventArgs e)
        {            
            DrawSplitText(this.pictureBox1.CreateGraphics()
                        , this.textBox1.Text
                        , new Font(this.textBox1.Font.FontFamily, 20, FontStyle.Bold)
                        , new Rectangle(this.pictureBox1.Location, this.pictureBox1.Size)
                        , new SolidBrush(Color.Black)
                        , new SolidBrush(Color.White));
        }

        // Draw split text centered in the indicated rectangle.
        private void DrawSplitText(Graphics gr,
            string text, Font font, Rectangle rect,
            Brush top_fg_brush, Brush bottom_fg_brush)
        {
            // Make bitmaps holding the text in different colors.
            Bitmap bm_top = new Bitmap(rect.Width, rect.Height);
            Bitmap bm_bottom = new Bitmap(rect.Width, rect.Height);

            // Make a StringFormat to center text.
            using (StringFormat sf = new StringFormat())
            {
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;

                using (Graphics gr_top = Graphics.FromImage(bm_top))
                {
                    gr_top.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                    gr_top.FillRectangle(bottom_fg_brush, rect);
                    gr_top.DrawString(text, font, top_fg_brush, rect, sf);
                }

                using (Graphics gr_bottom = Graphics.FromImage(bm_bottom))
                {
                    gr_bottom.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                    gr_bottom.FillRectangle(top_fg_brush, rect);
                    gr_bottom.DrawString(text, font, bottom_fg_brush, rect, sf);
                }
            }

            // Fill the top and bottom halves of the rectangle.
            RectangleF top_rect = new RectangleF(
                rect.X, rect.Y, rect.Width, rect.Height / 2f);
            using (TextureBrush brush = new TextureBrush(bm_top))
            {
                gr.FillRectangle(brush, top_rect);
            }

            RectangleF bottom_rect = new RectangleF(
                rect.X, top_rect.Bottom, rect.Width, rect.Height / 2f);
            using (TextureBrush brush = new TextureBrush(bm_bottom))
            {
                gr.FillRectangle(brush, bottom_rect);
            }

            bm_top.Dispose();
            bm_bottom.Dispose();
        }
Posted by 유령회사
|
반응형
private Image ScaleImage(Image image, float scale)
{
	if (image == null) return null;

	int width = (int)(image.Width * scale);
	int height = (int)(image.Height * scale);

	Bitmap bm = new Bitmap(width, height);
	using (Graphics gr = Graphics.FromImage(bm))
	{
		gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
		Rectangle dest_rect = new Rectangle(0, 0, width, height);
		Rectangle source_rect = new Rectangle(0, 0, image.Width, image.Height);
		gr.DrawImage(image, dest_rect, source_rect, GraphicsUnit.Pixel);
	}

	return bm;
}

'프로그래밍 > C#' 카테고리의 다른 글

[ C#] 생성자에서 생성자 호출하기  (0) 2020.05.18
[C#]텍스트 배경 반반따로 그리기?  (0) 2019.07.17
[C#]듀얼 스크린 Capture  (0) 2019.06.11
[C#]OpenCvSharp 이미지 로드  (0) 2019.02.05
[C#] 둥근 버튼  (0) 2019.01.12
Posted by 유령회사
|
반응형
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyCapture
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            Rectangle rc = new Rectangle();
            foreach (var item in Screen.AllScreens)
            {
                rc = Rectangle.Union(rc, item.Bounds);
            }

            Bitmap bmp = new Bitmap(rc.Width, rc.Height);
            using (Graphics g = Graphics.FromImage(bmp))
            {                
                g.CopyFromScreen(rc.Location, Point.Empty, bmp.Size);
            }
            bmp.Save(@"sshot.png", ImageFormat.Png);
        }
    }
}

'프로그래밍 > C#' 카테고리의 다른 글

[C#]텍스트 배경 반반따로 그리기?  (0) 2019.07.17
[C#]이미지 크기 변경  (0) 2019.06.23
[C#]OpenCvSharp 이미지 로드  (0) 2019.02.05
[C#] 둥근 버튼  (0) 2019.01.12
[C#]파일 확장자로 구분해서 image 저장  (0) 2018.12.15
Posted by 유령회사
|
반응형

OpenCvSharp nuget에서 설치



PictureBoxIpl 적당히 배치하고


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;
using OpenCvSharp.Extensions;
 
 
namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void btnOpenPic_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.DefaultExt = "jpg";
 
            //fileDialog.Filter = "JPG|*.jpg|JPEG|*.jpeg|BMP|*.bmp|PNG|*.png";
            fileDialog.Filter = "Images Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg;*.jpeg;*.gif;*.bmp;*.png";
            
            fileDialog.Multiselect = false;
            
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {                
                foreach (string filePath in fileDialog.FileNames)
                {                    
                    using (Mat mat = new Mat(filePath, ImreadModes.AnyColor))
                    {
                        pictureBoxIpl1.ImageIpl = mat;
                    }
                }
            }
        }
    }
}
 
cs

'프로그래밍 > C#' 카테고리의 다른 글

[C#]이미지 크기 변경  (0) 2019.06.23
[C#]듀얼 스크린 Capture  (0) 2019.06.11
[C#] 둥근 버튼  (0) 2019.01.12
[C#]파일 확장자로 구분해서 image 저장  (0) 2018.12.15
[C#]CommonOpenFileDialog  (0) 2018.11.27
Posted by 유령회사
|