검색결과 리스트
분류 전체보기에 해당되는 글 253건
- 2009.02.03 [C#] 프린트
- 2009.02.03 [Comsori]허브를 이용한 내부 네트워크 설정
- 2009.01.29 [ETC]SandCastle 사용(Help Document)
- 2009.01.19 [C#] 윈도우 좌표~
- 2009.01.16 [C#]Tray Icon
- 2009.01.15 [C#]volatile
- 2009.01.15 [Java]DCL(Double Checking Locking)
- 2009.01.14 [C#]스레드
- 2009.01.12 [C#]BackgroundWorker.
- 2009.01.09 [C#]Effective C# 인터넷이 되는데만 -_- 됩네다
글
흠.. 일단 간단한 프린트를 하기 위한 코드이다.
각 출력 결과에 따른 포멧 형식은 자신들이 정해야겠지만..
필자는 단지 출력 테스트를 한 것 뿐..
별 다른게 없다^_^
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace Print
{
public partial class Form1 : Form
{
private PageSettings m_PageSetting = null;
private Font m_subFont = new Font("굴림체",13);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
PageSetupDialog Psetup = new PageSetupDialog();
if (this.m_PageSetting == null)
this.m_PageSetting = new PageSettings();
Psetup.PageSettings = this.m_PageSetting;
Psetup.ShowDialog();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void button2_Click(object sender, EventArgs e)
{
try
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.PrintPageEvent);
if (this.m_PageSetting != null)
pd.DefaultPageSettings = this.m_PageSetting;
PrintPreviewDialog pdlg = new PrintPreviewDialog();
pdlg.Document = pd;
pdlg.ShowDialog();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
protected void PrintPageEvent(Object obj,PrintPageEventArgs pea)
{
Graphics g = pea.Graphics;
PrintDocument(g);
pea.HasMorePages=false;
}
private void PrintDocument(Graphics g)
{
g.FillRectangle(Brushes.White, 100, 50, 800, 600);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
Rectangle rect = new Rectangle(110, 130, 400, this.m_subFont.Height * 10);
g.DrawString(this.txt_Content.Text, this.m_subFont, Brushes.Black, rect);
}
private void button3_Click(object sender, System.EventArgs e)
{
try
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.PrintPageEvent);
if (this.m_PageSetting != null)
pd.DefaultPageSettings = this.m_PageSetting;
PrintDialog pdlg = new PrintDialog();
pdlg.Document = pd;
if (pdlg.ShowDialog() == DialogResult.OK)
{
pd.Print();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
설정
트랙백
댓글
글
다른거 필요없다;;
혹여나 모르시는 분들을 위해;;
필자도 오랜만에 해본 것이라서 잊을까봐;;
일단 허브에 해당 랜선을 다 꽂는다 -_- 물론 컴퓨터에도 꽂아야겠죠?
그 다음.. -_- DNS를 제외한 IP와 Subnetmask, Gateway를 입력하면.. 끝이다..
아 참고로 -_- 오라클이나 SQL같은 Datadase도 연결 가능하겠죠?^_^
네!! 가능합니다!!
설정
트랙백
댓글
글
SandCastle 설치 폴더에 Examples\generic아래에 Gui에 해당하는 실행 프로그램을 실행한 후
각 해당하는 항목에 Add 해 주면 된다.
-. Assembly And Comment Files
Assemblies : 작성할 대상의 DLL을 설정한다. 한 개의 DLL 또는 다수의 DLL, 폴더를 통째로 지정할 수 있다.
Comments : DLL 생성시 같이 생성되는 XML 코멘트 파일을 설정한다.
Comments파일을 지정하지 않더라도 Help File은 생성할 수 있지만, 이 경우 Syntax 외에 중요한 정보들은 Help File에 나타나지 않는다.
Dependent Assemblies : 해당 DLL에서 참조하는 DLL들을 지정한다. 참조하는 DLL을 지정하지 않을 경우 Help File은 생성되지 않는다.
-. Options
Name : Sandcastle 프로젝트 명이자, 출력될 폴더 명이 된다.
Presentation Style : Help File의 출력 타입을 설정한다.
Language ID : 생성될 Help File의 언어를 설정, 한국어는 1042
Default Targets : 출력할 대상 설정 -. Log : Build버튼을 눌러 실행하면 모든 로그가 이 항목에 나타난다. Build가 실패할 경우 로그를 통해 그 원인을 알 수 있다. 기본적으로 생성물은 C:\Program Files\Sandcastle\Examples 폴더아래에 Name에 설정한 폴더명으로 생성이 되며, generic.targets파일의 BuildDir 항목을 수정하여 변경할 수 있다. 기본적으로 Sandcastle은 사용되는 모든 파일을 복사하여 사용하고, 원본 파일은 사용하지 않는다. comments : 화면에서 지정한 코멘트파일(XML)이 이 폴더에 자동 복사되어 진다. dll : Assemblies 에서 지정한 DLL과 Dependent Assemblies 지정한 참조 파일들이 이 폴더에 자동으로 복사되어진다. hana, vs2005, prototype : Presentation Style에서 지정한 Style 폴더가 생성되고 최종 결과물(.chm파일)은 이 폴더 하위의 chm 폴더에 생성된다. http://www.codeplex.com/Sandcastle/Release/ProjectReleases.aspx?ReleaseId=13873
Build가 완료되면 지정된 폴더에 Name항목에 설정한 폴더가 생성된다.
SandCastle 파일은 아래 주소에 가면 받을 수 있다.
설정
트랙백
댓글
글
Rectangle tempRect = new Rectangle(screenRect.Right - 890, -8, 500, 0);
this.DesktopBounds = tempRect;
-_-ㅋ 말 그대로 좌표를 가지고 온답;;;
설정
트랙백
댓글
글
Tray Icon..
-_-a 뭐 기본적으로 그런 내용이다;;
언젠가 쉽게 쓸 일이 있겠지 ㅋㅋ
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;//이벤트 취소
this.WindowState = FormWindowState.Minimized;//폼 최소화
this.ShowInTaskbar = false;//작업표시줄 표시 금지
}
private void Tray_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Visible = true;
this.ShowInTaskbar = true; // 현재 프로그램을 테스크 바에 표시하게 한다.
this.WindowState = FormWindowState.Normal; // 폼을 윈도 상태를 normal
Tray.Visible = false; // 트레이의 아이콘을 보이지 않게 한다.
}
아 -_- contextmenu 넣어줄라면?
this.tray.contextmenu=this.contextmenu(생성한것) 해주기!
설정
트랙백
댓글
글
volatile 키워드는 동시에 실행 중인 여러 스레드에 의해 필드가 수정될 수 있음을 나타냅니다. volatile로 선언된 필드에는 단일 스레드를 통한 액세스를 전제로 하는 컴파일러 최적화가 적용되지 않습니다. 이렇게 하면 필드의 값을 항상 최신 상태로 유지할 수 있습니다.
일반적으로 volatile 한정자는 액세스를 serialize할 때 lock 문을 사용하지 않고 여러 스레드에서 액세스하는 필드에 사용됩니다.
volatile 키워드는 다음과 같은 형식의 필드에 적용할 수 있습니다.
-
참조 형식
-
안전하지 않은 컨텍스트의 포인터 형식. 포인터 자체는 volatile일 수 있지만 포인터가 가리키는 개체는 volatile일 수 없습니다. 즉, "volatile 개체에 대한 포인터"를 선언할 수 없습니다.
-
sbyte, byte, short, ushort, int, uint, char, float 및 bool 같은 정수 계열 형식
-
정수 계열 형식을 기반으로 한 열거형
-
참조 형식으로 알려진 제네릭 형식 매개 변수
volatile 키워드는 클래스 또는 구조체의 필드에만 적용할 수 있습니다. 지역 변수는 volatile로 선언할 수 없습니다.
[예제]
// csharp_volatile.cs
// Compile with: /target:library
class Test
{
public volatile int i;
Test(int _i)
{
i = _i;
}
}
출처 : MSDN
설정
트랙백
댓글
글
Syncronized를 할 경우 멀티 스레딩의 경우 효율적이지 못한 결과가 일어난다.
성능 저하를 말하는 것이다.
하지만 -_- DCL..
요놈을 이용하면 된답 -_-
이것은 인스턴스가 생성 되었는지 확인하고 난 다음 생성되지 않을때만 동기화를 한다
하지만 요놈은.. 1.4버전 이전은.. 되지 않는답 ㅠㅡㅠ
다음은 그 간단한 코드 예이다
public class Test{
private volatile static Test t;
private Test(){}
public static Test getInstance(){
if(t==null){
syncronized(Test.class){
if(t==null){
t = new Test();
}
}
}
}
}
설정
트랙백
댓글
글
여기서 Thread Class를 이용한 스레드는 과도한 문맥전환의 문제가 있을 수 있다.
이에 ThreadPool Class는 Pool을 구성하고 적정량의 스레드를 수용함으로
Thread Class를 이용한 것보다 좀 더 안정적이다.
Timer Class의 경우는 일정 시간마다 스레드를 자동으로 활성화 해 준다.
1.Thread Class
Thread th = new Thread(new ThreadStart(대상));
2. ThreadPool Class
ThreadPool.QueueUserWorkItem(new WaitCallBack(대상,null);
3. Timer Class
Timer timer = new Timer(new TimerCallBack(대상),null,시간,100);
설정
트랙백
댓글
글
myWorker.DoWork += new DoWorkEventHandler(myWorker_DoWork);
myWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(myWorker_RunWorkerCompleted);
myWorker.RunWorkerAsync() ;
먼저 BackgroundWorker는 다른 영역의 쓰레드를 실행 시키게 해 준다.
즉 메인 영역의 쓰레드가 아닌 별개의 영역을 말한다.
여기서 생성된 쓰레드는 DoWork 이벤트 핸들러에 의해서 작업이 수행된다.
만약 DoWork의 작업이 완료되거나 취소될 경우는 그 다음 RunWorkerCompletedEventHandler가 실행되어 쓰레드의 종료 또는 취소 후의 처리를 해 준다.
myWorker.RunWorkerAsync() 는 다른 영역에서 쓰레드가 실행되게 해 준다는 뜻이다.
설정
트랙백
댓글
글
http://www.synch3d.com/wiki/moin/moin.cgi/Effective_20C_23
찬찬~ 히 보면 많은 도움이 된다지요~
-_-/ 꼭 인터넷이 되는데만 보세요 ㅎㅎ
RECENT COMMENT