Example #1
0
        public HttpUrlBuferMenuGenerator(string url, IProgramSettingsGetter settingsGetter, IProgramSettingsSetter settingsSetter)
        {
            this._url = url;

            this._settingsGetter = settingsGetter;
            this._settingsSetter = settingsSetter;
        }
Example #2
0
 public Starter(IBufermanHost bufermanHost, IBufermanApplication bufermanApp,
                IProgramSettingsGetter settings)
 {
     this._bufermanHost = bufermanHost;
     this._bufermanApp  = bufermanApp;
     this._settings     = settings;
 }
Example #3
0
        public ChangeTextMenuItem(BufermanMenuItem menuItem, IBufer bufer, IBufermanHost bufermanHost, IProgramSettingsGetter settings) : base(menuItem, bufer, bufermanHost)
        {
            menuItem.AddOnClickHandler(this._ChangeText);
            menuItem.ShortCut = Shortcut.CtrlH;

            this._settings = settings;
        }
Example #4
0
 public BufermanOptionsWindowFactory(IProgramSettingsGetter settingsGetter,
                                     IProgramSettingsSetter settingsSetter,
                                     IUserInteraction userInteraction)
 {
     this._settingsGetter  = settingsGetter;
     this._settingsSetter  = settingsSetter;
     this._userInteraction = userInteraction;
 }
Example #5
0
 public SessionManager(
     IClipboardBuferService clipboardBuferService,
     IProgramSettingsGetter settings,
     IBufersStorageFactory bufersStorageFactory,
     IFileStorage fileStorage,
     ITime time)
 {
     this._clipboardBuferService = clipboardBuferService;
     this._settings             = settings;
     this._bufersStorageFactory = bufersStorageFactory;
     this._fileStorage          = fileStorage;
     this._time = time;
 }
 public BuferContextMenuGenerator(IBuferSelectionHandlerFactory buferSelectionHandlerFactory,
                                  IProgramSettingsGetter settings,
                                  IClipboardWrapper clipboardWrapper,
                                  IBufersStorageFactory bufersStorageFactory,
                                  IUserFileSelector userFileSelector,
                                  IFileStorage fileStorage)
 {
     this._buferSelectionHandlerFactory = buferSelectionHandlerFactory;
     this._settings             = settings;
     this._clipboardWrapper     = clipboardWrapper;
     this._bufersStorageFactory = bufersStorageFactory;
     this._userFileSelector     = userFileSelector;
     this._fileStorage          = fileStorage;
 }
        public BufermanWindow(
            IProgramSettingsGetter settingsGetter,
            IRenderingHandler renderingHandler,
            IUserInteraction userInteraction,
            IProgramSettingsSetter settingsSetter)
        {
            this._bufers           = new List <IBufer>(settingsGetter.MaxBufersCount + settingsGetter.ExtraBufersCount);
            this._renderingHandler = renderingHandler;
            this._settingsGetter   = settingsGetter;
            this._settingsSetter   = settingsSetter;

            this._userInteraction   = userInteraction;
            BufermanWindow._current = this;
        }
Example #8
0
        public EditBuferTextMenuItem(
            BufermanMenuItem menuItem,
            BuferContextMenuState buferContextMenuState,
            IBufermanHost bufermanHost,
            IProgramSettingsGetter settings,
            IClipboardWrapper clipboardWrapper)
        {
            this._settings              = settings;
            this._bufermanHost          = bufermanHost;
            this._buferContextMenuState = buferContextMenuState;
            this._clipboardWrapper      = clipboardWrapper;

            menuItem.AddOnClickHandler(this._ChangeBufer);
            menuItem.ShortCut = Shortcut.CtrlE;
        }
 public BuferHandlersBinder(
     IBuferContextMenuGenerator buferContextMenuGenerator,
     IBuferSelectionHandlerFactory buferSelectionHandlerFactory,
     IFileStorage fileStorage,
     IProgramSettingsGetter settingsGetter,
     IProgramSettingsSetter settingsSetter,
     IEnumerable <IBufermanPlugin> plugins,
     IClipboardBuferService clipboardBuferService)
 {
     this._buferContextMenuGenerator    = buferContextMenuGenerator;
     this._buferSelectionHandlerFactory = buferSelectionHandlerFactory;
     this._fileStorage           = fileStorage;
     this._settingsGetter        = settingsGetter;
     this._settingsSetter        = settingsSetter;
     this._plugins               = plugins;
     this._clipboardBuferService = clipboardBuferService;
 }
Example #10
0
 public MainMenuGenerator(
     IUserFileSelector userFileSelector,
     IClipboardBuferService clipboardBuferService,
     IProgramSettingsGetter settings,
     IProgramSettingsSetter settingsSetter,
     IIDataObjectHandler dataObjectHandler,
     IEnumerable <IBufermanPlugin> plugins,
     IBufermanOptionsWindowFactory optionsWindowFactory,
     IFileStorage fileStorage,
     ISessionManager sessionManager)
 {
     this._userFileSelector      = userFileSelector;
     this._clipboardBuferService = clipboardBuferService;
     this._settings             = settings;
     this._settingsSetter       = settingsSetter;
     this._dataObjectHandler    = dataObjectHandler;
     this._plugins              = plugins;
     this._optionsWindowFactory = optionsWindowFactory;
     this._fileStorage          = fileStorage;
     this._sessionManager       = sessionManager;
 }
 public BufermanApplication(IClipboardBuferService clipboardBuferService,
                            IClipboardWrapper clipboardWrapper,
                            IIDataObjectHandler dataObjectHandler,
                            IProgramSettingsGetter settings,
                            IMainMenuGenerator mainMenuGenerator,
                            IEnumerable <IBufermanPlugin> plugins,
                            IBufersStorageFactory bufersStorageFactory,
                            IBufermanOptionsWindowFactory optionsWindowFactory,
                            IFileStorage fileStorage,
                            ITime time,
                            ISessionManager sessionManager)
 {
     this._clipboardBuferService = clipboardBuferService;
     this._clipboardWrapper      = clipboardWrapper;
     this._plugins              = plugins;
     this._mainMenuGenerator    = mainMenuGenerator;
     this._dataObjectHandler    = dataObjectHandler;
     this._bufersStorageFactory = bufersStorageFactory;
     this._settings             = settings;
     this._optionsWindowFactory = optionsWindowFactory;
     this._fileStorage          = fileStorage;
     this._time           = time;
     this._sessionManager = sessionManager;
 }
Example #12
0
 public RenderingHandler(IClipboardBuferService clipboardBuferService, IProgramSettingsGetter settings, IBuferHandlersBinder buferHandlersBinder)
 {
     this._clipboardBuferService = clipboardBuferService;
     this._settings            = settings;
     this._buferHandlersBinder = buferHandlersBinder;
 }
Example #13
0
        public BufermanOptionsWindow(
            IProgramSettingsGetter settingsGetter,
            IProgramSettingsSetter settingsSetter,
            IUserInteraction userInteraction)
        {
            this._settingsGetter  = settingsGetter;
            this._settingsSetter  = settingsSetter;
            this._userInteraction = userInteraction;

            this.Icon    = Icons.Buferman;
            this.TopMost = true;

            this.AutoSize = true;

            this._components     = new Container();
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            this.Text  = Resource.OptionsWindowTitle;
            this.Width = 425;

            this.SuspendLayout();

            var tabs = new TabControl()
            {
                Dock   = DockStyle.Fill,
                Parent = this
            };

            tabs.TabPages.Add(this._CreateCommonTab());
            tabs.TabPages.Add(this._CreateUITab());
            //tabs.TabPages.Add(this._CreatePluginsTab());

            var controlPanel = new FlowLayoutPanel()
            {
                FlowDirection = FlowDirection.RightToLeft,
                AutoSize      = true,
                Dock          = DockStyle.Bottom,
                Parent        = this
            };

            var cancelButton = new Button
            {
                Text     = Resource.OptionsWindowCancelButton,
                AutoSize = true,
                Parent   = controlPanel
            };

            cancelButton.Click += (object sender, EventArgs args) =>
            {
                this.Close();
            };
            this._saveButton = new Button {
                Text     = Resource.OptionsWindowSaveButton,
                AutoSize = true,
                Parent   = controlPanel,
                Enabled  = false
            };
            this._saveButton.Click += (object sender, EventArgs args) =>
            {
                this._settingsSetter.Save();
                // TODO (m) rerender bufers because colors can be changed
                this.Close();
            };
            this._restoreButton = new Button
            {
                Text     = Resource.OptionsWindowRestoreButton,
                AutoSize = true,
                Parent   = controlPanel,
                Enabled  = !this._settingsSetter.IsDefault
            };
            this._restoreButton.Click += (object sender, EventArgs args) =>
            {
                this._settingsSetter.RestoreDefault();
                this._settingsSetter.Save();
                // TODO (m) rerender bufers because colors can be changed
                this.Close();
            };

            this.ResumeLayout(false);
        }
Example #14
0
        public BuferHandlersWrapper(
            IClipboardBuferService clipboardBuferService,
            IBuferContextMenuGenerator buferContextMenuGenerator,
            IBuferSelectionHandlerFactory buferSelectionHandlerFactory,
            IFileStorage fileStorage,
            IBufermanHost bufermanHost,
            IProgramSettingsGetter settingsGetter,
            IProgramSettingsSetter settingsSetter,
            IEnumerable<IBufermanPlugin> plugins,
            IBufer bufer)
        {
            this._settingsGetter = settingsGetter;
            this._settingsSetter = settingsSetter;

            this._clipboardBuferService = clipboardBuferService;
            this._bufermanHost = bufermanHost;
            this._bufer = bufer;
            this._buferSelectionHandlerFactory = buferSelectionHandlerFactory;
            this._fileStorage = fileStorage;

            var formats = this._bufer.ViewModel.Clip.GetFormats();

            string buferTitle = null;

            var clipFiles = this._bufer.ViewModel.Clip.GetData(DataFormats.FileDrop) as string[];
            if (clipFiles != null && clipFiles.Length > 0)
            {
                var firstFile = clipFiles.First();
                var onlyFolders = clipFiles.Select(f => this._fileStorage.GetFileAttributes(f).HasFlag(FileAttributes.Directory))
                    .All(f => f);

                if (clipFiles.Length == 1)
                {
                    buferTitle = this._MakeSpecialBuferText(
                        firstFile.Length < settingsGetter.MaxFilePathLengthForBuferTitle ?
                        firstFile :
                        (onlyFolders ? Resource.FolderBufer : Resource.FileBufer));// TODO (m) these resources are duplicated in BuferMAN.Application project
                }
                else
                {
                    buferTitle = this._MakeSpecialBuferText($"{(onlyFolders ? Resource.FoldersBufer : Resource.FilesBufer)} ({clipFiles.Length})");
                }
            }
            else
            {
                if (formats.Contains(ClipboardFormats.CUSTOM_IMAGE_FORMAT) ||
                    formats.Contains(ClipboardFormats.FILE_CONTENTS_FORMAT))
                {
                    this._bufer.ApplyFontStyle(FontStyle.Italic | FontStyle.Bold);
                }
            }

            string buferText = buferTitle ?? this._bufer.ViewModel.TextRepresentation;
            if (string.IsNullOrWhiteSpace(buferText))
            {
                this._bufer.ApplyFontStyle(FontStyle.Italic | FontStyle.Bold);
                this._bufer.ViewModel.IsChangeTextAvailable = false;

                if (buferText == null)
                {
                    if (formats.Any(f => string.Equals(f, ClipboardFormats.VISUAL_STUDIO_PROJECT_ITEMS, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        buferText = "<< VISUAL STUDIO project items >>";
                    }
                    else
                    {
                        buferText = Resource.NotTextBufer;
                        // TODO (l) maybe track such cases and/or ask user to send info (at least formats list) of this bufer?
                        // Or user can think of some name for this combination of formats
                    }
                }
                else
                {
                    buferText = this._MakeSpecialBuferText($"{buferText.Length}   {Resource.WhiteSpaces}");
                    this._bufer.ViewModel.TooltipTitle = buferText;
                }
            }
            this._bufer.ViewModel.DefaultBackColor = this._bufer.BackColor;
            buferText = buferText.Trim();
            this._bufer.SetText(buferText);
            this._bufer.ViewModel.OriginBuferTitle = buferText;

            this._bufer.SetMouseOverToolTip(this._bufer.ViewModel.TextRepresentation);
            this._bufer.ViewModel.TooltipTitle = this._bufer.ViewModel.TooltipTitle ?? buferTitle;

            if (!string.IsNullOrWhiteSpace(this._bufer.ViewModel.TooltipTitle))
            {
                this._bufer.MouseOverTooltip.ToolTipTitle = this._bufer.ViewModel.TooltipTitle;
                this._bufer.FocusTooltip.ToolTipTitle = this._bufer.ViewModel.TooltipTitle;
            }

            IBuferTypeMenuGenerator buferTypeMenuGenerator = null;
            if (Uri.TryCreate(this._bufer.ViewModel.OriginBuferTitle, UriKind.Absolute, out var uriResult)
                        && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps))
            {
                buferTypeMenuGenerator = new HttpUrlBuferMenuGenerator(this._bufer.ViewModel.OriginBuferTitle, this._settingsGetter, this._settingsSetter);
            }
            else
            {
                var files = this._bufer.ViewModel.Clip.GetData(DataFormats.FileDrop) as string[];
                if (files != null && files.Length > 0)
                {
                    var firstFile = files.First();

                    if (files.Length == 1)
                    {
                        buferTypeMenuGenerator = new FileBuferMenuGenerator(firstFile);
                    }
                }
            }

            if (formats.Contains(ClipboardFormats.CUSTOM_IMAGE_FORMAT))
            {
                var image = this._bufer.ViewModel.Clip.GetData(ClipboardFormats.CUSTOM_IMAGE_FORMAT) as Image;
                if (image != null)
                {
                    this._bufer.ViewModel.Representation = image;
                    this._bufer.MouseOverTooltip.IsBalloon = false;
                    this._bufer.MouseOverTooltip.OwnerDraw = true;
                    this._bufer.MouseOverTooltip.Popup += (object sender, PopupEventArgs e) =>
                    {
                        e.ToolTipSize = new Size((int)(image.Width * IMAGE_SCALE), (int)(image.Height * IMAGE_SCALE));
                    };
                    this._bufer.MouseOverTooltip.Draw += (object sender, DrawToolTipEventArgs e) =>
                    {
                        using (var b = new TextureBrush(new Bitmap(image)))
                        {
                            b.ScaleTransform(IMAGE_SCALE, IMAGE_SCALE);

                            var g = e.Graphics;
                            g.FillRectangle(b, e.Bounds);
                        }
                    };
                }
            }

            this._bufer.AddOnFocusHandler(this._Bufer_GotFocus);
            this._bufer.AddOnUnfocusHandler(this._Bufer_LostFocus);

            var buferSelectionHandler = this._buferSelectionHandlerFactory.CreateHandler(this._bufer, bufermanHost);
            if (this._settingsGetter.IsBuferClickingExplained)
            {
                this._bufer.AddOnClickHandler(buferSelectionHandler.DoOnClipSelection);
            }
            else
            {
                this._bufer.AddOnClickHandler((object sender, EventArgs e) =>
                {
                    if (this._settingsGetter.IsBuferClickingExplained)
                    {
                        buferSelectionHandler.DoOnClipSelection(sender, e);
                    }
                    else
                    {
                        this._bufermanHost.UserInteraction.ShowPopup(Resource.BuferClickingExplanationText, Application.ProductName);
                        this._settingsSetter.MarkThatBuferClickingWasExplained();
                    }
                });
            }

            var buferContextMenuState = new BuferContextMenuState(
                clipboardBuferService,
                buferSelectionHandler,
                bufermanHost,
                () => Resource.MenuPin, // TODO (m) remove these actions
                () => Resource.MenuUnpin,
                () => Resource.MenuAddedToFile,
                bufer);

            bufer.ContextMenu = buferContextMenuGenerator.GenerateContextMenuItems(buferContextMenuState, bufermanHost, buferTypeMenuGenerator);

            foreach (var plugin in plugins) if (plugin.Available && plugin.Enabled)
                {
                    try
                    {
                        plugin.UpdateBuferItem(buferContextMenuState);
                    }
                    catch (Exception exc)
                    {
                        bufermanHost
                            .UserInteraction
                            .ShowPopup(exc.Message, plugin.Name);
                    }
                }
        }
Example #15
0
 public DataObjectHandler(IClipboardBuferService clipboardBuferService, IProgramSettingsGetter settings, IFileStorage fileStorage)
 {
     this._clipboardBuferService = clipboardBuferService;
     this._settings    = settings;
     this._fileStorage = fileStorage;
 }