posted by 권오성의 Biomedical Engineering 2007. 10. 31. 17:33
이 문제때문에 하루종일 헤맷네요.

이건 라이센스가 있는 상용컴포넌트를 사용했을 때의 기록이 남아서입니다.

이 라이센스 부분을 모조리 삭제하시면 해결됩니다.

\Properties 밑에 "licenses.licx"에 들어있는 정보를 모조리 삭제합니다.

and then... 빌드합니다. ^^
posted by 권오성의 Biomedical Engineering 2007. 10. 10. 11:25
사용자 삽입 이미지

입사 후 웹관련 분야에서 일하고 싶었는데 본의 아니게 임베디드 장비 개발회사로 취업하여 장비와 맞물린 개발업무를 하고 있습니다.
'C#은 웹 전문언어야~'라고 생각하고 있었는데 얼마전 VOIP, IPTV 개발회사를 방문해보니 의외로 C#으로 개발하고 있는 회사가 많다는걸 알게 되었습니다. 특히 젊은 사장의 경우 말입니다.
다시 한번 C#의 무궁무진한 개발분야를 염두해 두시라고 올려봅니다.
posted by 권오성의 Biomedical Engineering 2007. 9. 20. 10:26
FlexGrid Insert/Remove Example
 
SUMMARY
 
이번에는 FlexGrid에서 특정 위치에 칼럼을 삽입하거나 삭제하는 방법을 배워볼 것이다. 엑셀에서 칼럼을 추가하거나 삭제할 때의 방식과 비슷하도록 하기 위해 고정행 위에서 마우스 오른쪽 버튼을 클릭할 때 팝업 메뉴를 표시한 후 처리하도록 구성했다(아래 그림 참조). 추가가 가능한 칼럼은 과목 칼럼으로 한정한다.
사용자 삽입 이미지


 




BASIS

이 예제를 완성하려면 비주얼 베이직에서 팝업 메뉴를 표시하는 방법과 FlexGrid에서 칼럼을 추가하거나 삭제하는 간단한 방법에 대해 알아야 한다. 당연하게도(^^).... 참고문헌 [1], [2]에서 각 방법에 대한 친절한 설명을 찾을 수 있었다. 아래에 퍼왔으니 참고하시길...
 
 
Pop-Up Menus (참고문헌 [2]에서 가져왔음)

Visual Basic also supports pop-up menus, those context-sensitive menus that most commercial applications show when you right-click on an user interface object. In Visual Basic, you can display a pop-up menu by calling the form's PopupMenu method, typically from within the MouseDown event procedure of the object:
 
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, _
        X As Single, Y As Single)
    If Button And vbRightButton Then
        ' User right-clicked the list box.
        PopupMenu mnuListPopup
    End If
End Sub

The argument you pass to the PopupMenu method is the name of a menu that you have defined using the Menu Editor. This might be either a submenu that you can reach using the regular menu structure or a submenu that's intended to work only as a pop-up menu. In the latter case, you should create it as a top-level menu in the Menu Editor and then set its Visible attribute to False. If your program includes many pop-up menus, you might find it convenient to add one invisible top-level entry and then add all the pop-up menus below it. (In this case, you don't need to make each individual item invisible.) The complete syntax of the PopupMenu method is quite complex:
 
PopupMenu Menu, [Flags], [X], [Y], [DefaultMenu]
 

By default, pop-up menus appear left aligned on the mouse cursor, and even if you use a right-click to invoke the menu you can select a command only with the left button. You can change these defaults using the Flags argument. The following constants control the alignment: 0-vbPopupMenuLeftAlign (default), 4-vbPopupMenuCenterAlign, and 8-vbPopupMenuRightAlign. The following constants determine which buttons are active during menu operations: 0-vbPopupMenuLeftButton (default) and 2-vbPopupMenuRightButton. For example, I always use the latter because I find it natural to select a command with the right button since it's already pressed when the menu appears:
 

PopupMenu mnuListPopup, vbPopupMenuRightButton
 

The x and y arguments, if specified, make the menu appear in a particular position on the form, rather than at mouse coordinates. The last optional argument is the name of the menu that's the default item for the pop-up menu. This item will be displayed in boldface. This argument has only a visual effect; If you want to offer a default menu item, you must write code in the MouseDown event procedure to trap double-clicks with the right button.
 
 
 
ColPosition Property
Moves a given column to a new position.
 
Syntax
[form!]vsFlexGrid.ColPosition(Col As Long)[ = NewPosition As Long ]
 
Remarks
The Col and NewPosition parameters must be valid column indices (in the range 0 to Cols - 1), or an error will be generated.
When a column or row is moved with ColPosition or RowPosition, all formatting information moves
with it, including width, height, alignment, colors, fonts, etc. To move text only, use the Clip property instead.
The ColPosition property gives you programmatic control over the column order. You may also use the ExplorerBar property to allow users to move columns with the mouse.
 
 
IMPLEMENTATION
 
팝업 메뉴를 표시하는 이벤트로 MouseUp을 선택했다. 일단 마우스 오른쪽 버튼을 눌렀는지 확인한 후 다음으로 과목명 칼럼을 클릭했는지 확인한다. 두가지 조건을 모두 만족하면 엑셀의 동작방식과 비슷한 효과를 주기 위해 해당 칼럼을 모두 선택 상태로 만들고 팝업 메뉴를 표시한다.
 
Private Sub FG_MouseUp(Button As Integer, Shift As Integer, _
                       X As Single, Y As Single)
    If Button And vbRightButton Then
        '
과목명 셀을 클릭할 때만 팝업 메뉴를 표시한다.
        If (FG.MouseRow = 1) And (FG.MouseCol > 1) And (FG.MouseCol < FG.Cols - 2) Then
            '
선택한 느낌이 들도록....
            FG.Col = FG.MouseCol
            FG.Row = FG.MouseRow + 1
            FG.RowSel = FG.Rows - 1
            FG.ColSel = FG.MouseCol

            '
팝업 메뉴 표시함.
            PopupMenu mnuGridPopup
        End If
    End If
End Sub
 
 
"Insert Column" 메뉴를 선택하면 과목명을 입력받은 후 칼럼을 추가하고 양식을 유지시키기 위한 몇가지 작업을 추가로 처리한다. 핵심 코드는 굵게 표시한 2줄이다. 칼럼수를 늘린 후에 ColPosition 속성을 이용해서 추가된 칼럼(.Cols-1)을 사용자가 선택한 칼럼(.Col) 앞으로 이동시키는 것이다. 아주 간편하게 처리된다.
 
Private Sub mnuInsertColumn_Click()
    With FG
        ' insert column
        Dim str As String
        str = InputBox("
과목명을 입력하세요")
        If str <> "" Then
            .Cols = .Cols + 1          ' add column
            .ColPosition(.Cols - 1) = .Col    ' move into place

            .Cell(flexcpText, 1, .Col) = str
            .Cell(flexcpAlignment, 1, .Col) = flexAlignCenterCenter
            .Cell(flexcpText, 0, .Col) = "
과목"
        End If
    End With
End Sub
 
사용자 삽입 이미지
 
 
 
"Remove Column" 메뉴를 선택하면 사용자가 선택한 칼럼(.Col)을 마지막 칼럼(.Cols-1)으로 이동시킨 후에 칼럼의 수를 1만큼 감소시켜 삭제하는 효과를 준다. 어려울게 없다.
 
Private Sub mnuRemoveColumn_Click()
    With FG
        ' delete column
        .ColPosition(.Col) = .Cols - 1 ' move to right
        .Cols = .Cols - 1              ' delete column

        '
칼럼이 삭제됐으므로 계산을 다시 수행한다.
        Dim nTotal As Integer
        Dim dAverage As Single

        For i = 2 To .Rows - 1
            nTotal = .Aggregate(flexSTSum, i, 2, i, .Cols - 3)
            dAverage = .Aggregate(flexSTAverage, i, 2, i, .Cols - 3)

            .Cell(flexcpText, i, .Cols - 2) = CStr(nTotal)
            .Cell(flexcpText, i, .Cols - 1) = Format(dAverage, "#,##.0")
        Next
    End With
End Sub
 
 
지금까지 FlexGrid가 제공하는 기능 중 내가 주로 쓸 몇가지 기능 위주로 알아봤다. 매뉴얼을 살펴보니 이것 외에도 다양한 기능을 제공하는데, 그럼에도 불구하고 300달러의 가격 밖에 안되니 가격대 성능비가 뛰어난 제품이라 하겠다. 아주 마음에 든다.
 
 
REFERENCE
 
[1] VSFlexGrid 8.0 Manual, ComponentOne, 2005.
     - f:\ftp_root\program\develop\FlexGrid\VSFlexGrid8Manual2005.pdf
     - pp.269, FAQ: How can I add or delete a column at a given position?
[2] Francesco Balena, "Programming Microsoft Visual Basic 6.0", Microsoft Press, 1999.
     - Chapter 3. Intrinsic Controls, Menus.
 
Project Folder : D:\KDSONG\Study\Visual Basic\Controls\VSFlexGrid\FlexGridInsertRemove\
 
KEYWORDS : FlexGrid grid selection insert remove column copy paste 리드 복사 붙여넣기 선택 영역
열 칼럼 삽입 삭제
posted by 권오성의 Biomedical Engineering 2007. 8. 22. 13:46
아래와 같은 메시지가 나올 경우 소스에 다음과 같이 델이게이트 처리를 해주시면 해결됩니다.

사용자 삽입 이미지



//Delegate로 처리하는 부분
this.Invoke(new MethodInvoker(delegate()
{
*** 어쩌구 저쩌구 데이터를 뿌려주는 메소드 안의 내용.
}));

이렇게 하시면 위의 에러는 해결됩니다.
posted by 써니루루 2007. 7. 20. 17:21

.net Window form에서 컨트롤을 드래그 드롭하는 예제를 보면서 DragEnter와 DragDrop이벤트를 발췌해서 소개한다.


  /// <summary>
  /// The DragEnter event of the target control fires when the mouse enters
  /// a target control during a drag operation, and is used to determine if a drop
  /// will be allowed over this control.  This generally involves checking the type
  /// of data being dragged, the type of effects allowed (copy, move, etc.),
  /// and potentially the type and/or the specific instance of the source control that
  /// initiated the drag operation.
  ///
  /// This event will fire only if the AllowDrop property of the target control has
  /// been set to true.
  /// </summary>
  /// <param name="sender">The source of the event.</param>
  /// <param name="e">A DragEventArgs that contains the event data.</param>
  private void listBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
  {
   // Display some information about the DragDrop information in the
   // richTextBox1 control to show some of the information available.
   richTextBox1.Text = "Source Control: " + sourceControl.Name +
    "\r\nSource Control Type: " + sourceControl.GetType().Name +
    "\r\nAllowed Effect: " + e.AllowedEffect +
    "\r\nMouse Button: " + mouseButton.ToString() + "\r\n" +
    "\r\nAvailable Formats:\r\n";

   // Data may be available in more than one format, so loop through
   // all available formats and display them in richTextBox1.
   foreach (string availableFormat in e.Data.GetFormats(true))
   {
    richTextBox1.Text += "\t" + availableFormat + "\r\n";
   }

   // This control will use any dropped data to add items to the listbox.
   // Therefore, only data in a text format will be allowed.  Setting the
   // autoConvert parameter to true specifies that any data that can be
   // converted to a text format is also acceptable.
   if (e.Data.GetDataPresent(DataFormats.Text, true))
   {
    // Some controls in this sample allow both Copy and Move effects.
    // If a Move effect is allowed, this implementation assumes a Move
    // effect unless the CTRL key was pressed, in which case a Copy
    // effect is assumed.  This follows standard DragDrop conventions.
    if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move && (e.KeyState & ctrlKey) != ctrlKey)
    {
     // Show the standard Move icon.
     e.Effect = DragDropEffects.Move;
    }
    else
    {
     // Show the standard Copy icon.
     e.Effect = DragDropEffects.Copy;
    }
   }
  }

  /// <summary>
  /// The DragDrop event of the target control fires when a drop actually occurs over
  /// the target control.  This is where the data being dragged is actually processed.
  ///
  /// This event will fire only if the AllowDrop property of the target control has
  /// been set to true.
  /// </summary>
  /// <param name="sender">The source of the event.</param>
  /// <param name="e">A DragEventArgs that contains the event data.</param>
  private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
  {

   // Store the data as a string so that it can be accessed from the
   // mnuCopy and mnuMove click events.
   sourceData = e.Data.GetData(DataFormats.Text, true).ToString();

   // If the right mouse button was used, provide a context menu to allow
   // the user to select a DragDrop effect.  The mouseButton is recorded in the
   // MouseDown event of the source control.
   if (mouseButton == MouseButtons.Right)
   {
    // Show a context menu, asking which operation to perform.
    // The ProcessData() call is then made in the click event
    // of the mnuCopy and mnuMove menu items.  Show only those
    // menu items that correspond to an allowed effect.
    mnuCopy.Visible = ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy);
    mnuMove.Visible = ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move);
    contextMenu1.Show(listBox1, new Point(20,20));
   }
   else
   {
    // Set the deleteSource member field based on the Effect.
    // The Effect is preset in the DragEnter event handler.
    deleteSource = (e.Effect == DragDropEffects.Move);

    // The processing of the data is done in a separate call, since
    // this is also called from the click event of the contextMenu1 items.
    ProcessData();

   }
  }

posted by 써니루루 2007. 7. 19. 02:38
간단히 .NET 2.0 C# Windows form 으로 개발한 적금 계산하는 프로그램입니다.

적금이 얼마나 될지 궁금한 일이 많은데 가끔씩 한번 찾아보게 되서 동료가 만든 프로그램을 올려봅니다.

짧은 시간에 짠거라 많은 기능은 기대하지 말아주세용;
posted by 써니루루 2007. 7. 17. 20:21

제곱근을 구하기 위해서는 다음과 같은 공식을 만족합니다.


x = root(a) 라면

x^2 = a 입니다.

따라서 x = a/x가 됩니다.

이에 의해서

임의의 x에 의해서 a의 제곱근 값은

x < root(a) < a/x 거나
a/x < root(a) <x 의 범위에 있게 됩니다.

따라서 a와 a/x의 평균값을 구하는

(a+b)/2 공식을 이용해 x = (x + a/x)/2 의 식을 이용하면

대부분의 수는 10번을 돌기 이전에 루트 값을 구할 수 있습니다.

간단하게 아래 C#으로 코딩해본 소스입니다.

using System;
using System.Collections.Generic;
using System.Text;

namespace Sqrt
{
    class SqrtMain
    {
        static double Sqrt(double aa, double xx)
        {
            try
            {
                for (int i = 0; i < 10; i++)
                    Console.WriteLine(xx = (xx + aa / xx) / 2);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return xx;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Sqrt(2341, 3));
        }
    }
}

posted by 써니루루 2007. 7. 16. 23:30
마방진 클래스다이어그램


오늘 1시간 시험으로 봤던 마방진 홀수 / 마방진 4의 배수 알고리즘을 이용한 마방진 소스

조금은 어렵지만 한번 분석해보시길 ^ ^

.NET 2.0 C# Console 응용 프로그램으로 제작했습니다.

사용 IDE는 Visual studio 2007 orcas


posted by 써니루루 2007. 7. 16. 17:35
11을 입력하면 1이 2개
그래서 12가 출력되고 다음은

1이 1개 2가 1개 이므로
1121이 출력되고

1이 2개 2가 1개 1이 1개 이므로
122111 이런식으로 증가되는 숫자 계산이 개미퀴즈이다.

이를 코딩으로 옮기는 작업..;
사용자 삽입 이미지


소스가 어렵지만;;

posted by 써니루루 2007. 7. 16. 16:30
클래스 다이어그램
예전에 짜본 야구게임 다시한번 짜봤다.

소스코드는 넘 쪼개놔서 압축해서 올렸으니 참고하시길..

Visual studio 2007 Orcas로 개발했으면 .NET Framework 2.0을 기준으로 제작했습니다.