internal static async Task LoadImage(this Canvas canvas, WindowData data, int imageIndex) { var image = await Task.Run(delegate { var im = new BitmapImage(new Uri(data.FileList[imageIndex].FileName)); im.Freeze(); return(im); }); data.ScaleX = image.Width / image.PixelWidth; data.ScaleY = image.Height / image.PixelHeight; //if (image.PixelWidth != FileAccess.imageWidth || image.PixelHeight != FileAccess.imageHeight) throw new Exception(); var bg = new ImageBrush { ImageSource = image }; data.WindowTitle = Path.GetFileName(data.FileList[imageIndex].FileName) + " (" + bg.ImageSource.Width + "x" + bg.ImageSource.Height + ")"; canvas.Background = bg; canvas.Width = bg.ImageSource.Width; canvas.Height = bg.ImageSource.Height; canvas.Scale(data.Zoom); Keyboard.Focus(canvas); }
public override string ToString() { return(string.IsNullOrEmpty(_componentName) && string.IsNullOrEmpty(_projectName) ? string.Empty : (string.IsNullOrEmpty(ProjectPath) ? string.Empty : Path.GetFileName(ProjectPath) + ";") + $"{_projectName}.{_componentName}"); }
public static IItem Create(string fullPath) { var item = new LocalItem { FullPath = fullPath }; var isRoot = IsRoot(fullPath); item.Type = isRoot ? ItemTypes.LocaDrive : IsFolder(fullPath) ? ItemTypes.Folder : ItemFactoryHelper.GetFileType(fullPath); if (isRoot) { item.Name = fullPath.Replace(Path.DirectorySeparatorChar, ' ').Trim(); } else { if (fullPath.Last() == Path.DirectorySeparatorChar) { fullPath = fullPath.Remove(fullPath.Length - 1); } item.Name = Path.GetFileName(fullPath); } return(item); }
// Add files to list with Add button private void AddFileButton_Click(object sender, RoutedEventArgs e) { var openFileDialog = new OpenFileDialog { Multiselect = true, RestoreDirectory = true, Filter = "Excel files (*.xlsx)|*.xlsx|Text files (*.txt)|*.txt|All files (*.*)|*.*", FilterIndex = 3 }; if (InputExcel.IsChecked == true) { openFileDialog.FilterIndex = 1; } else if (InputText.IsChecked == true) { openFileDialog.FilterIndex = 2; } if (openFileDialog.ShowDialog() == true) { foreach (var filePath in openFileDialog.FileNames) { var fileName = Path.GetFileName(filePath); fileNamesPaths.Add(new KeyValuePair <string, string>(fileName, filePath)); FileNamesListView.Items.Add(fileName); } } }
//获取要素面积,单位为平方米 private double GetShpArea(string filePath) { string folder = Path.GetDirectoryName(filePath); string fileName = Path.GetFileName(filePath); double dArea = 0; IWorkspaceFactory pwsf = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace pFeatureWorkspace = pwsf.OpenFromFile(folder, 0) as IFeatureWorkspace; if (pFeatureWorkspace != null) { IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(fileName); IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); while (pFeature != null) { if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { IArea pArea = pFeature.Shape as IArea; dArea = dArea + pArea.Area; } pFeature = pFeatureCursor.NextFeature(); } Marshal.ReleaseComObject(pFeatureCursor); } Marshal.ReleaseComObject(pwsf); return(dArea); }
private static void GetRouteAndBasePath(string file, out string routePath, out string basePath) { routePath = null; basePath = null; Stack <string> subDirectories = new Stack <string>(); string directory = Path.GetDirectoryName(file); string root = Path.GetPathRoot(file); while (directory.Length > root.Length) { string subdDirectoryName = Path.GetFileName(directory); if (subdDirectoryName.Equals("routes", System.StringComparison.OrdinalIgnoreCase)) { routePath = Path.Combine(directory, subDirectories.Pop()); basePath = Path.GetDirectoryName(Path.GetDirectoryName(routePath)); return; } if (subdDirectoryName.Equals("trains", System.StringComparison.OrdinalIgnoreCase)) { basePath = Path.GetDirectoryName(directory); return; } if (subdDirectoryName.Equals("trains", System.StringComparison.OrdinalIgnoreCase)) { basePath = Path.GetDirectoryName(directory); } if (subdDirectoryName.Equals("sound", System.StringComparison.OrdinalIgnoreCase)) { basePath = Path.GetDirectoryName(directory); } subDirectories.Push(Path.GetFileName(directory)); directory = Path.GetDirectoryName(directory); } }
private IEnumerable <View> FindViews(string root, string areaName) { var viewsPath = Path.Combine(root, "Views"); if (_fileLocator.DirectoryExists(viewsPath)) { foreach (var controllerPath in _fileLocator.GetDirectories(viewsPath)) { var controllerName = Path.GetFileName(controllerPath); foreach (var file in _fileLocator.GetFiles(Path.Combine(viewsPath, controllerName), "*.cshtml")) { var relativePath = !string.IsNullOrEmpty(areaName) ? $"~/Areas/{areaName}/Views/{controllerName}/{Path.GetFileName(file)}" : $"~/Views/{controllerName}/{Path.GetFileName(file)}"; yield return(GetView(file, controllerName, areaName)); } foreach (var directory in _fileLocator.GetDirectories(controllerPath)) { foreach (var file in _fileLocator.GetFiles(directory, "*.cshtml")) { yield return(GetView(file, controllerName, areaName, Path.GetFileName(directory))); } } } } }
private void LoadArchive(BackgroundWorker worker, string pathToMappingFile, out ISrcMLArchive archive, out IDataRepository data, out string projectName) { string pathToArchive = FilePath.GetDirectoryName(pathToMappingFile); string archiveDirectoryName = FilePath.GetFileName(pathToArchive); string baseDirectory = FilePath.GetFullPath(FilePath.GetDirectoryName(pathToArchive)); projectName = FilePath.GetFileName(baseDirectory); worker.ReportProgress(0, String.Format("Loading {0}", projectName)); archive = new SrcMLArchive(baseDirectory, archiveDirectoryName); int numberOfFiles = archive.FileUnits.Count(); worker.ReportProgress(0, String.Format("Loading {0} ({1} files)", projectName, numberOfFiles)); data = new DataRepository(archive); int i = 0; foreach (var unit in archive.FileUnits) { try { data.AddFile(unit); } catch (Exception) { } if (++i % 25 == 0) { int percentComplete = (int)(100 * (double)i / (double)numberOfFiles); worker.ReportProgress(percentComplete, String.Format("Loading {0} ({1} / {2} files)", projectName, i, numberOfFiles)); } } worker.ReportProgress(100, String.Format("Loaded {0} ({1} files)", baseDirectory, i)); }
public void OutputFileHelper_GetNewA11yTestFilePath_SpecificScanId_CreatesExpectedFileName() { var mockSystem = new Mock <ISystem>(MockBehavior.Strict); var mockIO = new Mock <ISystemIO>(MockBehavior.Strict); var mockDirectory = new Mock <ISystemIODirectory>(MockBehavior.Strict); mockSystem.Setup(x => x.DateTime).Returns(InertDateTime); mockSystem.Setup(x => x.Environment).Returns(InertEnvironment); mockSystem.Setup(x => x.IO).Returns(mockIO.Object); mockIO.Setup(x => x.Directory).Returns(mockDirectory.Object); string directory = @"c:\TestDir2"; mockDirectory.Setup(x => x.Exists(directory)).Returns(true); var outputFileHelper = new OutputFileHelper(directory, mockSystem.Object); outputFileHelper.SetScanId("myScanId"); var result = outputFileHelper.GetNewA11yTestFilePath(); var expectedFileName = "myScanId.a11ytest"; var actualFileName = Path.GetFileName(result); Assert.AreEqual(expectedFileName, actualFileName); Assert.AreEqual(directory, Path.GetDirectoryName(result)); mockSystem.VerifyAll(); mockIO.VerifyAll(); mockDirectory.VerifyAll(); }
private void LIDokumen_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (LstDokumen.SelectedItem != null) { this.dokumenSelected = (Dokumen)LstDokumen.SelectedItem; if (this.dokumenSelected != null) { using (var uow = new UnitOfWork(AppConfig.Current.ContextName)) { this.dokument = uow.Dokumen.Get(this.dokumenSelected.Id); txtDocumentNo.Text = this.dokument.NoReferensiDokumen; txtDocumentType.Text = this.dokument.TypeDokumen; if (this.dokumenSelected.TanggalDokumen != null) { txtDate.Text = this.dokumenSelected.TanggalDokumen.GetValueOrDefault().ToShortDateString(); } txtContactName.Text = this.dokument.PelangganDokumen; txtDescription.Text = this.dokument.KeteranganDokumen; txtuploadfileA.Text = Path.GetFileName(this.dokument.UploadFile1); txtuploadfileB.Text = Path.GetFileName(this.dokument.UploadFile2); txtuploadfileC.Text = Path.GetFileName(this.dokument.UploadFile3); txtuploadfileD.Text = Path.GetFileName(this.dokument.UploadFile4); } } } }
private void LaunchFile(int index) { Bundle bundle; if (AppConstant.IsQPOffline(SystemPath.GetFileName(semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()))) { bundle = new Bundle(); bundle.PutBoolean("IsFileOffline", true); bundle.PutString("PATH", SystemPath.Combine(AppConstant.QPFolderPath, SystemPath.GetFileName(semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()))); } else { bundle = new Bundle(); bundle.PutBoolean("IsFileOffline", false); bundle.PutString("URL", semesters[semesterIndex].Years[yearIndex].QuestionPapers[index].FileLink.ToString()); bundle.PutBoolean("IsFileNotice", false); } if (Looper.MyLooper() == null) { Looper.Prepare(); } Android.Content.Intent i = new Android.Content.Intent(this, typeof(PDFViewerActivity)); i.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); i.PutExtras(bundle); StartActivity(i); }
/// <summary> /// Create a new <see cref="Font"/> from a path. /// </summary> /// <param name="path">The path of the font.</param> public Font(string path) { Slug = Utility.ToSlug(PathIO.GetFileNameWithoutExtension(path)); Path = path; File = PathIO.GetFileName(path); Format = PathIO.GetExtension(path).Replace(".", string.Empty); }
private void SubmitNewMod_OnReadLogo(string path, bool success, byte[] data) { if (!success) { this.SubmissionError_Local("Mod Profile logo file could not be read for uploading." + "\nLogo Path: " + path); } else { this.addModParams.logo = BinaryUpload.Create(Path.GetFileName(path), data); if (this.eModProfile == null) { APIClient.AddMod(this.addModParams, this.onSuccess, this.onError); } else { APIClient.AddMod(this.addModParams, this.SubmitModChanges_Internal, this.onError); } } }
// We have to move the folder separation into the file name // e.g. "myfolder"\"myassembly.iam" => "myfolder\myassembly.iam" // On windows we might have to URL encode this, i.e. // "myfolder%2Fmyassembly.iam" public void flattenFolder(string folder, string rootFolder, string path) { const string separator = "%2F"; if (folder != rootFolder) { string[] filePaths = Directory.GetFiles(folder); foreach (string filePath in filePaths) { string fileName = path + Path.GetFileName(filePath); string filePathNew = Path.Combine(rootFolder, fileName); File.Move(filePath, filePathNew); } } string[] directoryPaths = Directory.GetDirectories(folder); foreach (string directoryPath in directoryPaths) { string directoryName = Path.GetFileName(directoryPath); // move its contents first flattenFolder(directoryPath, rootFolder, path + directoryName + separator); // Then delete it try { Directory.Delete(directoryPath); } catch (Exception ex) { LogTrace(ex.Message + ": " + directoryPath); } } }
public async Task SendResult(object sender, CaptureResponseEventArgs e) { if (e == null) { Logger.Warn("result is null, ignoring"); return; } var message = e.Request.RequestContext as Message; if (message == null) { Logger.Error("Returned RequestContext is not a valid Telegram UserRequest object"); return; } if (e.Attachments != null) { foreach (var filePath in e.Attachments) { using (var fs = File.OpenRead(filePath)) { var trial = 0; var succeed = false; var fileName = Path.GetFileName(filePath); while (!succeed && trial < MaxUploadRetries) { try { Logger.Debug($"(retry {trial}/{MaxUploadRetries}) Uploading file \"{fileName}\""); var inputOnlineFile = new InputOnlineFile(fs, fileName); await _bot.SendDocumentAsync(message.Chat, inputOnlineFile, replyToMessageId : message.MessageId); succeed = true; } catch (ApiRequestException) { Logger.Warn("Telegram API timeout"); trial += 1; } } if (!succeed) { Logger.Error("Unable to upload file \"{fileName}\""); e.StatusText += "Unable to upload file \"{fileName}\".\n"; } } } } Logger.Debug("Sending session information"); await _bot.SendTextMessageAsync( message.Chat, $"<pre>{e}</pre>", replyToMessageId : message.MessageId, parseMode : ParseMode.Html ); }
public virtual string GetOutputFile(string fileName) { string outputDir = tool.GetOutputDirectory(g.fileName); if (outputDir.Equals(".")) { // pay attention to -o then outputDir = tool.GetOutputDirectory(fileName); } if (outputDir.Equals(".")) { return(fileName); } if (Path.GetFileName(outputDir).Equals(".")) { string fname = outputDir; int dot = fname.LastIndexOf('.'); outputDir = outputDir.Substring(0, dot); } if (Path.GetFileName(outputDir).IndexOf(' ') >= 0) { // has spaces? string escSpaces = outputDir.Replace(" ", "\\ "); outputDir = escSpaces; } return(Path.Combine(outputDir, fileName)); }
public void Bind(JavaDebugProgram program, JavaDebugThread thread, IReferenceType type, IEnumerable <string> sourcePaths) { IVirtualMachine virtualMachine = program.VirtualMachine; IEnumerable <string> validPaths = sourcePaths.Where(i => string.Equals(Path.GetFileName(RequestLocation.DocumentPosition.GetFileName()), Path.GetFileName(i), StringComparison.OrdinalIgnoreCase)); List <JavaDebugBoundBreakpoint> boundBreakpoints = new List <JavaDebugBoundBreakpoint>(); List <IDebugErrorBreakpoint2> errorBreakpoints = new List <IDebugErrorBreakpoint2>(); foreach (var path in validPaths) { TextSpan range = RequestLocation.DocumentPosition.GetRange(); try { ReadOnlyCollection <ILocation> locations = type.GetLocationsOfLine(range.iStartLine + 1); ILocation bindLocation = locations.OrderBy(i => i.GetCodeIndex()).FirstOrDefault(); if (bindLocation != null && IsFirstOnLine()) { IEventRequestManager eventRequestManager = virtualMachine.GetEventRequestManager(); IBreakpointRequest eventRequest = eventRequestManager.CreateBreakpointRequest(bindLocation); eventRequest.SuspendPolicy = SuspendPolicy.All; JavaDebugCodeContext codeContext = new JavaDebugCodeContext(program, bindLocation); BreakpointResolutionLocationCode location = new BreakpointResolutionLocationCode(codeContext); DebugBreakpointResolution resolution = new DebugBreakpointResolution(program, thread, enum_BP_TYPE.BPT_CODE, location); JavaDebugBoundBreakpoint boundBreakpoint = new JavaDebugBoundBreakpoint(this, program, eventRequest, resolution); if (!_disabled) { boundBreakpoint.Enable(1); } boundBreakpoints.Add(boundBreakpoint); } } catch (MissingInformationException) { } } _boundBreakpoints.AddRange(boundBreakpoints); if (boundBreakpoints.Count > 0) { _errorBreakpoints.Clear(); } _errorBreakpoints.AddRange(errorBreakpoints); if (boundBreakpoints.Count > 0) { DebugEvent debugEvent = new DebugBreakpointBoundEvent(enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS, this, new EnumDebugBoundBreakpoints(boundBreakpoints)); program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent); } foreach (var errorBreakpoint in errorBreakpoints) { DebugEvent debugEvent = new DebugBreakpointErrorEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, errorBreakpoint); program.Callback.Event(DebugEngine, program.Process, program, null, debugEvent); } }
void GetRouteAndBasePath(string file, out string routePath, out string basePath) { routePath = null; basePath = null; Stack <string> subDirectories = new Stack <string>(); string directory = Path.GetDirectoryName(file); var root = Path.GetPathRoot(file); while (directory.Length > root.Length) { string subdDirectoryName = Path.GetFileName(directory); if (subdDirectoryName.ToLowerInvariant().Equals("routes")) { routePath = Path.Combine(directory, subDirectories.Pop()); basePath = Path.GetDirectoryName(Path.GetDirectoryName(routePath)); return; } if (subdDirectoryName.ToLowerInvariant().Equals("trains")) { basePath = Path.GetDirectoryName(directory); return; } if (subdDirectoryName.ToLowerInvariant().Equals("trains")) { basePath = Path.GetDirectoryName(directory); } if (subdDirectoryName.ToLowerInvariant().Equals("sound")) { basePath = Path.GetDirectoryName(directory); } subDirectories.Push(Path.GetFileName(directory)); directory = Path.GetDirectoryName(directory); } }
/// <exception cref="Exception">Root schema does not include a BIE schema.</exception> public ImporterContext(ICctsRepository cctsRepository, string rootSchemaPath) { RootSchemaPath = rootSchemaPath; RootSchemaFileName = Path.GetFileName(rootSchemaPath); string inputDirectory = Path.GetDirectoryName(rootSchemaPath) + @"\"; foreach (string schemaLocation in GetIncludedSchemaLocations(rootSchemaPath)) { if (schemaLocation.StartsWith("BusinessInformationEntity")) { BIESchemaPath = inputDirectory + schemaLocation; } else if (schemaLocation.StartsWith("BusinessDataType")) { BDTSchemaPath = inputDirectory + schemaLocation; } } if (BDTSchemaPath == null) { throw new Exception("Root schema does not include a BDT schema."); } if (BIESchemaPath == null) { throw new Exception("Root schema does not include a BIE schema."); } CDTLibrary = cctsRepository.GetCdtLibraries().ElementAt(0); CCLibrary = cctsRepository.GetCcLibraries().ElementAt(0); BDTLibrary = cctsRepository.GetBdtLibraries().ElementAt(0); BIELibrary = cctsRepository.GetBieLibraries().ElementAt(0); PRIMLibrary = cctsRepository.GetPrimLibraries().ElementAt(0); BLibrary = cctsRepository.GetBLibraries().ElementAt(0); }
protected override void OnClick() { string tablePath = Path.Combine(DataPath, @"File-Based\MajorCities.csv"); string tableName = Path.GetFileName(tablePath); Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.TextFileWorkspaceFactory"); IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory; IWorkspace workspace = workspaceFactory.OpenFromFile(Path.GetDirectoryName(tablePath), 0); ITable table = ((IFeatureWorkspace) workspace).OpenTable(tableName); ISpatialReference sRef = CreateSpatialReference(esriSRGeoCSType.esriSRGeoCS_WGS1984); IFeatureClass featureClass = CreateXYEventFeature(table, "POINT_X", "POINT_y", sRef); IFeatureLayer featureLayer = new FeatureLayerClass { FeatureClass = featureClass, Name = "CSV XY Event Table" }; IFeatureLayerSourcePageExtension sourcePageExtension = new XYDataSourcePageExtensionClass(); ((ILayerExtensions) featureLayer).AddExtension(sourcePageExtension); ArcMap.Document.FocusMap.AddLayer(featureLayer); ArcMap.Document.UpdateContents(); }
private AntlrClassGenerationTaskInternal CreateBuildTaskWrapper() { var wrapper = new AntlrClassGenerationTaskInternal(); IList <string> sourceCodeFiles = null; if (this.SourceCodeFiles != null) { sourceCodeFiles = new List <string>(SourceCodeFiles.Length); foreach (ITaskItem taskItem in SourceCodeFiles) { sourceCodeFiles.Add(taskItem.ItemSpec); } } if (this.TokensFiles != null && this.TokensFiles.Length > 0) { Directory.CreateDirectory(OutputPath); HashSet <string> copied = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (ITaskItem taskItem in TokensFiles) { string fileName = taskItem.ItemSpec; if (!File.Exists(fileName)) { Log.LogError("The tokens file '{0}' does not exist.", fileName); continue; } string vocabName = Path.GetFileNameWithoutExtension(fileName); if (!copied.Add(vocabName)) { Log.LogWarning("The tokens file '{0}' conflicts with another tokens file in the same project.", fileName); continue; } string target = Path.Combine(OutputPath, Path.GetFileName(fileName)); if (!Path.GetExtension(target).Equals(".tokens", StringComparison.OrdinalIgnoreCase)) { Log.LogError("The destination for the tokens file '{0}' did not have the correct extension '.tokens'.", target); continue; } File.Copy(fileName, target, true); File.SetAttributes(target, File.GetAttributes(target) & ~FileAttributes.ReadOnly); } } wrapper.AntlrToolPath = AntlrToolPath; wrapper.SourceCodeFiles = sourceCodeFiles; wrapper.TargetLanguage = TargetLanguage; wrapper.OutputPath = OutputPath; wrapper.RootNamespace = RootNamespace; wrapper.GeneratedSourceExtension = GeneratedSourceExtension; wrapper.LanguageSourceExtensions = LanguageSourceExtensions; wrapper.DebugGrammar = DebugGrammar; wrapper.ProfileGrammar = ProfileGrammar; return(wrapper); }
//TODO: Gather all conflicts and report them in one error dialog instead of reporting them one at a time. private void NotifyUserAboutAbortDueToUnsupportedFileExtensions(IEnumerable <string> fileNames) { var firstUnsupportedFile = fileNames.First(filename => !ImportableExtensions.Contains(Path.GetExtension(filename))); var unsupportedFileName = Path.GetFileName(firstUnsupportedFile); var message = string.Format(RubberduckUI.ImportCommand_UnsupportedFileExtensions, unsupportedFileName); MessageBox.NotifyWarn(message, DialogsTitle); }
/// <summary> /// 获取栅格数据集 /// </summary> /// <param name="filePath">栅格文件路径</param> /// <returns></returns> public static IRasterDataset GetRasterDataset(string filePath) { string fileName = Path.GetFileName(filePath); IRasterWorkspace pRasterWorkspace = (IRasterWorkspace)GetRasterWorkspace(filePath); IRasterDataset pRasterDataset = pRasterWorkspace.OpenRasterDataset(fileName); return(pRasterDataset); }
public ItemModel(Types type, string fullPath, bool isRoot = false) { Type = type; FullPath = fullPath ?? throw new ArgumentNullException(nameof(fullPath)); Name = isRoot ? fullPath.Replace(Path.DirectorySeparatorChar, ' ').Trim() : Path.GetFileName(fullPath); }
public static async Task <OneDriveStorageFile> GetOneDriveFilesAsync(string fileName) { if (rootFolder is null) { if (!await LogintoOnedriveAsync()) { throw new InvalidOperationException("Failed to log in"); } if (rootFolder is null) { var root = await OneDriveService.Instance.AppRootFolderAsync(); Interlocked.CompareExchange(ref rootFolder, root, null); } } fileName = fileName.Split(@"\OneDrive\", 2).Last(); var folderName = SysPath.GetDirectoryName(fileName); var sFileName = SysPath.GetFileName(fileName); if (folderName.IsNullorEmpty()) { return(await rootFolder.GetFileAsync(fileName)); } var file = default(OneDriveStorageFile); // copy to local to avoid changes by other threads var currentCache = cache; if (currentCache != null && folderName == currentCache.FolderName) { file = currentCache.Files.Find(f => f.Name == sFileName); } if (file != null) { return(file); } // cache miss var folder = await rootFolder.GetFolderAsync(folderName); var files = await folder.GetFilesAsync(10000); file = files.Find(f => f.Name == sFileName); cache = new CacheData { Files = files, Folder = folder, FolderName = folderName, }; if (file != null) { return(file); } // slow route: first 10000 files missed return(await folder.GetFileAsync(sFileName)); }
private Component GetCasingComponent(AssemblyDocument assembly) { try { Component component = new Component(inventorApp); // Get file info component.FullFileName = assembly.FullFileName; PropertySet oPropSet = assembly.PropertySets["Design Tracking Properties"]; component.PartNumber = oPropSet["Part Number"].Value.ToString(); component.Description = oPropSet["Description"].Value.ToString(); oPropSet = assembly.PropertySets["Inventor User Defined Properties"]; component.FactoryNumber = oPropSet["Заводской номер"].Value.ToString(); component.ComponentType = ComponentTypes.Assembly; // Define assembly type string fileName = Path.GetFileName(component.FullFileName); component.CasingType = CasingTypes.Common; if (fileName.IndexOf("Комплект ЛСП") >= 0) { component.CasingType = CasingTypes.ЛСП; } if (fileName.IndexOf("Рама") >= 0) { component.CasingType = CasingTypes.Frame; } // Get property "Тип сборки" string casingType = "Common"; string propertyName = "Тип сборки"; if (Library.HasInventorProperty(oPropSet, propertyName)) { casingType = oPropSet[propertyName].Value.ToString(); } switch (casingType) { case "Common": component.CasingType = CasingTypes.Common; break; case "ЛСП": component.CasingType = CasingTypes.ЛСП; break; case "F": component.CasingType = CasingTypes.Frame; break; default: break; } return(component); } catch (Exception ex) { MessageBox.Show(ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name, MessageBoxButton.OK); return(null); } }
public static string GetAssemblyNameWithoutExtension(string assemblyName) { if (AssetPath.GetExtension(assemblyName) == ".dll") { return(SystemPath.GetFileNameWithoutExtension(assemblyName.NormalizePath())); } return(SystemPath.GetFileName(assemblyName.NormalizePath())); }
private void SymetricDropPanelKey_OnDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); AESCrypter.Instance().SetKeyFilePath(files[0]); SymetricKeyNameText.Text = Path.GetFileName(files[0]); } }
private void AsymetricDropPanel_OnDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); RSACrypter.Instance().SetFileBeingEcryptedPath(files[0]); AsymetricFileNameText.Text = Path.GetFileName(files[0]); } }
public virtual void LexerError(string srcName, string msg, IToken templateToken, RecognitionException e) { if (srcName != null) { srcName = Path.GetFileName(srcName); } Listener.CompiletimeError(new TemplateLexerMessage(srcName, msg, templateToken, e)); }