示例#1
0
 public void registerWatcher()
 {
     if (linkedFilePath != null)
     {
         SetupWizard.registerFileWatch(linkedFilePath, this);
     }
 }
示例#2
0
        public SetupWizard(MainWindow mw)
        {
            InitializeComponent();
            inspectedClasses = new ObservableCollection <ConvertedClass>();

            ContextMenu cm       = new ContextMenu();
            MenuItem    removeMI = new MenuItem();

            removeMI.Header = "Remove";

            _mw = mw;

            removeMI.Click += (rs, EventArgs) => { deleteClass(rs, EventArgs); };

            cm.Items.Add(removeMI);
            loadedScripts.ContextMenu = cm;

            /*Binding lhs = new Binding();
             * lhs.Converter = new Misc.ConvertedClassConvertor();
             * lhs.Path = new PropertyPath("name");
             * lhs.Source = inspectedClasses;
             *
             * loadedScripts.SetBinding(ListView.ItemsSourceProperty, lhs);*/
            loadedScripts.ItemsSource = inspectedClasses;


            if (variants.Count == 0)
            {
                loadVariants();
            }

            if (File.Exists("config/classinspections.txt"))
            {
                string stored = File.ReadAllText("config/classinspections.txt");
                var    deserializeSettings = new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.All
                };
                ObservableCollection <ConvertedClass> sv =
                    JsonConvert.DeserializeObject <ObservableCollection <ConvertedClass> >(stored, deserializeSettings);

                foreach (ConvertedClass cc in sv)
                {
                    cc.PropertyChanged += rebuildView;
                    inspectedClasses.Add(cc);

                    //loadedScripts.Items.Add(cc.name);
                    cc.registerWatcher();
                }
            }

            //loadedScripts.ItemsSource = loadedClasses;
            setupSingleton = this;
        }
示例#3
0
 private void MenuItem_Classes(object sender, RoutedEventArgs e)
 {
     Assistant.SetupWizard sw = new Assistant.SetupWizard(this);
     sw.Show();
 }
示例#4
0
        public static void registerFileWatch(string filePath, ConvertedClass cc)
        {
            if (filePath == null || fileWatchers.ContainsKey(filePath))
            {
                return;
            }

            Console.WriteLine("registering " + filePath);

            FileSystemWatcher fsw = new FileSystemWatcher();

            fsw.Path   = System.IO.Path.GetDirectoryName(filePath);
            fsw.Filter = System.IO.Path.GetFileName(filePath);

            fsw.EnableRaisingEvents = true;

            fileWatchers.Add(filePath, new ccFileWrapper(cc, fsw));
            //        this.textboxlink.Dispatcher.Invoke(DispatcherPriority.Normal,
            // new Action(() => { textBoxValue = this.textboxlink.Text; }));



            fsw.Changed += (object sender, FileSystemEventArgs e) => {
                setupSingleton.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { SetupWizard.reload(cc, filePath); }));
            };
        }