Example #1
0
        public AwardEntryViewModel(AwardEntry model, JamOverviewViewModel jamOverview) : base(model)
        {
            Candidates = ListCandidates(jamOverview);

            var currentCandidate = Candidates.Single(candidate => candidate.Entry?.Model.Id == model.JamEntry?.Id);

            EntryProperty = MutableProperty.Create(this, nameof(Entry), currentCandidate);
        }
Example #2
0
        public void TestWriteSimplePropertySet()
        {
            String AUTHOR = "Rainer Klute";
            String TITLE  = "Test Document";

            FileInfo   fi   = TempFile.CreateTempFile(POI_FS, ".doc");
            FileStream file = new FileStream(fi.FullName, FileMode.Open, FileAccess.ReadWrite);

            FileStream      out1  = file;
            POIFSFileSystem poiFs = new POIFSFileSystem();

            MutablePropertySet ps = new MutablePropertySet();
            MutableSection     si = new MutableSection();

            si.SetFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
            ps.Sections[0] = si;

            MutableProperty p = new MutableProperty();

            p.ID    = PropertyIDMap.PID_AUTHOR;
            p.Type  = Variant.VT_LPWSTR;
            p.Value = AUTHOR;
            si.SetProperty(p);
            si.SetProperty(PropertyIDMap.PID_TITLE, Variant.VT_LPSTR, TITLE);

            poiFs.CreateDocument(ps.ToInputStream(),
                                 SummaryInformation.DEFAULT_STREAM_NAME);
            poiFs.WriteFileSystem(out1);
            poiFs.Close();
            //out1.Close();
            file.Position = 0;

            POIFSReader reader1 = new POIFSReader();
            //reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded);
            POIFSReaderListener1 psl = new POIFSReaderListener1();

            reader1.RegisterListener(psl);
            reader1.Read(file);
            Assert.IsNotNull(psa[0]);
            Assert.IsTrue(psa[0].IsSummaryInformation);

            Section s  = (Section)(psa[0].Sections[0]);
            Object  p1 = s.GetProperty(PropertyIDMap.PID_AUTHOR);
            Object  p2 = s.GetProperty(PropertyIDMap.PID_TITLE);

            Assert.AreEqual(AUTHOR, p1);
            Assert.AreEqual(TITLE, p2);
            file.Close();
            try
            {
                File.Delete(fi.FullName);
            }
            catch
            {
            }
        }
Example #3
0
        public RankingOverviewViewModel(RankingOverview model)
            : base(model)
        {
            RankedEntries   = new RankedEntriesListViewModel(model.RankedEntries, rankingOverview: this);
            UnrankedEntries = new UnrankedEntriesListViewModel(model.UnrankedEntries, rankingOverview: this);

            SelectedEntryProperty = MutableProperty.Create(this, nameof(SelectedEntry), initialValue: (RankingEntryViewModel?)null)
                                    .WithDependingProperty(RankedEntries, nameof(RankedEntries.SelectedEntry))
                                    .WithDependingProperty(UnrankedEntries, nameof(UnrankedEntries.SelectedEntry));

            GetNextEntryCommand = new SimpleCommand(GetNextEntry);
        }
Example #4
0
        public RankingEntryViewModel(RankingEntry model)
            : base(model)
        {
            JamEntry = new JamEntryViewModel(model.JamEntry);

            RankProperty = MutableProperty.Create(this, nameof(Rank), (int?)null)
                           .WithDependingProperty(nameof(IsRanked));

            Ratings = model.Ratings.Select(RatingViewModel.Create).ToList();

            CommentProperty = WrapperProperty.Create(this, nameof(Comment), vm => vm.Model.Comment, (vm, value) => vm.Model.Comment = value);
        }
Example #5
0
        public void TestUnicodeWrite8Bit()
        {
            String             TITLE = "This is a sample title";
            MutablePropertySet mps   = new MutablePropertySet();
            MutableSection     ms    = (MutableSection)mps.Sections[0];

            ms.SetFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
            MutableProperty p = new MutableProperty();

            p.ID    = PropertyIDMap.PID_TITLE;
            p.Type  = Variant.VT_LPSTR;
            p.Value = TITLE;
            ms.SetProperty(p);

            Exception t = null;

            try
            {
                MemoryStream out1 = new MemoryStream();
                mps.Write(out1);
                out1.Close();
                byte[] bytes = out1.ToArray();

                PropertySet psr = new PropertySet(bytes);
                Assert.IsTrue(psr.IsSummaryInformation);
                Section sr    = (Section)psr.Sections[0];
                String  title = (String)sr.GetProperty(PropertyIDMap.PID_TITLE);
                Assert.AreEqual(TITLE, title);
            }
            catch (WritingNotSupportedException e)
            {
                t = e;
            }
            catch (IOException e)
            {
                t = e;
            }
            catch (NoPropertySetStreamException e)
            {
                t = e;
            }
            if (t != null)
            {
                Assert.Fail(t.Message);
            }
        }
Example #6
0
        public void TestGetCustomerProperties()
        {
            long   ID_1    = 2;
            long   ID_2    = 3;
            String NAME_1  = "Schlüssel";
            String VALUE_1 = "Wert 1";
            Dictionary <object, object> dictionary = new Dictionary <object, object>();

            DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            CustomProperties           cps;
            MutableSection             s;

            /* A document summary information Set stream by default does have custom properties. */
            cps = dsi.CustomProperties;
            Assert.AreEqual(null, cps);

            /* Test an empty custom properties Set. */
            s = new MutableSection();
            s.SetFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID2);
            // s.SetCodepage(CodePageUtil.CP_UNICODE);
            dsi.AddSection(s);
            cps = dsi.CustomProperties;
            Assert.AreEqual(0, cps.Count);

            /* Add a custom property. */
            MutableProperty p = new MutableProperty();

            p.ID    = ID_1;
            p.Type  = Variant.VT_LPWSTR;
            p.Value = VALUE_1;
            s.SetProperty(p);
            dictionary[ID_1] = NAME_1;
            s.Dictionary     = dictionary;
            cps = dsi.CustomProperties;
            Assert.AreEqual(1, cps.Count);
            Assert.IsTrue(cps.IsPure);

            /* Add another custom property. */
            s.SetProperty((int)ID_2, Variant.VT_LPWSTR, VALUE_1);
            dictionary[ID_2] = NAME_1;
            s.Dictionary     = dictionary;
            cps = dsi.CustomProperties;
            Assert.AreEqual(1, cps.Count);
            Assert.IsFalse(cps.IsPure);
        }
Example #7
0
 private AppViewModel(AppModel model) : base(model)
 {
     JamProperty      = MutableProperty.Create <JamOverviewViewModel>(this, nameof(Jam), default !);
Example #8
0
 /// <summary>
 /// Adds a named date property.
 /// </summary>
 /// <param name="name">The property's name.</param>
 /// <param name="value">The property's value.</param>
 /// <returns>the property that was stored under the specified name before, or
 /// <c>null</c>
 ///  if there was no such property before.</returns>
 public Object Put(String name,DateTime value)
 {
     MutableProperty p = new MutableProperty();
     p.ID=-1;
     p.Type=Variant.VT_FILETIME;
     p.Value=value;
     CustomProperty cp = new CustomProperty(p, name);
     return Put(cp);
 }
Example #9
0
 /// <summary>
 /// Adds a named bool property.
 /// </summary>
 /// <param name="name">The property's name.</param>
 /// <param name="value">The property's value.</param>
 /// <returns>the property that was stored under the specified name before, or
 /// <c>null</c>
 ///  if there was no such property before.</returns>
 public Object Put(String name, bool value)
 {
     MutableProperty p = new MutableProperty();
     p.ID=-1;
     p.Type=Variant.VT_BOOL;
     p.Value=value;
     CustomProperty cp = new CustomProperty(p, name);
     return Put(cp);
 }
Example #10
0
 /// <summary>
 /// Constructs a <c>MutableSection</c> by doing a deep copy of an
 /// existing <c>Section</c>. All nested <c>Property</c>
 /// instances, will be their mutable counterparts in the new
 /// <c>MutableSection</c>.
 /// </summary>
 /// <param name="s">The section Set To copy</param>
 public MutableSection(Section s)
 {
     SetFormatID(s.FormatID);
     Property[] pa = s.Properties;
     MutableProperty[] mpa = new MutableProperty[pa.Length];
     for (int i = 0; i < pa.Length; i++)
         mpa[i] = new MutableProperty(pa[i]);
     SetProperties(mpa);
     this.Dictionary=(s.Dictionary);
 }
Example #11
0
 /// <summary>
 /// Sets the value and the variant type of the property with the
 /// specified ID. If a property with this ID is not yet present in
 /// the section, it will be Added. An alReady present property with
 /// the specified ID will be overwritten. A default mapping will be
 /// used To choose the property's type.
 /// </summary>
 /// <param name="id">The property's ID.</param>
 /// <param name="variantType">The property's variant type.</param>
 /// <param name="value">The property's value.</param>
 public void SetProperty(int id, long variantType,
                         Object value)
 {
     MutableProperty p = new MutableProperty();
     p.ID=id;
     p.Type=variantType;
     p.Value=value;
     SetProperty(p);
     dirty = true;
 }
Example #12
0
        public AppViewModel()
        {
            DirectoryPathProperty = new MutableProperty <string>(this, nameof(DirectoryPath), string.Empty);

            GenerateJamFilesCommand = new SimpleCommand(GenerateJamFiles);
        }