示例#1
0
        /// <summary>
        ///     技術座標追加ボタン押下時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTechPositionAddButtonClick(object sender, EventArgs e)
        {
            // 選択項目がなければ何もしない
            TechItem item = GetSelectedItem() as TechItem;
            if (item == null)
            {
                return;
            }

            // 座標をリストに追加する
            TechPosition position = new TechPosition { X = 0, Y = 0 };
            item.Positions.Add(position);

            Log.Info("[Tech] Added tech position: ({0}, {1}) [{2}]", position.X, position.Y, item);

            // 編集済みフラグを設定する
            TechGroup grp = GetSelectedGroup();
            grp.SetDirty();
            item.SetDirty();
            position.SetDirtyAll();

            // 座標リストビューの項目を追加する
            ListViewItem li = new ListViewItem { Text = IntHelper.ToString(position.X) };
            li.SubItems.Add(IntHelper.ToString(position.Y));
            techPositionListView.Items.Add(li);

            // 追加した項目を選択する
            techPositionListView.Items[techPositionListView.Items.Count - 1].Focused = true;
            techPositionListView.Items[techPositionListView.Items.Count - 1].Selected = true;
            techPositionListView.EnsureVisible(techPositionListView.Items.Count - 1);

            // 編集項目を有効化する
            EnableTechPositionItems();

            // 技術ツリーにラベルを追加する
            _techTreePanelController.AddItem(item, position);
        }
        /// <summary>
        ///     技術ツリーに技術ラベルを追加する
        /// </summary>
        /// <param name="item">追加対象の項目</param>
        /// <param name="position">追加対象の位置</param>
        private void AddLabelItem(TechLabel item, TechPosition position)
        {
            Label label = new Label
            {
                Location = new Point(DeviceCaps.GetScaledWidth(position.X), DeviceCaps.GetScaledHeight(position.Y)),
                BackColor = Color.Transparent,
                Tag = new TechLabelInfo { Item = item, Position = position }
            };
            label.Size = Graphics.FromHwnd(label.Handle).MeasureString(item.ToString(), label.Font).ToSize();

            label.Click += OnItemLabelClick;
            label.MouseClick += OnItemLabelMouseClick;
            label.MouseDown += OnItemLabelMouseDown;
            label.MouseUp += OnItemLabelMouseUp;
            label.MouseMove += OnItemLabelMouseMove;
            label.GiveFeedback += OnItemLabelGiveFeedback;
            label.Paint += OnTechLabelPaint;

            _pictureBox.Controls.Add(label);
        }
        /// <summary>
        ///     技術ツリーに技術項目を追加する
        /// </summary>
        /// <param name="item">追加対象の項目</param>
        /// <param name="position">追加対象の位置</param>
        private void AddTechItem(TechItem item, TechPosition position)
        {
            Label label = new Label
            {
                Location = new Point(DeviceCaps.GetScaledWidth(position.X), DeviceCaps.GetScaledHeight(position.Y)),
                BackColor = Color.Transparent,
                Tag = new TechLabelInfo { Item = item, Position = position },
                Size = new Size(_techLabelBitmap.Width, _techLabelBitmap.Height),
                Region = _techLabelRegion
            };

            // ラベル画像を設定する
            if (ApplyItemStatus && (QueryItemStatus != null))
            {
                QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                QueryItemStatus(this, e);
                label.Image = e.Done
                    ? (e.Blueprint ? _blueprintDoneTechLabelBitmap : _doneTechLabelBitmap)
                    : (e.Blueprint ? _blueprintTechLabelBitmap : _techLabelBitmap);
            }
            else
            {
                label.Image = _techLabelBitmap;
            }

            label.Click += OnItemLabelClick;
            label.MouseClick += OnItemLabelMouseClick;
            label.MouseDown += OnItemLabelMouseDown;
            label.MouseUp += OnItemLabelMouseUp;
            label.MouseMove += OnItemLabelMouseMove;
            label.GiveFeedback += OnItemLabelGiveFeedback;
            label.Paint += OnTechItemPaint;

            _pictureBox.Controls.Add(label);
        }
        /// <summary>
        ///     技術ツリーの項目を削除する
        /// </summary>
        /// <param name="item">削除対象の項目</param>
        /// <param name="position">削除対象の位置</param>
        public void RemoveItem(ITechItem item, TechPosition position)
        {
            Control.ControlCollection labels = _pictureBox.Controls;
            foreach (Label label in labels)
            {
                TechLabelInfo info = label.Tag as TechLabelInfo;
                if (info == null)
                {
                    continue;
                }

                if (info.Item == item && info.Position == position)
                {
                    _pictureBox.Controls.Remove(label);
                }
            }
        }
        /// <summary>
        ///     技術ツリーの項目を更新する
        /// </summary>
        /// <param name="item">更新対象の項目</param>
        /// <param name="position">更新対象の座標</param>
        public void UpdateItem(ITechItem item, TechPosition position)
        {
            Control.ControlCollection labels = _pictureBox.Controls;
            foreach (Label label in labels)
            {
                TechLabelInfo info = label.Tag as TechLabelInfo;
                if (info == null)
                {
                    continue;
                }

                if (info.Item != item)
                {
                    continue;
                }

                // ラベルの位置を更新する
                if (info.Position == position)
                {
                    label.Location = new Point(DeviceCaps.GetScaledWidth(position.X),
                        DeviceCaps.GetScaledHeight(position.Y));
                }

                // 項目ラベルの表示に項目の状態を反映しないならば座標変更のみ
                if (!ApplyItemStatus || (QueryItemStatus == null))
                {
                    continue;
                }

                if (item is TechItem)
                {
                    // ラベル画像を設定する
                    QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                    QueryItemStatus(this, e);
                    label.Image = e.Done
                        ? (e.Blueprint ? _blueprintDoneTechLabelBitmap : _doneTechLabelBitmap)
                        : (e.Blueprint ? _blueprintTechLabelBitmap : _techLabelBitmap);
                }
                else if (item is TechEvent)
                {
                    // ラベル画像を設定する
                    QueryItemStatusEventArgs e = new QueryItemStatusEventArgs(item);
                    QueryItemStatus(this, e);
                    label.Image = e.Done ? _doneEventLabelBitmap : _eventLabelBitmap;
                }
            }
        }
        /// <summary>
        ///     技術ツリーに項目ラベルを追加する
        /// </summary>
        /// <param name="item">追加対象の項目</param>
        /// <param name="position">追加対象の位置</param>
        public void AddItem(ITechItem item, TechPosition position)
        {
            TechItem tech = item as TechItem;
            if (tech != null)
            {
                AddTechItem(tech, position);
                return;
            }

            TechLabel label = item as TechLabel;
            if (label != null)
            {
                AddLabelItem(label, position);
                return;
            }

            TechEvent ev = item as TechEvent;
            if (ev != null)
            {
                AddEventItem(ev, position);
            }
        }
 /// <summary>
 ///     コンストラクタ
 /// </summary>
 /// <param name="item">技術項目</param>
 /// <param name="position">項目ラベルの位置</param>
 /// <param name="e">マウスイベントのパラメータ</param>
 public ItemMouseEventArgs(ITechItem item, TechPosition position, MouseEventArgs e)
     : base(e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
     Item = item;
     Position = position;
 }
 /// <summary>
 ///     コンストラクタ
 /// </summary>
 /// <param name="item">技術項目</param>
 /// <param name="position">項目ラベルの位置</param>
 public ItemEventArgs(ITechItem item, TechPosition position)
 {
     Item = item;
     Position = position;
 }
 /// <summary>
 ///     コンストラクタ
 /// </summary>
 /// <param name="item">技術項目</param>
 /// <param name="position">項目ラベルの位置</param>
 /// <param name="e">ドラッグアンドドロップイベントのパラメータ</param>
 public ItemDragEventArgs(ITechItem item, TechPosition position, DragEventArgs e)
     : base(e.Data, e.KeyState, e.X, e.Y, e.AllowedEffect, e.Effect)
 {
     Item = item;
     Position = position;
 }
示例#10
0
        /// <summary>
        ///     座標を複製する
        /// </summary>
        /// <returns>複製した座標</returns>
        public TechPosition Clone()
        {
            TechPosition position = new TechPosition { X = X, Y = Y };

            return position;
        }