Beispiel #1
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="viewManager">Obiekt menadżera widoków.</param>
        /// <param name="view">Obiekt zarządzanego przez prezentera widoku.</param>
        /// <param name="subtitlesManager">Obiekt menadżera zarządzającego obiektami reprezentującymi napisy.</param>
        /// <param name="editor">Obiekt menadżera zajmującego się edycjią napisów.</param>
        /// <param name="tool">Obiekt narzędzia odpowiadającego za synchronizację napisów.</param>
        public SynchronizationCommandPresenter(IViewManager viewManager, ICommandView view, SubtitlesManager subtitlesManager, SynchronizationTool tool)
            : base(viewManager, view)
        {
            this.subtitlesManager = subtitlesManager;

            this.tool = tool;

            this.View.IsExecutable = true;
        }
        public void Execute(UIApplication uiapp)
        {
            try
            {
                SynchronizationTool synchronizationTool = App.Instance.SynchronizationTool;
                synchronizationTool.Document = uiapp.ActiveUIDocument.Document;
                if (synchronizationTool.ToolAction == ToolAction.CreateCloudResource)
                {
                    synchronizationTool.SetProjectOpenings();
                    synchronizationTool.SetProjectHosts();
                    synchronizationTool.CreateNewCloudResource();
                    TaskDialog.Show("Info", "Openigs have been uploaded to cloud!");
                }

                if (synchronizationTool.ToolAction == ToolAction.CheckWithCloud)
                {
                    synchronizationTool.SetProjectOpenings();
                    synchronizationTool.SetProjectHosts();
                    synchronizationTool.GetCloudResource();
                    synchronizationTool.CompareResources();
                    synchronizationTool.SetOpeningHostStatus();
                    synchronizationTool.CreateViewModel();
                    if (synchronizationTool.OpeningViewModels.Count == 0)
                    {
                        TaskDialog.Show("Info", "All openings are up to date!");
                    }
                    synchronizationTool.SignalEvent.Set();
                }

                if (synchronizationTool.ToolAction == ToolAction.UpdateProject)
                {
                    synchronizationTool.UpdateProject();
                }

                if (synchronizationTool.ToolAction == ToolAction.ShowItem)
                {
                    ElementId id = synchronizationTool.SelectedId;
                    if (id.IntegerValue > 0)
                    {
                        Element element = uiapp.ActiveUIDocument.Document.GetElement(id);
                        if (element != null)
                        {
                            uiapp.ActiveUIDocument.Selection.SetElementIds(new List <ElementId>()
                            {
                                id
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Error", ex.ToString());
            }
        }
Beispiel #3
0
        /// <summary>
        /// Konstruktor.
        /// </summary>
        /// <param name="viewManager">Obiekt menadżera widoków.</param>
        /// <param name="view">Obiekt zarządzanego przez prezentera widoku.</param>
        /// <param name="subtitlesManager">Obiekt modelu menadżera plików.</param>
        /// <param name="tool">Obiekt narzędzia do synchronizacji napisów.</param>
        public SynchronizationToolPresenter(IViewManager viewManager, ISynchronizationToolView view, SubtitlesManager subtitlesManager, SynchronizationTool tool)
            : base(viewManager, view)
        {
            this.subtitlesManager = subtitlesManager;
            this.subtitlesManager.CurrentSubtitlesFormatChanged += new EventHandler(CurrentSubtitlesFormatChangedHandler);

            this.tool = tool;

            this.View.CanSynchronize = false;
            this.View.CanAdd         = true;
            this.View.CanDelete      = false;
            this.View.CanChange      = false;
            this.View.Synchronize   += new EventHandler(SynchronizeHandler);
            this.View.Add           += new EventHandler(AddHandler);
            this.View.Delete        += new EventHandler(DeleteHandler);
            this.View.Change        += new EventHandler(ChangeHandler);
            this.View.SelectedSynchronizationPointChanged += new EventHandler <EventArgs <int> >(SelectedTimingChangedHandler);
            this.View.SwitchTimingToTime();
            this.SetViewTimingMode();
        }
Beispiel #4
0
        public Result OnStartup(UIControlledApplication application)
        {
            _app = this;
            IExternalEventHandler synchronizationEvent = new SynchronizationEvent();
            ExternalEvent         synExEvent           = ExternalEvent.Create(synchronizationEvent);

            SynchronizationTool = new SynchronizationTool();
            SynchronizationTool.SetEvent(synExEvent);

            string         path            = Assembly.GetExecutingAssembly().Location;
            RibbonPanel    gtbSynchroPanel = application.CreateRibbonPanel("GTB-Openings");
            PushButtonData synchroButton   = new PushButtonData("GTB-Synchronization", "Synchronize", path, "OpeningSynchronization.Synchronization");

            synchroButton.LargeImage = GetEmbeddedImage("Resources.gtb_sync.png");
            gtbSynchroPanel.AddItem(synchroButton);

            PushButtonData settingsButton = new PushButtonData("GTB-Settings", "Settings", path, "OpeningSynchronization.Settings");

            settingsButton.LargeImage = GetEmbeddedImage("Resources.gtb_settings.png");
            gtbSynchroPanel.AddItem(settingsButton);

            return(Result.Succeeded);
        }
Beispiel #5
0
        static void Main()
        {
#if DEBUG
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
#endif

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IViewManager viewManager = new WinFormsViewManager();

            SubtitlesManager subtitlesManager = new SubtitlesManager();

            //Określenie obsługiwanych formatów przed wczytaniem pliku.
            subtitlesManager.AddSupportedSubtitles(new AssFileFormat());
            subtitlesManager.AddSupportedSubtitles(new SSAFileFormat());
            subtitlesManager.AddSupportedSubtitles(new SubripFileFormat());
            subtitlesManager.AddSupportedSubtitles(new MicroDVDFileFormat());
            subtitlesManager.AddSupportedSubtitles(new TMPlayerFileFormat());

            MainFormView mainFormView = new MainFormView(Subeditor.Properties.Resources.NameMainView);
            viewManager.AddView(mainFormView);

            ApplicationManager appManager        = new ApplicationManager(viewManager);
            MainFormPresenter  mainFormPresenter = new MainFormPresenter(viewManager, mainFormView, appManager, subtitlesManager);

            UndoRedoManager undoRedoManager = new UndoRedoManager();

            ClipboardAssistant assistant = new ClipboardAssistant();
            mainFormView.ClipboardChanged += assistant.OnClipboardChanged;

            SubtitlesEditor editor = new SubtitlesEditor(subtitlesManager, undoRedoManager);
            (editor.Clipboard as SubtitlesClipboard).ClipboardAssistant = assistant;

            //<--------------------------------------------------------------Tools-------------------------------------------------------------->

            TimingAdjustmentTool timingAdjustmentTool = new TimingAdjustmentTool(subtitlesManager, editor);
            SynchronizationTool  synchronizationTool  = new SynchronizationTool(subtitlesManager, editor);

            //<-------------------------------------------------------SubtitlesPresenter-------------------------------------------------------->

            ISubtitlesView     subtitlesFileView      = (ISubtitlesView)viewManager.GetView("SubtitlesView");
            SubtitlesPresenter subtitlesFilePresenter = new SubtitlesPresenter(viewManager, subtitlesFileView, subtitlesManager, editor);

            //<-------------------------------------------------------Menu File Commands-------------------------------------------------------->

            ICommandView             openFileCmdView      = (ICommandView)viewManager.GetView("MenuOpenView");
            OpenFileCommandPresenter openFileCmdPresenter = new OpenFileCommandPresenter(viewManager, openFileCmdView, subtitlesManager);

            ICommandView             saveFileCmdView          = (ICommandView)viewManager.GetView("MenuSaveView");
            SaveFileCommandPresenter saveFileCommandPResenter = new SaveFileCommandPresenter(viewManager, saveFileCmdView, subtitlesManager);

            ICommandView saveAsFileCmddView = (ICommandView)viewManager.GetView("MenuSaveAsView");
            SaveAsFileCommandPresenter saveAsFileCmdPResenter = new SaveAsFileCommandPresenter(viewManager, saveAsFileCmddView, subtitlesManager);

            ICommandView         exitCmdView      = (ICommandView)viewManager.GetView("MenuExitView");
            ExitCommandPresenter exitCmdPresenter = new ExitCommandPresenter(viewManager, exitCmdView, appManager);

            //<--------------------------------------------------------------------------------------------------------------------------------->

            //<-------------------------------------------------------Menu Edit Commands-------------------------------------------------------->

            ICommandView        cutCmdView      = (ICommandView)viewManager.GetView("MenuCutView");
            CutCommandPresenter cutCmdPresenter = new CutCommandPresenter(viewManager, cutCmdView, editor);

            ICommandView         copyCmdView      = (ICommandView)viewManager.GetView("MenuCopyView");
            CopyCommandPresenter copyCmdPresenter = new CopyCommandPresenter(viewManager, copyCmdView, editor);

            ICommandView          pasteCmdView      = (ICommandView)viewManager.GetView("MenuPasteView");
            PasteCommandPresenter pasteCmdPresenter = new PasteCommandPresenter(viewManager, pasteCmdView, editor);

            ICommandView selectAllCmdView = (ICommandView)viewManager.GetView("MenuSelectAllView");
            SelectAllCommandPresenter selectAllCmdPresenter = new SelectAllCommandPresenter(viewManager, selectAllCmdView, editor);

            ICommandView selectFromCmdView = (ICommandView)viewManager.GetView("MenuSelectFromView");
            SelectFromCommandPresenter selectFromCmdPresenter = new SelectFromCommandPresenter(viewManager, selectFromCmdView, editor);

            ICommandView         menuUndoCmdView      = (ICommandView)viewManager.GetView("MenuUndoView");
            UndoCommandPresenter menuUndoCmdPresenter = new UndoCommandPresenter(viewManager, menuUndoCmdView, undoRedoManager);

            ICommandView         menuRedoCmdView      = (ICommandView)viewManager.GetView("MenuRedoView");
            RedoCommandPresenter menuRedoCmdPresenter = new RedoCommandPresenter(viewManager, menuRedoCmdView, undoRedoManager);

            //<--------------------------------------------------------------------------------------------------------------------------------->

            //<-------------------------------------------------------Menu Tools Commands------------------------------------------------------->

            ICommandView adjustTimingCmdView = (ICommandView)viewManager.GetView("MenuTimingAdjustmentView");
            TimingAdjustmentCommandPresenter adjustTimingCmdPresenter = new TimingAdjustmentCommandPresenter(
                viewManager,
                adjustTimingCmdView,
                subtitlesManager,
                editor,
                timingAdjustmentTool);

            ICommandView synchronizationCmdView = (ICommandView)viewManager.GetView("MenuSynchronizationView");
            SynchronizationCommandPresenter synchronizationCmdPresenter = new SynchronizationCommandPresenter(
                viewManager,
                synchronizationCmdView,
                subtitlesManager,
                synchronizationTool);

            //<--------------------------------------------------------------------------------------------------------------------------------->

            //<-----------------------------------------------------------Toolbar -------------------------------------------------------------->

            ICommandView             toolbarOpenFileCmdView      = (ICommandView)viewManager.GetView("ToolbarOpenFileView");
            OpenFileCommandPresenter toolbarOpenFileCmdPresenter = new OpenFileCommandPresenter(viewManager, toolbarOpenFileCmdView, subtitlesManager);

            ICommandView             toolbarSaveFileCmdView      = (ICommandView)viewManager.GetView("ToolbarSaveFileView");
            SaveFileCommandPresenter toolbarSaveFileCmdPResenter = new SaveFileCommandPresenter(viewManager, toolbarSaveFileCmdView, subtitlesManager);

            ICommandView toolbarSaveAsFileCmdView = (ICommandView)viewManager.GetView("ToolbarSaveAsFileView");
            SaveAsFileCommandPresenter toolbarSaveAsFileCmdPResenter = new SaveAsFileCommandPresenter(viewManager, toolbarSaveAsFileCmdView, subtitlesManager);

            ICommandView        toolbarCutCmdView      = (ICommandView)viewManager.GetView("ToolbarCutView");
            CutCommandPresenter toolbarCutCmdPresenter = new CutCommandPresenter(viewManager, toolbarCutCmdView, editor);

            ICommandView         toolbarCopyCmdView      = (ICommandView)viewManager.GetView("ToolbarCopyView");
            CopyCommandPresenter toolbarCopyCmdPresenter = new CopyCommandPresenter(viewManager, toolbarCopyCmdView, editor);

            ICommandView          toolbarPasteCmdView      = (ICommandView)viewManager.GetView("ToolbarPasteView");
            PasteCommandPresenter toolbarPasteCmdPresenter = new PasteCommandPresenter(viewManager, toolbarPasteCmdView, editor);

            ICommandView         toolbarUndoCmdView      = (ICommandView)viewManager.GetView("ToolbarUndoView");
            UndoCommandPresenter toolbarUndoCmdPresenter = new UndoCommandPresenter(viewManager, toolbarUndoCmdView, undoRedoManager);

            ICommandView         toolbarRedoCmdView      = (ICommandView)viewManager.GetView("ToolbarRedoView");
            RedoCommandPresenter toolbarRedoCmdPresenter = new RedoCommandPresenter(viewManager, toolbarRedoCmdView, undoRedoManager);

            IToolStripComboBoxView    toolbarEncodingView      = (IToolStripComboBoxView)viewManager.GetView("ToolbarEncodingView");
            EncodingComboBoxPresenter toolbarEncodingPresenter = new EncodingComboBoxPresenter(viewManager, toolbarEncodingView, subtitlesManager);

            //<--------------------------------------------------------------------------------------------------------------------------------->

            //<-------------------------------------------------------Context Menu-------------------------------------------------------------->
            MainContextMenuStripView mainContextMenuStripView = new MainContextMenuStripView();
            (subtitlesFileView as IHierarchicalView).AddChildView(mainContextMenuStripView);
            MainContextMenuStripPresenter mainContextMenuStripPresenter = new MainContextMenuStripPresenter(viewManager, mainContextMenuStripView, editor);

            //<--------------------------------------------------------------------------------------------------------------------------------->

            //Próbuje otworzyć plik, w sytuacji gdy użytkownik uruchomił program poprzez polecenie "otwórz za pomocą".
            bool operationResult = subtitlesManager.TryLoadFromClickOnceDeploymentSystem();
            if (operationResult == false)
            {
                subtitlesManager.TryLoadFromLineArgs();
            }

            //<--------------------------------------------------------------------------------------------------------------------------------->

            viewManager.ShowView(mainFormView);
        }
Beispiel #6
0
 public SynchronizationWindow(SynchronizationTool synchronizationTool)
 {
     SynchronizationTool = synchronizationTool;
     SetOwner();
     InitializeComponent();
 }