Exemple #1
0
 public ActionResult Set(SetRequest rq)
 {
     if (rq == null)
     {
         throw new ArgumentNullException("rq");
     }
     rq.Persist <Device>(Device.Delete);
     return(Json(SetRequest.FromPoco(DevicePersistense.List()), JsonRequestBehavior.AllowGet));
 }
 private void BulkUpdate_Shown(object sender, EventArgs e)
 {
     CbxDevice.Items.AddRange(DevicePersistense.ListForTitleUpdate().ToArray());
     if (CbxDevice.Items.Count == 1)
     {
         CbxDevice.SelectedIndex = 0;
         CbxDevice_SelectedIndexChanged(null, null);
     }
     CbxDevice.Enabled = true;
 }
        private void CbxDevice_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_rescanResults = null;
            CbxLocation.Items.Clear();
            var selected = GetSelectedDevice();

            if (selected != null)
            {
                CbxLocation.Items.Add(new LocationBase {
                    Id = -1, Kind = LocationBaseKind.Local, Name = "All"
                });
                CbxLocation.Items.AddRange(DevicePersistense.GetLocationsForTitleUpdate(selected.Id).ToArray());
            }
            CbxLocation.Enabled = true;
            BtnApply.Enabled    = false;
        }
Exemple #4
0
        public Devices()
        {
            InitializeComponent();
            TVDevices.CanExpandGetter = (object o) => { return(o is Device); };
            TVDevices.ChildrenGetter  = (object o) => {
                var dev = o as Device;
                if (dev != null)
                {
                    return(DevicePersistense.GetLocations(dev.Id));
                }
                return(null);
            };

            olvColData.AspectGetter = (object o) => {
                var dev = o as Device;
                if (dev != null)
                {
                    return(dev.Data);
                }

                var loc = o as LocationBaseDeviceMapping;
                if (loc != null)
                {
                    return(loc.Mapping);
                }

                return(null);
            };


            olvColData.AspectPutter = (object o, object val) => {
                var dev = o as Device;
                if (dev != null)
                {
                    dev.Data = (string)val;
                }

                var loc = o as LocationBaseDeviceMapping;
                if (loc != null)
                {
                    loc.Mapping = (string)val;
                }
            };
        }
 public ActionResult GetLocationBases(long deviceid)
 {
     return(Json(DevicePersistense.GetLocationsForTitleUpdate(deviceid), JsonRequestBehavior.AllowGet));
 }
        public ActionResult UpdateTitles()
        {
            var devices = DevicePersistense.ListForTitleUpdate();

            return(View("~/Views/UpdateTitles.cshtml", devices));
        }
Exemple #7
0
 private void Devices_Shown(object sender, EventArgs e)
 {
     TVDevices.Roots = DevicePersistense.List();
 }
Exemple #8
0
        public MainForm()
        {
            InitializeComponent();
            LVLocations.VirtualMode = false;
            LVRatings.VirtualMode   = false;

            AppDomain.CurrentDomain.UnhandledException += (o, e) => {
                var    ex  = e.ExceptionObject as Exception;
                string msg = ex == null ? "Unhandled error" : ex.Message;
                MessageBox.Show(msg, "Application Error");
            };
            Application.ThreadException += (o, e) => {
                string msg = e.Exception == null ? "Unhandled error (thread)" : e.Exception.Message;
                MessageBox.Show(msg, "Application Error");
            };

            TVTitles.CanExpandGetter = (o) => {
                var t = o as Title;
                if (t == null)
                {
                    return(false);
                }
                return(t.Kind != TitleKind.Episode && t.Kind != TitleKind.Track && t.Kind != TitleKind.Title);
            };

            TVTitles.ChildrenGetter = (o) => {
                var t = o as Title;
                if (t == null)
                {
                    return(null);
                }
                return(new SortableTitles(TitlePersistence.ListTitlesByParent(t.Id)));
            };

            OlvColumnName.ImageGetter = (o) => {
                var t = o as Title;
                if (t == null)
                {
                    return(-1);
                }
                return((int)t.Kind);
            };

            OlvBtnPlay.AspectGetter = (o) => {
                var l = o as LocationForDisplay;
                if (l != null && l.LocationKind != LocationBaseKind.Shelf)
                {
                    return("Play");
                }
                return(null);
            };

            var sink = (BrightIdeasSoftware.SimpleDropSink)TVTitles.DropSink;

            sink.AcceptExternal      = false;
            sink.CanDropBetween      = false;
            sink.CanDropOnBackground = false;
            sink.CanDropOnItem       = true;
            sink.CanDropOnSubItem    = true;

            sink.CanDrop += (sender, e) => {
                e.Handled = true;
                e.Effect  = DragDropEffects.None;
                var models = GetModelsFromDropEvent(e);

                if (CanDrop(models.Item1, models.Item2))
                {
                    e.Effect = DragDropEffects.Move;
                }
            };

            sink.Dropped += (sender, e) => {
                var models = GetModelsFromDropEvent(e);
                if (models.Item1 == null || models.Item2 == null)
                {
                    return;
                }
                SetSeriesHierarchy(models.Item1, models.Item2);
                GeneralPersistense.Upsert(models.Item1);
                e.Effect = DragDropEffects.Move;
                TVTitles.RemoveObject(models.Item1);
                TVTitles.RefreshObject(models.Item2);
            };

            TVTitles.ModelFilter = new ModelFilter((m) => {
                var t = m as Title;
                if (t == null)
                {
                    return(false);
                }

                string filter = TbxSearch.Text.Trim().ToLower();
                if (m_titleFilter.Count > 0)
                {
                    if (m_titleFilter.Contains(t.Id))
                    {
                        if (filter.Length == 0)
                        {
                            return(true);
                        }
                        return(t.TitleName.ToLower().Contains(filter));
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (filter.Length == 0)
                    {
                        return(true);
                    }
                    return(t.TitleName.ToLower().Contains(filter));
                }
            });

            olvColumnRatingValue.AspectPutter = (object o, object val) => {
                var r = o as TitleRatingWithName;
                if (r != null)
                {
                    r.RatingValue = Convert.ToSingle(val);
                }
            };



            CbxDevices.Items.AddRange(DevicePersistense.ListForPalyback().ToArray());
            if (CbxDevices.Items.Count > 0)
            {
                CbxDevices.SelectedIndex = 0;
            }

            m_imageIndex = 0;
        }
Exemple #9
0
 public ActionResult ListLocations(long id)
 {
     return(Json(SetRequest.FromPoco(DevicePersistense.GetLocations(id)), JsonRequestBehavior.AllowGet));
 }
Exemple #10
0
        //
        // GET: /Device/


        public ActionResult Index()
        {
            return(View("~/Views/Devices.cshtml", SetRequest.FromPoco(DevicePersistense.List())));
        }