// open an existing zip file
        void _btnOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();

                op.RestoreDirectory = true;
                op.Filter           = "Zip(*.zip)|*.zip";

                var open = op.ShowDialog();

                if (open.HasValue && open.Value)
                {
                    Clear();
                    progressBar.Visibility = Visibility.Visible;

                    if (_zip == null)
                    {
                        _zip = new C1ZipFile();
                    }

                    _zip.Open(op.FileName);
                    _btnExtract.IsEnabled = true;
                    RefreshView();
                }
            }
            catch (Exception x)
            {
                progressBar.Visibility = Visibility.Collapsed;
                // snapped?
                System.Diagnostics.Debug.WriteLine(x.Message);
            }
            progressBar.Visibility = Visibility.Collapsed;
        }
Beispiel #2
0
        static public void CreateZip(string filename)
        {
            int       fileCount = 0;
            C1ZipFile ZipFile   = null;

            try
            {
                ZipFile = new C1ZipFile(GetCompletePath() + filename);
                foreach (string file in Directory.GetFiles(GetCompletePath()))
                {
                    if (!file.EndsWith(".zip"))
                    {
                        fileCount++;
                        ZipFile.Entries.Add(file);
                    }
                }
                ZipFile.Close();
            }
            catch (System.Exception e)
            {
                ExitCode   = JobStatus.JOB_FAILED;
                FatalError = "Failed to create zipped file archive. (" + e.Message + ")";
            }
            finally
            {
                if (ZipFile != null)
                {
                    ZipFile.Close();
                    ZipFile = null;
                }
            }
        }
Beispiel #3
0
        // open an existing zip file
        async void _btnOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var picker = new Windows.Storage.Pickers.FileOpenPicker();

                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add(".zip");
                StorageFile _zipfile = await picker.PickSingleFileAsync();

                if (_zipfile != null)
                {
                    Clear();
                    progressBar.Visibility = Visibility.Visible;

                    if (_zip == null)
                    {
                        _zip = new C1ZipFile(new System.IO.MemoryStream(), true);
                    }
                    var stream = await _zipfile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    _zip.Open(stream.AsStream());

                    _btnExtract.IsEnabled = true;
                    RefreshView();
                }
            }
            catch (Exception x)
            {
                System.Diagnostics.Debug.WriteLine(x.Message);
            }
            progressBar.Visibility = Visibility.Collapsed;
        }
Beispiel #4
0
        bool _ascending;        // list view sort order

        // ** ctor
        public Form1()
        {
            InitializeComponent();

            _zipFile           = new C1ZipFile();
            _zipFile.Progress += _zipFile_Progress;
        }
Beispiel #5
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // load data from embedded zip resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("CustomColumns.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // show sales by country and category
            var olap = _c1OlapPage.OlapPanel.OlapEngine;

            olap.BeginUpdate();
            olap.Updated += olap_Updated;
            olap.ValueFields.MaxItems = 3;
            olap.DataSource           = ds.Tables[0].DefaultView;
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("Category");
            olap.ValueFields.Add("Sales");
            olap.Fields["Sales"].Format = "n0";
            olap.EndUpdate();
        }
Beispiel #6
0
        void OpenZip(string fn)
        {
            // make sure this is a valid zip file
            if (!File.Exists(fn))
            {
                return;
            }
            if (!C1ZipFile.IsZipFile(fn))
            {
                return;
            }

            // open zip file
            try
            {
                _zipFile.Open(fn);
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message, "Open Zip File", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // update user interface
            UpdateUI();
        }
Beispiel #7
0
        public static void ExtractC1NWind()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.C1NWind.xml.zip"))
            {
                C1ZipFile zf = new C1ZipFile();
                zf.Open(stream);
                using (Stream src = zf.Entries[0].OpenReader())
                {
                    if (!File.Exists("C1NWind.xml") || new FileInfo("C1NWind.xml").Length != zf.Entries[0].SizeUncompressed)
                    {
                        using (Stream dst = new FileStream("C1NWind.xml", FileMode.Create))
                        {
                            byte[] buf = new byte[16 * 1024];
                            int    len;
                            while ((len = src.Read(buf, 0, buf.Length)) > 0)
                            {
                                dst.Write(buf, 0, len);
                            }
                        }
                    }
                }
            }
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("CustomColumns.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // show sales by country and category
            var olap = _c1OlapPage.OlapPanel.OlapEngine;
            olap.BeginUpdate();
            olap.Updated += olap_Updated;
            olap.ValueFields.MaxItems = 3;
            olap.DataSource = ds.Tables[0].DefaultView;
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("Category");
            olap.ValueFields.Add("Sales");
            olap.Fields["Sales"].Format = "n0";
            olap.EndUpdate();
        }
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("OlapQuickStart.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            _c1OlapPage.Loaded += (s, ea) =>
            {
                // bind olap page to data
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;

                // show sales by country and category
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.DataSource = ds.Tables[0].DefaultView;
                olap.BeginUpdate();
                olap.RowFields.Add("Country");
                olap.ColumnFields.Add("Category");
                olap.ValueFields.Add("Sales");
                olap.Fields["Sales"].Format = "n0";
                olap.EndUpdate();
            };
        }
Beispiel #10
0
        void LoadSourceCodes()
        {
            var resource = Application.GetResourceStream(new Uri("/" + new AssemblyName(Assembly.GetExecutingAssembly().FullName).Name + ";component/Resources/SamplesCodes.zip", UriKind.Relative));

            if (resource != null)
            {
                using (C1ZipFile zip = new C1ZipFile(resource.Stream))
                {
                    AllItems.ToList <SampleItem>().ForEach(sampleItem =>
                    {
                        var ets = zip.Entries.Where(entry => entry.FileName.Equals(sampleItem.SourceCodes.XamlFileName) ||
                                                    entry.FileName.Equals(sampleItem.SourceCodes.CodeFileName));
                        ets.ToList <C1ZipEntry>().ForEach(entry =>
                        {
                            if (entry.FileName.Contains("xaml.cs"))
                            {
                                sampleItem.SourceCodes.Code = GetContent(entry);
                            }
                            else
                            {
                                sampleItem.SourceCodes.Xaml = GetContent(entry);
                            }
                        });
                    });
                }
            }
        }
Beispiel #11
0
        SymbolData GetSymbolDataOffline(string symbol)
        {
            SymbolData data = null;

            try
            {
                using (var zstream = GetResourceStream(symbol + ".csv.zip"))
                {
                    if (zstream != null)
                    {
                        using (var zip = new C1ZipFile(zstream))
                        {
                            using (var stream = zip.Entries[0].OpenReader())
                            {
                                using (var sr = new StreamReader(stream))
                                {
                                    data = LoadQuote(sr.ReadToEnd());
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            return(data);
        }
Beispiel #12
0
        static void Main(String[] args)
        {
            String DirectoryToRead = "";
            String DirectoryToSave = "";
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: Zipper \\SourceFolder \\DestinationFile");
                return;
            }
            if (args.Length > 0)
            {
                Console.WriteLine(args[0]);
                DirectoryToRead = args[0];

            }
            if (args.Length > 1)
            {
                DirectoryToSave = args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip";
                Console.WriteLine(args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip");
            }

            Console.WriteLine(DirectoryToSave);

            Int32 Depth = 0;
            C1ZipFile zf = new C1ZipFile(DirectoryToSave, true);
            FolderLoop(DirectoryToRead, Depth, zf);
            zf.Close();
            //Console.WriteLine("Press any key ...");
            //Console.ReadKey();
        }
        // add files by folder
        private void _btnPickFolder_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
                dlg.ShowDialog();
                if (dlg.SelectedPath != null)
                {
                    if (_btnExtract.IsEnabled)
                    {
                        Clear();
                    }
                    progressBar.Visibility = Visibility.Visible;

                    if (zipMemoryStream == null)
                    {
                        zipMemoryStream = new MemoryStream();
                    }
                    if (_zip == null)
                    {
                        _zip = new C1ZipFile(zipMemoryStream, true);
                    }
                    _zip.Entries.AddFolder(dlg.SelectedPath);

                    _btnCompress.IsEnabled = true;
                }
            }
            catch
            {
                progressBar.Visibility = Visibility.Collapsed;
                // snapped?
            }
            RefreshView();
            progressBar.Visibility = Visibility.Collapsed;
        }
Beispiel #14
0
        private void InitializeCodeViewer()
        {
            // todo: correct below code to properly find samples inside zip
            string filename1 = _sample.TypeName.Replace('.', '/') + ".cs";
            string filename2 = _sample.TypeName.Replace('.', '/') + ".Designer.cs";

            // Code from WPF version:
            // var sourceArray = Source.Split('\\');
            // string xaml = String.Format("{0}/{1}", sourceArray.First(), sourceArray.Last());
            // string cs = String.Format("{0}/{1}.cs", sourceArray.First(), sourceArray.Last());

            Stream s = _exAsm.GetManifestResourceStream(SOURCE_NAME);

            if (s != null)
            {
                C1ZipFile z = new C1ZipFile();
                z.Open(s);
                if (z.Entries[filename1] != null)
                {
                    _code.Add(filename1, string.Empty);
                }
                if (z.Entries[filename2] != null)
                {
                    _code.Add(filename2, string.Empty);
                }
                z.Close();
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("OlapQuickStart.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            _c1OlapPage.Loaded += (s, ea) =>
            {
                // bind olap page to data
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;

                // show sales by country and category
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.DataSource = ds.Tables[0].DefaultView;
                olap.BeginUpdate();
                olap.RowFields.Add("Country");
                olap.ColumnFields.Add("Category");
                olap.ValueFields.Add("Sales");
                olap.Fields["Sales"].Format = "n0";
                olap.EndUpdate();
            };
        }
Beispiel #16
0
        static Utils()
        {
            PivotDataSet = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("FlexPivotExplorer.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    PivotDataSet.ReadXml(zr);
                }
            }

            PivotViews = new Dictionary <string, string>();
            using (var s = asm.GetManifestResourceStream("FlexPivotExplorer.Resources.FlexPivotViews.xml"))
                using (var reader = XmlReader.Create(s))
                {
                    // read predefined view definitions
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "FlexPivotPage")
                        {
                            var id  = reader.GetAttribute("id");
                            var def = reader.ReadOuterXml();
                            PivotViews[id] = def;
                        }
                    }
                }
        }
Beispiel #17
0
        static void Main(String[] args)
        {
            String DirectoryToRead = "";
            String DirectoryToSave = "";

            if (args.Length < 2)
            {
                Console.WriteLine("Usage: Zipper \\SourceFolder \\DestinationFile");
                return;
            }
            if (args.Length > 0)
            {
                Console.WriteLine(args[0]);
                DirectoryToRead = args[0];
            }
            if (args.Length > 1)
            {
                DirectoryToSave = args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip";
                Console.WriteLine(args[1] + DateTime.Now.ToString("yyyyMMddHHmm") + ".zip");
            }

            Console.WriteLine(DirectoryToSave);


            Int32     Depth = 0;
            C1ZipFile zf    = new C1ZipFile(DirectoryToSave, true);

            FolderLoop(DirectoryToRead, Depth, zf);
            zf.Close();
            //Console.WriteLine("Press any key ...");
            //Console.ReadKey();
        }
Beispiel #18
0
        private void LoadZip()
        {
            // locate zip file
            string strFile = Application.ExecutablePath;
            int    i       = strFile.IndexOf("\\bin");

            if (i > -1)
            {
                strFile = strFile.Substring(0, i);
            }
            strFile += "\\" + zipName;

            // open password-protected zip file
            C1ZipFile zip = new C1ZipFile();

            zip.Open(strFile);
            zip.Password = zipPwd;

            // load report definition XML document from compressed stream
            Stream stream = zip.Entries[0].OpenReader();

            _xmlDoc = new XmlDocument();
            _xmlDoc.PreserveWhitespace = true;
            _xmlDoc.Load(stream);
            stream.Close();
            //
            zip.Close();
            //
            _lbReports.Items.AddRange(C1FlexReport.GetReportList(_xmlDoc));
        }
Beispiel #19
0
        public MainWindow()
        {
            InitializeComponent();

            // load Invoices data from embedded resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("ConditionalFormatting.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            _c1OlapPage.Loaded += (s, ea) =>
            {
                // prepare to build view
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.BeginUpdate();

                // show sales by country and category/product
                olap.ColumnFields.Add("Country");
                olap.RowFields.Add("Category", "Product");
                olap.Fields["Product"].Width = 250;
                var value = olap.Fields["Sales"];
                olap.ValueFields.Add(value);
                value.Format = "n0";

                // show values in the top 90% percentile in green
                var sh = value.StyleHigh;
                sh.Value         = .90;
                sh.ConditionType = C1.Olap.ConditionType.Percentage;
                sh.ForeColor     = Color.FromArgb(0xff, 0, 50, 0);
                sh.BackColor     = Color.FromArgb(0xff, 200, 250, 200);
                sh.FontBold      = true;

                // show values in the bottom 2% percentile in red
                var sl = value.StyleLow;
                sl.Value         = .02;
                sl.ConditionType = C1.Olap.ConditionType.Percentage;
                sl.ForeColor     = Color.FromArgb(0xff, 50, 0, 0);
                sl.BackColor     = Color.FromArgb(0xff, 250, 200, 200);
                sl.FontBold      = true;

                // view is ready
                olap.EndUpdate();
            };
        }
        public MainWindow()
        {
            InitializeComponent();

            // load Invoices data from embedded resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("ConditionalFormatting.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            _c1OlapPage.Loaded += (s, ea) =>
            {
                // prepare to build view
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.BeginUpdate();

                // show sales by country and category/product
                olap.ColumnFields.Add("Country");
                olap.RowFields.Add("Category", "Product");
                olap.Fields["Product"].Width = 250;
                var value = olap.Fields["Sales"];
                olap.ValueFields.Add(value);
                value.Format = "n0";

                // show values in the top 90% percentile in green
                var sh = value.StyleHigh;
                sh.Value = .90;
                sh.ConditionType = C1.Olap.ConditionType.Percentage;
                sh.ForeColor = Color.FromArgb(0xff, 0, 50, 0);
                sh.BackColor = Color.FromArgb(0xff, 200, 250, 200);
                sh.FontBold = true;

                // show values in the bottom 2% percentile in red
                var sl = value.StyleLow;
                sl.Value = .02;
                sl.ConditionType = C1.Olap.ConditionType.Percentage;
                sl.ForeColor = Color.FromArgb(0xff, 50, 0, 0);
                sl.BackColor = Color.FromArgb(0xff, 250, 200, 200);
                sl.FontBold = true;

                // view is ready
                olap.EndUpdate();
            };
        }
Beispiel #21
0
        void LoadProjectStructure()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            Stream s = asm.GetManifestResourceStream("ControlExplorer.SourceCode.zip");

            C1ZipFile z = new C1ZipFile();

            z.Open(s);

            C1TreeNodeCollection targetNodeCollection = null;
            int previousLevel = -1;

            for (int i = 0; i < z.Entries.Count; i++)
            {
                string[] partsOfPath = z.Entries[i].FileName.Split('/');

                int level      = partsOfPath.Length - 2;
                int imageIndex = 0;

                if (!string.IsNullOrEmpty(partsOfPath[partsOfPath.Length - 1]))
                {
                    level      = partsOfPath.Length - 1;
                    imageIndex = 2;
                }

                string nodeName = partsOfPath[level];

                if (targetNodeCollection == null)
                {
                    targetNodeCollection = c1TreeView1.Nodes;
                }
                else
                {
                    if (previousLevel > level)
                    {
                        targetNodeCollection = targetNodeCollection.Parent.ParentCollection;
                    }
                    else if (previousLevel < level)
                    {
                        targetNodeCollection = targetNodeCollection.Last().Nodes;
                    }
                }

                C1TreeNode node = targetNodeCollection.Add(nodeName);
                node.Images.Add(imageIndex);
                previousLevel = level;
            }

            z.Close();
        }
Beispiel #22
0
        private string GetCode(string filename)
        {
            Stream    s    = _exAsm.GetManifestResourceStream(SOURCE_NAME);
            string    code = string.Empty;
            C1ZipFile z    = new C1ZipFile();

            z.Open(s);
            if (z.Entries[filename] != null)
            {
                StreamReader reader = new StreamReader(z.Entries[filename].OpenReader());
                code = reader.ReadToEnd();
                reader.Close();
            }
            z.Close();
            return(code);
        }
        // add files
        private void _btnPickFiles_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
                op.Multiselect      = true;
                op.RestoreDirectory = true;
                op.Filter           = "All files(*.*)|*.*";

                var open = op.ShowDialog();

                if (open.HasValue && open.Value)
                {
                    var files = op.FileNames;
                    if (files.Length == 0)
                    {
                        return;
                    }
                    if (_btnExtract.IsEnabled)
                    {
                        Clear();
                    }
                    progressBar.Visibility = Visibility.Visible;
                    if (zipMemoryStream == null)
                    {
                        zipMemoryStream = new MemoryStream();
                    }
                    if (_zip == null)
                    {
                        _zip = new C1ZipFile(zipMemoryStream, true);
                    }
                    foreach (var f in files)
                    {
                        _zip.Entries.Add(f);
                    }

                    _btnCompress.IsEnabled = true;
                }
            }
            catch
            {
                // snapped?
            }
            RefreshView();
            progressBar.Visibility = Visibility.Collapsed;
        }
Beispiel #24
0
 // refresh view when collection is modified
 void RefreshView()
 {
     _flex.ItemsSource = null;
     if (_zip == null)
     {
         return;
     }
     _flex.ItemsSource = _zip.Entries;
     if (_zip.Entries.Count == 0)
     {
         _btnCompress.IsEnabled = false;
         _btnRemove.IsEnabled   = false;
         _btnView.IsEnabled     = false;
         _btnExtract.IsEnabled  = false;
         _zip = null;
     }
 }
Beispiel #25
0
        static void FolderLoop(String DirectoryToRead, Int32 Depth, C1ZipFile zf)
        {
            DirectoryInfo di = new DirectoryInfo(DirectoryToRead);
            ++Depth;

            foreach (DirectoryInfo diSub in di.GetDirectories())
            {
                Console.WriteLine(DirectoryToRead);
                DirectoryToRead = diSub.FullName;
                FolderLoop(DirectoryToRead, Depth, zf);
            }
            foreach (FileInfo fi in di.GetFiles())
            {
                Console.WriteLine(fi.FullName);
                zf.Entries.Add(fi.FullName, Depth);
            }
        }
Beispiel #26
0
        static void FolderLoop(String DirectoryToRead, Int32 Depth, C1ZipFile zf)
        {
            DirectoryInfo di = new DirectoryInfo(DirectoryToRead);

            ++Depth;

            foreach (DirectoryInfo diSub in di.GetDirectories())
            {
                Console.WriteLine(DirectoryToRead);
                DirectoryToRead = diSub.FullName;
                FolderLoop(DirectoryToRead, Depth, zf);
            }
            foreach (FileInfo fi in di.GetFiles())
            {
                Console.WriteLine(fi.FullName);
                zf.Entries.Add(fi.FullName, Depth);
            }
        }
Beispiel #27
0
        private void Clear()
        {
            _flex.ItemsSource = null;

            if (zipMemoryStream != null)
            {
                zipMemoryStream.Flush();
                zipMemoryStream.Dispose();
            }
            zipMemoryStream        = null;
            _btnCompress.IsEnabled = false;
            _btnExtract.IsEnabled  = false;
            if (_zip != null)
            {
                _zip.Close();
                _zip = null;
            }
        }
Beispiel #28
0
        // add files
        private async void _btnPickFiles_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var picker = new Windows.Storage.Pickers.FileOpenPicker();
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add(Strings.Star);

                var files = await picker.PickMultipleFilesAsync();

                if (files != null)
                {
                    if (files.Count == 0)
                    {
                        return;
                    }
                    if (_btnExtract.IsEnabled)
                    {
                        Clear();
                    }
                    progressBar.Visibility = Visibility.Visible;
                    if (zipMemoryStream == null)
                    {
                        zipMemoryStream = new MemoryStream();
                    }
                    if (_zip == null)
                    {
                        _zip = new C1ZipFile(zipMemoryStream, true);
                    }
                    foreach (var f in files)
                    {
                        await _zip.Entries.AddAsync(f);
                    }
                    _btnCompress.IsEnabled = true;
                }
            }
            catch
            {
            }
            RefreshView();
            progressBar.Visibility = Visibility.Collapsed;
        }
 public static void LoadKMZ(this C1VectorLayer vl, Stream stream, bool centerAndZoom,
                            ProcessVectorItem processVector)
 {
     using (C1ZipFile zip = new C1ZipFile(stream))
     {
         foreach (C1ZipEntry entry in zip.Entries)
         {
             if (entry.FileName.EndsWith(".kml"))
             {
                 using (Stream docStream = entry.OpenReader())
                 {
                     if (docStream != null)
                     {
                         LoadKML(vl, docStream, centerAndZoom, processVector);
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var sampleItems = SampleDataSource.GetItems((String)navigationParameter);

            try
            {
                Assembly asm = typeof(MainPage).GetTypeInfo().Assembly;
                using (Stream stream = asm.GetManifestResourceStream("FlexChart101.Resources.SamplesCodes.zip"))
                {
                    using (C1ZipFile zip = new C1ZipFile(stream))
                    {
                        bool isMobileDevice = LayoutAwarePage.IsWindowsPhoneDevice();
                        sampleItems.ToList <SampleDataItem>().ForEach(sampleItem =>
                        {
                            var ets = zip.Entries.Where(entry => entry.FileName.Equals(sampleItem.SourceCodes.XamlFileName) ||
                                                        entry.FileName.Equals(sampleItem.SourceCodes.CodeFileName) ||
                                                        (entry.FileName.Contains("DeviceFamily-Mobile/")) && entry.FileName.Contains(sampleItem.SourceCodes.XamlFileName));
                            ets.ToList <C1ZipEntry>().ForEach(entry =>
                            {
                                if (entry.FileName.Contains("xaml.cs"))
                                {
                                    sampleItem.SourceCodes.Code = GetContent(entry);
                                }
                                else if (ets.Count() == 2 || (isMobileDevice && entry.FileName.Contains("DeviceFamily-Mobile/") ||
                                                              !isMobileDevice && !entry.FileName.Contains("DeviceFamily-Mobile/")))
                                {
                                    sampleItem.SourceCodes.Xaml = GetContent(entry);
                                }
                            });
                        });
                    }
                }
            }
            catch
            {
            }
            this.DefaultViewModel["AllItems"] = sampleItems;
        }
 public void ExtractC1NWind()
 {
     using (Stream stream = Application.GetResourceStream(new Uri("/" + _asmName + ";component/FlexViewer/C1NWind.xml.zip", UriKind.Relative)).Stream)
     {
         C1ZipFile zf = new C1ZipFile();
         zf.Open(stream);
         using (Stream src = zf.Entries[0].OpenReader())
         {
             if (!File.Exists("C1NWind.xml") || new FileInfo("C1NWind.xml").Length != zf.Entries[0].SizeUncompressed)
             {
                 using (Stream dst = new FileStream("C1NWind.xml", FileMode.Create))
                 {
                     byte[] buf = new byte[16 * 1024];
                     int    len;
                     while ((len = src.Read(buf, 0, buf.Length)) > 0)
                     {
                         dst.Write(buf, 0, len);
                     }
                 }
             }
         }
     }
 }
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("OlapTemplate.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            _c1OlapPage.Loaded += (s, ea) =>
            {
                // bind olap page to data
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;
                // set columns totals chart
                _c1OlapPage.ChartType   = C1.WPF.Olap.ChartType.Column;
                _c1OlapPage.ChartTotals = true;
                // show sales by country and order date
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.DataSource = ds.Tables[0].DefaultView;
                olap.BeginUpdate();
                olap.RowFields.Add("Country");
                olap.ColumnFields.Add("OrderDate");
                olap.ValueFields.Add("Sales");
                olap.Fields["OrderDate"].Format = "MMM";

                olap.EndUpdate();
            };
        }
Beispiel #33
0
        // add files by folder
        private async void _btnPickFolder_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FolderPicker folderPicker = new FolderPicker();
                folderPicker.FileTypeFilter.Add(Strings.Star);

                StorageFolder pickedFolder = await folderPicker.PickSingleFolderAsync();

                if (pickedFolder != null)
                {
                    if (_btnExtract.IsEnabled)
                    {
                        Clear();
                    }
                    progressBar.Visibility = Visibility.Visible;

                    if (zipMemoryStream == null)
                    {
                        zipMemoryStream = new MemoryStream();
                    }
                    if (_zip == null)
                    {
                        _zip = new C1ZipFile(zipMemoryStream, true);
                    }
                    await _zip.Entries.AddFolderAsync(pickedFolder);

                    _btnCompress.IsEnabled = true;
                }
            }
            catch
            {
            }
            RefreshView();
            progressBar.Visibility = Visibility.Collapsed;
        }
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("OlapTemplate.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            _c1OlapPage.Loaded += (s, ea) =>
            {
                // bind olap page to data
                _c1OlapPage.DataSource = ds.Tables[0].DefaultView;
                // set columns totals chart
                _c1OlapPage.ChartType = C1.WPF.Olap.ChartType.Column;
                _c1OlapPage.ChartTotals = true;
                // show sales by country and order date
                var olap = _c1OlapPage.OlapPanel.OlapEngine;
                olap.DataSource = ds.Tables[0].DefaultView;
                olap.BeginUpdate();
                olap.RowFields.Add("Country");
                olap.ColumnFields.Add("OrderDate");
                olap.ValueFields.Add("Sales");
                olap.Fields["OrderDate"].Format = "MMM";

                olap.EndUpdate();
            };
        }
Beispiel #35
0
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("CustomUI.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            PivotBuilder.DataSource = ds.Tables[0].DefaultView;

            var olap = PivotBuilder.OlapEngine;

            // rename fields in the UI
            olap.Fields["ExtendedPrice"].Caption = "Sales";
            olap.Fields["OrderDate"].Caption     = "Order Date";
            olap.Fields["PostalCode"].Caption    = "Postal Code";
            //olap.Fields["Customers_002eCompanyName"].Caption = "Company Name";
            olap.Fields["ProductName"].Caption  = "Product Name";
            olap.Fields["RequiredDate"].Caption = "Required Date";
            olap.Fields["ShipAddress"].Caption  = "Ship Address";
            olap.Fields["ShipCity"].Caption     = "Ship City";
            olap.Fields["ShipCountry"].Caption  = "Ship Country";
            olap.Fields["ShipName"].Caption     = "Ship Name";
            olap.Fields["ShippedDate"].Caption  = "Shipped Date";
            //olap.Fields["Shippers_002eCompanyName"].Caption = "Shipper";
            olap.Fields["ShipPostalCode"].Caption = "Ship Postal Code";
            olap.Fields["ShipRegion"].Caption     = "Ship Region";
            olap.Fields["UnitPrice"].Caption      = "Price";

            // set formats
            olap.Fields["OrderDate"].Format     = "yyyy";
            olap.Fields["RequiredDate"].Format  = "yyyy";
            olap.Fields["ShippedDate"].Format   = "yyyy";
            olap.Fields["ExtendedPrice"].Format = "c2";
            olap.Fields["UnitPrice"].Format     = "c2";

            // show sales by country and category
            olap.DataSource = ds.Tables[0].DefaultView;
            olap.BeginUpdate();
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("OrderDate");
            olap.ValueFields.Add("ExtendedPrice");
            olap.EndUpdate();

            PivotBuilder.OlapEngine.Update();

            olap.Updated += (s, e) =>
            {
                info.Visibility = Visibility.Collapsed;
            };

            olap.UpdateProgressChanged += (s, e) =>
            {
                info.Visibility = Visibility.Visible;
            };

            // initialize printing report options
            _reportOptions = new ReportOptions()
            {
                IncludeGrid         = true,
                IncludeChart        = true,
                IncludeRawData      = false,
                Margin              = new Thickness(1),
                ChartScale          = ScaleMode.SinglePage,
                GridScale           = ScaleMode.PageWidth,
                RawDataScale        = ScaleMode.PageWidth,
                ShowFooterSeparator = true,
                ShowHeaderSeparator = true,
                HeaderCenter        = "&[ViewTitle]",
                HeaderRight         = "&[Date]",
                FooterRight         = "Page &[Page] of &[PageCount]"
            };

            // initialize undo/redo stack
            new OlapPanelUndoStack(PivotBuilder, btnUndo, btnRedo);

            // configure toolbar
            btnChartType_Bar.IsChecked = true;

            Application.Current.Resources.MergedDictionaries.Add(C1.WPF.Theming.C1Theme.GetCurrentThemeResources(new C1.WPF.Theming.Office2013.C1ThemeOffice2013White()));
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("CustomizePage.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            _c1OlapPage.DataSource = ds.Tables[0].DefaultView;

            // view not found in storage, use default
            var olap = _c1OlapPage.OlapPanel.OlapEngine;
            olap.DataSource = ds.Tables[0].DefaultView;
            olap.BeginUpdate();
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("Category");
            olap.ValueFields.Add("Sales");
            olap.Fields["Sales"].Format = "n0";
            olap.EndUpdate();

            // get predefined views from XML resource
            var views = new Dictionary<string, string>();
            using (var s = asm.GetManifestResourceStream("CustomizePage.Resources.OlapViews.xml"))
            using (var reader = XmlReader.Create(s))
            {
                // read predefined view definitions
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "C1OlapPage")
                    {
                        var id = reader.GetAttribute("id");
                        var def = reader.ReadOuterXml();
                        views[id] = def;
                    }
                }
            }

            // build new menu with predefined views
            var menuViews = new C1MenuItem();
            menuViews.Header = "View";
            menuViews.Icon = GetImage("Resources/views.png");
            menuViews.VerticalAlignment = VerticalAlignment.Center;
            ToolTipService.SetToolTip(menuViews, "Select a predefined Olap view.");
            foreach (var id in views.Keys)
            {
                var mi = new C1MenuItem();
                mi.Header = id;
                mi.Tag = views[id];
                mi.Click += mi_Click;
                menuViews.Items.Add(mi);
            }

            // add new menu to the page's main menu
            _c1OlapPage.MainMenu.Items.Insert(6, menuViews);
        }
Beispiel #37
0
        void OlapDemo_Loaded(object sender, RoutedEventArgs e)
        {
            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            olapPage.DataSource = ds.Tables[0].DefaultView;

            // view not found in storage, use default
            var olap = olapPage.OlapPanel.OlapEngine;
            olap.DataSource = ds.Tables[0].DefaultView;

            // set value field limit to 4 (**default is 1)
            olap.ValueFields.MaxItems = 4;

            // create conditional formatting
            olap.Fields["ExtendedPrice"].StyleHigh.ForeColor = Colors.Green;
            olap.Fields["ExtendedPrice"].StyleHigh.ConditionType = C1.Olap.ConditionType.Percentage;
            olap.Fields["ExtendedPrice"].StyleHigh.Value = 0.8;
            olap.Fields["ExtendedPrice"].StyleLow.ForeColor = Colors.Red;
            olap.Fields["ExtendedPrice"].StyleLow.ConditionType = C1.Olap.ConditionType.Percentage;
            olap.Fields["ExtendedPrice"].StyleLow.Value = 0.1;

            // apply update to view
            olap.BeginUpdate();
            olap.Fields["ExtendedPrice"].Caption = "Sales";
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("Salesperson");
            olap.ValueFields.Add("ExtendedPrice");
            olap.Fields["ExtendedPrice"].Format = "c0";
            olap.EndUpdate();

            // get predefined views from XML resource
            var views = new Dictionary<string, string>();
            using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.OlapViews.xml"))
            using (var reader = XmlReader.Create(s))
            {
                // read predefined view definitions
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "C1OlapPage")
                    {
                        var id = reader.GetAttribute("id");
                        var def = reader.ReadOuterXml();
                        views[id] = def;
                    }
                }
            }

            // build new menu with predefined views
            var menuViews = new C1MenuItem();
            menuViews.Header = "Views";
            menuViews.Icon = GetImage("/Resources/Views.png");
            menuViews.VerticalAlignment = VerticalAlignment.Center;
            ToolTipService.SetToolTip(menuViews, "Select a predefined Olap view.");
            foreach (var id in views.Keys)
            {
                var mi = new C1MenuItem();
                mi.Header = id;
                mi.Padding = new Thickness(5);
                mi.Tag = views[id];
                mi.Click += mi_Click;
                menuViews.Items.Add(mi);
            }

            // add new menu to the page's main menu
            olapPage.MainMenu.Items.Insert(6, menuViews);
        }
        /// <summary>
        /// Reads the application id from the package.
        /// </summary>
        /// <param name="packageFile"> The package file.</param>
        /// <returns> An application id.</returns>
        public static string ReadApplicationID(string packageFile)
        {
            string result = string.Empty;
            C1ZipFile zipFile = new C1ZipFile();

            try
            {
                zipFile.Open(packageFile);

                // Application
                C1ZipEntry entry = zipFile.Entries[0];
                // Get entry name and convert to guid
                // if invalid GUID, throw exception
                string name = entry.FileName;

                Guid g = new Guid(name);
                result = name;
            }
            catch ( Exception ex )
            {
                System.Diagnostics.Debug.Write(ex.ToString());
            }
            finally
            {
                zipFile.Close();
            }

            return result;
        }
        /// <summary>
        /// Opens a package from a web instance.
        /// </summary>
        /// <param name="fileName"> The package file name.</param>
        public void OpenPackageWeb(string fileName)
        {
            C1ZipFile zipFile = new C1ZipFile();
            //  package = new ScriptingApplicationPackage();

            try
            {
                zipFile.Open(fileName);

                // Application
                C1ZipEntry entry = zipFile.Entries[0];
                // Get entry name and convert to guid
                // if invalid GUID, throw exception
                string name = entry.FileName;
                string applicationXml = string.Empty;
                string applicationArgumentsXml = string.Empty;

                // Get Scripting Application Xml.
                Guid g = new Guid(name);
                StreamReader reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8);
                applicationXml= reader.ReadToEnd();
                reader.Close();

                if ( zipFile.Entries.Count > 1 )
                {
                    // Arguments
                    entry = zipFile.Entries[1];
                    reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8);
                    applicationArgumentsXml = reader.ReadToEnd();

                    if ( applicationArgumentsXml.ToLower() != "none" )
                    {
                        _arguments = ScriptingApplicationArgs.FromXml(applicationArgumentsXml);
                    }
                    else
                    {
                        _arguments = null;
                    }

                    reader.Close();
                }

                // Get Custom Transforms
                int start = 2;
                for ( int i=2;i<zipFile.Entries.Count;i++ )
                {
                    entry = zipFile.Entries[i];

                    if ( entry.FileName == "CustomTransformsSeparator" )
                    {
                        start = i+1;
                        break;
                    }

                    // Add File References to Application Startup
                    // string location = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + entry.FileName;
            //					if ( !File.Exists(location) )
            //					{
            //						zipFile.Entries.Extract(i, location);
            //					}
                    // Add WebTransform Entry in Configuration.
                    // if exists don't add.
                    // RegisterWebTransform(location);
                    // ScriptingApplicationSerializer.UpdateSerializer();
                }

                // Generate scripting application.
                XmlDocument document = new XmlDocument();
                document.LoadXml(applicationXml);
                _application = ScriptingApplication.Decrypt(document);
                //	_application = ScriptingApplication.FromXml(applicationXml);
            //
            //				for ( int i=start;i<zipFile.Entries.Count;i++ )
            //				{
            //					entry = zipFile.Entries[i];
            //
            //					// Add File References to Internet Cache
            //					string location = Utils.AppLocation.InternetTemp + Path.DirectorySeparatorChar + _application.Header.ApplicationID + Path.DirectorySeparatorChar + entry.FileName;
            //					if ( File.Exists(location) )
            //					{
            //						File.Delete(location);
            //					}
            //					zipFile.Entries.Extract(i, location);
            //				}
            }
            catch
            {
                throw;
            }
            finally
            {
                zipFile.Close();
            }
        }
        void OlapDemo_Loaded(object sender, RoutedEventArgs e)
        {
            // load data from embedded zip resource
            var ds  = new DataSet();
            var asm = Assembly.GetExecutingAssembly();

            using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            olapPage.DataSource = ds.Tables[0].DefaultView;

            // view not found in storage, use default
            var olap = olapPage.OlapPanel.OlapEngine;

            olap.DataSource = ds.Tables[0].DefaultView;

            // set value field limit to 4 (**default is 1)
            olap.ValueFields.MaxItems = 4;

            // create conditional formatting
            olap.Fields["ExtendedPrice"].StyleHigh.ForeColor     = Colors.Green;
            olap.Fields["ExtendedPrice"].StyleHigh.ConditionType = C1.Olap.ConditionType.Percentage;
            olap.Fields["ExtendedPrice"].StyleHigh.Value         = 0.8;
            olap.Fields["ExtendedPrice"].StyleLow.ForeColor      = Colors.Red;
            olap.Fields["ExtendedPrice"].StyleLow.ConditionType  = C1.Olap.ConditionType.Percentage;
            olap.Fields["ExtendedPrice"].StyleLow.Value          = 0.1;

            // apply update to view
            olap.BeginUpdate();
            olap.Fields["ExtendedPrice"].Caption = "Sales";
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("Salesperson");
            olap.ValueFields.Add("ExtendedPrice");
            olap.Fields["ExtendedPrice"].Format = "c0";
            olap.EndUpdate();

            // get predefined views from XML resource
            var views = new Dictionary <string, string>();

            using (var s = asm.GetManifestResourceStream("OlapSamples.Resources.OlapViews.xml"))
                using (var reader = XmlReader.Create(s))
                {
                    // read predefined view definitions
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "C1OlapPage")
                        {
                            var id  = reader.GetAttribute("id");
                            var def = reader.ReadOuterXml();
                            views[id] = def;
                        }
                    }
                }

            // build new menu with predefined views
            var menuViews = new C1MenuItem();

            menuViews.Header            = "Views";
            menuViews.Icon              = GetImage("/Resources/Views.png");
            menuViews.VerticalAlignment = VerticalAlignment.Center;
            ToolTipService.SetToolTip(menuViews, "Select a predefined Olap view.");
            foreach (var id in views.Keys)
            {
                var mi = new C1MenuItem();
                mi.Header  = id;
                mi.Padding = new Thickness(5);
                mi.Tag     = views[id];
                mi.Click  += mi_Click;
                menuViews.Items.Add(mi);
            }

            // add new menu to the page's main menu
            olapPage.MainMenu.Items.Insert(6, menuViews);
        }
        public MainWindow()
        {
            InitializeComponent();

            // load data from embedded zip resource
            var ds = new DataSet();
            var asm = Assembly.GetExecutingAssembly();
            using (var s = asm.GetManifestResourceStream("CustomUI.Resources.nwind.zip"))
            {
                var zip = new C1ZipFile(s);
                using (var zr = zip.Entries[0].OpenReader())
                {
                    // load data
                    ds.ReadXml(zr);
                }
            }

            // bind olap page to data
            PivotBuilder.DataSource = ds.Tables[0].DefaultView;

            var olap = PivotBuilder.OlapEngine;
            // rename fields in the UI
            olap.Fields["ExtendedPrice"].Caption = "Sales";
            olap.Fields["OrderDate"].Caption = "Order Date";
            olap.Fields["PostalCode"].Caption = "Postal Code";
            //olap.Fields["Customers_002eCompanyName"].Caption = "Company Name";
            olap.Fields["ProductName"].Caption = "Product Name";
            olap.Fields["RequiredDate"].Caption = "Required Date";
            olap.Fields["ShipAddress"].Caption = "Ship Address";
            olap.Fields["ShipCity"].Caption = "Ship City";
            olap.Fields["ShipCountry"].Caption = "Ship Country";
            olap.Fields["ShipName"].Caption = "Ship Name";
            olap.Fields["ShippedDate"].Caption = "Shipped Date";
            //olap.Fields["Shippers_002eCompanyName"].Caption = "Shipper";
            olap.Fields["ShipPostalCode"].Caption = "Ship Postal Code";
            olap.Fields["ShipRegion"].Caption = "Ship Region";
            olap.Fields["UnitPrice"].Caption = "Price";

            // set formats
            olap.Fields["OrderDate"].Format = "yyyy";
            olap.Fields["RequiredDate"].Format = "yyyy";
            olap.Fields["ShippedDate"].Format = "yyyy";
            olap.Fields["ExtendedPrice"].Format = "c2";
            olap.Fields["UnitPrice"].Format = "c2";

            // show sales by country and category
            olap.DataSource = ds.Tables[0].DefaultView;
            olap.BeginUpdate();
            olap.RowFields.Add("Country");
            olap.ColumnFields.Add("OrderDate");
            olap.ValueFields.Add("ExtendedPrice");
            olap.EndUpdate();

            PivotBuilder.OlapEngine.Update();

            // initialize printing report options
            _reportOptions = new ReportOptions()
            {
                IncludeGrid = true,
                IncludeChart = true,
                IncludeRawData = false,
                Margin = new Thickness(1),
                ChartScale = ScaleMode.SinglePage,
                GridScale = ScaleMode.PageWidth,
                RawDataScale = ScaleMode.PageWidth,
                ShowFooterSeparator = true,
                ShowHeaderSeparator = true,
                HeaderCenter = "&[ViewTitle]",
                HeaderRight = "&[Date]",
                FooterRight = "Page &[Page] of &[PageCount]"
            };

            // initialize undo/redo stack
            new OlapPanelUndoStack(PivotBuilder, btnUndo, btnRedo);

            // configure toolbar
            btnChartType_Bar.IsChecked = true;

            Application.Current.Resources.MergedDictionaries.Add(C1.WPF.Theming.C1Theme.GetCurrentThemeResources(new C1.WPF.Theming.Office2013.C1ThemeOffice2013White()));
        }