Exemplo n.º 1
0
        /// <summary>
        /// 作業の作成
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="categoryId"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="workId"></param>
        /// <returns></returns>
        public Work CreateWork( string subject, int categoryId, DateTime startTime, DateTime endTime )
        {
            long	workId;
            if( Api.CreateWork( subject, categoryId, startTime, endTime, out workId ) == false )
            {
                MessageBox.Show( "作業の作成に失敗しました。", "作業の作成", MessageBoxButton.OK, MessageBoxImage.Error );
                return	null;
            }

            var	work	= new Work( workId )
            {
                UserId		= Api.LoginUser.Id,
                CategoryId	= categoryId,
                Subject		= subject,
                StartTime	= startTime,
                EndTime		= endTime,
            };

            return	work;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 作業アイテムの作成
        /// </summary>
        /// <param name="work"></param>
        /// <returns></returns>
        WorkItem _CreateWorkItem( Work work )
        {
            var	category	= Controllers.Category.Categories.Find( c => c.Id == work.CategoryId );
            var	background	= (Color)ColorConverter.ConvertFromString( category.Background );
            var	item	= new WorkItem()
            {
                Background	= new SolidColorBrush( background ),
                Margin		= new Thickness( 0, 0, 0, 1 ),
                Tag			= work,
            };
            item.Subject.Text	= work.Subject;

            item.TopBarMoveing		+= _Item_TopBarMoveing;
            item.TopBarMoved		+= _Item_TopBarMoved;
            item.BottomBarMoveing	+= _Item_BottomBarMoveing;
            item.BottomBarMoved		+= _Item_BottomBarMoved;
            item.SubjectChanged		+= _Item_SubjectChanged;
            return	item;
        }
Exemplo n.º 3
0
        /// <summary>
        /// マウスアップ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _TimeBackGrid_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if( IsReadOnly )
            {
                return;
            }

            if( m_createGhostStart )
            {
                m_createGhostStart	= false;

                m_timeBackGrid.ReleaseMouseCapture();

                m_createGhostLock	= true;

                m_reserveWork	= _CreateWork( m_createStartPos.Y, e.GetPosition( m_timeBackGrid ).Y );

                // カテゴリーの選択ツールボックスを表示する
                {
                    var	pos			= e.GetPosition( this );
                    var	screenPos	= this.PointToScreen( pos );

                    var	selectCategoryToolBox	= new SelectCategoryToolBox();
                    selectCategoryToolBox.SetCategories( Controllers.Category.Categories );
                    selectCategoryToolBox.Left	= screenPos.X + 10;
                    selectCategoryToolBox.Top	= screenPos.Y - 100;

                    selectCategoryToolBox.SelectedCategory += _SelectCategoryToolBox_SelectedCategory;
                    selectCategoryToolBox.Closed += _SelectCategoryToolBox_Closed;

                    selectCategoryToolBox.Show();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 作業の作成
        /// </summary>
        /// <param name="startPosY"></param>
        /// <param name="endPosY"></param>
        /// <returns></returns>
        Work _CreateWork( double startPosY, double endPosY )
        {
            if( startPosY > endPosY )
            {
                // 上にドラッグしている

                var	temp	= startPosY;
                startPosY	= endPosY;
                endPosY		= temp;

                var	startTime	= _GetTime( startPosY, false );
                var	endTime		= _GetTime( endPosY, true );

                // 重複させない
                startTime	= _GetLastFreeTime( startTime, endTime );

                // 仮
                var	startDateTime	= DateTime.Now.Date.Add( startTime );
                var	endDateTime		= DateTime.Now.Date.Add( endTime );
                var	work	= new Work()
                {
                    CategoryId	= 1,
                    StartTime	= startDateTime,
                    EndTime		= endDateTime,
                    Subject		= "新規作成",
                };
                return	work;
            }
            else
            {
                // 下にドラッグしている
                var	startTime	= _GetTime( startPosY, false );
                var	endTime		= _GetTime( endPosY, true );

                // 重複させない
                endTime		= _GetFirstFreeTime( startTime, endTime );

                // 仮
                var	startDateTime	= DateTime.Now.Date.Add( startTime );
                var	endDateTime		= DateTime.Now.Date.Add( endTime );
                var	work	= new Work()
                {
                    CategoryId	= 1,
                    StartTime	= startDateTime,
                    EndTime		= endDateTime,
                    Subject		= "新規作成",
                };
                return	work;
            }
        }