Exemplo n.º 1
0
 static public bool LoadXmlFile <T>(Stream filestream, out T obj, Type[] extra = null)
 {
     try
     {
         var xmlSettings = new System.Xml.XmlReaderSettings()
         {
             CheckCharacters = false,
         };
         XmlSerializer serializer = new XmlSerializer(typeof(T), extra);
         using (var streamReader = new StreamReader(filestream, Encoding.UTF8))
         {
             using (var xmlReader = System.Xml.XmlReader.Create(streamReader, xmlSettings))
             {
                 obj = (T)serializer.Deserialize(xmlReader);
             }
         }
     }
     catch (Exception ex)
     {
         LogStatics.Debug(ex.ToString());
         obj = default(T);
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// Get all nodes under the specified rootPath.
        /// </summary>
        /// <param name="rootPath">The rootPath must at least contains the drive and may include any number of subdirectories. Wildcards aren't supported.</param>
        public List <INode> GetNodes(string rootPath)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            List <INode> nodes = new List <INode>();

            //TODO use Parallel.Net to process this when it becomes available
            UInt32 nodeCount = (UInt32)_nodes.Length;

            for (UInt32 i = 0; i < nodeCount; ++i)
            {
                if (_nodes[i].NameIndex != 0 && GetNodeFullNameCore(i).StartsWith(rootPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    nodes.Add(new NodeWrapper(this, i, _nodes[i]));
                }
            }

            stopwatch.Stop();

            LogStatics.Debug(
                string.Format(
                    "{0} node{1} have been retrieved in {2} ms",
                    nodes.Count,
                    nodes.Count > 1 ? "s" : string.Empty,
                    (float)stopwatch.ElapsedTicks / TimeSpan.TicksPerMillisecond
                    )
                );

            return(nodes);
        }
        private async void SearchAsync(string text)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Restart();
            if (Finder.IsReady)
            {
                _cancellation?.Cancel();
                _cancellation       = new CancellationTokenSource();
                _cancellation_token = _cancellation.Token;
                try
                {
                    StatusText = "検索中...";
                    var SearchedList = await Finder.SearchFileAsync(text, SearchRange, SearchMax, _cancellation_token);

                    _SearchResults = new ObservableCollection <FileFinderDisplayItemViewModel>(SearchedList.Select(x => new FileFinderDisplayItemViewModel(x)));
                    RefreshDisplayItemVisibility();
                    StatusText = "検索完了";
                }
                catch (OperationCanceledException)
                {
                }
            }
            stopwatch.Stop();
            LogStatics.Debug(string.Format("call Search at {0:F3} s", (float)stopwatch.Elapsed.TotalSeconds));
        }
Exemplo n.º 4
0
        private void WatermarkTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            TextBox textBox = (TextBox)sender;

            try
            {
                converter.ConvertFromString(e.Text.ToUpper());
                textBox.Text = string.Empty;
            }
            catch (Exception ex)
            {
                LogStatics.Debug(ex.ToString());
                e.Handled    = false;
                textBox.Text = string.Empty;
            }
        }
Exemplo n.º 5
0
 static public bool SaveXmlFile <T>(Stream filestream, T obj, Type[] extra = null)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(T), extra);
         using (var streamWriter = new StreamWriter(filestream, Encoding.UTF8))
         {
             serializer.Serialize(streamWriter, obj);
             streamWriter.Flush();
         }
     }
     catch (Exception ex)
     {
         LogStatics.Debug(ex.ToString());
         return(false);
     }
     return(true);
 }
        public void Execute(LauncherCommandInfo CommandInfo)
        {
            string[] Commands     = ParseCommandList(CommandInfo);
            int      CommnadCount = Commands.Count();

            foreach (var Command in Commands.Select((command, index) => new { command, index }))
            {
                bool IsImmediately = Command.index != CommnadCount - 1 || (App.AppConfig.IsImmediately && CommandInfo.IsImmediately);
                try
                {
                    if (App.AppConfig.IsCopyToClipboard || !IsImmediately)
                    {
                        System.Windows.Forms.Clipboard.Clear();
                        System.Threading.Thread.Sleep(100);
                        System.Windows.Forms.Clipboard.SetText(Command.command);
                    }
                }
                catch (Exception ex)
                {
                    LogStatics.Debug(ex.ToString());
                }
                switch (CommandInfo.Type)
                {
                case CommandExecuteType.None:
                    break;

                case CommandExecuteType.Command:
                    foreach (var CommandModule in App.PluginManagerInstance.CommandExecuteModules)
                    {
                        if (CommandModule.CanExecute(Command.command, IsImmediately))
                        {
                            CommandModule.Execute(Command.command, IsImmediately);
                        }
                    }
                    break;

                case CommandExecuteType.FileOpen:
                    ExecuteFileOpen(Command.command);
                    break;
                }
            }
        }
 public void Info(string message, params object[] args)
 {
     LogStatics.Info(message, args);
 }
 public void Info(string message)
 {
     LogStatics.Info(message);
 }
Exemplo n.º 9
0
 private static void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     LogStatics.Fatal(e.Exception, "App_DispatcherUnhandledException");
 }
Exemplo n.º 10
0
 public void Warn(string message)
 {
     LogStatics.Warn(message);
 }
Exemplo n.º 11
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     LogStatics.Fatal(e.ExceptionObject as Exception, "CurrentDomain_UnhandledException");
 }
Exemplo n.º 12
0
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     LogStatics.Fatal(e.Exception, "TaskScheduler_UnobservedTaskException");
 }
Exemplo n.º 13
0
 public void Fatal(string message, params object[] args)
 {
     LogStatics.Fatal(message, args);
 }
Exemplo n.º 14
0
 public void Error(string message)
 {
     LogStatics.Error(message);
 }
Exemplo n.º 15
0
 public void Debug(string message)
 {
     LogStatics.Debug(message);
 }
Exemplo n.º 16
0
 public void Fatal(Exception exception, string message)
 {
     LogStatics.Fatal(exception, message);
 }
Exemplo n.º 17
0
 public void Error(Exception exception, string message, params object[] args)
 {
     LogStatics.Error(exception, message, args);
 }
Exemplo n.º 18
0
 public void Error(string message, params object[] args)
 {
     LogStatics.Error(message, args);
 }
Exemplo n.º 19
0
 public void Error(Exception exception, string message)
 {
     LogStatics.Error(exception, message);
 }
Exemplo n.º 20
0
 public void Debug(string message, params object[] args)
 {
     LogStatics.Debug(message, args);
 }
Exemplo n.º 21
0
 public void Fatal(Exception exception, string message, params object[] args)
 {
     LogStatics.Fatal(exception, message, args);
 }
Exemplo n.º 22
0
 public void Fatal(string message)
 {
     LogStatics.Fatal(message);
 }
Exemplo n.º 23
0
 public void Warn(string message, params object[] args)
 {
     LogStatics.Warn(message, args);
 }