コード例 #1
0
        /// <summary>
        /// Read an XFile and create the objects defined in it
        /// </summary>
        /// <param name="filespec"></param>
        public void Load(string filespec)
        {
            Debug.WriteLine("Loading XFile: "+filespec);

            manager = new XFileManager();
            manager.RegisterDefaultTemplates();							// register standard templates BEFORE opening file
            try
            {
                xfile = manager.FromFile(filespec);						// create an XFile object from file
            }
            catch (GraphicsException e)
            {
                if (e.ErrorCode == (int)XFileErrorCodes.ParseError)
                    Debug.WriteLine("ERROR in CellLoader.Load() - Couldn't parse Xfile "+filespec);
                else
                    Debug.WriteLine("ERROR in CellLoader.Load() - Failed to load "+filespec);
                throw;
            }

            manager.RegisterXFileTemplates(xfile);						// register any custom templates in the file
            //manager.RegisterTemplates(data);							// register any templates defined in my code

            for (int i=0; i<xfile.NumberChildren; i++)					// iterate through the root-level objects
            {
                using (XFileData rootObject = xfile.GetChild(i))
                {
                    LoadDataObject(rootObject,0,null,null);
                }
            }

            // Dispose of everything
            xfile.Dispose();
            manager.Dispose();
        }
コード例 #2
0
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     if ((this.AxisX == null) || (this.AxisY == null))
     {
         throw new InvalidOperationException("Both XAxis and YAxis cannot be null");
     }
     using (writer.WriteElement("lineChart", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("grouping", null, "c", "val", this.GetChartGrouping());
         writer.WriteLeafElementWithAttribute("varyColors", null, "c", "val", this.VaryColors ? "1" : "0");
         using (List <IExcelLineSeries> .Enumerator enumerator = this.LineSeries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 (enumerator.Current as ExcelLineSeries).WriteXml(writer, mFolder, chartFile);
             }
         }
         if (this.DataLabels != null)
         {
             (this.DataLabels as ExcelDataLabels).WriteXml(writer, mFolder, chartFile);
         }
         if (this.DropLine != null)
         {
             this.DropLine.WriteXml(writer, mFolder, chartFile, "dropLines");
         }
         if (this.HighLowLine != null)
         {
             this.HighLowLine.WriteXml(writer, mFolder, chartFile, "hiLowLines");
         }
         if (this.UpDownBars != null)
         {
             this.UpDownBars.WriteXml(writer, mFolder, chartFile);
         }
         writer.WriteLeafElementWithAttribute("marker", null, "c", "val", this.ShowMarkers() ? "1" : "0");
         writer.WriteLeafElementWithAttribute("smooth", null, "c", "val", this.Smoothing ? "1" : "0");
         if (this.AxisX != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisY != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
 }
コード例 #3
0
ファイル: StringLiteralData.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     if (this._literalDatas.Count > 0)
     {
         writer.WriteStartElement("c", "strLit", null);
         writer.WriteStartElement("c", "ptCount", null);
         writer.WriteAttributeString("val", null, ((int)this._literalDatas.Count).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         writer.WriteEndElement();
         for (int i = 0; i < this._literalDatas.Count; i++)
         {
             writer.WriteStartElement("c", "pt", null);
             writer.WriteAttributeString("idx", null, ((int)i).ToString((IFormatProvider)CultureInfo.InvariantCulture));
             writer.WriteElementString("c", "v", null, this._literalDatas[i]);
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
     }
 }
コード例 #4
0
ファイル: ExcelWall.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile, string root)
 {
     using (writer.WriteElement(root, null, "c"))
     {
         using (writer.WriteElement("thickness", null, "c"))
         {
             writer.WriteAttributeString("val", ((int)this.Thickness).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.Format != null)
         {
             (this.Format as ExcelChartFormat).WriteXml(writer, mFolder, chartFile);
         }
         if (this.PictureOptions != null)
         {
             this.PictureOptions.WriteXml(writer, mFolder, chartFile);
         }
     }
 }
コード例 #5
0
 internal XSharpSearchLocation(XFile file, XSourceMemberSymbol member, ITextSnapshot snapshot,
                               int lineNumber = 0, int position = 0, string currentNs = "")
 {
     Member   = member;
     Snapshot = snapshot;
     if (member != null)
     {
         File = Member.File;
     }
     else
     {
         File = file;
     }
     LineNumber       = lineNumber;
     Position         = position;
     CurrentNamespace = currentNs;
     Usings           = GetUsings();
 }
コード例 #6
0
        public XSharpOutliningTagger(ITextBuffer buffer, IClassifierAggregatorService AggregatorFactory, IClassificationTypeRegistryService registry)
        {
            this.buffer = buffer;
            if (buffer.Properties.ContainsProperty(typeof(XFile)))
            {
                _file = buffer.GetFile();
            }
            var classifier = buffer.GetClassifier();

            if (classifier == null)
            {
                // should not happen we checked before we created the class
                return;
            }
            this.buffer.Properties.AddProperty(typeof(XSharpOutliningTagger), this);
            xsharpRegionStartType = registry.GetClassificationType(ColorizerConstants.XSharpRegionStartFormat);
            xsharpRegionStopType  = registry.GetClassificationType(ColorizerConstants.XSharpRegionStopFormat);
        }
コード例 #7
0
ファイル: IOService.cs プロジェクト: mhsallam/xod.core
        //returns Type
        internal string GetItemPage(Type type, string code)
        {
            XFile tableFile = this.OpenFileOrCreate(type.FullName + ".xtab");

            foreach (var file in tableFile.Pages().Select(s => s.Attribute("file").Value))
            {
                XFile pageFile = this.OpenFileOrCreate(file);
                if (pageFile.Rows().Where(delegate(XElement s)
                {
                    XAttribute sa = s.Attribute("code");
                    return(null != sa && sa.Value == code);
                }).Any())
                {
                    return(file.Replace(".xpag", ""));
                }
            }
            return(null);
        }
コード例 #8
0
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     using (writer.WriteElement("p", null, "a"))
     {
         using (writer.WriteElement("pPr", null, "a"))
         {
             using (writer.WriteElement("defRPr", null, "a"))
             {
                 if (this.FontSize.HasValue && ((this.FontSize.Value - 1.0) > 0.0))
                 {
                     int num = (int)Math.Ceiling((double)(this.FontSize.Value * 100.0));
                     writer.WriteAttributeString("sz", ((int)num).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                 }
                 if (this.Bold.HasValue)
                 {
                     writer.WriteAttributeString("b", this.Bold.Value ? "1" : "0");
                 }
                 if (this.Italics.HasValue)
                 {
                     writer.WriteAttributeString("i", this.Italics.Value ? "1" : "0");
                 }
                 else
                 {
                     writer.WriteAttributeString("i", "0");
                 }
                 if (this.FillFormat != null)
                 {
                     this.FillFormat.WriteXml(writer, mFolder, chartFile);
                 }
                 this.WriteFont(writer, "latin", this.LatinFontFamily);
                 this.WriteFont(writer, "ea", this.EastAsianFontFamily);
                 this.WriteFont(writer, "cs", this.ComplexFontFamily);
                 this.WriteFont(writer, "sym", this.SymbolFontFamily);
             }
         }
         using (List <TextRun> .Enumerator enumerator = this.TextRuns.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.WriteXml(writer, mFolder, chartFile);
             }
         }
     }
 }
コード例 #9
0
ファイル: DisplayUnits.cs プロジェクト: Daoting/dt
 internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
 {
     foreach (XElement element in node.Elements())
     {
         if (element.Name.LocalName == "custUnit")
         {
             this.CustomDisplayUnit = element.GetAttributeValueOrDefaultOfDoubleType("val", 0.0);
         }
         else if (element.Name.LocalName == "builtInUnit")
         {
             BuiltInDisplayUnitValue hundreds = BuiltInDisplayUnitValue.Hundreds;
             Enum.TryParse <BuiltInDisplayUnitValue>(element.GetAttributeValueOrDefaultOfStringType("val", "hundreds"), true, out hundreds);
             this.BuiltInDisplayUnit = hundreds;
         }
         else if (element.Name.LocalName == "dispUnitsLbl")
         {
             foreach (XElement element2 in element.Elements())
             {
                 if (element2.Name.LocalName == "layout")
                 {
                     Dt.Xls.Chart.Layout layout = new Dt.Xls.Chart.Layout();
                     layout.ReadXml(element2, mFolder, xFile);
                     this.Layout = layout;
                 }
                 else if (element2.Name.LocalName == "tx")
                 {
                     foreach (XElement element3 in element.Elements())
                     {
                         if (element3.Name.LocalName == "rich")
                         {
                             Dt.Xls.Chart.RichText text = new Dt.Xls.Chart.RichText();
                             text.ReadXml(element3, mFolder, xFile);
                             this.RichText = text;
                         }
                         else if (element3.Name.LocalName == "strRef")
                         {
                             this.TextFormula = element3.GetChildElementValue("f");
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #10
0
ファイル: ExcelAreaChart.cs プロジェクト: Daoting/dt
 internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
 {
     foreach (XElement element in node.Elements())
     {
         if (element.Name.LocalName == "grouping")
         {
             this.ChartType = this.GetChartType(element.GetAttributeValueOrDefaultOfStringType("val", "standard"));
         }
         else if (element.Name.LocalName == "dLbls")
         {
             ExcelDataLabels labels = new ExcelDataLabels();
             labels.ReadXml(element, mFolder, xFile);
             this.DataLabels = labels;
         }
         else if (element.Name.LocalName == "varyColors")
         {
             this.VaryColors = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
         }
         else if (element.Name.LocalName == "ser")
         {
             ExcelAreaSeries series = new ExcelAreaSeries();
             series.ReadXml(element, mFolder, xFile);
             this.AreaSeries.Add(series);
         }
         else if (element.Name.LocalName == "axId")
         {
             int num = element.GetAttributeValueOrDefaultOfInt32Type("val", 0);
             if (!this.XAxisID.HasValue)
             {
                 this.XAxisID = new int?(num);
             }
             else if (!this.YAxisID.HasValue)
             {
                 this.YAxisID = new int?(num);
             }
         }
         else if (element.Name.LocalName == "dropLines")
         {
             this.DropLine = new ExcelChartLines();
             this.DropLine.ReadXml(element, mFolder, xFile);
         }
     }
 }
コード例 #11
0
        public void SortShouldCreateDestinationFile()
        {
            // arrange
            const string FileName        = "TestFile3.txt";
            const string DestinationFile = "SortedFile3.txt";

            var options = new XFileGenerationOptions {
                FileName = FileName, Strings = Strings, MinNumber = MinNumber, MaxNumber = MaxNumber, FileSize = FileSize
            };
            var xFile = new XFile();

            xFile.Generate(options);

            // act
            xFile.Sort(FileName, DestinationFile);

            // assert
            Assert.IsTrue(File.Exists(DestinationFile));
        }
コード例 #12
0
ファイル: ExcelLine3DChart.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     if (((this.AxisX == null) || (this.AxisY == null)) || (this.AxisZ == null))
     {
         throw new InvalidOperationException("Both XAxis, YAxis and ZAxis cannot be null");
     }
     using (writer.WriteElement("line3DChart", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("grouping", null, "c", "val", "standard");
         writer.WriteLeafElementWithAttribute("varyColors", null, "c", "val", this.VaryColors ? "1" : "0");
         using (List <IExcelLineSeries> .Enumerator enumerator = this.LineSeries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 (enumerator.Current as ExcelLineSeries).WriteXml(writer, mFolder, chartFile);
             }
         }
         if (this.DataLabels != null)
         {
             (this.DataLabels as ExcelDataLabels).WriteXml(writer, mFolder, chartFile);
         }
         if (this.DropLine != null)
         {
             this.DropLine.WriteXml(writer, mFolder, chartFile, "dropLines");
         }
         if (this.GapDepth != 150)
         {
             writer.WriteLeafElementWithAttribute("gapDepth", null, "c", "val", ((int)this.GapDepth).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisX != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisY != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisZ != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisZ.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
 }
コード例 #13
0
ファイル: ExcelChartTitle.cs プロジェクト: Daoting/dt
        internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
        {
            writer.WriteStartElement("c", "title", null);
            if (this.RichTextTitle != null)
            {
                using (writer.WriteElement("tx", null, "c"))
                {
                    this.RichTextTitle.WriteXml(writer, mFolder, chartFile);
                    goto Label_00B8;
                }
            }
            if (!string.IsNullOrWhiteSpace(this.TitleFormula))
            {
                using (writer.WriteElement("tx", null, "c"))
                {
                    using (writer.WriteElement("strRef", null, "c"))
                    {
                        string titleFormula = this.TitleFormula;
                        if (ParsingContext.ReferenceStyle == ExcelReferenceStyle.R1C1)
                        {
                            titleFormula = ParsingContext.ConvertR1C1FormulaToA1Formula(titleFormula, 0, 0);
                        }
                        writer.WriteElementString("c", "f", null, titleFormula);
                    }
                }
            }
Label_00B8:
            if (this.Layout != null)
            {
                this.Layout.WriteXml(writer, mFolder, chartFile);
            }
            writer.WriteLeafElementWithAttribute("overlay", null, "c", "val", this.Overlay ? "1" : "0");
            if (this.ShapeFormat != null)
            {
                (this.ShapeFormat as ExcelChartFormat).WriteXml(writer, mFolder, chartFile);
            }
            if (this.TextForamt != null)
            {
                (this.TextForamt as ExcelTextFormat).WriteXml(writer, mFolder, chartFile);
            }
            writer.WriteEndElement();
        }
コード例 #14
0
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     if ((this.AxisX == null) || (this.AxisY == null))
     {
         throw new InvalidOperationException("Both XAxis and YAxis cannot be null");
     }
     using (writer.WriteElement("bubbleChart", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("varyColors", null, "c", "val", this.VaryColors ? "1" : "0");
         using (List <ExcelBubbleSeries> .Enumerator enumerator = this.BubbleSeries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.WriteXml(writer, mFolder, chartFile);
             }
         }
         if (this.DataLabels != null)
         {
             (this.DataLabels as ExcelDataLabels).WriteXml(writer, mFolder, chartFile);
         }
         if (this.ChartType == ExcelChartType.Bubble)
         {
             writer.WriteLeafElementWithAttribute("bubble3D", null, "c", "val", "0");
         }
         writer.WriteLeafElementWithAttribute("bubbleScale", null, "c", "val", ((int)this.BubbleScale).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         writer.WriteLeafElementWithAttribute("showNegBubbles", null, "c", "val", this.ShowNegativeBubbles ? "1" : "0");
         string str = "area";
         if (this.SizeRepresents == BubbleSizeRepresents.Width)
         {
             str = "w";
         }
         writer.WriteLeafElementWithAttribute("sizeRepresents", null, "c", "val", str);
         if (this.AxisX != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisY != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
 }
コード例 #15
0
ファイル: StylesManager.cs プロジェクト: prepare/Sitana
        public void LoadStyles(string filename, bool overwrite)
        {
            XFile          file = XFileEx.FromPath(filename);
            DefinitionFile def  = DefinitionFile.LoadFile(file);

            if (def.Class != typeof(StylesContainer))
            {
                throw new Exception(String.Format("Invalid style sheet."));
            }

            Dictionary <string, DefinitionFile> dict = def["Styles"] as Dictionary <string, DefinitionFile>;

            if (dict != null)
            {
                foreach (var el in dict)
                {
                    RegisterStyle(el.Key, el.Value, overwrite);
                }
            }
        }
コード例 #16
0
ファイル: ExcelLegendEntry.cs プロジェクト: Daoting/dt
 internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
 {
     foreach (XElement element in node.Elements())
     {
         if (element.Name.LocalName == "delete")
         {
             this.Delete = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
         }
         else if (element.Name.LocalName == "idx")
         {
             this.Index = element.GetAttributeValueOrDefaultOfInt32Type("val", 0);
         }
         else if ((element.Name.LocalName != "extLst") && (element.Name.LocalName == "txPr"))
         {
             ExcelTextFormat format = new ExcelTextFormat();
             format.ReadXml(element, mFolder, xFile);
             this.TextFormat = format;
         }
     }
 }
コード例 #17
0
        public ActionResult ListFile(CommonFilterData filter)
        {
            var vm = CreateViewData <VMXFileList>();

            switch (filter.Action)
            {
            case "trash":
                var msg = XFile.DeleteByID(filter.ObjIDList.ToArray());
                if (!msg.Error)
                {
                    return(ListFile(string.Format("Items with id [{0}] have been deleted!", String.Join(",", filter.ObjIDList))));
                }
                vm.Msg   = msg.Body;
                vm.Error = msg.Error;
                break;
            }

            vm.FileList = XFile.ListAllData();
            return(View(vm));
        }
コード例 #18
0
 public XSharpDropDownClient(IVsDropdownBarManager manager, XFile file)
 {
     _manager   = manager;
     _textViews = new Dictionary <ITextView, ITextView>();
     _file      = file;
     if (file != null)
     {
         _file.ContentsChanged += _file_ContentsChanged;
     }
     _types   = new List <XDropDownMember>();
     _members = new List <XDropDownMember>();
     _saveSettings();
     _lastLine        = 0;
     _relatedFiles    = new List <string>();
     _lastFileChanged = DateTime.MinValue;
     ThreadHelper.JoinableTaskFactory.Run(async delegate
     {
         await RefreshDropDownAsync(needsUI: false);
     });
 }
コード例 #19
0
ファイル: TextRun.cs プロジェクト: Daoting/dt
 internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
 {
     foreach (XElement element in node.Elements())
     {
         if (element.Name.LocalName == "rPr")
         {
             int num = element.GetAttributeValueOrDefaultOfInt32Type("sz", -1);
             if ((num >= 100) && (num <= 0x61a80))
             {
                 this.FontSize = new double?(((double)num) / 100.0);
             }
             foreach (XAttribute attribute in element.Attributes())
             {
                 if (attribute.Name.LocalName == "b")
                 {
                     this.Bold = new bool?(element.GetAttributeValueOrDefaultOfBooleanType("b", true));
                 }
                 if (attribute.Name.LocalName == "i")
                 {
                     this.Italics = new bool?(element.GetAttributeValueOrDefaultOfBooleanType("i", true));
                 }
             }
             using (IEnumerator <XElement> enumerator3 = element.Elements().GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     IFillFormat format = enumerator3.Current.ReadFillFormat(mFolder, xFile);
                     if (format != null)
                     {
                         this.FillFormat = format;
                     }
                 }
                 continue;
             }
         }
         if (element.Name.LocalName == "t")
         {
             this.Text = element.Value;
         }
     }
 }
コード例 #20
0
ファイル: ExcelManualLayout.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     writer.WriteStartElement("c", "manualLayout", null);
     if (this.Target != ExcelLayoutTarget.Outer)
     {
         this.WriteElement(writer, "c", "layoutTarget", "val", "inner");
     }
     if (this.LeftMode != ExcelLayoutMode.Factor)
     {
         this.WriteElement(writer, "c", "xMode", "val", "edge");
     }
     if (this.TopMode != ExcelLayoutMode.Factor)
     {
         this.WriteElement(writer, "c", "yMode", "val", "edge");
     }
     if (this.WidthMode != ExcelLayoutMode.Factor)
     {
         this.WriteElement(writer, "c", "wMode", "val", "edge");
     }
     if (this.HeightMode != ExcelLayoutMode.Factor)
     {
         this.WriteElement(writer, "c", "hMode", "val", "edge");
     }
     if (this.Left >= 0.0)
     {
         this.WriteElement(writer, "c", "x", "val", ((double)this.Left).ToString((IFormatProvider)CultureInfo.InvariantCulture));
     }
     if (this.Top >= 0.0)
     {
         this.WriteElement(writer, "c", "y", "val", ((double)this.Top).ToString((IFormatProvider)CultureInfo.InvariantCulture));
     }
     if (!this.Width.IsZero())
     {
         this.WriteElement(writer, "c", "w", "val", ((double)this.Width).ToString((IFormatProvider)CultureInfo.InvariantCulture));
     }
     if (!this.Height.IsZero())
     {
         this.WriteElement(writer, "c", "h", "val", ((double)this.Height).ToString((IFormatProvider)CultureInfo.InvariantCulture));
     }
     writer.WriteEndElement();
 }
コード例 #21
0
        internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
        {
            foreach (XElement element in node.Elements())
            {
                if (element.Name.LocalName == "varyColors")
                {
                    this.VaryColors = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
                }
                else if (element.Name.LocalName == "ser")
                {
                    ExcelPieSeries series = new ExcelPieSeries();
                    series.ReadXml(element, mFolder, xFile);
                    this.PieSeries.Add(series);
                }
                else if (element.Name.LocalName == "dLbls")
                {
                    ExcelDataLabels labels = new ExcelDataLabels();
                    labels.ReadXml(element, mFolder, xFile);
                    this.DataLabels = labels;
                }
                else if (element.Name.LocalName == "firstSliceAng")
                {
                    this.FirstSliceAngle = element.GetAttributeValueOrDefaultOfInt32Type("val", 0);
                }
            }
            bool flag = true;

            if (this.PieSeries.Count > 0)
            {
                int explosion = this.PieSeries[0].Explosion;
                foreach (IExcelPieSeries series2 in this.PieSeries)
                {
                    if ((series2.Explosion == 0) || (series2.Explosion != explosion))
                    {
                        flag = false;
                        break;
                    }
                }
            }
            this.ChartType = flag ? ExcelChartType.ExplodedPie : ExcelChartType.Pie;
        }
コード例 #22
0
ファイル: ExcelAreaChart.cs プロジェクト: Daoting/dt
        internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
        {
            if ((this.AxisX == null) || (this.AxisY == null))
            {
                throw new InvalidOperationException("Both XAxis and YAxis cannot be null");
            }
            writer.WriteStartElement("c", "areaChart", null);
            string str = "standard";

            if (this.ChartType == ExcelChartType.AreaStacked)
            {
                str = "stacked";
            }
            else if (this.ChartType == ExcelChartType.AreaStacked100Percent)
            {
                str = "percentStacked";
            }
            writer.WriteLeafElementWithAttribute("grouping", null, "c", "val", str);
            writer.WriteLeafElementWithAttribute("varyColors", null, "c", "val", this.VaryColors ? "1" : "0");
            foreach (ExcelAreaSeries series in this.AreaSeries)
            {
                series.WriteXml(writer, mFolder, chartFile);
            }
            if (this.DataLabels != null)
            {
                (this.DataLabels as ExcelDataLabels).WriteXml(writer, mFolder, chartFile);
            }
            if (this.DropLine != null)
            {
                this.DropLine.WriteXml(writer, mFolder, chartFile, "dropLines");
            }
            if (this.AxisX != null)
            {
                writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            if (this.AxisY != null)
            {
                writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            writer.WriteEndElement();
        }
コード例 #23
0
        public void WriteToCSV(string fpath)
        {
            using (StreamWriter sw = new StreamWriter(fpath))
            {
                var headers = new List <string>
                {
                    "unit_mix",
                    "typology",
                    "seismicity",
                    "number_of_stories",
                    "drift_limit",
                    "gross_square_feet",
                    "total_structural_shear_wall_cost",
                    "cost_per_square_foot",
                    "meets_wall_design_limit",
                    "meets_drift_limit"
                };

                var headerString = XFile.CreateCSVString(headers);

                sw.WriteLine(headerString);

                var items = new List <string>
                {
                    RandomizedBuilding.UnitMix.Description,
                    RandomizedBuilding.Typology.Description,
                    RandomizedBuilding.Seismicity.Description,
                    RandomizedBuilding.NumberOfStories.ToString(),
                    RandomizedBuilding.DriftLimit.ToString(),
                    GrossSquareFeet.ToString(),
                    TotalStructuralShearWallCost.ToString(),
                    (TotalStructuralShearWallCost / GrossSquareFeet).ToString(),
                    MeetsWallDesignLimit.ToString(),
                    MeetsDriftLimit.ToString()
                };

                var csvString = XFile.CreateCSVString(items);

                sw.WriteLine(csvString);
            }
        }
コード例 #24
0
ファイル: CellLoader.cs プロジェクト: JamesTryand/simergy
        /// <summary>
        /// Read an XFile and create the objects defined in it,
        /// i.e. the frame hierarchy and Cytoplasm meshes.
        /// The animationSet objects in the X file are used to set joint limits in the frames
        /// </summary>
        /// <param name="group">Group that cell belongs to (i.e. DLL and folder name)</param>
        /// <param name="name">Cell type (i.e. filename minus extension, and CellType-derived class name)</param>
        /// <param name="variantName">NAME of the variant (i.e. name of the .X file)</param>
        /// <returns>The root frame of the loaded hierarchy</returns>
        public static JointFrame Load(string group, string type, string variantName)
        {
            CellLoader.folder = "cells" + "\\" + group + "\\" + type;				    // store subfolder name so that textures can be found

            string fsp = FileResource.Fsp(CellLoader.folder, variantName + ".X");	    // .X file will be ../cells/group/type/variant.x
            //			Debug.WriteLine("Loading XFile: "+fsp);
            filespec = fsp;

            manager = new XFileManager();
            manager.RegisterDefaultTemplates();							                // register standard templates BEFORE opening file

            try
            {
                xfile = manager.FromFile(filespec);						                // create an XFile object from file
            }
            catch (GraphicsException e)
            {
                if (e.ErrorCode == (int)XFileErrorCodes.ParseError)
                    throw new SDKException("ERROR in CellLoader.Load() - Couldn't parse Xfile "+filespec);
                else
                    throw new SDKException("ERROR in CellLoader.Load() - Failed to load " + filespec);
            }

            manager.RegisterXFileTemplates(xfile);						// register any custom templates in the file
            ////////			RegisterCustomTemplates();									// register any templates in this code

            for (int i=0; i<xfile.NumberChildren; i++)					// iterate through the root-level objects
            {
                using (XFileData rootObject = xfile.GetChild(i))
                {
                    LoadRootObject(rootObject);
                }
            }

            // Dispose of everything
            xfile.Dispose();
            manager.Dispose();

            // return the completed hierarchy
            return rootFrame;
        }
コード例 #25
0
        internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
        {
            if ((this.AxisX == null) || (this.AxisY == null))
            {
                throw new InvalidOperationException("Both XAxis and YAxis cannot be null");
            }
            writer.WriteStartElement("c", "radarChart", null);
            string str = "standard";

            if (this.ChartType == ExcelChartType.Radar)
            {
                str = "standard";
            }
            else if (this.ChartType == ExcelChartType.RadarWithMarkers)
            {
                str = "marker";
            }
            else if (this.ChartType == ExcelChartType.FilledRadar)
            {
                str = "filled";
            }
            writer.WriteLeafElementWithAttribute("radarStyle", null, "c", "val", str);
            writer.WriteLeafElementWithAttribute("varyColors", null, "c", "val", this.VaryColors ? "1" : "0");
            foreach (ExcelRadarSeries series in this.RadarSeries)
            {
                series.WriteXml(writer, mFolder, chartFile);
            }
            if (this.DataLabels != null)
            {
                (this.DataLabels as ExcelDataLabels).WriteXml(writer, mFolder, chartFile);
            }
            if (this.AxisX != null)
            {
                writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            if (this.AxisY != null)
            {
                writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
            }
            writer.WriteEndElement();
        }
コード例 #26
0
ファイル: ExcelUpDownBars.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     using (writer.WriteElement("upDownBars", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("gapWidth", null, "c", "val", ((int)this.GapWidth).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         using (writer.WriteElement("upBars", null, "c"))
         {
             if (this.UpBars != null)
             {
                 (this.UpBars as ExcelChartFormat).WriteXml(writer, mFolder, chartFile);
             }
         }
         using (writer.WriteElement("downBars", null, "c"))
         {
             if (this.DownBars != null)
             {
                 (this.DownBars as ExcelChartFormat).WriteXml(writer, mFolder, chartFile);
             }
         }
     }
 }
コード例 #27
0
        public async UniTask DownloadFile(string url, string save_path, int timeout)
        {
            XFile.DeleteIfExists(save_path);
            var req = UnityWebRequest.Get(url);

            req.timeout         = timeout;
            req.downloadHandler = new DownloadHandlerVDisk(save_path);
            await req.SendWebRequest();

            if (req.isNetworkError || req.isHttpError)
            {
                if (req.responseCode == 404)
                {
                    throw new FileNotFoundException("file not found from web :" + url, url);
                }
                else
                {
                    throw new DownloadNetworkException($"[{req.responseCode}]Failed to download file from web: {url} --> {req.error}", url, req.error, req.responseCode);
                }
            }
        }
コード例 #28
0
ファイル: DisplayUnits.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     using (writer.WriteElement("dispUnits", null, "c"))
     {
         if (this.IsCustomDisplayUnit && (this.CustomDisplayUnit > 0.0))
         {
             writer.WriteLeafElementWithAttribute("custUnit", null, "c", "val", ((double)this.CustomDisplayUnit).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         else if (this.BuiltInDisplayUnit != BuiltInDisplayUnitValue.None)
         {
             writer.WriteLeafElementWithAttribute("builtInUnit", null, "c", "val", this.BuiltInDisplayUnit.ToString().ToCamelCase());
         }
         if (((this.Layout != null) || !string.IsNullOrWhiteSpace(this.TextFormula)) || (this.RichText != null))
         {
             using (writer.WriteElement("dispUnitsLbl", null, "c"))
             {
                 if (this.Layout != null)
                 {
                     this.Layout.WriteXml(writer, mFolder, chartFile);
                 }
                 if (this.RichText != null)
                 {
                     using (writer.WriteElement("tx", null, "c"))
                     {
                         this.RichText.WriteXml(writer, mFolder, chartFile);
                         return;
                     }
                 }
                 if (!string.IsNullOrWhiteSpace(this.TextFormula))
                 {
                     writer.WriteStartElement("c", "tx", null);
                     writer.WriteStartElement("c", "strRef", null);
                     writer.WriteElementString("c", "f", null, this.TextFormula);
                     writer.WriteEndElement();
                     writer.WriteEndElement();
                 }
             }
         }
     }
 }
コード例 #29
0
ファイル: ExcelDataPoint.cs プロジェクト: Daoting/dt
 internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
 {
     foreach (XElement element in node.Elements())
     {
         if (element.Name.LocalName == "bubble3D")
         {
             this.IsBubble3D = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
         }
         else if (element.Name.LocalName == "idx")
         {
             this.Index = element.GetAttributeValueOrDefaultOfInt32Type("val", 0);
         }
         else if (element.Name.LocalName == "explosion")
         {
             this.Explosion = new int?(element.GetAttributeValueOrDefaultOfInt32Type("val", 0));
         }
         else if (element.Name.LocalName == "invertIfNegative")
         {
             this.InvertIfNegative = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
         }
         else if (element.Name.LocalName == "marker")
         {
             ExcelDataMarker marker = new ExcelDataMarker();
             marker.ReadXml(element, mFolder, xFile);
             this.Marker = marker;
         }
         else if (element.Name.LocalName == "spPr")
         {
             ExcelChartFormat format = new ExcelChartFormat();
             format.ReadXml(element, mFolder, xFile);
             this.DataPointFormat = format;
         }
         else if (element.Name.LocalName == "pictureOptions")
         {
             Dt.Xls.Chart.PictureOptions options = new Dt.Xls.Chart.PictureOptions();
             options.ReadXml(element, mFolder, xFile);
             this.PictureOptions = options;
         }
     }
 }
コード例 #30
0
ファイル: ExcelSurfaceChart.cs プロジェクト: Daoting/dt
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     if ((this.AxisX == null) || (this.AxisY == null))
     {
         throw new InvalidOperationException("Both XAxis and YAxis cannot be null");
     }
     using (writer.WriteElement("surfaceChart", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("wireframe", null, "c", "val", (this.ChartType == ExcelChartType.SurfaceViewedAboveWireFrame) ? "1" : "0");
         using (List <ExcelSurfaceSeries> .Enumerator enumerator = this.SurfaceSeries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.WriteXml(writer, mFolder, chartFile);
             }
         }
         using (writer.WriteElement("bandFmts", null, "c"))
         {
             foreach (int num in this.BandFormats)
             {
                 using (writer.WriteElement("bandFmt", null, "c"))
                 {
                     writer.WriteLeafElementWithAttribute("idx", null, "c", "val", ((int)num).ToString((IFormatProvider)CultureInfo.InvariantCulture));
                 }
             }
         }
         if (this.AxisX != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisX.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisY != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisY.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.AxisZ != null)
         {
             writer.WriteLeafElementWithAttribute("axId", null, "c", "val", ((int)this.AxisZ.Id).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
 }
コード例 #31
0
        internal void ReadXml(XElement node, MemoryFolder mFolder, XFile file)
        {
            foreach (XElement element in node.Elements())
            {
                if (element.Name.LocalName == "applyToFront")
                {
                    this.ApplyToFront = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
                }
                else if (element.Name.LocalName == "applyToEnd")
                {
                    this.ApplyToEnd = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
                }
                else if (element.Name.LocalName == "applyToSides")
                {
                    this.ApplyToSides = element.GetAttributeValueOrDefaultOfBooleanType("val", true);
                }
                else if (element.Name.LocalName == "pictureFormat")
                {
                    switch (element.GetAttributeValueOrDefaultOfStringType("val", "stretch"))
                    {
                    case "stretch":
                        this.PictureFormat = Dt.Xls.Chart.PictureFormat.Stretch;
                        break;

                    case "stack":
                        this.PictureFormat = Dt.Xls.Chart.PictureFormat.Stack;
                        break;

                    case "stackScale":
                        this.PictureFormat = Dt.Xls.Chart.PictureFormat.StackAndScale;
                        break;
                    }
                }
                else if (element.Name.LocalName == "pictureStackUnit")
                {
                    this.PictureStackUnit = element.GetAttributeValueOrDefaultOfDoubleType("val", 1.0);
                }
            }
        }
コード例 #32
0
 internal void WriteXml(XmlWriter writer, MemoryFolder mFolder, XFile chartFile)
 {
     using (writer.WriteElement("view3D", null, "c"))
     {
         writer.WriteLeafElementWithAttribute("rotX", null, "c", "val", ((double)this.RotationY).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         writer.WriteLeafElementWithAttribute("rotY", null, "c", "val", ((double)this.RotationX).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         writer.WriteLeafElementWithAttribute("rAngAx", null, "c", "val", this.RightAngleAxes ? "1" : "0");
         if (this.perspective != 15.0)
         {
             int num = (int)(perspective * 2.0);
             writer.WriteLeafElementWithAttribute("perspective", null, "c", "val", ((int)num).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.HeightPercent != 100.0)
         {
             writer.WriteLeafElementWithAttribute("hPercent", null, "c", "val", ((double)this.HeightPercent).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
         if (this.DepthPercent != 100.0)
         {
             writer.WriteLeafElementWithAttribute("depthPercent", null, "c", "val", ((double)this.DepthPercent).ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
 }