private void LocationMouseUp(int? data)
        {
            if (data.HasValue)
            {
                switch (ControlSettings.SelectionCommand)
                {
                    case SelectionCommand.Fill:
                        //keep the last position when mouse is up
                        this.clickLastPosition = data.Value;
                        if (this.clickFirstPosition != -1)
                        {
                            if (FillSettings.ShowNextTime)
                            {
                                //save the current direction and replicates
                                this.previewDirection = FillSettings.FillDirection;
                                this.previewReplicates = FillSettings.Replicates;
                                this.previewRectangleMode = FillSettings.RectangleMode;
                                this.previewReplicateDirection = FillSettings.ReplicateDirection;
                                this.previewGroupNum = FillSettings.GroupNum;
                                this.previewMode = true;

                                PreviewFillFirstAndLast();

                                var childWindowFillSettings = new FillSettingsPopup();
                                childWindowFillSettings.DataContext = FillSettings;
                                childWindowFillSettings.Closed += new EventHandler(FillSettingsDialog_Closed);
                                childWindowFillSettings.radioButtonAcross.Click += new RoutedEventHandler(radioButtonAcross_Click);
                                childWindowFillSettings.radioButtonDown.Click += new RoutedEventHandler(radioButtonDown_Click);
                                childWindowFillSettings.radioReplicateDirectionByCol.Click += new RoutedEventHandler(radioReplicateDirectionByCol_Click);
                                childWindowFillSettings.radioReplicateDirectionByRow.Click += new RoutedEventHandler(radioReplicateDirectionByRow_Click);
                                childWindowFillSettings.checkboxRectangleMode.Click += new RoutedEventHandler(checkboxRectangleMode_Click);
                                childWindowFillSettings.textBoxReplicates.TextChanged += new TextChangedEventHandler(textBoxReplicates_TextChanged);
                                childWindowFillSettings.textBoxGroupNum.TextChanged += new TextChangedEventHandler(textBoxGroupNum_TextChanged);
                                childWindowFillSettings.ShowInteractive();

                                return;
                            }
                            else
                            {
                                FillFirstAndLast(this.clickFirstPosition, data.Value);
                            }
                        }
                        break;
                    case SelectionCommand.Flag:
                        // This checks that mouse up is on the same position as mouse down (so user can cancel the flag by moving to outside the well on mouse up)
                        if (this.clickFirstPosition == data.Value)
                        {
                            if (!_editorStateHelper.IsPositionUsed(data.Value))
                                MessageBox.Show("Only positions with samples can be flagged.");
                            else
                                FlagPosition(data.Value);
                        }
                        break;
                }
                this.clickFirstPosition = -1;
            }
            this.mouseDown = false;
        }
 public void UpdateFillSettings()
 {
     var childWindowFillSettings = new FillSettingsPopup();
     childWindowFillSettings.DataContext = FillSettings;
     childWindowFillSettings.ShowNonInteractive();
 }