예제 #1
0
 // Any construction logic to be included here later
 public MarketHoursWidget(MarketClocks marketClocks)
 {
     this.marketClocks = marketClocks;
 }
예제 #2
0
 // Any construction logic to be included here later
 public MarketHoursWidget(MarketClocks marketClocks)
 {
     this.marketClocks = marketClocks;
 }
예제 #3
0
        /// <summary>
        /// create exchange object list and initialise the clock widget.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                Colors openColor;
                Colors closedColor;

                // are the color input strings valid?
                try
                {
                    openColor   = (Colors)Enum.Parse(typeof(Colors), OpenColor, true);
                    closedColor = (Colors)Enum.Parse(typeof(Colors), ClosedColor, true);
                } catch
                {
                    throw new Exception("Open or closed color name(s) are incorrect.");
                }

                // setup a collection of the market exchanges
                MarketClocks marketClocks = new MarketClocks();

                // create clock entities. * CHANGE CLOCK TIMES HERE *
                Exchange exchange = new Exchange(ExchangeName.Wellington);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time");
                exchange.UtcOffset    = 12;
                exchange.OpeningTime  = "09:05:00";
                exchange.ClosingTime  = "18:00:00";
                exchange.LabelFormat  = "{0,-134}";
                exchange.TimeFormat   = "\n{0,-131}";
                exchange.DisplayOrder = 1;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.Sydney);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
                exchange.UtcOffset    = 10;
                exchange.OpeningTime  = "07:05:00";
                exchange.ClosingTime  = "16:00:00";
                exchange.LabelFormat  = "{0,-79}";
                exchange.TimeFormat   = "\n{0,-80}";
                exchange.DisplayOrder = 2;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.Tokyo);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
                exchange.UtcOffset    = 9;
                exchange.OpeningTime  = "09:00:00";
                exchange.ClosingTime  = "18:00:00";
                exchange.LabelFormat  = "{0,-29}";
                exchange.TimeFormat   = "\n{0,-31}";
                exchange.DisplayOrder = 3;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.Singapore);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("Singapore Standard Time");
                exchange.UtcOffset    = 8;
                exchange.OpeningTime  = "09:00:00";
                exchange.ClosingTime  = "17:00:00";
                exchange.LabelFormat  = "{0,33}";
                exchange.TimeFormat   = "\n{0,31}";
                exchange.DisplayOrder = 4;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.Frankfurt);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
                exchange.UtcOffset    = 2;
                exchange.OpeningTime  = "08:00:00";
                exchange.ClosingTime  = "17:00:00";
                exchange.LabelFormat  = "{0,82}";
                exchange.TimeFormat   = "\n{0,80}";
                exchange.DisplayOrder = 5;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.London);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
                exchange.UtcOffset    = 1;
                exchange.OpeningTime  = "08:00:00";
                exchange.ClosingTime  = "17:00:00";
                exchange.LabelFormat  = "{0,127}";
                exchange.TimeFormat   = "\n{0,128}";
                exchange.DisplayOrder = 6;
                marketClocks.Exchanges.Add(exchange);

                exchange              = new Exchange(ExchangeName.NewYork);
                exchange.TimeZone     = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                exchange.UtcOffset    = -4;
                exchange.OpeningTime  = "08:00:00";
                exchange.ClosingTime  = "17:00:00";
                exchange.LabelFormat  = "{0,175}";
                exchange.TimeFormat   = "\n{0,175}";
                exchange.DisplayOrder = 7;
                marketClocks.Exchanges.Add(exchange);

                // ADD NEW EXCHANGE HERE
                //exchange = new Exchange(ExchangeName.NewYork);
                //exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("ADD TIME ZONE");
                //exchange.UtcOffset = "UTC/GMT Time difference for exchange";
                //exchange.OpeningTime = "ADD OPEN TIME";
                //exchange.ClosingTime = "ADD CLOSE TIME";
                //exchange.LabelFormat = "ADD HORIZONTAL POSITIONING";
                //exchange.TimeFormat = "ADD HORIZONTAL POSITIONING";
                //exchange.DisplayOrder = 8; // No. 8 is last on right.
                //marketClocks.Exchanges.Add(exchange);

                // set common properties
                if (Is24Hr)
                {
                    marketClocks.ClockFormat = "HH:mm";
                }
                else
                {
                    marketClocks.ClockFormat = "hh:mmtt";
                }

                // if your local time is selected and not exchange local time.
                if (IsLocalTimeZone)
                {
                    foreach (Exchange ex in marketClocks.Exchanges)
                    {
                        ex.IsLocalTimeZone = true;
                        ex.TimeZone        = TimeZoneInfo.Local;
                    }
                }

                foreach (Exchange ex in marketClocks.Exchanges)
                {
                    ex.IsLocalTimeZone = IsLocalTimeZone;
                }

                // setup the clock's default settings
                widget             = new MarketHoursWidget(marketClocks);
                widget.OpenColor   = openColor;
                widget.ClosedColor = closedColor;
                widget.MarketAlert = MarketAlert;
                widget.Position    = StaticPosition.TopCenter;

                widget.AlertTimeBeforeOpen = AlertBeforeMarketOpens;
            } catch (Exception e)
            {
                errorOccured = true;
                errorMsg    += e.Message;
                System.Media.SystemSounds.Asterisk.Play();
            }
        }
예제 #4
0
        /// <summary>
        /// create exchange object list and initialise the clock widget.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                Colors openColor;
                Colors closedColor;

                // are the color input strings valid?    
                try
                {
                    openColor = (Colors)Enum.Parse(typeof(Colors), OpenColor, true);
                    closedColor = (Colors)Enum.Parse(typeof(Colors), ClosedColor, true);
                } catch
                {
                    throw new Exception("Open or closed color name(s) are incorrect.");
                }

                // setup a collection of the market exchanges
                MarketClocks marketClocks = new MarketClocks();

                // create clock entities. * CHANGE CLOCK TIMES HERE *
                Exchange exchange = new Exchange(ExchangeName.Wellington);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time");
                exchange.UtcOffset = 12;
                exchange.OpeningTime = "09:05:00";
                exchange.ClosingTime = "18:00:00";
                exchange.LabelFormat = "{0,-134}";
                exchange.TimeFormat = "\n{0,-131}";
                exchange.DisplayOrder = 1;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.Sydney);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
                exchange.UtcOffset = 10;
                exchange.OpeningTime = "07:05:00";
                exchange.ClosingTime = "16:00:00";
                exchange.LabelFormat = "{0,-79}";
                exchange.TimeFormat = "\n{0,-80}";
                exchange.DisplayOrder = 2;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.Tokyo);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
                exchange.UtcOffset = 9;
                exchange.OpeningTime = "09:00:00";
                exchange.ClosingTime = "18:00:00";
                exchange.LabelFormat = "{0,-29}";
                exchange.TimeFormat = "\n{0,-31}";
                exchange.DisplayOrder = 3;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.Singapore);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Singapore Standard Time");
                exchange.UtcOffset = 8;
                exchange.OpeningTime = "09:00:00";
                exchange.ClosingTime = "17:00:00";
                exchange.LabelFormat = "{0,33}";
                exchange.TimeFormat = "\n{0,31}";
                exchange.DisplayOrder = 4;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.Frankfurt);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time");
                exchange.UtcOffset = 2;
                exchange.OpeningTime = "08:00:00";
                exchange.ClosingTime = "17:00:00";
                exchange.LabelFormat = "{0,82}";
                exchange.TimeFormat = "\n{0,80}";
                exchange.DisplayOrder = 5;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.London);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
                exchange.UtcOffset = 1;
                exchange.OpeningTime = "08:00:00";
                exchange.ClosingTime = "17:00:00";
                exchange.LabelFormat = "{0,127}";
                exchange.TimeFormat = "\n{0,128}";
                exchange.DisplayOrder = 6;
                marketClocks.Exchanges.Add(exchange);

                exchange = new Exchange(ExchangeName.NewYork);
                exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                exchange.UtcOffset = -4;
                exchange.OpeningTime = "08:00:00";
                exchange.ClosingTime = "17:00:00";
                exchange.LabelFormat = "{0,175}";
                exchange.TimeFormat = "\n{0,175}";
                exchange.DisplayOrder = 7;
                marketClocks.Exchanges.Add(exchange);

                // ADD NEW EXCHANGE HERE
                //exchange = new Exchange(ExchangeName.NewYork);
                //exchange.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("ADD TIME ZONE");
                //exchange.UtcOffset = "UTC/GMT Time difference for exchange";
                //exchange.OpeningTime = "ADD OPEN TIME";
                //exchange.ClosingTime = "ADD CLOSE TIME";
                //exchange.LabelFormat = "ADD HORIZONTAL POSITIONING";
                //exchange.TimeFormat = "ADD HORIZONTAL POSITIONING";
                //exchange.DisplayOrder = 8; // No. 8 is last on right.
                //marketClocks.Exchanges.Add(exchange);

                // set common properties
                if (Is24Hr)
                    marketClocks.ClockFormat = "HH:mm";
                else
                    marketClocks.ClockFormat = "hh:mmtt";

                // if your local time is selected and not exchange local time.
                if (IsLocalTimeZone)
                {
                    foreach (Exchange ex in marketClocks.Exchanges)
                    {
                        ex.IsLocalTimeZone = true;
                        ex.TimeZone = TimeZoneInfo.Local;
                    }
                }

                foreach (Exchange ex in marketClocks.Exchanges)
                    ex.IsLocalTimeZone = IsLocalTimeZone;

                // setup the clock's default settings
                widget = new MarketHoursWidget(marketClocks);
                widget.OpenColor = openColor;
                widget.ClosedColor = closedColor;
                widget.MarketAlert = MarketAlert;
                widget.Position = StaticPosition.TopCenter;

                widget.AlertTimeBeforeOpen = AlertBeforeMarketOpens;

            } catch (Exception e)
            {
                errorOccured = true;
                errorMsg += e.Message;
                System.Media.SystemSounds.Asterisk.Play();
            }
        }