private void SetOpenWithButtonAndPath() { // share icon buttonShare.Visibility = ShareHelper.IsShareSupported(_path) ? Visibility.Visible : Visibility.Collapsed; // open icon if (Directory.Exists(_path)) { buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_BrowseFolder"), Path.GetFileName(_path)); return; } var isExe = FileHelper.IsExecutable(_path, out var appFriendlyName); if (isExe) { buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_Run"), appFriendlyName); return; } // not an exe var found = FileHelper.GetAssocApplication(_path, out appFriendlyName); if (found) { buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_OpenWith"), appFriendlyName); return; } // assoc not found buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_Open"), Path.GetFileName(_path)); }
private void ShareListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedItem = ShareListBox.SelectedItem as string; if (selectedItem == null) { return; } FlurryWP8SDK.Api.LogEvent("Wallpaper.Share"); var item = (ShareViewModel)ViewModel; if (selectedItem == AppResources.ShareEmail) { ShareHelper.ShareViaEmail(item); } else if (selectedItem == AppResources.ShareSocialNetwork) { ShareHelper.ShareViaSocial(item); } else if (selectedItem == AppResources.ShareTextMessaging) { ShareHelper.ShareViaSms(item); } else if (selectedItem == AppResources.ShareClipboard) { ShareHelper.ShareViaClipBoard(item); } ShareListBox.SelectedIndex = -1; }
public async Task<IActionResult> DownloadShare(string shareId) { if (string.IsNullOrWhiteSpace(shareId)) return NotFound(); (ShareHelper.AccessStatus allowed, Share share) = await ShareHelper.CanAccess(HttpContext, database, shareId); if (allowed == ShareHelper.AccessStatus.Denied) return NotFound(); share.LastAccessed = DateTime.Now; string path = Path.Combine(config.GetValue<string>("FileDirectory"), share.File.Identifier + ".file"); FileStream file = System.IO.File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); string filename = share.File.Filename + "." + share.File.Extension; new FileExtensionContentTypeProvider().TryGetContentType(filename, out string contentType); // Returns null on unkown file ending if (contentType == null) contentType = "application/octet-stream"; return File(file, contentType, filename, true); }
protected override void Execute(object content) { if (content is INiconicoContent niconicoContent) { var shareContent = ShareHelper.MakeShareTextWithTitle(niconicoContent); ClipboardHelper.CopyToClipboard(shareContent); } else if (content is string contentId) { var video = _nicoVideoProvider.GetCachedVideoInfo(contentId); if (video != null) { var shareContent = ShareHelper.MakeShareTextWithTitle(video); ClipboardHelper.CopyToClipboard(shareContent); } } else { ClipboardHelper.CopyToClipboard(content.ToString()); } _notificationService.ShowLiteInAppNotification_Success("Copy".Translate()); //Analytics.TrackEvent("CopyToClipboardWithShareTextCommand", new Dictionary<string, string> //{ //}); }
private async void HistoryAdapter_ShareItemRequested(object sender, HistoryListItem e) { if (e.Data.Data is ReceivedText) { await DataStorageProviders.TextReceiveContentManager.OpenAsync(); string text = DataStorageProviders.TextReceiveContentManager.GetItemContent(e.Data.Id); DataStorageProviders.TextReceiveContentManager.Close(); ShareHelper.ShareText(this, text); } else if (e.Data.Data is ReceivedUrl) { ShareHelper.ShareText(this, (e.Data.Data as ReceivedUrl).Uri.OriginalString); } else if (e.Data.Data is ReceivedFile || e.Data.Data is ReceivedFileCollection) { ReceivedFile receivedFile; if (e.Data.Data is ReceivedFile) { receivedFile = e.Data.Data as ReceivedFile; } else { receivedFile = (e.Data.Data as ReceivedFileCollection).Files.First(); } Java.IO.File file = new Java.IO.File(Path.Combine(receivedFile.StorePath, receivedFile.Name)); ShareHelper.ShareFile(this, file); } }
async private void shareFile_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { string installPath = Package.Current.InstalledLocation.Path; StorageFile file = await StorageFile.GetFileFromPathAsync(installPath + @"\Assets\Share\espresso_450x450.jpg"); ShareHelper.ShareFiles(file); }
protected override void Execute(object content) { Uri uri = null; if (content is INiconicoObject niconicoContent) { uri = ShareHelper.ConvertToUrl(niconicoContent); // TODO: } else if (content is Uri uriContent) { uri = uriContent; } else if (content is string str) { uri = new Uri(str); } if (uri != null) { _ = Windows.System.Launcher.LaunchUriAsync(uri); //Analytics.TrackEvent("OpenLinkCommand", new Dictionary<string, string> //{ //}); } }
public bool Trade() { if (User == null || User.Id <= 0) { return(false); } var totalCost = (LatestPrice * TradeSharesCount); var sh = new ShareHelper(); var db = sh._db; var datauser = db.Users.Where(du => du.Id == User.Id).FirstOrDefault(); var dataportfolio = db.Portfolios.Include(p => p.Shares).Where(p => p.Id == User.Portfolio.Id).FirstOrDefault(); if (State == "Buy") { if (LatestVolume < TradeSharesCount || totalCost > User.AccountBalance) { return(false); } } if (State == "Sell") { var sl = dataportfolio.Shares.Where(s => s.Symbol == Symbol).ToList(); var cnt = 0; foreach (var item in sl) { cnt += item.NumberOfShares; } if (LatestVolume < TradeSharesCount || TradeSharesCount > cnt) { return(false); } totalCost = -totalCost; TradeSharesCount = -TradeSharesCount; } var share = new Share() { Symbol = Symbol.ToUpper(), NumberOfShares = TradeSharesCount, Price = LatestPrice, State = State, TimeStamp = DateTime.Now }; sh.SetShare(share); var datashare = db.Shares.Where(s => s.Symbol == Symbol).LastOrDefault(); dataportfolio.Shares.Add(datashare); datauser.AccountBalance -= totalCost; db.SaveChanges(); return(true); }
protected override void Execute(object content) { if (content is INiconicoObject nicoContent) { ShareHelper.Share(nicoContent); //Analytics.TrackEvent("OpenShareUICommand", new Dictionary<string, string> //{ // { "ContentType", content.GetType().Name } //}); } }
public async Task <IActionResult> OnGetAsync(string shareId) { if (string.IsNullOrWhiteSpace(shareId)) { return(NotFound()); } ShareName = shareId; (ShareHelper.AccessStatus allowed, Share share) = await ShareHelper.CanAccess(HttpContext, database, shareId); if (share != null && !share.DontTrack) { database.Visits.Add(new() { Access = allowed, Date = DateTime.Now, IP = Request.Headers["X-Forwarded-For"], UserAgent = Request.Headers["User-Agent"], Share = share, User = userManager.GetUser(HttpContext) }); await database.SaveChangesAsync(); } if (allowed == ShareHelper.AccessStatus.Denied) { await database.SaveChangesAsync(); return(NotFound()); } share.LastAccessed = DateTime.Now; await database.SaveChangesAsync(); IsOwner = allowed == ShareHelper.AccessStatus.Owner; FileId = share.File.Id; ShareId = share.Id; FileViewInfo = new FileViewInfo() { FileName = share.File.Filename + "." + share.File.Extension, SourcePath = "/d/" + shareId }; return(Page()); }
public ShareHelperTests() { uh = new UserHelper(new InMemoryDbContext()); sh = new ShareHelper(new InMemoryDbContext()); ih = new IdentityHelper(new InMemoryDbContext()); Share1 = new Share() { NumberOfShares = 100, Price = 50, Symbol = "GOOG" }; Share2 = new Share() { NumberOfShares = 100, Price = 100, Symbol = "GOOG" }; Share3 = new Share() { NumberOfShares = 40, Price = 1000, Symbol = "MSFT" }; User = new User() { AccountBalance = (double)5000m, Portfolio = new Portfolio() { Shares = new List <Share>() { Share1, Share2 } }, Identity = new Identity() { Name = new Name() { First = "James", Last = "Bond" } } }; }
protected override void Execute(object content) { if (content is INiconicoObject niconicoContent) { var uri = ShareHelper.ConvertToUrl(niconicoContent); ClipboardHelper.CopyToClipboard(uri.OriginalString); } else { ClipboardHelper.CopyToClipboard(content.ToString()); } _notificationService.ShowLiteInAppNotification_Success("Copy".Translate()); //Analytics.TrackEvent("CopyToClipboardCommand", new Dictionary<string, string> //{ //}); }
private async void GifHelper_OnGifCreated(object sender, GifCreatedEventArgs e) { GifHelper.OnGifCreated -= GifHelper_OnGifCreated; ExitScreen(); if (e.Success) { var sharer = new ShareHelper(ScreenManager.Game); await sharer.ShareImage(e.Filename, ShareText); } else { var messageDisplay = ScreenManager.Game.Services.GetService <IToastBuddy>(); messageDisplay.ShowMessage($"Error creating gif", Color.Yellow); await ScreenManager.AddScreen(new OkScreen(e.ErrorMessage)); } }
public void ShareEvent() { try { this.ViewModel.OperationInProgress = true; StringBuilder builder = new StringBuilder(); builder.Append("I am attending"); builder.Append("\n"); builder.Append(string.Format("{0}, registration Link {1}", this.ViewModel.Event.EventName, this.ViewModel.Event.EventRegLink)); ShareHelper.Share(builder.ToString()); } catch (Exception ex) { } finally { this.ViewModel.OperationInProgress = false; } }
/// <summary> /// 分享 /// </summary> /// <param name="video"></param> public void Share(Video video) { ShareDialog dialog = new ShareDialog(); dialog.WechatClick += (s, a) => { ShareHelper.WeChatShare(video.Title, video.ShareUrl); }; dialog.LinkClick += (s, a) => { ShareHelper.CopyLink(video.Title); }; dialog.MoreClick += (s, a) => { ShareHelper.SystemShare(video.Title, video.ShareUrl); //DataTransferManager.ShowShareUI(); }; dialog.Show(); }
public void ShareEvent() { try { this.ProgressBar.IsRunning = true; this.ProgressBar.IsVisible = true; var resourceData = _resource as LearningResource; StringBuilder builder = new StringBuilder(); builder.Append("Useful resource"); builder.Append("\n"); builder.Append(string.Format("{0}, Link {1}", resourceData.Title, resourceData.Link)); ShareHelper.Share(builder.ToString()); } catch (Exception ex) { } finally { this.ProgressBar.IsRunning = false; this.ProgressBar.IsVisible = false; } }
internal ViewerWindow() { // this object should be initialized before loading UI components, because many of which are binding to it. ContextObject = new ContextObject(); ContextObject.PropertyChanged += ContextObject_PropertyChanged; InitializeComponent(); Icon = (App.IsWin10 ? Properties.Resources.app_white_png : Properties.Resources.app_png).ToBitmapSource(); FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI")); SizeChanged += SaveWindowSizeOnSizeChanged; StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true; windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer; Topmost = SettingHelper.Get("Topmost", false); buttonTop.Tag = Topmost ? "Top" : "Auto"; buttonTop.Click += (sender, e) => { Topmost = !Topmost; SettingHelper.Set("Topmost", Topmost); buttonTop.Tag = Topmost ? "Top" : "Auto"; }; buttonPin.Click += (sender, e) => { if (Pinned) { return; } ViewWindowManager.GetInstance().ForgetCurrentWindow(); }; buttonCloseWindow.Click += (sender, e) => { if (Pinned) { BeginClose(); } else { ViewWindowManager.GetInstance().ClosePreview(); } }; buttonOpen.Click += (sender, e) => { if (Pinned) { RunAndClose(); } else { ViewWindowManager.GetInstance().RunAndClosePreview(); } }; buttonWindowStatus.Click += (sender, e) => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; buttonShare.Click += (sender, e) => ShareHelper.Share(_path, this); buttonOpenWith.Click += (sender, e) => ShareHelper.Share(_path, this, true); }
private void shareUri_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ShareHelper.ShareUri(new Uri("http://en.wikipedia.org/wiki/Coffee", UriKind.Absolute)); }
public Uri GetCategoryUrl(string category) { return(new Uri(string.Format("http://www.indeed.com/q-{0}-jobs.html", ShareHelper.FillSpace(category, "-")))); }
public Uri GetTitleUrlWithPaging() { return(new Uri(string.Format("https://www.indeed.com/jobs?q={0}&start={1}", ShareHelper.FillSpace(this.Title, "+"), this.PageCount.ToString()))); }
internal ViewerWindow() { // this object should be initialized before loading UI components, because many of which are binding to it. ContextObject = new ContextObject(); ContextObject.PropertyChanged += ContextObject_PropertyChanged; InitializeComponent(); Icon = (App.IsWin10 ? Properties.Resources.app_white_png : Properties.Resources.app_png).ToBitmapSource(); FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI")); SizeChanged += SaveWindowSizeOnSizeChanged; StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true; // bring the window to top when users click in the client area. // the non-client area is handled by the WndProc inside OnSourceInitialized(). // This is buggy for Windows 7 and 8: https://github.com/QL-Win/QuickLook/issues/644#issuecomment-628921704 if (App.IsWin10) { PreviewMouseDown += (sender, e) => this.BringToFront(false); } windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer; Topmost = SettingHelper.Get("Topmost", false); buttonTop.Tag = Topmost ? "Top" : "Auto"; buttonTop.Click += (sender, e) => { Topmost = !Topmost; SettingHelper.Set("Topmost", Topmost); buttonTop.Tag = Topmost ? "Top" : "Auto"; }; buttonPin.Click += (sender, e) => { if (Pinned) { return; } ViewWindowManager.GetInstance().ForgetCurrentWindow(); }; buttonCloseWindow.Click += (sender, e) => { if (Pinned) { BeginClose(); } else { ViewWindowManager.GetInstance().ClosePreview(); } }; buttonOpen.Click += (sender, e) => { if (Pinned) { RunAndClose(); } else { ViewWindowManager.GetInstance().RunAndClosePreview(); } }; buttonWindowStatus.Click += (sender, e) => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; buttonShare.Click += (sender, e) => ShareHelper.Share(_path, this); buttonOpenWith.Click += (sender, e) => ShareHelper.Share(_path, this, true); }
private void DataAdapter_ShareFileRequested(object sender, ReceivedFile e) { ShareHelper.ShareFile(this, new Java.IO.File(Path.Combine(e.StorePath, e.Name))); }
private void ShareByWeChatAppBarButton_Tapped(object sender, TappedRoutedEventArgs e) { ShareHelper.Share2UserChoose(this._url, this._title); this.Hide(); }
internal void Share(object sender, RoutedEventArgs e) { ShareHelper.Share(_path, this); }
private void SetOpenWithButtonAndPath() { // share icon buttonShare.Visibility = ShareHelper.IsShareSupported(_path) ? Visibility.Visible : Visibility.Collapsed; // open icon buttonOpenText.Inlines.Clear(); if (Directory.Exists(_path)) { AddToInlines("MW_BrowseFolder", Path.GetFileName(_path)); return; } var isExe = FileHelper.IsExecutable(_path, out var appFriendlyName); if (isExe) { AddToInlines("MW_Run", appFriendlyName); return; } // not an exe var found = FileHelper.GetAssocApplication(_path, out appFriendlyName); if (found) { AddToInlines("MW_OpenWith", appFriendlyName); return; } // assoc not found AddToInlines("MW_Open", Path.GetFileName(_path)); void AddToInlines(string str, string replaceWith) { // limit str length if (replaceWith.Length > 16) { replaceWith = replaceWith.Substring(0, 8) + "…" + replaceWith.Substring(replaceWith.Length - 8); } str = TranslationHelper.Get(str); var elements = str.Split(new[] { "{0}" }, StringSplitOptions.None).ToList(); while (elements.Count < 2) { elements.Add(string.Empty); } buttonOpenText.Inlines.Add( new Run(elements[0]) { FontWeight = FontWeights.Normal }); // text beforehand buttonOpenText.Inlines.Add( new Run(replaceWith) { FontWeight = FontWeights.SemiBold }); // appFriendlyName buttonOpenText.Inlines.Add( new Run(elements[1]) { FontWeight = FontWeights.Normal }); // text afterward } }
private void shareText_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ShareHelper.ShareText(LocalizableStrings.SHARE_TEXT_CONTENT); }