Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e) //make sure
 {
     Edit_min = 0;                                      //Int32.Parse(MinText.Text);
     Edit_max = 0;                                      //Int32.Parse(MaxText.Text);
     if (float.TryParse(MinText.Text, out edit_min))
     {
         if (float.TryParse(MaxText.Text, out edit_max))
         {
             DensityRange temp_range = new DensityRange(Edit_min, Edit_max, Red, Green, Blue);
             Edit_range = temp_range;
             g.Dispose();
             brush_picbox.Dispose();
         }
         else
         {
             MaxText.Focus();
             MaxText.SelectAll();
         }
     }
     else
     {
         MinText.Focus();
         MinText.SelectAll();
     }
 }
Exemplo n.º 2
0
        private void AddDensityRange_Click(object sender, EventArgs e)
        {
            EditRange temp_editrange = new EditRange();

            if (temp_editrange.ShowDialog(this) == DialogResult.OK)
            {
                DensityRange temp_range = new DensityRange(temp_editrange.Edit_min, temp_editrange.Edit_max, temp_editrange.Red, temp_editrange.Green,
                                                           temp_editrange.Blue);
                int index = 0;
                if (_rangeList == null)
                {
                    return;
                }
                foreach (DensityRange r in _rangeList)
                {
                    if (temp_range.minValue < r.minValue)
                    {
                        break;
                    }
                    index++;
                }

                lstDensityRange.Items.Insert(index, temp_range.ToString());


                if (lstDensityRange.Items.Count > _rangeList.Count)
                {
                    _rangeList.Insert(index, temp_range);
                }
                else
                {
                    _rangeList[index] = temp_range;
                }
            }
        }
Exemplo n.º 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lstDensityRange.SelectedIndex >= 0)
            {
                DensityRange dr = _rangeList[lstDensityRange.SelectedIndex];
                GetMinMaxValue(ref dr);

                EditRange temp_editrange = new EditRange(dr);

                string list_text;
                temp_editrange.StartPosition = FormStartPosition.Manual;
                temp_editrange.Location      = new Point(this.Location.X + this.Width, this.Location.Y);
                if (temp_editrange.ShowDialog(this) == DialogResult.OK)
                {
                    DensityRange temp_range = new DensityRange(temp_editrange.Edit_min, temp_editrange.Edit_max, temp_editrange.Red, temp_editrange.Green,
                                                               temp_editrange.Blue);

                    if (lstDensityRange.Items.Count > _rangeList.Count)
                    {
                        _rangeList.Add(temp_range);
                    }
                    else
                    {
                        _rangeList[lstDensityRange.SelectedIndex] = temp_range;
                    }

                    list_text = temp_range.ToString();
                    lstDensityRange.Items[lstDensityRange.SelectedIndex] = list_text;
                }
            }
        }
Exemplo n.º 4
0
        private List <DensityRange> InitRange(int range)
        {
            ConstructColorList();
            if (ckInterval.Checked)
            {
                if (StringToNumberHelper.isFloatPointNumber(txtInterval.Text))
                {
                    _intervalType = IntervalType.FloatType;
                }
                else
                {
                    _intervalType = IntervalType.IntType;
                }
            }
            else
            {
                _interval = (float)Math.Round((_maxValue - _minValue) / (float)numSliceRange.Value, 2);
            }
            if (_intervalType == IntervalType.IntType)
            {
                _interval = (int)Math.Ceiling(_interval);
            }
            List <DensityRange> m_RangeList = new List <DensityRange>();

            for (int i = 0; i < range; i++)
            {
                int          color_idx  = i > colorList.Length - 1 ? i % (colorList.Length - 1) : i;
                Color        rangeColor = colorList[color_idx];
                DensityRange r          = (i == 0) ?
                                          new DensityRange(_minValue + (i * _interval), _minValue + ((i + 1) * _interval), rangeColor.R, rangeColor.G, rangeColor.B) :
                                          new DensityRange(_minValue + (i * _interval), _minValue + ((i + 1) * _interval), rangeColor.R, rangeColor.G, rangeColor.B);
                m_RangeList.Add(r);
            }
            return(m_RangeList);
        }
Exemplo n.º 5
0
 private static void SetSubRangeInfo(XElement pNode, DensityRange densityRange)
 {
     pNode.SetElementValue("L", densityRange.minValue.ToString());
     pNode.SetElementValue("R", densityRange.maxValue.ToString());
     pNode.SetElementValue("RGB_R", densityRange.RGB_r.ToString());
     pNode.SetElementValue("RGB_G", densityRange.RGB_g.ToString());
     pNode.SetElementValue("RGB_B", densityRange.RGB_b.ToString());
 }
Exemplo n.º 6
0
        private static void ReadRanges(ref DensityDef densityDef, XElement node)
        {
            XElement rangeNode = node.Element("RANGE");

            if (rangeNode == null)
            {
                return;
            }
            IEnumerable <XElement> rangeSubNodes = rangeNode.Elements();

            if (rangeSubNodes == null || rangeSubNodes.Count() == 0)
            {
                return;
            }
            List <DensityRange> ranges   = new List <DensityRange>();
            XElement            tempNode = null;

            foreach (XElement item in rangeSubNodes)
            {
                DensityRange temprange = new DensityRange(0, 0, 0, 0, 0);
                tempNode = item.Element("L");
                if (tempNode == null)
                {
                    continue;
                }
                temprange.minValue = float.Parse(tempNode.Value);
                tempNode           = item.Element("R");
                if (tempNode == null)
                {
                    continue;
                }
                temprange.maxValue = float.Parse(tempNode.Value);
                tempNode           = item.Element("RGB_R");
                if (tempNode == null)
                {
                    continue;
                }
                temprange.RGB_r = byte.Parse(tempNode.Value);
                tempNode        = item.Element("RGB_G");
                if (tempNode == null)
                {
                    continue;
                }
                temprange.RGB_g = byte.Parse(tempNode.Value);
                tempNode        = item.Element("RGB_B");
                if (tempNode == null)
                {
                    continue;
                }
                temprange.RGB_b = byte.Parse(tempNode.Value);
                ranges.Add(temprange);
            }
            densityDef.Ranges = ranges.Count == 0 ? null : ranges.ToArray();
        }
Exemplo n.º 7
0
        private void tsmiSaveFile_Click(object sender, EventArgs e)
        {
            if (_rangeList == null || _rangeList.Count == 0)
            {
                MessageBox.Show("请先设置密度分割范围,然后保存方案!", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string         filename       = null;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "XML文件|*.xml|所有文件|*.*";
            saveFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + @"\\SesitySliceForm\";
            if (!Directory.Exists(saveFileDialog.InitialDirectory))
            {
                Directory.CreateDirectory(saveFileDialog.InitialDirectory);
            }
            saveFileDialog.FileName = CreateFileName();
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                filename = saveFileDialog.FileName;
            }
            else
            {
                return;
            }
            DensityDef densityDef = new DensityDef();

            densityDef.MaxValue       = _maxValue;
            densityDef.MinValue       = _minValue;
            densityDef.Interval       = _interval;
            densityDef.RangeCount     = _rangeList.Count;
            densityDef.ApplayInterval = ckInterval.Checked;
            List <DensityRange> ranges = new List <DensityRange>();

            for (int i = 0; i < _rangeList.Count; i++)
            {
                DensityRange tempRange = new DensityRange();
                tempRange.minValue = _rangeList[i].minValue;
                tempRange.maxValue = _rangeList[i].maxValue;
                tempRange.RGB_r    = _rangeList[i].RGB_r;
                tempRange.RGB_g    = _rangeList[i].RGB_g;
                tempRange.RGB_b    = _rangeList[i].RGB_b;
                ranges.Add(tempRange);
            }
            densityDef.Ranges = ranges.ToArray();
            DensitySolution.Save(filename, densityDef);
        }
Exemplo n.º 8
0
        public EditRange(DensityRange dr)
        {
            InitializeComponent();

            this.TopMost = true;
            this.redText.DataBindings.Add("Text", this, "Red", true, DataSourceUpdateMode.OnPropertyChanged);
            this.redTrack.DataBindings.Add("Value", this, "Red", true, DataSourceUpdateMode.OnPropertyChanged);
            this.greenText.DataBindings.Add("Text", this, "Green", true, DataSourceUpdateMode.OnPropertyChanged);
            this.greenTrack.DataBindings.Add("Value", this, "Green", true, DataSourceUpdateMode.OnPropertyChanged);
            this.blueText.DataBindings.Add("Text", this, "Blue", true, DataSourceUpdateMode.OnPropertyChanged);
            this.blueTrack.DataBindings.Add("Value", this, "Blue", true, DataSourceUpdateMode.OnPropertyChanged);
            this.MinText.Text = dr.minValue.ToString();
            this.MaxText.Text = dr.maxValue.ToString();
            this.Red          = dr.RGB_r;
            this.Green        = dr.RGB_g;
            this.Blue         = dr.RGB_b;
            UpdateColor();
        }
Exemplo n.º 9
0
 private void GetMinMaxValue(ref DensityRange dr)
 {
     if (lstDensityRange.SelectedIndex - 1 < 0)
     {
         dr.minValue = _rangeList[lstDensityRange.SelectedIndex].minValue;
     }
     else
     {
         dr.minValue = _rangeList[lstDensityRange.SelectedIndex - 1].maxValue;
     }
     if (lstDensityRange.SelectedIndex + 1 >= lstDensityRange.Items.Count)
     {
         dr.maxValue = _rangeList[lstDensityRange.SelectedIndex].maxValue;
     }
     else
     {
         dr.maxValue = _rangeList[lstDensityRange.SelectedIndex + 1].minValue;
     }
 }
Exemplo n.º 10
0
        private List <DensityRange> InitRange()
        {
            List <DensityRange> m_RangeList = new List <DensityRange>();

            float length = _max_value - _min_value;
            float step   = length / _devide_num;

            if (_intervalType == IntervalType.IntType)
            {
                step = (int)Math.Ceiling(step);
            }

            for (int i = 0; i < _devide_num; i++)
            {
                switch (i)
                {
                case 0:
                    DensityRange range0 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 255, 0, 0);    //red
                    m_RangeList.Add(range0);
                    break;

                case 1:
                    DensityRange range1 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 0, 255, 0);    //green
                    m_RangeList.Add(range1);
                    break;

                case 2:
                    DensityRange range2 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 0, 0, 255);    //blue
                    m_RangeList.Add(range2);
                    break;

                case 3:
                    DensityRange range3 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 255, 255, 0);    //yellow
                    m_RangeList.Add(range3);
                    break;

                case 4:
                    DensityRange range4 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 0, 255, 255);    //cyan
                    m_RangeList.Add(range4);
                    break;

                case 5:
                    DensityRange range5 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 255, 0, 255);    //magenta
                    m_RangeList.Add(range5);
                    break;

                case 6:
                    DensityRange range6 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step) - 1, 176, 48, 96);    //maroon
                    m_RangeList.Add(range6);
                    break;

                case 7:
                    DensityRange range7 = new DensityRange(_min_value + (i * step), _min_value + ((i + 1) * step), 46, 139, 87);    //sea green
                    m_RangeList.Add(range7);
                    break;

                default:
                    break;
                }
            }

            return(m_RangeList);
        }