예제 #1
0
        private Button GetButton(ActionModel.Action action)
        {
            string appPath = AppDomain.CurrentDomain.BaseDirectory;
            string image   = appPath + "Images\\" + action.Image;

            Button button = new Button();

            StackPanel stackPanel = new StackPanel();

            TextBlock textBlock = new TextBlock
            {
                Text = action.Caption,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            Image img = new Image // action.Caption;
            {
                Source = new BitmapImage(new Uri(image, UriKind.Absolute)),
                Width  = 60,
                Height = 60
            };

            stackPanel.Children.Add(img);
            stackPanel.Children.Add(textBlock);

            button.Content = stackPanel;
            button.Tag     = action.ID;
            button.Click  += new RoutedEventHandler(button_Click);

            return(button);
        }
예제 #2
0
        private void ButtonHandler(int id)
        {
            ActionModel.Action action  = _actionCollection.Actions[id];
            string             path    = action.Start;
            string             cmd     = action.Command;
            string             file    = "";
            string             command = action.Command;

            if (String.IsNullOrEmpty(path))
            {
                CreateBat(command);
                file = "start.bat";
            }
            else
            {
                file = command;
            }

            RunBat(file, path);
            this.WindowState = WindowState.Minimized;
        }