473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

910209 - Where's ResizeEnd event?

7
hi
i need to know when resize ends in my Silverlight application. how can i do that?
Apr 28 '12 #1

✓ answered by RhysW

according to the link i gave you there isnt a way to know when the browser is finished resizing, because "Remember the event doesn't really start or end, it just "happens" when a resize occurs" this is the logic of browser resizing, it doesnt need to know if the user is finished or not so there is no event for it, so the only way to know is if you write your own method for deciding if a resize is done, and a timer is a way to decide if it is finished or not, unfortunately there isnt a finish clause for the browser resize, it just resizes to co-ordinates repeatedly, think of it this way, when you resize the window it follows the mouse fluidly, not stays still til the mouse is released, because the resize event happens continuously, as there is no resizeend event for a browser


EDIT: read the coments on the timeout answer in stack overflow, many people agree there just is NO end event for resize, YOU have to determine when a resize session has finished

EDIT 2: http://www.quirksmode.org/dom/events/resize.html

this url explains when and how many resize events are triggered in each browser, if youre using win xp you can make each one (cept IE ofc ¬_¬) fire only when finished, but that would be a choice of the user and only for xp, so your timer idea seems to be not just the only way but the best way

10 3272
RhysW
70
Could you not use the FrameworkElement.SizeChanged Event? it is called multiple times each time it is resized but is also called for the very last resize event.

This MSDN explanation might be better

Additionally the SizeChanged Event handler may be what you are looking for MSDN link for more information about this one
Apr 30 '12 #2
hamidi
7
thanx 4 the reply, but i need a way to distinguish between multiple resize events coming and the last one. how can i realize this is the last resize and the user has ended resizing and has released the left mouse button? i need to know when this is triggered. the other resize events is not useful for me. i want to get only one resize event, the last one, every time user resizes the browser window.
Apr 30 '12 #3
RhysW
70
then the only solution i can think of it storing the size of the form or whatever, and everytime the mousebutton is released check to see if the size is different from the stored values, if it is store the new values for future comparisons and fire the rest of your code, i dont think there is an event that does exactly what you ask so you will have a hard time finding it unless you write something that does it for you. the event you are looking for is very specific and likely to be hard to find,

if you explain Why you need to know when its finished perhaps we can provide an alternative, but with the limited information were given its hard to suggest anything but whats already documeted, which apparently isnt what you need. though i appreciate sometimes you cant give away all your code sometimes its a lot of help to us all to be given an example, even if it is in pseudo code, is there a reason your code should only be fired on the final size changed event? or is it just you being picky about when it is fired?
Apr 30 '12 #4
hamidi
7
ok, let me explain the reason;
i'm showing a map inside browser. every time size is changed a request is sent to server for new map. it's not still optimized to just return the exposed part to the client. i send the whole image every time a request is received from client. this causes expensive resources to be consumed for nothing, while just the new size is important, the size which user is going to reach by mouse and have to generate several resize events. i want client send the last size to server and update the image at the end of resize.
about ur suggestion, unfortunately it's impractical, because i can't realize when mouse left button is released, because it appears in browser and browser events don't come to Silverlight applications' UserControl and their children.
Apr 30 '12 #5
RhysW
70
hmm, as i can't find a solution to this and no-one else on the other sites youve posted seems to know, might i make a suggestion to how to do this?

When the user finishes resizing the window you want to fire off and get a new map presumeably to fit in the windows new size correct? but what if the user only moves it a millimeter, perhaps by accident (which i do alot when im moving the mouse about) you arent going to want to send off for a new map then, especially if the map refreshes everytime its sent back the user would lose their location which would annoy them, not something you want for a customer product.

However you could use one of my solutions with a bit of tweaking, use one of the oens that checks if its resized, even if it fires off multiple times, BUT heres the trick, inside that event stick an if statement, ONLY send off for a new map at certain milestone sizes, e.g 1000 by 800px or 250 by 400 px (yes these sizes are stupid but its an example) if one of these milestones is breached send off for the map that will fit inside it, because lets face it if a user does only move the border by a small amount (a mm or 2) adjusting the map to by 2mm larger will hardly make any difference visually, and sending off for a new map thats 1mm larger is just silly if you ask me. (if youre having multiple milestones which i suggest then perhaps use a switch statement instead where CASE is using the length and height, if you just use multiple if statements then 400 x 400 would pass at 100x100 and get a map then pass at 200x200 and get a map then pass at 300x300 and egt a map, there would be three useless map calls, (unless your ifs also checked it was BELOW the next thresh-hold too) just a thought for you, perhaps just temporary until someone finds the proper way of doing it.
Apr 30 '12 #6
hamidi
7
thank u 4 ur suggestion
as far as i could understand, u mean i change the map size in grids of a value eg. 100 and if map size (width or height) gets different than before more than this value this causes me to send the request, right?
if so, i should choose a value which is not so small and not so big. if the value be large, the map is not got at expected values and if it be small, requests grow.
seems a good suggestion, but i doubt they agree (i work for a company). besides, the users are accurate in missing even such a neglectable margins. they expect when they maximize the browser window they get as large as map they can.
another method which i thought about was using a timer. if in a specified amount of time no resize occurred, then i decide to assume that resize has ended, and then send the request. in another words, i may wait for the new size to get stable. this reduces the number of resize events noticeably. but it's not as good as if i may know when the resize really done.
let's not surrender yet and think about another method i'm thinking about. may this help.
please take a look at:
http://www.codeproject.com/Questions...-not-triggered
just if i may grab "onmouseup", i may think i've found a solution. don't u think so? :)
Apr 30 '12 #7
RhysW
70
found you a solution, well, if you are happy with using javascript i have found you a solution! i found an answer on stack overflow, some javascript that uses your idea, it sees if ther is another change in size within 500ms of the last resize event, if not it updates the width and height textbox areas, but im sure you will be able to use it instead to resize the map, here is both a link and the code incase the question is deleted:

Expand|Select|Wrap|Line Numbers
  1. $(window).resize(function() {
  2.     if(this.resizeTO) clearTimeout(this.resizeTO);
  3.     this.resizeTO = setTimeout(function() {
  4.         $(this).trigger('resizeEnd');
  5.     }, 500);
  6. });
  7. You could have this is a base file somewhere, whatever you want to do...then you can bind to that new resizeEnd event you're triggering, like this:
  8.  
  9. $(window).bind('resizeEnd', function() {
  10.     //do something, window hasn't changed size in 500ms
  11. });
all this from Here
Apr 30 '12 #8
hamidi
7
thanx 4 ur favor,
as i said, timeout is a way like the grid way u suggested which hides unavailability of mouse up event. we will reach there in case we can't really find a solution to grab mouse up on the browser window's border. until then, i prefer not to use timeout and really find out when user releases the mouse left button. the way in the stackoverflow is just a simulation and ResizeEnd is not really received.
so let's concentrate again on the question i posted in codeproject link. someone has answered that this is not the event of the browser window. instead the handler is called because the client area is also resized and this is the client area's event that was raised. if so, there must be a way to access the browser window, its parent. is there a way?
Apr 30 '12 #9
RhysW
70
according to the link i gave you there isnt a way to know when the browser is finished resizing, because "Remember the event doesn't really start or end, it just "happens" when a resize occurs" this is the logic of browser resizing, it doesnt need to know if the user is finished or not so there is no event for it, so the only way to know is if you write your own method for deciding if a resize is done, and a timer is a way to decide if it is finished or not, unfortunately there isnt a finish clause for the browser resize, it just resizes to co-ordinates repeatedly, think of it this way, when you resize the window it follows the mouse fluidly, not stays still til the mouse is released, because the resize event happens continuously, as there is no resizeend event for a browser


EDIT: read the coments on the timeout answer in stack overflow, many people agree there just is NO end event for resize, YOU have to determine when a resize session has finished

EDIT 2: http://www.quirksmode.org/dom/events/resize.html

this url explains when and how many resize events are triggered in each browser, if youre using win xp you can make each one (cept IE ofc ¬_¬) fire only when finished, but that would be a choice of the user and only for xp, so your timer idea seems to be not just the only way but the best way
Apr 30 '12 #10
hamidi
7
u know, i hope we've thought right. if someone from Microsoft core members was asked, he could make us more certain about it. i wonder why browser must neglect WM_EXITSIZEMOVE while we've ResizeEnd in a form application?!
THEN, since i'm essentially a low-level programmer recently ported from C++ to C# and .Net, i'm thinking about a way to grab the original WM_EXITSIZEMOVE message. is there any WndProc in Silverlight? maybe i have to write an unmanaged low-level C++ code. i don't mind. just give me a possible way, and i will do my best for resolving this problem.
Apr 30 '12 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
1
by: Anders Both | last post by:
If i write to the event log like this: EventLog.WriteEntry("myPro","Applcation_Starty",EventLogEntryType.Informatio n); Where can i then see a list of thesse event, if i go into the event log...
3
by: Dan | last post by:
How do I find out what control a DragDrop event comes from? I initially presumed that it was the "sender" parameter. But this always seems to be the destination. Ie ... private void...
4
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
5
by: rn5a | last post by:
Consider the following user control which resides in Address.ascx: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)...
5
by: =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post by:
Hi there, I'm using Web Developer Express 2005 in my ASP.NET learning. I tried creating a simple aspx page using "code-behind" approach. I noticed that protected void Page_Load event method...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
0
by: xmlmahesh | last post by:
Hi, I have usercontrol I just want to know when user done with his resizing of the control (like ResizeEnd event). I am following below approach is this correct or something else I can do. Can...
1
by: Noah | last post by:
I'm trying to match against Event.type for KeyPress and ButtonPress. Currently I'm using integer constants (2 and 4). Are these constants defined anywhere? The docs talk about KeyPress and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.