Ejemplo n.º 1
0
        public ActionResult AddQuickLink(int Page_ID, int Link_List_ID, string Display_Text, string URL)
        {
            QuickLinkList qList = db.QuickLinkLists.Find(Link_List_ID);
            QuickLinkListEditViewModel viewMod = new QuickLinkListEditViewModel(qList, Page_ID);

            if (Display_Text.Trim() == "")
            {
                ModelState.AddModelError("", "'Display Text' must be filled out");
                return(View("Edit", viewMod));
            }
            else if (URL.Trim() == "")
            {
                ModelState.AddModelError("", "'URL' must be filled out");
                return(View("Edit", viewMod));
            }
            else
            {
                QuickLink link = new QuickLink();
                link.URL          = URL;
                link.Display_Text = Display_Text;
                link.Archived     = false;
                link.Date_Added   = DateTime.Now;
                link.Added_By     = User.Identity.Name;
                link.Link_List_ID = Link_List_ID;
                db.QuickLinks.Add(link);
                db.SaveChanges();

                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Link_List_ID = Link_List_ID }));
            }
        }
Ejemplo n.º 2
0
        internal int CreateLinks(CatalogItem ci)
        {
            QuickLink ql;
            int       count   = -1;
            bool      success = true;

            if (!Int32.TryParse(Property.Get("QuickLink_Count"), out count))
            {
                // TODO: The parsing attempt failed
            }

            if (count <= 1)
            {
                return(count);
            }

            for (int i = 1; i <= count; i++)
            {
                if (success == false)
                {
                    return(i);
                }

                ql      = new QuickLink(ci.ItemID, i);
                success = db.CreateQuickLink(ql);
            }
            return(count);
        }
Ejemplo n.º 3
0
        private void InitializeQuickLinks()
        {
            addedQuickLinksSet = new HashSet <string>();

            Vector2 anchoredPos = new Vector2(0f, -quickLinksContainer.sizeDelta.y);

            if (generateQuickLinksForDrives)
            {
                string[] drives = Directory.GetLogicalDrives();

                for (int i = 0; i < drives.Length; i++)
                {
                    AddQuickLink(driveIcon, drives[i], drives[i], ref anchoredPos);
                }
            }

            for (int i = 0; i < quickLinks.Length; i++)
            {
                QuickLink quickLink     = quickLinks[i];
                string    quickLinkPath = Environment.GetFolderPath(quickLink.target);

                AddQuickLink(quickLink.icon, quickLink.name, quickLinkPath, ref anchoredPos);
            }

            quickLinksContainer.sizeDelta = new Vector2(0f, -anchoredPos.y);
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            QuickLink quicklink = db.QuickLinks.Find(id);

            db.QuickLinks.Remove(quicklink);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This thread code starts the device, reads and frame, and then
        /// sleeps.  When the PictureBox paint event wakes it up, then it reads
        /// another frame.  When the form is closing, it stops the device and
        /// exits.
        /// </summary>
        private void ReaderThreadTask()
        {
            this.Display(string.Format("Reading from device.  Updating Every: {0} ms.\n", MinDelayBetweenReads));

            // Load QuickLink DLL files.
            QuickLink QL;

            try
            {
                QL = new QuickLink();
                this.Display("QuickLink loaded.  Be sure to start QuickGlance, if you have not already.\n");
            }
            catch (Exception e)
            {
                this.Display(string.Format("Failed to load QuickLink.  MSG: {0}.\n", e.Message));
                // Can't continue without QuickLink.
                return;
            }

            // Create an empty frame structure to hold the data we read.
            ImageData iDat = new ImageData();

            while (true)
            {
                // Sleep while the last frame is in use and we aren't shutting down.
                lock (this.l)
                    while (this.frameInUse && !this.isClosing)
                    {
                        Monitor.Wait(this.l);
                    }

                // Break if the program is closing.
                if (this.isClosing)
                {
                    break;
                }

                // Read a new data sample.
                bool success = QL.GetImageData(MaxFrameWaitTime, ref iDat);
                if (success)
                {
                    // Tell the paint event handler to display the frame.
                    this.frameInUse = true;

                    // Update the form's display.
                    UpdateReadout(ref iDat);

                    if (MinDelayBetweenReads > 0)
                    {
                        Thread.Sleep(MinDelayBetweenReads);
                    }
                }
                else
                {
                    // Failed.
                }
            }
        }
Ejemplo n.º 6
0
        private void SaveContent()
        {
            var quickLink = new QuickLink
            {
                Id    = "LL.ShareTarget",
                Title = "Share Target"
            };

            _shareOperation.ReportCompleted(quickLink);
        }
Ejemplo n.º 7
0
        //
        // GET: /QuickLink/Delete/5

        public ActionResult Delete(int id = 0)
        {
            QuickLink quicklink = db.QuickLinks.Find(id);

            if (quicklink == null)
            {
                return(HttpNotFound());
            }
            return(View(quicklink));
        }
Ejemplo n.º 8
0
        //
        // GET: /QuickLink/Edit/5

        public ActionResult Edit(int id = 0)
        {
            QuickLink quicklink = db.QuickLinks.Find(id);

            if (quicklink == null)
            {
                return(HttpNotFound());
            }
            ViewBag.HomeModelId = new SelectList(db.HomeModels, "HomeModelId", "BuildServerName", quicklink.HomeModelId);
            return(View(quicklink));
        }
Ejemplo n.º 9
0
 public ActionResult Edit(QuickLink quicklink)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quicklink).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HomeModelId = new SelectList(db.HomeModels, "HomeModelId", "BuildServerName", quicklink.HomeModelId);
     return(View(quicklink));
 }
Ejemplo n.º 10
0
        public ActionResult Create(QuickLink quicklink)
        {
            if (ModelState.IsValid)
            {
                db.QuickLinks.Add(quicklink);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HomeModelId = new SelectList(db.HomeModels, "HomeModelId", "BuildServerName", quicklink.HomeModelId);
            return(View(quicklink));
        }
        private async void OnReportSuccessClick(Object sender, RoutedEventArgs e)
        {
            var useQuickLink = (Boolean)(DefaultViewModel["UseQuickLink"] ?? false);

            if (useQuickLink)
            {
                // Make sure a thumbnail is available
                if (_shareOperation.Data.Properties.Square30x30Logo == null)
                {
                    return;
                }
                var quickLinkThumbnail = RandomAccessStreamReference.CreateFromStream(await _shareOperation.Data.Properties.Square30x30Logo.OpenReadAsync());

                // Make sure a title is available
                var quickLinkTitle = (DefaultViewModel["QuickLinkTitle"] ?? String.Empty).ToString();
                if (String.IsNullOrWhiteSpace(quickLinkTitle))
                {
                    return;
                }

                var quickLinkTag = (DefaultViewModel["QuickLinkTag"] ?? String.Empty).ToString();
                if (String.IsNullOrWhiteSpace(quickLinkTag))
                {
                    return;
                }

                var quickLink = new QuickLink
                {
                    SupportedFileTypes = { "*" },
                    Thumbnail          = quickLinkThumbnail,
                    Title = quickLinkTitle,
                    Id    = quickLinkTag,
                };

                // Just reuse the current set of data formats, though it could be selective
                // based on the context of how the id value will be used.
                var quickLinkFormats = _shareOperation.Data.AvailableFormats;
                foreach (var item in quickLinkFormats)
                {
                    quickLink.SupportedDataFormats.Add(item);
                }

                _shareOperation.ReportCompleted(quickLink);
            }
            else
            {
                // Close the UI and inform Windows that the sharing completed succesfully
                _shareOperation.ReportCompleted();
            }
        }
Ejemplo n.º 12
0
        async void ReportCompleted_Click(object sender, RoutedEventArgs e)
        {
            if (AddQuickLink.IsChecked.Equals(true))
            {
                QuickLink quickLinkInfo = new QuickLink
                {
                    Id    = QuickLinkId.Text,
                    Title = QuickLinkTitle.Text,

                    // For QuickLinks, the supported FileTypes and DataFormats are set independently from the manifest.
                    SupportedFileTypes   = { "*" },
                    SupportedDataFormats =
                    {
                        StandardDataFormats.Text,
                        StandardDataFormats.WebLink,
                        StandardDataFormats.ApplicationLink,
                        StandardDataFormats.Bitmap,
                        StandardDataFormats.StorageItems,
                        StandardDataFormats.Html,
                        dataFormatName
                    }
                };

                try
                {
                    StorageFile iconFile = await Package.Current.InstalledLocation.CreateFileAsync("assets\\user.png", CreationCollisionOption.OpenIfExists);

                    quickLinkInfo.Thumbnail = RandomAccessStreamReference.CreateFromFile(iconFile);
                    this.shareOperation.ReportCompleted(quickLinkInfo);
                }
                catch (Exception)
                {
                    // Even if the QuickLink cannot be created it is important to call ReportCompleted. Otherwise, if this is a long-running share,
                    // the app will stick around in the long-running share progress list.
                    this.shareOperation.ReportCompleted();
                    throw;
                }
            }
            else
            {
                this.shareOperation.ReportCompleted();
            }
        }
Ejemplo n.º 13
0
        private async void OnReportSuccessClick(Object sender, RoutedEventArgs e)
        {
            var useQuickLink = (Boolean)(DefaultViewModel["UseQuickLink"] ?? false);

            if (useQuickLink)
            {
                // Make sure a thumbnail is available
                if (_shareOperation.Data.Properties.Square30x30Logo == null)
                {
                    return;
                }
                var quickLinkThumbnail = RandomAccessStreamReference.CreateFromStream(await _shareOperation.Data.Properties.Square30x30Logo.OpenReadAsync());

                // Make sure a title is available
                var quickLinkTitle = (DefaultViewModel["QuickLinkTitle"] ?? String.Empty).ToString();
                if (String.IsNullOrWhiteSpace(quickLinkTitle))
                {
                    return;
                }

                var quickLinkTag = (DefaultViewModel["QuickLinkTag"] ?? String.Empty).ToString();
                if (String.IsNullOrWhiteSpace(quickLinkTag))
                {
                    return;
                }

                var quickLink = new QuickLink
                {
                    Id = quickLinkTag,
                    SupportedDataFormats = { StandardDataFormats.Bitmap },
                    SupportedFileTypes   = { "*" },
                    Thumbnail            = quickLinkThumbnail,
                    Title = quickLinkTitle
                };
                _shareOperation.ReportCompleted(quickLink);
            }
            else
            {
                // Close the UI and inform Windows that the sharing completed succesfully
                _shareOperation.ReportCompleted();
            }
        }
Ejemplo n.º 14
0
        private static void Main(string[] args)
        {
            // Load Quick Glance; and load the QuickLink DLLs into our
            // address space.
            QuickLink QL;

            try
            {
                QL = new QuickLink();
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Failed to load QuickLink.  MSG: {0}.", e.Message));
                // Can't continue without QuickLink.
                return;
            }

            // Create an empty frame to hold newly read data.
            ImageData iDat = new ImageData();

            Console.WriteLine("Time, Width, Height" +
                              ", Left Eye Found, Left Eye Calibrated, Left Eye Pupil X, Left Eye Pupil Y, Left Eye Pupil Diameter, Left Eye Glint1 X, Left Eye Glint1 Y, Left Eye Glint2 X, Left Eye Glint2 Y, Left Eye GazePoint X, Left Eye GazePoint Y" +
                              ", Right Eye Found, Right Eye Calibrated, Right Eye Pupil X, Right Eye Pupil Y, Right Eye Pupil Diameter, Right Eye Glint1 X, Right Eye Glint1 Y, Right Eye Glint2 X, Right Eye Glint2 Y, Right Eye GazePoint X, Right Eye GazePoint Y");

            while (true)
            {
                // Read a new data sample.
                if (QL.GetImageData(MaxFrameWaitTime, ref iDat))
                {
                    string headerString   = string.Format("{0},{1},{2}", iDat.Time, iDat.Width, iDat.Height);
                    string leftEyeString  = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", iDat.LeftEye.Found, iDat.LeftEye.Calibrated, iDat.LeftEye.Pupil.x, iDat.LeftEye.Pupil.y, iDat.LeftEye.PupilDiameter, iDat.LeftEye.Glint1.x, iDat.LeftEye.Glint1.y, iDat.LeftEye.Glint2.x, iDat.LeftEye.Glint2.y, iDat.LeftEye.GazePoint.x, iDat.LeftEye.GazePoint.y);
                    string rightEyeString = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", iDat.RightEye.Found, iDat.RightEye.Calibrated, iDat.RightEye.Pupil.x, iDat.RightEye.Pupil.y, iDat.RightEye.PupilDiameter, iDat.RightEye.Glint1.x, iDat.RightEye.Glint1.y, iDat.RightEye.Glint2.x, iDat.RightEye.Glint2.y, iDat.RightEye.GazePoint.x, iDat.RightEye.GazePoint.y);

                    Console.WriteLine(string.Format("{0},{1},{2}", headerString, leftEyeString, rightEyeString));
                }

                if (MinDelayBetweenReads > 0)
                {
                    Thread.Sleep(MinDelayBetweenReads);
                }
            }
        }
Ejemplo n.º 15
0
        public ActionResult RemoveQuickLink(int Page_ID, int Link_List_ID, int Quick_Link_ID)
        {
            QuickLink link = db.QuickLinks.Find(Quick_Link_ID);

            if (link != null)
            {
                link.Archived    = true;
                link.Date_Added  = DateTime.Now;
                link.Archived_By = User.Identity.Name;
                db.SaveChanges();
                return(RedirectToAction("Edit", new { Page_ID = Page_ID, Link_List_ID = Link_List_ID }));
            }
            else
            {
                QuickLinkList qList = db.QuickLinkLists.Find(Link_List_ID);
                QuickLinkListEditViewModel viewMod = new QuickLinkListEditViewModel(qList, Page_ID);
                ModelState.AddModelError("", "No Quick Link Found with the ID '" + Quick_Link_ID + "'");
                return(View("Edit", viewMod));
            }
        }
Ejemplo n.º 16
0
        // Note that the following code if for snippeting only. It's not actually called in
        // this app. It's derived from the SharingTarget sample, so I'm confident it works.

        // <Snippetcs_HowToCreateAQuickLink>
        async void ReportCompleted(ShareOperation shareOperation, string quickLinkId, string quickLinkTitle)
        {
            QuickLink quickLinkInfo = new QuickLink
            {
                Id    = quickLinkId,
                Title = quickLinkTitle,

                // For quicklinks, the supported FileTypes and DataFormats are set
                // independently from the manifest
                SupportedFileTypes   = { "*" },
                SupportedDataFormats = { StandardDataFormats.Text,   StandardDataFormats.Uri,
                                         StandardDataFormats.Bitmap, StandardDataFormats.StorageItems }
            };

            StorageFile iconFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFileAsync(
                "assets\\user.png", CreationCollisionOption.OpenIfExists);

            quickLinkInfo.Thumbnail = RandomAccessStreamReference.CreateFromFile(iconFile);
            shareOperation.ReportCompleted(quickLinkInfo);
        }
Ejemplo n.º 17
0
        internal bool CreateQuickLink(QuickLink QL)
        {
            // In a using statement, acquire the SqlConnection
            using (SqlConnection con = new SqlConnection(Helper.CONNECTION_NOVOTEK_REPORTPLUS))
            {
                // Open the SqlConnection.
                con.Open();

                string query = ""
                               + "INSERT INTO QuickLinks("
                               + "ReportId, "
                               + "Name, "
                               + "Description, "
                               + "StartTimeId, "
                               + "DurationId, "
                               + "SampleIntervalId) "
                               + "VALUES("
                               + "@ReportId, "
                               + "@Name, "
                               + "@Description, "
                               + "@StartTimeId, "
                               + "@DurationId, "
                               + "@SampleIntervalId)";

                using (SqlCommand command = new SqlCommand(query, con))
                {
                    command.Parameters.AddWithValue("@ReportId", QL.GUID);
                    command.Parameters.AddWithValue("@Name", QL.Name);
                    command.Parameters.AddWithValue("@Description", QL.Description);
                    command.Parameters.AddWithValue("@StartTimeId", QL.StartTime);
                    command.Parameters.AddWithValue("@DurationId", QL.Duration);
                    command.Parameters.AddWithValue("@SampleIntervalId", QL.Interval);

                    //Rows affected
                    return(command.ExecuteNonQuery() > 0 ? true : false);
                }
            }
        }
Ejemplo n.º 18
0
        /*
         * 关于 QuickLink 的相关说明如下
         * 注:经测试,在我的 windows 10 环境中,此部分内容无效(应该是 windows 10 已经不再支持 QuickLink 了)
         *
         * ShareOperation - 分享操作的相关信息
         *     QuickLinkId - 如果是 QuickLink 激活的,此属性可获取此 QuickLink 的 Id
         *     RemoveThisQuickLink() - 如果是 QuickLink 激活的,此方法可删除此 QuickLink
         *     ReportCompleted(QuickLink quicklink) - 指定一个需要增加的 QuickLink 对象,然后通知系统分享操作已经完成(会自动关闭分享面板)
         *
         * QuickLink - 预定义了一些数据,指向相应分享目标的一个快捷方式,其会出现在分享面板的上部
         *     Id - 预定义数据
         *     Title - QuickLink 出现在分享面板上的时候所显示的名称
         *     Thumbnail - QuickLink 出现在分享面板上的时候所显示的图标
         *     SupportedDataFormats - 分享数据中所包含的数据格式与此定义相匹配(有一个匹配即可),QuickLink 才会出现在分享面板上
         *     SupportedFileTypes - 分享数据中所包含的文件的扩展名与此定义的相匹配(有一个匹配即可),QuickLink 才会出现在分享面板上
         *
         * QuickLink 的适用场景举例
         * 1、当用户总是分享信息到某一个邮件地址时,便可以在分享目标中以此邮件地址为 QuickLinkId 生成一个 QuickLink
         * 2、下回用户再分享时,此 QuickLink 就会出现在分享面板上,用户在分享面板上可以点击此 QuickLink 激活分享目标
         * 3、分享目标被 QuickLink 激活后便可以通过 ShareOperation 对象获取到 QuickLink,然后就可以拿到用户需要分享到的邮件地址(就是 QuickLink 的 Id),从而避免用户输入此邮件地址,从而方便用户的分享操作
         */

        // 演示如何增加一个 QuickLink
        private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            OutputMessage("QuickLinkId: " + _shareOperation.QuickLinkId);

            QuickLink quickLink = new QuickLink
            {
                Id    = "*****@*****.**",
                Title = "分享到邮件: [email protected]", // QuickLink 在分享面板上显示的内容

                SupportedFileTypes   = { "*" },
                SupportedDataFormats =
                {
                    StandardDataFormats.Text,
                    StandardDataFormats.WebLink,
                    StandardDataFormats.ApplicationLink,
                    StandardDataFormats.Bitmap,
                    StandardDataFormats.StorageItems,
                    StandardDataFormats.Html,
                    "http://webabcd/sharedemo"
                }
            };

            try
            {
                // 设置 QuickLink 在分享面板上显示的图标
                StorageFile iconFile = await Package.Current.InstalledLocation.CreateFileAsync("Assets\\StoreLogo.png", CreationCollisionOption.OpenIfExists);

                quickLink.Thumbnail = RandomAccessStreamReference.CreateFromFile(iconFile);

                // 完成分享操作,同时在分享面板上增加一个指定的 QuickLink
                _shareOperation.ReportCompleted(quickLink);
            }
            catch (Exception ex)
            {
                OutputMessage(ex.ToString());
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Specifies that the sharing operation is complete.
 /// </summary>
 /// <param name="quickLink">A <see cref="QuickLink">quick link</see> that the system saves as a shortcut for future sharing operations.</param>
 public void ReportCompleted( QuickLink quickLink ) => adapted.ReportCompleted( quickLink );
Ejemplo n.º 20
0
        private void InitializeQuickLinks()
        {
            addedQuickLinksSet = new HashSet <string>();

            Vector2 anchoredPos = new Vector2(0f, -quickLinksContainer.sizeDelta.y);

            if (generateQuickLinksForDrives)
            {
#if !UNITY_EDITOR && UNITY_ANDROID
                string drivesList = AJC.CallStatic <string>("GetExternalDrives");
                if (drivesList != null && drivesList.Length > 0)
                {
                    bool     defaultPathInitialized = false;
                    int      driveIndex             = 1;
                    string[] drives = drivesList.Split(':');
                    for (int i = 0; i < drives.Length; i++)
                    {
                        try
                        {
                            //string driveName = new DirectoryInfo( drives[i] ).Name;
                            //if( driveName.Length <= 1 )
                            //{
                            //	try
                            //	{
                            //		driveName = Directory.GetParent( drives[i] ).Name + "/" + driveName;
                            //	}
                            //	catch
                            //	{
                            //		driveName = "Drive " + driveIndex++;
                            //	}
                            //}

                            string driveName;
                            if (!defaultPathInitialized)
                            {
                                DEFAULT_PATH           = drives[i];
                                defaultPathInitialized = true;

                                driveName = "Primary Drive";
                            }
                            else
                            {
                                if (driveIndex == 1)
                                {
                                    driveName = "External Drive";
                                }
                                else
                                {
                                    driveName = "External Drive " + driveIndex;
                                }

                                driveIndex++;
                            }

                            AddQuickLink(driveIcon, driveName, drives[i], ref anchoredPos);
                        }
                        catch { }
                    }
                }
#elif !UNITY_EDITOR && (UNITY_IOS || UNITY_WSA || UNITY_WSA_10_0)
                AddQuickLink(driveIcon, "Files", Application.persistentDataPath, ref anchoredPos);
#else
                string[] drives = Directory.GetLogicalDrives();

                for (int i = 0; i < drives.Length; i++)
                {
                    AddQuickLink(driveIcon, drives[i], drives[i], ref anchoredPos);
                }
#endif
            }

#if UNITY_EDITOR || (!UNITY_ANDROID && !UNITY_WSA && !UNITY_WSA_10_0)
            for (int i = 0; i < quickLinks.Length; i++)
            {
                QuickLink quickLink     = quickLinks[i];
                string    quickLinkPath = Environment.GetFolderPath(quickLink.target);

                AddQuickLink(quickLink.icon, quickLink.name, quickLinkPath, ref anchoredPos);
            }
#endif

            quickLinksContainer.sizeDelta = new Vector2(0f, -anchoredPos.y);
        }
Ejemplo n.º 21
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var key = parameter as StateItemKey;

            if (key != null && SessionState.Contains(key))
            {
                ShareOperation = SessionState.Get <ShareOperation>(key);
            }
            else
            {
                Content = "Opened without using share";
                return;
            }

            try
            {
                if (this.ShareOperation.Data.Contains(StandardDataFormats.Html))
                {
                    Content = (await ShareOperation.Data.GetHtmlFormatAsync()).ToString();
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.Text))
                {
                    Content = (await ShareOperation.Data.GetTextAsync()).ToString();
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.WebLink))
                {
                    Content = (await ShareOperation.Data.GetWebLinkAsync()).AbsoluteUri;
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.ApplicationLink))
                {
                    Content = (await ShareOperation.Data.GetApplicationLinkAsync()).AbsoluteUri;
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.Bitmap))
                {
                    Content = nameof(StandardDataFormats.Bitmap);
                    var bitmap = await ShareOperation.Data.GetBitmapAsync();

                    using (var stream = await bitmap.OpenReadAsync())
                    {
                        Bitmap = new BitmapImage();
                        Bitmap.SetSource(stream);
                    }
                }
                else if (ShareOperation.Data.Contains(StandardDataFormats.StorageItems))
                {
                    Content = nameof(StandardDataFormats.StorageItems);
                    foreach (var item in await ShareOperation.Data.GetStorageItemsAsync())
                    {
                        Content += item.Path + Environment.NewLine;
                    }
                }
                else
                {
                    Content = "Some unsupported share type.";
                    return;
                }

                QuickLink = ShareOperation.QuickLinkId ?? "None set";

                if (ShareOperation.Data.Properties.Square30x30Logo != null)
                {
                    using (var stream = await ShareOperation.Data.Properties.Square30x30Logo.OpenReadAsync())
                    {
                        Logo = new BitmapImage();
                        Logo.SetSource(stream);
                    }
                }

                if (ShareOperation.Data.Properties.Thumbnail != null)
                {
                    using (var stream = await ShareOperation.Data.Properties.Thumbnail.OpenReadAsync())
                    {
                        Thumbnail = new BitmapImage();
                        Thumbnail.SetSource(stream);
                    }
                }
            }
            catch (Exception e) { Content = e.Message; }
            finally
            {
                var folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");

                var file = await folder.GetFileAsync("T10 56x56.png");

                var reference = RandomAccessStreamReference.CreateFromFile(file);
                var quick     = new QuickLink()
                {
                    Id        = "Template10 QuickLink",
                    Title     = "Template10 QuickLink",
                    Thumbnail = reference,
                };
                quick.SupportedFileTypes.Clear();
                quick.SupportedFileTypes.Add(StandardDataFormats.Text);
                quick.SupportedFileTypes.Add(StandardDataFormats.WebLink);
                quick.SupportedFileTypes.Add(StandardDataFormats.ApplicationLink);
                quick.SupportedFileTypes.Add(StandardDataFormats.Bitmap);
                quick.SupportedFileTypes.Add(StandardDataFormats.Html);
                ShareOperation.ReportCompleted(quick);
            }
        }
Ejemplo n.º 22
0
        private void InitializeQuickLinks()
        {
            addedQuickLinksSet = new HashSet <string>();

            Vector2 anchoredPos = new Vector2(0f, -quickLinksContainer.sizeDelta.y);

            if (generateQuickLinksForDrives)
            {
#if !UNITY_EDITOR && UNITY_ANDROID
                using (AndroidJavaClass externalDrivesList = new AndroidJavaClass("com.yasirkula.unity.ExternalDrivesList"))
                {
                    string drivesList = externalDrivesList.CallStatic <string>("GetExternalDrives");
                    if (drivesList != null && drivesList.Length > 0)
                    {
                        bool     defaultPathInitialized = false;
                        string[] drives = drivesList.Split(':');
                        for (int i = 0; i < drives.Length; i++)
                        {
                            if (drives[i].ToLower().Contains("/usb"))
                            {
                                continue;
                            }

                            int driveIndex = 1;
                            try
                            {
                                string driveName = new DirectoryInfo(drives[i]).Name;
                                if (driveName.Length <= 1)
                                {
                                    try
                                    {
                                        driveName = Directory.GetParent(drives[i]).Name + "/" + driveName;
                                    }
                                    catch (Exception)
                                    {
                                        driveName = "Drive " + driveIndex++;
                                    }
                                }

                                AddQuickLink(driveIcon, driveName, drives[i], ref anchoredPos);

                                if (!defaultPathInitialized)
                                {
                                    DEFAULT_PATH           = drives[i];
                                    defaultPathInitialized = true;
                                }
                            }
                            catch (Exception) { }
                        }
                    }
                }
#else
                string[] drives = Directory.GetLogicalDrives();

                for (int i = 0; i < drives.Length; i++)
                {
                    AddQuickLink(driveIcon, drives[i], drives[i], ref anchoredPos);
                }
#endif
            }

            for (int i = 0; i < quickLinks.Length; i++)
            {
                QuickLink quickLink     = quickLinks[i];
                string    quickLinkPath = Environment.GetFolderPath(quickLink.target);

                AddQuickLink(quickLink.icon, quickLink.name, quickLinkPath, ref anchoredPos);
            }

            quickLinksContainer.sizeDelta = new Vector2(0f, -anchoredPos.y);
        }
Ejemplo n.º 23
0
 private void Service_FoundAddress(object sender, QuickLink.FoundAddressEventArgs e)
 {
     Invoke((MethodInvoker)(() => addressList.Items.Add(e.Address)));
 }
Ejemplo n.º 24
0
 private void Service_MessageReceived(object sender, QuickLink.MessageReceivedEventArgs e)
 {
     messages.AppendText("[INCOMING] " + e.Message.From + ":" + Environment.NewLine + e.Message.Content);
     messages.AppendText(Environment.NewLine + Environment.NewLine);
 }