private void DeviceManager_PhotoCaptured(object sender, PhotoCapturedEventArgs eventArgs) { try { string tempFile = Path.Combine(Settings.Instance.TempFolder, Path.GetRandomFileName() + Path.GetExtension(eventArgs.FileName)); Utils.CreateFolder(tempFile); if (File.Exists(tempFile)) { File.Delete(tempFile); } eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tempFile); FileItem item = new FileItem() { FileName = tempFile, Thumb = Utils.LoadImage(tempFile, 200, 0) }; FileItems.Add(item); FileItem = item; item.ThumbFile = Path.GetTempFileName(); Utils.Save2Jpg(Utils.LoadImage(tempFile, 800, 0), item.ThumbFile); OnMessage(new MessageEventArgs(Messages.PhotoDownloaded, FileItem)); } catch (Exception ex) { Log.Error("Error transfer file", ex); } }
public async Task <bool> UpdateFiles() { QueryResults = null; HitItems.Clear(); FileItems.Clear(); if (Group != null) { var api = IndexApiClient.Create(cts.Token); var results = await api.GetFiles(Group); if (results is FileInfo[] entries) { foreach (var entry in entries.OrderBy(x => x.Path.ToUpperInvariant())) { FileItems.Add(new FileItem(entry.Fid, entry.Path, entry.Size, !Unchecked.Contains(entry.Fid))); } return(true); } else { return(false); } } else { return(true); } }
private void DeviceManager_PhotoCaptured(object sender, PhotoCapturedEventArgs eventArgs) { try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string tempFile = Path.Combine(Settings.Instance.TempFolder, Path.GetRandomFileName() + Path.GetExtension(eventArgs.FileName)); Utils.CreateFolder(tempFile); if (File.Exists(tempFile)) { File.Delete(tempFile); } eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tempFile); FileItem item = new FileItem() { TempFile = tempFile, Thumb = Utils.LoadImage(tempFile, 200), Variables = Context.WorkFlow.Variables.GetItemVariables() }; FileItems.Add(item); FileItem = item; Context.FileItem = FileItem; Utils.WaitForFile(tempFile); using (MemoryStream stream = new MemoryStream(File.ReadAllBytes(tempFile))) { Context.FileItem = item; Context.ImageStream = stream; OnMessage(new MessageEventArgs(Messages.PhotoDownloaded, FileItem) { Context = Context }); OnMessage(new MessageEventArgs(Messages.FileTransferred, Context) { Context = Context }); } } catch (Exception ex) { Log.Error("Error transfer file", ex); } }
private void DeviceManager_PhotoCaptured(object sender, PhotoCapturedEventArgs eventArgs) { try { // if no workflow loaded do nothing if (Context?.WorkFlow == null) { return; } string tempFile = Path.Combine(Settings.Instance.TempFolder, Path.GetRandomFileName() + Path.GetExtension(eventArgs.FileName)); // set in varieable the captured file original name Context?.WorkFlow?.Variables.SetValue("CapturedFileName", Path.GetFileNameWithoutExtension(eventArgs.FileName)); Utils.CreateFolder(tempFile); if (File.Exists(tempFile)) { File.Delete(tempFile); } eventArgs.CameraDevice.TransferFile(eventArgs.Handle, tempFile); eventArgs.CameraDevice.ReleaseResurce(eventArgs); if (!Context.CaptureEnabled) { // files should be transferred anyway if capture is enabled or not // to prevent camera buffer fill up Utils.DeleteFile(tempFile); Log.Debug("File transfer disabled"); return; } FileItem item = new FileItem() { TempFile = tempFile, Thumb = Utils.LoadImage(tempFile, 200), Variables = Context.WorkFlow.Variables.GetItemVariables() }; Bitmap = Utils.LoadImage(tempFile, 1090); FileItems.Add(item); FileItem = item; Context.FileItem = FileItem; Utils.WaitForFile(tempFile); Context.FileItem = item; OnMessage(new MessageEventArgs(Messages.PhotoDownloaded, FileItem) { Context = Context }); OnMessage(new MessageEventArgs(Messages.FileTransferred, Context) { Context = Context }); } catch (Exception ex) { Log.Error("Error transfer file", ex); } }
public InitCommand(InitCommandOptions options) { _options = options; _metadataQuestions = new IQuestion[] { new MultiAnswerQuestion( "What are the locations of your source code files?", (s, m, c) => { if (s != null) { var item = new FileMapping( new FileMappingItem(s) { SourceFolder = options.ApiSourceFolder }); m.Metadata.Add(new MetadataJsonItemConfig { Source = item, Destination = DefaultMetadataOutputFolder, }); m.Build.Content = new FileMapping(new FileMappingItem("api/**.yml", "api/index.md")); } }, new string[] { options.ApiSourceGlobPattern ?? "src/**.csproj" }) { Descriptions = new string[] { "Supported project files could be .sln, .csproj, .vbproj project files, or assembly files .dll, or .cs, .vb source files", Hints.Glob, Hints.Enter, } }, new MultiAnswerQuestion( "What are the locations of your markdown files overwriting triple slash comments?", (s, m, _) => { if (s != null) { var exclude = new FileItems(DefaultExcludeFiles); if (!string.IsNullOrEmpty(m.Build.Destination)) { exclude.Add($"{m.Build.Destination}/**"); } m.Build.Overwrite = new FileMapping(new FileMappingItem(s) { Exclude = exclude }); } }, new string[] { "apidoc/**.md" }) { Descriptions = new string[] { "You can specify markdown files with a YAML header to overwrite summary, remarks and description for parameters", Hints.Glob, Hints.Enter, } }, }; _overallQuestion = new IQuestion[] { new SingleAnswerQuestion( "Where to save the generated documentation?", (s, m, _) => m.Build.Destination = s, "_site") { Descriptions = new string[] { Hints.Enter, } }, }; _buildQuestions = new IQuestion[] { // TODO: Check if the input glob pattern matches any files // IF no matching: WARN [init]: There is no file matching this pattern. new MultiAnswerQuestion( "What are the locations of your conceptual files?", (s, m, _) => { if (s != null) { if (m.Build.Content == null) { m.Build.Content = new FileMapping(); } m.Build.Content.Add(new FileMappingItem(s)); } }, new string[] { "articles/**.md", "articles/**/toc.yml", "toc.yml", "*.md" }) { Descriptions = new string[] { "Supported conceptual files could be any text files. Markdown format is also supported.", Hints.Glob, Hints.Enter, } }, new MultiAnswerQuestion( "What are the locations of your resource files?", (s, m, _) => { if (s != null) { m.Build.Resource = new FileMapping(new FileMappingItem(s)); } }, new string[] { "images/**" }) { Descriptions = new string[] { "The resource files which conceptual files are referencing, e.g. images.", Hints.Glob, Hints.Enter, } }, new MultiAnswerQuestion( "Do you want to specify external API references?", (s, m, _) => { if (s != null) { m.Build.XRefMaps = new ListWithStringFallback(s); } }, null) { Descriptions = new string[] { "Supported external API references can be in either JSON or YAML format.", Hints.Enter, } }, new MultiAnswerQuestion( "What documentation templates do you want to use?", (s, m, _) => { if (s != null) { m.Build.Templates.AddRange(s); } }, new string[] { "default" }) { Descriptions = new string[] { "You can define multiple templates in order. The latter one will overwrite the former one if names collide", "Predefined templates in docfx are now: default, statictoc", Hints.Enter, } } }; _selectorQuestions = new IQuestion[] { new YesOrNoQuestion( "Does the website contain API documentation from source code?", (s, m, c) => { m.Build = new BuildJsonConfig(); if (s) { m.Metadata = new MetadataJsonConfig(); c.ContainsMetadata = true; } else { c.ContainsMetadata = false; } }), }; }
private void CalFileState() { if (this.FileState == FileStates.Receiving) { return; } try { this.tbName.ToolTip = System.IO.Path.GetFileName(this.FullName);//?.Split('\\').LastOrDefault(); } catch { return; } if (ChatViewModel == null) { ChatViewModel = AppData.MainMV.ChatListVM.SelectedItem; } else if (_targetModel.MessageState == MessageStates.Fail) { if (_operateTask != null) { _operateTask.Cancel(); } AcioningItems.Remove(this); } if (_targetModel == null && this.DataContext is MessageModel item) { _targetModel = item; var target = FileItems.FirstOrDefault(info => info.MsgKey == item.MsgKey); if (target == null) { target = item; FileItems.Add(item); } if (string.IsNullOrEmpty(target.MsgKey)) { target.MsgKey = Guid.NewGuid().ToString(); } this.DataContext = _targetModel = target; } if (this.IsMainView == false) { if (_targetModel.ResourceModel.FileState != FileStates.None) { return; } } //是否发送者 bool isSender = _targetModel.Sender.ID == AppData.Current.LoginUser.ID; _targetModel.ResourceModel.FileImg = Helper.FileHelper.GetFileImage(this.FullName, false); this.gridLayout.ToolTip = System.IO.Path.GetFileName(this.FullName); if (File.Exists(this.FullName)) { if (isSender && _targetModel.IsSending) { if (this._targetModel.ResourceModel.FileState == FileStates.SendOffline || this._targetModel.ResourceModel.FileState == FileStates.SendOnline) { } else { this.FileState = _targetModel.ResourceModel.FileState = FileStates.SendOnline; this.OnlineSend(); } } else { this.FileState = _targetModel.ResourceModel.FileState = FileStates.Completed; _completeTime = DateTime.Now.AddMinutes(-5); } } else { if (isSender) //发送者 { this.FileState = _targetModel.ResourceModel.FileState = FileStates.Completed; _completeTime = DateTime.Now.AddMinutes(-5); } else { this.FileState = _targetModel.ResourceModel.FileState = FileStates.WaitForReceieve; } } }
private void CalFileState() { if (ChatViewModel == null) { ChatViewModel = AppData.MainMV.ChatListVM.SelectedItem; } else if (_targetModel?.MessageState == MessageStates.Fail) { if (_operateTask != null) { _operateTask.Cancel(); } AcioningItems.Remove(this); } if (_targetModel == null && this.DataContext is MessageModel item) { this.PreviewMouseRightButtonUp -= SmallVideo_PreviewMouseRightButtonUp; _targetModel = item; var target = FileItems.FirstOrDefault(info => info.MsgKey == item.MsgKey); if (target == null) { target = item; FileItems.Add(item); } if (string.IsNullOrEmpty(target.MsgKey)) { target.MsgKey = Guid.NewGuid().ToString(); } _completeTime = _targetModel.SendTime; _isMine = _targetModel.IsMine; _isSync = _targetModel.IsSync; this.DataContext = _targetModel = target; if (_completeTime != null) { _targetModel.SendTime = _completeTime.Value; } _targetModel.IsMine = _isMine; _targetModel.IsSync = _isSync; //this.gridProgress.Visibility = Visibility.Visible; //this.borderPlay.Visibility = Visibility.Collapsed; } else { if (_targetModel != null) { return; } this.gridProgress.Visibility = Visibility.Collapsed; this.borderPlay.Visibility = Visibility.Visible; this.imgReset.Visibility = Visibility.Collapsed; this.imgDownload.Visibility = Visibility.Collapsed; this.PreviewMouseRightButtonUp += SmallVideo_PreviewMouseRightButtonUp; return; } if (SDKClient.SDKClient.Instance.property.CurrentAccount.Isforbidden) { _targetModel.MessageState = MessageStates.Warn; } //是否发送者 bool isSender = _targetModel.Sender.ID == AppData.Current.LoginUser.ID; string filePath = System.IO.Path.Combine(SDKClient.SDKClient.Instance.property.CurrentAccount.filePath, this.VideoPath); if (System.IO.File.Exists(filePath) || System.IO.File.Exists(this.VideoPath)) { if (isSender) //当前作为发送方 { if (_targetModel.IsSending) //若是正在发送中 { this.FileState = _targetModel.ResourceModel.FileState = FileStates.SendOffline; this.gridProgress.Visibility = Visibility.Visible; this.borderPlay.Visibility = Visibility.Collapsed; this.imgReset.Visibility = Visibility.Collapsed; this.imgDownload.Visibility = Visibility.Collapsed; SendVideo(); } else if (_targetModel.ResourceModel.DBState == 0) { this.gridProgress.Visibility = Visibility.Collapsed; this.borderPlay.Visibility = Visibility.Visible; this.imgReset.Visibility = Visibility.Collapsed; this.imgDownload.Visibility = Visibility.Collapsed; //HasContexMenu = true; } else { this.FileState = _targetModel.ResourceModel.FileState = FileStates.Completed; if (_targetModel.IsSync) { _completeTime = _targetModel.SendTime; } else if (_completeTime == null) { _completeTime = DateTime.Now.AddMinutes(-5); } } } else //当前用户作为接收方,若文件已有则认为已经成功 { this.FileState = _targetModel.ResourceModel.FileState = FileStates.Completed; if (_targetModel.IsSync) { _completeTime = _targetModel.SendTime; } else if (_completeTime == null) { _completeTime = DateTime.Now.AddMinutes(-5); } } } else { if (isSender) //发送者 { this.FileState = _targetModel.ResourceModel.FileState = FileStates.WaitForReceieve; if (_targetModel.IsSync) { _completeTime = _targetModel.SendTime; } else if (_completeTime == null) { _completeTime = DateTime.Now.AddMinutes(-5); } } else { this.FileState = _targetModel.ResourceModel.FileState = FileStates.WaitForReceieve; } } }