Exemplo n.º 1
0
        private void PivotGridDemoModule_Loaded(object sender, RoutedEventArgs e)
        {
            List <LayoutSampleBase> layoutSamples = new List <LayoutSampleBase>();

            layoutSamples.Add(new MemoryStreamLayoutSample("Original", SaveLayout()));
            Assembly assembly = typeof(Serialization).Assembly;

            layoutSamples.Add(new ResourceLayoutSample("Brief view", DemoHelper.GetPath("PivotGridDemo.Data.LayoutSamples.", assembly) + "BriefView.xml"));
            layoutSamples.Add(new ResourceLayoutSample("Full view", DemoHelper.GetPath("PivotGridDemo.Data.LayoutSamples.", assembly) + "FullView.xml"));
            layoutSamplesComboBox.ItemsSource   = layoutSamples;
            layoutSamplesComboBox.SelectedIndex = 0;
        }
        static List <string> Dump(string fileName)
        {
            var      result   = new List <string>();
            Assembly assembly = typeof(PersonGenerator).Assembly;
            var      file     = assembly.GetManifestResourceStream(DemoHelper.GetPath(assembly.GetName().Name + ".Data.", assembly) + fileName);

            if (file != null)
            {
                var reader = new XmlTextReader(file);
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                        string nodeValue = reader.Value;
                        if (!string.IsNullOrEmpty(nodeValue))
                        {
                            result.Add(reader.Value);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        void LoadPredefinedWorkspaces()
        {
            workspaces.Items.Clear();
            Assembly thisExe = typeof(IDEWorkspaces).Assembly;

            for (int i = 1; i <= 4; i++, workspaceNumber++)
            {
                string workspaceName = string.Format("workspace{0}", i);
                string fileName      = string.Format("{0}.xml", workspaceName);
                using (Stream resourceStream = AssemblyHelper.GetEmbeddedResourceStream(thisExe, DemoHelper.GetPath("Layouts/", thisExe) + fileName, true))
                    Manager.LoadWorkspace(workspaceName, resourceStream);
                workspaces.Items.Add(workspaceName);
            }
        }
        void loadSampleLayoutButton_Click(object sender, RoutedEventArgs e)
        {
            Assembly thisExe = typeof(Serialization).Assembly;

            string name1 = string.Format("views{0}.xml", (layoutSampleName.SelectedIndex + 1).ToString().ToLower());

            using (Stream resourceStream = AssemblyHelper.GetEmbeddedResourceStream(thisExe, DemoHelper.GetPath("Layouts/MVVMSerialization/", thisExe) + name1, true)) {
                serializationViewModel.Restore(resourceStream);
            }
            string name = string.Format("saved{0}.xml", layoutSampleName.SelectedItem.ToString().ToLower());

            using (Stream resourceStream = AssemblyHelper.GetEmbeddedResourceStream(thisExe, DemoHelper.GetPath("Layouts/MVVMSerialization/", thisExe) + name, true)) {
                dockManager.RestoreLayoutFromStream(resourceStream);
            }
        }
 string GetCodeText(string name)
 {
     System.Reflection.Assembly assembly = typeof(VS2010DocumentViewModel).Assembly;
     using (Stream stream = AssemblyHelper.GetEmbeddedResourceStream(assembly, DemoHelper.GetPath("Data/", assembly) + name, true)) {
         if (stream == null)
         {
             return(string.Empty);
         }
         using (StreamReader reader = new StreamReader(stream)) {
             return(reader.ReadToEnd());
         }
     }
 }