Esempio n. 1
0
 private void InitLoadProductDicList(string selectedFilename)
 {
     listBox1.Items.Clear();
     foreach (ProductDic product in _productDics)
     {
         listBox1.Items.Add(product);
     }
     listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
     if (listBox1.Items.Count != 0)
     {
         ProductDic selectedPdc = null;
         if (!string.IsNullOrWhiteSpace(selectedFilename))
         {
             foreach (ProductDic product in _productDics)
             {
                 if (selectedFilename == product.FileName)
                 {
                     selectedPdc = product;
                     break;
                 }
             }
         }
         if (selectedPdc == null)
         {
             selectedPdc = _productDics[0];
         }
         listBox1.SelectedItem = selectedPdc;
     }
 }
Esempio n. 2
0
        void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TryAskSave();
            ProductDic product = listBox1.SelectedItem as ProductDic;

            LoadCurProductColorTable(product);
        }
Esempio n. 3
0
 private void Export()
 {
     using (SaveFileDialog diag = new SaveFileDialog())
     {
         diag.Title  = "导出产品颜色表";
         diag.Filter = "产品颜色表(*.pct)|*.pct|所有文件(*.*)|*.*";
         ProductDic product = listBox1.SelectedItem as ProductDic;
         diag.FileName = Path.GetFileNameWithoutExtension(product.FileName);
         if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string filename = diag.FileName;
             ProductColorTableParser.WriteToXml(_selectedProductColorTables, filename);
         }
     }
 }
Esempio n. 4
0
        private void InitLoadColorTables(string selectedFilename)
        {
            ProductColorTableParser parser = new ProductColorTableParser();

            string[]     files = parser.LoadColorTables();
            ProductDic[] pdcs  = new ProductDic[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                ProductDic pdc = new ProductDic();
                pdc.FileName        = files[i];
                pdc.ProductIdentify = Path.GetFileNameWithoutExtension(files[i]);
                pdcs[i]             = pdc;
            }
            TrySetProductDicName(pdcs);
            _productDics = pdcs;
            InitLoadProductDicList(selectedFilename);
        }
Esempio n. 5
0
        private void LoadCurProductColorTable(ProductDic product)
        {
            _selectedProductDic         = product;
            _selectedProductColorTables = null;
            _selectedProductColorTable  = null;
            if (product == null || string.IsNullOrWhiteSpace(product.FileName))
            {
                ClearPcts();
                return;
            }
            ProductColorTableParser parser = new ProductColorTableParser();

            _selectedProductColorTables = ProductColorTableParser.Parse(product.FileName);
            if (_selectedProductColorTables == null)
            {
                ClearPcts();
            }
            else
            {
                LoadColorTable(_selectedProductColorTables);
            }
        }