Example #1
0
        public SearchResultView()
        {
            InitializeComponent();


            mainToolStrip.ImageScalingSize  = new Size(UIUtils.Dpi.Scale(16), UIUtils.Dpi.Scale(16));
            mainToolStrip.ResizingEnabled   = true;
            mainToolStrip.ResizingStarted  += (sender, args) => viewModel.OnResizingStarted();
            mainToolStrip.ResizingFinished += (sender, args) => viewModel.OnResizingFinished();
            mainToolStrip.Resizing         += (sender, args) => viewModel.OnResizing(args.Delta);

            findCurrentTimeButton.Image = UIUtils.DownscaleUIImage(Properties.Resources.FindCurrentTime, mainToolStrip.ImageScalingSize);
            toggleBookmarkButton.Image  = UIUtils.DownscaleUIImage(Properties.Resources.Bookmark, mainToolStrip.ImageScalingSize);
            pinImage          = UIUtils.DownscaleUIImage(Properties.Resources.Pin, mainToolStrip.ImageScalingSize);
            pinnedImage       = UIUtils.DownscaleUIImage(Properties.Resources.Pinned, mainToolStrip.ImageScalingSize);
            dropdownImage     = UIUtils.DownscaleUIImage(Properties.Resources.Dropdown, mainToolStrip.ImageScalingSize);
            hideDropdownImage = UIUtils.DownscaleUIImage(Properties.Resources.HideDropdown, mainToolStrip.ImageScalingSize);
            emptyImage        = new Bitmap(mainToolStrip.ImageScalingSize.Width, mainToolStrip.ImageScalingSize.Height);

            dropDownPanel.Left   = this.PointToClient(mainToolStrip.PointToScreen(new Point(toggleBookmarkButton.Bounds.Right, 0))).X;
            dropDownPanel.Height = mainToolStrip.Height * 3;

            mainToolStripControls = AddToolStripControls(mainToolStrip);
            mainToolStripControls.dropdownBtnShowsList = true;
            UpdateToolStripControls(mainToolStripControls, null);
        }
Example #2
0
        ToolStripControls AddToolStripControls(ExtendedToolStrip toolstrip)
        {
            var ctrls = new ToolStripControls()
            {
                toolStrip = toolstrip
            };

            ctrls.dropdownBtn = new ToolStripButton()
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image,
            };
            ctrls.visibleCb = new CheckBox()
            {
                Padding = new Padding(0, 3, 0, 0),
            };
            ctrls.visibleCbHost = new ToolStripControlHost(ctrls.visibleCb)
            {
                Padding = new Padding(3, 0, 3, 0)                 // todo: check if scaling by DPI is needed
            };
            ctrls.pinnedBtn = new ToolStripButton()
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image,
            };
            ctrls.textLabel = new ProgressToolStripLabel()
            {
                Padding   = new Padding(6, 0, 0, 0),
                TextAlign = ContentAlignment.MiddleLeft,
                AutoSize  = false,
            };
            toolstrip.Items.AddRange(new ToolStripItem[]
            {
                ctrls.dropdownBtn,
                ctrls.visibleCbHost,
                ctrls.pinnedBtn,
                ctrls.textLabel
            });
            toolstrip.ContextMenu = new ContextMenu(new[]
            {
                ctrls.visibleMenuItem           = new MenuItem("Visible", (s, e) => viewModel.OnMenuItemClicked(ctrls.currentItem, MenuItemId.Visible)),
                ctrls.pinnedMenuItem            = new MenuItem("Pinned", (s, e) => viewModel.OnMenuItemClicked(ctrls.currentItem, MenuItemId.Pinned)),
                ctrls.visibleOnTimelineMenuItem = new MenuItem("Display on timeline", (s, e) => viewModel.OnMenuItemClicked(ctrls.currentItem, MenuItemId.VisibleOnTimeline)),
                ctrls.deleteSeparatorMenuItem   = new MenuItem("-"),
                ctrls.deleteMenuItem            = new MenuItem("Delete", (s, e) => viewModel.OnMenuItemClicked(ctrls.currentItem, MenuItemId.Delete)),
            });
            return(ctrls);
        }
Example #3
0
 void UpdateToolStripControls(ToolStripControls ctrls, ViewItem item)
 {
     ctrls.visibleCbHost.Visible = item != null;
     ctrls.pinnedBtn.Visible     = item != null;
     ctrls.textLabel.Visible     = item != null;
     if (item == null)
     {
         return;
     }
     if (!ctrls.isInitialized)
     {
         ctrls.dropdownBtn.Enabled = ctrls.dropdownBtnShowsList != null;
         ctrls.dropdownBtn.Image   =
             ctrls.dropdownBtnShowsList == null ? emptyImage :
             ctrls.dropdownBtnShowsList == true ? dropdownImage :
             hideDropdownImage;
         ctrls.dropdownBtn.ToolTipText =
             ctrls.dropdownBtnShowsList == null ? "" :
             ctrls.dropdownBtnShowsList == true ? expandButtonHint :
             unexpandButtonHint;
         if (ctrls.dropdownBtnShowsList != null)
         {
             ctrls.dropdownBtn.Click += (s, e) => viewModel.OnExpandSearchesListClicked();
         }
         ctrls.visibleCbHost.ToolTipText = item.VisiblityControlHint;
         ctrls.visibleCb.CheckedChanged += (s, e) => { if (!updateLock)
                                                       {
                                                           viewModel.OnVisibilityCheckboxClicked(ctrls.currentItem);
                                                       }
         };
         ctrls.pinnedBtn.ToolTipText = item.PinControlHint;
         ctrls.pinnedBtn.Click      += (s, e) => { if (!updateLock)
                                                   {
                                                       viewModel.OnPinCheckboxClicked(ctrls.currentItem);
                                                   }
         };
         if (ctrls.dropdownBtnShowsList != null)
         {
             ctrls.textLabel.Click += (s, e) => viewModel.OnDropdownTextClicked();
         }
         ctrls.toolStrip.ContextMenu.Popup += (s, e) =>
         {
             var menuData = viewModel.OnContextMenuPopup(ctrls.currentItem);
             Action <MenuItem, MenuItemId> updateItem = (menuItem, id) =>
             {
                 menuItem.Visible = (menuData.VisibleItems & id) != 0;
                 menuItem.Checked = (menuData.CheckedItems & id) != 0;
             };
             updateItem(ctrls.visibleMenuItem, MenuItemId.Visible);
             updateItem(ctrls.pinnedMenuItem, MenuItemId.Pinned);
             updateItem(ctrls.visibleOnTimelineMenuItem, MenuItemId.VisibleOnTimeline);
             updateItem(ctrls.deleteSeparatorMenuItem, MenuItemId.Delete);
             updateItem(ctrls.deleteMenuItem, MenuItemId.Delete);
         };
         ctrls.isInitialized = true;
     }
     ctrls.currentItem         = item;
     ctrls.visibleCb.Checked   = item.VisiblityControlChecked;
     ctrls.pinnedBtn.Checked   = item.PinControlChecked;
     ctrls.pinnedBtn.Image     = item.PinControlChecked ? pinnedImage : pinImage;
     ctrls.textLabel.Text      = item.Text;
     ctrls.textLabel.Progress  = item.ProgressVisible ? item.ProgressValue : new double?();
     ctrls.textLabel.ForeColor = item.IsWarningText ? Color.Red : Color.Black;
 }