Example #1
0
        internal void addLabelToStore(string nowText,
                                      string[] nowLabelResultValues,
                                      string nowFilename)
        {
            int category;

            //nowLabelResultValues的元素个数 判断是否存在
            if (nowLabelResultValues.Length == 3)
            {
                category = 1;
            }
            else if (nowLabelResultValues.Length == 4)
            {
                category = Convert.ToInt16(nowLabelResultValues[3]);
            }
            else
            {
                return;     //解析失败
            }

            LabelItem labelItem = new LabelItem(
                Convert.ToSingle(nowLabelResultValues[1]),
                Convert.ToSingle(nowLabelResultValues[2]),
                nowText.Trim(),
                category);

            addLabelItem(nowFilename, labelItem);
        }
Example #2
0
 public bool AddLabelItem(string file, LabelItem item, int insertIndex = -1)
 {
     try
     {
         if (addLabelItem(file, item, insertIndex))
         {
             OnLabelItemListChanged();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch { return(false); }
 }
Example #3
0
        internal bool addLabelItem(string file, LabelItem item, int insertIndex = -1)
        {
            try
            {
                if (insertIndex == -1)
                {
                    store[file].Add(item);
                }
                else
                {
                    store[file].Insert(insertIndex, item);
                }

                return(true);
            }
            catch { return(false); }
        }
        internal void addLabelToStore(string nowText, 
                                        string[] nowLabelResultValues, 
                                        string nowFilename)
        {
            int category;

            //nowLabelResultValues的元素个数 判断是否存在
            if (nowLabelResultValues.Length == 3)
            {
                category = 1;
            }
            else if(nowLabelResultValues.Length == 4)
            {
                category = Convert.ToInt16(nowLabelResultValues[3]);
            }
            else
            {
                return;     //解析失败
            }

            LabelItem labelItem = new LabelItem(
                            Convert.ToSingle(nowLabelResultValues[1]),
                            Convert.ToSingle(nowLabelResultValues[2]),
                            nowText.Trim(),
                            category);
            addLabelItem(nowFilename, labelItem);
        }
        internal bool addLabelItem(string file, LabelItem item, int insertIndex = -1)
        {
            try
            {
                if (insertIndex == -1)
                    store[file].Add(item);
                else
                    store[file].Insert(insertIndex, item);

                return true;
            }
            catch { return false; }
        }
 public bool AddLabelItem(string file, LabelItem item, int insertIndex = -1)
 {
     try
     {
         if (addLabelItem(file, item, insertIndex))
         {
             OnLabelItemListChanged();
             return true;
         }
         else return false;
     }
     catch { return false; }
 }
Example #7
0
        void PicView_Label_MouseClick(object sender, MouseEventArgs e)
        {
            if (image == null)
            {
                return;
            }
            if (alreadyDraged == true)
            {
                return;
            }

            int   index     = getLabelIndex(e.X, e.Y);
            float x_percent = (startP.X * zoom + e.X) / image.Width;
            float y_percent = (startP.Y * zoom + e.Y) / image.Height;

            if (x_percent > 1.0f || y_percent > 1.0f)
            {
                return;                                         //忽略超出边界的点击
            }
            //var referRect = getLabelRectangle(0, 0); //参考矩形
            //x_percent = (startP.X * zoom + e.X - referRect.Width / 2) / image.Width;
            //y_percent = (startP.Y * zoom + e.Y - referRect.Height / 2) / image.Height;
            //重新计算,为了契合鼠标点击的目标

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (dragLabel != null && dragStart == true)
                {
                    dragLabel.X_percent = x_percent;
                    dragLabel.Y_percent = y_percent;
                    //Console.WriteLine(dragLabel.X_percent + "    " + dragLabel.Y_percent);
                    dragLabel = null;
                    dragStart = false;
                    if (LabelUserAction != null)
                    {
                        LabelUserAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent, LabelUserActionEventArgs.ActionType.labelChanged));
                    }

                    return;
                }
                //MessageBox.Show("i find you");
                bool flag = false;
                foreach (LabelItem label in this.labels)
                {
                    if (Math.Abs(x_percent - label.X_percent) < 0.02 && Math.Abs(y_percent - label.Y_percent) < 0.02)
                    {
                        // Console.WriteLine(x_percent + " " + label.X_percent + " " );
                        //MessageBox.Show("nice");
                        flag      = true;
                        dragStart = true;
                        dragLabel = label;
                        //MessageBox.Show("已选中"+dragLabel.Text);
                        break;
                    }
                }

                if (!flag)
                {
                    if (LabelUserAction != null)
                    {
                        LabelUserAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent, LabelUserActionEventArgs.ActionType.leftClick));
                    }
                }
                //左键

                ////添加
                //var referRect = getLabelRectangle(0, 0); //参考矩形
                //x_percent = (startP.X * zoom + e.X - referRect.Width / 2) / image.Width;
                //y_percent = (startP.Y * zoom + e.Y - referRect.Height / 2) / image.Height;
                ////重新计算,为了契合鼠标点击的目标
                //if(LabelUserAddAction!=null)
                //    LabelUserAddAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //右键
                if (LabelUserAction != null)
                {
                    LabelUserAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent, LabelUserActionEventArgs.ActionType.rightClick));
                }

                ////删除
                //if (index == -1) return;
                //if(LabelUserDelAction!=null)
                //    LabelUserDelAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            }
            //else if (!ctrlBepush && e.Button == System.Windows.Forms.MouseButtons.Left)
            //{
            //    //点击事件
            //    if (index == -1) return;
            //    if (LabelUserClickAction != null)
            //        LabelUserClickAction(this, new LabelUserActionEventArgs(index, x_percent, y_percent));
            //}
            //else if (!ctrlBepush && e.Button == System.Windows.Forms.MouseButtons.Right)
            //{
            //    //检阅模式

            //}
        }