Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="header">The header to which the user entered data is to be appended.</param>
        /// <param name="dateTimeCreated">The date and time to be used as the reference for the date and time that the file was created.</param>
        public FormAddComments(Header_t header, DateTime dateTimeCreated)
        {
            InitializeComponent();

            m_TextBoxUserName.Text = General.GetUsername();

            // Copy header information into the appropriate member variable.
            m_Header = header;

            // Copy the date and time when the file was created into the appropriate member variable.
            m_DateTimeCreated = dateTimeCreated;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="header">The header to which the user entered data is to be appended.</param>
        /// <param name="dateTimeCreated">The date and time to be used as the reference for the date and time that the file was created.</param>
        public FormAddComments(Header_t header, DateTime dateTimeCreated)
        {
            InitializeComponent();

            m_TextBoxUserName.Text = General.GetUsername();

            // Copy header information into the appropriate member variable.
            m_Header = header;

            // Copy the date and time when the file was created into the appropriate member variable.
            m_DateTimeCreated = dateTimeCreated;
        }
Ejemplo n.º 3
0
    void LoadIndexFile(string path)
    {
        _chunkFiles = new Dictionary <WorldChunkPos_t, ChunkFile_t>();

        bool valid = false;
        var  file  = File.Open(path + ".cix", FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
        long fpos  = 0;

        using (var reader = new BinaryReader(file, Encoding.UTF8)) {
            Header_t header = default(Header_t);
            try {
                header.version    = reader.ReadInt32();
                header.chunkCount = reader.ReadInt32();
                valid             = header.version == VERSION;

                if (valid)
                {
                    for (int i = 0; i < header.chunkCount; ++i)
                    {
                        var cf = ChunkFile_t.Read(reader);
                        _chunkFiles.Add(cf.pos, cf);
                    }
                    fpos = reader.BaseStream.Position;
                }
            } catch (Exception) {
                valid = false;
            }
        }

        file       = File.Open(path + ".cix", valid ? FileMode.Open : FileMode.Create, FileAccess.Write, FileShare.None);
        _indexFile = new BinaryWriter(file);
        if (valid)
        {
            _indexFile.BaseStream.Position = fpos;
        }
        else
        {
            _chunkFiles.Clear();
            WriteIndexFile();
            try {
                File.Delete(path + ".cdf");
            } catch (Exception e) {
                Debug.LogException(e);
            }
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Event handler for the OK button <c>Click</c> event. Closes the form.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_ButtonOK_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Check whether the comments text of the header has been modified.
            if (m_TextBoxComments.Text != m_Header.Comments)
            {
                Cursor = Cursors.WaitCursor;

                // Check whether the calling form implements the IWatchFile interface.
                IWatchFile iWatchFile = CalledFrom as IWatchFile;
                if (iWatchFile != null)
                {
                    // Yes - Update the WatchFile property with the current header.
                    WatchFile_t watchFile = iWatchFile.WatchFile;
                    watchFile.Header.Comments = m_TextBoxComments.Text;
                    iWatchFile.WatchFile      = watchFile;
                    iWatchFile.SaveWatchFile();
                }
                else
                {
                    // No - Check whether the calling form implements the IEventLogFIle interface.
                    IEventLogFile iEventLogFile = CalledFrom as IEventLogFile;
                    if (iEventLogFile != null)
                    {
                        // Yes - Update the EventLogFile property with the current header.
                        EventLogFile_t eventLogFile = iEventLogFile.EventLogFile;
                        Header_t       header       = eventLogFile.Header;
                        header.Comments            = m_TextBoxComments.Text;
                        eventLogFile.Header        = header;
                        iEventLogFile.EventLogFile = eventLogFile;
                        iEventLogFile.SaveEventLogFile();
                    }
                }

                Cursor = Cursors.Default;
            }

            Close();
        }
		/// <summary>
		/// Initializes a new instance of the class. Zero parameter constructor.
		/// </summary>
		public FormShowHeaderInformation(Header_t header)
		{
			InitializeComponent();

			m_LabelVersionPTU.Text = header.ProductVersion;
			m_LabelVersionDDB.Text = header.ProjectInformation.DataDictionaryBuilderVersion;

			m_LabelVersionDD.Text = header.ProjectInformation.Version;
			m_LabelNameDD.Text = header.ProjectInformation.DataDictionaryName;
			m_LabelProjectIdentifierDD.Text = header.ProjectInformation.ProjectIdentifier;

			m_LabelVersionVCU.Text = header.TargetConfiguration.Version;
			m_LabelSubsystemVCU.Text = header.TargetConfiguration.SubSystemName;
			m_LabelProjectIdentifierVCU.Text = header.TargetConfiguration.ProjectIdentifier;
			m_LabelCarIdentifierVCU.Text = header.TargetConfiguration.CarIdentifier;

			m_LabelUser.Text = header.UserName;
			m_LabelDate.Text = header.DateTimeCreated.ToShortDateString();
			m_LabelTime.Text = header.DateTimeCreated.ToShortTimeString();

			// Windows machines handle newlines by inserting a carriage-return line-feed. Linux-based systems just use a
			// line feed, as does XML encoding. Therefore, we check to see if the environment we're working in uses the
			// Windows schema. If so, we cycle through until all cases of a non-carriage return followed by a line-feed
			// is replaced by the character followed by an Environment.NewLine.
			if (Environment.NewLine == "\r\n")
			{
				Regex regEx = new Regex("([^\r])\n");

				while (regEx.Match(header.Comments).Value != String.Empty)
				{
					header.Comments = regEx.Replace(header.Comments, "$1" + Environment.NewLine);
				}
			}

			m_TextBoxComments.Text = header.Comments;
		

            m_Header = header;
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the class. Zero parameter constructor.
        /// </summary>
        public FormShowHeaderInformation(Header_t header)
        {
            InitializeComponent();

            m_LabelVersionPTU.Text = header.ProductVersion;
            m_LabelVersionDDB.Text = header.ProjectInformation.DataDictionaryBuilderVersion;

            m_LabelVersionDD.Text           = header.ProjectInformation.Version;
            m_LabelNameDD.Text              = header.ProjectInformation.DataDictionaryName;
            m_LabelProjectIdentifierDD.Text = header.ProjectInformation.ProjectIdentifier;

            m_LabelVersionVCU.Text           = header.TargetConfiguration.Version;
            m_LabelSubsystemVCU.Text         = header.TargetConfiguration.SubSystemName;
            m_LabelProjectIdentifierVCU.Text = header.TargetConfiguration.ProjectIdentifier;
            m_LabelCarIdentifierVCU.Text     = header.TargetConfiguration.CarIdentifier;

            m_LabelUser.Text = header.UserName;
            m_LabelDate.Text = header.DateTimeCreated.ToShortDateString();
            m_LabelTime.Text = header.DateTimeCreated.ToShortTimeString();

            // Windows machines handle newlines by inserting a carriage-return line-feed. Linux-based systems just use a
            // line feed, as does XML encoding. Therefore, we check to see if the environment we're working in uses the
            // Windows schema. If so, we cycle through until all cases of a non-carriage return followed by a line-feed
            // is replaced by the character followed by an Environment.NewLine.
            if (Environment.NewLine == "\r\n")
            {
                Regex regEx = new Regex("([^\r])\n");

                while (regEx.Match(header.Comments).Value != String.Empty)
                {
                    header.Comments = regEx.Replace(header.Comments, "$1" + Environment.NewLine);
                }
            }

            m_TextBoxComments.Text = header.Comments;


            m_Header = header;
        }