private void Button_AcceptRename(object sender, RoutedEventArgs e)
        {
            //check for forbidden strings
            if (this.IndexCardNewName.Text == "Options" || this.IndexCardNewName.Text == "Folders" || this.IndexCardNewName.Text == "Fonts" || this.IndexCardNewName.Text == "Windowposition")
            {
                MessageBox.Show(Globals.MultilangManager.GetTranslation("Error : Name is already used"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            //check if name is already used. This would cause issues when saving
            IndexCard RenameWho    = Globals.FolderManager.IndexCardGet(EditedGUID);
            IndexCard AlreadyTaken = Globals.FolderManager.IndexCardGet(this.IndexCardNewName.Text);

            if (AlreadyTaken != null && AlreadyTaken != RenameWho)
            {
                MessageBox.Show(Globals.MultilangManager.GetTranslation("Error : Name is already used"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (RenameWho != null)
            {
                RenameWho.SetName(this.IndexCardNewName.Text);
            }
            this.Close();
        }
Example #2
0
        /// <summary>
        /// Create a default index card and append it to the list of index cards
        /// </summary>
        public void AppendIndexCard()
        {
            IndexCard nc = new IndexCard(GeneralSettings);

            nc.SetVisible(false);
            nc.SetName("Unsaved " + IndexCards.Count.ToString());
            IndexCards.Add(nc);
        }
Example #3
0
        /// <summary>
        /// Redraw the active index card. Invisible cards will be ingored
        /// </summary>
        public void RedrawIndexCards()
        {
            IndexCard ic = GetVisibleIndexCard();

            if (ic != null)
            {
                ic.ShowIndexCardContent();
            }
        }
        public IndexCardRename(IndexCard sender)
        {
            InitializeComponent();
            EditedGUID = sender.GetGUID();
            this.IndexCardNewName.Text = sender.GetName();
            this.IndexCardNewName.Focus();
            this.IndexCardNewName.SelectAll();

            //if we push enter we presume we pushed button "ok"
            RoutedCommand firstSettings = new RoutedCommand();

            firstSettings.InputGestures.Add(new KeyGesture(Key.Enter, ModifierKeys.None));
            CommandBindings.Add(new CommandBinding(firstSettings, Button_AcceptRename));
            RoutedCommand SecondSettings = new RoutedCommand();

            SecondSettings.InputGestures.Add(new KeyGesture(Key.Escape, ModifierKeys.None));
            CommandBindings.Add(new CommandBinding(SecondSettings, Button_DiscardRename));

            Globals.MultilangManager.TranslateUIComponent(this);
            this.Owner = App.Current.MainWindow;
            this.Left  = this.Owner.Left + this.Owner.Width / 2 - this.Width / 2;
            this.Top   = this.Owner.Top + this.Owner.Height / 2 - this.Height / 2;
        }
Example #5
0
        private void OnMouseUpGrid(object sender, MouseButtonEventArgs e)
        {
            double EndDragPosX = Mouse.GetPosition(this).X;
            double EndDragPosY = Mouse.GetPosition(this).Y;

            //get the cell it was below start drag position
            int StartCellX = (int)(StartDragPosX / GetCellWidth());
            int EndCellX   = (int)(EndDragPosX / GetCellWidth());
            int StartCellY = (int)(StartDragPosY / GetCellHeight());
            int EndCellY   = (int)(EndDragPosY / GetCellHeight());

            //did we drag a cell over another cell ?
            if (StartCellX != EndCellX || StartCellY != EndCellY)
            {
                //yes, we dragged it to a neighbour cell
                MainWindow MainObject = (MainWindow)App.Current.MainWindow;
                IndexCard  ic         = MainObject.GetVisibleIndexCard();
                if (ic != null)
                {
                    ic.SwapPhoneNumbersAtPos(StartCellX, StartCellY, EndCellX, EndCellY);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Delete an index card. Auto select a new one and draw it
        /// </summary>
        /// <param name="todel"></param>
        public void DeleteIndexCard(IndexCard todel)
        {
            bool NeedsVisualRefresh = (todel == IndexCards[SelectedIndexCard]);

            //delete it
            todel.OnDelete();
            IndexCards.Remove(todel);
            // if this is the selected index card. try to select a new one
            if (NeedsVisualRefresh)
            {
                //select a new index card and show it
                if (IndexCards.Count == 0)
                {
                    SelectedIndexCard = -1;
                }
                else
                {
                    SelectedIndexCard = 0;
                    IndexCards[SelectedIndexCard].SetVisible(true);
                    RedrawIndexCards();
                }
            }
        }
Example #7
0
 public IndexCardRename(IndexCard sender)
 {
     InitializeComponent();
     RenameWho = sender;
     this.IndexCardNewName.Text = sender.GetName();
 }