コード例 #1
0
		public override void ExecuteWithResourceItems(System.Collections.Generic.IEnumerable<ResourceItem> resourceItems)
		{
			var editor = ResourceEditor;
			OpenFileDialog fdiag = new OpenFileDialog();
			fdiag.AddExtension = true;
			fdiag.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.AllFiles}|*.*");
			fdiag.Multiselect = true;
			fdiag.CheckFileExists = true;
			
			if ((bool)fdiag.ShowDialog()) {
				foreach (string filename in fdiag.FileNames) {
					string oresname = Path.ChangeExtension(Path.GetFileName(filename), null);
					if (oresname == "")
						oresname = "new";
					
					string resname = oresname;
					
					int i = 0;
					TestName:
					if (editor.ContainsResourceName(resname)) {
						if (i == 10) {
							continue;
						}
						i++;
						resname = oresname + "_" + i;
						goto TestName;
					}
					
					object tmp = LoadResource(filename);
					if (tmp == null) {
						continue;
					}
					var newResourceItem = new ResourceItem(editor, resname, tmp);
					newResourceItem.IsNew = true;
					editor.ResourceItems.Add(newResourceItem);
					editor.SelectItem(newResourceItem);
				}
			}
		}
コード例 #2
0
        public void Paste()
        {
            IDataObject dob = Clipboard.GetDataObject();

            if (dob == null)
            {
                return;
            }

            if (dob.GetDataPresent(typeof(Hashtable).FullName))
            {
                Hashtable tmphash = (Hashtable)dob.GetData(typeof(Hashtable));
                foreach (DictionaryEntry entry in tmphash)
                {
                    object       resourceValue = GetClonedResource(entry.Value);
                    ResourceItem item;

                    if (!resourceItemNames.Contains((string)entry.Key))
                    {
                        item = new ResourceItem(this, entry.Key.ToString(), resourceValue);
                    }
                    else
                    {
                        int    count       = 1;
                        string newNameBase = entry.Key + " ";
                        string newName     = newNameBase + count;

                        while (resourceItemNames.Contains(newName))
                        {
                            count++;
                            newName = newNameBase + count;
                        }
                        item = new ResourceItem(this, newName, resourceValue);
                    }
                    resourceItems.Add(item);
                    SelectItem(item);
                }
            }
        }
コード例 #3
0
 public void SelectItem(ResourceItem item)
 {
     view.SelectItem(item);
 }
コード例 #4
0
		public void SelectItem(ResourceItem item)
		{
			SelectedItems.Clear();
			SelectedItems.Add(item);
			resourceItemsListView.ScrollIntoView(item);
		}
コード例 #5
0
		void Button_Click(object sender, RoutedEventArgs e)
		{
			if (resourceItem != null) {
				if (resourceItem.UpdateFromFile()) {
					ResourceItem = resourceItem;
				}
			}
		}
コード例 #6
0
		public void Paste()
		{
			IDataObject dob = Clipboard.GetDataObject();
			if (dob == null)
				return;
			
			if (dob.GetDataPresent(typeof(Hashtable).FullName)) {
				Hashtable tmphash = (Hashtable)dob.GetData(typeof(Hashtable));
				foreach (DictionaryEntry entry in tmphash) {
					object resourceValue = GetClonedResource(entry.Value);
					ResourceItem item;
					
					if (!resourceItemNames.Contains((string)entry.Key)) {
						item = new ResourceItem(this, entry.Key.ToString(), resourceValue);
					} else {
						int count = 1;
						string newNameBase = entry.Key + " ";
						string newName = newNameBase + count;
						
						while (resourceItemNames.Contains(newName)) {
							count++;
							newName = newNameBase + count;
						}
						item = new ResourceItem(this, newName, resourceValue);
					}
					resourceItems.Add(item);
					SelectItem(item);
				}
			}
		}
コード例 #7
0
		public void AddBooleanEntry()
		{
			int count = 1;
			string newNameBase = "New boolean entry ";
			string newName = newNameBase + count;
			
			while (ContainsResourceName(newName)) {
				count++;
				newName = newNameBase + count;
			}
			
			var selectedItem = GetSelectedItems().FirstOrDefault();
			ResourceItem item = new ResourceItem(this, newName, false);
			item.IsNew = true;
			if (selectedItem != null)
				item.SortingCriteria = selectedItem.Name;
			else
				item.SortingCriteria = item.Name;
			ResourceItems.Add(item);
			SelectItem(item);
			StartEditing();
		}
コード例 #8
0
		public void StartEditing()
		{
			// Start editing currently selected item
			var firstSelectedItem = SelectedItems.OfType<ResourceItem>().FirstOrDefault();
			if (firstSelectedItem != null) {
				editedResourceItem = firstSelectedItem;
				originalNameOfEditedItem = editedResourceItem.Name;
				firstSelectedItem.IsEditing = true;
			}
		}
コード例 #9
0
		public void SelectItem(ResourceItem item)
		{
			view.SelectItem(item);
		}