'event'에 해당되는 글 9건
- 2009/07/16 2009년 07월 16일 - sunyruru 미투데이 일기장
- 2009/05/18 Silverlight – bubbling events (2)
- 2009/05/08 Javascript – 이벤트 추가
- 2009/02/11 sunyruru의 미투데이 - 2009년 2월 10일
- 2009/01/05 [js]브라우저의 오른쪽 상단의 X표시를 누르거나 창을 닫을때 이벤트 잡기! (1)
- 2008/05/06 SMTP 서비스가 재시작 시 작동하지 않는 오류
- 2008/03/06 드래그 드랍(Drag and Drop) 으로 개체의 정보 다루기
- 2007/08/10 엔터키 누르면 특정 버튼 클릭하게 하기 (1)
- 2007/07/20 C# Drag & Drop event handling
- OCS의 DMessengerEvents::OnContactStatusChange (http://msdn.microsoft.com/en-us/library/bb758796.aspx) . Scriptable 이라고 써있으니 스크립트에서 처리가능해야 하는데 왜 안되냐..ㅡㅡ2009-07-08 16:06:25
- 자바스크립트 유용한 함수들을 잘 정리해둔 사이트를 찾았당… 유후~ 나중에도 쓸만한 내용이 많겠군.. 훗~2009-07-14 19:19:55
- 브라우져의 주소 부분에 javascript:var w=window.document;var p=w.plugins;for(var i in w)w.writeln(i+“=”+eval('w.'+i)+“<br/>”); 이렇게 실행하면 document개체의 값을 볼 수 있네요.2009-07-15 10:12:29
- 아오.. C++ ATL COM 개체에서 받은 이벤트를 어떻게 JavaScript로 콜백해줘야 하는거냐 ㅠㅠ어렵다 제기랄…2009-07-15 14:47:00
- 우리 진상.. 얼마나 피곤했으면 신입이 한시간을 라커룸에서 업무시간에 잤을까 -_ -;; 그래도 조심해야지 신입인데.. 조심좀 해~2009-07-15 16:48:19
- Silverlight 2 Unit Test를 .net계의 멋진 행님 스캇 구슬이 님이 만드셨나부다. Visual Studio랑 연계도 되고.. Silverlight 2.0 용으로 브라우져에서 GUI 환경으로 유닛 테스트가 되니 꽤 좋은것 같다…2009-07-15 20:08:39
이 글은 sunyruru님의 2009년 7월 8일에서 2009년 7월 15일까지의 미투데이 내용입니다.
'FunFun' 카테고리의 다른 글
| 2009년 7월 22일 - sunyruru 미투데이 일기장 (0) | 2009/07/23 |
|---|---|
| 2009년 7월 16일 - sunyruru 미투데이 일기장 (0) | 2009/07/17 |
| 2009년 07월 16일 - sunyruru 미투데이 일기장 (0) | 2009/07/16 |
| sunyruru의 미투데이 - 2009년 3월 22일 (0) | 2009/03/23 |
| sunyruru의 미투데이 - 2009년 3월 20일 (0) | 2009/03/21 |
| sunyruru의 미투데이 - 2009년 3월 13일 (0) | 2009/03/14 |
이번 내용은 실버라이트에서 개체가 중첩되어 있을 때 이벤트가 중첩(버블링, Bubbling)되는 현상을 막기 위한 방법인데요.
두서 없이 작성한 내용이라 저도 무슨 소린지 모르겠네요 - _-;;
중요한 내용은 4~5번 내용을 살펴보시면 이해가 되실거에요.
1. XAML 코드
<UserControl x:Class="BubblingEvents.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Grid x:Name="SubPanel" Margin="28,20,33,26" Background="#FF4084CE" Grid.Row="3">
<Ellipse x:Name="Ellipse1" Margin="47,48,129,43" Stroke="#FF000000">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF0D4C07"/>
<GradientStop Color="#FF239E16" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse x:Name="Ellipse2" Margin="146,79,61,43" Stroke="#FF000000">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF490B68"/>
<GradientStop Color="#FFF56DFD" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
<TextBlock x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
</UserControl>
2. C# Code
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace BubblingEvents
{
public partial class Page : UserControl
{
private Int16 _sequence = default(Int16);
public Page()
{
InitializeComponent();
InitHandlers();
}
private void InitHandlers()
{
this.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
this.SubPanel.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
this.Ellipse1.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
this.Ellipse2.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
}
void MouseLeftClickHandler(Object sender, MouseButtonEventArgs e)
{
Trace((sender as FrameworkElement).Name);
}
private void Trace(String name)
{
this.Output.Text = String.Format("[{0}] {1}\n{2}", ++_sequence, name, this.Output.Text);
}
}
}
3. 버블링이 발생한다
(클릭순서 1. 파란배경, 2 녹색원, 3보라원)
4. 버블링 제거 코드
Ellipse를 포함하고 있는 Grid의 이벤트에서만 별도로 이벤트를 작성해 준다
private void InitHandlers()
{
this.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
this.SubPanel.MouseLeftButtonDown += new MouseButtonEventHandler(SubPanel_MouseLeftButtonDown);
this.Ellipse1.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
this.Ellipse2.MouseLeftButtonDown += new MouseButtonEventHandler(MouseLeftClickHandler);
}
void SubPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Trace((sender as FrameworkElement).Name);
e.Handled = true;
}
5. 상위의 개체가 하위의 개체의 이벤트 전달을 막지 않도록 설정
IsHitTestVisable 속성을 이용하여 사용자의 마우스나 키보드 등의 입력이 전달되는 것을 막지 않을 수 있다.
…
<Ellipse x:Name="Ellipse2" Margin="146,79,61,43" Stroke="#FF000000" IsHitTestVisible="False">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF490B68"/>
<GradientStop Color="#FFF56DFD" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Grid>
<TextBlock x:Name="Output" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
…
'.NET > Silverlight' 카테고리의 다른 글
| Silverlight – Custom control (0) | 2009/07/03 |
|---|---|
| Silverlight Custom control (0) | 2009/06/23 |
| Silverlight – bubbling events (2) | 2009/05/18 |
| Silverlight – DispatcherTimer , Clock (0) | 2009/05/12 |
| Silverlight – Dynamic Page load (0) | 2009/05/10 |
| Silverlight – Host Settings (0) | 2009/05/10 |
웹 페이지에서 컨트롤이나 Element에 이벤트를 추가하기 위해 Cross-browser를 고려해야 한다.
이럴 때 다음과 같이 코드를 작성하면 되겠다.
if (window.addEventListener)
{
window.addEventListener('click', SomeClass.ClickEventMethod , false);
}
else
{
window.attachEvent('onclick', SomeClass.ClickEventMethod );
}
특정 타겟 브라우저로 개발을 하더라도 위와 같이 작업하는 습관은 정말 중요할 것 같다.
'Web > JavaScript' 카테고리의 다른 글
| Ext JS 3.0 (0) | 2009/09/23 |
|---|---|
| Javascript : Microsoft OS & Internet Explorer Agent Check (0) | 2009/07/20 |
| Javascript – 이벤트 추가 (0) | 2009/05/08 |
| 스크립트에서 클라이언트 프로그램 실행 시키는 방법 (3) | 2009/02/17 |
| [js]브라우저의 오른쪽 상단의 X표시를 누르거나 창을 닫을때 이벤트 잡기! (1) | 2009/01/05 |
| DHTML을 빠르게 하는 12가지 튜닝 (0) | 2008/07/14 |
- Microsoft OCS Event Virtual Launch Event가 등록되었네요~ 새로나온 Microsoft의 UC 핵심으로 추진하는 OCS의 R2버전을 시험해볼 수 있습니다~2009-02-10 14:23:05
이 글은 sunyruru님의 2009년 2월 10일의 미투데이 내용입니다.
'FunFun' 카테고리의 다른 글
| sunyruru의 미투데이 - 2009년 2월 27일 (0) | 2009/02/28 |
|---|---|
| sunyruru의 미투데이 - 2009년 2월 20일 (0) | 2009/02/21 |
| sunyruru의 미투데이 - 2009년 2월 10일 (0) | 2009/02/11 |
| sunyruru의 미투데이 - 2009년 2월 9일 (0) | 2009/02/10 |
| 아내가 마법을 쓴다 - 프리츠 라이머 (0) | 2008/06/14 |
| 당신의 성공의 기준은 무엇인가요? - 광수생각 (0) | 2008/03/05 |
창의 오른쪽 상단의 X표시를 누르거나 창을 닫을때 이벤트 잡기
비밀은 onbeforeunload 이벤트 였군요.
아래와 같은 코드 작성시 창을 닫게 되면 아래의 그림이 나타납니다.
==============================================================================
<HTML>
<HEAD>
<SCRIPT>
function closeIt()
{
event.returnValue = "푸클클 정말 닫아? 진짜루?";
}
</SCRIPT>
</HEAD>
<BODY onbeforeunload="closeIt()">
<a href="http://www.microsoft.com">Click here to navigate to
www.microsoft.com</a>
</BODY>
</HTML>
==============================================================================
간단하네요..
까먹지만 않는다면 ㅎㅎ
'Web > JavaScript' 카테고리의 다른 글
| Javascript – 이벤트 추가 (0) | 2009/05/08 |
|---|---|
| 스크립트에서 클라이언트 프로그램 실행 시키는 방법 (3) | 2009/02/17 |
| [js]브라우저의 오른쪽 상단의 X표시를 누르거나 창을 닫을때 이벤트 잡기! (1) | 2009/01/05 |
| DHTML을 빠르게 하는 12가지 튜닝 (0) | 2008/07/14 |
| 다양한 HTML 소스복사 / 마우스 우클릭 방지 모음 (0) | 2008/05/23 |
| 드래그 드랍(Drag and Drop) 으로 개체의 정보 다루기 (0) | 2008/03/06 |
SMTP가 재시작될 때 작동하지 않는 오류가 발생할 수 있습니다.
이러한 경우 다음과 같이 kb326740 문서를 확인하고 처리하시면 됩니다.
http://support.microsoft.com/kb/326740
Event ID 418 is logged when you restart the SMTP service
View products that this article applies to.
Article ID : 326740
Last Review : October 25, 2007
Revision : 2.2
This article was previously published under Q326740
Important This article contains information about editing the metabase. Before you edit the metabase, verify that you have a backup copy that you can restore if a problem occurs. For information about how to do this, see the "Configuration Backup/Restore" Help topic in Microsoft Management Console (MMC).
'System > OS' 카테고리의 다른 글
| VMPlayer, VMWare에서 3D 가속화 설정 사용법 (1) | 2008/07/17 |
|---|---|
| 특정 폴더 주기적인 자동 백업 (0) | 2008/07/01 |
| SMTP 서비스가 재시작 시 작동하지 않는 오류 (0) | 2008/05/06 |
| Exchange를 설치하지 않고 AD 스키마 확장 (0) | 2008/03/27 |
| Microsoft Windows Server 2008 (0) | 2007/11/14 |
| Windows XP 기본 압축폴더 사용 안하려면.. (0) | 2007/10/17 |
드래그 드랍 이벤트에 따라 개체에 데이터를 담아 처리할수 있는 DHTML 예제입니다.
쇼핑몰의 쇼핑카트 등에 이용할 방향이 크네요.
소스 내용은 직접 위 링크를 참조하셔서 확인해 주셔야 할 것 같습니다.
'Web > JavaScript' 카테고리의 다른 글
| DHTML을 빠르게 하는 12가지 튜닝 (0) | 2008/07/14 |
|---|---|
| 다양한 HTML 소스복사 / 마우스 우클릭 방지 모음 (0) | 2008/05/23 |
| 드래그 드랍(Drag and Drop) 으로 개체의 정보 다루기 (0) | 2008/03/06 |
| JavaScript Obejct 형식의 데이터를 덤프하여 내용 보기 (0) | 2008/02/12 |
| innerHTML 을 사용할 때 속도를 위한 주의사항 (2) | 2008/02/01 |
| Yahoo Map API (1) | 2008/01/15 |
[Page.GetPostBackEventReference()를 이용한 doPostBack]
자바스크립트로 behind code의 메서드를 실행하고 싶은 경우가 있다.
이럴 경우 보통은 스크립트에서 __doPostBack() 메서드를 정의해서 사용하곤 한다. 하지만, 이는 좋지 못한 방법이다.
__doPostBack() 메서드는 .net에서 자동 생성하는 부분으로, 개발자가 별도로 작성하여도 바뀔 가능성이 있다. 또한, .net에서 자동으로 생성하지 않는 경우도 발생한다.
스크립트로 behind code의 메서드를 실행하고 싶을 때는 아래와 같은 방법을 권한다.
<%= Page.GetPostBackEventReference( WebFormButton ) %>
이는 postback이 발생하는 WebForm Control을 매개변수로 넘겨주면, 자동으로 __doPostBack()을 생성해 준다.
ex)
[Page.aspx]
btnOne -> HTML Input 컨트롤 - visible
<script language="javascript">
function btnOneClick()
{
<%= Page.GetPostBackEventReference( btnTwo ) %>
}
</script>
<input type="button" onclick="btnOneClick()">
[Page.aspx.cs]
btnTwo -> WebForm Button 컨트롤 - invisible
private void btnTwo_Click(...)
{
...
}
[추가사항 1]
onunload 이벤트시 처리하려면, btnTwo를 LinkButton으로 설정한다.
'.NET > ASP.NET' 카테고리의 다른 글
| ASP.NET on Ruby on Rails (0) | 2008/03/14 |
|---|---|
| ASP.NET 503 서버 사용량이 많습니다. (0) | 2007/11/02 |
| 엔터키 누르면 특정 버튼 클릭하게 하기 (1) | 2007/08/10 |
| ASP.NET Web Applications (.NET 3.0) (0) | 2007/08/09 |
| ASP.NET 페이지 실행 주기 (0) | 2007/08/09 |
| Understanding ASP.NET View State (0) | 2007/08/08 |
.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();}
}
'.NET > C#' 카테고리의 다른 글
| 2차원 행렬의 계산 프로그램 (0) | 2007/07/25 |
|---|---|
| 롯또 가장많이 나온 숫자 찾기 (0) | 2007/07/25 |
| C# Drag & Drop event handling (0) | 2007/07/20 |
| Microsoft Visual C# .NET을 통해 Microsoft Excel을 자동화하는 방법 (0) | 2007/07/19 |
| 적금계산 프로그램 (1) | 2007/07/18 |
| C# SQRT 제곱근 구하기 (0) | 2007/07/16 |

이올린에 북마크하기
이올린에 추천하기



Prev




