Esempio n. 1
0
        public JsonResult Menu()
        {
            string        userInfo = "";
            UserPrincipal up       = null;

            if (HttpContext.User != null && HttpContext.User.Identity.IsAuthenticated)
            {
                up = new UserPrincipal(HttpContext.User.Identity.Name, _accountRepository);

                userInfo = up.User.ContactInfo.FirstName + " " + up.User.ContactInfo.LastName;
            }

            string mainMenu = MenuBuilder.Build(Server.MapPath("~/Content/xml/menu.blog.xml"),
                                                Server.MapPath("~/Content/xsl/menu.xslt"),
                                                up,
                                                false,
                                                userInfo);

            string flyout = MenuBuilder.Build(Server.MapPath("~/Content/xml/menu.blog.xml"),
                                              Server.MapPath("~/Content/xsl/menu.xslt"),
                                              up,
                                              true,
                                              userInfo);

            return(Json(new { flyout, mainMenu }));
        }
Esempio n. 2
0
        public override MenuItem CreateMenuItem()
        {
            _baseItem = base.CreateMenuItem();

            // if no plugins found, disable the menu item
            if (!_plugins.Any())
            {
                _baseItem.Enabled = false;
                return(_baseItem);
            }

            var asBtn = _baseItem as ButtonMenuItem;

            if (asBtn != null)
            {
                foreach (var plugin in _plugins.OrderBy(p => p.PluginName))
                {
                    var newItem = new ButtonMenuItem
                    {
                        Text = plugin.PluginName
                    };

                    asBtn.Items.Add(newItem);

                    var subMenus = _menuBuilder.Build(plugin.UniqueId).ToList();
                    if (subMenus.Any())
                    {
                        newItem.Items.AddRange(subMenus);
                    }
                }
            }

            return(_baseItem);
        }
 public async Task OnlyMove()
 {
     await using RecordingTracker tracker = new();
     tracker.AddMove(file2, file2, "theExe", "theArguments", true, null);
     var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
     await Verifier.Verify(menu, settings);
 }
 public void OffTheActiveItem()
 {
     foreach (MenuItem item in MenuBuilder.Build(x => x.Position))
     {
         Console.WriteLine("> " + item.Title + "|" + MenuItem.Title + "|IsActM: " + MenuItem.IsActive);
         Console.WriteLine("---> item CssActive: " + item.CssActive + "|" + "MenuItem CssActive: " + MenuItem.CssActive);
         if (item.IsSubMenu == false && item.IsActive == true)
         {
             //Console.WriteLine("> " + item.Title + "|" + MenuItem.Title + "|IsAct: " + item.IsActive + "|IsActM: " + MenuItem.IsActive);
             item.IsActive  = false;
             item.CssActive = String.Empty;
         }
         else if (item.IsSubMenu == true)
         {
             //Console.WriteLine("> " + item.Title + "+");
             foreach (MenuItem itemSub in item.MenuItems.Build(x => x.Position))
             {
                 //Console.WriteLine(">> " + itemSub.Title);
                 if (itemSub.IsSubMenu == false && itemSub.IsActive == true)
                 {
                     itemSub.IsActive  = false;
                     itemSub.CssActive = String.Empty;
                 }
             }
         }
     }
 }
Esempio n. 5
0
 private void button_AddBeverage_Click_1(object sender, EventArgs e)
 {
     try
     {
         string Name           = textBox_NameBeverage.Text;
         int    Price          = int.Parse(textBox_Price.Text);
         bool   checkBeverages = MenuDAO.Instance.CheckExists(Name);
         if (checkBeverages)
         {
             MessageBox.Show("Đồ uống đã tồn tại", "Thông Báo");
         }
         else
         {
             IMenuBuilder menu = new MenuBuilder().SetName(Name).SetPrice(Price);
             MenuDAO.Instance.Create(menu.Build());
             textBox_BeverID.Clear();
             textBox_NameBeverage.Clear();
             textBox_Price.Clear();
             LoadListBeverages();
             MessageBox.Show("Thêm đồ uống thành công", "Thông Báo");
         }
     }
     catch
     {
         MessageBox.Show("Hãy điền đầy đủ thông tin đồ uống mà bạn muốn thêm", "Thông Báo");
     }
 }
 public async Task OnlyDelete()
 {
     await using RecordingTracker tracker = new();
     tracker.AddDelete(file1);
     var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
     await Verifier.Verify(menu, settings);
 }
Esempio n. 7
0
        /// <summary>
        /// Build the menu for displaying fixing
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public override MenuToDisplay GetFixMenu(MenuBuilder builder)
        {
            builder = base.GetFixMenu(builder).GetBuilder();

            builder.AddOption(Strings.FixStrings.Pipe.Sensor);
            return(builder.Build());
        }
Esempio n. 8
0
    public async Task Empty()
    {
        await using var tracker = new RecordingTracker();
        var menu = new ContextMenuStrip();

        MenuBuilder.Build(menu, () => { }, () => { }, tracker);
        await Verifier.Verify(menu, settings);
    }
 public async Task Grouped()
 {
     await using RecordingTracker tracker = new();
     tracker.AddDelete("file2.txt");
     tracker.AddMove(file4, "file4.txt", "theExe", "theArguments", true, null);
     var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
     await Verifier.Verify(menu, settings);
 }
Esempio n. 10
0
        /// <summary>
        /// Build the menu for displaying attacking
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public override MenuToDisplay GetAttackMenu(MenuBuilder builder)
        {
            builder = base.GetAttackMenu(builder).GetBuilder();

            builder.AddOption(Strings.AttackStrings.Reservoir.Drain);
            builder.AddOption(Strings.AttackStrings.Reservoir.Sensor);
            return(builder.Build());
        }
Esempio n. 11
0
        /// <summary>
        /// Build the menu for displaying attacking
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public override MenuToDisplay GetAttackMenu(MenuBuilder builder)
        {
            builder = base.GetAttackMenu(builder).GetBuilder();

            builder.AddOption(Strings.AttackStrings.Pump.Flow);
            builder.AddOption(Strings.AttackStrings.Pump.Sensor);
            return(builder.Build());
        }
Esempio n. 12
0
    static async Task Main()
    {
        Logging.Init();

        var settings = await GetSettings();

        if (settings == null)
        {
            return;
        }
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        var tokenSource  = new CancellationTokenSource();
        var cancellation = tokenSource.Token;

        using var mutex = new Mutex(true, "DiffEngine", out var createdNew);
        if (!createdNew)
        {
            Log.Information("Mutex already exists. Exiting.");
            return;
        }

        using var icon = new NotifyIcon
              {
                  Icon    = Images.Default,
                  Visible = true,
                  Text    = "DiffEngine"
              };

        var showMenu = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic) !;

        icon.MouseUp += (sender, args) =>
        {
            if (args.Button == MouseButtons.Left)
            {
                showMenu.Invoke(icon, null);
            }
        };

        await using var tracker = new Tracker(
                        active: () => icon.Icon   = Images.Active,
                        inactive: () => icon.Icon = Images.Default);

        using var task = StartServer(tracker, cancellation);

        using var keyRegister = new KeyRegister(icon.Handle());
        ReBindKeys(settings, keyRegister, tracker);

        icon.ContextMenuStrip = MenuBuilder.Build(
            Application.Exit,
            async() => await OptionsFormLauncher.Launch(keyRegister, tracker),
            tracker);

        Application.Run();
        tokenSource.Cancel();
        await task;
    }
Esempio n. 13
0
    public async Task OnlyDelete()
    {
        await using var tracker = new RecordingTracker();
        tracker.AddDelete(file1);
        var menu = new ContextMenuStrip();

        MenuBuilder.Build(menu, () => { }, () => { }, tracker);
        await Verifier.Verify(menu, settings);
    }
        private void InitializeComponent()
        {
            // XXX read these from a settings file
            this.Width  = 640;
            this.Height = 480;

            this.Text = "Manticore"; // XXX localize

            mMenuBuilder = new MenuBuilder("browser\\browser-menu.xml", this);
            mMenuBuilder.Build();
            mMenuBuilder.OnCommand += new EventHandler(OnMenuCommand);

            // Show the resize handle
            this.SizeGripStyle = SizeGripStyle.Auto;

            // Set up the Status Bar
            mStatusBar = new StatusBar();

            StatusBarPanel docStatePanel = new StatusBarPanel();

            mStatusPanel   = new StatusBarPanel();
            mProgressMeter = new StatusBarPanel();
            StatusBarPanel zonePanel = new StatusBarPanel();

            docStatePanel.Text    = "X";
            zonePanel.Text        = "Internet Region";
            mStatusPanel.Text     = "Document Done";
            mStatusPanel.AutoSize = StatusBarPanelAutoSize.Spring;


            mStatusBar.Panels.AddRange(new StatusBarPanel[] { docStatePanel, mStatusPanel, mProgressMeter, zonePanel });
            mStatusBar.ShowPanels = true;

            this.Controls.Add(mStatusBar);

            mToolbarBuilder = new BrowserToolbarBuilder("browser\\browser-toolbar.xml", this);

            mLocationBar                      = new LocationBar();
            mLocationBar.Top                  = mToolbarBuilder.Bounds.Top + mToolbarBuilder.Bounds.Height;
            mLocationBar.Left                 = 0;
            mLocationBar.Width                = ClientRectangle.Width;
            mLocationBar.Anchor               = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            mLocationBar.LocationBarCommit   += new LocationBar.LocationBarEventHandler(OnLocationCommit);
            mLocationBar.LocationBarModified += new LocationBar.LocationBarEventHandler(OnLocationModified);
            this.Controls.Add(mLocationBar);

            mWebBrowser        = new WebBrowser(this);
            mWebBrowser.Dock   = DockStyle.Bottom;
            mWebBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            mWebBrowser.Top    = mLocationBar.Top + mLocationBar.Height;
            mWebBrowser.Width  = ClientRectangle.Width;
            mWebBrowser.Height = ClientRectangle.Height - mWebBrowser.Top - mStatusBar.Height;
            this.Controls.Add(mWebBrowser);

            // Start Page handler
            this.VisibleChanged += new EventHandler(LoadStartPage);
        }
Esempio n. 15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     log = new Log(this);
     if (!IsPostBack && !DesignMode)
     {
         var menuBuilder = new MenuBuilder();
         lblMenu.Text = menuBuilder.Build(SiteMap.Providers["LearnixSiteMapProvider"].RootNode, Request);
     }
 }
Esempio n. 16
0
 public async Task Full()
 {
     await using var tracker = new RecordingTracker();
     tracker.AddDelete(file1);
     tracker.AddDelete(file2);
     tracker.AddMove(file3, file3, "theExe", "theArguments", true, null);
     tracker.AddMove(file4, file4, "theExe", "theArguments", true, null);
     var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
     await Verifier.Verify(menu, settings);
 }
Esempio n. 17
0
        static void MessageMenu()
        {
            var operations = new Dictionary <MessageOperationType, Action>()
            {
                //TODO
            };

            var menuBuilder = new MenuBuilder <MessageOperationType>("Message Menu", 1, operations);

            menuBuilder.Build();
        }
    public async Task Many()
    {
        await using RecordingTracker tracker = new();
        foreach (var file in EmptyFiles.AllFiles.AllPaths)
        {
            tracker.AddDelete(file);
        }

        var menu = MenuBuilder.Build(() => { }, () => { }, tracker);
        await Verifier.Verify(menu, settings);
    }
Esempio n. 19
0
        static void UserMenu()
        {
            var operations = new Dictionary <UserOperationType, Action>()
            {
                //TODO
            };

            var menuBuilder = new MenuBuilder <UserOperationType>("User Menu", 1, operations);

            menuBuilder.Build();
        }
Esempio n. 20
0
    public async Task FullGrouped()
    {
        await using var tracker = new RecordingTracker();
        tracker.AddDelete(file1);
        tracker.AddDelete("file2.txt");
        tracker.AddMove(file3, file3, "theExe", "theArguments", true, null);
        tracker.AddMove(file4, "file4.txt", "theExe", "theArguments", true, null);
        var menu = new ContextMenuStrip();

        MenuBuilder.Build(menu, () => { }, () => { }, tracker);
        await Verifier.Verify(menu, settings);
    }
Esempio n. 21
0
        static void Menu()
        {
            var operations = new Dictionary <OperationType.OperationType, Action>()
            {
                { OperationType.OperationType.Role, RoleMenu },
                { OperationType.OperationType.User, UserMenu },
                { OperationType.OperationType.Message, MessageMenu }
            };

            var menuBuilder = new MenuBuilder <OperationType.OperationType>("Menu", 0, operations);

            menuBuilder.Build();
        }
Esempio n. 22
0
        public VisualTreePouch(IEnumerable <IPluginRegistration> plugins, MenuBuilder menuBuilder)
        {
            _newViewDlg = ToolboxApp.Services.Get <RegisterNewViewDialog>();

            var views = plugins
                        .SelectMany(p => p.Views)
                        .OrderBy(o => o.Type.ShortName);

            var menuItems = menuBuilder.Build(MenuLocation.VisualTree, views);

            _editMenuItems = menuBuilder.Build(MenuLocation.VisualTree, views);

            var mis = menuItems?.ToArray();

            if (mis != null)
            {
                _newViewDlg.Register(mis);
                _newViewDlg.Register(_editMenuItems);
                _contextMenu = new ContextMenu(mis);
            }

            // Once the toolbox sends the visual tree, we'll show it.
            ToolboxApp.Bus.Listen <NewVisualTreeRootSet>(args =>
            {
                _views = 0;
                Application.Instance.Invoke(PopulateVisualTree);
            });

            ToolboxApp.Bus.Listen <ShowRegisterNewViewDialog>(args =>
            {
                _newViewDlg.Show();
            });

            ToolboxApp.Bus.Listen <ProjectFolderSetEvent>(args =>
            {
                _newViewDlg.Initialize();
            });
        }
Esempio n. 23
0
    public async Task Empty()
    {
        await using var tracker = new RecordingTracker();
        var menu = MenuBuilder.Build(
            () =>
        {
        },
            () =>
        {
        },
            tracker);

        await Verify(menu, settings);
    }
Esempio n. 24
0
        /// <inheritdoc/>
        public bool Initialize(string pluginFolder)
        {
            RengaApplication   = new Renga.Application();
            ActionEventSources = new List <Renga.ActionEventSource>();
            try
            {
                // init lang
                if (!Language.Initialize())
                {
                    return(false);
                }

                // statistic
                Statistic.SendPluginStarting("Renga", "4.0");

                // Принудительная загрузка сборок
                LoadAssemblies();
                UserConfigFile.InitConfigFile();
                LoadFunctions();

                MenuBuilder.Build(RengaApplication, ActionEventSources);

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                var disableConnectionWithLicenseServer = Variables.DisableConnectionWithLicenseServerInRenga;

                // license server
                if (Variables.IsLocalLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    ClientStarter.StartConnection(SupportedProduct.Renga);
                }

                if (Variables.IsWebLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.Renga);
                }

                // user info
                AuthorizationOnStartup();

                return(true);
            }
            catch (Exception exception)
            {
                RengaApplication.UI.ShowMessageBox(Renga.MessageIcon.MessageIcon_Error, "ModPlus", exception.Message);
                return(false);
            }
        }
Esempio n. 25
0
 /// <summary>
 /// Build the menu for displaying sensor information
 /// Dependent on if sensor is attacked
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public override MenuToDisplay GetInformation(MenuBuilder builder)
 {
     builder = base.GetInformation(builder).GetBuilder();
     if (this.SensorBroken)
     {
         builder.AddStringItem(Strings.HasFlow, Strings.Hacked);
         builder.AddStringItem(Strings.IsPurityAsExpected, Strings.Hacked);
     }
     else
     {
         builder.AddBoolItem(Strings.HasFlow, this.HasFlow);
         builder.AddBoolItem(Strings.IsPurityAsExpected, this.IsPurityAsExpected);
     }
     return(builder.Build());
 }
Esempio n. 26
0
        static void RoleMenu()
        {
            var operations = new Dictionary <RoleOperationType, Action>
            {
                { RoleOperationType.GetAll, RoleGetList },
                { RoleOperationType.GetByName, RoleGetByName },
                { RoleOperationType.Create, RoleCreate },
                { RoleOperationType.Update, RoleUpdate },
                { RoleOperationType.Delete, RoleDelete },
                { RoleOperationType.AssociateWithUser, RoleAssociate },
                { RoleOperationType.UnAssociateWithUser, RoleUnAssociate }
            };

            var menuBuilder = new MenuBuilder <RoleOperationType>("Role Menu", 1, operations);

            menuBuilder.Build();
        }
Esempio n. 27
0
        private IEnumerable <MenuItem> BuildAddOnMenu()
        {
            var menuRequests = _menuChangers.Select(x => new
            {
                StartMenu      = new MenuBuilder(),
                MenuConfigurer = x.Configure()
            }).ToList();

            var menuItems = menuRequests.SelectMany(rq =>
            {
                rq.MenuConfigurer(rq.StartMenu);
                return(rq.StartMenu.Build());
            });

            var addons = new MenuBuilder();

            addons.AddDropdown("Add-Ons").AddItems(menuItems);
            return(addons.Build());
        }
Esempio n. 28
0
        public ActionResult Menu(bool isFlyout = false)
        {
            string        userInfo = "";
            UserPrincipal up       = null;

            if (HttpContext.User != null && HttpContext.User.Identity.IsAuthenticated)
            {
                up = new UserPrincipal(HttpContext.User.Identity.Name, _accountRepository);

                userInfo = up.User.ContactInfo.FirstName + " " + up.User.ContactInfo.LastName;
            }
            string menu = MenuBuilder.Build(Server.MapPath("~/Content/xml/menu.blog.xml"),
                                            Server.MapPath("~/Content/xsl/menu.xslt"),
                                            up,
                                            isFlyout,
                                            userInfo);

            return(Content(menu));
        }
Esempio n. 29
0
        public FilesFolderPouch(MenuBuilder menuBuilder, IFileSystemTraverser fileSystemTraverser, LoadProjectDialog loadProject)
        {
            _fileSystemTraverser = fileSystemTraverser;
            _loadProject         = loadProject;

            var menuItems = menuBuilder.Build(MenuLocation.FilesFolders);

            // can be null when no plugins are loaded.
            if (menuItems != null)
            {
                _contextMenu = new ContextMenu(menuItems);
            }

            // layout that's displayed when the actionbar's "Minimize" button is clicked.
            _minLayout = CreateMinimizeLayout();

            // reference to the layout that is always visible
            _visibleLayout = new Panel();
        }
Esempio n. 30
0
    /// <summary>
    /// Gets what to display for the expected values popup
    /// </summary>
    /// <param name="builder"></param>
    /// <returns></returns>
    public MenuToDisplay GetExpectedValuesPopup(MenuBuilder builder)
    {
        builder.SetTitle(this.GetType().Name.ToString() + " Expected");

        builder.AddBoolItem(Strings.HasFlow, this.ExpectedValues.HasFlow);
        builder.AddBoolItem(Strings.IsPurityAsExpected, this.ExpectedValues.IsPurityAsExpected);

        if (this.GetType() == typeof(Pump))
        {
            builder.AddBoolItem(Strings.IsPumping, this.ExpectedValues.IsPumping);
        }

        if (this.GetType() == typeof(Reservoir))
        {
            builder.AddBoolItem(Strings.IsFull, this.ExpectedValues.IsFull);
            builder.AddBoolItem(Strings.IsEmpty, this.ExpectedValues.IsEmpty);
        }
        return(builder.Build());
    }
        public PackageTreeNodeViewModel(Object model, PackageDatabaseTreeViewModel parent, CompositionContainer container, String assetType)
        {
            this._parent = parent;
            this._contextMenuTopLevelItems = new ObservableCollection<MenuItemViewModel>();
            this._children = new ObservableCollection<PackageTreeNodeViewModel>();
            this.Model = model;

            var menuItemImports = container.GetExports<IMenuItem, IContextMenuItemMetaData>();
            var globalCommandImports = container.GetExports<IGlobalCommand>();

            var menuBuilder = new MenuBuilder(globalCommandImports);

            foreach (var import in menuItemImports.Where(x => x.Metadata.AssetType == assetType))
            {
                if (import.Metadata.IsPrimary)
                {
                    this.PrimaryCommand = import.Value.Command;
                }

                menuBuilder.AddItem(import.Value, import.Metadata);
            }

            foreach (var rootItem in menuBuilder.Build().Children)
            {
                MenuItemViewModel viewModel;

                if (rootItem is MenuSeparatorModel)
                {
                    viewModel = new MenuSeparatorViewModel();
                }
                else
                {
                    viewModel = new MenuItemViewModel(this.Model, rootItem.HeaderText, rootItem.Command, rootItem.GestureText, rootItem.Children);
                }

                _contextMenuTopLevelItems.Add(viewModel);
            }
        }