Ejemplo n.º 1
0
        /// <summary>
        /// Add Model event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (_worker == null || !_worker.IsBusy)
            {
                toolStripLabel.Text = string.Empty;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "All XBim Files|*.ifc;*.ifcxml;*.ifczip;*.xbim|IFC Files|*.ifc;*.ifcxml;*.ifczip|Xbim Files|*.xbim"; //|XLS Files|*.xls
            dlg.Title  = "Choose a refrence model file to add to federation";

            dlg.CheckFileExists = true;

            // Show open file dialog box
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                var      xbimFile = Path.ChangeExtension(dlg.FileName, "xbim");
                FileInfo file     = new FileInfo(xbimFile);

                if (!RefModels.Contains(file, new FileInfoComparer()))
                {
                    if (Path.GetExtension(dlg.FileName).ToUpper().Contains(".IFC"))
                    {
                        _filesToProcess.Push(dlg.FileName);
                        if (_worker == null)
                        {
                            _worker         = CreateWorker();
                            _worker.DoWork += CreateXBimFile;
                        }
                        if (!_worker.IsBusy)
                        {
                            btnSave.Enabled = false;
                            _worker.RunWorkerAsync(_filesToProcess.Pop());
                        }
                    }


                    rolesList.Enabled = true;

                    RefModels.Add(file);
                    var roles = RoleFilter.Unknown;
                    FileRoles.Add(file, roles);

                    if (_worker == null || !_worker.IsBusy)
                    {
                        labelPath.Text = "Path:" + file.FullName;
                    }
                    //highlight added name
                    listBox.SelectedIndex = RefModels.Count - 1;
                    rolesList.Roles       = FileRoles[file];
                }
                else
                {
                    toolStripLabel.Text = "File already added";
                }
            }
        }
Ejemplo n.º 2
0
        private void Init(FileLocation fileLocation, string parentKey, int offset, int length, FileRoles roles, string mimeType, FileContent contents, string encoding, IEnumerable <Hash> hashes, DateTime lastModifiedTime, IDictionary <string, SerializedPropertyInfo> properties)
        {
            if (fileLocation != null)
            {
                FileLocation = new FileLocation(fileLocation);
            }

            ParentKey = parentKey;
            Offset    = offset;
            Length    = length;
            Roles     = roles;
            MimeType  = mimeType;
            if (contents != null)
            {
                Contents = new FileContent(contents);
            }

            Encoding = encoding;
            if (hashes != null)
            {
                var destination_0 = new List <Hash>();
                foreach (var value_0 in hashes)
                {
                    if (value_0 == null)
                    {
                        destination_0.Add(null);
                    }
                    else
                    {
                        destination_0.Add(new Hash(value_0));
                    }
                }

                Hashes = destination_0;
            }

            LastModifiedTime = lastModifiedTime;
            if (properties != null)
            {
                Properties = new Dictionary <string, SerializedPropertyInfo>(properties);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove model event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (_worker == null || !_worker.IsBusy)
            {
                toolStripLabel.Text = string.Empty;
            }

            if (listBox.SelectedIndex >= 0)
            {
                var file = RefModels[listBox.SelectedIndex];
                RefModels.Remove(file);
                FileRoles.Remove(file);
                if (listBox.SelectedIndex >= 0)
                {
                    file = RefModels[listBox.SelectedIndex];
                    toolStripLabel.Text = file.FullName;
                    rolesList.Roles     = FileRoles[file];
                }
            }
            else
            {
                toolStripLabel.Text = string.Empty;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileData" /> class from the supplied values.
 /// </summary>
 /// <param name="fileLocation">
 /// An initialization value for the <see cref="P: FileLocation" /> property.
 /// </param>
 /// <param name="parentKey">
 /// An initialization value for the <see cref="P: ParentKey" /> property.
 /// </param>
 /// <param name="offset">
 /// An initialization value for the <see cref="P: Offset" /> property.
 /// </param>
 /// <param name="length">
 /// An initialization value for the <see cref="P: Length" /> property.
 /// </param>
 /// <param name="roles">
 /// An initialization value for the <see cref="P: Roles" /> property.
 /// </param>
 /// <param name="mimeType">
 /// An initialization value for the <see cref="P: MimeType" /> property.
 /// </param>
 /// <param name="contents">
 /// An initialization value for the <see cref="P: Contents" /> property.
 /// </param>
 /// <param name="encoding">
 /// An initialization value for the <see cref="P: Encoding" /> property.
 /// </param>
 /// <param name="hashes">
 /// An initialization value for the <see cref="P: Hashes" /> property.
 /// </param>
 /// <param name="lastModifiedTime">
 /// An initialization value for the <see cref="P: LastModifiedTime" /> property.
 /// </param>
 /// <param name="properties">
 /// An initialization value for the <see cref="P: Properties" /> property.
 /// </param>
 public FileData(FileLocation fileLocation, string parentKey, int offset, int length, FileRoles roles, string mimeType, FileContent contents, string encoding, IEnumerable <Hash> hashes, DateTime lastModifiedTime, IDictionary <string, SerializedPropertyInfo> properties)
 {
     Init(fileLocation, parentKey, offset, length, roles, mimeType, contents, encoding, hashes, lastModifiedTime, properties);
 }