Beispiel #1
0
        private void _InitTasks()
        {
            if (App.Current.CommandManager != null)
            {
                TasksStack.Children.Clear();

                string categoryName = ((PageBase)this._Page).PageCommandsCategoryName;
                Debug.Assert(!String.IsNullOrEmpty(categoryName));

                ICollection <AppCommands.ICommand> commands = App.Current.CommandManager.GetCategoryCommands(categoryName);
                if (0 < commands.Count)
                {
                    foreach (ESRI.ArcLogistics.App.Commands.ICommand command in commands)
                    {
                        System.Windows.Controls.Button button = null;
                        if (command is ISupportOptions)
                        {
                            OptionsCommandButton ocbtn = new OptionsCommandButton();
                            ocbtn.ApplicationCommand = command;
                            ocbtn.Style  = (Style)App.Current.FindResource("CommandOptionsButtonInWidgetStyle");
                            ocbtn.Margin = new Thickness(14, 0, 0, 0);
                            button       = ocbtn;
                        }
                        else
                        {
                            CommandButton cbtn = new CommandButton();
                            cbtn.ApplicationCommand = command;
                            button = cbtn;
                        }

                        button.Content = command.Title;
                        TasksStack.Children.Add(button);
                    }
                }

                _widgetInitialized = true;
            }
        }
        private void _InitTasks()
        {
            if (App.Current.CommandManager != null)
            {
                TasksStack.Children.Clear();

                string categoryName = ((PageBase)this._Page).PageCommandsCategoryName;
                Debug.Assert(!String.IsNullOrEmpty(categoryName));

                ICollection<AppCommands.ICommand> commands = App.Current.CommandManager.GetCategoryCommands(categoryName);
                if (0 < commands.Count)
                {
                    foreach (ESRI.ArcLogistics.App.Commands.ICommand command in commands)
                    {
                        System.Windows.Controls.Button button = null;
                        if (command is ISupportOptions)
                        {
                            OptionsCommandButton ocbtn = new OptionsCommandButton();
                            ocbtn.ApplicationCommand = command;
                            ocbtn.Style = (Style)App.Current.FindResource("CommandOptionsButtonInWidgetStyle");
                            ocbtn.Margin = new Thickness(14, 0, 0, 0);
                            button = ocbtn;
                        }
                        else
                        {
                            CommandButton cbtn = new CommandButton();
                            cbtn.ApplicationCommand = command;
                            button = cbtn;
                        }

                        button.Content = command.Title;
                        TasksStack.Children.Add(button);
                    }
                }

                _widgetInitialized = true;
            }
        }
        /// <summary>
        /// Creates command buttons.
        /// </summary>
        private void _CreateCommandButtons()
        {
            Debug.Assert(null != App.Current.CommandManager);

            _ClearCommandButtons();

            // If command category name is empty - just clear command buttons.
            if (string.IsNullOrEmpty(CommandCategoryName))
                return;

            ICollection<AppCommands.ICommand> commands = App.Current.CommandManager.GetCategoryCommands(CommandCategoryName);
            foreach (AppCommands.ICommand command in commands)
            {
                AppCommands.ICommand cmd = command;

                // If command supports context - special handling.
                if (command is AppCommands.ISupportContext)
                {
                    // Instantiate new intance of such command to initialize it with the context.
                    cmd = (AppCommands.ICommand)Activator.CreateInstance(command.GetType());

                    // Initialize command.
                    cmd.Initialize(App.Current);

                    // Set command context.
                    ((AppCommands.ISupportContext)cmd).Context = CommandContext;
                }

                if (command is AppCommands.ISupportOptions)
                {
                    OptionsCommandButton ocbtn = new OptionsCommandButton();
                    ocbtn.Content = command.Title;
                    ocbtn.ApplicationCommand = cmd;
                    ocbtn.Style = (Style)App.Current.FindResource("CommandOptionsButtonInGroupStyle");
                    ButtonsWrapPanel.Children.Add(ocbtn);
                }
                else
                {
                    CommandButton cbtn = new CommandButton();
                    cbtn.Content = command.Title;
                    cbtn.ApplicationCommand = cmd;
                    cbtn.Style = (Style)App.Current.FindResource("CommandButtonInGroupStyle");
                    ButtonsWrapPanel.Children.Add(cbtn);
                }
            }
        }