Ejemplo n.º 1
0
        private void DataProvider_DatumInserted(int ndxDatum, IDatum datum)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <int, IDatum>(DataProvider_DatumInserted), ndxDatum, datum);
            }
            else
            {
                //adjust indices
                foreach (ListViewEntry item in m_lvData.Items)
                {
                    if (ndxDatum <= item.DatumIndex)
                    {
                        ++item.DatumIndex;
                    }
                }


                //add new item
                var lvi = new ListViewEntry(datum.Content, ndxDatum);

                m_lvData.Items.Add(lvi);

                if (m_trackNewRows)
                {
                    lvi.Selected = true;
                    m_lvData.EnsureVisible(lvi.Index);
                }

                m_tslblStatus.Text = $"Nombre d'neregistrements: {m_lvData.Items.Count}";
            }
        }
Ejemplo n.º 2
0
        public void RemoveKey(string key)
        {
            // remove from the localization list
            foreach (KeyValuePair <string, List <LocalizationItem> > entry in localizationDictionary)
            {
                // correct list found
                List <LocalizationItem> list = entry.Value;

                try
                {
                    LocalizationItem localizationItem = list.Single(s => s.key == key);
                    list.Remove(localizationItem);
                }
                catch (Exception)
                {
                    // not in the list
                }
            }

            // remove from the global list
            try
            {
                ListViewEntry listViewEntry = collection.Single(s => s.Key == key);
                collection.Remove(listViewEntry);
            }
            catch (Exception)
            {
                // not in the list
            }

            IsDirty = true;
        }
Ejemplo n.º 3
0
 private void buttonForceUpdate_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listView1.SelectedItems)
     {
         ListViewEntry entry = lvi.Tag as ListViewEntry;
         ForceDatabaseUpdate(entry.Path, entry.IsVanilla);
     }
 }
Ejemplo n.º 4
0
 private void buttonForceUpdate_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listViewInstalls.SelectedItems)
     {
         ListViewEntry mod   = listViewMods.SelectedItems[0].Tag as ListViewEntry;
         ListViewEntry entry = lvi.Tag as ListViewEntry;
         ForceDatabaseUpdate(entry.Path, mod?.Path);
     }
 }
        /**********************************************************/

        private void listView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ListViewEntry entry = (ListViewEntry)listView.SelectedItem;

            if (entry != null)
            {
                ShowLocalization(entry.Key);
            }
            else
            {
                stackPanelDetails.Visibility = Visibility.Hidden;
            }
        }
        /**********************************************************/

        private void AddNew()
        {
            DialogInput dialogInput = new DialogInput("Please enter new key:");

            dialogInput.Owner = this;
            if (dialogInput.ShowDialog() == true)
            {
                string        key           = dialogInput.Answer;
                ListViewEntry listViewEntry = LocalizationManager.GetInstance().AddKey(key);

                listView.SelectedItem = listViewEntry;
                listView.ScrollIntoView(listViewEntry);
            }
        }
Ejemplo n.º 7
0
        ListViewEntry[] LoadItems()
        {
            Assert(m_dataProvider != null);
            Assert(m_dataProvider.IsConnected);

            var items = new ListViewEntry[m_dataProvider.Count];

            for (int i = 0; i < m_dataProvider.Count; ++i)
            {
                IDatum datum = m_dataProvider.Get(i);

                var lvi = new ListViewEntry(datum.Content, i);
                items[i] = lvi;
            }

            return(items);
        }
        private void DeleteSelected()
        {
            ListViewEntry entry = (ListViewEntry)listView.SelectedItem;

            if (entry != null)
            {
                MessageBoxResult messageBoxResult = MessageBox.Show(entry.Key, "Do you want to delete the entry?", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (messageBoxResult == MessageBoxResult.No)
                {
                    return;
                }

                LocalizationManager.GetInstance().RemoveKey(entry.Key);

                listView.SelectedItem = null;
            }
        }
Ejemplo n.º 9
0
        public bool RenameKey(string oldKey, string newKey)
        {
            // remove from the global list
            try
            {
                ListViewEntry listViewEntry = collection.Single(s => s.Key == newKey);
                // if no exception, then we already have the new key

                return(false);
            }
            catch (Exception)
            {
                // remove from the localization list
                foreach (KeyValuePair <string, List <LocalizationItem> > entry in localizationDictionary)
                {
                    // correct list found
                    List <LocalizationItem> list = entry.Value;

                    try
                    {
                        LocalizationItem localizationItem = list.Single(s => s.key == oldKey);
                        localizationItem.key = newKey;
                    }
                    catch (Exception)
                    {
                        // not in the list
                    }
                }

                // remove from the global list
                try
                {
                    ListViewEntry listViewEntry = collection.Single(s => s.Key == oldKey);
                    listViewEntry.Key = newKey;
                    listViewEntry.FirePropertyChanged("Key");
                }
                catch (Exception)
                {
                    // not in the list
                }
            }
            IsDirty = true;
            return(true);
        }
Ejemplo n.º 10
0
        public ListViewEntry AddKey(string key)
        {
            // add tothe global list
            try
            {
                ListViewEntry listViewEntry = collection.Single(s => s.Key == key);
                // if no exception, then we already have the key

                return(listViewEntry);
            }
            catch (Exception)
            {
                ListViewEntry listViewEntry = new ListViewEntry(key);
                collection.Add(listViewEntry);

                IsDirty = true;
                return(listViewEntry);
            }
        }
Ejemplo n.º 11
0
        //handlers
        private void DataProvider_DatumReplaced(int ndxDatum, IDatum newDatum)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <int, IDatum>(DataProvider_DatumReplaced), ndxDatum, newDatum);
            }
            else
            {
                var lvi = new ListViewEntry(newDatum.Content, ndxDatum);

                for (int i = 0; ; ++i)
                {
                    if ((m_lvData.Items[i] as ListViewEntry).DatumIndex == ndxDatum)
                    {
                        m_lvData.Items[i] = lvi;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void RenameSelected()
        {
            ListViewEntry entry = (ListViewEntry)listView.SelectedItem;

            if (entry != null)
            {
                DialogInput dialogInput = new DialogInput("Rename Key", entry.Key);
                dialogInput.Owner = this;
                if (dialogInput.ShowDialog() == true)
                {
                    string key = dialogInput.Answer;

                    bool result = LocalizationManager.GetInstance().RenameKey(entry.Key, key);

                    if (result == false)
                    {
                        MessageBox.Show("The key already exists", "Could not rename key", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }