示例#1
0
 private OpenNETCF.AppSettings.SettingGroup GetGroup(OpenNETCF.AppSettings.SettingsFile settingFile, string groupName)
 {
     if ( !settingFile.Groups.Contains(groupName) )
     {
         settingFile.Groups.Add(groupName);
     }
     return settingFile.Groups[groupName];
 }
		protected void Open(OpenNETCF.IO.FileAccess access, OpenNETCF.IO.FileShare share)
		{
			m_hPort = FileEx.CreateFile(m_portName, access, share, IO.FileCreateDisposition.OpenExisting, 0);

			if((int)m_hPort == -1)
			{
				throw new Win32.WinAPIException("Cannot open driver", Marshal.GetLastWin32Error());
			}
		}
示例#3
0
 /// <summary>Calculates distance of two positions in given unit</summary>
 /// <param name="pos1">A position</param>
 /// <param name="pos2">A position</param>
 /// <param name="unit">The unit to get result in</param>
 /// <returns>Distance between given points in given unit; 0 if <paramref name="unit"/> is not one of the <see cref="OpenNETCF.IO.Serial.GPS.Units"/> values.</returns>
 /// <exception cref="ArgumentException"><see cref="Latitude"/> or <paramref name="Longitude"/> of <paramref name="pos1"/> or <paramref name="pos2"/> is null.</exception>
 public static decimal CalculateDistance(GpsPosition pos1, GpsPosition pos2, OpenNETCF.IO.Serial.GPS.Units unit)
 {
     if (!pos1.Longitude.HasValue || !pos1.Latitude.HasValue) throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos1");
     if (!pos2.Longitude.HasValue || !pos2.Latitude.HasValue) throw new ArgumentException(GPSTracka.Properties.Resources.err_PositionIsNull, "pos2");
     var ret = GpsPoint.CalculateDistance(new GpsPoint(pos1.Latitude.Value, pos1.Longitude.Value, pos1.Altitude), new GpsPoint(pos2.Latitude.Value, pos1.Longitude.Value, pos2.Altitude));
     switch (unit)
     {
         case OpenNETCF.IO.Serial.GPS.Units.Kilometers: return ret;
         case OpenNETCF.IO.Serial.GPS.Units.Knots: return ret / 1.85200m;
         case OpenNETCF.IO.Serial.GPS.Units.Miles: return ret / 1.609344m;
         default: throw new ArgumentException("Invalid enum argument");
     }
 }
 public GpsAutoDiscoveryEventArgs(States state,string gpsport,OpenNETCF.IO.Serial.BaudRates gpsbauds)
 {
     this.state=state;
     this.gpsport=gpsport;
     this.gpsbauds=gpsbauds;
 }
示例#5
0
文件: GPS.cs 项目: mendhak/gpstracka
 protected virtual void OnAutoDiscovery(OpenNETCF.IO.Serial.GPS.AutoDiscoverStates state, string port, OpenNETCF.IO.Serial.BaudRates bauds)
 {
     if (GpsAutoDiscovery!=null) GpsAutoDiscovery(this,state,port,bauds);
 }
示例#6
0
 private void gps_Movement(object sender, OpenNETCF.IO.Serial.GPS.Movement mov)
 {
     OnMovement(new GpsMovementEventArgs(mov.SpeedKph));
 }
示例#7
0
		/// <summary>
		/// Determines the location at which the content should be displayed, on the control, based on the indicated alignment value.
		/// </summary>
		/// <param name="alignment">The <see cref="T:OpenNETCF.Drawing.ContentAlignment"/> that represents how the content should be positioned on the control.</param>
		/// <param name="contentSize">The <see cref="T:System.Drawing.SizeF"/> containing the width and height of the content to display on the control.</param>
		/// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> that represents the allotted area in which the content may be displayed.</param>
		/// <returns>A <see cref="T:System.Drawing.Point"/> containing the x and y coordinates at which the content should be displayed.</returns>
		private Point GetLocationFromContentAlignment(OpenNETCF.Drawing.ContentAlignment alignment, SizeF contentSize, Rectangle clipRect)
		{
			byte x = 0;
			Point point = Point.Empty;

			// Vertical Alignment
			if ((((int)alignment) & 0xF00) > 0)			// Bottom
			{
				point.Y = (int)(clipRect.Height - contentSize.Height);
				x = (byte)((int)alignment >> 8);
			}
			else if ((((int)alignment) & 0x0F0) > 0)	// Middle
			{
				point.Y = (int)(((float)clipRect.Height / 2) - (contentSize.Height / 2));
				x = (byte)((int)alignment >> 4);
			}
			else if ((((int)alignment) & 0x00F) > 0)	// Top
			{
				point.Y = 0;
				x = (byte)((int)alignment);
			}

			// Horizontal Alignment
			if ((x & 0x2) > 0)		// Center
			{
				point.X = (int)(((float)clipRect.Width / 2) - (contentSize.Width / 2));
			}
			else if ((x & 0x1) > 0)	// Left
			{
				point.X = 0;
			}
			else if ((x & 0x4) > 0)	// Right
			{
				point.X = (int)(clipRect.Width - contentSize.Width);
			}

			// Ensure that the x coordinate is greater than or equal to zero.
			if (point.X < 0)
			{
				point.X = 0;
			}

			// Ensure that the y coordinate is greater than or equal to zero.
			if (point.Y < 0)
			{
				point.Y = 0;
			}

			// Offset the x and y coordinates based on the clip rectangle.
			point.X += clipRect.X;
			point.Y += clipRect.Y;

			return point;
		}
示例#8
0
 public OpenNETCF.ORM.Test.Entities.Book[] GetBooksOfType(OpenNETCF.ORM.Test.Entities.BookType type)
 {
     throw new NotImplementedException();
 }
示例#9
0
        protected bool GetCommStatusFlag( OpenNETCF.IO.Serial.CommModemStatusFlags statusFlag )
        {
            AssertOpenPort();

            uint modemStatus = 0;
            _port.m_CommAPI.GetCommModemStatus( _port.hPort, ref modemStatus );

            return ( (uint)statusFlag & modemStatus ) != 0;
        }
示例#10
0
 private void gps_GpsSentence(object sender, OpenNETCF.IO.Serial.GPS.GpsSentenceEventArgs e)
 {
     gpsTxt.Text = e.Sentence + " ";
 }
示例#11
0
        private void gps_GpsCommState(object sender, OpenNETCF.IO.Serial.GPS.GpsCommStateEventArgs e)
        {
            switch (e.State)
            {
                case OpenNETCF.IO.Serial.GPS.States.Running:
                    gpsTxt.Text = "GPS Started";
                    Application.DoEvents();
                    break;

                case OpenNETCF.IO.Serial.GPS.States.Stopped:
                    gpsTxt.Text = "GPS Stop";
                    Application.DoEvents();
                    break;
            }
        }
示例#12
0
 private void SaveValue(OpenNETCF.AppSettings.SettingsFile settingFile, string groupName, string key, object value)
 {
     OpenNETCF.AppSettings.Setting setting = this.GetGroup(settingFile, groupName).Settings[key];
     setting.Value = value;
 }
示例#13
0
 private object LoadValue(OpenNETCF.AppSettings.SettingsFile settingFile, string groupName, string key, object defaultValue)
 {
     OpenNETCF.AppSettings.Setting setting = this.GetGroup(settingFile, groupName).Settings[key];
     return (setting.Value != null ? setting.Value : defaultValue);
 }