public XamlNodeQueue (XamlSchemaContext schemaContext)
		{
			if (schemaContext == null)
				throw new ArgumentNullException ("schemaContext");
			this.ctx = schemaContext;
			reader = new XamlNodeQueueReader (this);
			writer = new XamlNodeQueueWriter (this);
		}
 public override object Load(XamlReader xamlReader, IServiceProvider context)
 {
     FuncFactory factory = FuncFactory.CreateFactory(xamlReader, context);
     IXamlNamespaceResolver nsResolver = context.GetService(typeof(IXamlNamespaceResolver)) as IXamlNamespaceResolver;
     if (nsResolver != null)
     {
         factory.ParentNamespaces = nsResolver.GetNamespacePrefixes().ToList();
     }
     return factory.GetFunc();
 }
 public override object Load(XamlReader xamlReader, IServiceProvider context)
 {
     IXamlObjectWriterFactory service = context.GetService(typeof(IXamlObjectWriterFactory)) as IXamlObjectWriterFactory;
     IProvideValueTarget target = context.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;
     Type propertyType = null;
     PropertyInfo targetProperty = target.TargetProperty as PropertyInfo;
     if (targetProperty != null)
     {
         propertyType = targetProperty.PropertyType;
     }
     object firstArgument = Activator.CreateInstance(typeof(FuncFactory).MakeGenericType(propertyType.GetGenericArguments()), new object[] { service, xamlReader });
     return Delegate.CreateDelegate(propertyType, firstArgument, firstArgument.GetType().GetMethod("Evaluate"));
 }
 public TemplateContent(XamlReader xamlReader)
 {
     if (xamlReader == null)
         throw new ArgumentNullException("xamlReader");
     _SchemaContext = xamlReader.SchemaContext;
     _Cache = new MemoryStream();
     XamlXmlWriter writer = new XamlXmlWriter(_Cache, xamlReader.SchemaContext);
     //writer.WriteNamespace(xamlReader.Namespace);
     while (xamlReader.Read())
     {
         writer.WriteNode(xamlReader);
     }
     writer.Close();
 }
 internal XamlDebuggerXmlReader(TextReader underlyingTextReader, XamlSchemaContext schemaContext, Assembly localAssembly)
 {
     UnitTestUtility.Assert(underlyingTextReader != null, "underlyingTextReader should not be null and is ensured by caller.");
     this.xmlReaderWithSourceLocation = new XmlReaderWithSourceLocation(underlyingTextReader);
     this.underlyingReader = new XamlXmlReader(this.xmlReaderWithSourceLocation, schemaContext, new XamlXmlReaderSettings { ProvideLineInfo = true, LocalAssembly = localAssembly });
     this.xamlLineInfo = (IXamlLineInfo)this.underlyingReader;
     UnitTestUtility.Assert(this.xamlLineInfo.HasLineInfo, "underlyingReader is constructed with the ProvideLineInfo option above.");
     this.schemaContext = schemaContext;
     this.objectDeclarationRecords = new Stack<XamlNode>();
     this.initializationValueRanges = new Dictionary<XamlNode, DocumentRange>();
     this.bufferedXamlNodes = new Queue<XamlNode>();
     this.current = this.CreateCurrentNode();
     this.SourceLocationFound += XamlDebuggerXmlReader.SetSourceLocation;
 }
Exemple #6
0
		protected void Read_String (XamlReader r)
		{
			Assert.AreEqual (XamlNodeType.None, r.NodeType, "#1");
			Assert.IsNull (r.Member, "#2");
			Assert.IsNull (r.Namespace, "#3");
			Assert.IsNull (r.Member, "#4");
			Assert.IsNull (r.Type, "#5");
			Assert.IsNull (r.Value, "#6");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.IsNotNull (r.Type, "#23");
			Assert.AreEqual (new XamlType (typeof (string), r.SchemaContext), r.Type, "#23-2");
			Assert.IsNull (r.Namespace, "#25");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.IsNotNull (r.Member, "#33");
			Assert.AreEqual (XamlLanguage.Initialization, r.Member, "#33-2");
			Assert.IsNull (r.Type, "#34");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("foo", r.Value, "#43");
			Assert.IsNull (r.Member, "#44");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");
			Assert.IsNull (r.Type, "#53");
			Assert.IsNull (r.Member, "#54");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");
			Assert.IsNull (r.Type, "#63");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
 // We don't know what namespaces are actually used inside convertible values, so any namespaces
 // that were in the parent scope on load need to be regurgitated on save, unless the prefixes were
 // shadowed in the child scope.
 // This can potentially cause namespace bloat, but the alternative is emitting unloadable XAML.
 static XamlReader InsertNamespaces(XamlReader reader, IEnumerable<NamespaceDeclaration> parentNamespaces)
 {
     XamlNodeQueue namespaceNodes = new XamlNodeQueue(reader.SchemaContext);
     HashSet<string> childPrefixes = new HashSet<string>();
     while (reader.Read() && reader.NodeType == XamlNodeType.NamespaceDeclaration)
     {
         childPrefixes.Add(reader.Namespace.Prefix);
         namespaceNodes.Writer.WriteNode(reader);
     }
     foreach (NamespaceDeclaration parentNamespace in parentNamespaces)
     {
         if (!childPrefixes.Contains(parentNamespace.Prefix) &&
             !IsXmlNamespace(parentNamespace))
         {
             namespaceNodes.Writer.WriteNamespace(parentNamespace);
         }
     }
     if (!reader.IsEof)
     {
         namespaceNodes.Writer.WriteNode(reader);
     }
     return new ConcatenatingXamlReader(namespaceNodes.Reader, reader);
 }
Exemple #8
0
        //-------------------------------------------------------------------------------
        //
        // Private Methods
        //
        //-------------------------------------------------------------------------------

        #region Private Methods

        /// <summary>
        /// Copy the current Selection in XAML format.
        /// Called by :
        ///             CopySelectedData
        /// </summary>
        /// <param name="dataObject"></param>
        /// <param name="strokes"></param>
        /// <param name="elements"></param>
        /// <param name="transform"></param>
        /// <param name="size"></param>
        /// <returns>True if the copy is succeeded</returns>
        private bool CopySelectionInXAML(IDataObject dataObject, StrokeCollection strokes, List <UIElement> elements, Matrix transform, Size size)
        {
            InkCanvas inkCanvas = new InkCanvas();

            // We already transform the Strokes in CopySelectedData.
            if (strokes.Count != 0)
            {
                inkCanvas.Strokes = strokes;
            }

            int elementCount = elements.Count;

            if (elementCount != 0)
            {
                InkCanvasSelection inkCanvasSelection = InkCanvas.InkCanvasSelection;

                for (int i = 0; i < elementCount; i++)
                {
                    // NOTICE-2005/05/05-WAYNEZEN,
                    // An element can't be added to two visual trees.
                    // So, we cannot add the elements to the new container since they have been added to the current InkCanvas.
                    // Here we have to do is according to the suggestion from Avalon team -
                    //      1. Presist the elements to Xaml
                    //      2. Load the xaml to create the new instances of the elements.
                    //      3. Add the new instances to the new container.
                    string xml;

                    try
                    {
                        xml = XamlWriter.Save(elements[i]);

                        UIElement newElement = XamlReader.Load(new XmlTextReader(new StringReader(xml))) as UIElement;
                        ((IAddChild)inkCanvas).AddChild(newElement);

                        // Now we tranform the element.
                        inkCanvasSelection.UpdateElementBounds(elements[i], newElement, transform);
                    }
                    catch (SecurityException)
                    {
                        // If we hit a SecurityException under the PartialTrust, we should just stop generating
                        // the containing InkCanvas.
                        inkCanvas = null;
                        break;
                    }
                }
            }

            if (inkCanvas != null)
            {
                inkCanvas.Width  = size.Width;
                inkCanvas.Height = size.Height;

                ClipboardData data = new XamlClipboardData(new UIElement[] { inkCanvas });

                try
                {
                    data.CopyToDataObject(dataObject);
                }
                catch (SecurityException)
                {
                    // If we hit a SecurityException under the PartialTrust, we should just fail the copy
                    // operation.
                    inkCanvas = null;
                }
            }

            return(inkCanvas != null);
        }
        /// <summary>
        /// This is what happens:
        ///
        ///Get date of available resource
        ///  if resource available is newer than assembly
        ///      if there is already a translation downloaded
        ///          if current translation is older than available
        ///              Download latest, overwriting current
        ///          if current translation is newer
        ///              Don't download
        ///      if there no translation downloaded already
        ///          Download latest
        ///  if resource available is older than assembly
        ///      Don't download, erase current translation
        /// </summary>
        /// <param name="culture">The culture that should be searched for updates.</param>
        internal static void CheckForUpdates(string culture)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(UserSettings.All.TemporaryFolderResolved))
                {
                    return;
                }

                var folder = Path.Combine(UserSettings.All.TemporaryFolderResolved, "ScreenToGif", "Localization");
                var file   = Path.Combine(folder, $"StringResources.{culture}.new.xaml");

                Directory.CreateDirectory(folder);

                //Get when the available resource was updated.
                var updated = GetWhenResourceWasUpdated(culture);

                //If resource available is older than assembly.
                if (!updated.HasValue || updated <= File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location))
                {
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }

                    return;
                }

                //If a translation was previously downloaded.
                if (File.Exists(file))
                {
                    //If current translation is older than the available one.
                    if (new FileInfo(file).LastWriteTimeUtc < updated.Value.ToUniversalTime())
                    {
                        DownloadLatest(file, culture);
                    }
                }
                else
                {
                    DownloadLatest(file, culture);
                }

                //If a new translation was not downloaded (now or previously), ignore the following code.
                if (!File.Exists(file))
                {
                    return;
                }

                //Removes any resource that was added by this updater.
                var listToRemove = Application.Current.Resources.MergedDictionaries.Where(w => w.Source?.OriginalString.EndsWith(".new.xaml") == true).ToList();

                foreach (var rem in listToRemove)
                {
                    Application.Current.Resources.MergedDictionaries.Remove(rem);
                }

                //Load the resource from the file, not replacing the current resource, but putting right after it.
                using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    if (fs.Length == 0)
                    {
                        throw new InvalidDataException("File is empty");
                    }

                    //Reads the ResourceDictionary file
                    var dictionary = (ResourceDictionary)XamlReader.Load(fs);
                    dictionary.Source = new Uri(Path.Combine(file));

                    //Add in newly loaded Resource Dictionary.
                    Application.Current.Resources.MergedDictionaries.Add(dictionary);
                }
            }
            catch (WebException)
            {
                //Ignore it.
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Check for an updated localization recource");
            }
        }
Exemple #10
0
 public static ResourceDictionary LoadResourceDictionary(Stream stream)
 {
     return(( ResourceDictionary )XamlReader.Load(stream));
 }
Exemple #11
0
 /// <summary>
 /// load resource-dictionary and set default styles
 /// </summary>
 public static void Load()
 {
     using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WPFLight.Themes.Default.xaml")){
         XamlReader.Load(stream);
     }
 }
Exemple #12
0
 public tabCompactDiscInfo()
 {
     XamlReader.Load(this);
 }
Exemple #13
0
		protected void Read_ArrayOrArrayExtensionOrMyArrayExtension (XamlReader r, Action validateInstance, Type extType)
		{
			if (extType == typeof (MyArrayExtension)) {
				Assert.IsTrue (r.Read (), "#1");
				Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#2");
				Assert.IsNotNull (r.Namespace, "#3");
				Assert.AreEqual (String.Empty, r.Namespace.Prefix, "#3-2");
			}
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (extType, r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

			// This assumption on member ordering ("Type" then "Items") is somewhat wrong, and we might have to adjust it in the future.

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Type"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("x:Int32", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#62");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "#63");

			Assert.IsTrue (r.Read (), "#71");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "#71-2");
			Assert.IsNull (r.Type, "#71-3");
			Assert.IsNull (r.Member, "#71-4");
			Assert.IsNull (r.Value, "#71-5");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"5", "-3", "0"};
			for (int i = 0; i < 3; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#75-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items

			Assert.IsTrue (r.Read (), "#83");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#84"); // GetObject

			Assert.IsTrue (r.Read (), "#85");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#86"); // ArrayExtension.Items

			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88"); // ArrayExtension

			Assert.IsFalse (r.Read (), "#89");
		}
        private void NestedRepeaterWithDataTemplateScenario(bool disableAnimation)
        {
            if (!disableAnimation && PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
            {
                Log.Warning("This test is showing consistent issues with not scrolling enough on RS5 and 19H1 when animations are enabled, tracked by microsoft-ui-xaml#779");
                return;
            }

            // Example of how to include debug tracing in an ApiTests.ItemsRepeater test's output.
            // using (PrivateLoggingHelper privateLoggingHelper = new PrivateLoggingHelper("Repeater"))
            // {
            ItemsRepeater    rootRepeater = null;
            ScrollViewer     scrollViewer = null;
            ManualResetEvent viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                var anchorProvider = (ItemsRepeaterScrollHost)XamlReader.Load(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                        xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                        xmlns:controls='using:Microsoft.UI.Xaml.Controls'>
                    <controls:ItemsRepeaterScrollHost.Resources>
                        <DataTemplate x:Key='ItemTemplate' >
                            <TextBlock Text='{Binding}' />
                        </DataTemplate>
                        <DataTemplate x:Key='GroupTemplate'>
                            <StackPanel>
                                <TextBlock Text='{Binding}' />
                                <controls:ItemsRepeater ItemTemplate='{StaticResource ItemTemplate}' ItemsSource='{Binding}' VerticalCacheLength='0'/>
                            </StackPanel>
                        </DataTemplate>
                    </controls:ItemsRepeaterScrollHost.Resources>
                    <ScrollViewer x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource GroupTemplate}' VerticalCacheLength='0' />
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater              = (ItemsRepeater)anchorProvider.FindName("rootRepeater");
                rootRepeater.SizeChanged += (sender, args) =>
                {
                    Log.Comment($"SizeChanged: Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})");
                };

                scrollViewer = (ScrollViewer)anchorProvider.FindName("scrollviewer");
                scrollViewer.ViewChanging += (sender, args) =>
                {
                    Log.Comment($"ViewChanging: Next VerticalOffset={args.NextView.VerticalOffset}, Final VerticalOffset={args.FinalView.VerticalOffset}");
                };
                scrollViewer.ViewChanged += (sender, args) =>
                {
                    Log.Comment($"ViewChanged: VerticalOffset={scrollViewer.VerticalOffset}, IsIntermediate={args.IsIntermediate}");

                    if (!args.IsIntermediate)
                    {
                        viewChanged.Set();
                    }
                };

                var itemsSource = new ObservableCollection <ObservableCollection <int> >();
                for (int i = 0; i < 100; i++)
                {
                    itemsSource.Add(new ObservableCollection <int>(Enumerable.Range(0, 5)));
                }
                ;

                rootRepeater.ItemsSource = itemsSource;
                Content = anchorProvider;
            });

            // scroll down several times to cause recycling of elements
            for (int i = 1; i < 10; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    Log.Comment($"Size=({rootRepeater.ActualWidth} x {rootRepeater.ActualHeight})");
                    Log.Comment($"ChangeView(VerticalOffset={i * 200})");
                    scrollViewer.ChangeView(null, i * 200, null, disableAnimation);
                });

                Log.Comment("Waiting for view change completion...");
                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
                Log.Comment("View change completed");

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(i * 200, scrollViewer.VerticalOffset);
                });
            }
            // }
        }
Exemple #15
0
		protected void Read_TypeOrTypeExtension2 (XamlReader r, Action validateInstance, XamlMember ctorArgMember)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");

			var defns = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (defns, r.Namespace.Namespace, "#13-3:" + r.Namespace.Prefix);

			Assert.IsTrue (r.Read (), "#16");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#17");
			Assert.IsNotNull (r.Namespace, "#18");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#18-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#18-3:" + r.Namespace.Prefix);

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.AreEqual (new XamlType (typeof (TypeExtension), r.SchemaContext), r.Type, "#23-2");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (ctorArgMember, r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("TestClass1", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
        public void VerifyCurrentAnchor()
        {
            if (PlatformConfiguration.IsDebugBuildConfiguration())
            {
                // Test is failing in chk configuration due to:
                // Bug #1726 Test Failure: RepeaterTests.VerifyCurrentAnchor
                Log.Warning("Skipping test for Debug builds.");
                return;
            }

            ItemsRepeater           rootRepeater = null;
            ScrollViewer            scrollViewer = null;
            ItemsRepeaterScrollHost scrollhost   = null;
            ManualResetEvent        viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                     xmlns:controls='using:Microsoft.UI.Xaml.Controls'>
                    <controls:ItemsRepeaterScrollHost.Resources>
                        <DataTemplate x:Key='ItemTemplate' >
                            <TextBlock Text='{Binding}' Height='50'/>
                        </DataTemplate>
                    </controls:ItemsRepeaterScrollHost.Resources>
                    <ScrollViewer x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource ItemTemplate}' VerticalCacheLength='0' />
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater              = (ItemsRepeater)scrollhost.FindName("rootRepeater");
                scrollViewer              = (ScrollViewer)scrollhost.FindName("scrollviewer");
                scrollViewer.ViewChanged += (sender, args) =>
                {
                    if (!args.IsIntermediate)
                    {
                        viewChanged.Set();
                    }
                };

                rootRepeater.ItemsSource = Enumerable.Range(0, 500);
                Content = scrollhost;
            });

            // scroll down several times and validate current anchor
            for (int i = 1; i < 10; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    scrollViewer.ChangeView(null, i * 200, null);
                });

                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
                IdleSynchronizer.Wait();

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(i * 200, scrollViewer.VerticalOffset);
                    var anchor = PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5) ?
                                 scrollhost.CurrentAnchor :
                                 scrollViewer.CurrentAnchor;
                    var anchorIndex = rootRepeater.GetElementIndex(anchor);
                    Log.Comment("CurrentAnchor: " + anchorIndex);
                    Verify.AreEqual(i * 4, anchorIndex);
                });
            }
        }
 private DataTemplate CreateDataTemplateWithContent(string content)
 {
     return((DataTemplate)XamlReader.Load(@"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>" + content + @"</DataTemplate>"));
 }
        public dlgPlugins()
        {
            XamlReader.Load(this);

            DefaultButton = btnClose;
            DisplayMode   = DialogDisplayMode.Attached;

            filters              = new ObservableCollection <PluginEntry>();
            floppyImages         = new ObservableCollection <PluginEntry>();
            mediaImages          = new ObservableCollection <PluginEntry>();
            partitions           = new ObservableCollection <PluginEntry>();
            filesystems          = new ObservableCollection <PluginEntry>();
            readOnlyFilesystems  = new ObservableCollection <PluginEntry>();
            writableFloppyImages = new ObservableCollection <PluginEntry>();
            writableImages       = new ObservableCollection <PluginEntry>();

            grdFilters.DataStore = filters;
            grdFilters.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdFilters.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdFilters.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdFilters.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdFilters.AllowMultipleSelection = false;
            grdFilters.AllowColumnReordering  = true;

            grdReadableMediaImages.DataStore = mediaImages;
            grdReadableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdReadableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdReadableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdReadableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdReadableMediaImages.AllowMultipleSelection = false;
            grdReadableMediaImages.AllowColumnReordering  = true;

            grdPartitions.DataStore = partitions;
            grdPartitions.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdPartitions.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdPartitions.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdPartitions.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdPartitions.AllowMultipleSelection = false;
            grdPartitions.AllowColumnReordering  = true;

            grdFilesystem.DataStore = filesystems;
            grdFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdFilesystem.AllowMultipleSelection = false;
            grdFilesystem.AllowColumnReordering  = true;

            grdReadOnlyFilesystem.DataStore = readOnlyFilesystems;
            grdReadOnlyFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdReadOnlyFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdReadOnlyFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdReadOnlyFilesystem.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdReadOnlyFilesystem.AllowMultipleSelection = false;
            grdReadOnlyFilesystem.AllowColumnReordering  = true;

            grdReadableFloppyImages.DataStore = floppyImages;
            grdReadableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdReadableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdReadableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdReadableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdReadableFloppyImages.AllowMultipleSelection = false;
            grdReadableFloppyImages.AllowColumnReordering  = true;

            grdWritableFloppyImages.DataStore = writableFloppyImages;
            grdWritableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdWritableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdWritableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdWritableFloppyImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdWritableFloppyImages.AllowMultipleSelection = false;
            grdWritableFloppyImages.AllowColumnReordering  = true;

            grdWritableMediaImages.DataStore = writableImages;
            grdWritableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Name)
                },
                HeaderText = "Name",
                Sortable   = true
            });
            grdWritableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding
                        .Property <PluginEntry, string>(r => $"{r.Uuid}")
                },
                HeaderText = "UUID",
                Sortable   = true
            });
            grdWritableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Version)
                },
                HeaderText = "Version",
                Sortable   = true
            });
            grdWritableMediaImages.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding =
                        Binding.Property <PluginEntry, string>(r => r.Author)
                },
                HeaderText = "Author",
                Sortable   = true
            });
            grdWritableMediaImages.AllowMultipleSelection = false;
            grdWritableMediaImages.AllowColumnReordering  = true;
        }
Exemple #19
0
        /// <summary>
        /// Process a set of labels into a TextBlock.
        /// </summary>
        /// <param name="labels">
        /// A dictionary of the labels to be processed.
        /// </param>
        /// <param name="skip">
        /// Whether or not to return after generating the first line.
        /// </param>
        /// <param name="choices">
        /// The choice of keys for labels are to be generated.
        /// </param>
        /// <param name="tb">
        /// The TextBlock to which the labels are to be added.
        /// </param>
        /// <param name="gotLine">
        /// Whether or not an entire line was generated, including a line break.
        /// </param>
        private static void ProcessLabels(
            IDictionary <string, string> labels,
            bool skip,
            IEnumerable <string> choices,
            TextBlock tb,
            ref bool gotLine)
        {
            // boolean flag to manage dividers after a "<Run"
            bool needDivider = false;

            string finalLabel = string.Empty;

            foreach (string choice in choices)
            {
                if (!labels.ContainsKey(choice))
                {
                    continue;
                }

                gotLine = true;

                string label = labels[choice];

                // What to do if the current label is its own "Run"?
                // 1. If we alrady have something make it into its own "Run".
                // 2. Add this new "Run".
                // 3. Reset the finalLabel.
                // 4. Continue.
                if (label.StartsWith("<Run"))
                {
                    if (!string.IsNullOrEmpty(finalLabel))
                    {
                        // Need separator before next run
                        finalLabel += Divider;
                        tb.Inlines.Add(new Run {
                            Text = finalLabel
                        });                         // #1
                        finalLabel = string.Empty;  // #3
                    }

                    try
                    {
#if SILVERLIGHT
                        var run = XamlReader.Load(XmlnsOpen + label.Substring(4)) as Run;   // #2
#elif WINDOWS_UWP
                        var run = XamlReader.Load(XmlnsOpen + label.Substring(4)) as Run;   // #2
#else
                        var run = XamlReader.Parse(XmlnsOpen + label.Substring(4)) as Run;  // #2
#endif
                        if (run != null)
                        {
                            tb.Inlines.Add(run);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteMessage(LogLevel.Warn, "Error parsing 'Run' command in label", ex);
                    }

                    needDivider = true;
                    continue;   // #4
                }

                if (!string.IsNullOrEmpty(finalLabel) || needDivider)
                {
                    finalLabel += Divider;
                    needDivider = false;
                }

                finalLabel += label;
            }

            // If we have a string, add it to the output
            if (!string.IsNullOrEmpty(finalLabel))
            {
                tb.Inlines.Add(new Run {
                    Text = finalLabel
                });
            }

            if (skip)
            {
                return; // don't need another line break
            }

            if (gotLine)
            {
                tb.Inlines.Add(new LineBreak());
            }
        }
Exemple #20
0
        ///<summary>
        ///</summary>
        static public TestExtenderOutput Load(Stream txro)
        {
            object o = XamlReader.Load(txro);

            return(o as TestExtenderOutput);
        }
Exemple #21
0
		protected void Read_CommonXamlType (XamlReader r, Action validateInstance)
		{
			Assert.IsTrue (r.Read (), "ct#1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ct#2");
			Assert.IsNotNull (r.Namespace, "ct#3");
			Assert.AreEqual ("x", r.Namespace.Prefix, "ct#3-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "ct#3-3");
			if (validateInstance != null)
				validateInstance ();

			Assert.IsTrue (r.Read (), "ct#5");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "ct#6");
		}
        public void VerifyCorrectionsInNonScrollableDirection()
        {
            ItemsRepeater           rootRepeater = null;
            ScrollViewer            scrollViewer = null;
            ItemsRepeaterScrollHost scrollhost   = null;
            ManualResetEvent        viewChanged  = new ManualResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load(
                    @"<controls:ItemsRepeaterScrollHost Width='400' Height='600'
                     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                     xmlns:controls='using:Microsoft.UI.Xaml.Controls'>
                    <ScrollViewer Width='400' Height='400' x:Name='scrollviewer'>
                        <controls:ItemsRepeater x:Name='repeater'>
                            <DataTemplate>
                                <StackPanel>
                                    <controls:ItemsRepeater ItemsSource='{Binding}'>
                                        <controls:ItemsRepeater.Layout>
                                            <controls:StackLayout Orientation='Horizontal' />
                                        </controls:ItemsRepeater.Layout>
                                    </controls:ItemsRepeater>
                                </StackPanel>
                            </DataTemplate>
                        </controls:ItemsRepeater>
                    </ScrollViewer>
                </controls:ItemsRepeaterScrollHost>");

                rootRepeater              = (ItemsRepeater)scrollhost.FindName("repeater");
                scrollViewer              = (ScrollViewer)scrollhost.FindName("scrollviewer");
                scrollViewer.ViewChanged += (sender, args) =>
                {
                    if (!args.IsIntermediate)
                    {
                        viewChanged.Set();
                    }
                };

                List <List <int> > items = new List <List <int> >();
                for (int i = 0; i < 100; i++)
                {
                    items.Add(Enumerable.Range(0, 4).ToList());
                }
                rootRepeater.ItemsSource = items;
                Content = scrollhost;
            });

            // scroll down several times and validate no crash
            for (int i = 1; i < 5; i++)
            {
                IdleSynchronizer.Wait();
                RunOnUIThread.Execute(() =>
                {
                    scrollViewer.ChangeView(null, i * 200, null);
                });

                Verify.IsTrue(viewChanged.WaitOne(DefaultWaitTimeInMS));
                viewChanged.Reset();
            }
        }
Exemple #23
0
		protected void ReadBase (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "sbase#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sbase#2");
			Assert.AreEqual (XamlLanguage.Base, r.Member, "sbase#3");

			Assert.IsTrue (r.Read (), "vbase#1");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "vbase#2");
			Assert.IsTrue (r.Value is string, "vbase#3");

			Assert.IsTrue (r.Read (), "ebase#1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "ebase#2");
		}
        public void VerifyStoreScenarioCache()
        {
            ItemsRepeater rootRepeater = null;

            RunOnUIThread.Execute(() =>
            {
                var scrollhost = (ItemsRepeaterScrollHost)XamlReader.Load(
                    @" <controls:ItemsRepeaterScrollHost Width='400' Height='200'
                        xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                        xmlns:controls='using:Microsoft.UI.Xaml.Controls'>
                        <controls:ItemsRepeaterScrollHost.Resources>
                            <DataTemplate x:Key='ItemTemplate' >
                                <TextBlock Text='{Binding}' Height='100' Width='100'/>
                            </DataTemplate>
                            <DataTemplate x:Key='GroupTemplate'>
                                <StackPanel>
                                    <TextBlock Text='{Binding}' />
                                    <controls:ItemsRepeaterScrollHost>
                                        <ScrollViewer HorizontalScrollMode='Enabled' VerticalScrollMode='Disabled' HorizontalScrollBarVisibility='Auto' VerticalScrollBarVisibility='Hidden'>
                                            <controls:ItemsRepeater ItemTemplate='{StaticResource ItemTemplate}' ItemsSource='{Binding}'>
                                                <controls:ItemsRepeater.Layout>
                                                    <controls:StackLayout Orientation='Horizontal' />
                                                </controls:ItemsRepeater.Layout>
                                            </controls:ItemsRepeater>
                                        </ScrollViewer>
                                    </controls:ItemsRepeaterScrollHost>
                                </StackPanel>
                            </DataTemplate>
                        </controls:ItemsRepeaterScrollHost.Resources>
                        <ScrollViewer x:Name='scrollviewer'>
                            <controls:ItemsRepeater x:Name='rootRepeater' ItemTemplate='{StaticResource GroupTemplate}'/>
                        </ScrollViewer>
                    </controls:ItemsRepeaterScrollHost>");

                rootRepeater = (ItemsRepeater)scrollhost.FindName("rootRepeater");

                List <List <int> > items = new List <List <int> >();
                for (int i = 0; i < 100; i++)
                {
                    items.Add(Enumerable.Range(0, 4).ToList());
                }
                rootRepeater.ItemsSource = items;
                Content = scrollhost;
            });

            IdleSynchronizer.Wait();

            // Verify that first items outside the visible range but in the realized range
            // for the inner of the nested repeaters are realized.
            RunOnUIThread.Execute(() =>
            {
                // Group2 will be outside the visible range but within the realized range.
                var group2 = rootRepeater.TryGetElement(2) as StackPanel;
                Verify.IsNotNull(group2);

                var group2Repeater = ((ItemsRepeaterScrollHost)group2.Children[1]).ScrollViewer.Content as ItemsRepeater;
                Verify.IsNotNull(group2Repeater);

                Verify.IsNotNull(group2Repeater.TryGetElement(0));
            });
        }
Exemple #25
0
		protected void Read_NullOrNullExtension (XamlReader r, Action validateInstance)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.AreEqual (new XamlType (typeof (NullExtension), r.SchemaContext), r.Type, "#23-2");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
Exemple #26
0
 private object ParseXaml(string xaml)
 {
     return(XamlReader.Parse(Utils.WrapToXaml(xaml)));
 }
Exemple #27
0
		protected void Read_ListArray (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");

			var defns = "clr-namespace:System.Collections.Generic;assembly=mscorlib";
			var defns2 = "clr-namespace:System;assembly=mscorlib";
			var defns3 = "clr-namespace:System.Xaml;assembly=System.Xaml";

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "ns#1-3");
			Assert.AreEqual (defns, r.Namespace.Namespace, "ns#1-4");

			Assert.IsTrue (r.Read (), "ns#2-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#2-2");
			Assert.IsNotNull (r.Namespace, "ns#2-3");
			Assert.AreEqual ("s", r.Namespace.Prefix, "ns#2-3-2");
			Assert.AreEqual (defns2, r.Namespace.Namespace, "ns#2-3-3");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (List<Array>), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
			Assert.IsTrue (xt.IsCollection, "#27");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Capacity"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("2", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"x:Int32", "x:String"};
			for (int i = 0; i < 2; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.AreEqual (XamlLanguage.Array, r.Type, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				Assert.AreEqual (XamlLanguage.Array.GetMember ("Type"), r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");

				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#75-2");
				Assert.AreEqual (XamlLanguage.Array.GetMember ("Items"), r.Member, i + "#75-3");
				Assert.IsTrue (r.Read (), i + "#75-4");
				Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, i + "#75-5");
				Assert.IsTrue (r.Read (), i + "#75-7");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#75-8");
				Assert.AreEqual (XamlLanguage.Items, r.Member, i + "#75-9");

				for (int j = 0; j < 3; j++) {
					Assert.IsTrue (r.Read (), i + "#76-" + j);
					Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#76-2"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-3"+ "-" + j);
					Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#76-4"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-5"+ "-" + j);
					Assert.AreEqual (XamlNodeType.Value, r.NodeType, i + "#76-6"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-7"+ "-" + j);
					Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#76-8"+ "-" + j);
					Assert.IsTrue (r.Read (), i + "#76-9"+ "-" + j);
					Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#76-10"+ "-" + j);
				}

				Assert.IsTrue (r.Read (), i + "#77");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#77-2");

				Assert.IsTrue (r.Read (), i + "#78");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#78-2");

				Assert.IsTrue (r.Read (), i + "#79");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#79-2");

				Assert.IsTrue (r.Read (), i + "#80");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#80-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items
			
			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88");

			Assert.IsFalse (r.Read (), "#89");
		}
Exemple #28
0
		protected void Read_NullableContainer (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");
			Assert.IsNotNull (r.Namespace, "ns#1-3");
			Assert.AreEqual ("", r.Namespace.Prefix, "ns#1-4");
			var assns = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			Assert.AreEqual (assns, r.Namespace.Namespace, "ns#1-5");

			// t:NullableContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (NullableContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:TestProp
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (xt.GetMember ("TestProp"), r.Member, "sm1#3");

			// x:Value
			Assert.IsTrue (r.Read (), "v#1-1");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#1-2");
			Assert.AreEqual ("5", r.Value, "v#1-3");

			// /m:TestProp
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:NullableContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
Exemple #29
0
		protected void Read_CustomMarkupExtension (XamlReader r)
		{
			r.Read (); // ns
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#1");
			r.Read (); // ns
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#1-2");
			r.Read ();
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#2-0");
			Assert.IsFalse (r.IsEof, "#1");
			var xt = r.Type;

			if (r is XamlXmlReader)
				ReadBase (r);

			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#2-1");
			Assert.IsFalse (r.IsEof, "#2-2");
			Assert.AreEqual (xt.GetMember ("Bar"), r.Member, "#2-3");

			Assert.IsTrue (r.Read (), "#2-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#2-5");
			Assert.AreEqual ("v2", r.Value, "#2-6");

			Assert.IsTrue (r.Read (), "#2-7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#2-8");

			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#3-1");
			Assert.IsFalse (r.IsEof, "#3-2");
			Assert.AreEqual (xt.GetMember ("Baz"), r.Member, "#3-3");

			Assert.IsTrue (r.Read (), "#3-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#3-5");
			Assert.AreEqual ("v7", r.Value, "#3-6");

			Assert.IsTrue (r.Read (), "#3-7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#3-8");
			
			r.Read ();
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#4-1");
			Assert.IsFalse (r.IsEof, "#4-2");
			Assert.AreEqual (xt.GetMember ("Foo"), r.Member, "#4-3");
			Assert.IsTrue (r.Read (), "#4-4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#4-5");
			Assert.AreEqual ("x:Int32", r.Value, "#4-6");

			Assert.IsTrue (r.Read (), "#4-7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#4-8");

			Assert.IsTrue (r.Read (), "#5");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#5-2");

			Assert.IsFalse (r.Read (), "#6");
		}
Exemple #30
0
		protected void Read_DirectDictionaryContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			ReadNamespace (r, String.Empty, assns1, "ns#1");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#2");

			// t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (DirectDictionaryContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "sm1#3");

			// GetObject
			Assert.IsTrue (r.Read (), "go#1");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#2");

			// m:Items(GetObject)
			Assert.IsTrue (r.Read (), "sm2#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm2#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm2#3");

			xt = r.SchemaContext.GetXamlType (typeof (int));
			for (int i = 0; i < 3; i++) {
				// t:DirectDictionaryContent
				Assert.IsTrue (r.Read (), "so#x-1." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3." + i);

				// m:Key
				Assert.IsTrue (r.Read (), "sm#y1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#y2");
				Assert.AreEqual (XamlLanguage.Key, r.Member, "sm#y3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#y-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#y-2");
				Assert.AreEqual (((EnumValueType) i).ToString ().ToLower (), r.Value, "v#y-3");

				// /m:Key
				Assert.IsTrue (r.Read (), "em#y-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#y-2");

				// m:Value
				Assert.IsTrue (r.Read (), "sm#x1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2");
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, "sm#x3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#x-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#x-2");
				Assert.AreEqual ("" + (i + 2) * 10, r.Value, "v#x-3");

				// /m:Value
				Assert.IsTrue (r.Read (), "em#x-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x-2");

				// /t:DirectDictionaryContent
				Assert.IsTrue (r.Read (), "eo#x-1");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#x-2");
			}

			// /m:Items(GetObject)
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#2-2");

			// /GetObject
			Assert.IsTrue (r.Read (), "ego#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "ego#2-2");

			// /m:Items
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:DirectDictionaryContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
Exemple #31
0
        private static async void HtmlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // Get the target RichTextBlock
            RichTextBlock richText = d as RichTextBlock;

            if (richText == null)
            {
                return;
            }

            // Wrap the value of the Html property in a div and convert it to a new RichTextBlock
            string        xhtml       = string.Format("<div>{0}</div>", e.NewValue as string);
            RichTextBlock newRichText = null;

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // In design mode we swallow all exceptions to make editing more friendly
                string xaml = "";
                try {
                    xaml = await ConvertHtmlToXamlRichTextBlock(xhtml);

                    newRichText = (RichTextBlock)XamlReader.Load(xaml);
                }
                catch (Exception ex) {
                    string errorxaml = string.Format(@"
                        <RichTextBlock 
                         xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                         xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                        >
                            <Paragraph>An exception occurred while converting HTML to XAML: {0}</Paragraph>
                            <Paragraph />
                            <Paragraph>HTML:</Paragraph>
                            <Paragraph>{1}</Paragraph>
                            <Paragraph />
                            <Paragraph>XAML:</Paragraph>
                            <Paragraph>{2}</Paragraph>
                        </RichTextBlock>",
                                                     ex.Message,
                                                     EncodeXml(xhtml),
                                                     EncodeXml(xaml)
                                                     );
                    newRichText = (RichTextBlock)XamlReader.Load(errorxaml);
                } // Display a friendly error in design mode.
            }
            else
            {
                // When not in design mode, we let the application handle any exceptions
                string xaml = await ConvertHtmlToXamlRichTextBlock(xhtml);

                newRichText = (RichTextBlock)XamlReader.Load(xaml);
            }

            // Move the blocks in the new RichTextBlock to the target RichTextBlock
            richText.Blocks.Clear();
            if (newRichText != null)
            {
                for (int i = newRichText.Blocks.Count - 1; i >= 0; i--)
                {
                    Block b = newRichText.Blocks[i];
                    newRichText.Blocks.RemoveAt(i);
                    richText.Blocks.Insert(0, b);
                }
            }
        }
Exemple #32
0
		protected void Read_TypeOrTypeExtension (XamlReader r, Action validateInstance, XamlMember ctorArgMember)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.IsNotNull (r.Type, "#23");
			Assert.AreEqual (XamlLanguage.Type, r.Type, "#23-2");
			Assert.IsNull (r.Namespace, "#25");
			if (validateInstance != null)
				validateInstance ();

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.IsNotNull (r.Member, "#33");
			Assert.AreEqual (ctorArgMember, r.Member, "#33-2");
			Assert.IsNull (r.Type, "#34");
//			Assert.IsNull (r.Instance, "#35");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.IsNotNull (r.Value, "#43");
			Assert.AreEqual ("x:Int32", r.Value, "#43-2");
			Assert.IsNull (r.Member, "#44");
//			Assert.IsNull (r.Instance, "#45");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");
			Assert.IsNull (r.Type, "#53");
			Assert.IsNull (r.Member, "#54");
//			Assert.IsNull (r.Instance, "#55");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");
			Assert.IsNull (r.Type, "#63");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
Exemple #33
0
        public Task <bool> LoadDocumentAsync(string svgFilePath)
        {
            if (_isLoadingDrawing || string.IsNullOrWhiteSpace(svgFilePath))
            {
                return(Task.FromResult <bool>(false));
            }
            Uri uriSvgPath = new Uri(svgFilePath);

            if (uriSvgPath.IsFile && !File.Exists(svgFilePath))
            {
                return(Task.FromResult <bool>(false));
            }

            string fileExt = Path.GetExtension(svgFilePath);

            if (!(string.Equals(fileExt, SvgConverter.SvgExt, StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(fileExt, SvgConverter.CompressedSvgExt, StringComparison.OrdinalIgnoreCase)))
            {
                _svgFilePath = null;
                return(Task.FromResult <bool>(false));
            }

            _isLoadingDrawing = true;

            this.UnloadDocument(true);

            DirectoryInfo workingDir = _workingDir;

            if (_directoryInfo != null)
            {
                workingDir = _directoryInfo;
            }

            _svgFilePath = svgFilePath;
            _saveXaml    = _optionSettings.ShowOutputFile;

            _embeddedImageVisitor.SaveImages    = !_wpfSettings.IncludeRuntime;
            _embeddedImageVisitor.SaveDirectory = _drawingDir;
            _wpfSettings.Visitors.ImageVisitor  = _embeddedImageVisitor;

            if (_fileReader == null)
            {
                _fileReader          = new FileSvgReader(_wpfSettings);
                _fileReader.SaveXaml = _saveXaml;
                _fileReader.SaveZaml = false;
            }

            var drawingStream = new MemoryStream();

            // Get the UI thread's context
            var context = TaskScheduler.FromCurrentSynchronizationContext();

            return(Task <bool> .Factory.StartNew(() =>
            {
//                var saveXaml = _fileReader.SaveXaml;
//                _fileReader.SaveXaml = true; // For threaded, we will save to avoid loading issue later...
                DrawingGroup drawing = _fileReader.Read(svgFilePath, workingDir);
//                _fileReader.SaveXaml = saveXaml;
                _drawingDocument = _fileReader.DrawingDocument;
                if (drawing != null)
                {
                    XamlWriter.Save(drawing, drawingStream);
                    drawingStream.Seek(0, SeekOrigin.Begin);

                    return true;
                }
                _svgFilePath = null;
                return false;
            }).ContinueWith((t) => {
                try
                {
                    if (!t.Result)
                    {
                        _isLoadingDrawing = false;
                        _svgFilePath = null;
                        return false;
                    }
                    if (drawingStream.Length != 0)
                    {
                        DrawingGroup drawing = (DrawingGroup)XamlReader.Load(drawingStream);

                        svgViewer.UnloadDiagrams();
                        svgViewer.RenderDiagrams(drawing);

                        Rect bounds = svgViewer.Bounds;

                        if (bounds.IsEmpty)
                        {
                            bounds = new Rect(0, 0, svgViewer.ActualWidth, svgViewer.ActualHeight);
                        }

                        zoomPanControl.AnimatedZoomTo(bounds);
                        CommandManager.InvalidateRequerySuggested();

                        // The drawing changed, update the source...
                        _fileReader.Drawing = drawing;
                    }

                    _isLoadingDrawing = false;

                    return true;
                }
                catch
                {
                    _isLoadingDrawing = false;
                    throw;
                }
            }, context));
        }
Exemple #34
0
		// from StartMember of Initialization to EndMember
		protected string Read_Initialization (XamlReader r, object comparableValue)
		{
			Assert.IsTrue (r.Read (), "init#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "init#2");
			Assert.IsNotNull (r.Member, "init#3");
			Assert.AreEqual (XamlLanguage.Initialization, r.Member, "init#3-2");
			Assert.IsTrue (r.Read (), "init#4");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "init#5");
			Assert.AreEqual (typeof (string), r.Value.GetType (), "init#6");
			string ret = (string) r.Value;
			if (comparableValue != null)
				Assert.AreEqual (comparableValue.ToString (), r.Value, "init#6-2");
			Assert.IsTrue (r.Read (), "init#7");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "init#8");
			return ret;
		}
Exemple #35
0
        private void SetupRepeaterAnchoringUI(
            Scroller scroller,
            AutoResetEvent scrollerLoadedEvent)
        {
            Log.Comment("Setting up ItemsRepeater anchoring UI with Scroller and ItemsRepeater");

            TestDataSource dataSource = new TestDataSource(
                Enumerable.Range(0, c_defaultAnchoringUIRepeaterChildrenCount).Select(i => string.Format("Item #{0}", i)).ToList());

            RecyclingElementFactory elementFactory = new RecyclingElementFactory();

            elementFactory.RecyclePool       = new RecyclePool();
            elementFactory.Templates["Item"] = XamlReader.Load(
                @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>
                        <Border BorderThickness='3' BorderBrush='Chartreuse' Width='100' Height='100' Margin='3' Background='BlanchedAlmond'>
                          <TextBlock Text='{Binding}' HorizontalAlignment='Center' VerticalAlignment='Center'/>
                        </Border>
                      </DataTemplate>") as DataTemplate;

            ItemsRepeater repeater = new ItemsRepeater()
            {
                Name        = "repeater",
                ItemsSource = dataSource,
#if BUILD_WINDOWS
                ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                ItemTemplate = elementFactory,
#endif
                Layout = new UniformGridLayout()
                {
                    MinItemWidth     = 125,
                    MinItemHeight    = 125,
                    MinRowSpacing    = 10,
                    MinColumnSpacing = 10
                },
                Margin = new Thickness(30)
            };

            Border border = new Border()
            {
                Name            = "border",
                BorderThickness = new Thickness(3),
                BorderBrush     = new SolidColorBrush(Colors.Chartreuse),
                Margin          = new Thickness(15),
                Background      = new SolidColorBrush(Colors.Beige),
                Child           = repeater
            };

            Verify.IsNotNull(scroller);
            scroller.Name = "scroller";
            scroller.IsChildAvailableWidthConstrained = true;
            scroller.Width      = 400;
            scroller.Height     = 600;
            scroller.Background = new SolidColorBrush(Colors.AliceBlue);
            scroller.Child      = border;

            if (scrollerLoadedEvent != null)
            {
                scroller.Loaded += (object sender, RoutedEventArgs e) =>
                {
                    Log.Comment("Scroller.Loaded event handler");
                    scrollerLoadedEvent.Set();
                };
            }

            scroller.AnchorRequested += (Scroller sender, ScrollerAnchorRequestedEventArgs args) =>
            {
                Log.Comment("Scroller.AnchorRequested event handler");

                Verify.IsNull(args.AnchorElement);
                Verify.IsGreaterThan(args.AnchorCandidates.Count, 0);
            };

            Log.Comment("Setting window content");
            MUXControlsTestApp.App.TestContentRoot = scroller;
        }
Exemple #36
0
        private void numStates_Changed(object sender, RoutedEventArgs e)
        {
            if (IsLoaded)
            {
                // Add additional states
                for (var i = m_stateOptions.Count; i < numStates.Value; ++i)
                {
                    // Add template for state options
                    m_stateOptions.Add(new XMLGenerator.CombinationStateOptions());

                    // Create new GUI element from template string
                    var stringReader = new StringReader(StateGridXml);
                    var xmlReader    = XmlReader.Create(stringReader);
                    var newGrid      = (Grid)XamlReader.Load(xmlReader);
                    // Adapt margin
                    var margin = stateOptionsGrid0.Margin;
                    margin.Top    += stateOptionsGrid0.Height * i;
                    newGrid.Margin = margin;
                    // Name with distinct pattern
                    newGrid.Name = "stateOptionsGrid" + i;
                    // Add data bindings
                    foreach (Control ctrl in newGrid.Children)
                    {
                        if (ctrl.Name == "recognizers")
                        {
                            var box = ctrl as ComboBox;
                            if (box != null)
                            {
                                DataTable d = new DataTable();
                                d.Columns.Add("Name", typeof(string));
                                d.Columns.Add("IsChecked", typeof(bool));
                                d.ColumnChanged += recTableColumnChanged;
                                m_basicRecognizersTable.Add(d);
                                refreshGestureLists();
                                box.DataContext       = m_basicRecognizersTable.Last();
                                box.SelectionChanged += recognizers_SelectionChanged;
                            }
                        }
                    }
                    // Add to surrounding grid and adapt its height
                    mainGrid.Children.Add(newGrid);
                    mainGrid.Height += newGrid.Height;
                }
                // And remove old ones
                for (var i = m_stateOptions.Count - 1; i >= numStates.Value; --i)
                {
                    var oldGridName = "stateOptionsGrid" + i;
                    foreach (UIElement el in mainGrid.Children)
                    {
                        if (el is Grid)
                        {
                            var g = el as Grid;
                            if (g.Name == oldGridName)
                            {
                                mainGrid.Height -= g.Height;
                                mainGrid.Children.Remove(g);
                                m_stateOptions.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
                // Update activations
                updateStateOptionsActivation();
                checkOptions();
            }
        }
Exemple #37
0
		protected void Read_DirectListContainer (XamlReader r)
		{
			var assns1 = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			var assns2 = "clr-namespace:System.Collections.Generic;assembly=" + typeof (IList<>).Assembly.GetName ().Name;
			ReadNamespace (r, String.Empty, assns1, "ns#1");
			ReadNamespace (r, "scg", assns2, "ns#2");
			ReadNamespace (r, "x", XamlLanguage.Xaml2006Namespace, "ns#3");

			// t:DirectListContainer
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (DirectListContainer), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			// m:Items
			Assert.IsTrue (r.Read (), "sm1#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm1#2");
			Assert.AreEqual (xt.GetMember ("Items"), r.Member, "sm1#3");

			// GetObject
			Assert.IsTrue (r.Read (), "go#1");
			Assert.AreEqual (XamlNodeType.GetObject, r.NodeType, "go#2");

			// m:Items(GetObject)
			Assert.IsTrue (r.Read (), "sm2#1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm2#2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "sm2#3");

			xt = r.SchemaContext.GetXamlType (typeof (DirectListContent));
			for (int i = 0; i < 3; i++) {
				// t:DirectListContent
				Assert.IsTrue (r.Read (), "so#x-1." + i);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#x-2." + i);
				Assert.AreEqual (xt, r.Type, "so#x-3." + i);

				// m:Value
				Assert.IsTrue (r.Read (), "sm#x1");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "sm#x2");
				Assert.AreEqual (xt.GetMember ("Value"), r.Member, "sm#x3");

				// x:Value
				Assert.IsTrue (r.Read (), "v#x-1");
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "v#x-2");
				Assert.AreEqual ("Hello" + (i + 1), r.Value, "v#x-3");

				// /m:Value
				Assert.IsTrue (r.Read (), "em#x-1");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#x-2");

				// /t:DirectListContent
				Assert.IsTrue (r.Read (), "eo#x-1");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#x-2");
			}

			// /m:Items(GetObject)
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#2-2");

			// /GetObject
			Assert.IsTrue (r.Read (), "ego#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "ego#2-2");

			// /m:Items
			Assert.IsTrue (r.Read (), "em#1-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "em#1-2");

			// /t:DirectListContainer
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
        /// <summary>
        /// Converts a string containing valid XAML into WPF objects.
        /// </summary>
        /// <param name="value">The string to convert.</param>
        /// <param name="targetType">This parameter is not used.</param>
        /// <param name="parameter">This parameter is not used.</param>
        /// <param name="culture">This parameter is not used.</param>
        /// <returns>A WPF object.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string input = value as string;

            if (input != null)
            {
                string escapedXml = SecurityElement.Escape(input);

                if (escapedXml == null)
                {
                    return(string.Empty);
                }

                string escaped = escapedXml;

                //TODO: Add escapes for the following types:
                //      Color Texts
                //      Search Options
                //      Certain websites: imgur, github, youtube, etc...


                escaped = ResolveLinks(escaped);
                escaped = ResolveEmotes(escaped);
                escaped = ResolveColors(escaped);


                string wrappedInput = string.Format(
                    "<TextBlock  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Name=\"lblMessage\" FontFamily=\"Segoe UI\" TextWrapping=\"Wrap\" Padding=\"10, 10, 0, 10\" VerticalAlignment=\"Stretch\">{0}</TextBlock>", escaped);


                using (var stringReader = new StringReader(wrappedInput))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stringReader))
                    {
                        TextBlock block;
                        try
                        {
                            block = XamlReader.Load(xmlReader) as TextBlock;
                        }
                        catch
                        {
                            return(new TextBlock(new Run {
                                Foreground = Brushes.Red
                            })
                            {
                                Text = "Error getting message"
                            });
                        }

                        if (block == null)
                        {
                            return(null);
                        }

                        foreach (var lnk in from line in block.Inlines where line.GetType() == typeof(Hyperlink) select line as Hyperlink)
                        {
                            if (lnk == null)
                            {
                                throw new Exception("Not sure what happened here exactly...");
                            }

                            lnk.RequestNavigate += Hyperlink_RequestNavigateEvent;
                        }

                        return(block);
                    }
                }
            }

            return(null);
        }
Exemple #39
0
		protected void Read_AttachedProperty (XamlReader r)
		{
			var at = new XamlType (typeof (Attachable), r.SchemaContext);

			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");
			Assert.IsNotNull (r.Namespace, "ns#1-3");
			Assert.AreEqual ("", r.Namespace.Prefix, "ns#1-4");
			var assns = "clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name;
			Assert.AreEqual (assns, r.Namespace.Namespace, "ns#1-5");

			// t:AttachedWrapper
			Assert.IsTrue (r.Read (), "so#1-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "so#1-2");
			var xt = new XamlType (typeof (AttachedWrapper), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "so#1-3");

			if (r is XamlXmlReader)
				ReadBase (r);

			ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "x", "x");

			// m:Value
			Assert.IsTrue (r.Read (), "sm#2-1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#sm#2-2");
			Assert.AreEqual (xt.GetMember ("Value"), r.Member, "sm#2-3");

			// t:Attached
			Assert.IsTrue (r.Read (), "so#2-1");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#so#2-2");
			Assert.AreEqual (r.SchemaContext.GetXamlType (typeof (Attached)), r.Type, "so#2-3");

			ReadAttachedProperty (r, at.GetAttachableMember ("Foo"), "y", "y");

			Assert.IsTrue (r.Read (), "eo#2-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#eo#2-2");

			// /m:Value
			Assert.IsTrue (r.Read (), "em#2-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#em#2-2");

			// /t:AttachedWrapper
			Assert.IsTrue (r.Read (), "eo#1-1");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "eo#1-2");

			Assert.IsFalse (r.Read (), "end");
		}
Exemple #40
0
 public TextDescriptionControl()
 {
     XamlReader.Load(this);
 }
Exemple #41
0
		void ReadAttachedProperty (XamlReader r, XamlMember xm, string value, string label)
		{
			Assert.IsTrue (r.Read (), label + "#1-1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, label + "#1-2");
			Assert.AreEqual (xm, r.Member, label + "#1-3");

			Assert.IsTrue (r.Read (), label + "#2-1");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, label + "#2-2");
			Assert.AreEqual (value, r.Value, label + "2-3");

			Assert.IsTrue (r.Read (), label + "#3-1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, label + "#3-2");
		}
        private void LoadQuestion(int questionCode, bool viewOnly)
        {
            listBox.Items.Clear();
            OleDbDataReader reader  = db.GetQuestion(questionCode);
            bool            flag    = true;
            List <double>   answers = new List <double>();
            double          sum     = 0;

            while (reader.Read())
            {
                if (questionTextBox.Text == "")
                {
                    questionTextBox.Text = (reader[0]).ToString();
                }
                if (questionType.SelectedIndex == -1)
                {
                    questType = (reader[1]).ToString();
                    questionType.SelectedIndex = ComboIndex();
                }
                if (flag)
                {
                    if ((reader[1]).ToString() == "TextAnswer")
                    {
                        if ((reader[3]).ToString() == "true")
                        {
                            dopParamBox.IsChecked = true;
                        }
                        else
                        {
                            dopParamBox.IsChecked = false;
                        }
                    }
                    else if ((reader[1]).ToString() == "SomeAnswers")
                    {
                        if ((reader[3]).ToString() == "true")
                        {
                            dopParamBox.IsChecked = true;
                        }
                        else
                        {
                            dopParamBox.IsChecked = false;
                        }
                    }
                }
                flag = false;
                //Загрузка ответов
                if (reader[6].ToString() != "")
                {
                    answers.Add((double)((int)reader[6]));
                    sum += (double)((int)reader[6]);
                    StackPanel answer = XamlReader.Parse(XamlWriter.Save(Tanswer)) as StackPanel;
                    answer.Name       = "answer" + answers.Count;
                    answer.Visibility = Visibility.Visible;
                    ((Button)(answer.Children[3])).Click        += delete_button_Click;
                    ((TextBox)(answer.Children[2])).TextChanged += right_text_TextChanged;
                    ((CheckBox)(answer.Children[1])).Checked    += answer_Check;
                    ((TextBox)(answer.Children[0])).Text         = reader[4].ToString();
                    if (!viewOnly)
                    {
                        if (questType == "Один ответ" || (questType == "Несколько ответов" && dopParamBox.IsChecked == false))
                        {
                            if ((decimal)reader[5] > 0)
                            {
                                ((CheckBox)(answer.Children[1])).IsChecked = true;
                            }
                            else
                            {
                                ((CheckBox)(answer.Children[1])).IsChecked = false;
                            }
                        }
                        if (questType == "Несколько ответов" && dopParamBox.IsChecked == true)
                        {
                            ((TextBox)(answer.Children[2])).Text = Math.Round(((decimal)reader[5]), 2).ToString();
                        }
                    }
                    listBox.Items.Add(answer);
                }
            }
            reader.Close();
            if (viewOnly)
            {
                for (int i = 0; i < answers.Count; i++)
                {
                    double percent;
                    if (sum == 0)
                    {
                        percent = 0;
                    }
                    else
                    {
                        percent = (answers[i] / sum) * 100;
                    }
                    ((TextBox)((StackPanel)listBox.Items[i]).Children[2]).Text = ((percent == 100 || percent == 0) ? percent : Math.Round(percent, 2)).ToString() + "%";
                }
            }
        }
Exemple #43
0
		protected object [] Read_AttributedArguments_String (XamlReader r, string [] argNames) // valid only for string arguments.
		{
			object [] ret = new object [argNames.Length];

			Assert.IsTrue (r.Read (), "attarg.Arguments.Start1");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "attarg.Arguments.Start2");
			Assert.IsNotNull (r.Member, "attarg.Arguments.Start3");
			Assert.AreEqual (XamlLanguage.Arguments, r.Member, "attarg.Arguments.Start4");
			for (int i = 0; i < argNames.Length; i++) {
				string arg = argNames [i];
				Assert.IsTrue (r.Read (), "attarg.ArgStartObject1." + arg);
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "attarg.ArgStartObject2." + arg);
				Assert.AreEqual (typeof (string), r.Type.UnderlyingType, "attarg.ArgStartObject3." + arg);
				Assert.IsTrue (r.Read (), "attarg.ArgStartMember1." + arg);
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "attarg.ArgStartMember2." + arg);
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, "attarg.ArgStartMember3." + arg); // (as the argument is string here by definition)
				Assert.IsTrue (r.Read (), "attarg.ArgValue1." + arg);
				Assert.AreEqual (XamlNodeType.Value, r.NodeType, "attarg.ArgValue2." + arg);
				Assert.AreEqual (typeof (string), r.Value.GetType (), "attarg.ArgValue3." + arg);
				ret [i] = r.Value;
				Assert.IsTrue (r.Read (), "attarg.ArgEndMember1." + arg);
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "attarg.ArgEndMember2." + arg);
				Assert.IsTrue (r.Read (), "attarg.ArgEndObject1." + arg);
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "attarg.ArgEndObject2." + arg);
			}
			Assert.IsTrue (r.Read (), "attarg.Arguments.End1");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "attarg.Arguments.End2");
			return ret;
		}
        private void btn_load_Click(object sender, RoutedEventArgs e)
        {
            Chart new_Chart = XamlReader.Parse(xamlString) as Chart;

            this.AssociatedObject.ScrollContents.Content = new_Chart;
        }
Exemple #45
0
		// from initial to StartObject
		protected void Read_CommonClrType (XamlReader r, object obj, params KeyValuePair<string,string> [] additionalNamespaces)
		{
			Assert.IsTrue (r.Read (), "ct#1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ct#2");
			Assert.IsNotNull (r.Namespace, "ct#3");
			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "ct#3-2");
			Assert.AreEqual ("clr-namespace:" + obj.GetType ().Namespace + ";assembly=" + obj.GetType ().Assembly.GetName ().Name, r.Namespace.Namespace, "ct#3-3");

			foreach (var kvp in additionalNamespaces) {
				Assert.IsTrue (r.Read (), "ct#4." + kvp.Key);
				Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ct#5." + kvp.Key);
				Assert.IsNotNull (r.Namespace, "ct#6." + kvp.Key);
				Assert.AreEqual (kvp.Key, r.Namespace.Prefix, "ct#6-2." + kvp.Key);
				Assert.AreEqual (kvp.Value, r.Namespace.Namespace, "ct#6-3." + kvp.Key);
			}

			Assert.IsTrue (r.Read (), "ct#7");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "ct#8");
		}
        /// <summary>
        /// Generates the code.
        /// </summary>
        /// <param name="inputFileName">Name of the input file.</param>
        /// <param name="inputFileContent">Content of the input file.</param>
        /// <param name="renderMode">The render mode.</param>
        /// <param name="desiredNamespace">The desired namespace.</param>
        /// <param name="header">The header.</param>
        /// <returns></returns>
        public string GenerateCode(string inputFileName, string inputFileContent, RenderMode renderMode, string desiredNamespace, string header)
        {
            inputFileContent = RemoveClassAndAddAssembly(inputFileContent);

            var parserContext = new ParserContext
            {
                BaseUri = new Uri(inputFileName, UriKind.Absolute)
            };

            object source = null;

            try
            {
                using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(inputFileContent)))
                {
                    source = XamlReader.Load(stream, parserContext);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            if (source == null)
            {
                return("Source is empty. XAML file is not valid.");
            }

            Console.WriteLine();
            Console.WriteLine("Generating " + inputFileName);

            ElementGeneratorType.NameUniqueId = 0;
            string className = Path.GetFileNameWithoutExtension(inputFileName);

            CodeNamespace ns = new CodeNamespace(desiredNamespace);

            ns.Imports.Add(new CodeNamespaceImport("System"));
            ns.Imports.Add(new CodeNamespaceImport("System.CodeDom.Compiler"));
            ns.Imports.Add(new CodeNamespaceImport("System.Collections.ObjectModel"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Charts"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Data"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Controls"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Controls.Primitives"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Input"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Interactions.Core"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Interactivity"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Media"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Media.Effects"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Media.Animation"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Media.Imaging"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Shapes"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Renderers"));
            ns.Imports.Add(new CodeNamespaceImport("EmptyKeys.UserInterface.Themes"));

            CodeTypeDeclaration classType = new CodeTypeDeclaration(className);

            GeneratedCodeAttribute generatedCodeAttribute =
                new GeneratedCodeAttribute("Empty Keys UI Generator", Assembly.GetExecutingAssembly().GetName().Version.ToString());

            CodeAttributeDeclaration codeAttrDecl =
                new CodeAttributeDeclaration(generatedCodeAttribute.GetType().Name,
                                             new CodeAttributeArgument(
                                                 new CodePrimitiveExpression(generatedCodeAttribute.Tool)),
                                             new CodeAttributeArgument(
                                                 new CodePrimitiveExpression(generatedCodeAttribute.Version)));

            classType.CustomAttributes.Add(codeAttrDecl);

            if (string.IsNullOrEmpty(header))
            {
                ns.Comments.Add(new CodeCommentStatement("-----------------------------------------------------------", false));
                ns.Comments.Add(new CodeCommentStatement(" ", false));
                ns.Comments.Add(new CodeCommentStatement(" This file was generated, please do not modify.", false));
                ns.Comments.Add(new CodeCommentStatement(" ", false));
                ns.Comments.Add(new CodeCommentStatement("-----------------------------------------------------------", false));
            }
            else
            {
                ns.Comments.Add(new CodeCommentStatement(header, false));
            }

            CodeMemberMethod initMethod = null;

            if (source is UIRoot)
            {
                initMethod = CreateUIRootClass(ns, classType, renderMode);
                generator.ProcessGenerators(source, classType, initMethod, true);
            }
            else if (source is UserControl)
            {
                initMethod = CreateUserControlClass(ns, classType);
                generator.ProcessGenerators(source, classType, initMethod, true);
            }
            else if (source is ResourceDictionary)
            {
                initMethod = CreateDictionaryClass(ns, classType);

                ResourceDictionary dictionary = source as ResourceDictionary;
                if (dictionary != null)
                {
                    ResourceDictionaryGenerator resourcesGenerator = new ResourceDictionaryGenerator();
                    resourcesGenerator.Generate(dictionary, classType, initMethod, new CodeThisReferenceExpression());
                }
            }
            else
            {
                string errorText = "#error This type is not supported - " + source.GetType();
                Console.WriteLine(errorText);
                return(errorText);
            }

            ImageAssets.Instance.GenerateManagerCode(initMethod);
            ImageAssets.Instance.ClearAssets();

            EffectAssets.Instance.GenerateManagerCode(initMethod);
            EffectAssets.Instance.ClearAssets();

            FontGenerator.Instance.GenerateManagerCode(initMethod);

            if (BindingGenerator.Instance.IsEnabled)
            {
                BindingGenerator.Instance.GenerateRegistrationCode(initMethod);
            }

            string resultCode = string.Empty;

            using (CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider())
            {
                string mappedFileName = memoryMappedFileName + className;
                using (MemoryMappedFile mappedFile = MemoryMappedFile.CreateNew(mappedFileName, nemoryMappedFileCapacity))
                {
                    MemoryMappedViewStream stream = mappedFile.CreateViewStream();

                    using (StreamWriter sw = new StreamWriter(stream))
                    {
                        provider.GenerateCodeFromNamespace(ns, sw, new CodeGeneratorOptions());
                    }

                    stream = mappedFile.CreateViewStream();

                    TextReader tr = new StreamReader(stream);
                    resultCode = tr.ReadToEnd();
                    resultCode = resultCode.Trim(new char());

                    tr.Close();
                }
            }

            return(resultCode);
        }
Exemple #47
0
		void ReadNamespace (XamlReader r, string prefix, string ns, string label)
		{
			Assert.IsTrue (r.Read (), label + "-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, label + "-2");
			Assert.IsNotNull (r.Namespace, label + "-3");
			Assert.AreEqual (prefix, r.Namespace.Prefix, label + "-4");
			Assert.AreEqual (ns, r.Namespace.Namespace, label + "-5");
		}
Exemple #48
0
        public Setup()
        {
            Controller.ShowWindowEvent += delegate {
                Dispatcher.BeginInvoke((Action) delegate {
                    Show();
                    Activate();
                    BringIntoView();
                });
            };

            Controller.HideWindowEvent += delegate {
                Dispatcher.BeginInvoke((Action) delegate {
                    Hide();
                });
            };

            Controller.ChangePageEvent += delegate(PageType type, string [] warnings) {
                Dispatcher.BeginInvoke((Action) delegate {
                    Reset();

                    // TODO: Remove switch statement for ifs
                    switch (type)
                    {
                    case PageType.Setup: {
                        Header      = "Welcome to SparkleShare!";
                        Description = "First off, what’s your name and email?\n(Visible only to team members)";

                        TextBlock name_label = new TextBlock()
                        {
                            Text          = "Full Name:",
                            Width         = 150,
                            TextAlignment = TextAlignment.Right,
                            FontWeight    = FontWeights.Bold
                        };

                        string name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                        name        = name.Split("\\".ToCharArray()) [1];

                        TextBox name_box = new TextBox()
                        {
                            Text  = name,
                            Width = 175
                        };

                        TextBlock email_label = new TextBlock()
                        {
                            Text          = "Email:",
                            Width         = 150,
                            TextAlignment = TextAlignment.Right,
                            FontWeight    = FontWeights.Bold
                        };

                        TextBox email_box = new TextBox()
                        {
                            Width = 175
                        };


                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        Button continue_button = new Button()
                        {
                            Content   = "Continue",
                            IsEnabled = false
                        };


                        ContentCanvas.Children.Add(name_label);
                        Canvas.SetLeft(name_label, 180);
                        Canvas.SetTop(name_label, 200 + 3);

                        ContentCanvas.Children.Add(name_box);
                        Canvas.SetLeft(name_box, 340);
                        Canvas.SetTop(name_box, 200);

                        ContentCanvas.Children.Add(email_label);
                        Canvas.SetLeft(email_label, 180);
                        Canvas.SetTop(email_label, 230 + 3);

                        ContentCanvas.Children.Add(email_box);
                        Canvas.SetLeft(email_box, 340);
                        Canvas.SetTop(email_box, 230);

                        Buttons.Add(cancel_button);
                        Buttons.Add(continue_button);

                        Controller.UpdateSetupContinueButtonEvent += delegate(bool enabled) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    continue_button.IsEnabled = enabled;
                                });
                        };

                        name_box.TextChanged += delegate {
                            Controller.CheckSetupPage(name_box.Text, email_box.Text);
                        };

                        email_box.TextChanged += delegate {
                            Controller.CheckSetupPage(name_box.Text, email_box.Text);
                        };

                        cancel_button.Click += delegate {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    SparkleShare.UI.StatusIcon.Dispose();
                                    Controller.SetupPageCancelled();
                                });
                        };

                        continue_button.Click += delegate {
                            Controller.SetupPageCompleted(name_box.Text, email_box.Text);
                        };

                        Controller.CheckSetupPage(name_box.Text, email_box.Text);

                        if (name_box.Text.Equals(""))
                        {
                            name_box.Focus();
                        }
                        else
                        {
                            email_box.Focus();
                        }

                        break;
                    }

                    case PageType.Invite: {
                        Header      = "You’ve received an invite!";
                        Description = "Do you want to add this project to SparkleShare?";


                        TextBlock address_label = new TextBlock()
                        {
                            Text          = "Address:",
                            Width         = 150,
                            TextAlignment = TextAlignment.Right
                        };

                        TextBlock address_value = new TextBlock()
                        {
                            Text       = Controller.PendingInvite.Address,
                            Width      = 175,
                            FontWeight = FontWeights.Bold
                        };


                        TextBlock path_label = new TextBlock()
                        {
                            Text          = "Remote Path:",
                            Width         = 150,
                            TextAlignment = TextAlignment.Right
                        };

                        TextBlock path_value = new TextBlock()
                        {
                            Width      = 175,
                            Text       = Controller.PendingInvite.RemotePath,
                            FontWeight = FontWeights.Bold
                        };



                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        Button add_button = new Button()
                        {
                            Content = "Add"
                        };


                        ContentCanvas.Children.Add(address_label);
                        Canvas.SetLeft(address_label, 180);
                        Canvas.SetTop(address_label, 200);

                        ContentCanvas.Children.Add(address_value);
                        Canvas.SetLeft(address_value, 340);
                        Canvas.SetTop(address_value, 200);

                        ContentCanvas.Children.Add(path_label);
                        Canvas.SetLeft(path_label, 180);
                        Canvas.SetTop(path_label, 225);

                        ContentCanvas.Children.Add(path_value);
                        Canvas.SetLeft(path_value, 340);
                        Canvas.SetTop(path_value, 225);

                        Buttons.Add(add_button);
                        Buttons.Add(cancel_button);


                        cancel_button.Click += delegate {
                            Controller.PageCancelled();
                        };

                        add_button.Click += delegate {
                            Controller.InvitePageCompleted();
                        };

                        break;
                    }

                    case PageType.Add: {
                        Header = "Where’s your project hosted?";


                        ListView list_view = new ListView()
                        {
                            Width         = 419,
                            Height        = 195,
                            SelectionMode = SelectionMode.Single
                        };

                        GridView grid_view = new GridView()
                        {
                            AllowsColumnReorder = false
                        };

                        grid_view.Columns.Add(new GridViewColumn());

                        string xaml =
                            "<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" +
                            "  xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" +
                            "  <Grid>" +
                            "    <StackPanel Orientation=\"Horizontal\">" +
                            "      <Image Margin=\"5,0,0,0\" Source=\"{Binding Image}\" Height=\"24\" Width=\"24\"/>" +
                            "      <StackPanel>" +
                            "        <TextBlock Padding=\"10,4,0,0\" FontWeight=\"Bold\" Text=\"{Binding Name}\">" +
                            "        </TextBlock>" +
                            "        <TextBlock Padding=\"10,0,0,4\" Opacity=\"0.5\" Text=\"{Binding Description}\">" +
                            "        </TextBlock>" +
                            "      </StackPanel>" +
                            "    </StackPanel>" +
                            "  </Grid>" +
                            "</DataTemplate>";

                        grid_view.Columns [0].CellTemplate = (DataTemplate)XamlReader.Parse(xaml);

                        Style header_style = new Style(typeof(GridViewColumnHeader));
                        header_style.Setters.Add(new Setter(GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed));
                        grid_view.ColumnHeaderContainerStyle = header_style;

                        foreach (Preset plugin in Controller.Presets)
                        {
                            // FIXME: images are blurry
                            BitmapFrame image = BitmapFrame.Create(
                                new Uri(plugin.ImagePath)
                                );

                            list_view.Items.Add(
                                new {
                                    Name        = plugin.Name,
                                    Description = plugin.Description,
                                    Image       = image
                                }
                                );
                        }

                        list_view.View          = grid_view;
                        list_view.SelectedIndex = Controller.SelectedPresetIndex;

                        TextBlock address_label = new TextBlock()
                        {
                            Text       = "Address:",
                            FontWeight = FontWeights.Bold
                        };

                        TextBox address_box = new TextBox()
                        {
                            Width     = 200,
                            Text      = Controller.PreviousAddress,
                            IsEnabled = (Controller.SelectedPreset.Address == null)
                        };

                        TextBlock address_help_label = new TextBlock()
                        {
                            Text       = Controller.SelectedPreset.AddressExample,
                            FontSize   = 11,
                            Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128))
                        };

                        TextBlock path_label = new TextBlock()
                        {
                            Text       = "Remote Path:",
                            FontWeight = FontWeights.Bold,
                            Width      = 200
                        };

                        TextBox path_box = new TextBox()
                        {
                            Width     = 200,
                            Text      = Controller.PreviousPath,
                            IsEnabled = (Controller.SelectedPreset.Path == null)
                        };

                        TextBlock path_help_label = new TextBlock()
                        {
                            Text       = Controller.SelectedPreset.PathExample,
                            FontSize   = 11,
                            Width      = 200,
                            Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128))
                        };

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        Button add_button = new Button()
                        {
                            Content = "Add"
                        };

                        CheckBox history_check_box = new CheckBox()
                        {
                            Content   = "Fetch prior revisions",
                            IsChecked = Controller.FetchPriorHistory
                        };

                        history_check_box.Click += delegate {
                            Controller.HistoryItemChanged(history_check_box.IsChecked.Value);
                        };

                        ContentCanvas.Children.Add(history_check_box);
                        Canvas.SetLeft(history_check_box, 185);
                        Canvas.SetBottom(history_check_box, 12);

                        ContentCanvas.Children.Add(list_view);
                        Canvas.SetTop(list_view, 70);
                        Canvas.SetLeft(list_view, 185);

                        ContentCanvas.Children.Add(address_label);
                        Canvas.SetTop(address_label, 285);
                        Canvas.SetLeft(address_label, 185);

                        ContentCanvas.Children.Add(address_box);
                        Canvas.SetTop(address_box, 305);
                        Canvas.SetLeft(address_box, 185);

                        ContentCanvas.Children.Add(address_help_label);
                        Canvas.SetTop(address_help_label, 330);
                        Canvas.SetLeft(address_help_label, 185);

                        ContentCanvas.Children.Add(path_label);
                        Canvas.SetTop(path_label, 285);
                        Canvas.SetRight(path_label, 30);

                        ContentCanvas.Children.Add(path_box);
                        Canvas.SetTop(path_box, 305);
                        Canvas.SetRight(path_box, 30);

                        ContentCanvas.Children.Add(path_help_label);
                        Canvas.SetTop(path_help_label, 330);
                        Canvas.SetRight(path_help_label, 30);

                        TaskbarItemInfo.ProgressValue = 0.0;
                        TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;

                        Buttons.Add(add_button);
                        Buttons.Add(cancel_button);

                        address_box.Focus();
                        address_box.Select(address_box.Text.Length, 0);


                        Controller.ChangeAddressFieldEvent += delegate(string text,
                                                                       string example_text, FieldState state) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    address_box.Text        = text;
                                    address_box.IsEnabled   = (state == FieldState.Enabled);
                                    address_help_label.Text = example_text;
                                });
                        };

                        Controller.ChangePathFieldEvent += delegate(string text,
                                                                    string example_text, FieldState state) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    path_box.Text        = text;
                                    path_box.IsEnabled   = (state == FieldState.Enabled);
                                    path_help_label.Text = example_text;
                                });
                        };

                        Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    add_button.IsEnabled = button_enabled;
                                });
                        };

                        list_view.SelectionChanged += delegate {
                            Controller.SelectedPresetChanged(list_view.SelectedIndex);
                        };

                        list_view.KeyDown += delegate {
                            Controller.SelectedPresetChanged(list_view.SelectedIndex);
                        };

                        Controller.CheckAddPage(address_box.Text, path_box.Text, list_view.SelectedIndex);

                        address_box.TextChanged += delegate {
                            Controller.CheckAddPage(address_box.Text, path_box.Text, list_view.SelectedIndex);
                        };

                        path_box.TextChanged += delegate {
                            Controller.CheckAddPage(address_box.Text, path_box.Text, list_view.SelectedIndex);
                        };

                        cancel_button.Click += delegate {
                            Controller.PageCancelled();
                        };

                        add_button.Click += delegate {
                            Controller.AddPageCompleted(address_box.Text, path_box.Text);
                        };

                        break;
                    }


                    case PageType.Syncing: {
                        Header      = "Adding project ‘" + Controller.SyncingFolder + "’…";
                        Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?";

                        Button finish_button = new Button()
                        {
                            Content   = "Finish",
                            IsEnabled = false
                        };

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        ProgressBar progress_bar = new ProgressBar()
                        {
                            Width  = 414,
                            Height = 15,
                            Value  = Controller.ProgressBarPercentage
                        };

                        TextBlock progress_label = new TextBlock()
                        {
                            Width         = 414,
                            Text          = "Preparing to fetch files…",
                            TextAlignment = TextAlignment.Right
                        };

                        ContentCanvas.Children.Add(progress_bar);
                        ContentCanvas.Children.Add(progress_label);

                        Canvas.SetLeft(progress_bar, 185);
                        Canvas.SetTop(progress_bar, 150);

                        Canvas.SetLeft(progress_label, 185);
                        Canvas.SetTop(progress_label, 175);

                        TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;

                        Buttons.Add(cancel_button);
                        Buttons.Add(finish_button);


                        Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    progress_bar.Value            = percentage;
                                    TaskbarItemInfo.ProgressValue = percentage / 100;
                                    progress_label.Text           = speed;
                                });
                        };

                        cancel_button.Click += delegate {
                            Controller.SyncingCancelled();
                        };

                        break;
                    }


                    case PageType.Error: {
                        Header      = "Oops! Something went wrong…";
                        Description = "Please check the following:";

                        TextBlock help_block = new TextBlock()
                        {
                            TextWrapping = TextWrapping.Wrap,
                            Width        = 310
                        };

                        TextBlock bullets_block = new TextBlock()
                        {
                            Text = "•\n\n\n•"
                        };

                        help_block.Inlines.Add(new Bold(new Run(Controller.PreviousUrl)));
                        help_block.Inlines.Add(" is the address we’ve compiled. Does this look alright?\n\n");
                        help_block.Inlines.Add("Is this computer’s Client ID known by the host?");

                        if (warnings.Length > 0)
                        {
                            bullets_block.Text += "\n\n•";
                            help_block.Inlines.Add("\n\nHere’s the raw error message:");

                            foreach (string warning in warnings)
                            {
                                help_block.Inlines.Add("\n");
                                help_block.Inlines.Add(new Bold(new Run(warning)));
                            }
                        }

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        Button try_again_button = new Button()
                        {
                            Content = "Try again…"
                        };


                        ContentCanvas.Children.Add(bullets_block);
                        Canvas.SetLeft(bullets_block, 195);
                        Canvas.SetTop(bullets_block, 100);

                        ContentCanvas.Children.Add(help_block);
                        Canvas.SetLeft(help_block, 210);
                        Canvas.SetTop(help_block, 100);

                        TaskbarItemInfo.ProgressValue = 1.0;
                        TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error;

                        Buttons.Add(try_again_button);
                        Buttons.Add(cancel_button);


                        cancel_button.Click += delegate {
                            Controller.PageCancelled();
                        };

                        try_again_button.Click += delegate {
                            Controller.ErrorPageCompleted();
                        };

                        break;
                    }

                    case PageType.CryptoSetup: {
                        // TODO: Merge crypto pages
                        Header      = "Set up file encryption";
                        Description = "Please a provide a strong password that you don’t use elsewhere.";

                        TextBlock password_label = new TextBlock()
                        {
                            Text       = "Password:"******"Show password",
                            IsChecked = false
                        };

                        TextBlock info_label = new TextBlock()
                        {
                            Text         = "This password can’t be changed later, and your files can’t be recovered if it’s forgotten.",
                            TextWrapping = TextWrapping.Wrap,
                            Width        = 315
                        };

                        Image warning_image = new Image()
                        {
                            Source = Imaging.CreateBitmapSourceFromHIcon(Drawing.SystemIcons.Information.Handle,
                                                                         Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
                        };

                        show_password_checkbox.Checked += delegate {
                            visible_password_box.Text       = password_box.Password;
                            visible_password_box.Visibility = Visibility.Visible;
                            password_box.Visibility         = Visibility.Hidden;
                        };

                        show_password_checkbox.Unchecked += delegate {
                            password_box.Password           = visible_password_box.Text;
                            password_box.Visibility         = Visibility.Visible;
                            visible_password_box.Visibility = Visibility.Hidden;
                        };

                        password_box.PasswordChanged += delegate {
                            Controller.CheckCryptoSetupPage(password_box.Password);
                        };

                        visible_password_box.TextChanged += delegate {
                            Controller.CheckCryptoSetupPage(visible_password_box.Text);
                        };

                        Button continue_button = new Button()
                        {
                            Content   = "Continue",
                            IsEnabled = false
                        };

                        continue_button.Click += delegate {
                            if (show_password_checkbox.IsChecked == true)
                            {
                                Controller.CryptoSetupPageCompleted(visible_password_box.Text);
                            }
                            else
                            {
                                Controller.CryptoSetupPageCompleted(password_box.Password);
                            }
                        };

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        cancel_button.Click += delegate {
                            Controller.CryptoPageCancelled();
                        };

                        Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    continue_button.IsEnabled = button_enabled;
                                });
                        };

                        ContentCanvas.Children.Add(password_label);
                        Canvas.SetLeft(password_label, 270);
                        Canvas.SetTop(password_label, 180);

                        ContentCanvas.Children.Add(password_box);
                        Canvas.SetLeft(password_box, 335);
                        Canvas.SetTop(password_box, 180);

                        ContentCanvas.Children.Add(visible_password_box);
                        Canvas.SetLeft(visible_password_box, 335);
                        Canvas.SetTop(visible_password_box, 180);

                        ContentCanvas.Children.Add(show_password_checkbox);
                        Canvas.SetLeft(show_password_checkbox, 338);
                        Canvas.SetTop(show_password_checkbox, 208);

                        ContentCanvas.Children.Add(info_label);
                        Canvas.SetLeft(info_label, 240);
                        Canvas.SetTop(info_label, 300);

                        ContentCanvas.Children.Add(warning_image);
                        Canvas.SetLeft(warning_image, 193);
                        Canvas.SetTop(warning_image, 300);

                        Buttons.Add(continue_button);
                        Buttons.Add(cancel_button);

                        password_box.Focus();

                        break;
                    }

                    case PageType.CryptoPassword: {
                        Header      = "This project contains encrypted files";
                        Description = "Please enter the password to see their contents.";

                        TextBlock password_label = new TextBlock()
                        {
                            Text       = "Password:"******"Show password",
                            IsChecked = false
                        };

                        show_password_checkbox.Checked += delegate {
                            visible_password_box.Text       = password_box.Password;
                            visible_password_box.Visibility = Visibility.Visible;
                            password_box.Visibility         = Visibility.Hidden;
                        };

                        show_password_checkbox.Unchecked += delegate {
                            password_box.Password           = visible_password_box.Text;
                            password_box.Visibility         = Visibility.Visible;
                            visible_password_box.Visibility = Visibility.Hidden;
                        };

                        password_box.PasswordChanged += delegate {
                            Controller.CheckCryptoPasswordPage(password_box.Password);
                        };

                        visible_password_box.TextChanged += delegate {
                            Controller.CheckCryptoPasswordPage(visible_password_box.Text);
                        };

                        Button continue_button = new Button()
                        {
                            Content   = "Continue",
                            IsEnabled = false
                        };

                        continue_button.Click += delegate {
                            if (show_password_checkbox.IsChecked == true)
                            {
                                Controller.CryptoPasswordPageCompleted(visible_password_box.Text);
                            }
                            else
                            {
                                Controller.CryptoPasswordPageCompleted(password_box.Password);
                            }
                        };

                        Button cancel_button = new Button()
                        {
                            Content = "Cancel"
                        };

                        cancel_button.Click += delegate {
                            Controller.CryptoPageCancelled();
                        };

                        Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) {
                            Dispatcher.BeginInvoke((Action) delegate {
                                    continue_button.IsEnabled = button_enabled;
                                });
                        };

                        ContentCanvas.Children.Add(password_label);
                        Canvas.SetLeft(password_label, 270);
                        Canvas.SetTop(password_label, 180);

                        ContentCanvas.Children.Add(password_box);
                        Canvas.SetLeft(password_box, 335);
                        Canvas.SetTop(password_box, 180);

                        ContentCanvas.Children.Add(visible_password_box);
                        Canvas.SetLeft(visible_password_box, 335);
                        Canvas.SetTop(visible_password_box, 180);

                        ContentCanvas.Children.Add(show_password_checkbox);
                        Canvas.SetLeft(show_password_checkbox, 338);
                        Canvas.SetTop(show_password_checkbox, 208);

                        Buttons.Add(continue_button);
                        Buttons.Add(cancel_button);

                        password_box.Focus();

                        break;
                    }

                    case PageType.Finished: {
                        Header      = "Your shared project is ready!";
                        Description = "You can find the files in your SparkleShare folder.";


                        Button finish_button = new Button()
                        {
                            Content = "Finish"
                        };

                        Button show_files_button = new Button()
                        {
                            Content = "Show files"
                        };

                        if (warnings.Length > 0)
                        {
                            Image warning_image = new Image()
                            {
                                Source = Imaging.CreateBitmapSourceFromHIcon(Drawing.SystemIcons.Information.Handle,
                                                                             Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
                            };

                            TextBlock warning_block = new TextBlock()
                            {
                                Text         = warnings [0],
                                Width        = 310,
                                TextWrapping = TextWrapping.Wrap
                            };

                            ContentCanvas.Children.Add(warning_image);
                            Canvas.SetLeft(warning_image, 193);
                            Canvas.SetTop(warning_image, 100);

                            ContentCanvas.Children.Add(warning_block);
                            Canvas.SetLeft(warning_block, 240);
                            Canvas.SetTop(warning_block, 100);
                        }

                        TaskbarItemInfo.ProgressValue = 0.0;
                        TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;

                        Buttons.Add(show_files_button);
                        Buttons.Add(finish_button);


                        finish_button.Click += delegate {
                            Controller.FinishPageCompleted();
                        };

                        show_files_button.Click += delegate {
                            Controller.ShowFilesClicked();
                        };

                        break;
                    }
                    }

                    ShowAll();
                });
            };
        }
Exemple #49
0
		protected void Read_Reference (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (Reference), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is Reference, "#26");
			Assert.IsNotNull (XamlLanguage.Type.SchemaContext, "#23-3");
			Assert.IsNotNull (r.SchemaContext, "#23-4");
			Assert.AreNotEqual (XamlLanguage.Type.SchemaContext, r.SchemaContext, "#23-5");
			Assert.AreNotEqual (XamlLanguage.Reference.SchemaContext, xt.SchemaContext, "#23-6");
			Assert.AreEqual (XamlLanguage.Reference, xt, "#23-7");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			// unlike TypeExtension there is no PositionalParameters.
			Assert.AreEqual (xt.GetMember ("Name"), r.Member, "#33-2");

			// It is a ContentProperty (besides [ConstructorArgument])
			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("FooBar", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
Exemple #50
0
 /// <summary>
 /// Returns an object with the xaml string loaded
 /// </summary>
 /// <param name="xaml">XAML string to load</param>
 /// <returns>Loaded XAML object</returns>
 public static object LoadComponentFromString(string xaml)
 {
     return(XamlReader.Load(Regex.Replace(xaml, "x:Class=\".*?\"", "")));
 }
Exemple #51
0
		// almost identical to TypeExtension (only type/instance difference)
		protected void Read_StaticExtension (XamlReader r, XamlMember ctorArgMember)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			Assert.AreEqual (new XamlType (typeof (StaticExtension), r.SchemaContext), r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is StaticExtension, "#26");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (ctorArgMember, r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("FooBar", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
Exemple #52
0
 public tabScsiInfo()
 {
     XamlReader.Load(this);
 }
Exemple #53
0
		protected void Read_ListType (XamlReader r, bool isObjectReader)
		{
			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");

			var defns = "clr-namespace:System.Collections.Generic;assembly=mscorlib";
			var defns2 = "clr-namespace:System;assembly=mscorlib";
			var defns3 = "clr-namespace:System.Xaml;assembly=System.Xaml";

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "ns#1-3");
			Assert.AreEqual (defns, r.Namespace.Namespace, "ns#1-4");

			Assert.IsTrue (r.Read (), "ns#2-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#2-2");
			Assert.IsNotNull (r.Namespace, "ns#2-3");
			Assert.AreEqual ("s", r.Namespace.Prefix, "ns#2-3-2");
			Assert.AreEqual (defns2, r.Namespace.Namespace, "ns#2-3-3");

			Assert.IsTrue (r.Read (), "ns#3-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#3-2");
			Assert.IsNotNull (r.Namespace, "ns#3-3");
			Assert.AreEqual ("sx", r.Namespace.Prefix, "ns#3-3-2");
			Assert.AreEqual (defns3, r.Namespace.Namespace, "ns#3-3-3");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (List<Type>), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
			Assert.IsTrue (xt.IsCollection, "#27");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Capacity"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("2", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"x:Int32", "Dictionary(s:Type, sx:XamlType)"};
			for (int i = 0; i < 2; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				// Here XamlObjectReader and XamlXmlReader significantly differs. (Lucky we can make this test conditional so simply)
				if (isObjectReader)
					Assert.AreEqual (XamlLanguage.PositionalParameters, r.Member, i + "#74-3");
				else
					Assert.AreEqual (XamlLanguage.Type.GetMember ("Type"), r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#75-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items
			
			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88");

			Assert.IsFalse (r.Read (), "#89");
		}
Exemple #54
0
 public static T FromString <T>(string xaml)
 {
     return((T)XamlReader.Parse(xaml));
 }
Exemple #55
0
		protected void Read_ArrayList (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "ns#1-1");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "ns#1-2");

			var defns = "clr-namespace:System.Collections;assembly=mscorlib";

			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "ns#1-3");
			Assert.AreEqual (defns, r.Namespace.Namespace, "ns#1-4");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (ArrayList), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23");
//			Assert.AreEqual (obj, r.Instance, "#26");
			Assert.IsTrue (xt.IsCollection, "#27");

			if (r is XamlXmlReader)
				ReadBase (r);

			// This assumption on member ordering ("Type" then "Items") is somewhat wrong, and we might have to adjust it in the future.

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Capacity"), r.Member, "#33");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			// The value is implementation details, not testable.
			//Assert.AreEqual ("3", r.Value, "#43");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#72");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#72-2");
			Assert.AreEqual (XamlLanguage.Items, r.Member, "#72-3");

			string [] values = {"5", "-3", "0"};
			for (int i = 0; i < 3; i++) {
				Assert.IsTrue (r.Read (), i + "#73");
				Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, i + "#73-2");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, i + "#74-2");
				Assert.AreEqual (XamlLanguage.Initialization, r.Member, i + "#74-3");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.IsNotNull (r.Value, i + "#75-2");
				Assert.AreEqual (values [i], r.Value, i + "#73-3");
				Assert.IsTrue (r.Read (), i + "#74");
				Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, i + "#74-2");
				Assert.IsTrue (r.Read (), i + "#75");
				Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, i + "#75-2");
			}

			Assert.IsTrue (r.Read (), "#81");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#82"); // XamlLanguage.Items

			Assert.IsTrue (r.Read (), "#87");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#88");

			Assert.IsFalse (r.Read (), "#89");
		}
Exemple #56
0
        public void ValidateNonVirtualLayoutDoesNotGetMeasuredForViewportChanges()
        {
            RunOnUIThread.Execute(() =>
            {
                int measureCount = 0;
                int arrangeCount = 0;
                var repeater     = new ItemsRepeater();

                // with a non virtualizing layout, repeater will just
                // run layout once.
                repeater.Layout = new MockNonVirtualizingLayout()
                {
                    MeasureLayoutFunc = (size, context) =>
                    {
                        measureCount++;
                        return(new Size(100, 800));
                    },
                    ArrangeLayoutFunc = (size, context) =>
                    {
                        arrangeCount++;
                        return(new Size(100, 800));
                    }
                };

                repeater.ItemsSource  = Enumerable.Range(0, 10);
                repeater.ItemTemplate = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'>
						 <Button Content='{Binding}' Height='100' />
					</DataTemplate>"                    );

                Content = new ScrollViewer()
                {
                    Content = repeater
                };
                Content.UpdateLayout();

                Verify.AreEqual(1, measureCount);
                Verify.AreEqual(1, arrangeCount);

                measureCount = 0;
                arrangeCount = 0;

                // Once we switch to a virtualizing layout we should
                // get at least two passes to update the viewport.
                repeater.Layout = new MockVirtualizingLayout()
                {
                    MeasureLayoutFunc = (size, context) =>
                    {
                        measureCount++;
                        return(new Size(100, 800));
                    },
                    ArrangeLayoutFunc = (size, context) =>
                    {
                        arrangeCount++;
                        return(new Size(100, 800));
                    }
                };

                Content.UpdateLayout();

                Verify.IsGreaterThan(measureCount, 1);
                Verify.IsGreaterThan(arrangeCount, 1);
            });
        }
Exemple #57
0
		// It gives Type member, not PositionalParameters... and no Items member here.
		protected void Read_ArrayExtension2 (XamlReader r)
		{
			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.IsNotNull (r.Namespace, "#13");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#13-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#13-3");
//			Assert.IsNull (r.Instance, "#14");

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#22");
			var xt = new XamlType (typeof (ArrayExtension), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#23-2");
//			Assert.IsTrue (r.Instance is ArrayExtension, "#26");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#32");
			Assert.AreEqual (xt.GetMember ("Type"), r.Member, "#33-2");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.Value, r.NodeType, "#42");
			Assert.AreEqual ("x:Int32", r.Value, "#43-2");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#52");

			Assert.IsTrue (r.Read (), "#61");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#62");

			Assert.IsFalse (r.Read (), "#71");
			Assert.IsTrue (r.IsEof, "#72");
		}
Exemple #58
0
 public frmPrintHex(IMediaImage inputFormat)
 {
     this.inputFormat = inputFormat;
     XamlReader.Load(this);
 }
Exemple #59
0
		protected void WriteNullMemberAsObject (XamlReader r, Action validateNullInstance)
		{
			Assert.AreEqual (XamlNodeType.None, r.NodeType, "#1");
			Assert.IsTrue (r.Read (), "#6");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#7");
			Assert.AreEqual (String.Empty, r.Namespace.Prefix, "#7-2");
			Assert.AreEqual ("clr-namespace:MonoTests.System.Xaml;assembly=" + GetType ().Assembly.GetName ().Name, r.Namespace.Namespace, "#7-3");

			Assert.IsTrue (r.Read (), "#11");
			Assert.AreEqual (XamlNodeType.NamespaceDeclaration, r.NodeType, "#12");
			Assert.AreEqual ("x", r.Namespace.Prefix, "#12-2");
			Assert.AreEqual (XamlLanguage.Xaml2006Namespace, r.Namespace.Namespace, "#12-3");

			Assert.IsTrue (r.Read (), "#16");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#17");
			var xt = new XamlType (typeof (TestClass4), r.SchemaContext);
			Assert.AreEqual (xt, r.Type, "#17-2");
//			Assert.IsTrue (r.Instance is TestClass4, "#17-3");
			Assert.AreEqual (2, xt.GetAllMembers ().Count, "#17-4");

			if (r is XamlXmlReader)
				ReadBase (r);

			Assert.IsTrue (r.Read (), "#21");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#22");
			Assert.AreEqual (xt.GetMember ("Bar"), r.Member, "#22-2");

			Assert.IsTrue (r.Read (), "#26");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#27");
			Assert.AreEqual (XamlLanguage.Null, r.Type, "#27-2");
			if (validateNullInstance != null)
				validateNullInstance ();

			Assert.IsTrue (r.Read (), "#31");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#32");

			Assert.IsTrue (r.Read (), "#36");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#37");

			Assert.IsTrue (r.Read (), "#41");
			Assert.AreEqual (XamlNodeType.StartMember, r.NodeType, "#42");
			Assert.AreEqual (xt.GetMember ("Foo"), r.Member, "#42-2");

			Assert.IsTrue (r.Read (), "#43");
			Assert.AreEqual (XamlNodeType.StartObject, r.NodeType, "#43-2");
			Assert.AreEqual (XamlLanguage.Null, r.Type, "#43-3");
			if (validateNullInstance != null)
				validateNullInstance ();

			Assert.IsTrue (r.Read (), "#44");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#44-2");

			Assert.IsTrue (r.Read (), "#46");
			Assert.AreEqual (XamlNodeType.EndMember, r.NodeType, "#47");

			Assert.IsTrue (r.Read (), "#51");
			Assert.AreEqual (XamlNodeType.EndObject, r.NodeType, "#52");

			Assert.IsFalse (r.Read (), "#56");
			Assert.IsTrue (r.IsEof, "#57");
		}
Exemple #60
0
        private void _drawLines(int mod, int rem)
        {
            bool animate = (this.AnimationDuration > 0);

            double marginLeft = MarginLeft, marginTop = MarginTop;
            double marginRight = MarginRight, marginBottom = MarginBottom;

            double      gridWidth = (ChartCanvas.Width - marginLeft - marginRight);
            double      gridHeight = (ChartCanvas.Height - marginTop - marginBottom);
            LookAndFeel lf = CurrentLookAndFeel;
            string      lineDotXAML = lf.GetLineDotXAML(),
                        pathXAML = lf.GetLinePathXAML();
            Path             pathElem, dotElement;
            List <UIElement> dataElems        = null;
            MatrixTransform  defaultTransform = null;

            if (animate)
            {
                dataElems = DataElements;
            }

            bool       isStacked = (Type == ChartType.AREA_STACKED);
            ChartModel model     = Model;

            string[] groupLabels = model.GroupLabels;
            int      groupCount  = groupLabels.Length;

            string[] seriesLabels = model.SeriesLabels;
            int      seriesCount  = seriesLabels.Length;

            Color[] seriesColors = model.SeriesColors;
            double[,] yValues = model.YValues;

            double minValue = model.MinYValue, maxValue = model.MaxYValue;

            int yValueCount = yValues.GetUpperBound(0) + 1;

            string gradientXAML = lf.GetElementGradientXAML();
            double barWidth = gridWidth / Math.Max(yValueCount, groupCount);
            double dx, dy;

            for (int i = 0; i < seriesCount; ++i)
            {
                // for combo charts we draw a bar every once in a mod.
                if ((mod > 1) && (i % mod) != rem)
                {
                    continue;
                }

                dx = marginLeft + barWidth / 2;

                StringBuilder sb = new StringBuilder();

                for (int j = 0; j < yValueCount; ++j)
                {
                    dy = gridHeight + marginTop - gridHeight * (yValues[j, i] - minValue) / (maxValue - minValue);

                    if (j == 0)
                    {
                        sb.Append("M").Append(dx).Append(",").Append(dy);
                    }
                    else
                    {
                        sb.Append("L").Append(dx).Append(",").Append(dy);
                    }

                    dotElement = XamlReader.Load(lineDotXAML) as Path;
                    EllipseGeometry rectG = dotElement.Data as EllipseGeometry;
                    rectG.Center = new Point(dx, dy);

                    if (gradientXAML != null)
                    {
                        SetGradientOnElement(dotElement, gradientXAML, seriesColors[i], 0xe5);
                    }
                    else
                    {
                        SetFillOnElement(dotElement, seriesColors[i]);
                    }

                    dotElement.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                    if (animate)
                    {
                        dataElems.Add(dotElement);
                        defaultTransform = new MatrixTransform();
                        Matrix m = new Matrix();
                        m.M11 = 0.0;
                        defaultTransform.Matrix = m;
                        dotElement.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                    }
                    ChartCanvas.Children.Add(dotElement);

                    dx += barWidth;
                }

                pathElem = CreatePathFromXAMLAndData(pathXAML, sb);
                // There is no fill for lines
                pathElem.SetValue(Path.StrokeProperty, new SolidColorBrush(seriesColors[i]));

                SetExpandosOnElement(pathElem, -1, i, new Point());
                if (DisplayToolTip)
                {
                    pathElem.MouseMove  += new MouseEventHandler(ShowToolTip);
                    pathElem.MouseLeave += new MouseEventHandler(HideToolTip);
                }
                pathElem.MouseLeftButtonUp += new MouseButtonEventHandler(ChartDataClicked);

                if (animate)
                {
                    dataElems.Add(pathElem);
                    defaultTransform = new MatrixTransform();
                    Matrix m = new Matrix();
                    m.M11 = 0.0;
                    defaultTransform.Matrix = m;
                    pathElem.SetValue(UIElement.RenderTransformProperty, defaultTransform);
                }
                ChartCanvas.Children.Add(pathElem);
            }
        }