예제 #1
0
        public void ComparisonTests()
        {
            var x = new Portion(0.4);
            var y = new Portion(0.4);
            var z = new Portion(0.8);

            Assert.IsTrue(x.Value == y.Value);
            Assert.IsTrue(x.Value != z.Value);

            Assert.IsTrue(x == y);
            Assert.IsFalse(x == z);
            Assert.IsFalse(y == z);

            Assert.IsFalse(x != y);
            Assert.IsTrue(x != z);
            Assert.IsTrue(y != z);

            Assert.IsTrue(z > x);
            Assert.IsFalse(z < x);
            Assert.IsFalse(x > y);
            Assert.IsTrue(x >= y);
            Assert.IsFalse(x < y);
            Assert.IsTrue(x <= y);

            Assert.AreEqual(0, x.CompareTo(y));
            Assert.IsTrue(x.CompareTo(z) < 0);
            Assert.IsTrue(z.CompareTo(y) > 0);
        }
예제 #2
0
 public override void Progress(Portion progress)
 {
     foreach (var output in outputs)
     {
         output.Progress(progress);
     }
 }
예제 #3
0
        public void Init()
        {
            // initialise the portion object.
            _food = new Food
            {
                PortionID     = 1,
                Name          = "TestFood",
                KiloCalories  = 100,
                Carbohydrate  = 1,
                Protein       = 20,
                Fat           = 1,
                Sugar         = 0,
                Salt          = 0,
                Saturates     = 0,
                BaseUnit      = 20,
                MeasuringUnit = 1,
            };

            _portion = new Portion()
            {
                Name      = "TestPortion",
                PortionID = 1337,
                Foods     = new List <Food>()
                {
                    _food
                }
            };
        }
예제 #4
0
        public void TestClasses()
        {
            for (int i = 0; i < shelfsize; i++)
            {
                _bottleshelf.Add(new Bottle("Bottle" + i));
                Assert.AreEqual(_bottleshelf.Count, i + 1, "Bottle" + i);
            }
            for (int i = 0; i < shelfsize; i++)
            {
                _drinkdb.Add(new Drink("Testdrink" + i));
                for (var index = 0; index < _bottleshelf.Count; index++)
                {
                    if (index < 3)
                    {
                        Bottle t = _bottleshelf[index];
                        _drinkdb[i].AddPortion(t.Name, i);
                    }
                    else
                    {
                        Portion newPortion = new Portion(_bottleshelf[index].Name, i);
                        _drinkdb[i].AddPortion(newPortion);
                    }
                }
            }

            for (var i = 0; i < _bottleshelf.Count; ++i)
            {
                Assert.AreEqual(_drinkdb[i].Name, "Testdrink" + i, $"Drinkname {_drinkdb[i].Name}");
                for (int j = 0; j < _bottleshelf.Count; j++)
                {
                    Assert.AreEqual(_drinkdb[i].Portions()[j].Name, _bottleshelf[j].Name, $"Bottlename {_bottleshelf[j].Name}");
                    Assert.AreEqual(_drinkdb[i].Portions()[j].Amount, i, $"BottleAmount {_bottleshelf[j].Name}");
                }
            }
        }
예제 #5
0
 internal CacheBaseline(Portion cost, int pulseCount, TimeSpan impact, long queryCount)
 {
     this.cost       = cost;
     this.pulseCount = pulseCount;
     this.impact     = impact;
     this.queryCount = queryCount;
 }
예제 #6
0
파일: Player.cs 프로젝트: SeaPHY/phy_game01
    /// <summary>
    /// 액티브 아이템 사용
    /// </summary>
    /// <param name="item"></param>
    /// <returns>아이템 사용하면 null 반환 </returns>
    public Item ActiveItem(Item item)
    {
        Item retunItem = item;

        if (item is Portion)
        {
            Portion portion = item as Portion;

            if (portion.HpPoint != 0 || portion.HpPercent != 0)
            {
                Health    = (int)Mathf.Lerp(health, maxHealth, health + portion.HpPoint + maxHealth * (float)portion.HpPercent);
                retunItem = null;
            }

            if (portion.MpPoint != 0 || portion.MpPercent != 0)
            {
                playerMagic.MagicPoint = (int)Mathf.Lerp(playerMagic.magicPoint, playerMagic.maxMagicPoint,
                                                         playerMagic.magicPoint + portion.HpPoint + playerMagic.maxMagicPoint * (float)portion.MpPercent);
                retunItem = null;
            }
        }
        else if (item is Scroll)
        {
            retunItem = null;
        }

        return(retunItem);
    }
예제 #7
0
 public EditBasket(Warehouse warehouse, Portion portion, BindingSource portionBindingSource) : base(warehouse, portion.Product, portionBindingSource)
 {
     InitializeComponent();
     textLabel.Text            = "Edit product";
     this.portion              = portion;
     amountNumericUpDown.Value = (decimal)portion.Amount;
 }
예제 #8
0
        private static Portion getCostBaseline(long globalCost, Func <CacheHitInfo, CacheStats> getStats)
        {
            var cumulativeCost = 0L;
            var cacheCount     = 0;
            var _90pct         = Portion.Ratio(9, 10);
            var threshold      = globalCost * _90pct;

            var costs = from cache in Nrdo.GetCacheHitInfoUnsorted()
                        let cost = getStats(cache).CumulativeCost
                                   orderby cost descending
                                   select cost;

            foreach (var cost in costs)
            {
                cacheCount++;
                cumulativeCost += cost;
                if (cumulativeCost >= threshold)
                {
                    return(Portion.Ratio(cumulativeCost, cacheCount));
                }
            }

            // The only way we should be able to get to here is if there aren't any caches at all, but just in case, we define the threshold as equal to 90% of
            // the global cost in that case.
            return(threshold);
        }
예제 #9
0
    protected void SetAnchors(Portion p, Vector2 minAnchor, Vector2 maxAnchor,
                              float startPercent, float endPercent, Pivot alignment)
    {
        if (p == null)
        {
            return;
        }
        startPercent = Mathf.Clamp01(startPercent);
        endPercent   = Mathf.Clamp01(endPercent);

        switch (alignment)
        {
        case Pivot.Top:
        case Pivot.Right:
            float s = 1f - endPercent;
            float e = 1f - startPercent;

            startPercent = s;
            endPercent   = e;
            break;
        }

        p.rTrans.anchorMin = GetAnchor(minAnchor, startPercent, orientation);
        p.rTrans.anchorMax = GetAnchor(maxAnchor, endPercent, orientation);

        //p.rTrans.sizeDelta = Vector2.zero;
        //p.rTrans.anchoredPosition = Vector2.zero;
    }
        public void UpdateSubshapePortion()
        {
            Portion dto = new Portion()
            {
                Text       = c_newPortionText,
                FontBold   = Portion.FontBoldEnum.True,
                FontHeight = 20,
                LatinFont  = c_fontName,
                FillFormat = new SolidFill()
                {
                    Color = c_fontColor
                }
            };

            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Portion response = TestUtils.SlidesApi.UpdateSubshapePortion(c_fileName, c_slideIndex, c_shapePath,
                                                                         c_shapeIndex, 1,
                                                                         1, dto, c_password, c_folderName);

            Assert.AreEqual(dto.Text, response.Text);
            Assert.AreEqual(dto.FontBold, response.FontBold);
            Assert.AreEqual(dto.FontHeight, response.FontHeight);
            Assert.AreEqual(dto.LatinFont, c_fontName);
            Assert.IsInstanceOf <SolidFill>(response.FillFormat);
        }
예제 #11
0
 public ChooseItem(Portion portion) : this(new List <Item>() { portion.Item })
 {
     Portion               = portion;
     AmountUpDown.Value    = portion.Amount;
     SearchItemBox.Visible = false;
     inedit = true;
 }
예제 #12
0
        unsafe string GetUrl(int index, int mouseX)
        {
            mouseX -= Textures[index].X1;
            DrawTextArgs args = default(DrawTextArgs); args.UseShadow = true;
            string       text = lines[index];

            if (game.ClassicMode)
            {
                return(null);
            }

            char *   chars         = stackalloc char[lines.Length * 96];
            Portion *portions      = stackalloc Portion[(96 / httpLen) * 2];
            int      portionsCount = Reduce(chars, index, portions);

            for (int i = 0, x = 0; i < portionsCount; i++)
            {
                Portion bit = portions[i];
                args.Text = text.Substring(bit.LineBeg, bit.LineLen);
                args.Font = (bit.Len & 0x8000) == 0 ? font : underlineFont;

                int width = game.Drawer2D.MeasureText(ref args).Width;
                if (args.Font != font && mouseX >= x && mouseX < x + width)
                {
                    string url = new string(chars, bit.Beg, bit.Len & 0x7FFF);
                    // replace multiline bits
                    return(Utils.StripColours(url).Replace("> ", ""));
                }
                x += width;
            }
            return(null);
        }
예제 #13
0
        Data PrepareData(Portion portion, Project project)
        {
            Data data = new Data();

            data.Pipes      = new List <PipeObject>();
            data.Joints     = new List <JointObject>();
            data.Components = new List <ComponentObject>();
            data.Project    = project;

            foreach (var pipe in portion.Pipes)
            {
                data.Pipes.Add(new PipeObject(pipe));
            }

            foreach (var joint in portion.Joints)
            {
                data.Joints.Add(new JointObject(joint));
            }

            foreach (var component in portion.Components)
            {
                data.Components.Add(new ComponentObject(component));
            }

            return(data);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create an instance of Presentation class
            Presentation presentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            IChart chart = slide.Shapes.AddChart(ChartType.StackedColumn, 20, 20, 400, 400);
            IChartSeries series = chart.ChartData.Series[0];
            IChartCategory cat;
          
            double[] total_for_Cat = new double[chart.ChartData.Categories.Count];

            for (int k = 0; k < chart.ChartData.Categories.Count; k++)
            {
                cat = chart.ChartData.Categories[k];

                for (int i = 0; i < chart.ChartData.Series.Count; i++)
                {
                    total_for_Cat[k] = total_for_Cat[k] + Convert.ToDouble(chart.ChartData.Series[i].DataPoints[k].Value.Data);
                }
            }

            double dataPontPercent = 0f;

            for (int x = 0; x < chart.ChartData.Series.Count; x++)
            {
                series = chart.ChartData.Series[x];
                series.Labels.DefaultDataLabelFormat.ShowLegendKey = false;

                for (int j = 0; j < series.DataPoints.Count; j++)
                {
                    IDataLabel lbl = series.DataPoints[j].Label;
                    dataPontPercent = (Convert.ToDouble(series.DataPoints[j].Value.Data) / total_for_Cat[j]) * 100;

                    IPortion port = new Portion();
                    port.Text = String.Format("{0:F2} %", dataPontPercent);
                    port.PortionFormat.FontHeight = 8f;
                    lbl.TextFrameForOverriding.Text = "";
                    IParagraph para = lbl.TextFrameForOverriding.Paragraphs[0];
                    para.Portions.Add(port);

                    lbl.DataLabelFormat.ShowSeriesName = false;
                    lbl.DataLabelFormat.ShowPercentage = false;
                    lbl.DataLabelFormat.ShowLegendKey = false;
                    lbl.DataLabelFormat.ShowCategoryName = false;
                    lbl.DataLabelFormat.ShowBubbleSize = false;

                }

            }

            // Save presentation with chart
            presentation.Save(dataDir + "DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx);

        }
예제 #15
0
 private void UnmarkComponents(Portion portion)
 {
     foreach (var c in portion.Components)
     {
         c.ToExport = false;
         exportRepo.ComponentRepo.SaveOrUpdate(c);
     }
 }
        public void GetSubshapePortion()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Portion response = TestUtils.SlidesApi.GetSubshapePortion(c_fileName, c_slideIndex, c_shapePath, 1,
                                                                      c_paragraphIndex, c_portionIndex, c_password, c_folderName);

            Assert.IsTrue(response.Text.Contains(c_portionText));
        }
예제 #17
0
    public Portion GetPortion(string name)
    {
        Portion p = portions.Find(x =>
                                  x.name == name
                                  );

        return(p);
    }
예제 #18
0
 private void UnmarkJoints(Portion portion)
 {
     foreach (var j in portion.Joints)
     {
         j.ToExport = false;
         exportRepo.JointRepo.SaveOrUpdate(j);
     }
 }
예제 #19
0
        public void CastTest()
        {
            var p     = new Portion(0.4);
            var angle = new Angle(0.4, AngleUnit.Turns);

            Assert.AreEqual(angle, (Angle)p);
            Assert.AreEqual(p, (Portion)angle);
        }
예제 #20
0
        public void MathGetNull()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Portion portion = TestUtils.SlidesApi.GetPortion(
                c_fileName, c_slideIndex, c_notMathShapeIndex, c_paragraphIndex, c_portionIndex, c_password, c_folderName);

            Assert.IsNull(portion.MathParagraph);
        }
예제 #21
0
 private void UnmarkPipes(Portion portion)
 {
     foreach (var p in portion.Pipes)
     {
         p.ToExport = false;
         exportRepo.PipeRepo.SaveOrUpdate(p);
     }
 }
예제 #22
0
 protected void SetPivot(Portion p, Pivot a)
 {
     if (p == null)
     {
         return;
     }
     p.rTrans.pivot = GetPivot(a);
 }
예제 #23
0
        /// <inheritdoc/>
        public void Remove(IPortion removingPortion)
        {
            Portion removingInnerPortion = (Portion)removingPortion;

            removingInnerPortion.AText.Parent.Remove(); // remove parent <a:r>
            removingInnerPortion.IsRemoved = true;

            this.portions.Reset();
        }
예제 #24
0
        private void btnReexport_Click(object sender, EventArgs e)
        {
            Portion portion = gridViewHistory.GetFocusedRow() as Portion;

            if (portion != null)
            {
                DoExport(portion);
            }
        }
예제 #25
0
 internal SCFont(A.Text aText, Portion portion)
 {
     this.aText       = aText;
     this.size        = new ResettableLazy <int>(this.GetSize);
     this.latinFont   = new ResettableLazy <A.LatinFont>(this.GetALatinFont);
     this.colorFormat = new Lazy <ColorFormat>(() => new ColorFormat(this));
     this.Portion     = portion;
     this.aFontScheme = ((Shape)portion.ParentParagraph.ParentTextBox.ParentTextBoxContainer).ThemePart.Theme.ThemeElements.FontScheme;
 }
예제 #26
0
        public void HyperlinkGetPortion()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Portion portion = TestUtils.SlidesApi.GetPortion(c_fileName, c_slideIndex, c_hoverShapeIndex, c_paragraphIndex, c_portionIndex, c_password, c_folderName);

            Assert.IsNull(portion.HyperlinkClick);
            Assert.IsNotNull(portion.HyperlinkMouseOver);
            Assert.AreEqual(Hyperlink.ActionTypeEnum.JumpLastSlide, portion.HyperlinkMouseOver.ActionType);
        }
예제 #27
0
        public void MathCreate()
        {
            const int slideIndex = 1;
            const int shapeIndex = 1;

            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            Portion dto = new Portion
            {
                MathParagraph = new MathParagraph
                {
                    MathBlockList = new List <BlockElement>
                    {
                        new BlockElement
                        {
                            MathElementList = new List <MathElement>
                            {
                                new FunctionElement
                                {
                                    Name = new LimitElement {
                                        Base = new TextElement {
                                            Value = "lim"
                                        }, Limit = new TextElement {
                                            Value = "x->0"
                                        }
                                    },
                                    Base = new FractionElement
                                    {
                                        Numerator = new FunctionElement {
                                            Name = new TextElement {
                                                Value = "sin"
                                            }, Base = new TextElement {
                                                Value = "x"
                                            }
                                        },
                                        Denominator = new TextElement {
                                            Value = "x"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            Portion portion = TestUtils.SlidesApi.CreatePortion(
                c_fileName, slideIndex, shapeIndex, c_paragraphIndex, dto, password: c_password, folder: c_folderName);

            Assert.IsNotNull(portion.MathParagraph);
            portion = TestUtils.SlidesApi.GetPortion(c_fileName, slideIndex, shapeIndex, c_paragraphIndex, 2, c_password, c_folderName);
            Assert.IsNotNull(portion.MathParagraph);
            Assert.IsNotNull(portion.MathParagraph.MathBlockList);
            Assert.AreEqual(1, portion.MathParagraph.MathBlockList.Count);
            Assert.IsNotNull(portion.MathParagraph.MathBlockList[0].MathElementList);
            Assert.AreEqual(1, portion.MathParagraph.MathBlockList[0].MathElementList.Count);
            Assert.IsInstanceOf <FunctionElement>(portion.MathParagraph.MathBlockList[0].MathElementList[0]);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create an instance of Presentation class
            Presentation presentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            IChart         chart  = slide.Shapes.AddChart(ChartType.StackedColumn, 20, 20, 400, 400);
            IChartSeries   series = chart.ChartData.Series[0];
            IChartCategory cat;

            double[] total_for_Cat = new double[chart.ChartData.Categories.Count];

            for (int k = 0; k < chart.ChartData.Categories.Count; k++)
            {
                cat = chart.ChartData.Categories[k];

                for (int i = 0; i < chart.ChartData.Series.Count; i++)
                {
                    total_for_Cat[k] = total_for_Cat[k] + Convert.ToDouble(chart.ChartData.Series[i].DataPoints[k].Value.Data);
                }
            }

            double dataPontPercent = 0f;

            for (int x = 0; x < chart.ChartData.Series.Count; x++)
            {
                series = chart.ChartData.Series[x];
                series.Labels.DefaultDataLabelFormat.ShowLegendKey = false;

                for (int j = 0; j < series.DataPoints.Count; j++)
                {
                    IDataLabel lbl = series.DataPoints[j].Label;
                    dataPontPercent = (Convert.ToDouble(series.DataPoints[j].Value.Data) / total_for_Cat[j]) * 100;

                    IPortion port = new Portion();
                    port.Text = String.Format("{0:F2} %", dataPontPercent);
                    port.PortionFormat.FontHeight   = 8f;
                    lbl.TextFrameForOverriding.Text = "";
                    IParagraph para = lbl.TextFrameForOverriding.Paragraphs[0];
                    para.Portions.Add(port);

                    lbl.DataLabelFormat.ShowSeriesName   = false;
                    lbl.DataLabelFormat.ShowPercentage   = false;
                    lbl.DataLabelFormat.ShowLegendKey    = false;
                    lbl.DataLabelFormat.ShowCategoryName = false;
                    lbl.DataLabelFormat.ShowBubbleSize   = false;
                }
            }

            // Save presentation with chart
            presentation.Save(dataDir + "DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx);
        }
예제 #29
0
        private void AddToBasket(Portion portion, DataGridView table)
        {
            Font font1 = new Font("Microsoft Sans Serif", 15);
            Font font2 = new Font("Microsoft Sans Serif", 10);

            table.Rows.Add(portion.Item.Image, portion.Item.Name, portion.Item.Price[portion.Item.Price.Count - 1]);
            table.Rows[table.Rows.Count - 1].Height = (int)(((double)70 / (double)424) * ItemsGridView.Height);
            table.Rows[table.Rows.Count - 1].Cells[1].Style.Font = font1;
            table.Rows[table.Rows.Count - 1].Cells[2].Style.Font = font2;
        }
예제 #30
0
        // Метод для вывода дополнительной информации.
        private void GetInfo()
        {
            Portion portion = (Portion)portionBindingSource.Current;

            nameTextBox.Text          = portion.Product.Name;
            idNumericUpDown.Value     = portion.Product.Id;
            unitTextBox.Text          = portion.Product.Unit;
            priceNumericUpDown.Value  = portion.Product.Price;
            amountNumericUpDown.Value = (decimal)portion.Amount;
        }
예제 #31
0
    public float GetValue(string name)
    {
        Portion p = GetPortion(name);

        if (p == null)
        {
            return(0f);
        }
        return(p.Value);
    }
예제 #32
0
      void DoExport(Portion portion = null)
      {
         exportTabs.SelectedTabPage = logTabPage;
         log.Clear();

         if (portion == null && !exporter.AnyNewDataToExport())
         {
            exporter_OnMessage(Program.LanguageManager.GetString(StringResources.Export_NoData));
            return;
         }

         SaveFileDialog dlg = new SaveFileDialog();
         dlg.Filter = Program.LanguageManager.GetString(StringResources.Export_Filter) + Resources.prizm;

         if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            return;

         exporter.ArchiveName = dlg.FileName;

         exporter.OnMessage -= exporter_OnMessage;
         exporter.OnDone -= exporter_OnDone;
         exporter.OnError -= exporter_OnError;

         exporter.OnMessage += exporter_OnMessage;
         exporter.OnDone += exporter_OnDone;
         exporter.OnError += exporter_OnError;

         progressPanel.Visible = true;

         Task task = portion == null ? new Task(() => exporter.Export()) : new Task(() => exporter.Export(portion));
         task.ContinueWith((_) => {
            if (progressPanel.InvokeRequired)
            {
               progressPanel.Invoke(new MethodInvoker(() => { progressPanel.Visible = false; }));
            }
            else
            {
               progressPanel.Visible = false;
            }
            
            LoadPortions();
         });
         task.Start();
      }
예제 #33
0
        Data PrepareData(Portion portion, Project project)
        {
            Data data = new Data();
            data.Pipes = new List<PipeObject>();
            data.Joints = new List<JointObject>();
            data.Components = new List<ComponentObject>();
            data.Project = project;

            foreach(var pipe in portion.Pipes)
            {
                data.Pipes.Add(new PipeObject(pipe));
            }

            foreach(var joint in portion.Joints)
            {
                data.Joints.Add(new JointObject(joint));
            }

            foreach(var component in portion.Components)
            {
                data.Components.Add(new ComponentObject(component));
            }

            return data;
        }
예제 #34
0
 private void UnmarkPipes(Portion portion)
 {
     foreach(var p in portion.Pipes)
     {
         p.ToExport = false;
         exportRepo.PipeRepo.SaveOrUpdate(p);
     }
 }
예제 #35
0
 private void UnmarkJoints(Portion portion)
 {
     foreach(var j in portion.Joints)
     {
         j.ToExport = false;
         exportRepo.JointRepo.SaveOrUpdate(j);
     }
 }
예제 #36
0
 private void UnmarkComponents(Portion portion)
 {
     foreach(var c in portion.Components)
     {
         c.ToExport = false;
         exportRepo.ComponentRepo.SaveOrUpdate(c);
     }
 }
예제 #37
0
        public override ExportResult Export()
        {
            IList<Pipe> pipesToExport = new List<Pipe>();
            IList<Joint> jointsToExport = new List<Joint>();
            IList<Component> componentsToExport = new List<Component>();
            try
            {
                pipesToExport = exportRepo.PipeRepo.GetPipesToExport();
                jointsToExport = exportRepo.JointRepo.GetJointsToExport();
                componentsToExport = exportRepo.ComponentRepo.GetComponentsToExport();
            }
            catch(RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
            }

            exportRepo.PortionRepo.BeginTransaction();

            Portion portion = new Portion()
            {
                ExportDateTime = DateTime.Now,
                IsExport = true,
                PortionNumber = exportRepo.PortionRepo.GetPortionNumber(exportRepo.ProjectRepo.GetSingle()),
                Project = exportRepo.ProjectRepo.GetSingle()
            };

            foreach(var pipe in pipesToExport)
            {
                portion.Pipes.Add(pipe);
            }

            foreach(var joint in jointsToExport)
            {
                portion.Joints.Add(joint);
            }

            foreach(var component in componentsToExport)
            {
                portion.Components.Add(component);
            }

            exportRepo.PortionRepo.SaveOrUpdate(portion);
            exportRepo.PortionRepo.Commit();

            return Export(portion);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            // Instantiate a Presentation class that represents a PPTX file
            using (Presentation pres = new Presentation())
            {
                // Accessing first slide
                ISlide slide = pres.Slides[0];

                // Add an AutoShape of Rectangle type
                IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 300, 150);

                // Access TextFrame of the AutoShape
                ITextFrame tf = ashp.TextFrame;

                // Create Paragraphs and Portions with different text formats
                IParagraph para0 = tf.Paragraphs[0];
                IPortion port01 = new Portion();
                IPortion port02 = new Portion();
                para0.Portions.Add(port01);
                para0.Portions.Add(port02);

                IParagraph para1 = new Paragraph();
                tf.Paragraphs.Add(para1);
                IPortion port10 = new Portion();
                IPortion port11 = new Portion();
                IPortion port12 = new Portion();
                para1.Portions.Add(port10);
                para1.Portions.Add(port11);
                para1.Portions.Add(port12);

                IParagraph para2 = new Paragraph();
                tf.Paragraphs.Add(para2);
                IPortion port20 = new Portion();
                IPortion port21 = new Portion();
                IPortion port22 = new Portion();
                para2.Portions.Add(port20);
                para2.Portions.Add(port21);
                para2.Portions.Add(port22);

                for (int i = 0; i < 3; i++)
                    for (int j = 0; j < 3; j++)
                    {
                        tf.Paragraphs[i].Portions[j].Text = "Portion0" + j.ToString();
                        if (j == 0)
                        {
                            tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.FillType = FillType.Solid;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FontBold = NullableBool.True;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FontHeight = 15;
                        }
                        else if (j == 1)
                        {
                            tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.FillType = FillType.Solid;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FontItalic = NullableBool.True;
                            tf.Paragraphs[i].Portions[j].PortionFormat.FontHeight = 18;
                        }
                    }

                //Write PPTX to Disk
                pres.Save(dataDir + "multiParaPort_out.pptx", SaveFormat.Pptx);
            }

        }
예제 #39
0
        public override ExportResult Export(Portion portion)
        {
            try
            {
                FireMessage(Program.LanguageManager.GetString(StringResources.Export_ReadingData));

                Project project = exportRepo.ProjectRepo.GetSingle();
                Data data = PrepareData(portion, project);

                FireMessage(Program.LanguageManager.GetString(StringResources.Export_CreateTempStorage));

                string tempDir = CreateTempDir();

                FireMessage(Program.LanguageManager.GetString(StringResources.Export_WritingData));

                WriteManifest(tempDir, portion.Id, portion.PortionNumber, portion.ExportDateTime, project.WorkstationType);

                WriteData<Data>(tempDir, data);

                WriteAttachments(tempDir, data);

                FireMessage(Program.LanguageManager.GetString(StringResources.Export_CreatingArchive));

                ZipContent(tempDir);

                exportRepo.PipeRepo.BeginTransaction();

                UnmarkPipes(portion);
                UnmarkJoints(portion);
                UnmarkComponents(portion);

                exportRepo.PipeRepo.Commit();

                this.ExportedElementCount = portion.Pipes.Count + portion.Components.Count + portion.Joints.Count;

                FireDone();

                return ExportResult.Success;
            }
            catch(Exception e)
            {
                return FireError(e);
            }
        }