static void Main(string[] args) { Thread u = new Thread(delegate() { ShellMenu menu = new ShellMenu(); }); u.Start(); }
public void AddClient(TcpClient newClient) { try { _clientPool.Add(new Client(newClient, this)); } catch (Exception) { ShellMenu.ShowError("eroare la adaugare client in clientPool"); } }
public DataController() { //ma conectez la serverul SQL this.connection = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); try { connection.Open(); } catch (SqlException e) { ShellMenu.ShowError(e.ToString()); } }
public void WriteLog(string s) { try { lock (padlock) { File.AppendAllText(_path, s + Environment.NewLine); } } catch (Exception e) { ShellMenu.ShowError(e.ToString()); } }
public Logger() { try { string name = RandomString(8, true) + ".log"; _path = System.IO.Directory.GetCurrentDirectory(); _path = System.IO.Path.Combine(_path, "logs"); System.IO.Directory.CreateDirectory(_path); _path = System.IO.Path.Combine(_path, name); }catch (Exception e) { ShellMenu.ShowError(e.ToString()); } }
public void StartListener() { try { while (true) { if (server.Pending()) { _clientPool.AddClient(server.AcceptTcpClient()); } } } catch (SocketException e) { ShellMenu.ShowError("SocketException: " + e); server.Stop(); } }
protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { if (folder == null) { throw new ArgumentNullException(nameof(folder)); } if (items == null) { throw new ArgumentNullException(nameof(items)); } if (appendMenu == null) { throw new ArgumentNullException(nameof(appendMenu)); } appendMenu.AddInvokeItemHandler(OnShellMenuItemInvoke); if (items.Count == 1 && !items[0].IsFolder) { // only for one non-folder item var modifyItem = new ShellMenuItem(appendMenu, "Modify..."); modifyItem.Tag = MenuCommand.Modify; modifyItem.IsDefault = true; appendMenu.Items.Add(modifyItem); } else { if (existingMenu.Items.FirstOrDefault(i => i.Text == "New") == null) { var newItem = new ShellMenuItem(appendMenu, "New"); appendMenu.Items.Add(newItem); newItem.Items.Add(new ShellMenuItem(appendMenu, "Key") { Tag = MenuCommand.NewKey }); newItem.Items.Add(new ShellMenuSeparatorItem()); newItem.Items.Add(new ShellMenuItem(appendMenu, "String Value") { Tag = MenuCommand.NewValueString }); newItem.Items.Add(new ShellMenuItem(appendMenu, "Binary Value") { Tag = MenuCommand.NewValueBinary }); newItem.Items.Add(new ShellMenuItem(appendMenu, "DWORD (32-bit) Value") { Tag = MenuCommand.NewValueDWord }); newItem.Items.Add(new ShellMenuItem(appendMenu, "QWORD (64-bit) Value") { Tag = MenuCommand.NewValueQWord }); newItem.Items.Add(new ShellMenuItem(appendMenu, "Multi-String Value") { Tag = MenuCommand.NewValueMultiString }); newItem.Items.Add(new ShellMenuItem(appendMenu, "Expandable String Value") { Tag = MenuCommand.NewValueExpandString }); } } if (items.Count > 0) { // add the "Send To" menu appendMenu.Items.Add(new ShellMenuSendToItem()); } }
private void BuildMenuCommandHierarchy(ICommandEx parentCommand, ICommandSourceParent commandVisual, ShellMenu shellMenu) { if (parentCommand != null) { ICommandSourceParent parentCommandVisual; if (_commandInformations.TryGetValue(parentCommand, out parentCommandVisual)) { parentCommandVisual.AddItem(commandVisual); return; } parentCommandVisual = new ShellMenuItem(parentCommand); parentCommandVisual.AddItem(commandVisual); _commandInformations.Add(parentCommand, parentCommandVisual); parentCommand = parentCommand.MenuCommandParent; BuildMenuCommandHierarchy(parentCommand, parentCommandVisual, shellMenu); } else { shellMenu.AddItem(commandVisual); } }
public MenuManager(ShellMenu applicationMenu) { _shellMenu = applicationMenu; _commandInformations = new Dictionary <ICommandEx, ICommandSourceParent>(); }
protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { if (folder.IsRoot && items.Count == 0) // context menu in Explorer's left TreeView { var properties = new ShellMenuItem(appendMenu, "&Properties"); properties.Invoke += OnRootProperties; appendMenu.Items.Add(properties); } else { // only with selected items if (items.Count > 0) { var folderItem = new ShellMenuItem(appendMenu, "Cloud Folder"); folderItem.BitmapPath = FolderServer.MenuIconBitmapPath; var clearLocal = new ShellMenuItem(appendMenu, "Free up space"); clearLocal.Verb = "CloudFolder.free"; clearLocal.Invoke += OnClearLocal; folderItem.Items.Add(clearLocal); var downloadLocally = new ShellMenuItem(appendMenu, "Download on this device"); downloadLocally.Verb = "CloudFolder.download"; downloadLocally.Invoke += DownloadLocally; folderItem.Items.Add(downloadLocally); var pushToServer = new ShellMenuItem(appendMenu, "Push to server"); pushToServer.Verb = "CloudFolder.push"; pushToServer.Invoke += PushToServer; folderItem.Items.Add(pushToServer); appendMenu.Items.Add(folderItem); // add the "Sent To" menu appendMenu.Items.Add(new ShellMenuSendToItem()); } } }
protected override void CreateInformationBarMenu(InformationBar bar, ShellMenu appendMenu) { var item = new ShellMenuItem(appendMenu, "What is my UAC level?"); appendMenu.Items.Add(item); }
protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { // because we don't rely on file system, we won't have the "new" menu automatically set for us // so we must build one, from the standard one // fortunately, there is a helper for that appendMenu.AddInvokeItemHandler(OnShellMenuItemInvoke); appendMenu.MergeNewMenu(); // once the new menu has been merged, remember what Id corresponds to what type of item and use that in the OnShellMenuItemInvoke method }
// context menu on the root folder protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { if (folder == null) { throw new ArgumentNullException(nameof(folder)); } if (items == null) { throw new ArgumentNullException(nameof(items)); } if (appendMenu == null) { throw new ArgumentNullException(nameof(appendMenu)); } if (items.Count == 0) // 0 means this is called from Explorer's tree view. We don't want to add the menus twice. { return; } var regeditItem = new ShellMenuItem(appendMenu, "Run &Regedit..."); regeditItem.Invoke += (sender, e) => Process.Start("regedit"); appendMenu.Items.Add(regeditItem); appendMenu.Items.Add(new ShellMenuSeparatorItem()); var propertiesItem = new ShellMenuItem(appendMenu, "&Properties..."); propertiesItem.Invoke += (sender, e) => ShowProperties(e.HwndOwner); appendMenu.Items.Add(propertiesItem); }
protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { // only with selected items if (items.OfType <SimplePngItem>().Count() > 0) { var clearLocal = new ShellMenuItem(appendMenu, "Clear Cache"); clearLocal.Invoke += (s, e) => { foreach (var item in e.Items.OfType <SimplePngItem>()) { item.ClearCache(); } }; appendMenu.Items.Add(clearLocal); } }
// context menu on the root folder protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu) { if (folder == null) { throw new ArgumentNullException(nameof(folder)); } if (items == null) { throw new ArgumentNullException(nameof(items)); } if (appendMenu == null) { throw new ArgumentNullException(nameof(appendMenu)); } if (items.Count == 0) // 0 means this is called from Explorer's tree view. We don't want to add the menus twice. { return; } // since we added ShellFolderInitializationOptions.AddSelfToContextMenu, we must use some verb (unique to us) to make sure our menu items are not duplicated var regeditItem = new ShellMenuItem(appendMenu, "Run &Regedit..."); regeditItem.Verb = "shellboost.sample.regedit"; regeditItem.Invoke += (sender, e) => Process.Start("regedit"); appendMenu.Items.Add(regeditItem); appendMenu.Items.Add(new ShellMenuSeparatorItem()); var propertiesItem = new ShellMenuItem(appendMenu, "&Properties..."); propertiesItem.Verb = "shellboost.sample.properties"; propertiesItem.Invoke += (sender, e) => ShowProperties(e.HwndOwner); appendMenu.Items.Add(propertiesItem); }