示例#1
0
 public void OnTotalCountUpdated(object sender, WebsocketEventArgs evt)
 {
     SynchronizationContextHelper.SendMainSyncContext(() =>
     {
         updateNotifyIconMenu(evt.ctx);
     });
 }
示例#2
0
        private void removeDeviceFromNotifyIconMenu(WebsocketEventArgs evt)
        {
            try
            {
                var key = evt.ctx;

                if (deviceStipItems.ContainsKey(key))
                {
                    var item = deviceStipItems[key];
                    if (notifyIcon.ContextMenuStrip.Items.Contains(item))
                    {
                        var nextIdx = notifyIcon.ContextMenuStrip.Items.IndexOf(item) + 1;
                        var item2   = notifyIcon.ContextMenuStrip.Items[nextIdx];

                        notifyIcon.ContextMenuStrip.Items.Remove(item);
                        notifyIcon.ContextMenuStrip.Items.Remove(item2);
                    }

                    deviceStipItems.Remove(key);
                }
            }
            catch (Exception err)
            {
                log4net.LogManager.GetLogger(GetType()).Warn("Error in removeDeviceFromNotifyIconMenu", err);
            }
        }
示例#3
0
 public void OnDeviceConnected(object sender, WebsocketEventArgs evt)
 {
     SynchronizationContextHelper.SendMainSyncContext(() =>
     {
         showNotifyIconMenu(evt.ctx);
     });
 }
示例#4
0
 public void OnFileReceiving(object sender, WebsocketEventArgs arg)
 {
     if (!arg.ctx.BackToPhoneDialogClosed)
     {
         BackToPhoneDialog.CloseOpenedWindow(arg.ctx);
         arg.ctx.BackToPhoneDialogClosed = true;
     }
 }
        private void raiseDeviceDisconnectedEvent(WebsocketEventArgs e)
        {
            var handler = DeviceDisconnected;

            if (handler != null)
            {
                handler(this, e);
            }
        }
示例#6
0
        public void FileReceived(object sender, WebsocketEventArgs args)
        {
            try
            {
                var file = args.ctx.fileCtx;


                if (file.type == FileAssetType.image)
                {
                    if (withinToday(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelPhotoToday };

                        updateLabels(args, labels);
                    }

                    if (withinYesterday(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelPhotoYesterday };
                        updateLabels(args, labels);
                    }

                    if (withinThisWeek(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelPhotoThisWeek };

                        updateLabels(args, labels);
                    }
                }
                else if (file.type == FileAssetType.video)
                {
                    if (withinToday(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelVideoToday };

                        updateLabels(args, labels);
                    }

                    if (withinYesterday(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelVideoYesterday };
                        updateLabels(args, labels);
                    }

                    if (withinThisWeek(file.datetime))
                    {
                        var labels = new Guid[] { Settings.Default.LabelVideoThisWeek };

                        updateLabels(args, labels);
                    }
                }
            }
            catch (Exception e)
            {
                log4net.LogManager.GetLogger(GetType()).Warn("unable to auto label on file: " + args.ctx.fileCtx.file_id, e);
            }
        }
        public void OnFileEnding(object sender, WebsocketEventArgs args)
        {
            var file_id   = args.ctx.fileCtx.file_id;
            var file_name = args.ctx.fileCtx.file_name;
            var file_type = args.ctx.fileCtx.type;

            SynchronizationContextHelper.SendMainSyncContext(() =>
            {
                showFile(file_id, file_name, file_type, args.ctx.device_name, args.ctx.device_id);
            });
        }
示例#8
0
        private void updateLabels(WebsocketEventArgs args, Guid[] labels)
        {
            using (var db = new SQLiteConnection(MyDbContext.ConnectionString))
            {
                db.Open();
                using (var transaction = db.BeginTransaction())
                {
                    tagLabelsOnFile(args, db, labels);
                    updateLabelSeq(db, labels);

                    transaction.Commit();
                }
            }
        }
示例#9
0
        private static void tagLabelsOnFile(WebsocketEventArgs args, SQLiteConnection db, Guid[] labels)
        {
            using (var cmd = db.CreateCommand())
            {
                cmd.CommandText = "insert into [labelFiles] (label_id, file_id) values (@lid, @fid)";
                cmd.Prepare();

                foreach (var label_id in labels)
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add(new SQLiteParameter("@lid", label_id));
                    cmd.Parameters.Add(new SQLiteParameter("@fid", args.ctx.fileCtx.file_id));
                    cmd.ExecuteNonQuery();
                }
            }
        }
示例#10
0
 public void OnDeviceDisconnected(object sender, WebsocketEventArgs evt)
 {
     SynchronizationContextHelper.SendMainSyncContext(() => { removeDeviceFromNotifyIconMenu(evt); });
 }