Exemple #1
0
        private void CreateGMTEntries()
        {
            const string GmtShort = "GMT";
            const string GmtLong  = "Greenwich Mean Time";

            TimeZones.Add(GmtShort.ToLower(), new TimeZoneTO(GmtShort, GmtShort, GmtLong));
            TimeZones.Add(GmtLong.ToLower(), new TimeZoneTO(GmtShort, GmtShort, GmtLong));

            for (int hours = -12; hours < 13; hours++)
            {
                if (hours != 0)
                {
                    for (int minutes = 0; minutes < 2; minutes++)
                    {
                        var min = minutes == 0 ? "00" : "30";
                        var hrs = string.Concat(hours / Math.Abs(hours) < 0 ? "-" : "+",
                                                Math.Abs(hours).ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'));
                        var gmt = string.Concat(GmtShort, hrs, ":", min);
                        TimeZones.Add(gmt.ToLower(), new TimeZoneTO(GmtShort, gmt, GmtLong));
                    }
                }
                else
                {
                    TimeZones.Add(GmtShort + "-00:30", new TimeZoneTO(GmtShort, GmtShort + "-00:30", GmtLong));
                    TimeZones.Add(GmtShort + "+00:30", new TimeZoneTO(GmtShort, GmtShort + "+00:30", GmtLong));
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list type="bullet">
        ///         <item><see cref="Event"/></item>
        ///         <item><see cref="FreeBusy"/></item>
        ///         <item><see cref="Journal"/></item>
        ///         <item><see cref="DDay.iCal.Components.TimeZone"/></item>
        ///         <item><see cref="Todo"/></item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            base.AddChild(child);
            child.Parent = this;

            if (child is UniqueComponent)
            {
                UniqueComponents.Add((UniqueComponent)child);
            }

            Type type = child.GetType();

            if (type == typeof(Event) || type.IsSubclassOf(typeof(Event)))
            {
                Events.Add((Event)child);
            }
            else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy)))
            {
                FreeBusy.Add((FreeBusy)child);
            }
            else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal)))
            {
                Journals.Add((Journal)child);
            }
            else if (type == typeof(DDay.iCal.Components.TimeZone) || type.IsSubclassOf(typeof(DDay.iCal.Components.TimeZone)))
            {
                TimeZones.Add((DDay.iCal.Components.TimeZone)child);
            }
            else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo)))
            {
                Todos.Add((Todo)child);
            }
        }
Exemple #3
0
        public void Add()
        {
            Model.TimeZone item = new Model.TimeZone();
            TimeZoneRepository.Instance.SetItem(item);

            TimeZones.Add(item);
            SelectedTimeZone = item;
        }
Exemple #4
0
        public List <Entities.TimeZone> RetrieveAll()
        {
            SqlCommand     command = null;
            SqlDataAdapter adapter = null;

            try
            {
                command             = mDbConnection.CreateCommand();
                command.CommandText = "RetrieveAllTimeZones";
                command.CommandType = CommandType.StoredProcedure;
                adapter             = new SqlDataAdapter(command);
                DataTable TimeZoneDataTable = new DataTable("TimeZone");
                adapter.Fill(TimeZoneDataTable);

                //create a List
                List <Entities.TimeZone> TimeZones = null;
                if (TimeZoneDataTable.Rows.Count > 0)
                {
                    TimeZones = new List <Entities.TimeZone>();
                }

                // Iterate each row.
                foreach (DataRow row in TimeZoneDataTable.Rows)
                {
                    // Create an instance of TimeZones.

                    Entities.TimeZone timezone = new Entities.TimeZone(Int32.Parse(row["TimeZoneId"].ToString()));
                    timezone.Name             = row["Name"].ToString();
                    timezone.ShortName        = row["ShortName"].ToString();
                    timezone.Description      = row["Description"].ToString();
                    timezone.Reason           = row["Reason"].ToString();
                    timezone.IsActive         = bool.Parse(row["IsActive"].ToString());
                    timezone.LastUpdateUserId = Int32.Parse(row["LastUpdateUserId"].ToString());
                    timezone.LastUpdateDate   = DateTime.Parse(row["LastUpdateDate"].ToString());


                    // Add to the List
                    TimeZones.Add(timezone);
                }

                // Return the list.
                return(TimeZones);
            }
            catch { throw; }
            finally
            {
                // Dispose.
                if (adapter != null)
                {
                    adapter.Dispose();
                }
                if (command != null)
                {
                    command.Dispose();
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list>
        ///         <item>Event</item>
        ///         <item>FreeBusy</item>
        ///         <item>Journal</item>
        ///         <item>TimeZone</item>
        ///         <item>Todo</item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            Type type = child.GetType();

            switch (type.Name)
            {
            case "Event": Events.Add(child); break;

            case "FreeBusy": FreeBusy.Add(child); break;

            case "Journal": Journals.Add(child); break;

            case "TimeZone": TimeZones.Add(child); break;

            case "Todo": Todos.Add(child); break;

            default: break;
            }
        }
Exemple #6
0
        /// <summary>
        /// Adds an <see cref="iCalObject"/>-based component to the
        /// appropriate collection.  Currently, the iCalendar component
        /// supports the following components:
        ///     <list type="bullet">
        ///         <item><see cref="Event"/></item>
        ///         <item><see cref="FreeBusy"/></item>
        ///         <item><see cref="Journal"/></item>
        ///         <item><see cref="DDay.iCal.Components.TimeZone"/></item>
        ///         <item><see cref="Todo"/></item>
        ///     </list>
        /// </summary>
        /// <param name="child"></param>
        public override void AddChild(iCalObject child)
        {
            base.AddChild(child);
            child.Parent = this;

            Type type = child.GetType();

            switch (type.Name)
            {
            case "Event": Events.Add((Event)child); break;

            case "FreeBusy": FreeBusy.Add((FreeBusy)child); break;

            case "Journal": Journals.Add((Journal)child); break;

            case "TimeZone": TimeZones.Add((DDay.iCal.Components.TimeZone)child); break;

            case "Todo": Todos.Add((Todo)child); break;

            default: break;
            }
        }
Exemple #7
0
        private void ReadSystemTimeZones()
        {
            foreach (TimeZoneInfo timeZoneInfo in TimeZoneInfo.GetSystemTimeZones())
            {
                if (!TimeZones.TryGetValue(timeZoneInfo.DisplayName.ToLower(), out ITimeZoneTO timeZoneTo))
                {
                    TimeZones.Add(timeZoneInfo.DisplayName.ToLower(),
                                  new TimeZoneTO(timeZoneInfo.StandardName, timeZoneInfo.StandardName, timeZoneInfo.DisplayName));
                }

                if (!TimeZones.TryGetValue(timeZoneInfo.DaylightName.ToLower(), out timeZoneTo))
                {
                    TimeZones.Add(timeZoneInfo.DaylightName.ToLower(),
                                  new TimeZoneTO(timeZoneInfo.DaylightName, timeZoneInfo.DaylightName, timeZoneInfo.DisplayName));
                }

                if (!TimeZones.TryGetValue(timeZoneInfo.StandardName.ToLower(), out timeZoneTo))
                {
                    TimeZones.Add(timeZoneInfo.StandardName.ToLower(),
                                  new TimeZoneTO(timeZoneInfo.StandardName, timeZoneInfo.StandardName, timeZoneInfo.DisplayName));
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Creates new instance of <see cref="LocationVM"/>
        /// </summary>
        public LocationVM(ISky sky, ISettings settings)
        {
            CrdsEquatorial eqSun = SolarEphem.Ecliptical(sky.Context.JulianDay).ToEquatorial(sky.Context.Epsilon);

            ObserverLocation = new CrdsGeographical(sky.Context.GeoLocation);
            SunHourAngle     = Coordinates.HourAngle(sky.Context.SiderealTime, 0, eqSun.Alpha);
            SunDeclination   = eqSun.Delta;
            IsNightMode      = settings.Get <ColorSchema>("Schema") == ColorSchema.Red;

            OkCommand             = new Command(Ok);
            CancelCommand         = new Command(Close);
            EndSearchModeCommand  = new Command(EndSearchMode);
            SelectLocationCommand = new Command(SelectLocation);

            string line;
            string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "TimeZones.dat");

            using (StreamReader file = new StreamReader(filePath))
            {
                while ((line = file.ReadLine()) != null)
                {
                    // skip first and empty lines
                    if (line.StartsWith("CountryCode") ||
                        string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    string[] chunks = line.Split('\t');
                    TimeZones.Add(new TimeZoneItem()
                    {
                        TimeZoneId = chunks[1], UtcOffset = double.Parse(chunks[4], CultureInfo.InvariantCulture)
                    });
                }
                file.Close();
            }
        }
Exemple #9
0
        public virtual void Deserialize(System.IO.TextReader rdr, Serializer serializer = null)
        {
            if (serializer == null)
            {
                serializer = new Serializer();
            }
            string name, value;
            var    parameters = new System.Collections.Specialized.NameValueCollection();

            while (rdr.Property(out name, out value, parameters) && !string.IsNullOrEmpty(name))
            {
                switch (name.ToUpper())
                {
                case "BEGIN":
                    switch (value)
                    {
                    case "VEVENT":
                        var e = serializer.GetService <Event>();
                        e.Calendar = this;
                        Events.Add(e);
                        e.Deserialize(rdr, serializer);
                        break;

                    case "VTIMEZONE":
                        var tz = serializer.GetService <TimeZone>();
                        tz.Calendar = this;
                        TimeZones.Add(tz);
                        tz.Deserialize(rdr, serializer);
                        break;

                    case "VTODO":
                        var td = serializer.GetService <ToDo>();
                        td.Calendar = this;
                        ToDos.Add(td);
                        td.Deserialize(rdr, serializer);
                        break;

                    case "VFREEBUSY":
                        var fb = serializer.GetService <FreeBusy>();
                        fb.Calendar = this;
                        FreeBusy.Add(fb);
                        fb.Deserialize(rdr, serializer);
                        break;

                    case "VJOURNAL":
                        var jn = serializer.GetService <JournalEntry>();
                        jn.Calendar = this;
                        JournalEntries.Add(jn);
                        jn.Deserialize(rdr, serializer);
                        break;
                    }
                    break;

                case "CALSCALE": Scale = value; break;

                case "VERSION": Version = value; break;

                case "PRODID": ProdID = value; break;

                case "END":
                    if (value == "VCALENDAR")
                    {
                        return;
                    }
                    break;

                default:
                    Properties.Add(Tuple.Create(name, value, parameters));
                    break;
                }
            }
        }
        private MainViewModel()
        {
            Controllers = new ObservableCollection <IController>();
            MessageList = new ObservableCollection <Message>();
            LogList     = new ObservableCollection <Log>();

            Orders = new ObservableCollectionEx <DisplayedOrder>();
            Orders.CollectionChanged += Orders_CollectionChanged;
            ((INotifyPropertyChanged)Orders).PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Status")
                {
                    poViewSource.View.Refresh();
                    execViewSource.View.Refresh();
                }
            };

            SymbolInActions = new ObservableCollection <SymbolInAction>();

            poViewSource         = new CollectionViewSource();
            poViewSource.Source  = Orders;
            poViewSource.Filter += PendingOrders_Filter;
            PendingOrdersView    = poViewSource.View;

            execViewSource         = new CollectionViewSource();
            execViewSource.Source  = Orders;
            execViewSource.Filter += Execution_Filter;
            ExecutionView          = execViewSource.View;

            // retrieving the settings
            ReadSettings();
            ReadAccountAlias();

            // reading all order types
            var types = typeof(IBOrderType).Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(IBOrderType)));

            foreach (var t in types)
            {
                AllIBOrderTypes.Add((IBOrderType)Activator.CreateInstance(t));
            }
            types = typeof(FTOrderType).Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(FTOrderType)));
            foreach (var t in types)
            {
                AllFTOrderTypes.Add((FTOrderType)Activator.CreateInstance(t));
            }
            //VendorOrderTypes.Add("Order Types for IB", AllIBOrderTypes);
            //VendorOrderTypes.Add("Order Types for FT", AllFTOrderTypes);
            VendorOrderTypes.Add(new VendorOrderType {
                Name = "Order Types for Interative Broker", OrderTypes = AllIBOrderTypes
            });
            VendorOrderTypes.Add(new VendorOrderType {
                Name = "Order Types for FuTu NiuNiu", OrderTypes = AllFTOrderTypes
            });


            TimeZones.Add(new TimeZone {
                Id = "HKT", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"), Description = "China Standar Time"
            });
            TimeZones.Add(new TimeZone {
                Id = "EST", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"), Description = "Eastern Standard Time (North America)"
            });
            //TimeZones.Add(new TimeZone { Id = "CDT", TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central Daylight Time"), Description = "Eastern Standard Time (North America)" });

            Weekdays.Add(new WeekDay {
                Value = 0, Name = "Sun"
            });
            Weekdays.Add(new WeekDay {
                Value = 1, Name = "Mon"
            });
            Weekdays.Add(new WeekDay {
                Value = 2, Name = "Tue"
            });
            Weekdays.Add(new WeekDay {
                Value = 3, Name = "Wed"
            });
            Weekdays.Add(new WeekDay {
                Value = 4, Name = "Thu"
            });
            Weekdays.Add(new WeekDay {
                Value = 5, Name = "Fri"
            });
            Weekdays.Add(new WeekDay {
                Value = 6, Name = "Sat"
            });

            StopLossSource.Add("In Points/Dollars");
            StopLossSource.Add("In Ticks");
            StopLossSource.Add("In Percentage");
            StopLossSource.Add("From AFL script");
            //
            _hub.Subscribe <IController>(OnControllerConnected);
        }