private void GraphicExportButton_Click(object sender, RoutedEventArgs e) { if (this.tabControl.Items != null && this.tabControl.Items.Count > 0) { TabItem tabItem = this.tabControl.SelectedItem as TabItem; GraphicPanelControl graphicPanel = tabItem.Content as GraphicPanelControl; string defaultFileName = tabItem.Header.ToString(); CommonSaveFileDialog saveFileDialog = new CommonSaveFileDialog(defaultFileName); saveFileDialog.DefaultExtension = "dat"; saveFileDialog.DefaultFileName = defaultFileName; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == CommonFileDialogResult.Ok) { try { graphicPanel.SaveGraphic(saveFileDialog.FileName); } catch (Exception ex) { } } } }
private void SendCommandToChild_Clicked(object sender, RoutedEventArgs e) { ButtonBase buttonBase = sender as ButtonBase; if (this.tabControl.Items != null && this.tabControl.Items.Count > 0) { var tabItem = this.tabControl.SelectedItem as TabItem; GraphicPanelControl graphicPanel = tabItem.Content as GraphicPanelControl; graphicPanel.ExecuteCommand(buttonBase.Name); } }
private void CreateGraphicFile() { string newFileName = GetNewFileNameIndex(); GraphicPanelControl graphicsPanelControl = new GraphicPanelControl(); TabItem newTabItem = new TabItem(); newTabItem.Header = newFileName; newTabItem.Content = graphicsPanelControl; graphicsPanelControl.SwitchToSelectedToolItemEvent += GraphicsPanelControl_SwitchToSelectedToolItemEvent; this.tabControl.FlowDirection = FlowDirection.LeftToRight; this.tabControl.Items.Add(newTabItem); newTabItem.IsSelected = true; }
private void GraphicImportButton_Clicked(object sender, RoutedEventArgs e) { string filePath = string.Empty; ShellContainer selectedFolder = null; selectedFolder = KnownFolders.Computer as ShellContainer; CommonOpenFileDialog openFileDialog = new CommonOpenFileDialog(); openFileDialog.InitialDirectoryShellContainer = selectedFolder; openFileDialog.EnsurePathExists = true; openFileDialog.EnsureFileExists = true; openFileDialog.DefaultExtension = "dat"; openFileDialog.EnsureReadOnly = true; if (openFileDialog.ShowDialog() == CommonFileDialogResult.Ok) { filePath = openFileDialog.FileName; TabItem newTabItem = new TabItem(); newTabItem.Header = System.IO.Path.GetFileNameWithoutExtension(filePath); ScrollViewer scrollViewer = null; try { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite)) { scrollViewer = XamlReader.Load(fs) as ScrollViewer; } } catch (Exception ex) { } if (scrollViewer != null) { GraphicPanelControl graphicsPanelControl = new GraphicPanelControl(scrollViewer); //graphicsPanelControl.ImportFile(scrollViewer); newTabItem.Content = graphicsPanelControl; this.tabControl.Items.Add(newTabItem); newTabItem.IsSelected = true; } } }
private void ResizeCanvas_SelectionChanged(object sender, SelectionChangedEventArgs e) { var mainVM = this.DataContext as DrawBoardViewModel; ButtonBase buttonBase = sender as ButtonBase; if (null != tabControl) { if (this.tabControl.Items != null && this.tabControl.Items.Count > 0) { var tabItem = this.tabControl.SelectedItem as TabItem; GraphicPanelControl graphicPanel = tabItem.Content as GraphicPanelControl; if (null != mainVM.SelectedCanvasSize) { graphicPanel.ExecuteCommand("ResizeCanvas", mainVM.SelectedCanvasSize.RatioValue); } } } }