public iPhoneDiskApplication() { #region GUI preparation Text = "jPhone"; MaximizeBox = false; Size = new Size(nDefaultWidth, nHeightWithoutDebugLog); FormBorderStyle = FormBorderStyle.FixedSingle; ShowIcon = true; iApplication = new Icon(GetType(), "jphone.icons.icon.ico"); Icon = iApplication; FormClosing += new FormClosingEventHandler(iPhoneDiskApplication_FormClosing); SizeChanged += new EventHandler(iPhoneDiskApplication_SizeChanged); Show(); niTrayIcon = new NotifyIcon(); niTrayIcon.Text = "jPhone"; niTrayIcon.Icon = Icon; niTrayIcon.Click += new EventHandler(niTrayIcon_Click); lbText = new Label(); lbText.AutoSize = true; lbText.Location = new Point(10, 10); lbText.Text = "Select the iPhone, iPod Touch or iPad to mount:"; cbDeviceList = new ComboBox(); cbDeviceList.Location = new Point(lbText.Left + 5, lbText.Bottom); cbDeviceList.Width = 320; cbDeviceList.DropDownStyle = ComboBoxStyle.DropDownList; buMount = new Button(); buMount.Location = new Point(cbDeviceList.Right + 15, cbDeviceList.Top - 3); buMount.Size = new Size(80, 25); buMount.Click += new EventHandler(buMount_Click); buMount.Enabled = false; cmOptions = new ContextMenuStrip(); cmOptions.RenderMode = ToolStripRenderMode.System; cmOptions.ShowImageMargin = false; cmOptions.ShowCheckMargin = true; tsmiAutomount = new ToolStripMenuItem("Automount", null, (s, e) => { tsmiAutomount.Checked = !tsmiAutomount.Checked; }); tsmiMinimizeToTray = new ToolStripMenuItem("Minimize to tray", null, (s, e) => { tsmiMinimizeToTray.Checked = !tsmiMinimizeToTray.Checked; }); tsmiShowDebugLog = new ToolStripMenuItem("Show debug log", null, (s, e) => { tsmiShowDebugLog.Checked = !tsmiShowDebugLog.Checked; if (bShowDebugLog) Height = nHeightWithDebugLog; else Height = nHeightWithoutDebugLog; }); tsmiReapplyLibUSBFilters = new ToolStripMenuItem("Re-apply libusb filters", null, ReapplyLibUSBFilters_Click); cmOptions.Items.Add(tsmiAutomount); cmOptions.Items.Add(tsmiShowDebugLog); cmOptions.Items.Add(tsmiMinimizeToTray); cmOptions.Items.Add("-"); cmOptions.Items.Add(tsmiReapplyLibUSBFilters); buOptions = new Button(); buOptions.Location = new Point(buMount.Right + 5, buMount.Top); buOptions.Size = new Size(80, 25); buOptions.Text = "Options"; buOptions.Click += (s, e) => { cmOptions.Show(PointToScreen(new Point(buOptions.Left, buOptions.Bottom))); }; bool[] bOptions = GetRegistryOptions(); tsmiAutomount.Checked = bOptions[0]; tsmiShowDebugLog.Checked = bOptions[1]; tsmiMinimizeToTray.Checked = bOptions[2]; if (bShowDebugLog) Height = nHeightWithDebugLog; tbDebugLog = new TextBox(); tbDebugLog.ReadOnly = true; tbDebugLog.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; tbDebugLog.Location = new Point(10, 75); tbDebugLog.Size = new Size(ClientSize.Width - 20, nHeightWithDebugLog - 145); tbDebugLog.Multiline = true; tbDebugLog.BorderStyle = BorderStyle.FixedSingle; tbDebugLog.ScrollBars = ScrollBars.Vertical; sbStatus = new StatusBar(); sbStatus.Dock = DockStyle.Bottom; sbStatus.SizingGrip = false; sbStatus.ShowPanels = true; sbpDeviceCount = new StatusBarPanel(); sbpDeviceCount.Width = 150; sbpDeviceCount.Alignment = HorizontalAlignment.Center; sbpMountStatus = new StatusBarPanel(); sbpMountStatus.AutoSize = StatusBarPanelAutoSize.Spring; sbpMountStatus.Alignment = HorizontalAlignment.Center; sbStatus.Panels.Add(sbpDeviceCount); sbStatus.Panels.Add(sbpMountStatus); Controls.AddRange(new Control[] { lbText, cbDeviceList, buMount, buOptions, sbStatus, tbDebugLog }); cbDeviceList.Select(); #endregion Global.LogUpdated += new Global.LogEventHandler(Global_LogUpdated); USBNotifier.OnDeviceNotify += new EventHandler<DeviceNotifyEventArgs>(USBNotifier_OnDeviceNotify); Global.Log("jPhone 1.0: iPhone mounting utility. Copyright 2010 Jonathan Bergknoff.\n"); Global.Log("Shift-click the mount button to mount a jailbroken device as root.\n"); Global.Log("http://www.getjpod.com/jphone\n"); // Initialize everything to an unmounted state. UnmountDevice(); PopulateDeviceList(); TryAutomount(); }
private void presentRightClickMenu(ContextMenuStrip menu) { //clear all items currently in the menu menu.Items.Clear(); //is anything selected? if (p_Tree.SelectedNode == null) { return; } //position the menu where the mouse is menu.SetBounds(Cursor.Position.X, Cursor.Position.Y, menu.Width, menu.Height); menu.Hide(); menu.Show(); //get the selected tag object tag = p_Tree.SelectedNode.Tag; /*Solution entry*/ if (tag is Solution) { return; } /*ProjectEntity/Project items*/ if (tag is Project || tag is ProjectDirectory) { ToolStripMenuItem add = (ToolStripMenuItem)menu.Items.Add("Add", null); add.DropDownItems.Add(getRightClickItem_Add_NewItem()); add.DropDownItems.Add(getRightClickItem_Add_ExistingItem()); add.DropDownItems.Add(getRightClickItem_Add_NewFolder()); menu.Items.Add(new ToolStripSeparator()); } #region Clipboard ToolStripItem cut = menu.Items.Add("Cut", Icons.GetBitmap("menu.cut", 16), null); ToolStripItem copy = menu.Items.Add("Copy", Icons.GetBitmap("menu.copy", 16), null); ToolStripItem paste = menu.Items.Add("Paste", Icons.GetBitmap("menu.paste", 16), null); menu.Items.Add(getRightClickItem_Delete()); menu.Items.Add(new ToolStripSeparator()); #endregion }