[CLOSED] Center desktop shortcuts on desktop

  1. #1

    [CLOSED] Center desktop shortcuts on desktop

    Some customers can make you crazy :)

    I'm creating my shortcuts in codebehind like this:

     DesktopShortcut sc = new DesktopShortcut
                    {
                        X = Conversie.ToString(xPosition),
                        Y = Conversie.ToString(yPosition),
                        ModuleID ="dmname",
                        Text = "shortcuttext",
                        IconCls = "iconclasss"
                     };
                    MyDesktop.Shortcuts.Add(sc);
    Starting from the left top corner --> adding some pixels on x and y to place the different desktopshortcuts on the right place. Works like a charm.
    Suddenly a customer want to center these shortcuts. They need to be centered also after windowresize.

    Need some ideas... :)

    Martin
    Last edited by Daniil; Jul 18, 2011 at 2:54 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Unfortunately, there is no such functionality. So, you need to implement it manually.

    There is the .initShortcuts() function within the Desktop's sources.

    I can suggest you to override it as you wish directly into the Desktop's scripts.

    The following example will help you to start.

    This example is just to debug the .initShortcouts() function:

    1. Run the page under VS + IE
    2. Resize a browser window
    3. You are within the .initShortcuts() function

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
        <script type="text/javascript">
            var myInitShortcuts = function () {
                var shortcuts = Ext.get('x-shortcuts');
                if (shortcuts) {
                    debugger;
                    this.col = { index: 1, x: 10 };
                    this.row = { index: 1, y: 10 };
                    var items = shortcuts.query('dt');
                    for (var i = 0, len = items.length; i < len; i++) {
                        var item = Ext.Element.get(items[i]),
                            x = item.getAttributeNS('ext', 'X'),
                            y = item.getAttributeNS('ext', 'Y');
    
                        if (Ext.isEmpty(x) || Ext.isEmpty(y)) {
                            this.setPosition(item);
                        }
                        else {
                            x = eval(x.replace('{DX}', 'Ext.lib.Dom.getViewWidth()'));
                            y = eval(y.replace('{DY}', '(Ext.lib.Dom.getViewHeight() - taskbarEl.getHeight())'));
                            item.setXY([x, y]);
                        }
                    }
                }
            };
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
            <ext:Desktop ID="Desktop1" runat="server" BackgroundColor="black">
                <Modules>
                    <ext:DesktopModule ModuleID="DesktopModule1" WindowID="DesktopWindow1" />
                </Modules>
                <Shortcuts>
                    <ext:DesktopShortcut ModuleID="DesktopModule1" Text="Shortcut"  />
                </Shortcuts>
                <StartMenu>
                    <Items>
                        <ext:MenuItem Text="DesktopWindow1">
                            <Listeners>
                                <Click Handler="DesktopWindow1.show();" />
                            </Listeners>
                        </ext:MenuItem>
                    </Items>
                </StartMenu>
                <Listeners>
                    <Ready Handler="Ext.EventManager.removeResizeListener(this.desktop.initShortcuts, this.desktop);
                                    Ext.EventManager.onWindowResize(myInitShortcuts, this.desktop);" />
                </Listeners>
            </ext:Desktop>
            <ext:DesktopWindow ID="DesktopWindow1" runat="server" Title="DesktopWindow" />
        </form>
    </body>
    </html>
  3. #3
    Thanx Daniil,

    I will look into your example..and try to achieve what the customer wants :)

    Martin

Similar Threads

  1. Desktop Shortcuts
    By fabiomarcoseuzebio in forum 1.x Help
    Replies: 1
    Last Post: Sep 06, 2012, 2:23 PM
  2. Replies: 5
    Last Post: Nov 14, 2011, 9:28 AM
  3. Refreshing desktop control from desktop window
    By AnilVelamuri in forum 1.x Help
    Replies: 0
    Last Post: May 26, 2010, 7:53 AM
  4. Adding shortcuts on desktop
    By joao.msdn in forum 1.x Help
    Replies: 1
    Last Post: Apr 13, 2010, 9:06 AM
  5. Replies: 1
    Last Post: Mar 17, 2009, 1:17 AM

Tags for this Thread

Posting Permissions