示例#1
0
        public async Task <Unit> Handle(CreateHeadlineCommand request, CancellationToken cancellationToken)
        {
            var currentUserId = Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value);

            var entity = new Headline
            {
                ProjectId = request.ProjectId
            };

            entity.CreateEnd(request.Id, request.Title, currentUserId);

            await _context.WikiHeadlines.AddAsync(entity, cancellationToken);

            if (!string.IsNullOrEmpty(request.SectionBody) || !string.IsNullOrEmpty(request.SectionName))
            {
                var section = new Section
                {
                    HeadlineId = entity.Id,
                    Content    = request.SectionBody
                };

                section.CreateEnd(Guid.NewGuid(), request.SectionName, currentUserId);

                await _context.Sections.AddAsync(section, cancellationToken);
            }

            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
示例#2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            new JProperty("headline", Headline.ToJSON()),
            new JProperty("text", Text.ToJSON()),

            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              )),

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
示例#3
0
 /// <summary>
 /// 删除头条
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool delItem(int id)
 {
     try
     {
         using (var db = new huxiuEntities())
         {
             Headline delHead = db.Headline.SingleOrDefault(a => a.Id == id);
             if (!delHead.HisDisplay)            //如果删除队列中的项目,队列数量减一
             {
                 queueSize--;
             }
             else if (displayCount <= 4)         //最少头条保留4条
             {
                 return(false);
             }
             db.Headline.Remove(delHead);
             db.SaveChanges();
         }
         displayCount--;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (searchTerm_ != null)
            {
                hash ^= SearchTerm.GetHashCode();
            }
            if (headline_ != null)
            {
                hash ^= Headline.GetHashCode();
            }
            if (landingPage_ != null)
            {
                hash ^= LandingPage.GetHashCode();
            }
            if (pageUrl_ != null)
            {
                hash ^= PageUrl.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#5
0
        public async Task <IActionResult> Put(int headlineId, Headline model)
        {
            try
            {
                var headlineTarget = await _repository.GetHeadlineByIdAsync(headlineId, false);

                if (headlineTarget == null)
                {
                    return(NotFound());
                }

                _repository.Update(model);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/headline/{model.HeadlineId}", model));
                }
            }
            catch (SystemException)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database access failed"));
            }

            return(BadRequest());
        }
示例#6
0
        /// <summary>
        /// process headline click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RssViewer_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Headline item = (Headline)VisualHelper.GetObjectAtPoint <ListBoxItem>((ItemsControl)sender, e.GetPosition((IInputElement)sender));

            if (item != null)
            {
                ProcessHelper.LaunchShellUri(new Uri(item.LinkUri));
            }
        }
        public NewsDetailsView(Headline item)
        {
            BindingContext = item;
            var webView = new WebView();

            webView.Source = new UrlWebViewSource {
                Url = item.Url
            };
            Content = webView;
        }
示例#8
0
        private void SeedHeadlines()
        {
            IEnumerable <HeadlineInfo> headlineInfos = GetHeadlineInfos();

            foreach (var info in headlineInfos)
            {
                Headline headline = CreateHeadline(info);
                _dbContext.Add(headline);
            }

            _dbContext.SaveChanges();
        }
示例#9
0
        public IEnumerable <Doc> Mock20Articles()
        {
            List <Doc> allArticles = new List <Doc>();
            //headline
            var    kicker         = "kicker";
            var    content_kicker = "content_kicker";
            var    print_headline = "print_headline";
            object name           = new Object();
            object seo            = new Object();
            object sub            = new Object();

            var web_url  = "weburl";
            var snippet  = "snippet";
            var main     = "main";
            var headline = new Headline(kicker, content_kicker, print_headline, name, seo, sub);
            var pub_date = new DateTime(2016 - 09 - 02);
            var score    = 2.5;

            var doc1  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc2  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc3  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc4  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc5  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc6  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc7  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc8  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc9  = new Doc(web_url, snippet, headline, pub_date, score);
            var doc10 = new Doc(web_url, snippet, headline, pub_date, score);
            var doc11 = new Doc(web_url, snippet, headline, pub_date, score);
            var doc12 = new Doc(web_url, snippet, headline, pub_date, score);
            var doc13 = new Doc(web_url, snippet, headline, pub_date, score);
            var doc14 = new Doc(web_url, snippet, headline, pub_date, score);
            var doc15 = new Doc(web_url, snippet, headline, pub_date, score);

            allArticles.Add(doc1);
            allArticles.Add(doc2);
            allArticles.Add(doc3);
            allArticles.Add(doc4);
            allArticles.Add(doc5);
            allArticles.Add(doc6);
            allArticles.Add(doc7);
            allArticles.Add(doc8);
            allArticles.Add(doc9);
            allArticles.Add(doc10);
            allArticles.Add(doc11);
            allArticles.Add(doc12);
            allArticles.Add(doc13);
            allArticles.Add(doc14);
            allArticles.Add(doc15);

            return(allArticles);
        }
        /// <summary>
        /// Gets the data from IANA.
        /// </summary>
        /// <returns>The amount of loaded TLDs.</returns>
        private static int GetDataFromIANA()
        {
            int           result = 0;
            DateTime      start  = DateTime.Now;
            DateTime      end;
            IRestRequest  request  = new RestRequest(Path, Method.GET, DataFormat.None);
            IRestResponse response = RestClient.Execute(request);

            string[]  lines       = null;
            IHeadline oldHeadline = LastAnswer;

            LastResponseStatus = response.ResponseStatus;

            if (response.ResponseStatus == ResponseStatus.Completed ||
                response.ResponseStatus == ResponseStatus.None)
            {
                lines = response.Content.Split('\n');
            }

            if (lines != null && lines.Length > 1)
            {
                result     = lines.Length;
                LastAnswer = new Headline(lines[0].Trim());

                if (oldHeadline != null && !LastAnswer.Version.Equals(oldHeadline.Version))
                {
                    // the whole idea with reload is nice - but if there was no
                    // change, it isn't needes...

                    TLDs.Clear();

                    for (int i = 1; i < lines.Length; i++)
                    {
                        TLDs.Add(lines[i].Trim());
                    }
                }
                else if (oldHeadline == null)
                {
                    for (int i = 1; i < lines.Length; i++)
                    {
                        TLDs.Add(lines[i].Trim());
                    }
                }
            }

            end            = DateTime.Now;
            LastReloadTime = end.Subtract(start);
            Reloads++;

            return(result);
        }
        private static Headline readHeadlineFromDB(IDataRecord reader)
        {
            int id = reader.GetInt32(0);
            string title = reader.GetString(1);
            string descriptions = reader.GetString(2);

            Headline headline = new Headline
            {
                ID = id,
                Title = title,
                Descriptions = descriptions

            };
            return headline;
        }
示例#12
0
    private void OnUpdatedHeadline()
    {
        int    index = random.Next(0, PrototypeManager.Headline.Count + headlinesQueue.Count);
        string text;

        if (index > PrototypeManager.Headline.Count)
        {
            Headline headline = headlinesQueue.Dequeue();
            text = headline.Text;
        }
        else
        {
            text = PrototypeManager.Headline[index].Text;
        }

        OnUpdatedHeadline(text);
    }
示例#13
0
        public async Task <IActionResult> Post(Headline model)
        {
            try
            {
                _repository.Add(model);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/headline/{model.HeadlineId}", model));
                }
            }
            catch (SystemException)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database access failed"));
            }

            return(BadRequest());
        }
        private void DrawRequest()
        {
            Console.Clear();
            Console.WriteLine(" - " + Headline.ToUpper() + " - \r\n");
            Console.WriteLine(SelectionMessage);
            int writecounter = 0;

            foreach (string s in options)
            {
                if (writecounter == selector)
                {
                    Console.BackgroundColor = ConsoleColor.DarkCyan;
                }
                Console.WriteLine(s);
                Console.BackgroundColor = default;
                writecounter++;
            }
            Console.WriteLine(numberInput);
        }
示例#15
0
 public ActionResult editTags(Headline.ViewModels.editTagsViewModel model, string id)
 {
     ViewBag.Title = "Edit Tags: " + id;
     if (id == "" || id == null)
     {
         ViewBag.notify = "You can only edit by selecting these tags below";
         return View("viewTags");
     }
     int countTagExists = (from ts in user.tags
                           where ts.tagText == id
                           select ts).Count();
     if (countTagExists == 0)
     {
         ViewBag.notify = "Your tag "+ id + " cannot be found, select from the list below. Others are added at the headline level";
         return View("viewTags");
     }
     var idtouse = id;
     return View("editTags", model);
 }
示例#16
0
        /// <summary>
        /// Alle Überschriften in einem xhtml- dokument finden, und die
        /// Positonen in einer Liste aus Headlines beschreiben
        /// </summary>
        /// <param name="xthmlStream"></param>
        /// <returns></returns>
        public static List <Headline> filterHeader(string xhtml)
        {
            List <Headline> hls = new List <Headline>();

            xhtml = "<body>" + xhtml + "</body>";

            System.IO.StringReader str = new StringReader(xhtml);
            XmlReader reader           = XmlReader.Create(str);
            XElement  doc = XElement.Load(reader, LoadOptions.SetLineInfo);

            // Finden aller Headlines
            var headlines = doc.Elements().Where(e => System.Text.RegularExpressions.Regex.IsMatch(e.Name.LocalName, @"h\d"));

            foreach (var h in headlines)
            {
                string       anchor   = "";
                long         line     = 0;
                IXmlLineInfo lineInfo = h;
                line = lineInfo.LineNumber;

                if (h.Element(XName.Get("a")) != null)
                {
                    XElement a = h.Element(XName.Get("a"));
                    XName    n = XName.Get("id");
                    if (a.Name.LocalName == "a" && !string.IsNullOrEmpty(a.Attribute(n).Value))
                    {
                        anchor = a.Attribute(n).Value;
                    }
                }
                Headline hl = new Headline
                {
                    Anchor = anchor,
                    Level  = int.Parse(h.Name.LocalName[1].ToString()),
                    Line   = line,
                    Text   = h.Value
                };

                hls.Add(hl);
            }

            return(hls);
        }
示例#17
0
 /// <summary>
 /// 添加一条头条
 /// </summary>
 /// <param name="hId"></param>
 /// <param name="showTime"></param>
 /// <returns></returns>
 public bool addItem(int hId, string showTime)
 {
     if (!isExpire(showTime))
     {
         try
         {
             using (var db = new huxiuEntities())
             {
                 //是否重复
                 Headline isRpt = db.Headline.SingleOrDefault(a => a.HId == hId);
                 if (isRpt != null)
                 {
                     return(false);
                 }
                 //添加新头条
                 Passage pasInfo = db.Passage.SingleOrDefault(a => a.PassageId == hId && a.IsDel == false);
                 if (pasInfo == null)
                 {
                     return(false);
                 }
                 Headline headSave = new Headline();
                 headSave.HId        = hId;
                 headSave.Htitle     = pasInfo.PassageTitle;
                 headSave.Himg       = pasInfo.PassageImage;
                 headSave.Hdeadline  = showTime;
                 headSave.HisDisplay = false;
                 db.Headline.Add(headSave);
                 db.SaveChanges();
             }
             queueSize++;
             return(true);
         }
         catch
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (ResourceName.Length != 0)
            {
                hash ^= ResourceName.GetHashCode();
            }
            if (HasSearchTerm)
            {
                hash ^= SearchTerm.GetHashCode();
            }
            if (HasHeadline)
            {
                hash ^= Headline.GetHashCode();
            }
            if (HasLandingPage)
            {
                hash ^= LandingPage.GetHashCode();
            }
            if (HasPageUrl)
            {
                hash ^= PageUrl.GetHashCode();
            }
            if (HasHasNegativeKeyword)
            {
                hash ^= HasNegativeKeyword.GetHashCode();
            }
            if (HasHasMatchingKeyword)
            {
                hash ^= HasMatchingKeyword.GetHashCode();
            }
            if (HasHasNegativeUrl)
            {
                hash ^= HasNegativeUrl.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public int Put(int id, [FromBody] Headline headline)
        {
            //var item = hList.SingleOrDefault(h => h.ID == id);
            //hList.Remove(item);
            //hList.Add(header);

            //return header;

            string updateString = $"UPDATE Headline SET title = '{headline.Title}', descriptions = '{headline.Descriptions}' WHERE headlineId = '{id}'";
            using (SqlConnection databaseConnection = new SqlConnection(connectionString))
            {
                databaseConnection.Open();
                using (SqlCommand updateCommand = new SqlCommand(updateString, databaseConnection))
                {
                    int rowsAffected = updateCommand.ExecuteNonQuery();

                    return rowsAffected;
                }
            }
        }
        public int Post([FromBody] Headline headline)
        {
            //Headline h = header;
            //h.ID = id++;
            //hList.Add(header);
            //return header;

            const string postString = "INSERT INTO Headline (title, descriptions) VALUES (@Header, @Desc)";
            using (SqlConnection databaseConnection = new SqlConnection(connectionString))
            {
                databaseConnection.Open();
                using (SqlCommand insertCommand = new SqlCommand(postString, databaseConnection))
                {
                    insertCommand.Parameters.AddWithValue("@Header", headline.Title);
                    insertCommand.Parameters.AddWithValue("@Desc", headline.Descriptions);

                    int rowsAffected = insertCommand.ExecuteNonQuery();

                    return rowsAffected;
                }
            }
        }
示例#21
0
        public Message CreateNews(string headline, IList <string> lines)
        {
            var h = new Headline(headline);

            var news = new News(h);

            foreach (var s in lines)
            {
                var group = new News.LinesOfTextGroup {
                    Text = new Text(s)
                };
                news.AddGroup(group);
            }

            if (lines.Count == 0)
            {
                var noLines = new LinesOfText(0);
                news.SetField(noLines, true);
            }

            return(news);
        }
        public List<Headline> Get()
        {
            //return hList;

            const string selectString = "SELECT * FROM Headline order by headlineId";
            using (SqlConnection databaseConnection = new SqlConnection(connectionString))
            {
                databaseConnection.Open();
                using (SqlCommand selectCommand = new SqlCommand(selectString, databaseConnection))
                {
                    using (SqlDataReader reader = selectCommand.ExecuteReader())
                    {
                        List<Headline> headlineList = new List<Headline>();
                        while (reader.Read())
                        {
                            Headline headline = readHeadlineFromDB(reader);
                            headlineList.Add(headline);
                        }
                        return headlineList;
                    }
                }
            }
        }
示例#23
0
 /// <summary>
 /// 队列到头条
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool goHead(int id)
 {
     if (displayCount >= threshold)               //头条已经达到预期展示数量,不能增加
     {
         return(false);
     }
     try
     {
         using (var db = new huxiuEntities())
         {
             Headline goHead = db.Headline.Single(a => a.Id == id);
             goHead.HisDisplay = true;
             db.SaveChanges();
         }
         displayCount++;
         queueSize--;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public Headline Get(int id)
        {
            //var item = hList.SingleOrDefault(r => r.ID == id);
            //return item;

            string selectString = $"SELECT * FROM Headline Where headlineId = '{id}' ";
            using (SqlConnection databaseConnection = new SqlConnection(connectionString))
            {
                databaseConnection.Open();
                using (SqlCommand selectCommand = new SqlCommand(selectString, databaseConnection))
                {
                    using (SqlDataReader reader = selectCommand.ExecuteReader())
                    {
                        Headline headline = new Headline();
                        while (reader.Read())
                        {
                            headline = readHeadlineFromDB(reader);

                        }
                        return headline;
                    }
                }
            }
        }
示例#25
0
 /// <summary>
 /// 编辑属于队列中的等待头条
 /// </summary>
 /// <param name="id"></param>
 /// <param name="showTime"></param>
 /// <returns></returns>
 public bool edit(int id, string showTime)
 {
     if (!isExpire(showTime))
     {
         try
         {
             using (var db = new huxiuEntities())
             {
                 Headline goHead = db.Headline.Single(a => a.Id == id);
                 goHead.Hdeadline = showTime;
                 db.SaveChanges();
             }
             return(true);
         }
         catch
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
示例#26
0
 public HeadlineView(Headline headline)
 {
     Headline = headline;
     title    = headline.Text;
 }
示例#27
0
 public void AddHeadline(Headline headline)
 {
     headlines.Add(headline);
 }
 private HeadlineDisplayItems ConvertToViewModel(Headline headline)
 {
     // Conversion code here
 }
示例#29
0
 public static HeadlineLookupModel Create(Headline headline)
 {
     return(Projection.Compile().Invoke(headline));
 }
示例#30
0
        private Item parseXml(XElement element)
        {
            Item item = null;

            switch (element.Name.ToString())
            {
            case "MenuItem":
                item =
                    new PxMenuItem(
                        this,
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection") != null ? element.Parent.Attribute("selection").Value : "",
                        element.Attribute("selection").Value,
                        element.Element("Description").Value
                        );

                XName[] subItemLabels = new XName[] { "MenuItem", "Headline", "Link" };

                item.Cast <PxMenuItem>().AddSubItemRange(
                    from e in element.Elements()
                    where subItemLabels.Contains(e.Name)
                    select parseXml(e)
                    );

                break;

            case "Headline":
                item =
                    new Headline(
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value
                        );

                break;

            case "Link":
                item =
                    new TableLink(
                        element.Element("Text").Value,
                        element.Element("TextShort").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value,
                        element.Attribute("type").Value.ToEnum <LinkType>(),
                        element.Attribute("status").Value == "" ? TableStatus.NotSet : (TableStatus)element.Attribute("status").Value[0],
                        element.Element("Published").Value == "" ? null : (DateTime?)DateTime.Parse(element.Element("Published").Value),
                        element.Element("LastUpdated").Value == "" ? null : (DateTime?)DateTime.Parse(element.Element("LastUpdated").Value),
                        element.Element("StartTime").Value,
                        element.Element("EndTime").Value,
                        element.Attribute("tableId").Value,
                        element.Attribute("category").Value == "" ? PresCategory.NotSet : (PresCategory)element.Attribute("category").Value[0]
                        );

                foreach (XElement a in element.Elements("Attribute"))
                {
                    item.Cast <Link>().SetAttribute(a.Attribute("name").Value, a.Value);
                }

                break;

            case "Url":
                item =
                    new Url(
                        element.Element("Text").Value,
                        element.Attribute("sortCode").Value,
                        element.Parent.Attribute("selection").Value,
                        element.Attribute("selection").Value,
                        element.Element("Description").Value,
                        element.Attribute("category").Value == "" ? PresCategory.NotSet : (PresCategory)element.Attribute("category").Value[0],
                        element.Element("Url").Value,
                        element.Attribute("linkPres").Value == "" ? LinkPres.NotSet : (LinkPres)element.Attribute("linkPres").Value[0]
                        );

                foreach (XElement a in element.Elements("Attribute"))
                {
                    item.Cast <Link>().SetAttribute(a.Attribute("name").Value, a.Value);
                }

                break;

            default:
                break;
            }

            if (item.IsNotOfType <Url>())
            {
                foreach (Url u in element.Elements("Url").Select(e => parseXml(e)))
                {
                    if (u != null)
                    {
                        item.AddUrl(u);
                    }
                }
            }

            item.ID.Menu = element.Parent.Attribute("selection") != null?element.Parent.Attribute("selection").Value : "";

            if (Restriction == null || Restriction(item))
            {
                if (AlterItemBeforeStorage != null)
                {
                    AlterItemBeforeStorage(item);
                }

                return(item);
            }
            else
            {
                return(null);
            }
        }
示例#31
0
        private Item itemFromRow(DataRow row)
        {
            Item item;

            if (row["PRESENTATION"].ToString().ToUpper() == "P")
            {
                item =
                    new Headline(
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString()
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "table")
            {
                item =
                    new TableLink(
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString(),
                        LinkType.Table,
                        row["TABLESTATUS"].ToString() == "" ? TableStatus.NotSet : (TableStatus)row["TABLESTATUS"].ToString().ToUpper()[0],
                        row["PUBLISHED"].ToString() == "" ? null : (DateTime?)DateTime.Parse(row["PUBLISHED"].ToString()),
                        row["LASTUPDATED"].ToString() == "" ? null : (DateTime?)DateTime.Parse(row["LASTUPDATED"].ToString()),
                        row["STARTTIME"].ToString(),
                        row["ENDTIME"].ToString(),
                        row["TABLEID"].ToString(),
                        row["CATEGORY"].ToString() == "" ? PresCategory.NotSet : (PresCategory)row["CATEGORY"].ToString().ToUpper()[0]
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "menu")
            {
                item =
                    new PxMenuItem(
                        this,
                        row["PRESTEXT"].ToString(),
                        row["PRESTEXTS"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["SELECTION"].ToString(),
                        row["DESCRIPTION"].ToString()
                        );
            }
            else if (row["ITEMTYPE"].ToString() == "url")
            {
                item =
                    new Url(
                        row["PRESTEXT"].ToString(),
                        row["SORTCODE"].ToString(),
                        row["MENU"].ToString(),
                        row["LINKID"].ToString(),
                        row["DESCRIPTION"].ToString(),
                        (PresCategory)row["CATEGORY"].ToString().ToUpper()[0],
                        row["LINKURL"].ToString(),
                        (LinkPres)row["LINKPRES"].ToString().ToUpper()[0]
                        );
            }
            else
            {
                throw new Exceptions.NotValidItemFromDatabaseException("Row from database not valid for item creation.");
            }

            item.ID.Menu = row["MENU"].ToString();

            if (Restriction(item))
            {
                if (AlterItemBeforeStorage != null)
                {
                    AlterItemBeforeStorage(item);
                }

                return(item);
            }
            else
            {
                return(null);
            }
        }
示例#32
0
        private uint USER_ID = 1; // DO NOT TOUCH ! ! !

        #endregion Fields

        #region Constructors

        public MainWindow()
        {
            InitializeComponent();

            // Initialize tracking
            initJoints();
            this.tracking = false; // Turn off tracking
            this.calibrating = false; // Turn off any calibration

            // Initialize dialogs
            initDialogs();

            // Initialize handlers
            this.geometryHandler = new GeometryHandler();
            this.fileHandler = new FileHandler();

            // Initialize layout
            this.headline = Headline.Start;
            this.setting = Setting.None;
            updateLayout();
        }
示例#33
0
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            switch (this.headline)
            {
                case Headline.Start: //"hidden"
                    break;
                case Headline.Exhibition: //"open exhibition's properties"
                    this.contentLabel1 = this.exhibition.getName() + " - EINSTELLUNGEN";
                    this.contentButton5 = "OK";
                    this.headline = Headline.ExhibitionSettings;
                    updateLayout();
                    break;
                case Headline.LoadExhibit: //"hidden"
                    break;
                case Headline.NewExhibit: //"hidden"
                    break;
                case Headline.EditExhibit: //"open exhibit's properties"
                    this.contentLabel1 = this.TMP_EXHIBIT.getName() + " - EINSTELLUNGEN";
                    this.contentButton5 = "OK";
                    this.headline = Headline.ExhibitSettings;
                    updateLayout();
                    break;
                case Headline.ExhibitionPlane: //"back to the start"
                    this.headline = Headline.Start;
                    updateLayout();
                    break;
                case Headline.ExhibitionPlaneDef: //"abort calibration or go back to exhibition plane"
                    if (this.calibrating)
                    {
                        stopCalibration();

                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                        this.contentButton4 = "zurück";
                        this.button5.Visibility = Visibility.Visible;
                        updateLayout();
                    }
                    else
                    {
                        stopTracking();

                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                        this.contentButton1 = "laden";
                        this.contentButton2 = "bestimmen";
                        this.contentButton4 = "abbrechen";
                        this.headline = Headline.ExhibitionPlane;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitionPlaneVal: //"abort validation or go back to exhibition plane"
                    if (this.calibrating)
                    {
                        stopCalibration();

                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                        this.contentButton4 = "zurück";
                        this.button5.Visibility = Visibility.Visible;
                        updateLayout();
                    }
                    else
                    {
                        stopTracking();

                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                        this.contentButton1 = "laden";
                        this.contentButton2 = "bestimmen";
                        this.contentButton4 = "abbrechen";
                        this.headline = Headline.ExhibitionPlane;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitionPlaneDone: //"hidden"
                    break;
                case Headline.NewName: //"hidden"
                    break;
                case Headline.ExhibitDef: //"back to the exhibition"
                    if (this.calibrating)
                    {
                        stopCalibration();

                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                        this.contentButton4 = "zurück";
                        this.button5.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        stopTracking();

                        this.contentLabel1 = this.exhibition.getName().ToUpper();
                        this.contentButton4 = "Einstellungen";
                        this.contentButton5 = "schließen";
                        this.headline = Headline.Exhibition;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitVal: //"back to the exhibition"
                    if (this.calibrating)
                    {
                        stopCalibration();

                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                        this.contentButton4 = "zurück";
                        this.button5.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        stopTracking();

                        this.contentLabel1 = this.exhibition.getName().ToUpper();
                        this.contentButton4 = "Einstellungen";
                        this.contentButton5 = "schließen";
                        this.headline = Headline.Exhibition;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitDone: //"hidden"
                    break;
                case Headline.ExhibitionSettings: //"hidden"
                    break;
                case Headline.ExhibitSettings: //"hidden"
                    break;
                default:
                    break;
            }
        }
示例#34
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            switch (this.headline)
            {
                case Headline.Start: //"define new exhibition"
                    this.contentLabel1 = "AUSSTELLUNGSNAMEN BESTIMMEN";
                    this.contentLabel2 = "Bitte Ausstellungsnamen eingeben.";
                    this.contentButton5 = "OK";
                    this.headline = Headline.NewName;
                    updateLayout();
                    break;
                case Headline.Exhibition: //"hidden"
                    break;
                case Headline.LoadExhibit: //"remove exhibit from exhibition's list of exhibits"
                    this.exhibition.removeExhibit(this.TMP_EXHIBIT_INDEX);

                    this.contentLabel1 = this.exhibition.getName().ToUpper();
                    this.contentButton4 = "Einstellungen";
                    this.contentButton5 = "schließen";
                    this.headline = Headline.Exhibition;
                    updateLayout();
                    break;
                case Headline.NewExhibit: //"define new exhibit"
                    this.contentLabel1 = "EXPONATNAMEN BESTIMMEN";
                    this.contentLabel2 = "Bitte Exponatsnamen eingeben.";
                    this.contentButton5 = "OK";
                    this.headline = Headline.NewName;
                    updateLayout();
                    break;
                case Headline.EditExhibit: //"delete image from exhibit"
                    switch (this.comboBox1.SelectedIndex)
                    {
                        case -1: // No item selected
                            break;
                        case 0: // "new image"
                            if (this.loadImageDialog.ShowDialog() == true)
                            {
                                this.TMP_EXHIBIT.addImage(this.fileHandler.loadImage(this.TMP_PATH));
                                this.TMP_PATH = null;
                                updateLayout();
                            }
                            else
                            { }
                            break;
                        default: // Any other image selected
                            KeyValuePair<string, BitmapImage> img = new KeyValuePair<string,BitmapImage>();

                            foreach (KeyValuePair<string, BitmapImage> image in this.TMP_EXHIBIT.getImages())
                            {
                                if (image.Key.Contains(this.comboBox1.SelectedItem.ToString()))
                                {
                                    img = image;
                                }
                            }
                            if (img.Key != null) // Image found
                            {
                                this.TMP_EXHIBIT.removeImage(img);
                                this.image1.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                MessageBox.Show("Bild konnte nicht gelöscht werden.");
                            }
                            updateLayout();
                            break;
                    }
                    break;
                case Headline.ExhibitionPlane:// "define new exhibition plane"
                    startTracking();

                    this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                    this.headline = Headline.ExhibitionPlaneDef;
                    updateLayout();
                    break;
                case Headline.ExhibitionPlaneDef: //"hidden"
                    break;
                case Headline.ExhibitionPlaneVal: //"hidden"
                    break;
                case Headline.ExhibitionPlaneDone: //"hidden"
                    break;
                case Headline.NewName: //"hidden"
                    break;
                case Headline.ExhibitDef: //"hidden"
                    break;
                case Headline.ExhibitVal: //"hidden"
                    break;
                case Headline.ExhibitDone: //"hidden"
                    break;
                case Headline.ExhibitionSettings:
                    if (this.setting == Setting.UserPosition)
                    {
                        startTracking();

                        this.TMP_NAME = "Benutzer";

                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSDEFINITION";
                        this.contentLabel2 = "Bitte stellen Sie sich auf die zukünftige Benutzerposition.";
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "Start";
                        this.headline = Headline.ExhibitDef;
                    }
                    else if (this.setting == Setting.BackgroundImage)
                    {
                        if (this.loadImageDialog.ShowDialog() == true)
                        {
                            this.exhibition.setBackgroundImage(this.fileHandler.loadImage(this.loadImageDialog.FileName));
                        }
                    }
                    else if (this.setting == Setting.Overview)
                    {
                        if (this.loadImageDialog.ShowDialog() == true)
                        {
                            this.exhibition.setOverview(this.fileHandler.loadImage(this.loadImageDialog.FileName));
                        }
                    }
                    updateLayout();
                    break;
                case Headline.ExhibitSettings:
                    startTracking();

                    this.TMP_NAME = this.TMP_EXHIBIT.getName();

                    this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSDEFINITION";
                    this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                    this.contentButton4 = "zurück";
                    this.contentButton5 = "Start";
                    this.headline = Headline.ExhibitDef;
                    updateLayout();
                    break;
                default:
                    break;
            }
        }
示例#35
0
        private void definePosition()
        {
            int mode = 1; // 0 := pointing, 1 := aiming, 2 := both
            this.calibrationHandler = new CalibrationHandler(this.SAMPLING_VECTORS, this.exhibition.getThreshold()); // Initiate calibrator
            List<GeometryHandler.Vector> vectors = sampleVectors(1, this.SAMPLING_POSITIONS, this.SAMPLING_VECTORS, mode); // Sampled vectors
            Point3D position = this.calibrationHandler.definePosition(this.exhibition.getExhibitionPlane(), vectors, this.SAMPLING_POSITIONS, mode); // Calibration-points

            switch (this.setting)
            {
                case Setting.None: // Defining or validating exhibit's position
                    if (this.headline == Headline.ExhibitDef)
                    {
                        this.TMP_POSITION = position;
                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSVALIDIERUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "Start";
                        this.headline = Headline.ExhibitVal;

                        stopCalibration();
                    }
                    else if (this.headline == Headline.ExhibitVal)
                    {
                        this.TMP_POSITION_2 = position;
                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSBESTIMMUNG";
                        if (this.calibrationHandler.validatePoint(this.TMP_POSITION, this.TMP_POSITION_2) == 3) // All three axis are within threshold
                        {
                            this.contentLabel2 = "Position erfolgreich validiert.";
                            this.contentButton4 = "zurück";
                            this.contentButton5 = "OK";
                            this.headline = Headline.ExhibitDone;

                            stopCalibration();
                            stopTracking();
                        }
                        else
                        {
                            this.contentLabel2 = "Position konnte nicht validiert werden." + '\n' + "Erneut definieren?";
                            this.contentLabel2 += +'\n' + "1.: " + (int)this.TMP_POSITION.X + ";" + (int)this.TMP_POSITION.Y + ";" + (int)this.TMP_POSITION.Z;
                            this.contentLabel2 += +'\n' + "2.: " + (int)this.TMP_POSITION_2.X + ";" + (int)this.TMP_POSITION_2.Y + ";" + (int)this.TMP_POSITION_2.Z;
                            this.contentButton4 = "zurück";
                            this.contentButton5 = "OK";
                            this.headline = Headline.ExhibitDef;

                            stopCalibration();
                        }
                    }
                    else
                    {
                        MessageBox.Show("definePosition()-Problem: Setting.None, Headline?");

                        stopCalibration();
                        stopTracking();
                    }
                    break;
                case Setting.Position: // Re-defining exhibit's position
                    if (this.headline == Headline.ExhibitDef)
                    {
                        this.TMP_POSITION = position;
                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSVALIDIERUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "Start";
                        this.headline = Headline.ExhibitVal;

                        stopCalibration();
                    }
                    else if (this.headline == Headline.ExhibitVal)
                    {
                        this.TMP_POSITION_2 = position;
                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSBESTIMMUNG";
                        if (this.calibrationHandler.validatePoint(this.TMP_POSITION, this.TMP_POSITION_2) == 3) // All three axis are within threshold
                        {
                            this.contentLabel2 = "Position erfolgreich validiert.";
                            this.contentButton4 = "zurück";
                            this.contentButton5 = "OK";
                            this.headline = Headline.ExhibitDone;

                            stopCalibration();
                            stopTracking();
                        }
                        else
                        {
                            this.contentLabel2 = "Position konnte nicht validiert werden." + '\n' + "Erneut definieren?";
                            this.contentLabel2 += + '\n' + "1.: " + (int)this.TMP_POSITION.X + ";" + (int)this.TMP_POSITION.Y + ";" + (int)this.TMP_POSITION.Z;
                            this.contentLabel2 += + '\n' + "2.: " + (int)this.TMP_POSITION_2.X + ";" + (int)this.TMP_POSITION_2.Y + ";" + (int)this.TMP_POSITION_2.Z;
                            this.contentButton4 = "zurück";
                            this.contentButton5 = "OK";
                            this.headline = Headline.ExhibitDef;

                            stopCalibration();
                        }
                    }
                    break;
                default:
                    break;
            }
        }
示例#36
0
        private void defineUserPosition()
        {
            this.exhibition.setUserPosition(sampleUserPosition());

            this.contentLabel2 = "Benutzerposition erfolgreich bestimmt."; // "User position defined successfully."
            this.contentButton5 = "OK";
            this.headline = Headline.ExhibitVal;

            stopCalibration();
        }
示例#37
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            switch (this.headline)
            {
                case Headline.Start: //"load existing exhibition"
                    if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set
                    {
                        this.exhibition = this.fileHandler.loadExhibition(this.TMP_PATH);
                        this.TMP_PATH = null;

                        this.contentLabel1 = this.exhibition.getName().ToUpper();
                        this.contentButton4 = "Einstellungen";
                        this.contentButton5 = "schließen";
                        this.headline = Headline.Exhibition;
                        updateLayout();
                    }
                    break;
                case Headline.Exhibition: //"hidden"
                    break;
                case Headline.LoadExhibit: //"edit exhibit"
                    this.TMP_EXHIBIT = this.exhibition.getExhibit(this.TMP_EXHIBIT_INDEX);
                    this.TMP_EXHIBIT_INDEX = this.comboBox1.SelectedIndex - 1;

                    this.contentLabel1 = this.TMP_EXHIBIT.getName().ToUpper() + " - BEARBEITEN";
                    this.contentTextBox1 = this.TMP_EXHIBIT.getDescription();
                    this.headline = Headline.EditExhibit;
                    updateLayout();
                    break;
                case Headline.NewExhibit: //"load existing exhibit"
                    if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set
                    {
                        this.TMP_EXHIBIT = this.fileHandler.loadExhibit(this.TMP_PATH);
                        this.TMP_PATH = null;
                        this.exhibition.addExhibit(this.TMP_EXHIBIT);
                        this.TMP_EXHIBIT_INDEX = this.exhibition.getExhibits().Count - 1;

                        this.contentLabel1 = this.TMP_EXHIBIT.getName().ToUpper() + " - BEARBEITEN";
                        this.contentTextBox1 = this.TMP_EXHIBIT.getDescription();
                        this.headline = Headline.EditExhibit;
                        updateLayout();
                    }
                    else // Temporary file path hat not been set
                    { }
                    break;
                case Headline.EditExhibit: //"hidden"
                    break;
                case Headline.ExhibitionPlane: //"load exisiting definition of the exhibition plane"
                    if (this.loadConfigDialog.ShowDialog() == true) // Temporary file path has been set
                    {
                        this.TMP_EXHIBITION_PLANE = this.fileHandler.loadExhibitionPlane(this.TMP_PATH);
                        this.TMP_PATH = null;
                        this.exhibition = new Exhibition(this.TMP_NAME, this.TMP_EXHIBITION_PLANE);

                        this.contentLabel1 = this.exhibition.getName().ToUpper();
                        this.contentButton4 = "Einstellungen";
                        this.contentButton5 = "schließen";
                        this.headline = Headline.Exhibition;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitionPlaneDef: //"hidden"
                    break;
                case Headline.ExhibitionPlaneVal: //"hidden"
                    break;
                case Headline.ExhibitionPlaneDone: //"hidden"
                    break;
                case Headline.NewName: //"hidden"
                    break;
                case Headline.ExhibitDef: //"hidden"
                    break;
                case Headline.ExhibitVal: //"hidden"
                    break;
                case Headline.ExhibitDone: //"hidden"
                    break;
                case Headline.ExhibitionSettings: //"hidden"
                    break;
                case Headline.ExhibitSettings: //"hidden"
                    break;
                default:
                    break;
            }
        }
示例#38
0
        private void button5_Click(object sender, RoutedEventArgs e)
        {
            switch (this.headline)
            {
                default:
                    break;
                case Headline.Start: //"close the application"
                    closeAllThreads();
                    break;
                case Headline.Exhibition: //"close the application"
                    if (this.exhibition.getPath() == null)
                    {
                        if (this.saveConfigDialog.ShowDialog() == true)
                        {
                            this.exhibition.setPath(saveConfigDialog.FileName);
                        }
                    }
                    this.fileHandler.saveExhibition(this.exhibition);
                    closeAllThreads();
                    break;
                case Headline.LoadExhibit: //"hidden"
                    break;
                case Headline.NewExhibit: //"hidden"
                    break;
                case Headline.EditExhibit: //"editing done"
                    this.TMP_EXHIBIT.setDescription(this.textBox1.Text);

                    if (this.TMP_EXHIBIT_INDEX != -1) // Existing exhibit
                    {
                        this.exhibition.setExhibit(this.TMP_EXHIBIT_INDEX, this.TMP_EXHIBIT);
                        this.fileHandler.saveExhibit(this.TMP_EXHIBIT);

                        this.contentLabel1 = this.exhibition.getName().ToUpper();
                        this.contentButton4 = "Einstellungen";
                        this.contentButton5 = "schließen";
                        this.headline = Headline.Exhibition;
                        updateLayout();
                    }
                    else // New exhibit
                    {
                        if (this.saveConfigDialog.ShowDialog() == true)
                        {
                            this.TMP_EXHIBIT.setPath(this.saveConfigDialog.FileName);
                            this.TMP_PATH = null;
                            this.exhibition.addExhibit(this.TMP_EXHIBIT);

                            this.fileHandler.saveExhibit(this.TMP_EXHIBIT);

                            this.contentLabel1 = this.exhibition.getName().ToUpper();
                            this.contentButton4 = "Einstellungen";
                            this.contentButton5 = "schließen";
                            this.headline = Headline.Exhibition;
                            updateLayout();
                        }
                    }
                    break;
                case Headline.ExhibitionPlane: //"hidden"
                    break;
                case Headline.ExhibitionPlaneDef: //"start definition of exhibition plane"
                    if (!this.calibrating)
                    {
                        startPlaneDefinition();

                        this.contentButton4 = "Abbruch";
                        this.contentButton5 = "Start";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    break;
                case Headline.ExhibitionPlaneVal: //"start validation of exhibition plane"
                    if (!this.calibrating)
                    {
                        startPlaneDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    break;
                case Headline.ExhibitionPlaneDone: //"abort validation of exhibition plane"
                    stopTracking();
                    this.exhibition = new Exhibition(this.TMP_NAME, this.TMP_EXHIBITION_PLANE);

                    MessageBox.Show("Bitte stellen Sie umgehend die Benutzerposition ein.");

                    this.contentLabel1 = this.exhibition.getName().ToUpper();
                    this.contentButton4 = "Einstellungen";
                    this.contentButton5 = "schließen";
                    this.headline = Headline.Exhibition;
                    updateLayout();
                    break;
                case Headline.NewName: //"safe name and continue to next view"
                    if (this.exhibition == null) // New exhibition
                    {
                        this.TMP_NAME = this.textBox2.Text;

                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                        this.contentButton1 = "laden";
                        this.contentButton2 = "bestimmen";
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "OK";
                        this.headline = Headline.ExhibitionPlane;
                    }
                    else // New exhibit
                    {
                        startTracking();

                        this.TMP_NAME = this.textBox2.Text;

                        this.contentLabel1 = this.TMP_NAME.ToUpper() + " - POSITIONSBESTIMMUNG";
                        this.contentLabel2 = this.INSTRUCTIONS_EXHIBIT;
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "Start";
                        this.headline = Headline.ExhibitDef;
                    }
                    updateLayout();
                    break;
                case Headline.ExhibitDef: //"start definition of an exhibit or the user position"
                    if (!this.calibrating && this.setting == Setting.None)
                    {
                        startPositionDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    else if (!this.calibrating && this.setting == Setting.UserPosition)
                    {
                        startUserPositionDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    else if (!this.calibrating && this.setting == Setting.Position)
                    {
                        startPositionDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    break;
                case Headline.ExhibitVal: //"start validation of an exhibit or accept user position"
                    if (!this.calibrating && this.setting == Setting.None) // Validation
                    {
                        startPositionDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    else if (!this.calibrating && this.setting == Setting.Position)
                    {
                        startPositionDefinition();

                        this.contentButton4 = "Abbruch";
                        this.button5.Visibility = Visibility.Hidden;
                        updateButtons();
                    }
                    else // Acceptance of user position
                    {
                        stopTracking();

                        this.contentLabel1 = this.exhibition.getName() + " - EINSTELLUNGEN";
                        this.contentButton5 = "OK";
                        this.headline = Headline.ExhibitionSettings;
                        updateLayout();
                    }
                    break;
                case Headline.ExhibitDone: //"abort validation of exhibition plane"
                    if (this.setting == Setting.UserPosition)
                    {
                        //this.exhibition.setUserPosition SOMEHOW

                        this.contentLabel1 = this.exhibition.getName() + " - EINSTELLUNGEN";
                        this.contentButton5 = "OK";
                        this.headline = Headline.ExhibitionSettings;
                    }
                    else if (this.setting == Setting.Position)
                    {
                        this.TMP_EXHIBIT.setPosition(this.geometryHandler.getCenter(this.TMP_POSITION, this.TMP_POSITION_2));

                        this.contentLabel1 = this.TMP_EXHIBIT.getName() + " - EINSTELLUNGEN";
                        this.headline = Headline.ExhibitSettings;
                    }
                    else //((int)this.setting == 0) //New Exhibit: Settings.None
                    {
                        Point3D position = this.geometryHandler.getCenter(this.TMP_POSITION, this.TMP_POSITION_2);
                        this.TMP_EXHIBIT = new Exhibit(this.TMP_NAME, position);

                        this.contentLabel1 = this.TMP_EXHIBIT.getName();
                        this.contentTextBox1 = this.TMP_EXHIBIT.getDescription();
                        this.headline = Headline.EditExhibit;
                    }

                    this.setting = Setting.None;
                    updateLayout();
                    break;
                case Headline.ExhibitionSettings: //"safe and go back to exhibition"
                    if (this.exhibition.getPath() != null) // Config-file already exists
                    {
                        this.fileHandler.saveExhibition(this.exhibition);
                    }

                    this.contentLabel1 = this.exhibition.getName().ToUpper();
                    this.contentButton4 = "Einstellungen";
                    this.contentButton5 = "schließen";
                    this.headline = Headline.Exhibition;
                    this.setting = Setting.None;
                    updateLayout();
                    break;
                case Headline.ExhibitSettings: //"go to exhibit"
                    if (this.TMP_EXHIBIT.getPath() != null) // Config-file already exists
                    {
                        this.fileHandler.saveExhibit(this.TMP_EXHIBIT);
                    }

                    this.headline = Headline.EditExhibit;
                    this.setting = Setting.None;
                    updateLayout();
                    break;
            }
        }
示例#39
0
        private void definePlane()
        {
            int mode = 2; // 0 := pointing, 1 := aiming, 2 := both
            this.calibrationHandler = new CalibrationHandler(this.SAMPLING_VECTORS); // Initiate calibrator
            List<GeometryHandler.Vector> vectors = sampleVectors(this.SAMPLING_POINTS, this.SAMPLING_POSITIONS, this.SAMPLING_VECTORS, mode); // Sampled vectors
            List<Point3D> corners = this.calibrationHandler.definePlane(vectors, this.SAMPLING_POSITIONS, mode); // Calibration-points

            switch (this.headline)
            {
                case Headline.ExhibitionPlaneDef:
                    this.TMP_EXHIBITION_PLANE = new GeometryHandler.Plane(corners);

                    this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENVALIDIERUNG";
                    this.contentLabel2 = this.INSTRUCTIONS_EXHIBITION_PLANE;
                    this.contentButton4 = "zurück";
                    this.contentButton5 = "Start";
                    this.headline = Headline.ExhibitionPlaneVal;

                    stopCalibration();
                    break;
                case Headline.ExhibitionPlaneVal:
                    this.TMP_EXHIBITION_PLANE_2 = new GeometryHandler.Plane(corners);

                    this.contentLabel1 = this.TMP_NAME.ToUpper() + " - EBENENBESTIMMUNG";
                    if (this.calibrationHandler.validatePlane(this.TMP_EXHIBITION_PLANE, this.TMP_EXHIBITION_PLANE_2))
                    {
                        this.exhibition = new Exhibition(this.TMP_NAME, this.calibrationHandler.makePlane(this.TMP_EXHIBITION_PLANE, this.TMP_EXHIBITION_PLANE_2));

                        this.contentLabel2 = "Eckpunkte erfolgreich validiert.";
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "OK";
                        this.headline = Headline.ExhibitionPlaneDone;

                        stopCalibration();
                        stopTracking();
                    }
                    else
                    {
                        this.contentLabel2 = "Eckpunkte konnten nicht validiert werden." + '\n' + '\n' + "Erneut definieren?";
                        this.contentButton4 = "zurück";
                        this.contentButton5 = "OK";
                        this.headline = Headline.ExhibitionPlaneDef;

                        stopCalibration();
                    }

                    break;
                default:
                    MessageBox.Show("definePlane()-Problem!");
                    break;
            }
        }
示例#40
0
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (this.headline)
            {
                case Headline.Start: //"hidden"
                    break;
                case Headline.Exhibition:
                    this.TMP_EXHIBIT_INDEX = this.comboBox1.SelectedIndex - 1;

                    switch(this.comboBox1.SelectedIndex)
                    {
                        case -1: // No item selected: "initialization"
                            break;
                        case 0: // First item selected: "new exhibit"
                            this.contentLabel1 = "NEUES EXPONAT";
                            this.contentButton1 = "laden";
                            this.contentButton2 = "erstellen";
                            this.headline = Headline.NewExhibit;
                            updateLayout();
                            break;
                        default: // Existing item selected: "exhibit XY"
                            this.contentLabel1 = this.comboBox1.SelectedItem.ToString();
                            this.contentButton1 = "bearbeiten";
                            this.contentButton2 = "löschen";
                            this.headline = Headline.LoadExhibit;
                            updateLayout();
                            break;
                    }
                    break;
                case Headline.LoadExhibit: //"hidden"
                    break;
                case Headline.NewExhibit: //"hidden"
                    break;
                case Headline.EditExhibit:
                    switch (this.comboBox1.SelectedIndex)
                    {
                        case -1: // No item selected: "initialization"
                            this.contentButton2 = "     ";
                            this.contentButton3 = "Text laden";
                            this.contentButton4 = "Eigenschaften";
                            this.contentButton5 = "OK";
                            break;
                        case 0: // First item selected: "new image"
                            this.contentButton2 = "laden";
                            break;
                        default: // Existing image selected: "?. image"
                            foreach (KeyValuePair<string, BitmapImage> image in this.TMP_EXHIBIT.getImages())
                            {
                                if (image.Key.Contains(this.comboBox1.SelectedItem.ToString()))
                                {
                                    this.updateImage(image.Value);
                                    break;
                                }
                            }
                            this.contentButton2 = "löschen";
                            break;
                    }
                    updateButtons();
                    break;
                case Headline.ExhibitionPlane: //"hidden"
                    break;
                case Headline.ExhibitionPlaneDef: //"hidden"
                    break;
                case Headline.ExhibitionPlaneVal: //"hidden"
                    break;
                case Headline.ExhibitionPlaneDone: //"hidden"
                    break;
                case Headline.NewName: //"hidden"
                    break;
                case Headline.ExhibitDef: //"hidden"
                    break;
                case Headline.ExhibitVal: //"hidden"
                    break;
                case Headline.ExhibitDone: //"hidden"
                    break;
                case Headline.ExhibitionSettings:
                    switch (this.comboBox1.SelectedIndex)
                    {
                        case 0: //UserPosition
                            this.image1.Visibility = Visibility.Hidden;
                            this.comboBox2.Visibility = Visibility.Hidden;
                            this.contentButton2 = "einstellen";
                            this.button2.Visibility = Visibility.Visible;
                            this.button3.Visibility = Visibility.Hidden;
                            this.setting = Setting.UserPosition;
                            break;
                        case 1: //BackgroundImage
                            updateImage(this.exhibition.getBackgroundImage().Value);
                            this.comboBox2.Visibility = Visibility.Hidden;
                            this.contentButton2 = "laden";
                            this.button2.Visibility = Visibility.Visible;
                            this.button3.Visibility = Visibility.Hidden;
                            this.setting = Setting.BackgroundImage;
                            break;
                        case 2: //Overview
                            updateImage(this.exhibition.getOverview().Value);
                            this.comboBox2.Visibility = Visibility.Hidden;
                            this.contentButton2 = "laden";
                            this.button2.Visibility = Visibility.Visible;
                            this.button3.Visibility = Visibility.Hidden;
                            this.setting = Setting.Overview;
                            break;
                        case 3: //Threshold
                            this.image1.Visibility = Visibility.Hidden;
                            this.setting = Setting.Threshold;
                            this.showLowMedHigh();
                            break;
                        case 4: //SelectionTime
                            this.image1.Visibility = Visibility.Hidden;
                            this.setting = Setting.SelectionTime;
                            this.showLowMedHigh();
                            break;
                        case 5: //LockTime
                            this.image1.Visibility = Visibility.Hidden;
                            this.setting = Setting.LockTime;
                            this.showLowMedHigh();
                            break;
                        case 6: //SlideTime
                            this.image1.Visibility = Visibility.Hidden;
                            this.setting = Setting.SlideTime;
                            this.showLowMedHigh();
                            break;
                        case 7: //EndWait
                            this.image1.Visibility = Visibility.Hidden;
                            this.setting = Setting.EndWait;
                            this.showLowMedHigh();
                            break;
                        default:
                            break;
                    }
                    updateButtons();
                    break;
                case Headline.ExhibitSettings:
                    switch (this.comboBox1.SelectedIndex)
                    {
                        case 0: //Position
                            this.contentButton2 = "ändern";
                            this.comboBox2.Visibility = Visibility.Hidden;
                            this.button2.Visibility = Visibility.Visible;
                            this.button3.Visibility = Visibility.Hidden;
                            this.setting = Setting.Position;
                            updateButtons();
                            break;
                        case 1: //KernelSize
                            this.setting = Setting.KernelSize;
                            this.showLowMedHigh();
                            break;
                        case 2: //KernelWeight
                            this.setting = Setting.KernelWeight;
                            this.showLowMedHigh();
                            break;
                        default:
                            break;
                    }
                    updateButtons();
                    break;
                default:
                    break;
            }
        }
示例#41
0
 public ActionResult viewTags(Headline.ViewModels.editTagsListViewModel model)
 {
     return View(model);
 }