퇴근5분전

전에 구현했던게 있으니.. 

https://aseuka.tistory.com/entry/%EC%BB%A8%ED%8A%B8%EB%A1%A4-%EB%B0%B0%EC%9C%A8-%EC%A1%B0%EC%A0%95-%EA%B3%B5%EC%8B%9D

 

컨트롤 배율 조정 공식...

ZoomInOut을 구현했는데... int[] factors = { 50, 100, 200 }; 을 combo에 넣고 옛날 값 = 100; 으로 초기값 사용. 현재 선택된 Factor = 50; { float 조정배율 = 현재값/ 옛날값 ; Control.Scale( new SizeF( 조정배율 , 조정배

aseuka.tistory.com

int factorIndex = 4;
float[] factors = new float[] { 0.2f, 0.4f, 0.6f, 0.8f, 1f, 1.2f, 1.4f, 1.6f, 1.8f, 2f, }; // 20 ~ 200%
float oldSizeFactor = 1f;

 

- ZoomOut

factorIndex--;
if (factorIndex < 0) factorIndex = 0;              
pnlBoard.Scale(new SizeF(  factors[factorIndex] / oldSizeFactor,   factors[factorIndex] / oldSizeFactor));

pnlBoard.Invalidate();
oldSizeFactor = factors[factorIndex];

 

// 배율 조정시 스크롤이 있는 상태일때!! 왼쪽상단(left, top)에 판넬을 맞춰줘야 하니까.. 

int hv = pnlOutBorder.HorizontalScroll.Value;
int vv = pnlOutBorder.VerticalScroll.Value;
pnlBoard.Left = -hv;
pnlBoard.Top = -vv;

 

- ZoomIn

 factorIndex++;
 if (factors.Length <= factorIndex) factorIndex = factors.Length-1;             
 pnlBoard.Scale(new SizeF(factors[factorIndex] / oldSizeFactor, factors[factorIndex] / oldSizeFactor));

 pnlBoard.Invalidate();
 oldSizeFactor = factors[factorIndex];          

 

// 배율 조정시 스크롤이 있는 상태일때!! 왼쪽상단(left, top)에 판넬을 맞춰줘야 하니까.. 

int hv = pnlOutBorder.HorizontalScroll.Value;  
int vv = pnlOutBorder.VerticalScroll.Value;
pnlBoard.Left = -hv;
pnlBoard.Top = -vv;

 

** 함수, 호출 화살표등을 직접 드로잉 처리하고 있어서

이에 대한 크기조정도 적용해줘야 한다. 

파일, 함수, 화살표등을 그리기전에... 

 e.Graphics.ScaleTransform( factors[factorIndex], factors[factorIndex] );

배율 조정을 해준다.

 

 

그리고 마우스 다운 이벤트에서 파일과 함수인경우 이름을 복사!

호출하는 함수부분에서는 대상 함수로 화살표의 색을 바꿔주기 때문에... 배율조정시 마우스 다운 위치를 계산해줘야 하는데... 

Point pt = new Point((int)((float)e.Location.X / oldSizeFactor), (int)((float)e.Location.Y / oldSizeFactor));