コード例 #1
0
        public NotifyMonitor()
        {
            InitializeComponent();
            acpiControl = (App.Current.MainWindow as MainWindow).acpiControl;
            DeviceNode[] deviceNodeArray = null;
            acpiControl.GetDeviceList(ref deviceNodeArray);
            deviceList = new DeviceList(deviceNodeArray, new IsCheckedChangedEventHandler(DeviceItemIsCheckedChanged));
            notifyList = new NotifyList(deviceList);
            //methodListBox.ItemsSource = methodList;
            notifyListBox.ItemsSource = notifyList;
            deviceListBox.ItemsSource = deviceList;


            Binding checkedBinding = new Binding("IsChecked");

            checkedBinding.Source    = deviceList;
            checkedBinding.Converter = intToIsCheckedConverter;
            checkBoxSelectAll.SetBinding(CheckBox.IsCheckedProperty, checkedBinding);
        }
コード例 #2
0
        static public String baseDirectory = AppDomain.CurrentDomain.BaseDirectory; //+ @"Save\";
        static public int SaveNotify(NotifyList notifyList)
        {
            DateTime dateTime = DateTime.Now;
            String   path     = baseDirectory + "Notify(.txt";// + dateTime.GetDateTimeFormats('s')[0].ToString() +").txt";    OpenFileDialog openFileDialog1 = new OpenFileDialog();

            Stream         myStream        = null;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.InitialDirectory = baseDirectory;
            saveFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = saveFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            StreamWriter sw = new StreamWriter(myStream);
                            for (int i = 0; i < notifyList.Count; i++)
                            {
                                sw.WriteLine(notifyList[i].NotifyInformation);
                            }
                            sw.Close();
                        }
                    }
                    myStream.Close();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
                return(0);
            }
            else
            {
                return(-1);
            }
        }