Example #1
0
 /// <summary>
 /// Open a new project
 /// </summary>
 private void OpenProject()
 {
     QuestionDialog dialog = new QuestionDialog("Are you sure to open another project?\nUnsaved progress could be LOST!!!");
     dialog.ShowDialog();
     CurrentStatus.Text = "Opening a data file...";
     WinStatus.Background = Red;
     try {
         using (Stream s = FileManager.Open()) {
             WinStatus.Background = Green;
             CurrentStatus.Text = "Project opened";
             if (s == null)  // user cancel the operation
                 return;
             ReloadProject(DataSerializer<Project>.Load(s));
         }
     }
     catch (Exception e) {
         CurrentStatus.Text = "Error!";
         ReloadProject(null);
         new ErrorHandler("Project cannot be opened!", e).Show();
     }
 }
Example #2
0
 /// <summary>
 /// Close the diagram
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnRemoveDiagramButton(object sender, MouseButtonEventArgs e)
 {
     QuestionDialog dialog = new QuestionDialog("Are you sure to close this diagram?");
     dialog.ShowDialog();
     this.IsOpen = !dialog.Answer;
 }
Example #3
0
 /// <summary>
 /// Confirm before closing window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     QuestionDialog dialog = new QuestionDialog("Are you sure to close this project?\nUnsaved offline project progress could be LOST!!!");
     dialog.ShowDialog();
     e.Cancel = !dialog.Answer;
 }
 /// <summary>
 /// Get a handler thumb
 /// </summary>
 /// <returns></returns>
 private Thumb GetMoveThumb()
 {
     Thumb thumb = new Thumb();
     thumb.Style = FindResource("MoveThumbStyle") as Style;
     // move operation
     thumb.DragDelta += (s, e) => {
         ModelItem elem = AdornedElement as ModelItem;
         if (elem == null) return;
     #if DEBUG_ON
         System.Console.WriteLine("{0},Drag Test: elem.Positon {1}, Change {2},{3}", System.DateTime.Now.Millisecond, elem.Position, e.HorizontalChange, e.VerticalChange);
     #endif
         elem.Position += new Vector(e.HorizontalChange, e.VerticalChange);
     };
     // remove operation
     thumb.MouseDoubleClick += (s, e) => {
         ModelItem elem = AdornedElement as ModelItem;
         if (elem == null) return;
         // confirm
         QuestionDialog dialog = new QuestionDialog("Are you sure to remove this model from current diagram?");
         dialog.ShowDialog();
         if (!dialog.Answer) return;
         Diagram diagram = Project.Current.Children.FindByCanvas(elem.ContainerCanvas);
         diagram.Children.Remove(elem.ContentObject);
     };
     return thumb;
 }