예제 #1
0
        public SelectFolderDialogModel(Action onClose)
        {
            BrowseCommand = new UiCommand(OnBrowse);
            OkCommand     = new UiCommand(OnOk, IsProperFolder);

            _onClose = onClose;
        }
예제 #2
0
    private void FontSizeTest()
    {
        UiRect rect = new UiRect();

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                rect.x = j * DEFAULT_CHAR_WIDTH;
                rect.y = 200 + i * DEFAULT_LINE_HEIGHT;
                rect.w = DEFAULT_CHAR_WIDTH;
                rect.h = DEFAULT_LINE_HEIGHT;
                draw2D.FillRect(ToSurfaceRect(rect), (i + j) % 2 == 0 ? Color.green : Color.blue);
            }
        }
        UiCommand cmd = new UiCommand
        {
            rect = new UiRect
            {
                x = 0,
                y = 200
            },
            textColor = 0xffffff,
            text      = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n" +
                        "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n" +
                        "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
            opacity = 1
        };

        HandleCommandText(ref cmd);
    }
 public MediaSearchViewmodel(IPreview preview, IEngine engine, TMediaType mediaType, VideoLayer layer,
                             bool closeAfterAdd, VideoFormatDescription videoFormatDescription)
 {
     Engine = engine;
     Layer  = layer;
     if (mediaType == TMediaType.Movie)
     {
         _videoFormatDescription = engine.FormatDescription;
         if (preview != null)
         {
             _preview = new PreviewViewmodel(preview, false, false)
             {
                 IsSegmentsVisible = true
             }
         }
         ;
     }
     else
     {
         _videoFormatDescription = videoFormatDescription;
     }
     _mediaType = mediaType;
     if (_preview != null)
     {
         _preview.PropertyChanged += _onPreviewViewModelPropertyChanged;
     }
     CommandAdd        = new UiCommand(_add, _allowAdd);
     _mediaCategory    = MediaCategories.FirstOrDefault();
     NewEventStartType = TStartType.After;
     SetupSearchDirectory(closeAfterAdd, mediaType);
 }
예제 #4
0
    private void HandleCommandImage(ref UiCommand command)
    {
        string url = imageSystem.GetImageUrl(command.imageId);

        if (string.IsNullOrEmpty(url))
        {
            draw2D.FillRect(ToSurfaceRect(command.rect), Color.gray);
        }
        else
        {
            Texture2D tex = imageLoader.GetOrRequest(url);
            if (tex == null)
            {
                draw2D.FillRect(ToSurfaceRect(command.rect), Color.black);
            }
            else
            {
                UiRect gameUiRect = command.rect;
                if (gameUiRect.w < 0)
                {
                    // Means "auto compute from image".
                    gameUiRect.w = tex.width;
                }
                if (gameUiRect.h < 0)
                {
                    // Means "auto compute to keep aspect ratio".
                    gameUiRect.h = tex.width > 0 ? (tex.height * gameUiRect.w / tex.width) : 1;
                }
                Rect screenRect = ToSurfaceRect(gameUiRect);
                tex.filterMode = command.noFilter ? FilterMode.Point : FilterMode.Bilinear;
                draw2D.DrawTexture(screenRect, Color.white, tex);
            }
        }
    }
예제 #5
0
    private void HandleCommandCircle(ref UiCommand command)
    {
        Debug.Assert(command.points != null, "CMD_CIRCLE needs points. Was null.");
        Debug.Assert(command.points.Length == 1, "CMD_CIRCLE must have 1 point, had " + command.points.Length);
        Vector2 screenCenter = ToSurfacePoint(command.points[0]);
        Color   color        = DecodeColor(command.backgroundColor, command.opacity);
        float   screenRadius = ToSurfaceLength(command.radius);
        int     sides        = CalculateCircleSidesForRadius(screenRadius);

        if (command.style == "DASHED")
        {
            draw2D.DrawDashedCircle(screenCenter, screenRadius, sides, color, 1);
        }
        else if (command.style == "BORDER")
        {
            draw2D.DrawCircle(screenCenter, screenRadius, sides, color, 1);
        }
        else
        {
            // Due to Drawing2D bugs, we fill the circle TWICE using different methods:
            // (each has its own problems but if we do both, it works).

            // Method 1 (normal FillCircle way):
            // This leaves jagged edges but fills the center well.
            draw2D.FillCircle(screenCenter, Mathf.Max(1, screenRadius - 2), color);
            // Method 2 (abuse "border width" parameter):
            // This draws the edge perfectly but leaves random 1-pixel holes in the center
            // (covered by our call above).
            draw2D.DrawCircle(screenCenter, screenRadius / 2, sides, color, screenRadius);
        }
    }
예제 #6
0
 public IngestOperationViewModel(IIngestOperation operation, IEngine engine)
     : base(operation, engine.MediaManager)
 {
     _operation                         = operation;
     _engine                            = engine;
     _destMediaVideoFormat              = operation.Source.VideoFormat;
     DestMediaName                      = FileUtils.GetFileNameWithoutExtension(operation.Source.MediaName, operation.Source.MediaType);
     _duration                          = operation.Source.Duration;
     _startTc                           = operation.Source.TcStart;
     _destCategory                      = ((IIngestDirectory)operation.Source.Directory).MediaCategory;
     IsMovie                            = operation.Source.MediaType == TMediaType.Unknown || operation.Source.MediaType == TMediaType.Movie;
     IsStill                            = operation.Source.MediaType == TMediaType.Still;
     _audioChannelMappingConversion     = operation.AudioChannelMappingConversion;
     _aspectConversion                  = operation.AspectConversion;
     _audioVolume                       = operation.AudioVolume;
     _sourceFieldOrderEnforceConversion = operation.SourceFieldOrderEnforceConversion;
     _loudnessCheck                     = operation.LoudnessCheck;
     operation.Source.PropertyChanged  += OnSourceMediaPropertyChanged;
     AspectConversionsEnforce           = new TAspectConversion[3];
     Array.Copy(AspectConversions, AspectConversionsEnforce, 3);
     if (engine.Preview != null)
     {
         _preview = new PreviewViewmodel(engine.Preview, true, false)
         {
             SelectedIngestOperation = operation
         }
     }
     ;
     CommandRemove = new UiCommand(o => Removed?.Invoke(this, EventArgs.Empty));
 }
 protected OkCancelViewmodelBase(TM model, Type editor, string windowTitle) : base(model)
 {
     CommandCancel = new UiCommand(Close, CanClose);
     CommandOk     = new UiCommand(Ok, CanOk);
     Title         = windowTitle;
     Editor        = (UserControl)Activator.CreateInstance(editor);
 }
 public ExportMediaViewmodel(IEngine engine, MediaExportDescription mediaExport)
 {
     _engine        = engine;
     MediaExport    = mediaExport;
     Logos          = new ObservableCollection <ExportMediaLogoViewmodel>(mediaExport.Logos.Select(l => new ExportMediaLogoViewmodel(this, l)));
     CommandAddLogo = new UiCommand(_addLogo);
 }
예제 #9
0
 public ExportViewmodel(IEngine engine, IEnumerable <MediaExportDescription> exportList)
 {
     _engine           = engine;
     Items             = new ObservableCollection <ExportMediaViewmodel>(exportList.Select(media => new ExportMediaViewmodel(engine, media)));
     Directories       = engine.MediaManager.IngestDirectories.Where(d => d.ContainsExport()).Select(d => new MediaDirectoryViewmodel(d, d.DirectoryName, false, true)).ToList();
     SelectedDirectory = Directories.FirstOrDefault();
     CommandExport     = new UiCommand(_export, _canExport);
 }
예제 #10
0
        public PluginLoader(ILoadablePlugin loadableView, Action <PluginLoader> onSelection)
        {
            PluginName = loadableView.PresentationName;
            PluginLogo = loadableView.Logo as UIElement;
            ViewPlugin = loadableView.View;

            OnSelect = new UiCommand(delegate { onSelection(this); });
        }
예제 #11
0
 public EnginesViewmodel(string connectionString, string connectionStringSecondary)
     : base(new Model.Engines(connectionString, connectionStringSecondary), typeof(EnginesView), "Engines")
 {
     Engines = new ObservableCollection <EngineViewmodel>(Model.EngineList.Select(e => new EngineViewmodel(e)));
     Engines.CollectionChanged += _engines_CollectionChanged;
     CommandAdd    = new UiCommand(_add);
     CommandDelete = new UiCommand(o => Engines.Remove(_selectedEngine), o => _selectedEngine != null);
 }
예제 #12
0
 public PlayoutServersViewmodel(string connectionString, string connectionStringSecondary)
     : base(new Model.PlayoutServers(connectionString, connectionStringSecondary), typeof(PlayoutServersView), "Playout servers")
 {
     PlayoutServers = new ObservableCollection <PlayoutServerViewmodel>(Model.Servers.Select(s => new PlayoutServerViewmodel(s)));
     PlayoutServers.CollectionChanged += PlayoutServers_CollectionChanged;
     CommandAdd    = new UiCommand(Add);
     CommandDelete = new UiCommand(o => PlayoutServers.Remove(_selectedServer), o => _selectedServer != null);
 }
예제 #13
0
 public PicturesViewModel()
 {
     PreviousFolder = new UiCommand(o => PopFolder());
     AddEventListener(this);
     PushFolder(Root);
     FoldersView.Refresh();
     OnPropertyChanged(nameof(FoldersView));
 }
 public ConfiguratorViewModel()
 {
     CommandEditConnectionString          = new UiCommand(EditConnectionString);
     CommandEditConnectionStringSecondary = new UiCommand(EditConnectionStringSecondary);
     CommandTestConnectivity         = new UiCommand(TestConnectivity, o => !string.IsNullOrWhiteSpace(ConnectionStringPrimary));
     CommandTestConnectivitySecodary = new UiCommand(TestConnectivitySecondary, o => !string.IsNullOrWhiteSpace(ConnectionStringSecondary) && _isConnectionStringSecondary);
     CommandCreateDatabase           = new UiCommand(CreateDatabase, o => !string.IsNullOrWhiteSpace(ConnectionStringPrimary));
     CommandCloneDatabase            = new UiCommand(ClonePrimaryDatabase, o => !(string.IsNullOrWhiteSpace(ConnectionStringPrimary) || string.IsNullOrWhiteSpace(ConnectionStringSecondary)));
 }
예제 #15
0
 public CurrentPlaylistViewModel()
 {
     LaunchTrack = new UiCommand(o =>
     {
         PlayOffset = _shuffled ? ShuffledList.FindIndex(track => track.Track == o as TrackDefinition) : Current.Tracks.FindIndex(track => track.Track == o as TrackDefinition);
         Dispatch("Play", CurrentMedia);
         RefreshDisplay();
     }, o => Current != null);
 }
예제 #16
0
    private void HandleCommandButton(ref UiCommand command)
    {
        float textSize = command.textSize > 0 ? command.textSize : DEFAULT_TEXT_SIZE;

        draw2D.FillRect(ToSurfaceRect(command.rect), DecodeColor(command.backgroundColor, command.opacity));
        draw2D.DrawRect(ToSurfaceRect(command.rect), DecodeColor(0xffffff, command.opacity));
        RenderCenteredSingleLineText(command.text, command.rect.ToUnityRect().center.x,
                                     command.rect.ToUnityRect().center.y, DecodeColor(command.textColor, 1), textSize);
    }
예제 #17
0
    private void HandleCommandText(ref UiCommand command)
    {
        float x          = command.rect.x;
        float y          = command.rect.y;
        Color color      = DecodeColor(command.textColor, command.opacity);
        float textSize   = command.textSize > 0 ? command.textSize : DEFAULT_TEXT_SIZE;
        float lineHeight = GetLineHeightForSize(textSize);

        RenderRichText(command.text, x, y, textSize, color);
    }
예제 #18
0
        public MediaControlBarViewModel()
        {
            SliderMaxValue = 0;
            MediaDuration  = TimeSpan.FromSeconds(0).ToString(@"hh\:mm\:ss");

            Play = new UiCommand(delegate { Dispatch("Play"); },
                                 o => MediaState == MediaState.Pause);
            Pause = new UiCommand(delegate { Dispatch("Pause"); },
                                  o => MediaState == MediaState.Play);
        }
예제 #19
0
 public TemplatedEditViewmodel(ITemplated model, bool isFieldListReadOnly, bool displayCgMethod, TVideoFormat videoFormat) : base(model)
 {
     IsDisplayCgMethod      = displayCgMethod;
     VideoFormat            = videoFormat;
     IsFieldListReadOnly    = isFieldListReadOnly;
     Model.PropertyChanged += Model_PropertyChanged;
     CommandAddField        = new UiCommand(_addField, _canAddField);
     CommandDeleteField     = new UiCommand(_deleteField, _canDeleteField);
     CommandEditField       = new UiCommand(_editField, _canDeleteField);
 }
예제 #20
0
 public IngestEditorViewmodel(IList <IIngestOperation> convertionList, IPreview preview, IEngine engine)
 {
     _engine           = engine;
     OperationList     = new ObservableCollection <IngestOperationViewModel>(convertionList.Select(op => new IngestOperationViewModel(op, preview, engine)));
     SelectedOperation = OperationList.FirstOrDefault();
     foreach (var c in OperationList)
     {
         c.PropertyChanged += _convertOperationPropertyChanged;
     }
     CommandDeleteOperation = new UiCommand(_deleteOperation);
 }
예제 #21
0
 public EventRightsEditViewmodel(IEvent ev, IAuthenticationService authenticationService)
 {
     _ev = ev;
     _authenticationService = authenticationService;
     AclObjects             = authenticationService.Users.Cast <ISecurityObject>().Concat(authenticationService.Groups).ToArray();
     _originalRights        = ev.GetRights().ToList();
     Rights = new ObservableCollection <EventRightViewmodel>();
     Load();
     CommandAddRight    = new UiCommand(_addRight, _canAddRight);
     CommandDeleteRight = new UiCommand(_deleteRight, _canDeleteRight);
 }
예제 #22
0
 public UserManagerViewmodel(IAuthenticationService authenticationService)
 {
     _authenticationService = authenticationService;
     Groups             = new ObservableCollection <GroupViewmodel>(authenticationService.Groups.Select(g => new GroupViewmodel(g)));
     Users              = new ObservableCollection <UserViewmodel>(authenticationService.Users.Select(u => new UserViewmodel(u, this)));
     CommandAddUser     = new UiCommand(AddUser);
     CommandDeleteUser  = new UiCommand(DeleteUser, CanDeleteUser);
     CommandAddGroup    = new UiCommand(AddGroup);
     CommandDeleteGroup = new UiCommand(DeleteGroup, CanDeleteGroup);
     authenticationService.UsersOperation  += AuthenticationService_UsersOperation;
     authenticationService.GroupsOperation += AuthenticationService_GroupsOperation;
 }
예제 #23
0
 public MainWindowViewmodel()
 {
     CommandIngestFoldersSetup  = new UiCommand(_ingestFoldersSetup);
     CommandConfigFileEdit      = new UiCommand(_configFileEdit);
     CommandConfigFileSelect    = new UiCommand(_configFileSelect);
     CommandPlayoutServersSetup = new UiCommand(_serversSetup);
     CommandEnginesSetup        = new UiCommand(_enginesSetup);
     if (File.Exists("TVPlay.exe"))
     {
         ConfigFile = new Model.ConfigFile("TVPlay.exe");
     }
 }
 public MainWindowViewmodel()
 {
     if (File.Exists("TVPlay.exe"))
     {
         ConfigFile = new Model.ConfigFile(ConfigurationManager.OpenExeConfiguration("TVPlay.exe"));
     }
     CommandIngestFoldersSetup  = new UiCommand(_ingestFoldersSetup, _canShowDialog);
     CommandConfigFileEdit      = new UiCommand(_configFileEdit, _canShowDialog);
     CommandConfigFileSelect    = new UiCommand(_configFileSelect, _canShowDialog);
     CommandPlayoutServersSetup = new UiCommand(_serversSetup, _canShowDialog);
     CommandEnginesSetup        = new UiCommand(_enginesSetup, _canShowDialog);
 }
예제 #25
0
 public PlaylistHeaderViewModel(Playlist playlist)
 {
     Playlist = playlist;
     Play     = new UiCommand(o => DispatcherLibrary.Dispatcher.Dispatch("Playlist Plugin: Set Playlist", playlist));
     Playlist.PlaylistStateChanged += (sender, state) =>
     {
         if (sender == Playlist)
         {
             PlaylistState = state;
         }
     };
 }
예제 #26
0
        public EventPanelContainerViewmodel(IEvent ev, EventPanelViewmodelBase parent) : base(ev, parent)
        {
            if (ev.EventType != TEventType.Container)
            {
                throw new ApplicationException($"Invalid panel type:{GetType()} for event type:{ev.EventType}");
            }
            _isVisible = !HiddenEventsStorage.Contains(ev);

            CommandHide          = new UiCommand(o => IsVisible = false, o => _isVisible);
            CommandShow          = new UiCommand(o => IsVisible = true, o => !_isVisible);
            CommandAddSubRundown = new UiCommand(_addSubRundown, o => Event.HaveRight(EventRight.Create));
            ev.SubEventChanged  += SubEventChanged;
        }
예제 #27
0
 public VideoPreviewViewmodel()
 {
     _videoSources         = new ObservableCollection <string>(new[] { Common.Properties.Resources._none_ });
     _videoSource          = _videoSources.FirstOrDefault();
     CommandRefreshSources = new UiCommand(RefreshSources, o => NdiFindInstance != IntPtr.Zero);
     CommandGotoNdiWebsite = new UiCommand(GotoNdiWebsite);
     CommandShowPopup      = new UiCommand(o => DisplayPopup = true);
     CommandHidePopup      = new UiCommand(o => DisplayPopup = false);
     SourceRefreshed      += OnSourceRefreshed;
     View = new VideoPreviewView {
         DataContext = this
     };
 }
예제 #28
0
 public EventEditViewmodel(IEvent @event, EngineViewmodel engineViewModel) : base(@event)
 {
     _engineViewModel       = engineViewModel;
     Model.PropertyChanged += ModelPropertyChanged;
     if (@event.EventType == TEventType.Container)
     {
         EventRightsEditViewmodel = new EventRightsEditViewmodel(@event, engineViewModel.Engine.AuthenticationService);
         EventRightsEditViewmodel.ModifiedChanged += RightsModifiedChanged;
     }
     CommandSaveEdit         = new UiCommand(o => Save(), _canSave);
     CommandUndoEdit         = new UiCommand(o => UndoEdit(), o => IsModified);
     CommandChangeMovie      = new UiCommand(_changeMovie, _canChangeMovie);
     CommandEditMovie        = new UiCommand(_editMovie, _canEditMovie);
     CommandCheckVolume      = new UiCommand(_checkVolume, _canCheckVolume);
     CommandTriggerStartType = new UiCommand
                               (
         _triggerStartType,
         _canTriggerStartType
                               );
     CommandMoveUp = new UiCommand
                     (
         o => Model.MoveUp(),
         o => Model.CanMoveUp()
                     );
     CommandMoveDown = new UiCommand
                       (
         o => Model.MoveDown(),
         o => Model.CanMoveDown()
                       );
     CommandDelete = new UiCommand
                     (
         async o =>
     {
         if (MessageBox.Show(resources._query_DeleteItem, resources._caption_Confirmation, MessageBoxButton.OKCancel) != MessageBoxResult.OK)
         {
             return;
         }
         await EventClipboard.SaveUndo(new List <IEvent> {
             Model
         },
                                       Model.StartType == TStartType.After ? Model.Prior : Model.Parent);
         Model.Delete();
     },
         o => Model.AllowDelete()
                     );
     if (@event is ITemplated templated)
     {
         TemplatedEditViewmodel = new TemplatedEditViewmodel(templated, true, true, engineViewModel.VideoFormat);
         TemplatedEditViewmodel.ModifiedChanged += TemplatedEditViewmodel_ModifiedChanged;
     }
 }
예제 #29
0
        public MainWindowViewmodel()
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return;
            }
#if DEBUG
            System.Threading.Thread.Sleep(2000); // wait for server startup
#endif
            Application.Current.Dispatcher.ShutdownStarted += _dispatcher_ShutdownStarted;
            _configurationFile = Path.Combine(FileUtils.LocalApplicationDataPath, ConfigurationFileName);
            _loadTabs();
            CommandConfigure = new UiCommand(_configure);
        }
예제 #30
0
 public MainWindowViewmodel()
 {
     if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         return;
     }
     Application.Current.Dispatcher.ShutdownStarted += _dispatcher_ShutdownStarted;
     _configurationFile = Path.Combine(FileUtils.LocalApplicationDataPath, ConfigurationFileName);
     if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         _loadTabs();
     }
     CommandConfigure = new UiCommand(_configure);
 }