[CLOSED] TrayClock sample

  1. #1

    [CLOSED] TrayClock sample

    Hi,

    I will highly appreciate if someone show me sample for trayclock showing different time that server time. I'm working on project where i receive the time from a server via signalR, and i would like to show that data using trayclock.

    Thanks,
    BOVO
    Last edited by Daniil; Jan 21, 2015 at 12:45 PM. Reason: [CLOSED]
  2. #2
    Alright, there you go! It was an interesting task to learn how to override ext.net methods, I really learned a lot here. :) Didn't even know there was a desktop tag that could have a taskbar with a trayclock inside before your question.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="trayClock.aspx.cs" Inherits="ExtNetPlayground.trayClock" %>
    <%@ Import Namespace="x=Ext.Net" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script type="text/javascript">
            // Fill these javascript values with the data from your clock source.
            // If from code behind, you can just fill an hidden dateTime field and parse it here.
            var yearnow = 2018,
                monthnow = 11,
                daynow = 23,
                hoursnow = 15,
                minsnow = 11,
                secsnow = 43;
    
            Ext.define('Ext.ux.desktop.TrayClock', {
                override: 'Ext.ux.desktop.TrayClock',
                updateTime: function () {
                    var me = this;
                    var addsecs = me.refreshInterval / 1000;
                    secsnow += addsecs;
    
                    while (secsnow >= 60) {
                        minsnow++;
                        secsnow -= 60;
                    }
                    while (minsnow >= 60) {
                        hoursnow++;
                        minsnow -= 60;
                    }
                    while (hoursnow >= 24) {
                        daysnow++;
                        hournow -= 24;
                    }
                    // Okay, I guess you got the idea, we are just updating the time client-side, to avoid much requests for your custom time. :)
                    // There are plenty of javascript samples that close to correctly increment time that you can find on google. 
                    // Well and this is enough if you are just showing hour minute and second. :)
    
                    var time = Ext.Date.format(new Date(yearnow, monthnow, daynow, hoursnow, minsnow, secsnow, 0), me.timeFormat), 
                        text = me.tpl.apply({ time: time });
                    if (me.lastText != text) {
                        me.setText(text); me.lastText = text;
                    }
                    me.timer = Ext.Function.defer(me.updateTime, me.refreshInterval, me);
                }
            });
        </script>
        <script runat="server">
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ext:ResourceManager runat="server" />
            <ext:Desktop runat="server" ID="tbr1">
                <TaskBar>
                    <TrayClock runat="server" ID="tck1" TimeFormat="H:i:s" RefreshInterval="1000" />
                </TaskBar>
            </ext:Desktop>
        </div>
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] How to add a Click Event on the TrayClock
    By Ujvari in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 26, 2013, 6:36 AM
  2. MVC PartialView Sample
    By millenovanta in forum 2.x Help
    Replies: 2
    Last Post: Nov 18, 2012, 10:04 AM
  3. sample projects available ?
    By captainst in forum 1.x Help
    Replies: 2
    Last Post: Oct 06, 2011, 4:03 PM
  4. MVC Sample
    By BGeorge in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 12, 2008, 11:56 AM
  5. more sample please!
    By bruce in forum Examples and Extras
    Replies: 0
    Last Post: Oct 24, 2008, 3:58 AM

Posting Permissions