private void InitializeGlobalCommands() { //Most commands like Delete, Cut, Copy and paste are all added to the MenuCommandService // by the other services like the DesignerHost. Commands like ViewCode and ShowProperties // need to be added by the IDE because only the IDE would know how to perform those actions. // This allows people to call MenuCommandSerice.GlobalInvoke( StandardCommands.ViewCode ); // from designers and what not. .Net Control Designers like the TableLayoutPanelDesigner // build up their own context menus instead of letting the MenuCommandService build it. // The context menus they build up are in the format that Visual studio expects and invokes // the ViewCode and Properties commands by using GlobalInvoke. AbstractFormsDesignerCommand viewCodeCommand = new ViewCode(); AbstractFormsDesignerCommand propertiesCodeCommand = new ShowProperties(); this.AddCommand(new MenuCommand(viewCodeCommand.CommandCallBack, viewCodeCommand.CommandID)); this.AddCommand(new MenuCommand(propertiesCodeCommand.CommandCallBack, propertiesCodeCommand.CommandID)); }
void HandleCursorChanged(object sender, EventArgs e) { TreeSelection selection = tree.Selection; TreeModel model; TreeIter iter; Value v; string type, info; View view = null; if (!selection.GetSelected(out model, out iter)) { return; } // Create a view based on what we got v = new Value(); store.GetValue(iter, 2, ref v); info = v.Val as string; v = new Value(); store.GetValue(iter, 1, ref v); type = v.Val as string; switch (type) { case "Class": Console.WriteLine("JB, We need your decompiler."); break; case "Resource": Resource res; v = new Value(); store.GetValue(iter, 3, ref v); res = v.Val as Resource; if (res != null) { view = new ViewResource(res); } else { Console.WriteLine("{0} didn't have a Resource, it had a {1}.", type, v.Val == null ? "null" : v.Val.GetType().ToString()); } break; case "Method": case "Getter": case "Setter": case "Remover": case "Adder": case "Invoker": case "Constructor": MethodDefinition def; v = new Value(); store.GetValue(iter, 3, ref v); def = v.Val as MethodDefinition; if (def != null) { view = new ViewCode(def); } else { Console.WriteLine("{0} didn't have a MethodDefinition.", type); } break; default: Console.WriteLine("Unhandled case: {0}", type); break; } // Remove old views and add the new one while (box.Children.Length > 1) { box.Remove(box.Children [1]); } if (view != null) { box.PackStart(view.GetView(), true, true, 0); box.ShowAll(); } }
private void ListBoxGetCodeItem_OnSelected(object sender, RoutedEventArgs e) { if (!(e.Source is ListBoxItem listBoxItem)) { return; } var path = "ViewCode"; var title = ""; switch (listBoxItem.Name) { case "GetCodeLinearSearch": title = "Linear Search"; path += "/LinearSearch.txt"; break; case "GetCodeBinarySearch": title = "Binary Search"; path += "/BinarySearch.txt"; break; case "GetCodeInterpolationSearch": title = "Interpolation Search"; path += "/InterpolationSearch.txt"; break; case "GetCodeInterchangeSort": title = "Interchange Sort"; path += "/InterchangeSort.txt"; break; case "GetCodeBubbleSort": title = "Bubble Sort"; path += "/BubbleSort.txt"; break; case "GetCodeSelectionSort": title = "Selection Sort"; path += "/SelectionSort.txt"; break; case "GetCodeInsertionSort": title = "Insertion Sort"; path += "/InsertionSort.txt"; break; case "GetCodeHeapSort": title = "Heap Sort"; path += "/HeapSort.txt"; break; case "GetCodeMergeSort": title = "Merge Sort"; path += "/MergeSort.txt"; break; case "GetCodeQuickSort": title = "Quick Sort"; path += "/QuickSort.txt"; break; default: path += "LinearSearch.txt"; break; } var viewCode = new ViewCode(title, path); viewCode.ShowDialog(); }
void HandleCursorChanged (object sender, EventArgs e) { TreeSelection selection = tree.Selection; TreeModel model; TreeIter iter; Value v; string type, info; View view = null; if (!selection.GetSelected (out model, out iter)) return; // Create a view based on what we got v = new Value (); store.GetValue (iter, 2, ref v); info = v.Val as string; v = new Value (); store.GetValue (iter, 1, ref v); type = v.Val as string; switch (type) { case "Class": Console.WriteLine ("JB, We need your decompiler."); break; case "Resource": Resource res; v = new Value (); store.GetValue (iter, 3, ref v); res = v.Val as Resource; if (res != null) { view = new ViewResource (res); } else { Console.WriteLine ("{0} didn't have a Resource, it had a {1}.", type, v.Val == null ? "null" : v.Val.GetType ().ToString ()); } break; case "Method": case "Getter": case "Setter": case "Remover": case "Adder": case "Invoker": case "Constructor": MethodDefinition def; v = new Value (); store.GetValue (iter, 3, ref v); def = v.Val as MethodDefinition; if (def != null) { view = new ViewCode (def); } else { Console.WriteLine ("{0} didn't have a MethodDefinition.", type); } break; default: Console.WriteLine ("Unhandled case: {0}", type); break; } // Remove old views and add the new one while (box.Children.Length > 1) box.Remove (box.Children [1]); if (view != null) { box.PackStart (view.GetView (), true, true, 0); box.ShowAll (); } }