private void _pictureTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { TabItem tabItem = _pictureTabControl.SelectedItem as TabItem; ShotPanel panel = tabItem.Content as ShotPanel; panel.Open(); }
private void EnsurePictureSelection() { foreach (TabItem i in _pictureTabControl.Items) { ShotPanel panel = i.Content as ShotPanel; if (panel.IsOpened()) { _pictureTabControl.SelectedItem = i; } } }
private void shotButton_Click(object sender, RoutedEventArgs e) { if (_pictureTabControl.Items.Count == 0 || (_pictureTabControl.SelectedIndex == -1 && _pictureTabControl.Items.Count > 1)) { return; } EnsurePictureSelection(); this._tc.TrackEvent("Take Screenshot", (IDictionary <string, string>)null, (IDictionary <string, double>)null); int selIndex = _pictureTabControl.SelectedIndex != -1 ? _pictureTabControl.SelectedIndex : 0; ShotPanel shotPanel = (_pictureTabControl.Items[selIndex] as TabItem).Content as ShotPanel; this._windowState = this.WindowState; if (this._parentWindow != null) { this._parentWindowState = this._parentWindow.WindowState; this._parentWindow.WindowState = WindowState.Minimized; } this.WindowState = WindowState.Minimized; System.Drawing.Rectangle bounds = Screen.PrimaryScreen.Bounds; int width = bounds.Width; int height = bounds.Height; int x = bounds.X; int y = bounds.Y; System.Drawing.Size size = bounds.Size; Bitmap bitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics graphics = Graphics.FromImage((System.Drawing.Image)bitmap); graphics.CopyFromScreen(x, y, 0, 0, size, CopyPixelOperation.SourceCopy); shotPanel.SetPicture(bitmap); if (this._parentWindow != null) { this._parentWindow.WindowState = this._parentWindowState; } this.WindowState = this._windowState; this.Activate(); }
private void removeMarkButton_Click(object sender, RoutedEventArgs e) { this._tc.TrackEvent("Remove markers", (IDictionary <string, string>)null, (IDictionary <string, double>)null); if (_pictureTabControl.Items.Count == 0) { return; } if (_pictureTabControl.Items.Count == 1) { _pictureTabControl.SelectedIndex = 0; } ShotPanel panel = (_pictureTabControl.SelectedItem as TabItem).Content as ShotPanel; panel.RemoveMarkers(); this._isIssueEdited = true; }
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); }