Ejemplo n.º 1
0
        private void RecycleBin_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

            switch (args.VirtualKey)
            {
            case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                ListViewControl.SelectAll();
                break;
            }

            case VirtualKey.Delete when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
            {
                PermanentDelete_Click(null, null);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        void OnAttributeRepositioned(object sender, EventArgs e)
        {
            ListViewControl listView = sender as ListViewControl;

            if (listView.Parent is DockPanelDataSourceAttributes)
            {
                SaveAssociations(m_dm_Attributes.sreListView1.ListView);
            }
            else if (listView.Parent is DockPanelDataSourceSystemAttributes)
            {
                SaveAssociations(m_dm_SystemAttributes.sreListView1.ListView, true);
            }

            if (ServiceCommunicator.ClearDataSource(SelectedDataSource.Id, string.Empty))
            {
                SetToolStripStatusLabel("Ready");
            }
            else
            {
                SetToolStripStatusLabel("Failed to clear cache", true);
            }
        }
Ejemplo n.º 3
0
        private void RecycleBin_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            if (!LoadingControl.IsLoading)
            {
                SelectFlyout.Hide();
                EmptyFlyout.Hide();

                CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

                switch (args.VirtualKey)
                {
                case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    ListViewControl.SelectAll();
                    break;
                }

                case VirtualKey.Delete:
                case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    PermanentDelete_Click(null, null);
                    break;
                }

                case VirtualKey.R when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    RestoreRecycle_Click(null, null);
                    break;
                }

                case VirtualKey.E when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    ClearRecycleBin_Click(null, null);
                    break;
                }
                }
            }
        }
Ejemplo n.º 4
0
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!ShowSqlInitRules)
            {
                switch (tabControl.SelectedIndex)
                {
                case 0:
                    selectedRuleListView = lvPreValidate;
                    selectedRuleSetType  = RuleSetTypes.PreValidate;
                    break;

                case 1:
                    selectedRuleListView = lvRowPreparing;
                    selectedRuleSetType  = RuleSetTypes.RowPreparing;
                    break;

                case 2:
                    selectedRuleListView = lvRowPrepared;
                    selectedRuleSetType  = RuleSetTypes.RowPrepared;
                    break;

                case 3:
                    selectedRuleListView = lvRowValidate;
                    selectedRuleSetType  = RuleSetTypes.RowValidate;
                    break;

                case 4:
                    selectedRuleListView = lvPostValidate;
                    selectedRuleSetType  = RuleSetTypes.PostValidate;
                    break;
                }
            }
            else
            {
                selectedRuleListView = lvSqlInit;
                selectedRuleSetType  = RuleSetTypes.SqlPullInit;
            }
        }
        private static void CreateListViewItem(UploadInfo info)
        {
            if (ListViewControl != null)
            {
                Program.MyLogger.WriteLine("Upload in queue. ID: {0}, Job: {1}, Type: {2}, Host: {3}", info.ID, info.Job, info.UploadDestination, info.UploaderHost);

                ListViewItem lvi = new ListViewItem();
                lvi.Text = info.FileName;
                lvi.SubItems.Add("In queue");
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(info.DataType.ToString());
                lvi.SubItems.Add(info.UploaderHost);
                lvi.SubItems.Add(string.Empty);
                lvi.BackColor  = info.ID % 2 == 0 ? Color.White : Color.WhiteSmoke;
                lvi.ImageIndex = 3;
                ListViewControl.Items.Add(lvi);
                lvi.EnsureVisible();
                ListViewControl.FillLastColumn();
            }
        }
Ejemplo n.º 6
0
 internal void ImportAttributes(ListViewControl sreListView, bool isSytem = false)
 {
     openFileDialog1.FileName = string.Empty;
     openFileDialog1.Filter   = "Comma Delimited Files (*.csv)|*.csv|All Files (*.*)|*.*";
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.Cursor = Cursors.WaitCursor;
         DataTable            table      = m_dm_GlobalAttributes.ReadData(openFileDialog1.FileName);
         List <IdpeAttribute> attributes = new List <IdpeAttribute>();
         string result = m_dm_GlobalAttributes.ImportAttributes(table, ref attributes);
         if (!isSytem)
         {
             m_dm_Attributes.sreListView1.Attributes = attributes;
             SaveAssociations(m_dm_Attributes.sreListView1.ListView, isSytem);
         }
         else
         {
             m_dm_SystemAttributes.sreListView1.Attributes = attributes;
             SaveAssociations(m_dm_SystemAttributes.sreListView1.ListView, isSytem);
         }
         this.Cursor = Cursors.Default;
         MessageBox.Show(result, "Bulk Insert", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 7
0
        private static void CreateListViewItem(WorkerTask wt)
        {
            if (ListViewControl != null)
            {
                DebugHelper.WriteLine("Upload in queue. ID: {0}, Job: {1}, Type: {2}, Host: {3}",
                                      wt.Id, wt.Job1, wt.Job2, wt.GetDestinationName());

                ListViewItem lvi = new ListViewItem();
                lvi.Text = wt.Info.FileName;
                lvi.SubItems.Add("In queue");
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(string.Empty);
                lvi.SubItems.Add(wt.GetDescription());
                lvi.SubItems.Add(wt.GetDestinationName());
                lvi.SubItems.Add(string.Empty);
                lvi.BackColor  = wt.Id % 2 == 0 ? Color.White : Color.WhiteSmoke;
                lvi.ImageIndex = 3;
                ListViewControl.Items.Add(lvi);
                lvi.EnsureVisible();
                ListViewControl.FillLastColumn();
            }
        }
Ejemplo n.º 8
0
        private static void task_TaskCompleted(WorkerTask task)
        {
            try
            {
                task.KeepImage = false;

                if (task != null)
                {
                    if (task.RequestSettingUpdate)
                    {
                        Program.MainForm.UpdateCheckStates();
                    }

                    TaskInfo info = task.Info;

                    if (info != null && info.Result != null)
                    {
                        ListViewItem lvi = FindListViewItem(task);

                        if (task.Status == TaskStatus.Stopped)
                        {
                            DebugHelper.WriteLine($"Task stopped. Filename: {info.FileName}");

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;
                            }
                        }
                        else if (task.Status == TaskStatus.Failed)
                        {
                            string errors = string.Join("\r\n\r\n", info.Result.Errors.ToArray());

                            DebugHelper.WriteLine($"Task failed. Filename: {info.FileName}, Errors:\r\n{errors}");

                            if (lvi != null)
                            {
                                lvi.SubItems[1].Text = info.Status;
                                lvi.SubItems[6].Text = "";
                                lvi.ImageIndex       = 1;
                            }

                            if (!info.TaskSettings.AdvancedSettings.DisableNotifications)
                            {
                                if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                {
                                    TaskHelpers.PlayErrorSound(info.TaskSettings);
                                }

                                if (info.TaskSettings.GeneralSettings.PopUpNotification != PopUpNotificationType.None && !string.IsNullOrEmpty(errors) &&
                                    (!info.TaskSettings.AdvancedSettings.DisableNotificationsOnFullscreen || !CaptureHelpers.IsActiveWindowFullscreen()))
                                {
                                    TaskHelpers.ShowBalloonTip(errors, ToolTipIcon.Error, 5000, "ShareX - " + Resources.TaskManager_task_UploadCompleted_Error);
                                }
                            }
                        }
                        else
                        {
                            DebugHelper.WriteLine($"Task completed. Filename: {info.FileName}, Duration: {(long)info.TaskDuration.TotalMilliseconds} ms");

                            string result = info.Result.ToString();

                            if (string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(info.FilePath))
                            {
                                result = info.FilePath;
                            }

                            if (lvi != null)
                            {
                                lvi.Text             = info.FileName;
                                lvi.SubItems[1].Text = info.Status;
                                lvi.ImageIndex       = 2;

                                if (!string.IsNullOrEmpty(result))
                                {
                                    lvi.SubItems[6].Text = result;
                                }
                            }

                            if (!task.StopRequested && !string.IsNullOrEmpty(result))
                            {
                                if (Program.Settings.HistorySaveTasks && (!Program.Settings.HistoryCheckURL ||
                                                                          (!string.IsNullOrEmpty(info.Result.URL) || !string.IsNullOrEmpty(info.Result.ShortenedURL))))
                                {
                                    HistoryItem historyItem = info.GetHistoryItem();
                                    AppendHistoryItemAsync(historyItem);
                                }

                                RecentManager.Add(task);

                                if (!info.TaskSettings.AdvancedSettings.DisableNotifications && info.Job != TaskJob.ShareURL)
                                {
                                    if (info.TaskSettings.GeneralSettings.PlaySoundAfterUpload)
                                    {
                                        TaskHelpers.PlayTaskCompleteSound(info.TaskSettings);
                                    }

                                    if (!string.IsNullOrEmpty(info.TaskSettings.AdvancedSettings.BalloonTipContentFormat))
                                    {
                                        result = new UploadInfoParser().Parse(info, info.TaskSettings.AdvancedSettings.BalloonTipContentFormat);
                                    }

                                    if (!string.IsNullOrEmpty(result) &&
                                        (!info.TaskSettings.AdvancedSettings.DisableNotificationsOnFullscreen || !CaptureHelpers.IsActiveWindowFullscreen()))
                                    {
                                        switch (info.TaskSettings.GeneralSettings.PopUpNotification)
                                        {
                                        case PopUpNotificationType.BalloonTip:
                                            BalloonTipAction action = new BalloonTipAction()
                                            {
                                                ClickAction = BalloonTipClickAction.OpenURL,
                                                Text        = result
                                            };

                                            TaskHelpers.ShowBalloonTip(result, ToolTipIcon.Info, 5000,
                                                                       "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed, action);
                                            break;

                                        case PopUpNotificationType.ToastNotification:
                                            task.KeepImage = true;

                                            NotificationFormConfig toastConfig = new NotificationFormConfig()
                                            {
                                                LeftClickAction   = info.TaskSettings.AdvancedSettings.ToastWindowClickAction,
                                                RightClickAction  = info.TaskSettings.AdvancedSettings.ToastWindowRightClickAction,
                                                MiddleClickAction = info.TaskSettings.AdvancedSettings.ToastWindowMiddleClickAction,
                                                FilePath          = info.FilePath,
                                                Image             = task.Image,
                                                Text = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result,
                                                URL  = result
                                            };
                                            NotificationForm.Show((int)(info.TaskSettings.AdvancedSettings.ToastWindowDuration * 1000),
                                                                  (int)(info.TaskSettings.AdvancedSettings.ToastWindowFadeDuration * 1000),
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowPlacement,
                                                                  info.TaskSettings.AdvancedSettings.ToastWindowSize, toastConfig);
                                            break;
                                        }

                                        if (info.TaskSettings.AfterUploadJob.HasFlag(AfterUploadTasks.ShowAfterUploadWindow) && info.IsUploadJob)
                                        {
                                            AfterUploadForm dlg = new AfterUploadForm(info);
                                            NativeMethods.ShowWindow(dlg.Handle, (int)WindowShowStyle.ShowNoActivate);
                                        }
                                    }
                                }
                            }
                        }

                        if (lvi != null)
                        {
                            lvi.EnsureVisible();

                            if (Program.Settings.AutoSelectLastCompletedTask)
                            {
                                ListViewControl.SelectSingle(lvi);
                            }
                        }

                        if (Program.Settings.TaskViewMode == TaskViewMode.ThumbnailView)
                        {
                            TaskView.UpdateProgressVisible(task, false);
                        }
                    }
                }
            }
            finally
            {
                if (!IsBusy && Program.CLI.IsCommandExist("AutoClose"))
                {
                    Application.Exit();
                }
                else
                {
                    StartTasks();
                    UpdateProgressUI();

                    if (Program.Settings.SaveSettingsAfterTaskCompleted && !IsBusy)
                    {
                        SettingManager.SaveAllSettingsAsync();
                    }
                }
            }
        }
Ejemplo n.º 9
0
 private void RecycleBin_Loaded(object sender, RoutedEventArgs e)
 {
     ListViewControl.AddHandler(PointerPressedEvent, PointerPressedHandler, true);
     CoreWindow.GetForCurrentThread().KeyDown += RecycleBin_KeyDown;
     SelectionExtention = new ListViewBaseSelectionExtention(ListViewControl, DrawRectangle);
 }
Ejemplo n.º 10
0
 private void RecycleBin_Unloaded(object sender, RoutedEventArgs e)
 {
     SelectionExtention?.Dispose();
     CoreWindow.GetForCurrentThread().KeyDown -= RecycleBin_KeyDown;
     ListViewControl.RemoveHandler(PointerPressedEvent, PointerPressedHandler);
 }
 private void Bind()
 {
     ListViewControl.Bind();
 }
        private void AddCharacterItemBoxToCharacterListBox(Character c)
        {
            ListViewControl newListView = new ListViewControl(c);

            CharacterBox.Items.Add(newListView);
        }
Ejemplo n.º 13
0
 private void ListViewControl_ItemDrag(object sender, ItemDragEventArgs e)
 {
     string[] items = getSelectedPaths();
     ListViewControl.DoDragDrop(new DataObject(DataFormats.FileDrop, items), DragDropEffects.Copy);
 }
Ejemplo n.º 14
0
 public ListViewData(ListViewControl listViewControl)
 {
     ListViewControl = listViewControl;
     DataFilter      = new ListViewDataFilter(this);
 }
Ejemplo n.º 15
0
        void OnDataSourceChanged(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            dockPanel.SuspendLayout(true);
            ListViewControl sreListView = sender as ListViewControl;

            if (sreListView != null)
            {
                if (sreListView.ListView.SelectedItems.Count > 0)
                {
                    //if (((IdpeDataSource)sreListView.ListView.SelectedItems[0].Tag).Id == 100)
                    //{
                    //    m_dm_GlobalAttributes.btnAssociateBoth.Enabled = false;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeDataSource.Enabled = false;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeSystemDataSource.Enabled = false;
                    //    this.Cursor = Cursors.Default;
                    //    return;
                    //}
                    //else
                    //{
                    //    m_dm_GlobalAttributes.btnAssociateBoth.Enabled = true;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeDataSource.Enabled = true;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeSystemDataSource.Enabled = true;
                    //}

                    if ((m_dm_Property.propertyGrid.SelectedObject != null) &&
                        (((SrePropertyGrid)m_dm_Property.propertyGrid.SelectedObject).HasChanged))
                    {
                        this.Cursor = Cursors.WaitCursor;
                        toolStripStatusLabel1.Text = "Please wait...Saving properties...";
                        Application.DoEvents();
                        ((SrePropertyGrid)m_dm_Property.propertyGrid.SelectedObject).Save();

                        toolStripStatusLabel1.Text = "Please wait...Clearing cache...";
                        Application.DoEvents();
                        if (ServiceCommunicator.ClearDataSource(SelectedDataSource.Id, string.Empty))
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        else
                        {
                            SetToolStripStatusLabel("Failed to clear cache", true);
                        }

                        toolStripStatusLabel1.Text = "Please wait...Refresing...";
                        Application.DoEvents();
                        RefreshData();
                        if (MainWindowShown)
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        this.Cursor = Cursors.Default;
                    }

                    if (sreListView.ListView.SelectedItems.Count > 0)
                    {
                        toolStripStatusLabel1.Text = "Please wait...Refresing...";
                        Application.DoEvents();
                        if ((sreListView.DefaultItemId > 0) && (!MainWindowShown))
                        {
                            SelectedDataSource = sreListView.ListView.Items.Cast <ListViewItem>().Select(x => x.Tag).ToList().Cast <IdpeDataSource>().Where(ds => ds.Id == sreListView.DefaultItemId).SingleOrDefault();
                            if (sreListView.DefaultItem != null)
                            {
                                sreListView.DefaultItem.EnsureVisible();
                            }

                            if (SelectedDataSource == null)
                            {
                                SelectedDataSource = sreListView.ListView.Items[0].Tag as IdpeDataSource;
                            }
                        }
                        else
                        {
                            SelectedDataSource = sreListView.ListView.SelectedItems[0].Tag as IdpeDataSource;
                        }

                        m_dm_DataSources.SelectedDataSource      = SelectedDataSource;
                        m_dm_Attributes.SelectedDataSource       = SelectedDataSource;
                        m_dm_SystemAttributes.SelectedDataSource = SelectedDataSource;
                        m_dm_GlobalAttributes.SelectedDataSource = SelectedDataSource;
                        if (MainWindowShown)
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        Application.DoEvents();
                    }
                    m_dm_Attributes.DataSourceId             = SelectedDataSource.Id;
                    m_dm_SystemAttributes.SystemDataSourceId = (int)SelectedDataSource.SystemDataSourceId;
                    m_dm_Property.DataSource = SelectedDataSource;
                    SetToolStripStatusLabel("Ready");
                }
            }
            dockPanel.ResumeLayout(true, true);
            this.Cursor = Cursors.Default;
            sreListView.ListView.Focus();
        }
Ejemplo n.º 16
0
        internal static void CicleControls(String formName, Control.ControlCollection controls, bool isFormReloading)
        {
            foreach (Control control in controls)
            {
                if (control.Tag != null && control.Tag.ToString() == ConstantUtil.dontTranslate)
                {
                    continue;
                }

                try
                {
                    Type controlType = control.GetType();

                    if (controlType == typeof(TextBox) || controlType == typeof(Label) || controlType == typeof(LinkLabel) || controlType == typeof(Button) || controlType == typeof(CheckBox) || controlType == typeof(CustomCheckBox) ||
                        controlType == typeof(RadioButton) || controlType == typeof(RichTextBox) || (controlType == typeof(CustomXtraTabControl) && !isFormReloading) || controlType == typeof(TabControl) ||
                        controlType == typeof(XtraTabControl) || controlType == typeof(XmlGridView) || controlType == typeof(DataGridView))
                    {
                        GeneralControl.ManageControl(control, formName, isFormReloading);
                    }
                    else if (controlType == typeof(TabPage))
                    {
                        TabPageControl.ManageControl(control, formName, isFormReloading);
                    }
                    else if (controlType == typeof(XtraTabPage))
                    {
                        XtraTabPageControl.ManageControl(control, formName, isFormReloading);
                    }
                    else if (controlType == typeof(FlowLayoutPanel) || controlType == typeof(Panel) || controlType == typeof(SplitContainer) ||
                             controlType == typeof(SplitterPanel) || controlType == typeof(ContextMenuStrip))
                    {
                        PanelMenuControl.ManageControl(control, formName, isFormReloading);
                    }
                    else if (controlType == typeof(GroupBox))
                    {
                        GroupBoxControl.ManageControl(control, formName, isFormReloading);
                    }
                    else if (controlType == typeof(MenuStrip))
                    {
                        MenuStripControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(ToolStrip))
                    {
                        ToolStripControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(StatusStrip))
                    {
                        StatusStripControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(ComboBox) || (controlType == typeof(ComboBoxEdit)))
                    {
                        ComboBoxControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(CustomComboBox))
                    {
                        CustomComboBoxControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(CustomNumericUpDown))
                    {
                        CustomNumericUpDownControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(TreeView))
                    {
                        TreeViewControl.ManageControl(control, formName);
                    }
                    else if (controlType == typeof(ListView))
                    {
                        ListViewControl.ManageControl(control, formName);
                    }
                }
                catch (Exception exception)
                {
                    throw new LanguageException(String.Format("{0} - {1}", control.Name, exception.Message), exception);
                }
            }
        }