コード例 #1
0
        /// <summary>
        /// Private helper function (formerly in SaveSnapshotZip) to make it easier to call with different inputs
        /// </summary>
        private static void SaveSnapshotFromElement(int?focusedElementId, A11yFileMode mode, Contexts.ElementContext ec, Package package, A11yElement root)
        {
            var json = JsonConvert.SerializeObject(root, Formatting.Indented);

            using (MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                AddStream(package, mStrm, elementFileName);
            }

            if (ec.DataContext.Screenshot != null)
            {
                using (MemoryStream mStrm = new MemoryStream())
                {
                    ec.DataContext.Screenshot.Save(mStrm, System.Drawing.Imaging.ImageFormat.Png);
                    mStrm.Seek(0, SeekOrigin.Begin);

                    AddStream(package, mStrm, screenshotFileName);
                }
            }

            var meta     = new SnapshotMetaInfo(mode, RuleRunner.RuleVersion, focusedElementId, ec.DataContext.ScreenshotElementId);
            var jsonMeta = JsonConvert.SerializeObject(meta, Formatting.Indented);

            using (MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(jsonMeta)))
            {
                AddStream(package, mStrm, metadataFileName);
            }
        }
コード例 #2
0
        /// <summary>
        /// Private helper function (formerly in SaveSnapshotZip) to make it easier to call with different inputs
        /// </summary>
        private static void SaveSnapshotFromElement(int?focusedElementId, A11yFileMode mode, Dictionary <SnapshotMetaPropertyName, object> otherProperties, CompletenessMode completenessMode, Contexts.ElementContext ec, Package package, A11yElement root)
        {
            var json = JsonConvert.SerializeObject(root, Formatting.Indented);

            using (MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                AddStream(package, mStrm, elementFileName);
            }

            if (completenessMode == CompletenessMode.Full && ec.DataContext.Screenshot != null)
            {
                using (MemoryStream mStrm = new MemoryStream())
                {
                    ec.DataContext.Screenshot.Save(mStrm, System.Drawing.Imaging.ImageFormat.Png);
                    mStrm.Seek(0, SeekOrigin.Begin);

                    AddStream(package, mStrm, screenshotFileName);
                }
            }

            var meta     = new SnapshotMetaInfo(mode, SuiteFactory.GetRuleVersion(), focusedElementId, ec.DataContext.ScreenshotElementId, otherProperties);
            var jsonMeta = JsonConvert.SerializeObject(meta, Formatting.Indented);

            using (MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(jsonMeta)))
            {
                AddStream(package, mStrm, metatdataFileName);
            }
        }
コード例 #3
0
        /// <summary>
        /// Constructor that takes single ID
        /// </summary>
        /// <param name="mode">The save mode</param>
        /// <param name="ruleVersion">Indicate the version of rule</param>
        /// <param name="selected">The selected item (null if no item is selected)</param>
        /// <param name="screlementId">the ID of an element which was used to grab the screenshot</param>
        public SnapshotMetaInfo(A11yFileMode mode, string ruleVersion, int?selected, int screlementId)
        {
            this.Mode        = mode;
            this.RuleVersion = ruleVersion;
            this.Version     = Core.Misc.PackageInfo.InformationalVersion;

            if (selected.HasValue)
            {
                this.SelectedItems = new List <int> {
                    selected.Value
                };
            }
            this.ScreenshotElementId = screlementId;
        }
コード例 #4
0
        /// <summary>
        /// Constructor that takes single ID
        /// </summary>
        /// <param name="mode">The save mode</param>
        /// <param name="ruleVersion">Indicate the version of rule</param>
        /// <param name="selected">The selected item (null if no item is selected)</param>
        /// <param name="screlementId">the ID of an element which was used to grab the screenshot</param>
        /// <param name="otherProperties">values useful when setting the view upon loading this file</param>
        public SnapshotMetaInfo(A11yFileMode mode, string ruleVersion, int?selected, int screlementId, Dictionary <SnapshotMetaPropertyName, object> otherProperties = null)
        {
            this.Mode        = mode;
            this.RuleVersion = ruleVersion;
            this.Version     = AccessibilityInsights.Core.Misc.Utility.GetAppVersion();

            if (selected.HasValue)
            {
                this.SelectedItems = new List <int>()
                {
                    selected.Value
                };
            }
            this.ScreenshotElementId = screlementId;
            this.OtherProperties     = otherProperties;
        }
コード例 #5
0
        /// <summary>
        /// Constructor that takes single ID
        /// </summary>
        /// <param name="mode">The save mode</param>
        /// <param name="ruleVersion">Indicate the version of rule</param>
        /// <param name="selected">The selected item (null if no item is selected)</param>
        /// <param name="screlementId">the ID of an element which was used to grab the screenshot</param>
        /// <param name="otherProperties">values useful when setting the view upon loading this file</param>
        public SnapshotMetaInfo(A11yFileMode mode, string ruleVersion, int?selected, int screlementId, Dictionary <SnapshotMetaPropertyName, object> otherProperties = null)
        {
            this.Mode        = mode;
            this.RuleVersion = ruleVersion;
            this.Version     = Axe.Windows.Core.Misc.PackageInfo.InformationalVersion;

            if (selected.HasValue)
            {
                this.SelectedItems = new List <int>()
                {
                    selected.Value
                };
            }
            this.ScreenshotElementId = screlementId;
            this.OtherProperties     = otherProperties;
        }
コード例 #6
0
        /// <summary>
        /// Save snapshot zip
        /// </summary>
        /// <param name="ecId">ElementContext Id</param>
        /// <param name="path">The output file</param>
        /// <param name="focusedElementId">The ID of the element with the current focus</param>
        /// <param name="mode">The type of file being saved</param>
        public static void SaveSnapshotZip(string path, Guid ecId, int?focusedElementId, A11yFileMode mode)
        {
            var ec = DataManager.GetDefaultInstance().GetElementContext(ecId);

            using (FileStream str = File.Open(path, FileMode.Create))
                using (Package package = ZipPackage.Open(str, FileMode.Create))
                {
                    SaveSnapshotFromElement(focusedElementId, mode, ec, package, ec.DataContext.RootElment);
                }
        }
コード例 #7
0
ファイル: SaveAction.cs プロジェクト: waabid/axe-windows
        /// <summary>
        /// Save snapshot zip
        /// </summary>
        /// <param name="ecId">ElementContext Id</param>
        /// <param name="path">The output file</param>
        /// <param name="bmp">The screenshot</param>
        /// <param name="focusedElementId">The ID of the element with the current focus</param>
        /// <param name="mode">The type of file being saved</param>
        /// <param name="otherProperties">Properties to add to the snapshot metadata</param>
        public static void SaveSnapshotZip(string path, Guid ecId, int?focusedElementId, A11yFileMode mode, Dictionary <SnapshotMetaPropertyName, object> otherProperties = null)
        {
            var ec = DataManager.GetDefaultInstance().GetElementContext(ecId);

            using (FileStream str = File.Open(path, FileMode.Create))
                using (Package package = ZipPackage.Open(str, FileMode.Create))
                {
                    SaveSnapshotFromElement(focusedElementId, mode, otherProperties, ec, package, ec.DataContext.RootElment);
                }
        }
コード例 #8
0
ファイル: SaveAction.cs プロジェクト: Shobhit1/axe-windows
        /// <summary>
        /// Save snapshot zip
        /// </summary>
        /// <param name="ecId">ElementContext Id</param>
        /// <param name="path">The output file</param>
        /// <param name="bmp">The screenshot</param>
        /// <param name="focusedElementId">The ID of the element with the current focus</param>
        /// <param name="mode">The type of file being saved</param>
        /// <param name="otherProperties">Properties to add to the snapshot metadata</param>
        /// <param name="completenessMode">Mode to control selective removal of data from the output</param>
        public static void SaveSnapshotZip(string path, Guid ecId, int?focusedElementId, A11yFileMode mode, Dictionary <SnapshotMetaPropertyName, object> otherProperties = null, CompletenessMode completenessMode = CompletenessMode.Full)
        {
            var ec = DataManager.GetDefaultInstance().GetElementContext(ecId);

            using (FileStream str = File.Open(path, FileMode.Create))
                using (Package package = ZipPackage.Open(str, FileMode.Create))
                {
                    if (completenessMode == CompletenessMode.Full)
                    {
                        SaveSnapshotFromElement(focusedElementId, mode, otherProperties, completenessMode, ec, package, ec.DataContext.RootElment);
                    }
                    else
                    {
                        using (A11yElement reducedRoot = SelectAction.GetDefaultInstance().POIElementContext.Element.GetScrubbedElementTree())
                        {
                            SaveSnapshotFromElement(focusedElementId, mode, otherProperties, completenessMode, ec, package, reducedRoot);
                        }
                    }
                }
        }