public RoundhouseRedGateCompareRunner(KnownFolders known_folders, FileSystemAccess file_system, ConfigurationPropertyHolder configuration, RoundhouseMigrationRunner migration_runner)
 {
     this.known_folders = known_folders;
     this.file_system = file_system;
     this.configuration = configuration;
     this.migration_runner = migration_runner;
 }
 public RoundhouseMigrationRunner(
     string repository_path,
     Environment environment,
     KnownFolders known_folders,
     FileSystemAccess file_system,
     DatabaseMigrator database_migrator,
     VersionResolver version_resolver,
     bool silent,
     bool dropping_the_database,
     bool dont_create_the_database,
     bool run_in_a_transaction,
     bool use_simple_recovery,
     ConfigurationPropertyHolder configuration)
 {
     this.known_folders = known_folders;
     this.repository_path = repository_path;
     this.environment = environment;
     this.file_system = file_system;
     this.database_migrator = database_migrator;
     this.version_resolver = version_resolver;
     this.silent = silent;
     this.dropping_the_database = dropping_the_database;
     this.dont_create_the_database = dont_create_the_database;
     this.run_in_a_transaction = run_in_a_transaction;
     this.use_simple_recovery = use_simple_recovery;
     this.configuration = configuration;
 }
Exemplo n.º 3
0
 public FileSystemInitializer(KnownFolders knownFolders)
 {
     _knownFolders = knownFolders;
 }
Exemplo n.º 4
0
 private void OpenMyDocs(object sender, RoutedEventArgs e)
 {
     FolderHelper.OpenLocation(KnownFolders.GetPath(KnownFolder.Documents));
 }
Exemplo n.º 5
0
 private void OpenDownloads(object sender, RoutedEventArgs e)
 {
     FolderHelper.OpenLocation(KnownFolders.GetPath(KnownFolder.Downloads));
 }
Exemplo n.º 6
0
 private void OpenMyVideos(object sender, RoutedEventArgs e)
 {
     FolderHelper.OpenLocation(KnownFolders.GetPath(KnownFolder.Videos));
 }
Exemplo n.º 7
0
 private void OpenMyMusic(object sender, RoutedEventArgs e)
 {
     FolderHelper.OpenLocation(KnownFolders.GetPath(KnownFolder.Music));
 }
Exemplo n.º 8
0
 private void OpenMyPics(object sender, RoutedEventArgs e)
 {
     FolderHelper.OpenLocation(KnownFolders.GetPath(KnownFolder.Pictures));
 }
Exemplo n.º 9
0
        private void Setup(string ip)
        {
            string xml = "";

            if (this.cascadeClassifier == null)
            {
                Task.Run(async() => {
                    StorageFolder picturesLibrary = await KnownFolders.GetFolderForUserAsync(null /* current user */, KnownFolderId.DocumentsLibrary);
                    var sampleFile = (StorageFile)await picturesLibrary.TryGetItemAsync(@"cascades\haarcascade_mcs_upperbody.xml");
                    if (sampleFile != null)
                    {
                        using (var inputStream = await sampleFile.OpenReadAsync()) {
                            Byte[] bytes = new Byte[inputStream.Size];
                            var buffer   = await inputStream.ReadAsync(bytes.AsBuffer(), (uint)inputStream.Size, Windows.Storage.Streams.InputStreamOptions.None);
                            bytes        = buffer.ToArray();
                            xml          = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
                        }
                    }
                }).Wait();
                this.cascadeClassifier = new HaarRuntimeComponent.Class1(xml);
            }

            if (this.requestHandlers == null)
            {
                this.requestHandlers = new Dictionary <string, Func <byte[], bool> >()
                {
                    { "/kinect/request/facetrack/bounds", HandleRequestFaceTrackBounds }
                };
            }

            if (this.client == null)
            {
                this.client = new MqttClient(ip);
                this.client.ProtocolVersion         = MqttProtocolVersion.Version_3_1;
                this.client.MqttMsgPublishReceived += this.onMqttReceive;
                this.client.Subscribe(this.requestHandlers.Keys.ToArray(), Enumerable.Repeat(MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, this.requestHandlers.Count).ToArray());
                this.client.Connect(Guid.NewGuid().ToString());
            }

            if (this.frames == null)
            {
                this.frames = new Dictionary <MediaFrameSourceKind, MediaFrameReference>()
                {
                    { MediaFrameSourceKind.Color, null },
                    { MediaFrameSourceKind.Depth, null }
                }
            }
            ;

            if (this.mediaCapture == null)
            {
                // select device with both color and depth streams
                var cameras  = Task.Run(async() => { return(await MediaFrameSourceGroup.FindAllAsync()); });
                var eligible = cameras.Result.Select(c => new {
                    Group       = c,
                    SourceInfos = new MediaFrameSourceInfo[] {
                        c.SourceInfos.FirstOrDefault(info => info.SourceKind == MediaFrameSourceKind.Color),
                        c.SourceInfos.FirstOrDefault(info => info.SourceKind == MediaFrameSourceKind.Depth)
                    }
                }).Where(c => c.SourceInfos[0] != null && c.SourceInfos[1] != null).ToList();
                if (eligible.Count == 0)
                {
                    return;
                }
                var selected = eligible[0];

                // open device
                this.mediaCapture = new MediaCapture();
                Task.Run(async() => {
                    await this.mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings {
                        SourceGroup          = selected.Group,
                        SharingMode          = MediaCaptureSharingMode.SharedReadOnly,
                        StreamingCaptureMode = StreamingCaptureMode.Video,
                        MemoryPreference     = MediaCaptureMemoryPreference.Cpu
                    });
                }).Wait();

                // set stream callbacks
                for (int i = 0; i < selected.SourceInfos.Length; ++i)
                {
                    MediaFrameSourceInfo info        = selected.SourceInfos[i];
                    MediaFrameSource     frameSource = null;
                    if (this.mediaCapture.FrameSources.TryGetValue(info.Id, out frameSource))
                    {
                        var frameReader = Task.Run(async() => { return(await this.mediaCapture.CreateFrameReaderAsync(frameSource)); });
                        frameReader.Result.FrameArrived += FrameReader_FrameArrived;
                        var status = Task.Run(async() => { return(await frameReader.Result.StartAsync()); });
                        if (status.Result != MediaFrameReaderStartStatus.Success)
                        {
                            return;
                        }
                    }
                }
            }

            // start clock
            this.appClock.Start();
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// Variables From BackUpTimer Form End
        /// </summary>


        public frmMain()
        {
            InitializeComponent();

            ///
            /// Initialize for BackUpPersonalFiles Form Controls/Vars Start
            ///

            Name       = "BackUpMe";
            myPic      = KnownFolders.GetPath(KnownFolder.Pictures);
            myVid      = KnownFolders.GetPath(KnownFolder.Videos);
            myMus      = KnownFolders.GetPath(KnownFolder.Music);
            myDoc      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            myDL       = KnownFolders.GetPath(KnownFolder.Downloads);
            myDesk     = KnownFolders.GetPath(KnownFolder.Desktop);
            th         = new Thread(checkWhatCopy);
            folderName = new ArrayList();
            foreach (string know in Directory.GetDirectories(myDoc))
            {
                folderName.Add(know);
            }


            b         = folderName.Count;
            countPic  = Directory.GetFiles(myPic, "*.*", SearchOption.AllDirectories).Length;
            countVid  = Directory.GetFiles(myVid, "*.*", SearchOption.AllDirectories).Length;
            countMus  = Directory.GetFiles(myMus, "*.*", SearchOption.AllDirectories).Length;
            countDL   = Directory.GetFiles(myDL, "*.*", SearchOption.AllDirectories).Length;
            countDesk = Directory.GetFiles(myDesk, "*.*", SearchOption.AllDirectories).Length;

            for (int i = 0; i < b; i++)
            {
                if ((folderName[i].ToString() != myDoc + "\\My Music") && (folderName[i].ToString() != myDoc + "\\My Pictures") && (folderName[i].ToString() != myDoc + "\\My Videos"))
                {
                    countDoc += Directory.GetFiles(folderName[i].ToString(), "*.*", SearchOption.AllDirectories).Length;
                }
            }
            count = countPic + countDesk + countVid + countDL + countMus;

            ///
            /// Initialize for BackUpPersonalFiles Form End
            ///

            ///
            /// Initialize for BackUpTime Form Controls/Vars Start
            ///

            cbxList.Add(new ListId(0, "Weeks"));
            cbxList.Add(new ListId(1, "Days"));
            cbxList.Add(new ListId(2, "Hours"));
            cbxList.Add(new ListId(3, "Minutes"));
            cbxList.Add(new ListId(4, "Seconds"));
            cbxList.Add(new ListId(5, "Manual"));
            cbx_Mode.DataSource    = cbxList;
            cbx_Mode.DisplayMember = "Descr";
            cbx_Mode.ValueMember   = "Mode";
            cbx_Mode.SelectedIndex = 5;


            dtgrdvDisplay.ColumnCount = 5;
            //DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
            //dtgrdvDisplay.Columns.Add(chk);
            //chk.HeaderText = "Check Data";
            //chk.Name = "chk";
            dtgrdvDisplay.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dtgrdvDisplay.Columns[0].Name     = "Backup Job Name";
            dtgrdvDisplay.Columns[1].Name     = "Origin";
            dtgrdvDisplay.Columns[2].Name     = "Destination";
            dtgrdvDisplay.Columns[3].Name     = "Schedule";
            dtgrdvDisplay.Columns[4].Name     = "Last Run";
            dtgrdvDisplay.Font = new Font(FontFamily.GenericSansSerif, 9.0F, FontStyle.Bold);

            //dtgrdvDisplay.DataSource = source;
            // Check to see the current state (running at startup or not)
            if (rkApp.GetValue("MyApp") == null)
            {
                // The value doesn't exist, the application is not set to run at startup
                mnu_StartWithWindows.Checked  = false;
                ntfMnu_RunWithWindows.Checked = false;
            }
            else
            {
                // The value exists, the application is set to run at startup
                mnu_StartWithWindows.Checked  = true;
                ntfMnu_RunWithWindows.Checked = true;
            }

            ///
            /// Initialize for BackUpTime Form End
            ///
        }
Exemplo n.º 11
0
        /// <summary>
        /// Saves a Markdown Document to file with Save UI.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="saveAsEncrypted"></param>
        /// <returns></returns>
        public static bool SaveMarkdownDocumentToFile(MarkdownDocument doc = null, bool saveAsEncrypted = false)
        {
            if (doc == null)
            {
                doc = mmApp.Model.ActiveDocument;
            }

            string filename = Path.GetFileName(doc.Filename);
            string folder   = Path.GetDirectoryName(doc.Filename);

            if (filename == null)
            {
                filename = "untitled";
            }

            if (folder == null)
            {
                folder = mmApp.Configuration.LastFolder;
            }

            if (filename == "untitled")
            {
                folder = mmApp.Configuration.LastFolder;

                var match = Regex.Match(doc.CurrentText, @"^# (\ *)(?<Header>.+)", RegexOptions.Multiline);

                if (match.Success)
                {
                    filename = match.Groups["Header"].Value;
                    if (!string.IsNullOrEmpty(filename))
                    {
                        filename = FileUtils.SafeFilename(filename);
                    }
                }
            }

            if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder))
            {
                folder = mmApp.Configuration.LastFolder;
                if (string.IsNullOrEmpty(folder) || !Directory.Exists(folder))
                {
                    folder = KnownFolders.GetPath(KnownFolder.Libraries);
                }
            }


            SaveFileDialog sd = new SaveFileDialog
            {
                FilterIndex      = 1,
                InitialDirectory = folder,
                FileName         = filename,
                CheckFileExists  = false,
                OverwritePrompt  = true,
                CheckPathExists  = true,
                RestoreDirectory = true
            };


            bool?result = null;

            try
            {
                result = sd.ShowDialog();
            }
            catch (Exception ex)
            {
                mmApp.Log("Unable to save file: " + doc.Filename, ex);
                MessageBox.Show(
                    $@"Unable to open file:\r\n\r\n" + ex.Message,
                    "An error occurred trying to open a file",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }

            if (!saveAsEncrypted)
            {
                doc.Password = null;
            }
            else
            {
                var pwdDialog = new FilePasswordDialog(doc, false)
                {
                    Owner = mmApp.Model.Window
                };
                bool?pwdResult = pwdDialog.ShowDialog();
            }

            if (result == null || !result.Value)
            {
                return(false);
            }

            doc.Filename = sd.FileName;

            if (!doc.Save())
            {
                MessageBox.Show(mmApp.Model.Window,
                                $"{sd.FileName}\r\n\r\nThis document can't be saved in this location. The file is either locked or you don't have permissions to save it. Please choose another location to save the file.",
                                "Unable to save Document", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }
            mmApp.Configuration.LastFolder = Path.GetDirectoryName(sd.FileName);
            return(true);
        }
Exemplo n.º 12
0
 /// <summary>
 /// btn in download page (Download Sort)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click_DownloadSort(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(Properties.Settings.Default.MainBackupFolder))
     {
         MessageBox.Show("You need to install the main backup folder in the settings", "Error",
                         MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         var bk = new Sort();
         bk.SortFolder(DelFiles.IsChecked.Value, SortExtended.IsChecked.Value, KnownFolders.GetPath(KnownFolder.Downloads));
     }
 }
Exemplo n.º 13
0
        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 1)
            {
                throw new NotSupportedException(
                          "Cannot select multiple folders.");
            }
            string      who = (string)listBox1.SelectedItem;
            KnownFolder kf;

            try
            {
                kf = KnownFolders.GetKnownFolder(who, false);
            }
            catch (FileNotFoundException)
            {
                // It is possible for files to not be defined
                // on a system.
                nameText.Text       = who;
                nameText.ToolTip    = "";
                pathText.Text       = "The folder is not valid for this system.";
                pathText.Foreground = Brushes.Red;
                ClearDetails();

                return;
            }

            nameText.Text          = kf.Name;
            nameText.ToolTip       = kf.FolderId;
            canonicalNameText.Text = kf.CanonicalName;
            attributeText.Text     = kf.FileAttributes.ToString();

            if (kf.PathExists == null)
            {
                pathText.Text       = "(virtual)";
                pathText.Foreground = Brushes.Gray;
            }
            else if (kf.PathExists == false)
            {
                pathText.Text       = "(file does not exist on this computer.)";
                pathText.Foreground = System.Windows.Media.Brushes.Gray;
            }
            else
            {
                pathText.Text       = kf.Path;
                pathText.Foreground = System.Windows.Media.Brushes.Black;
            }
            relativePathText.Text = kf.RelativePath;
            if (kf.ParentId != Guid.Empty)
            {
                parentText.Text    = kf.Parent;
                parentText.ToolTip = kf.ParentId.ToString();
            }
            else
            {
                parentText.Text    = String.Empty;
                parentText.ToolTip = String.Empty;
            }
            securityText.Text         = kf.Security;
            folderTypeText.Text       = kf.FolderType;
            folderTypeText.ToolTip    = kf.FolderTypeId.ToString();
            categoryText.Text         = kf.Category.ToString();
            definitionText.Text       = kf.DefinitionOptions.ToString();
            redirectionText.Text      = kf.Redirection.ToString();
            localizedNameText.Text    = kf.LocalizedName;
            localizedNameText.ToolTip = kf.LocalizedNameResourceId;
            descriptionText.Text      = kf.Description;
            parsingNameText.Text      = kf.ParsingName;

            if (!String.IsNullOrEmpty(kf.Tooltip))
            {
                iconText.Text       = kf.Tooltip;
                iconText.Foreground = Brushes.Black;
                iconText.ToolTip    = kf.TooltipResourceId;
            }
            else
            {
                iconText.Text       = "(no tool tip)";
                iconText.Foreground = Brushes.Gray;
                iconText.ToolTip    = String.Empty;
            }
            if (kf.Icon != null)
            {
                iconImage.Source  = kf.Icon;
                iconImage.ToolTip = kf.IconResourceId;
            }
            else
            {
                iconImage.Source  = null;
                iconImage.ToolTip = String.Empty;
            }
        }
Exemplo n.º 14
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SortedList <string, Guid> f = KnownFolders.GetAllFolders();

            listBox1.ItemsSource = f.Keys;
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            Program.args = args;

            mConsole = WinConsole.Initialize(TestArg("-console"));

            if (TestArg("-help") || TestArg("/?"))
            {
                ShowHelp();
                return;
            }

            if (TestArg("-dbg_wait"))
            {
                MessageBox.Show("Waiting for debugger. (press ok when attached)");
            }

            Console.WriteLine("Starting...");

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            mVersion = fvi.FileMajorPart + "." + fvi.FileMinorPart;
            if (fvi.FileBuildPart != 0)
            {
                mVersion += (char)('a' + (fvi.FileBuildPart - 1));
            }

            AppLog Log = new AppLog();

            AppLog.Line("{0}, Version v{1} by David Xanatos", mName, mVersion);
            AppLog.Line("This Tool is Open Source under the GNU General Public License, Version 3\r\n");

            ipc = new PipeIPC("wumgr_pipe");

            var client = ipc.Connect(100);

            if (client != null)
            {
                AppLog.Line("Application is already running.");
                client.Send("show");
                string ret = client.Read(1000);
                if (!ret.Equals("ok", StringComparison.CurrentCultureIgnoreCase))
                {
                    MessageBox.Show(MiscFunc.fmt("Application is already running."));
                }
                return;
            }

            if (!MiscFunc.IsAdministrator() && !MiscFunc.IsDebugging())
            {
                Console.WriteLine("Trying to get admin privilegs...");

                if (SkipUacRun())
                {
                    Application.Exit();
                    return;
                }

                if (!MiscFunc.IsRunningAsUwp())
                {
                    Console.WriteLine("Trying to start with 'runas'...");
                    // Restart program and run as admin
                    var              exeName   = Process.GetCurrentProcess().MainModule.FileName;
                    string           arguments = "\"" + string.Join("\" \"", args) + "\"";
                    ProcessStartInfo startInfo = new ProcessStartInfo(exeName, arguments);
                    startInfo.UseShellExecute = true;
                    startInfo.Verb            = "runas";
                    try
                    {
                        Process.Start(startInfo);
                        Application.Exit();
                        return;
                    }
                    catch
                    {
                        //MessageBox.Show(MiscFunc.fmt("The {0} requirers Administrator privilegs in order to install updates", mName), mName);
                        AppLog.Line("Administrator privilegs are required in order to install updates.");
                    }
                }
            }

            wrkPath = appPath = Path.GetDirectoryName(Application.ExecutablePath);

            if (!FileOps.TestWrite(GetINIPath()))
            {
                Console.WriteLine("Can't write to default working directory.");

                string downloadFolder = KnownFolders.GetPath(KnownFolder.Downloads);
                if (downloadFolder == null)
                {
                    downloadFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
                }

                wrkPath = downloadFolder + @"\WuMgr";
                try
                {
                    if (!Directory.Exists(wrkPath))
                    {
                        Directory.CreateDirectory(wrkPath);
                    }
                }
                catch
                {
                    MessageBox.Show(MiscFunc.fmt("Can't write to working directory: {0}", wrkPath), mName);
                }
            }

            /*switch(FileOps.TestFileAdminSec(mINIPath))
             * {
             *  case 0:
             *      AppLog.Line("Warning wumgr.ini was writable by non administrative users, it was renamed to wumgr.ini.old and replaced with a empty one.\r\n");
             *      if (!FileOps.MoveFile(mINIPath, mINIPath + ".old", true))
             *          return;
             *      goto case 2;
             *  case 2: // file missing, create
             *      FileOps.SetFileAdminSec(mINIPath);
             *      break;
             *  case 1: // every thign's fine ini file is only writable by admins
             *      break;
             * }*/

            AppLog.Line("Working Directory: {0}", wrkPath);

            Agent = new WuAgent();

            ExecOnStart();

            Agent.Init();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WuMgr());

            Agent.UnInit();

            ExecOnClose();
        }
Exemplo n.º 16
0
 public FileSystemInitializer(KnownFolders knownFolders)
 {
     _knownFolders = knownFolders;
 }
Exemplo n.º 17
0
        private async void GetFilesButton_Click(object sender, RoutedEventArgs e)
        {
            // Reset output.
            OutputPanel.Children.Clear();

            // Set up file type filter.
            List <string> fileTypeFilter = new List <string>();

            fileTypeFilter.Add(".jpg");
            fileTypeFilter.Add(".png");
            fileTypeFilter.Add(".bmp");
            fileTypeFilter.Add(".gif");

            // Create query options.
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);

            // Set up property prefetch - use the PropertyPrefetchOptions for top-level properties
            // and a list for additional properties.
            List <string> propertyNames = new List <string>();

            propertyNames.Add(CopyrightProperty);
            propertyNames.Add(ColorSpaceProperty);
            queryOptions.SetPropertyPrefetch(PropertyPrefetchOptions.ImageProperties, propertyNames);

            // Set up thumbnail prefetch if needed, e.g. when creating a picture gallery view.

            /*
             * const uint requestedSize = 190;
             * const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView;
             * const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale;
             * queryOptions.SetThumbnailPrefetch(thumbnailMode, requestedSize, thumbnailOptions);
             */

            // Set up the query and retrieve files.
            StorageFolder picturesFolder = await KnownFolders.GetFolderForUserAsync(null /* current user */, KnownFolderId.PicturesLibrary);

            var query = picturesFolder.CreateFileQueryWithOptions(queryOptions);
            IReadOnlyList <StorageFile> fileList = await query.GetFilesAsync();

            foreach (StorageFile file in fileList)
            {
                OutputPanel.Children.Add(CreateHeaderTextBlock(file.Name));

                // GetImagePropertiesAsync will return synchronously when prefetching has been able to
                // retrieve the properties in advance.
                var properties = await file.Properties.GetImagePropertiesAsync();

                OutputPanel.Children.Add(CreateLineItemTextBlock("Dimensions: " + properties.Width + "x" + properties.Height));

                // Similarly, extra properties are retrieved asynchronously but may
                // return immediately when prefetching has fulfilled its task.
                IDictionary <string, object> extraProperties = await file.Properties.RetrievePropertiesAsync(propertyNames);

                var propValue = extraProperties[CopyrightProperty];
                OutputPanel.Children.Add(CreateLineItemTextBlock("Copyright: " + GetPropertyDisplayValue(propValue)));
                propValue = extraProperties[ColorSpaceProperty];
                OutputPanel.Children.Add(CreateLineItemTextBlock("Color space: " + GetPropertyDisplayValue(propValue)));

                // Thumbnails can also be retrieved and used.
                // var thumbnail = await file.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
            }
        }