public void ComEnumeratorTest8() { var oc = new IObjectCollection(); SHCreateItemFromParsingName(PInvoke.Tests.AdvApi32Tests.fn, null, typeof(IShellItem).GUID, out object ppv); Assert.That(ppv, Is.Not.Null); Assert.That(oc.GetCount(), Is.Zero); oc.AddObject(ppv); var oa = (IObjectArray)oc; // Test IEnumerable var e = new IEnumFromIndexer <IShellItem>(oa.GetCount, i => (IShellItem)oa.GetAt(i, typeof(IShellItem).GUID), 0); var c = 0; foreach (var pd in e) { Assert.IsInstanceOf <IShellItem>(pd); TestContext.WriteLine(pd.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVE)); c++; } Assert.That(c, Is.EqualTo(oa.GetCount())); // Test IEnumerator var g = e.GetEnumerator(); g.Reset(); Assert.That(g.MoveNext(), Is.True); g.Dispose(); Assert.That(g.MoveNext(), Is.False); }
/// <summary> /// Construtor /// </summary> /// <param name="collection">Colletion of objects</param> /// <param name="processor">Differential equation proessor</param> public StateTransformer(IObjectCollection collection, IDifferentialEquationProcessor processor) : this(collection, processor, null) { provider = this; processor.TimeProvider = provider; }
private static void AddUserTasks(ICustomDestinationList custom_destinationd_list) { IObjectCollection object_collection = (IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.EnumerableObjectCollection)); IShellLink search_notes = CreateShellLink(Catalog.GetString("Search All Notes"), tomboy_path, "--search", System.IO.Path.Combine(icons_path, SearchIcon), -1); if (search_notes != null) { object_collection.AddObject(search_notes); } //IShellLink new_notebook = CreateShellLink("New Notebook", topmboy_path, "--new-notebook", // icons_path, (int)TomboyIcons.NewNotebook); //if (new_notebook != null) // object_collection.AddObject(new_notebook); IShellLink new_note = CreateShellLink(Catalog.GetString("Create New Note"), tomboy_path, "--new-note", System.IO.Path.Combine(icons_path, NewNoteIcon), -1); if (new_note != null) { object_collection.AddObject(new_note); } custom_destinationd_list.AddUserTasks((IObjectArray)object_collection); Marshal.ReleaseComObject(object_collection); object_collection = null; }
/// <summary> /// Construtor /// </summary> /// <param name="collection">Collection</param> protected AbstractDoubleTransformer(IObjectCollection collection) { runtime = StaticExtensionDataPerformerPortable.Factory.Create(collection, 0); this.collection = collection; SetEvents(); type = new ArrayReturnType(a, new int[] { 1 }, true); }
private void button1_Click(object sender, EventArgs e) { try { MTSSystem = new RtSystem(); MTSSystem.Connect("", "AppName", "Appname"); IObjectCollection Names = MTSSystem.StationNames; foreach (var key in Names) { INamed N = (INamed)key; comboBox1.Items.Add(N.KeyName); } comboBox1.SelectedIndex = 0; string name = comboBox1.Items[0].ToString(); Debug.WriteLine("Station name is: " + name); Station = MTSSystem.FindStation(name, "AppName", "", oEnumAppType.oAppSummary); Debug.WriteLine(Station.Channels.Count); } catch (Exception err) { MessageBox.Show("DANGER WILL ROBINSON--" + err.ToString()); } }
public EasyPhony(IObjectCollection _house, IGangsterProvider _provider) : base(_house) { Name = "easy phony"; m_provider = _provider; m_magnum.ShowCrosshair = false; }
public Row(SequenceControl parent, IObjectCollection objectColection, Column column, List <Cell> cellList) : base(parent) { ObjectCollection = objectColection; _column = column; Cells = cellList; ObjectCollection.onSetObject += OnSetObject; _column.Add(this); }
public RootScope(Context context) { _context = context; _functions = new FunctionCollection(); _variables = new VariableCollection(); _classes = new ClassCollection(); _objects = new ObjectCollection(); _arrays = new ArrayCollection(); StandardLibrary.Populate(_functions); StandardLibrary.Populate(_variables); }
internal void RefreshTasks(ICustomDestinationList destinationList) { if (_tasks.Count == 0) { return; } IObjectCollection taskCollection = (IObjectCollection) new CEnumerableObjectCollection(); foreach (IJumpListTask task in _tasks) { taskCollection.AddObject(task.GetShellRepresentation()); } destinationList.AddUserTasks((IObjectArray)taskCollection); }
// Builds the collection of task items and adds them to the Task section of the Jump List. All tasks should be added to the canonical // "Tasks" category by calling ICustomDestinationList::AddUserTasks. private static void _AddTasksToList(ICustomDestinationList pcdl) { var poc = new IObjectCollection(); var psl = _CreateShellLink("/Task1", "Task 1"); poc.AddObject(psl); psl = _CreateShellLink("/Task2", "Second Task"); poc.AddObject(psl); psl = _CreateSeparatorLink(); poc.AddObject(psl); psl = _CreateShellLink("/Task3", "Task 3"); poc.AddObject(psl); var poa = (IObjectArray)poc; // Add the tasks to the Jump List. Tasks always appear in the canonical "Tasks" category that is displayed at the bottom of the // Jump List, after all other categories. pcdl.AddUserTasks(poa); }
internal void RefreshDestinations(ICustomDestinationList destinationList) { if (_categorizedDestinations.Count == 0) { return; } foreach (int key in _categorizedDestinations.Keys) { IObjectCollection categoryContents = (IObjectCollection) new CEnumerableObjectCollection(); var destinations = _categorizedDestinations[key]; foreach (IJumpListDestination destination in destinations) { categoryContents.AddObject(destination.GetShellRepresentation()); } destinationList.AppendCategory( destinations.First().Category, (IObjectArray)categoryContents); } }
private void AppendTaskList() { if (userTasks == null || userTasks.Count == 0) { return; } IObjectCollection taskContent = (IObjectCollection) new CEnumerableObjectCollection(); // Add each task's shell representation to the object array foreach (IJumpListTask task in userTasks) { if (task is JumpListLink) { taskContent.AddObject(((JumpListLink)task).NativeShellLink); } else if (task is JumpListSeparator) { taskContent.AddObject(((JumpListSeparator)task).NativeShellLink); } } // Add tasks to the taskbar HRESULT hr = customDestinationList.AddUserTasks((IObjectArray)taskContent); if (!CoreErrorHelper.Succeeded((int)hr)) { if ((uint)hr == 0x80040F03) { throw new InvalidOperationException("The file type is not registered with this application."); } else { Marshal.ThrowExceptionForHR((int)hr); } } }
// Adds a custom category to the Jump List. Each item that should be in the category is added to an ordered collection, and then the // category is appended to the Jump List as a whole. private static void _AddCategoryToList(ICustomDestinationList pcdl, IObjectArray poaRemoved) { var poc = new IObjectCollection(); foreach (var fn in c_rgpszFiles) { if (SHCreateItemInKnownFolder(KNOWNFOLDERID.FOLDERID_Documents.Guid(), KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, fn, typeof(IShellItem).GUID, out var ppv).Succeeded) { var psi = ppv as IShellItem; // Items listed in the removed list may not be re-added to the Jump List during this list-building transaction. They // should not be re-added to the Jump List until the user has used the item again. The AppendCategory call below will // fail if an attempt to add an item in the removed list is made. if (!_IsItemInArray(psi, poaRemoved)) { poc.AddObject(psi); } } // Add the category to the Jump List. If there were more categories, they would appear from top to bottom in the order they // were appended. pcdl.AppendCategory("Custom Category", poc); } }
private void AppendTaskList() { if (userTasks == null || userTasks.Count == 0) { return; } IObjectCollection taskContent = (IObjectCollection) new CEnumerableObjectCollection(); // Add each task's shell representation to the object array foreach (JumpListTask task in userTasks) { JumpListSeparator seperator; JumpListLink link = task as JumpListLink; if (link != null) { taskContent.AddObject(link.NativeShellLink); } else if ((seperator = task as JumpListSeparator) != null) { taskContent.AddObject(seperator.NativeShellLink); } } // Add tasks to the taskbar HResult hr = customDestinationList.AddUserTasks((IObjectArray)taskContent); if (!CoreErrorHelper.Succeeded(hr)) { if ((uint)hr == 0x80040F03) { throw new InvalidOperationException(LocalizedMessages.JumpListFileTypeNotRegistered); } throw new ShellException(hr); } }
private static void AddCategory(ICustomDestinationList cdl, string category, List <JumpList._ShellObjectPair> jumpItems, List <JumpItem> successList, List <JumpList._RejectedJumpItemPair> rejectionList, bool isHeterogenous) { IObjectCollection objectCollection = (IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("2d3468c1-36a7-43b6-ac24-d3f02fd9607a"))); foreach (JumpList._ShellObjectPair shellObjectPair in jumpItems) { objectCollection.AddObject(shellObjectPair.ShellObject); } HRESULT hrLeft; if (string.IsNullOrEmpty(category)) { hrLeft = cdl.AddUserTasks(objectCollection); } else { hrLeft = cdl.AppendCategory(category, objectCollection); } if (hrLeft.Succeeded) { int num = jumpItems.Count; while (--num >= 0) { successList.Add(jumpItems[num].JumpItem); } return; } if (isHeterogenous && hrLeft == HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER) { Utility.SafeRelease <IObjectCollection>(ref objectCollection); List <JumpList._ShellObjectPair> list = new List <JumpList._ShellObjectPair>(); foreach (JumpList._ShellObjectPair shellObjectPair2 in jumpItems) { if (shellObjectPair2.JumpItem is JumpPath) { rejectionList.Add(new JumpList._RejectedJumpItemPair { JumpItem = shellObjectPair2.JumpItem, Reason = JumpItemRejectionReason.NoRegisteredHandler }); } else { list.Add(shellObjectPair2); } } if (list.Count > 0) { JumpList.AddCategory(cdl, category, list, successList, rejectionList, false); return; } } else { foreach (JumpList._ShellObjectPair shellObjectPair3 in jumpItems) { rejectionList.Add(new JumpList._RejectedJumpItemPair { JumpItem = shellObjectPair3.JumpItem, Reason = JumpItemRejectionReason.InvalidItem }); } } }
private void AppendCustomCategories() { // Initialize our current index in the custom categories list int currentIndex = 0; // Keep track whether we add the Known Categories to our list bool knownCategoriesAdded = false; if (customCategoriesCollection != null) { // Append each category to list foreach (JumpListCustomCategory category in customCategoriesCollection) { // If our current index is same as the KnownCategory OrdinalPosition, // append the Known Categories if (!knownCategoriesAdded && currentIndex == KnownCategoryOrdinalPosition) { AppendKnownCategories(); knownCategoriesAdded = true; } // Don't process empty categories if (category.JumpListItems.Count == 0) { continue; } IObjectCollection categoryContent = (IObjectCollection) new CEnumerableObjectCollection(); // Add each link's shell representation to the object array foreach (IJumpListItem link in category.JumpListItems) { JumpListItem listItem = link as JumpListItem; JumpListLink listLink = link as JumpListLink; if (listItem != null) { categoryContent.AddObject(listItem.NativeShellItem); } else if (listLink != null) { categoryContent.AddObject(listLink.NativeShellLink); } } // Add current category to destination list HResult hr = customDestinationList.AppendCategory( category.Name, (IObjectArray)categoryContent); if (!CoreErrorHelper.Succeeded(hr)) { if ((uint)hr == 0x80040F03) { throw new InvalidOperationException(LocalizedMessages.JumpListFileTypeNotRegistered); } else if ((uint)hr == 0x80070005 /*E_ACCESSDENIED*/) { // If the recent documents tracking is turned off by the user, // custom categories or items to an existing category cannot be added. // The recent documents tracking can be changed via: // 1. Group Policy “Do not keep history of recently opened documents”. // 2. Via the user setting “Store and display recently opened items in // the Start menu and the taskbar” in the Start menu property dialog. // throw new UnauthorizedAccessException(LocalizedMessages.JumpListCustomCategoriesDisabled); } throw new ShellException(hr); } // Increase our current index currentIndex++; } } // If the ordinal position was out of range, append the Known Categories // at the end if (!knownCategoriesAdded) { AppendKnownCategories(); } }
/// <summary> /// Construtor /// </summary> /// <param name="collection">Collection of objects</param> public StateVariableTransformer(IObjectCollection collection) : base(collection) { }
private void AddRow(IObjectCollection collection) { _rowsList.Add(new Row(this, collection, Columns[0], new List <Cell>( ))); }
public Gangster(IObjectCollection _house) { m_magnum = new Magnum(_house); m_magnum.Owner = this; m_house = _house; }
/// <summary> /// Construtor /// </summary> /// <param name="collection">Colletion of objects</param> /// <param name="processor">Differential equation proessor</param> /// <param name="provider">Provider of time</param> protected StateTransformer(IObjectCollection collection, IDifferentialEquationProcessor processor, ITimeMeasureProvider provider) : base(collection) { this.processor = processor; this.provider = provider; }
/// <summary> /// Construtor /// </summary> /// <param name="collection">Colletion of objects</param> public StateTransformer(IObjectCollection collection) : this(collection, new InternalRungeProcessor()) { }
public void Apply() { BeginList(); try { if (active == null) { active = new List <JumpItemTask>(); } if (active.Count > 0) { foreach (var t in active) { t.Dispose(); } active.Clear(); } var count = tasks.Count; if (count > 0) { IObjectCollection content = null; var categories = new Dictionary <string, IObjectCollection>(); for (var i = 0; i < count; ++i) { var t = tasks[i]; if (i > 0) { if (tasks[i - 1].CustomCategory != t.CustomCategory) { content = null; } } if (content == null) { var c = t.CustomCategory; if (c == null) { c = ""; } if (!categories.TryGetValue(c, out content)) { content = categories[c] = (IObjectCollection) new CEnumerableObjectCollection(); } } var jit = new JumpItemTask(t); active.Add(jit); content.AddObject(jit.NativeShellLink); } foreach (var k in categories.Keys) { if (k.Length == 0) { list.AddUserTasks((IObjectArray)categories[k]); } else { var r = list.AppendCategory(k, (IObjectArray)categories[k]); if (r < 0) { if (r == -2147024891) //denied (tracking of recent files is disabled) { throw new CustomCategoryException(); } throw Marshal.GetExceptionForHR(r); } } } } } finally { list.CommitList(); } }
private static void AddRecentNotes(ICustomDestinationList custom_destinationd_list, NoteManager note_manager, uint slots) { IObjectCollection object_collection = (IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.EnumerableObjectCollection)); // Prevent template notes from appearing in the menu Tag template_tag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag); uint index = 0; foreach (Note note in note_manager.Notes) { if (note.IsSpecial) { continue; } // Skip template notes if (note.ContainsTag(template_tag)) { continue; } string note_title = note.Title; if (note.IsNew) { note_title = String.Format(Catalog.GetString("{0} (new)"), note_title); } IShellLink note_link = CreateShellLink(note_title, tomboy_path, "--open-note " + note.Uri, System.IO.Path.Combine(icons_path, NoteIcon), -1); if (note_link != null) { object_collection.AddObject(note_link); } if (++index == slots - 1) { break; } } // Add Start Here note Note start_note = note_manager.FindByUri(NoteManager.StartNoteUri); if (start_note != null) { IShellLink start_note_link = CreateShellLink(start_note.Title, tomboy_path, "--open-note " + NoteManager.StartNoteUri, System.IO.Path.Combine(icons_path, NoteIcon), -1); if (start_note_link != null) { object_collection.AddObject(start_note_link); } } custom_destinationd_list.AppendCategory(Catalog.GetString("Recent Notes"), (IObjectArray)object_collection); Marshal.ReleaseComObject(object_collection); object_collection = null; }