private void addPictureButton_Click(object sender, RoutedEventArgs e)
        {
            if (this._currentPicture != null)
            {
                if (!SavePicture(this._currentPicture))
                {
                    return;
                }
            }

            RIDataModelContainer d = new RIDataModelContainer();

            Picture p = new Picture();

            p.IsOpened = true;

            System.Windows.Controls.ListViewItem item = new System.Windows.Controls.ListViewItem();

            /*
             * System.Windows.Controls.ListBoxItem item = new System.Windows.Controls.ListBoxItem();
             * p.Name = string.Format("Picture - {0}", _pictureList.Items.Count + 1);
             *          item.Content = p.Name;
             *          item.DataContext = p;
             *          _pictureList.Items.Add(item);
             *          _pictureList.SelectedIndex = _pictureList.Items.Count - 1;
             */
            p.Name           = string.Format("Picture - {0}", _pictureListView.Items.Count + 1);
            item.Content     = p.Name;
            item.DataContext = p;
            _pictureListView.Items.Add(item);
            _pictureListView.SelectedIndex = _pictureListView.Items.Count - 1;
        }
        private bool SaveIssue()
        {
            this._tc.TrackEvent("Save Issue", (IDictionary <string, string>)null, (IDictionary <string, double>)null);

            if (!this.CheckCurrentIssueProperties())
            {
                int num = (int)System.Windows.MessageBox.Show("All values should be not empty", "Issue report");
                return(false);
            }

            this.PutCurrentIssueProperties();
            RIDataModelContainer d = new RIDataModelContainer();

            this.CurrentIssue.Wrong = ReportIssueUtilities.ReportIssueUtilities.EncodeErrors(_errorGrid.ItemsSource as ObservableCollection <Error>);

            this.CurrentIssue.Pictures.Clear();
            for (int i = 0; i < this._pictureListView.Items.Count; i++)
            {
                System.Windows.Controls.ListViewItem item = _pictureListView.Items[i] as System.Windows.Controls.ListViewItem;
                Picture picture = (Picture)item.DataContext;

                this.CurrentIssue.Pictures.Add(picture);
                if (!SavePicture(picture))
                {
                    return(false);
                }

                d.Pictures.AddOrUpdate(picture);
                foreach (Marker m in picture.Markers)
                {
                    d.Markers.AddOrUpdate(m);
                }
            }

            /*
             * for (int i = 0; i < this._pictureList.Items.Count; i++)
             *          {
             *               ListBoxItem item = this._pictureList.Items[i] as ListBoxItem;
             *               Picture picture = (Picture)item.DataContext;
             *
             *               this.CurrentIssue.Pictures.Add(picture);
             *               d.Pictures.AddOrUpdate(picture);
             *               if (!SavePicture(picture))
             *               {
             *                  return false;
             *               }
             *
             *          }
             */
            this.CurrentIssue.Save();
            d.Issues.AddOrUpdate(this.CurrentIssue);

            d.SaveChanges();
            return(true);
        }
Exemple #3
0
        public void Open()
        {
            if (this.IsOpened)
            {
                return;
            }

            if (this.Bitmap == null)
            {
                if (this.Bytes != null)
                {
                    this._openStream = new MemoryStream(Bytes);
                    this.Bitmap      = new Bitmap((Stream)this._openStream);
                }
            }

            if (this.MarkerString == null)
            {
                return;
            }

            RIDataModelContainer d = new RIDataModelContainer();

            try
            {
                string[] markArray = this.MarkerString.Split(':');
                foreach (string m in markArray)
                {
                    Marker marker = d.Markers.Find(m);
                    if (marker != null)
                    {
                        Markers.Add(marker);
                    }
                }

                this.IsOpened = true;
            }
            catch (Exception e)
            {
            }
        }
Exemple #4
0
        public void Open()
        {
            RIDataModelContainer d = new RIDataModelContainer();

            this.Pictures.Clear();
            string[] ids = this.PictureString.Split(',');
            foreach (string id in ids)
            {
                Picture p = d.Pictures.Find(id);
                if (p != null)
                {
                    this.Pictures.Add(p);
                }
                else
                {
                    continue;
                }

                p.Open();
            }
        }
        private void ShowPictures()
        {
            int picNum             = 1;
            RIDataModelContainer d = new RIDataModelContainer();

            string[] pictureIds = this.CurrentIssue.PictureString.Split(',');
            foreach (string id in pictureIds)
            {
                Picture   p         = d.Pictures.Find(id);
                ShotPanel shotPanel = new ShotPanel();

                TabItem tabItem = new TabItem();
                tabItem.Content = shotPanel;
                _pictureTabControl.Items.Add(tabItem);
                _pictureTabControl.SelectedIndex     = _pictureTabControl.Items.Count - 1;
                _pictureTabControl.SelectionChanged += _pictureTabControl_SelectionChanged;
                tabItem.Header    = string.Format("Picture {0}", picNum++);
                shotPanel.Picture = p;
                shotPanel.Open();
            }
        }
        private bool SaveIssue()
        {
            try
            {
                this._tc.TrackEvent("Save Issue", (IDictionary <string, string>)null, (IDictionary <string, double>)null);
                if (!this.CheckCurrentIssueProperties())
                {
                    int num = (int)System.Windows.MessageBox.Show("All values should be not empty", "Issue report");
                    return(false);
                }

                if (_pictureTabControl.Items.Count == 0)
                {
                    int num = (int)System.Windows.MessageBox.Show("Add at least one picture", "Issue report");
                    return(false);
                }


                foreach (TabItem i in _pictureTabControl.Items)
                {
                    ShotPanel shotPanel = i.Content as ShotPanel;
                    string    msg;
                    if (!shotPanel.IsValid(out msg))
                    {
                        System.Windows.MessageBox.Show(msg, "ReportIssue", MessageBoxButton.OK);
                        return(false);
                    }
                }

                this.PutCurrentIssueProperties();

                this.CurrentIssue.Pictures.Clear();
                StringBuilder stringBuilder = new StringBuilder();
                foreach (TabItem i in _pictureTabControl.Items)
                {
                    ShotPanel shotPanel = i.Content as ShotPanel;
                    shotPanel.Save();
                    this.CurrentIssue.Pictures.Add(shotPanel.Picture);

                    if (_pictureTabControl.Items.IndexOf(i) > 0)
                    {
                        stringBuilder.AppendFormat(",");
                    }

                    stringBuilder.AppendFormat("{0}", shotPanel.Picture.ID);
                }

                this.CurrentIssue.PictureString = stringBuilder.ToString();
                this.CurrentIssue.Save();

                RIDataModelContainer d = new RIDataModelContainer();
                foreach (Picture p in this.CurrentIssue.Pictures)
                {
                    d.Pictures.AddOrUpdate(p);
                }

                d.Issues.AddOrUpdate(this.CurrentIssue);
                d.SaveChanges();
                this._isIssueEdited = false;
                return(true);
            }
            catch (DbEntityValidationException e)
            {
                foreach (DbEntityValidationResult r in e.EntityValidationErrors)
                {
                    foreach (var err in r.ValidationErrors)
                    {
                        Console.WriteLine(err.PropertyName);
                        Console.WriteLine(err.ErrorMessage);
                    }
                }
            }

            return(false);
        }