Beispiel #1
0
        // Конструкторы
        #region Конструкторы
        public MyTask(MainWindow mainWindow)
        {
            m_TaskID        = mainWindow.GetTasksCounter + 1;
            m_Process       = new Process();
            m_TaskElement   = new TaskElement(mainWindow, this, m_TaskID);
            m_UtilityName   = String.Empty;
            m_SrcFileName   = String.Empty;
            m_ThumbnailFile = String.Empty;
            //m_OutputFileName = "";
            m_ProcessArguments = String.Empty;
            m_IsEditing        = false;
            m_State            = TaskState.Default;
            m_IsThereOutput    = false;

            // Необходимо для перенаправления входного и выходного потоков командной строки
            m_Process.StartInfo.UseShellExecute = false;
            // Разрешаем перенаправить выходной поток
            m_Process.StartInfo.RedirectStandardOutput = true;
            // Разрешаем перенаправить поток ошибок
            m_Process.StartInfo.RedirectStandardError = true;
            // Устанавливаем кодировку выходного потока (поддержка русского языка)
            m_Process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("cp866");
            m_Process.StartInfo.StandardErrorEncoding  = Encoding.GetEncoding("cp866");
            // Не создавать окно процесса
            m_Process.StartInfo.CreateNoWindow = true;
            // Нужно, чтобы вызывалось событие Exited
            m_Process.EnableRaisingEvents = true;
            // Добавляем обработчик события Exited
            m_Process.Exited += new EventHandler(Process_Exited);
        }
Beispiel #2
0
        public TaskElement(TaskElement copy, SelectTaskDialogWindow selectTaskDialogWindow)
        {
            InitializeComponent();
            this.m_MainWindow             = null;
            this.m_SelectTaskDialogWindow = selectTaskDialogWindow;
            this.m_ParentTask             = copy.m_ParentTask;
            this.m_TaskID                   = copy.m_TaskID;
            this.m_IsCurrent                = false;
            this.m_TaskElementState         = TaskElementState.Normal;
            this.m_PreviousTaskElementState = m_TaskElementState;
            this.SetBackgroundBrush         = TaskElement.m_NormalStateBrush;

            this.SetImageToImagePreviewElement(this.m_ParentTask.ThumbnailPath);
            this.SetTaskIDToLabel(this.m_TaskID);
            this.SetUtilityNameToLabel(this.m_ParentTask.UtilityName);
            this.SetFileNameToLabelAndToolTip(this.m_ParentTask.SrcFileName);
            this.SetTaskElementState(TaskElementState.Normal);

            this.MouseEnter          += new MouseEventHandler(taskElement_MouseEnter);
            this.MouseLeave          += new MouseEventHandler(taskElement_MouseLeave);
            this.MouseLeftButtonDown += new MouseButtonEventHandler(taskElement_MouseLeftButtonDown_SelectTaskDialog);
            this.image_SrcImagePreview.MouseEnter += new MouseEventHandler(Image_SrcImagePreview_MouseEnter);
            this.image_SrcImagePreview.MouseLeave += new MouseEventHandler(Image_SrcImagePreview_MouseLeave);

            Binding myBinding = new Binding();

            myBinding.Path   = new PropertyPath("SetBackgroundBrush");
            myBinding.Mode   = BindingMode.TwoWay;
            myBinding.Source = this;
            myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            this.SetBinding(UserControl.BackgroundProperty, myBinding);
        }
Beispiel #3
0
        private void taskElement_MouseLeftButtonDown(object sender, RoutedEventArgs e)
        {
            TaskElement taskElement = sender as TaskElement;

            if (m_MainWindow.CurrentTask != null)
            {
                //m_MainWindow.CurrentTask.GetTaskElement.Background = m_NormalStateBrush;
                //m_MainWindow.CurrentTask.GetTaskElement.SetTaskElementState(TaskElementState.Highlighted);
                m_MainWindow.CurrentTask.GetTaskElement.ReturnToPreviousElementState();
                m_MainWindow.CurrentTask.GetTaskElement.IsCurrent = false;
                if (taskElement == m_MainWindow.CurrentTask.GetTaskElement)
                {
                    m_MainWindow.CurrentTask = null;
                    return;
                }
            }

            MyTask selectedTask = m_MainWindow.GetTasksList.Where(
                x => x.GetTaskID == taskElement.m_TaskID
                ).FirstOrDefault();

            //taskElement.Background = m_SelectedBrush;
            //m_MainWindow.CurrentTask.GetTaskElement.SetTaskElementState(TaskElementState.Selected);
            //taskElement.SetPreviousState();
            taskElement.SetTaskElementState(TaskElementState.Selected);
            taskElement.IsCurrent    = true;
            m_MainWindow.CurrentTask = selectedTask;
        }
Beispiel #4
0
        // Обработчики событий
        #region Обработчики событий
        private void taskElement_MouseEnter(object sender, RoutedEventArgs e)
        {
            TaskElement taskElement = sender as TaskElement;

            if (taskElement.IsCurrent != true)
            {
                //taskElement.Background = m_HighlightedBrush;
                m_PreviousTaskElementState = m_TaskElementState;
                //m_MainWindow.CurrentTask.GetTaskElement.SetTaskElementState(TaskElementState.Highlighted);
                taskElement.SetTaskElementState(TaskElementState.Highlighted);
            }
        }
Beispiel #5
0
        private void taskElement_MouseLeave(object sender, RoutedEventArgs e)
        {
            TaskElement taskElement = sender as TaskElement;

            if (taskElement.IsCurrent != true)
            {
                //taskElement.Background = m_NormalStateBrush;

                /*
                 * m_MainWindow.CurrentTask.GetTaskElement.SetTaskElementState(TaskElementState.Normal);
                 * m_TaskElementState = m_PreviousTaskElementState;
                 */
                taskElement.ReturnToPreviousElementState();
            }
        }
Beispiel #6
0
 // Обработчики событий
 private void Tasks_CollectionChanged(object sender,
                                      System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.NewItems != null && e.NewItems[0] != null)
     {
         TaskElement taskElement = e.NewItems[0] as TaskElement;
         //StackPanel_TaskElements.Children.Add(task.GetTaskElement);
         StackPanel_TaskElements.Children.Insert(e.NewStartingIndex, taskElement);
     }
     else if (e.OldItems != null && e.OldItems[0] != null)
     {
         TaskElement taskElement = e.OldItems[0] as TaskElement;
         StackPanel_TaskElements.Children.Remove(taskElement);
     }
 }
Beispiel #7
0
        public void SelectedTasksChanged(TaskElement taskElement)
        {
            if (taskElement == null || taskElement.GetParentTask == null)
            {
                return;
            }

            if (m_SelectedTasks.Contains(taskElement.GetParentTask))
            {
                m_SelectedTasks.Remove(taskElement.GetParentTask);
                taskElement.ReturnToPreviousElementState();
                taskElement.IsCurrent = false;
            }
            else
            {
                m_SelectedTasks.Add(taskElement.GetParentTask);
                taskElement.SetTaskElementState(TaskElement.TaskElementState.Selected);
                taskElement.IsCurrent = true;
            }
        }
Beispiel #8
0
        // Конструкторы
        #region Конструкторы
        public MyTask(MainWindow mainWindow)
        {
            m_TaskID = mainWindow.GetTasksCounter + 1;
            m_Process = new Process();
            m_TaskElement = new TaskElement(mainWindow, this, m_TaskID);
            m_UtilityName = String.Empty;
            m_SrcFileName = String.Empty;
            m_ThumbnailFile = String.Empty;
            //m_OutputFileName = "";
            m_ProcessArguments = String.Empty;
            m_IsEditing = false;
            m_State = TaskState.Default;
            m_IsThereOutput = false;

            // Необходимо для перенаправления входного и выходного потоков командной строки
            m_Process.StartInfo.UseShellExecute = false;
            // Разрешаем перенаправить выходной поток
            m_Process.StartInfo.RedirectStandardOutput = true;
            // Разрешаем перенаправить поток ошибок 
            m_Process.StartInfo.RedirectStandardError = true;
            // Устанавливаем кодировку выходного потока (поддержка русского языка)  
            m_Process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding("cp866");
            m_Process.StartInfo.StandardErrorEncoding = Encoding.GetEncoding("cp866");
            // Не создавать окно процесса
            m_Process.StartInfo.CreateNoWindow = true;
            // Нужно, чтобы вызывалось событие Exited
            m_Process.EnableRaisingEvents = true;
            // Добавляем обработчик события Exited
            m_Process.Exited += new EventHandler(Process_Exited);
        }
        public void SelectedTasksChanged(TaskElement taskElement)
        {
            if (taskElement == null || taskElement.GetParentTask == null)
            {
                return;
            }

            if (m_SelectedTasks.Contains(taskElement.GetParentTask))
            {
                m_SelectedTasks.Remove(taskElement.GetParentTask);
                taskElement.ReturnToPreviousElementState();
                taskElement.IsCurrent = false;
            }
            else
            {
                m_SelectedTasks.Add(taskElement.GetParentTask);
                taskElement.SetTaskElementState(TaskElement.TaskElementState.Selected);
                taskElement.IsCurrent = true;
            }
        }
Beispiel #10
0
        private void taskElement_MouseLeftButtonDown_SelectTaskDialog(object sender, RoutedEventArgs e)
        {
            TaskElement taskElement = sender as TaskElement;

            m_SelectTaskDialogWindow.SelectedTasksChanged(taskElement);
        }
Beispiel #11
0
        public TaskElement(TaskElement copy, SelectTaskDialogWindow selectTaskDialogWindow)
        {
            InitializeComponent();
            this.m_MainWindow = null;
            this.m_SelectTaskDialogWindow = selectTaskDialogWindow;
            this.m_ParentTask = copy.m_ParentTask;
            this.m_TaskID = copy.m_TaskID;
            this.m_IsCurrent = false;
            this.m_TaskElementState = TaskElementState.Normal;
            this.m_PreviousTaskElementState = m_TaskElementState;
            this.SetBackgroundBrush = TaskElement.m_NormalStateBrush;

            this.SetImageToImagePreviewElement(this.m_ParentTask.ThumbnailPath);
            this.SetTaskIDToLabel(this.m_TaskID);
            this.SetUtilityNameToLabel(this.m_ParentTask.UtilityName);
            this.SetFileNameToLabelAndToolTip(this.m_ParentTask.SrcFileName);
            this.SetTaskElementState(TaskElementState.Normal);

            this.MouseEnter += new MouseEventHandler(taskElement_MouseEnter);
            this.MouseLeave += new MouseEventHandler(taskElement_MouseLeave);
            this.MouseLeftButtonDown += new MouseButtonEventHandler(taskElement_MouseLeftButtonDown_SelectTaskDialog);
            this.image_SrcImagePreview.MouseEnter += new MouseEventHandler(Image_SrcImagePreview_MouseEnter);
            this.image_SrcImagePreview.MouseLeave += new MouseEventHandler(Image_SrcImagePreview_MouseLeave);

            Binding myBinding = new Binding();
            myBinding.Path = new PropertyPath("SetBackgroundBrush");
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Source = this;
            myBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            this.SetBinding(UserControl.BackgroundProperty, myBinding);
        }