Exemplo n.º 1
0
 public static void Load()
 {
     if (File.Exists(FileName))
     {
         using (System.IO.Stream ReadStream = new FileStream(FileName, FileMode.Open))
         {
             BinaryFormatter binFormatter = new BinaryFormatter();
             Orders = binFormatter.Deserialize(ReadStream) as List <ManagedDirectory>;
         }
         foreach (var item in Orders)
         {
             if (item.Enabled && item.Option.RealtimeWatch)
             {
                 item.WatcherIndex = Watcher.Create(item);
             }
         }
     }
     else
     {
         Orders = new List <ManagedDirectory>();
     }
 }
Exemplo n.º 2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (CheckBoxIncludes.Checked == false)
            {
                TextBoxInclude.Text = string.Empty;
            }
            if (CheckBoxOptions.Checked == false)
            {
                TextBoxOptionStrings.Text = string.Empty;
            }
            if (CheckBoxDecludeStrings.Checked == false)
            {
                TextBoxDecludeStrings.Text = string.Empty;
            }
            if (CheckBoxFileExtensions.Checked == false)
            {
                TextBoxFileExtensions.Text = string.Empty;
            }

            DuplicateProcessing dp = DuplicateProcessing.None;

            if (dubCombobox.Text == Properties.Resources.OverwriteString)
            {
                dp = DuplicateProcessing.Overwrite;
            }
            else if (dubCombobox.Text == Properties.Resources.RenamingString)
            {
                dp = DuplicateProcessing.Renaming;
            }

            var option = new Option(
                GetArrayFromTextbox(TextBoxFileExtensions.Text),
                GetArrayFromTextbox(TextBoxInclude.Text),
                GetArrayFromTextbox(TextBoxDecludeStrings.Text),
                GetArrayFromTextbox(TextBoxOptionStrings.Text),
                RadioIsCopy.Checked,
                dp,
                RootSearch.Checked,
                RealTimeWatchService.Checked
                );

            var gen = new ManagedDirectory(
                TextBoxdeparture.Text,
                TextBoxDestination.Text,
                option
                );

            if (this.index == -1) // new obj
            {
                Setting.Orders.Add(gen);
            }
            else
            {
                Setting.Orders[index] = gen;
            }

            if (gen.Enabled && gen.Option.RealtimeWatch)
            {
                gen.WatcherIndex = Watcher.Create(gen);
            }

            this.Close();
        }