def __init__(self, __revit__, view, model):
        self.app = __revit__.Application
        self.doc = __revit__.ActiveUIDocument.Document
        self._view = view
        self._model = model
        self.excel_parameters = []
        self.exl_file_dir_path = "C:\\"
        self.config_file_dir_path = os.path.dirname(os.path.realpath(__file__))
        self._open_xl_file_Dialog = WinForms.OpenFileDialog()
        self._open_config_file_Dialog = WinForms.OpenFileDialog()
        self._save_config_file_Dialog = WinForms.SaveFileDialog()
        self._worker = BackgroundWorker()

        self._connectSignals()
Ejemplo n.º 2
0
    def __init__(self):
        wpf.LoadComponent(self, 'WpfApplicationRedGlass.xaml')
        
        self.startButton.Click += self.startButton_Click
        self.stopButton.Click += self.stopButton_Click 

        self.bw = BackgroundWorker()
        #// 進捗状況の更新を可能にする
        self.bw.WorkerReportsProgress = True
        #// キャンセルを可能にする
        self.bw.WorkerSupportsCancellation = True

        #// バックグラウンド行う処理
        self.bw.DoWork += self.bw_DoWork
        #// 進捗状況の更新を行う処理
        self.bw.ProgressChanged += self.bw_ProgressChanged
        #// バックグラウンドでの処理が終了後の処理
        self.bw.RunWorkerCompleted += self.bw_RunWorkerCompleted
Ejemplo n.º 3
0
 def __init__(self, doFunc, param, doneFunc, progressFunc):
     self.doFunc = doFunc
     self.param = param
     self.doneFunc = doneFunc
     thread = BackgroundWorker()
     self.thread = thread
     if progressFunc:
         thread.WorkerReportsProgress = True
         thread.ProgressChanged += progressFunc
     else:
         thread.WorkerReportsProgress = False
     thread.WorkerSupportsCancellation = False
     thread.DoWork += DoWorkEventHandler(self.doWork)
     thread.RunWorkerAsync()
     self.done = False
    def InitializeComponent(self):
        self.progressBar = System.Windows.Forms.ProgressBar()
        #
        # progressBar
        #
        self.progressBar.Location = Point(0, 0)
        self.progressBar.Size = Size(284, 23)
        self.progressBar.Maximum = 100
        self.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee

        self.worker = BackgroundWorker()
        self.worker.DoWork += self.WorkerDoWork
        self.worker.RunWorkerCompleted += self.WorkerCompleted

        self.ClientSize = Size(284, 23)
        self.Controls.Add(self.progressBar)
        self.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        self.MaximizeBox = False
        self.MinimizeBox = False
        self.Text = "Searching Filenames"
        self.Icon = System.Drawing.Icon(ICON)
        self.FormClosing += self.CheckClosing
        self.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Ejemplo n.º 5
0
    def __init__(self):
        self.start_color = Color.FromArgb(10, 225, 10)
        self.stop_color = Color.FromArgb(225, 10, 10)

        self.mining_worker = BackgroundWorker()
        self.mining_worker.DoWork += lambda _, __: self._start_mining_work()
        self.mining_worker.RunWorkerCompleted += lambda _, __: self.notify_completion(
        )
        self.mining_worker.WorkerSupportsCancellation = True

        self.Text = "Mining Utility"
        self.Width = 250
        self.Height = 225
        self.TopMost = True

        self.button = Button()
        self.button.Text = 'Choose Tool Manually'
        self.button.Width = 100
        self.button.Height = 40
        self.button.Location = Point(10, 10)
        self.button.Click += lambda _, __: self.select_manual_tool()

        self.button1 = Button()
        self.button1.Text = 'Clear Manual Tool'
        self.button1.Width = 100
        self.button1.Height = 40
        self.button1.Location = Point(125, 10)
        self.button1.Click += lambda _, __: self.clear_manual_tool()

        self.button2 = Button()
        self.button2.Text = 'Toggle Using Gargish Pickaxe'
        self.button2.Width = 100
        self.button2.Height = 40
        self.button2.Location = Point(125, 50)
        self.button2.Click += lambda _, __: self.toggle_gargish()

        self.button3 = Button()
        self.button3.Text = 'Set Ore Bag'
        self.button3.Width = 100
        self.button3.Height = 40
        self.button3.Location = Point(10, 50)
        self.button3.Click += lambda _, __: self.set_storage_bag()

        self.button4 = Button()
        self.button4.Text = 'Toggle Rail Mining'
        self.button4.Width = 100
        self.button4.Height = 40
        self.button4.Location = Point(10, 90)
        self.button4.Click += lambda _, __: self.toggle_rail()

        self.button5 = Button()
        self.button5.Text = 'START'
        self.button5.Width = 75
        self.button5.Height = 30
        self.button5.Location = Point(135, 135)
        self.button5.BackColor = self.start_color
        self.button5.Click += lambda _, __: self.toggle_mine()

        self.textbox = TextBox()
        if Misc.ReadSharedValue("railname"):
            self.textbox.Text = Misc.ReadSharedValue("railname")
        else:
            self.textbox.Text = "Rail_Name"
        self.textbox.Location = Point(10, 140)
        self.textbox.BackColor = Color.FromArgb(180, 180, 180)
        self.textbox.Width = 115

        self.Controls.Add(self.button)
        self.Controls.Add(self.button1)
        self.Controls.Add(self.button2)
        self.Controls.Add(self.button3)
        self.Controls.Add(self.button4)
        self.Controls.Add(self.button5)
        self.Controls.Add(self.textbox)
Ejemplo n.º 6
0
class mining_util(Form):
    def __init__(self):
        self.start_color = Color.FromArgb(10, 225, 10)
        self.stop_color = Color.FromArgb(225, 10, 10)

        self.mining_worker = BackgroundWorker()
        self.mining_worker.DoWork += lambda _, __: self._start_mining_work()
        self.mining_worker.RunWorkerCompleted += lambda _, __: self.notify_completion(
        )
        self.mining_worker.WorkerSupportsCancellation = True

        self.Text = "Mining Utility"
        self.Width = 250
        self.Height = 225
        self.TopMost = True

        self.button = Button()
        self.button.Text = 'Choose Tool Manually'
        self.button.Width = 100
        self.button.Height = 40
        self.button.Location = Point(10, 10)
        self.button.Click += lambda _, __: self.select_manual_tool()

        self.button1 = Button()
        self.button1.Text = 'Clear Manual Tool'
        self.button1.Width = 100
        self.button1.Height = 40
        self.button1.Location = Point(125, 10)
        self.button1.Click += lambda _, __: self.clear_manual_tool()

        self.button2 = Button()
        self.button2.Text = 'Toggle Using Gargish Pickaxe'
        self.button2.Width = 100
        self.button2.Height = 40
        self.button2.Location = Point(125, 50)
        self.button2.Click += lambda _, __: self.toggle_gargish()

        self.button3 = Button()
        self.button3.Text = 'Set Ore Bag'
        self.button3.Width = 100
        self.button3.Height = 40
        self.button3.Location = Point(10, 50)
        self.button3.Click += lambda _, __: self.set_storage_bag()

        self.button4 = Button()
        self.button4.Text = 'Toggle Rail Mining'
        self.button4.Width = 100
        self.button4.Height = 40
        self.button4.Location = Point(10, 90)
        self.button4.Click += lambda _, __: self.toggle_rail()

        self.button5 = Button()
        self.button5.Text = 'START'
        self.button5.Width = 75
        self.button5.Height = 30
        self.button5.Location = Point(135, 135)
        self.button5.BackColor = self.start_color
        self.button5.Click += lambda _, __: self.toggle_mine()

        self.textbox = TextBox()
        if Misc.ReadSharedValue("railname"):
            self.textbox.Text = Misc.ReadSharedValue("railname")
        else:
            self.textbox.Text = "Rail_Name"
        self.textbox.Location = Point(10, 140)
        self.textbox.BackColor = Color.FromArgb(180, 180, 180)
        self.textbox.Width = 115

        self.Controls.Add(self.button)
        self.Controls.Add(self.button1)
        self.Controls.Add(self.button2)
        self.Controls.Add(self.button3)
        self.Controls.Add(self.button4)
        self.Controls.Add(self.button5)
        self.Controls.Add(self.textbox)

    def select_manual_tool(self):
        global Manual_Tool

        selected = Target.PromptTarget("Select Pickaxe.")
        if Items.FindBySerial(selected).ItemID in [shovelID, pickaxeID]:
            Manual_Tool = selected
        else:
            Misc.SendMessage("Not a valid tool.")

    def clear_manual_tool(self):
        global Manual_Tool

        Manual_Tool = None

    def toggle_gargish(self):
        global using_garg

        using_garg = not using_garg
        if using_garg:
            Misc.SendMessage("Gargish pickaxe enabled.")
        else:
            Misc.SendMessage("Gargish pickaxe disabled.")

    def set_storage_bag(self):
        global Manual_Bag

        selected = Target.PromptTarget("Select storage bag.")
        if Items.FindBySerial(selected).IsContainer:
            Manual_Bag = selected
        else:
            Misc.SendMessage("Not a valid container.")

    def toggle_rail(self):
        global Using_Rail

        if Using_Rail:
            Using_Rail = False
            Misc.SendMessage("Rail Mining Disabled.")
        else:
            Using_Rail = True
            Misc.SendMessage("Rail Mining Enabled.")

    def toggle_mine(self):
        global Currently_Mining

        if Currently_Mining:
            self.toggle_mine_off()
        else:
            self.toggle_mine_on()

    def notify_completion(self):
        self.toggle_mine_off()
        Misc.SendMessage("Finished with mining work.")
        Player.HeadMessage(12, "Finished with mining work.")

    def _start_mining_work(self):
        Misc.SendMessage("Starting mining work.")
        start_mining_work()

    def toggle_mine_on(self):
        global Currently_Mining
        global Rail_Name

        Currently_Mining = True
        Rail_Name = self.textbox.Text

        if not self.mining_worker.IsBusy:
            self.mining_worker.RunWorkerAsync()

            self.button5.BackColor = self.stop_color
            self.button5.Text = "STOP"

    def toggle_mine_off(self):
        global Currently_Mining

        Currently_Mining = False

        Misc.Pause(500)

        self.button5.BackColor = self.start_color
        self.button5.Text = "START"
Ejemplo n.º 7
0
class MyWindow(Window):
    def __init__(self):
        wpf.LoadComponent(self, 'WpfApplicationRedGlass.xaml')
        
        self.startButton.Click += self.startButton_Click
        self.stopButton.Click += self.stopButton_Click 

        self.bw = BackgroundWorker()
        #// 進捗状況の更新を可能にする
        self.bw.WorkerReportsProgress = True
        #// キャンセルを可能にする
        self.bw.WorkerSupportsCancellation = True

        #// バックグラウンド行う処理
        self.bw.DoWork += self.bw_DoWork
        #// 進捗状況の更新を行う処理
        self.bw.ProgressChanged += self.bw_ProgressChanged
        #// バックグラウンドでの処理が終了後の処理
        self.bw.RunWorkerCompleted += self.bw_RunWorkerCompleted
    
    #// 時間のかかる処理
    def bw_DoWork(self, sender, e):
        import System
        for i in range(1,10001):
            if (self.bw.CancellationPending == True):
                #// キャンセルされたので処理を終了
                e.Cancel = True
                break

            #// 現在の進捗状況(数値)
            currentValue = i

            #// currentValue以外の進捗状況を表す情報(オプション)
            status = str(i) + " / 10000"

            #// 進捗状況を報告
            self.bw.ReportProgress(currentValue, status)

            #// 何らかの処理(ここではスリープさせるだけ)
            System.Threading.Thread.Sleep(1)

        #// 操作の結果を渡したい場合はe.Resultを使う
        e.Result = "[終了結果]"

    #// 進捗状況の更新処理
    def bw_ProgressChanged(self, sender, e):
        #// プログレスバーの値を更新
        self.progressBar.Value = e.ProgressPercentage

        #// プログレスバー以外の状況更新
        self.statusTextBlock.Text = e.UserState.ToString()

    #// 時間のかかる処理が終わった後の後処理
    def bw_RunWorkerCompleted(self, sender, e):
        self.statusTextBlock.Text = ""
        self.progressBar.Value = 0

        if (e.Cancelled == True):
            MessageBox.Show("処理を中断しました。")
        else:
            MessageBox.Show("処理が終了しました。" + e.Result.ToString())

        self.startButton.IsEnabled = True
        self.stopButton.IsEnabled = False

    #// 処理開始
    def startButton_Click(self, sender, e):
        self.startButton.IsEnabled = False
        self.stopButton.IsEnabled = True

        #// 時間のかかる処理を実行する
        self.bw.RunWorkerAsync()
    
    #// 作業を途中で止める
    def stopButton_Click(self, sender, e):
       self.bw.CancelAsync()
Ejemplo n.º 8
0
class CopyMoveFieldForm(Form):
    def __init__(self, books, settings):
        self.InitializeComponent()

        self.books = books
        self.percentage = 1.0 / len(books) * 100
        self.progresspercent = 0.0
        self._source.SelectedItem = settings["source_field"]
        self._destination.SelectedItem = settings["destination_field"]
        if settings["source_mode"] == "Copy":
            self._copy.Checked = True
        else:
            self._move.Checked = True
        self._seperator.Text = settings["seperator"]
        self._UserText.Text = settings["user_text"]
        if settings["destination_mode"] == "Replace":
            self._replace.Checked = True
        else:
            self._append.Checked = True

    def InitializeComponent(self):
        self._gbSource = System.Windows.Forms.GroupBox()
        self._source = System.Windows.Forms.ComboBox()
        self._copy = System.Windows.Forms.RadioButton()
        self._move = System.Windows.Forms.RadioButton()
        self._destination = System.Windows.Forms.ComboBox()
        self._groupBox1 = System.Windows.Forms.GroupBox()
        self._label1 = System.Windows.Forms.Label()
        self._append = System.Windows.Forms.RadioButton()
        self._replace = System.Windows.Forms.RadioButton()
        self._seperator = System.Windows.Forms.TextBox()
        self._label2 = System.Windows.Forms.Label()
        self._label3 = System.Windows.Forms.Label()
        self._progress = System.Windows.Forms.ProgressBar()
        self._Okay = System.Windows.Forms.Button()
        self._Cancel = System.Windows.Forms.Button()
        self._UserText = System.Windows.Forms.TextBox()
        self._gbSource.SuspendLayout()
        self._groupBox1.SuspendLayout()
        self.worker = BackgroundWorker()
        self.SuspendLayout()
        #
        # Worker
        #
        self.worker.WorkerSupportsCancellation = True
        self.worker.WorkerReportsProgress = True
        self.worker.DoWork += self.DoWork
        self.worker.ProgressChanged += self.ReportProgress
        self.worker.RunWorkerCompleted += self.WorkerCompleted
        #
        # gbSource
        #
        self._gbSource.Controls.Add(self._move)
        self._gbSource.Controls.Add(self._copy)
        self._gbSource.Controls.Add(self._source)
        self._gbSource.Controls.Add(self._UserText)
        self._gbSource.Controls.Add(self._label3)
        self._gbSource.Location = System.Drawing.Point(12, 11)
        self._gbSource.Name = "gbSource"
        self._gbSource.Size = System.Drawing.Size(202, 97)
        self._gbSource.TabIndex = 0
        self._gbSource.TabStop = False
        self._gbSource.Text = "Source"
        #
        # source
        #
        self._source.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        self._source.FormattingEnabled = True
        self._source.Location = System.Drawing.Point(6, 19)
        self._source.Name = "source"
        self._source.Size = System.Drawing.Size(187, 21)
        self._source.TabIndex = 0
        self._source.Items.AddRange(System.Array[System.String]([
            "Added Time", "Age Rating", "Alternate Count", "Alternate Number",
            "Alternate Series", "Book Age", "Book Collection Status",
            "Book Condition", "Book Location", "Book Notes", "Book Owner",
            "Book Price", "Book Store", "Characters", "Colorist", "Count",
            "Cover Artist", "Editor", "Format", "Genre", "Imprint", "Inker",
            "ISBN", "Letterer", "Locations", "Main Character Or Team", "Month",
            "Notes", "Number", "Penciller", "Published", "Publisher", "Review",
            "Scan Information", "Released Time", "Series", "Series Group",
            "Story Arc", "Summary", "Tags", "Teams", "Title", "User Text",
            "Volume", "Web", "Writer", "Year"
        ]))
        self._source.SelectedIndex = 0
        self._source.SelectedIndexChanged += self.SouceIndexChanged
        #
        # copy
        #
        self._copy.Location = System.Drawing.Point(18, 42)
        self._copy.Name = "copy"
        self._copy.Size = System.Drawing.Size(55, 24)
        self._copy.TabIndex = 1
        self._copy.TabStop = True
        self._copy.Text = "Copy"
        self._copy.UseVisualStyleBackColor = True
        self._copy.Checked = True
        #
        # move
        #
        self._move.Location = System.Drawing.Point(125, 42)
        self._move.Name = "move"
        self._move.Size = System.Drawing.Size(60, 24)
        self._move.TabIndex = 2
        self._move.TabStop = True
        self._move.Text = "Move"
        self._move.UseVisualStyleBackColor = True
        #
        # User Text
        #
        self._label3.AutoSize = True
        self._label3.Location = System.Drawing.Point(2, 72)
        self._label3.Text = "User Text:"
        #
        # User Text
        #
        self._UserText.Size = Size(135, 20)
        self._UserText.Location = Point(60, 69)
        self._UserText.Enabled = False
        #
        # destination
        #
        self._destination.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        self._destination.FormattingEnabled = True
        self._destination.Location = System.Drawing.Point(6, 19)
        self._destination.Name = "destination"
        self._destination.Size = System.Drawing.Size(190, 21)
        self._destination.TabIndex = 1
        self._destination.Items.AddRange(System.Array[System.String]([
            "Added Time", "Age Rating", "Alternate Count", "Alternate Number",
            "Alternate Series", "Book Age", "Book Collection Status",
            "Book Condition", "Book Location", "Book Notes", "Book Owner",
            "Book Price", "Book Store", "Characters", "Colorist", "Count",
            "Cover Artist", "Editor", "Format", "Genre", "Imprint", "Inker",
            "ISBN", "Letterer", "Locations", "Main Character Or Team", "Month",
            "Notes", "Number", "Penciller", "Published", "Publisher", "Review",
            "Scan Information", "Released Time", "Series", "Series Group",
            "Story Arc", "Summary", "Tags", "Teams", "Title", "Volume", "Web",
            "Writer", "Year"
        ]))
        self._destination.SelectedIndex = 0
        #
        # groupBox1
        #
        self._groupBox1.Controls.Add(self._label2)
        self._groupBox1.Controls.Add(self._seperator)
        self._groupBox1.Controls.Add(self._replace)
        self._groupBox1.Controls.Add(self._append)
        self._groupBox1.Controls.Add(self._destination)
        self._groupBox1.Location = System.Drawing.Point(266, 11)
        self._groupBox1.Name = "groupBox1"
        self._groupBox1.Size = System.Drawing.Size(202, 97)
        self._groupBox1.TabIndex = 2
        self._groupBox1.TabStop = False
        self._groupBox1.Text = "Destination"
        #
        # label1
        #
        self._label1.AutoSize = True
        self._label1.Location = System.Drawing.Point(232, 53)
        self._label1.Name = "label1"
        self._label1.Size = System.Drawing.Size(16, 13)
        self._label1.TabIndex = 3
        self._label1.Text = "to"
        #
        # append
        #
        self._append.AutoSize = True
        self._append.Location = System.Drawing.Point(126, 46)
        self._append.Name = "append"
        self._append.Size = System.Drawing.Size(62, 17)
        self._append.TabIndex = 2
        self._append.TabStop = True
        self._append.Text = "Append"
        self._append.UseVisualStyleBackColor = True
        self._append.CheckedChanged += self.DestinationModeChanged
        #
        # replace
        #
        self._replace.AutoSize = True
        self._replace.Location = System.Drawing.Point(14, 46)
        self._replace.Name = "replace"
        self._replace.Size = System.Drawing.Size(65, 17)
        self._replace.TabIndex = 3
        self._replace.TabStop = True
        self._replace.Text = "Replace"
        self._replace.UseVisualStyleBackColor = True
        self._replace.Checked = True
        #
        # seperator
        #
        self._seperator.Location = System.Drawing.Point(154, 69)
        self._seperator.Name = "seperator"
        self._seperator.Size = System.Drawing.Size(42, 20)
        self._seperator.TabIndex = 4
        self._seperator.Enabled = False
        #
        # label2
        #
        self._label2.AutoSize = True
        self._label2.Location = System.Drawing.Point(92, 72)
        self._label2.Name = "label2"
        self._label2.Size = System.Drawing.Size(56, 13)
        self._label2.TabIndex = 5
        self._label2.Text = "Seperator:"
        #
        # progressBar1
        #
        self._progress.Location = System.Drawing.Point(12, 114)
        self._progress.Size = System.Drawing.Size(456, 17)
        self._progress.TabIndex = 4
        #
        # Okay
        #
        self._Okay.Location = System.Drawing.Point(312, 137)
        self._Okay.Name = "Okay"
        self._Okay.Size = System.Drawing.Size(75, 23)
        self._Okay.TabIndex = 5
        self._Okay.Text = "Start"
        self._Okay.UseVisualStyleBackColor = True
        self._Okay.Click += self.OkayClicked
        #
        # Cancel
        #
        self._Cancel.Location = System.Drawing.Point(393, 137)
        self._Cancel.Name = "Cancel"
        self._Cancel.Size = System.Drawing.Size(75, 23)
        self._Cancel.TabIndex = 6
        self._Cancel.Text = "Cancel"
        self._Cancel.UseVisualStyleBackColor = True
        self._Cancel.Click += self.CancelClicked
        #
        # CopyFieldsForm
        #
        self.ClientSize = System.Drawing.Size(483, 170)
        self.Controls.Add(self._Cancel)
        self.Controls.Add(self._Okay)
        self.Controls.Add(self._progress)
        self.Controls.Add(self._label1)
        self.Controls.Add(self._groupBox1)
        self.Controls.Add(self._gbSource)
        self.Name = "CopyFieldsForm"
        self.Text = "Copy/Move Field"
        self.MinimizeBox = False
        self.MaximizeBox = False
        self.ShowIcon = True
        self.Icon = Icon(ICON)
        self.AcceptButton = self._Okay
        self.FormBorderStyle = FormBorderStyle.FixedDialog
        self.StartPosition = FormStartPosition.CenterParent
        self._gbSource.ResumeLayout(False)
        self._groupBox1.ResumeLayout(False)
        self._groupBox1.PerformLayout()
        self.ResumeLayout(False)
        self.PerformLayout()
        self.FormClosing += self.CheckClosing

    def SouceIndexChanged(self, sender, e):
        self._append.Enabled = True
        if sender.SelectedItem == "User Text":
            self._UserText.Enabled = True
            self._copy.Enabled = False
            self._move.Enabled = False

        else:
            self._UserText.Enabled = False
            self._copy.Enabled = True
            self._move.Enabled = True

            if sender.SelectedItem in ["Released Time", "Added Time"]:
                self._replace.Checked = True
                self._append.Enabled = False

    def CheckClosing(self, sender, e):
        if self.worker.IsBusy:
            self.worker.CancelAsync()
            e.Cancel = True

    def DestinationModeChanged(self, sender, e):
        self._seperator.Enabled = self._append.Checked

    def OkayClicked(self, sender, e):
        if self._Okay.Text == "Start":
            if self.worker.IsBusy == False:
                self.worker.RunWorkerAsync()

        else:
            self.DialogResult = DialogResult.OK

    def CancelClicked(self, sender, e):
        if self.worker.IsBusy:
            self.worker.CancelAsync()
        else:
            self.DialogResult = DialogResult.Cancel

    def DoWork(self, sender, e):
        if self._source.SelectedItem == "User Text":
            f, r = UserText(sender, self.books, self._UserText.Text,
                            self._destination.SelectedItem.replace(" ", ""),
                            self._append.Checked, self._seperator.Text)

        else:
            if self._move.Checked:
                f, r = MoveField(
                    sender, self.books,
                    self._source.SelectedItem.replace(" ", ""),
                    self._destination.SelectedItem.replace(" ", ""),
                    self._append.Checked, self._seperator.Text)
            else:
                f, r = CopyField(
                    sender, self.books,
                    self._source.SelectedItem.replace(" ", ""),
                    self._destination.SelectedItem.replace(" ", ""),
                    self._append.Checked, self._seperator.Text)

        e.Result = [f, r]

    def ReportProgress(self, sender, e):
        self.progresspercent = self.percentage * e.ProgressPercentage
        self._progress.Value = int(round(self.progresspercent))

    def WorkerCompleted(self, sender, e):
        self._Okay.Text = "Done"
        if e.Result[0] > 0:
            r = MessageBox.Show(
                "Failed: %s" % (e.Result[0]) +
                "\n\nWould you like to see a report of the failed operations?",
                "Report", MessageBoxButtons.YesNo)
            if r == DialogResult.Yes:
                f = ReportForm(e.Result[1])
                f.ShowDialog()
Ejemplo n.º 9
0
 def InitializeComponent(self):
     self._gbSource = System.Windows.Forms.GroupBox()
     self._source = System.Windows.Forms.ComboBox()
     self._copy = System.Windows.Forms.RadioButton()
     self._move = System.Windows.Forms.RadioButton()
     self._destination = System.Windows.Forms.ComboBox()
     self._groupBox1 = System.Windows.Forms.GroupBox()
     self._label1 = System.Windows.Forms.Label()
     self._append = System.Windows.Forms.RadioButton()
     self._replace = System.Windows.Forms.RadioButton()
     self._seperator = System.Windows.Forms.TextBox()
     self._label2 = System.Windows.Forms.Label()
     self._label3 = System.Windows.Forms.Label()
     self._progress = System.Windows.Forms.ProgressBar()
     self._Okay = System.Windows.Forms.Button()
     self._Cancel = System.Windows.Forms.Button()
     self._UserText = System.Windows.Forms.TextBox()
     self._gbSource.SuspendLayout()
     self._groupBox1.SuspendLayout()
     self.worker = BackgroundWorker()
     self.SuspendLayout()
     #
     # Worker
     #
     self.worker.WorkerSupportsCancellation = True
     self.worker.WorkerReportsProgress = True
     self.worker.DoWork += self.DoWork
     self.worker.ProgressChanged += self.ReportProgress
     self.worker.RunWorkerCompleted += self.WorkerCompleted
     #
     # gbSource
     #
     self._gbSource.Controls.Add(self._move)
     self._gbSource.Controls.Add(self._copy)
     self._gbSource.Controls.Add(self._source)
     self._gbSource.Controls.Add(self._UserText)
     self._gbSource.Controls.Add(self._label3)
     self._gbSource.Location = System.Drawing.Point(12, 11)
     self._gbSource.Name = "gbSource"
     self._gbSource.Size = System.Drawing.Size(202, 97)
     self._gbSource.TabIndex = 0
     self._gbSource.TabStop = False
     self._gbSource.Text = "Source"
     #
     # source
     #
     self._source.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
     self._source.FormattingEnabled = True
     self._source.Location = System.Drawing.Point(6, 19)
     self._source.Name = "source"
     self._source.Size = System.Drawing.Size(187, 21)
     self._source.TabIndex = 0
     self._source.Items.AddRange(System.Array[System.String]([
         "Added Time", "Age Rating", "Alternate Count", "Alternate Number",
         "Alternate Series", "Book Age", "Book Collection Status",
         "Book Condition", "Book Location", "Book Notes", "Book Owner",
         "Book Price", "Book Store", "Characters", "Colorist", "Count",
         "Cover Artist", "Editor", "Format", "Genre", "Imprint", "Inker",
         "ISBN", "Letterer", "Locations", "Main Character Or Team", "Month",
         "Notes", "Number", "Penciller", "Published", "Publisher", "Review",
         "Scan Information", "Released Time", "Series", "Series Group",
         "Story Arc", "Summary", "Tags", "Teams", "Title", "User Text",
         "Volume", "Web", "Writer", "Year"
     ]))
     self._source.SelectedIndex = 0
     self._source.SelectedIndexChanged += self.SouceIndexChanged
     #
     # copy
     #
     self._copy.Location = System.Drawing.Point(18, 42)
     self._copy.Name = "copy"
     self._copy.Size = System.Drawing.Size(55, 24)
     self._copy.TabIndex = 1
     self._copy.TabStop = True
     self._copy.Text = "Copy"
     self._copy.UseVisualStyleBackColor = True
     self._copy.Checked = True
     #
     # move
     #
     self._move.Location = System.Drawing.Point(125, 42)
     self._move.Name = "move"
     self._move.Size = System.Drawing.Size(60, 24)
     self._move.TabIndex = 2
     self._move.TabStop = True
     self._move.Text = "Move"
     self._move.UseVisualStyleBackColor = True
     #
     # User Text
     #
     self._label3.AutoSize = True
     self._label3.Location = System.Drawing.Point(2, 72)
     self._label3.Text = "User Text:"
     #
     # User Text
     #
     self._UserText.Size = Size(135, 20)
     self._UserText.Location = Point(60, 69)
     self._UserText.Enabled = False
     #
     # destination
     #
     self._destination.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
     self._destination.FormattingEnabled = True
     self._destination.Location = System.Drawing.Point(6, 19)
     self._destination.Name = "destination"
     self._destination.Size = System.Drawing.Size(190, 21)
     self._destination.TabIndex = 1
     self._destination.Items.AddRange(System.Array[System.String]([
         "Added Time", "Age Rating", "Alternate Count", "Alternate Number",
         "Alternate Series", "Book Age", "Book Collection Status",
         "Book Condition", "Book Location", "Book Notes", "Book Owner",
         "Book Price", "Book Store", "Characters", "Colorist", "Count",
         "Cover Artist", "Editor", "Format", "Genre", "Imprint", "Inker",
         "ISBN", "Letterer", "Locations", "Main Character Or Team", "Month",
         "Notes", "Number", "Penciller", "Published", "Publisher", "Review",
         "Scan Information", "Released Time", "Series", "Series Group",
         "Story Arc", "Summary", "Tags", "Teams", "Title", "Volume", "Web",
         "Writer", "Year"
     ]))
     self._destination.SelectedIndex = 0
     #
     # groupBox1
     #
     self._groupBox1.Controls.Add(self._label2)
     self._groupBox1.Controls.Add(self._seperator)
     self._groupBox1.Controls.Add(self._replace)
     self._groupBox1.Controls.Add(self._append)
     self._groupBox1.Controls.Add(self._destination)
     self._groupBox1.Location = System.Drawing.Point(266, 11)
     self._groupBox1.Name = "groupBox1"
     self._groupBox1.Size = System.Drawing.Size(202, 97)
     self._groupBox1.TabIndex = 2
     self._groupBox1.TabStop = False
     self._groupBox1.Text = "Destination"
     #
     # label1
     #
     self._label1.AutoSize = True
     self._label1.Location = System.Drawing.Point(232, 53)
     self._label1.Name = "label1"
     self._label1.Size = System.Drawing.Size(16, 13)
     self._label1.TabIndex = 3
     self._label1.Text = "to"
     #
     # append
     #
     self._append.AutoSize = True
     self._append.Location = System.Drawing.Point(126, 46)
     self._append.Name = "append"
     self._append.Size = System.Drawing.Size(62, 17)
     self._append.TabIndex = 2
     self._append.TabStop = True
     self._append.Text = "Append"
     self._append.UseVisualStyleBackColor = True
     self._append.CheckedChanged += self.DestinationModeChanged
     #
     # replace
     #
     self._replace.AutoSize = True
     self._replace.Location = System.Drawing.Point(14, 46)
     self._replace.Name = "replace"
     self._replace.Size = System.Drawing.Size(65, 17)
     self._replace.TabIndex = 3
     self._replace.TabStop = True
     self._replace.Text = "Replace"
     self._replace.UseVisualStyleBackColor = True
     self._replace.Checked = True
     #
     # seperator
     #
     self._seperator.Location = System.Drawing.Point(154, 69)
     self._seperator.Name = "seperator"
     self._seperator.Size = System.Drawing.Size(42, 20)
     self._seperator.TabIndex = 4
     self._seperator.Enabled = False
     #
     # label2
     #
     self._label2.AutoSize = True
     self._label2.Location = System.Drawing.Point(92, 72)
     self._label2.Name = "label2"
     self._label2.Size = System.Drawing.Size(56, 13)
     self._label2.TabIndex = 5
     self._label2.Text = "Seperator:"
     #
     # progressBar1
     #
     self._progress.Location = System.Drawing.Point(12, 114)
     self._progress.Size = System.Drawing.Size(456, 17)
     self._progress.TabIndex = 4
     #
     # Okay
     #
     self._Okay.Location = System.Drawing.Point(312, 137)
     self._Okay.Name = "Okay"
     self._Okay.Size = System.Drawing.Size(75, 23)
     self._Okay.TabIndex = 5
     self._Okay.Text = "Start"
     self._Okay.UseVisualStyleBackColor = True
     self._Okay.Click += self.OkayClicked
     #
     # Cancel
     #
     self._Cancel.Location = System.Drawing.Point(393, 137)
     self._Cancel.Name = "Cancel"
     self._Cancel.Size = System.Drawing.Size(75, 23)
     self._Cancel.TabIndex = 6
     self._Cancel.Text = "Cancel"
     self._Cancel.UseVisualStyleBackColor = True
     self._Cancel.Click += self.CancelClicked
     #
     # CopyFieldsForm
     #
     self.ClientSize = System.Drawing.Size(483, 170)
     self.Controls.Add(self._Cancel)
     self.Controls.Add(self._Okay)
     self.Controls.Add(self._progress)
     self.Controls.Add(self._label1)
     self.Controls.Add(self._groupBox1)
     self.Controls.Add(self._gbSource)
     self.Name = "CopyFieldsForm"
     self.Text = "Copy/Move Field"
     self.MinimizeBox = False
     self.MaximizeBox = False
     self.ShowIcon = True
     self.Icon = Icon(ICON)
     self.AcceptButton = self._Okay
     self.FormBorderStyle = FormBorderStyle.FixedDialog
     self.StartPosition = FormStartPosition.CenterParent
     self._gbSource.ResumeLayout(False)
     self._groupBox1.ResumeLayout(False)
     self._groupBox1.PerformLayout()
     self.ResumeLayout(False)
     self.PerformLayout()
     self.FormClosing += self.CheckClosing
Ejemplo n.º 10
0
 def InitializeComponent(self):
     self._wizard = CristiPotlog.Controls.Wizard()
     self._wpURL = CristiPotlog.Controls.WizardPage()
     self._label1 = System.Windows.Forms.Label()
     self._firstPageUrl = System.Windows.Forms.TextBox()
     self._wpInfo = CristiPotlog.Controls.WizardPage()
     self._webcomic_name = System.Windows.Forms.TextBox()
     self._label3 = System.Windows.Forms.Label()
     self._label4 = System.Windows.Forms.Label()
     self._Writer = System.Windows.Forms.TextBox()
     self._label6 = System.Windows.Forms.Label()
     self._Penciler = System.Windows.Forms.TextBox()
     self._label7 = System.Windows.Forms.Label()
     self._Summary = System.Windows.Forms.TextBox()
     self._label8 = System.Windows.Forms.Label()
     self._label9 = System.Windows.Forms.Label()
     self._Inker = System.Windows.Forms.TextBox()
     self._Colorist = System.Windows.Forms.TextBox()
     self._label11 = System.Windows.Forms.Label()
     self._Manga = System.Windows.Forms.ComboBox()
     self._label10 = System.Windows.Forms.Label()
     self._BlackAndWhite = System.Windows.Forms.ComboBox()
     self._save_file_dialog = System.Windows.Forms.SaveFileDialog()
     self._wpFinished = CristiPotlog.Controls.WizardPage()
     self._label13 = System.Windows.Forms.Label()
     self._label18 = System.Windows.Forms.Label()
     self._imageUrl = System.Windows.Forms.TextBox()
     self._linkUrl = System.Windows.Forms.TextBox()
     self._wpFailedImage = CristiPotlog.Controls.WizardPage()
     self._wpFaliedLink = CristiPotlog.Controls.WizardPage()
     self._wpProgress = CristiPotlog.Controls.WizardPage()
     self._ProgressBar = System.Windows.Forms.ProgressBar()
     self._ProgressText = System.Windows.Forms.Label()
     self._label2 = System.Windows.Forms.Label()
     self._label5 = System.Windows.Forms.Label()
     self._label14 = System.Windows.Forms.Label()
     self._label15 = System.Windows.Forms.Label()
     self._label16 = System.Windows.Forms.Label()
     self._label17 = System.Windows.Forms.Label()
     self._label19 = System.Windows.Forms.Label()
     self._background_worker = BackgroundWorker()
     self._open_webcomic = System.Windows.Forms.CheckBox()
     self._wizard.SuspendLayout()
     self._wpURL.SuspendLayout()
     self._wpInfo.SuspendLayout()
     self._wpFailedImage.SuspendLayout()
     self._wpFaliedLink.SuspendLayout()
     self._wpProgress.SuspendLayout()
     self.SuspendLayout()
     #
     # wizard
     #
     self._wizard.Controls.Add(self._wpFaliedLink)
     self._wizard.Controls.Add(self._wpFailedImage)
     self._wizard.Controls.Add(self._wpFinished)
     self._wizard.Controls.Add(self._wpInfo)
     self._wizard.Controls.Add(self._wpProgress)
     self._wizard.Controls.Add(self._wpURL)
     self._wizard.Location = System.Drawing.Point(0, 0)
     self._wizard.HeaderImage = Image.FromFile(HEADER_IMAGE)
     self._wizard.Pages.AddRange(
         System.Array[CristiPotlog.Controls.WizardPage]([
             self._wpURL, self._wpProgress, self._wpInfo, self._wpFinished,
             self._wpFailedImage, self._wpFaliedLink
         ]))
     self._wizard.Size = System.Drawing.Size(531, 414)
     self._wizard.TabIndex = 0
     self._wizard.BeforeSwitchPages += self.before_switch_page
     self._wizard.AfterSwitchPages += self.after_switch_page
     self._wizard.Cancel += self.wizard_cancel
     #
     # wpURL
     #
     self._wpURL.Controls.Add(self._linkUrl)
     self._wpURL.Controls.Add(self._imageUrl)
     self._wpURL.Controls.Add(self._firstPageUrl)
     self._wpURL.Controls.Add(self._label19)
     self._wpURL.Controls.Add(self._label17)
     self._wpURL.Controls.Add(self._label16)
     self._wpURL.Controls.Add(self._label18)
     self._wpURL.Controls.Add(self._label13)
     self._wpURL.Controls.Add(self._label1)
     self._wpURL.Description = "Enter the URLs of the first webcomic page, the image on that page and the URL of the second page"
     self._wpURL.Location = System.Drawing.Point(0, 0)
     self._wpURL.Name = "wpURL"
     self._wpURL.Size = System.Drawing.Size(531, 366)
     self._wpURL.TabIndex = 10
     self._wpURL.Title = "First Page URLs"
     #
     # label1
     #
     self._label1.AutoSize = True
     self._label1.Location = System.Drawing.Point(12, 88)
     self._label1.Name = "label1"
     self._label1.Size = System.Drawing.Size(82, 13)
     self._label1.TabIndex = 0
     self._label1.Text = "First Page URL:"
     #
     # firstPageUrl
     #
     self._firstPageUrl.Location = System.Drawing.Point(111, 85)
     self._firstPageUrl.Name = "firstPageUrl"
     self._firstPageUrl.Size = System.Drawing.Size(408, 20)
     self._firstPageUrl.TabIndex = 1
     #
     # wpInfo
     #
     self._wpInfo.Controls.Add(self._BlackAndWhite)
     self._wpInfo.Controls.Add(self._label10)
     self._wpInfo.Controls.Add(self._Manga)
     self._wpInfo.Controls.Add(self._label11)
     self._wpInfo.Controls.Add(self._Colorist)
     self._wpInfo.Controls.Add(self._Inker)
     self._wpInfo.Controls.Add(self._label9)
     self._wpInfo.Controls.Add(self._label8)
     self._wpInfo.Controls.Add(self._Summary)
     self._wpInfo.Controls.Add(self._label7)
     self._wpInfo.Controls.Add(self._Penciler)
     self._wpInfo.Controls.Add(self._label6)
     self._wpInfo.Controls.Add(self._Writer)
     self._wpInfo.Controls.Add(self._label4)
     self._wpInfo.Controls.Add(self._label3)
     self._wpInfo.Controls.Add(self._webcomic_name)
     self._wpInfo.Description = "Enter any desired information"
     self._wpInfo.Location = System.Drawing.Point(0, 0)
     self._wpInfo.Name = "wpInfo"
     self._wpInfo.Size = System.Drawing.Size(531, 366)
     self._wpInfo.TabIndex = 13
     self._wpInfo.Title = "Comic Information"
     #
     # SeriesName
     #
     self._webcomic_name.Location = System.Drawing.Point(110, 80)
     self._webcomic_name.Size = System.Drawing.Size(408, 20)
     self._webcomic_name.TabIndex = 0
     #
     # label3
     #
     self._label3.AutoSize = True
     self._label3.Location = System.Drawing.Point(12, 83)
     self._label3.Name = "label3"
     self._label3.Size = System.Drawing.Size(92, 13)
     self._label3.Text = "Webcomic Name:"
     #
     # label4
     #
     self._label4.AutoSize = True
     self._label4.Location = System.Drawing.Point(12, 147)
     self._label4.Name = "label4"
     self._label4.Size = System.Drawing.Size(38, 13)
     self._label4.Text = "Writer:"
     #
     # Writer
     #
     self._Writer.Location = System.Drawing.Point(56, 143)
     self._Writer.Name = "Writer"
     self._Writer.Size = System.Drawing.Size(140, 20)
     self._Writer.TabIndex = 1
     self._Writer.Tag = "Writer"
     #
     # label6
     #
     self._label6.AutoSize = True
     self._label6.Location = System.Drawing.Point(258, 175)
     self._label6.Name = "label6"
     self._label6.Size = System.Drawing.Size(44, 13)
     self._label6.Text = "Colorist:"
     #
     # Penciler
     #
     self._Penciler.Location = System.Drawing.Point(312, 143)
     self._Penciler.Name = "Penciler"
     self._Penciler.Size = System.Drawing.Size(139, 20)
     self._Penciler.TabIndex = 2
     self._Penciler.Tag = "Penciller"
     #
     # label7
     #
     self._label7.AutoSize = True
     self._label7.Location = System.Drawing.Point(12, 256)
     self._label7.Name = "label7"
     self._label7.Size = System.Drawing.Size(53, 13)
     self._label7.Text = "Summary:"
     #
     # Summary
     #
     self._Summary.Location = System.Drawing.Point(12, 272)
     self._Summary.Multiline = True
     self._Summary.Name = "Summary"
     self._Summary.Size = System.Drawing.Size(506, 82)
     self._Summary.TabIndex = 7
     self._Summary.Tag = "Summary"
     #
     # label8
     #
     self._label8.AutoSize = True
     self._label8.Location = System.Drawing.Point(258, 146)
     self._label8.Name = "label8"
     self._label8.Size = System.Drawing.Size(48, 13)
     self._label8.Text = "Penciller:"
     #
     # label9
     #
     self._label9.AutoSize = True
     self._label9.Location = System.Drawing.Point(12, 175)
     self._label9.Name = "label9"
     self._label9.Size = System.Drawing.Size(34, 13)
     self._label9.Text = "Inker:"
     #
     # Inker
     #
     self._Inker.Location = System.Drawing.Point(57, 171)
     self._Inker.Name = "Inker"
     self._Inker.Size = System.Drawing.Size(139, 20)
     self._Inker.TabIndex = 3
     self._Inker.Tag = "Inker"
     #
     # Colorist
     #
     self._Colorist.Location = System.Drawing.Point(312, 171)
     self._Colorist.Name = "Colorist"
     self._Colorist.Size = System.Drawing.Size(139, 20)
     self._Colorist.TabIndex = 4
     self._Colorist.Tag = "Colorist"
     #
     # label11
     #
     self._label11.AutoSize = True
     self._label11.Location = System.Drawing.Point(12, 219)
     self._label11.Name = "label11"
     self._label11.Size = System.Drawing.Size(43, 13)
     self._label11.Text = "Manga:"
     #
     # Manga
     #
     self._Manga.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
     self._Manga.FormattingEnabled = True
     self._Manga.Items.AddRange(System.Array[System.Object](
         ["", "No", "Yes", "Yes (Right to Left)"]))
     self._Manga.Location = System.Drawing.Point(57, 215)
     self._Manga.Name = "Manga"
     self._Manga.Size = System.Drawing.Size(99, 21)
     self._Manga.TabIndex = 5
     self._Manga.Tag = "Manga"
     #
     # label10
     #
     self._label10.AutoSize = True
     self._label10.Location = System.Drawing.Point(180, 219)
     self._label10.Name = "label10"
     self._label10.Size = System.Drawing.Size(77, 13)
     self._label10.Text = "Black & White:"
     self._label10.UseMnemonic = False
     #
     # BlackAndWhite
     #
     self._BlackAndWhite.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
     self._BlackAndWhite.FormattingEnabled = True
     self._BlackAndWhite.Items.AddRange(
         System.Array[System.Object](["", "No", "Yes"]))
     self._BlackAndWhite.Location = System.Drawing.Point(263, 215)
     self._BlackAndWhite.Name = "BlackAndWhite"
     self._BlackAndWhite.Size = System.Drawing.Size(80, 21)
     self._BlackAndWhite.TabIndex = 6
     self._BlackAndWhite.Tag = "BlackAndWhite"
     #
     # saveFileDialog
     #
     self._save_file_dialog.Filter = "ComicRack webcomic|*.cbw"
     #
     # wpFinished
     #
     self._wpFinished.Description = "The webcomic file has been created and added into ComicRack"
     self._wpFinished.Controls.Add(self._open_webcomic)
     self._wpFinished.Location = System.Drawing.Point(0, 0)
     self._wpFinished.Name = "wpFinished"
     self._wpFinished.Size = System.Drawing.Size(531, 366)
     self._wpFinished.Style = CristiPotlog.Controls.WizardPageStyle.Finish
     self._wpFinished.TabIndex = 15
     self._wpFinished.Title = "Success"
     #
     # open_webcomic checkbox
     #
     self._open_webcomic.Location = System.Drawing.Point(174, 96)
     self._open_webcomic.Size = System.Drawing.Size(239, 22)
     self._open_webcomic.Text = "Open WebComic in ComicRack"
     self._open_webcomic.TabIndex = 0
     self._open_webcomic.BackColor = System.Drawing.SystemColors.ControlLightLight
     self._open_webcomic.Checked = False
     #
     # label13
     #
     self._label13.Location = System.Drawing.Point(13, 172)
     self._label13.Name = "label13"
     self._label13.Size = System.Drawing.Size(69, 23)
     self._label13.TabIndex = 4
     self._label13.Text = "Image URL:"
     #
     # label18
     #
     self._label18.Location = System.Drawing.Point(13, 265)
     self._label18.Name = "label18"
     self._label18.Size = System.Drawing.Size(116, 23)
     self._label18.TabIndex = 5
     self._label18.Text = "Second Page URL:"
     #
     # imageUrl
     #
     self._imageUrl.Location = System.Drawing.Point(111, 169)
     self._imageUrl.Name = "imageUrl"
     self._imageUrl.Size = System.Drawing.Size(408, 20)
     self._imageUrl.TabIndex = 6
     #
     # linkUrl
     #
     self._linkUrl.Location = System.Drawing.Point(111, 262)
     self._linkUrl.Name = "linkUrl"
     self._linkUrl.Size = System.Drawing.Size(408, 20)
     self._linkUrl.TabIndex = 7
     #
     # wpFailedImage
     #
     self._wpFailedImage.Controls.Add(self._label5)
     self._wpFailedImage.Controls.Add(self._label2)
     self._wpFailedImage.Description = "No available regular expression could match the image on the webcomic page."
     self._wpFailedImage.Location = System.Drawing.Point(0, 0)
     self._wpFailedImage.Name = "wpFailedImage"
     self._wpFailedImage.Size = System.Drawing.Size(531, 366)
     self._wpFailedImage.Style = CristiPotlog.Controls.WizardPageStyle.Finish
     self._wpFailedImage.TabIndex = 16
     self._wpFailedImage.Title = "Failed"
     #
     # wpFaliedLink
     #
     self._wpFaliedLink.Controls.Add(self._label14)
     self._wpFaliedLink.Controls.Add(self._label15)
     self._wpFaliedLink.Description = "No available regular expression could match the next page link on the webcomic page."
     self._wpFaliedLink.Location = System.Drawing.Point(0, 0)
     self._wpFaliedLink.Name = "wpFaliedLink"
     self._wpFaliedLink.Size = System.Drawing.Size(531, 366)
     self._wpFaliedLink.Style = CristiPotlog.Controls.WizardPageStyle.Finish
     self._wpFaliedLink.TabIndex = 17
     self._wpFaliedLink.Title = "Failed"
     #
     # wpProgress
     #
     self._wpProgress.Controls.Add(self._ProgressText)
     self._wpProgress.Controls.Add(self._ProgressBar)
     self._wpProgress.Location = System.Drawing.Point(0, 0)
     self._wpProgress.Name = "wpProgress"
     self._wpProgress.Size = System.Drawing.Size(531, 366)
     self._wpProgress.TabIndex = 18
     self._wpProgress.Title = "Working"
     #
     # ProgressBar
     #
     self._ProgressBar.Location = System.Drawing.Point(12, 172)
     self._ProgressBar.Name = "ProgressBar"
     self._ProgressBar.Size = System.Drawing.Size(507, 23)
     self._ProgressBar.TabIndex = 0
     self._ProgressBar.Maximum = 4
     #
     # ProgressText
     #
     self._ProgressText.Location = System.Drawing.Point(13, 202)
     self._ProgressText.Name = "ProgressText"
     self._ProgressText.Size = System.Drawing.Size(506, 44)
     self._ProgressText.TabIndex = 1
     self._ProgressText.Text = "Action"
     #
     # label2
     #
     self._label2.BackColor = System.Drawing.Color.Transparent
     self._label2.Location = System.Drawing.Point(170, 100)
     self._label2.Name = "label2"
     self._label2.Size = System.Drawing.Size(344, 33)
     self._label2.TabIndex = 0
     self._label2.Text = "Please notify the script authors by posting the name and url of the webcomic into the forum thread."
     #
     # label5
     #
     self._label5.BackColor = System.Drawing.Color.Transparent
     self._label5.Location = System.Drawing.Point(170, 174)
     self._label5.Size = System.Drawing.Size(344, 90)
     self._label5.TabIndex = 1
     self._label5.Text = "Press the restart button to restart with a different webcomic or press Finish to close the script."
     #
     # label14
     #
     self._label14.BackColor = System.Drawing.Color.Transparent
     self._label14.Location = System.Drawing.Point(170, 174)
     self._label14.Size = System.Drawing.Size(344, 90)
     self._label14.TabIndex = 3
     self._label14.Text = "Press the restart button to restart with a different webcomic or press Finish to close the script."
     #
     # label15
     #
     self._label15.BackColor = System.Drawing.Color.Transparent
     self._label15.Location = System.Drawing.Point(170, 100)
     self._label15.Size = System.Drawing.Size(344, 33)
     self._label15.TabIndex = 2
     self._label15.Text = "Please notify the script authors by posting the name and url of the webcomic into the forum thread."
     #
     # label16
     #
     self._label16.Location = System.Drawing.Point(13, 114)
     self._label16.Name = "label16"
     self._label16.Size = System.Drawing.Size(506, 37)
     self._label16.TabIndex = 8
     self._label16.Text = "Enter here the entire url of the very first page of the webcomic. For example:  http://www.giantitp.com/comics/oots0001.html"
     #
     # label17
     #
     self._label17.Location = System.Drawing.Point(13, 199)
     self._label17.Name = "label17"
     self._label17.Size = System.Drawing.Size(506, 36)
     self._label17.TabIndex = 9
     self._label17.Text = "Enter here the entire url of the comic image on the very first page of the webcomic. For example: http://www.giantitp.com/comics/images/oots0001.gif"
     #
     # label19
     #
     self._label19.Location = System.Drawing.Point(13, 292)
     self._label19.Name = "label19"
     self._label19.Size = System.Drawing.Size(506, 51)
     self._label19.TabIndex = 10
     self._label19.Text = "Enter here the  entire url of the second page of the webcomic. For example: http://www.giantitp.com/comics/oots0002.html"
     #
     # background_worker
     #
     self._background_worker.WorkerReportsProgress = True
     self._background_worker.WorkerSupportsCancellation = True
     self._background_worker.DoWork += webcomichelper.webcomic_helper_do_work
     self._background_worker.ProgressChanged += self.worker_progress_changed
     self._background_worker.RunWorkerCompleted += self.worker_completed
     #
     # MainForm
     #
     self.ClientSize = System.Drawing.Size(531, 414)
     self.Controls.Add(self._wizard)
     self.ShowIcon = False
     self.Text = "Webcomic Helper"
     self.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
     self.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
     self.MinimizeBox = False
     self.MaximizeBox = False
     self._wizard.ResumeLayout(False)
     self._wpURL.ResumeLayout(False)
     self._wpURL.PerformLayout()
     self._wpInfo.ResumeLayout(False)
     self._wpInfo.PerformLayout()
     self._wpFailedImage.ResumeLayout(False)
     self._wpFaliedLink.ResumeLayout(False)
     self._wpProgress.ResumeLayout(False)
     self.ResumeLayout(False)
Ejemplo n.º 11
0
class WebComicHelperWizard(Form):
    def __init__(self):
        self.InitializeComponent()

        self._info_textboxes = [
            self._Writer, self._Penciler, self._Inker, self._Colorist,
            self._Summary
        ]

    def InitializeComponent(self):
        self._wizard = CristiPotlog.Controls.Wizard()
        self._wpURL = CristiPotlog.Controls.WizardPage()
        self._label1 = System.Windows.Forms.Label()
        self._firstPageUrl = System.Windows.Forms.TextBox()
        self._wpInfo = CristiPotlog.Controls.WizardPage()
        self._webcomic_name = System.Windows.Forms.TextBox()
        self._label3 = System.Windows.Forms.Label()
        self._label4 = System.Windows.Forms.Label()
        self._Writer = System.Windows.Forms.TextBox()
        self._label6 = System.Windows.Forms.Label()
        self._Penciler = System.Windows.Forms.TextBox()
        self._label7 = System.Windows.Forms.Label()
        self._Summary = System.Windows.Forms.TextBox()
        self._label8 = System.Windows.Forms.Label()
        self._label9 = System.Windows.Forms.Label()
        self._Inker = System.Windows.Forms.TextBox()
        self._Colorist = System.Windows.Forms.TextBox()
        self._label11 = System.Windows.Forms.Label()
        self._Manga = System.Windows.Forms.ComboBox()
        self._label10 = System.Windows.Forms.Label()
        self._BlackAndWhite = System.Windows.Forms.ComboBox()
        self._save_file_dialog = System.Windows.Forms.SaveFileDialog()
        self._wpFinished = CristiPotlog.Controls.WizardPage()
        self._label13 = System.Windows.Forms.Label()
        self._label18 = System.Windows.Forms.Label()
        self._imageUrl = System.Windows.Forms.TextBox()
        self._linkUrl = System.Windows.Forms.TextBox()
        self._wpFailedImage = CristiPotlog.Controls.WizardPage()
        self._wpFaliedLink = CristiPotlog.Controls.WizardPage()
        self._wpProgress = CristiPotlog.Controls.WizardPage()
        self._ProgressBar = System.Windows.Forms.ProgressBar()
        self._ProgressText = System.Windows.Forms.Label()
        self._label2 = System.Windows.Forms.Label()
        self._label5 = System.Windows.Forms.Label()
        self._label14 = System.Windows.Forms.Label()
        self._label15 = System.Windows.Forms.Label()
        self._label16 = System.Windows.Forms.Label()
        self._label17 = System.Windows.Forms.Label()
        self._label19 = System.Windows.Forms.Label()
        self._background_worker = BackgroundWorker()
        self._open_webcomic = System.Windows.Forms.CheckBox()
        self._wizard.SuspendLayout()
        self._wpURL.SuspendLayout()
        self._wpInfo.SuspendLayout()
        self._wpFailedImage.SuspendLayout()
        self._wpFaliedLink.SuspendLayout()
        self._wpProgress.SuspendLayout()
        self.SuspendLayout()
        #
        # wizard
        #
        self._wizard.Controls.Add(self._wpFaliedLink)
        self._wizard.Controls.Add(self._wpFailedImage)
        self._wizard.Controls.Add(self._wpFinished)
        self._wizard.Controls.Add(self._wpInfo)
        self._wizard.Controls.Add(self._wpProgress)
        self._wizard.Controls.Add(self._wpURL)
        self._wizard.Location = System.Drawing.Point(0, 0)
        self._wizard.HeaderImage = Image.FromFile(HEADER_IMAGE)
        self._wizard.Pages.AddRange(
            System.Array[CristiPotlog.Controls.WizardPage]([
                self._wpURL, self._wpProgress, self._wpInfo, self._wpFinished,
                self._wpFailedImage, self._wpFaliedLink
            ]))
        self._wizard.Size = System.Drawing.Size(531, 414)
        self._wizard.TabIndex = 0
        self._wizard.BeforeSwitchPages += self.before_switch_page
        self._wizard.AfterSwitchPages += self.after_switch_page
        self._wizard.Cancel += self.wizard_cancel
        #
        # wpURL
        #
        self._wpURL.Controls.Add(self._linkUrl)
        self._wpURL.Controls.Add(self._imageUrl)
        self._wpURL.Controls.Add(self._firstPageUrl)
        self._wpURL.Controls.Add(self._label19)
        self._wpURL.Controls.Add(self._label17)
        self._wpURL.Controls.Add(self._label16)
        self._wpURL.Controls.Add(self._label18)
        self._wpURL.Controls.Add(self._label13)
        self._wpURL.Controls.Add(self._label1)
        self._wpURL.Description = "Enter the URLs of the first webcomic page, the image on that page and the URL of the second page"
        self._wpURL.Location = System.Drawing.Point(0, 0)
        self._wpURL.Name = "wpURL"
        self._wpURL.Size = System.Drawing.Size(531, 366)
        self._wpURL.TabIndex = 10
        self._wpURL.Title = "First Page URLs"
        #
        # label1
        #
        self._label1.AutoSize = True
        self._label1.Location = System.Drawing.Point(12, 88)
        self._label1.Name = "label1"
        self._label1.Size = System.Drawing.Size(82, 13)
        self._label1.TabIndex = 0
        self._label1.Text = "First Page URL:"
        #
        # firstPageUrl
        #
        self._firstPageUrl.Location = System.Drawing.Point(111, 85)
        self._firstPageUrl.Name = "firstPageUrl"
        self._firstPageUrl.Size = System.Drawing.Size(408, 20)
        self._firstPageUrl.TabIndex = 1
        #
        # wpInfo
        #
        self._wpInfo.Controls.Add(self._BlackAndWhite)
        self._wpInfo.Controls.Add(self._label10)
        self._wpInfo.Controls.Add(self._Manga)
        self._wpInfo.Controls.Add(self._label11)
        self._wpInfo.Controls.Add(self._Colorist)
        self._wpInfo.Controls.Add(self._Inker)
        self._wpInfo.Controls.Add(self._label9)
        self._wpInfo.Controls.Add(self._label8)
        self._wpInfo.Controls.Add(self._Summary)
        self._wpInfo.Controls.Add(self._label7)
        self._wpInfo.Controls.Add(self._Penciler)
        self._wpInfo.Controls.Add(self._label6)
        self._wpInfo.Controls.Add(self._Writer)
        self._wpInfo.Controls.Add(self._label4)
        self._wpInfo.Controls.Add(self._label3)
        self._wpInfo.Controls.Add(self._webcomic_name)
        self._wpInfo.Description = "Enter any desired information"
        self._wpInfo.Location = System.Drawing.Point(0, 0)
        self._wpInfo.Name = "wpInfo"
        self._wpInfo.Size = System.Drawing.Size(531, 366)
        self._wpInfo.TabIndex = 13
        self._wpInfo.Title = "Comic Information"
        #
        # SeriesName
        #
        self._webcomic_name.Location = System.Drawing.Point(110, 80)
        self._webcomic_name.Size = System.Drawing.Size(408, 20)
        self._webcomic_name.TabIndex = 0
        #
        # label3
        #
        self._label3.AutoSize = True
        self._label3.Location = System.Drawing.Point(12, 83)
        self._label3.Name = "label3"
        self._label3.Size = System.Drawing.Size(92, 13)
        self._label3.Text = "Webcomic Name:"
        #
        # label4
        #
        self._label4.AutoSize = True
        self._label4.Location = System.Drawing.Point(12, 147)
        self._label4.Name = "label4"
        self._label4.Size = System.Drawing.Size(38, 13)
        self._label4.Text = "Writer:"
        #
        # Writer
        #
        self._Writer.Location = System.Drawing.Point(56, 143)
        self._Writer.Name = "Writer"
        self._Writer.Size = System.Drawing.Size(140, 20)
        self._Writer.TabIndex = 1
        self._Writer.Tag = "Writer"
        #
        # label6
        #
        self._label6.AutoSize = True
        self._label6.Location = System.Drawing.Point(258, 175)
        self._label6.Name = "label6"
        self._label6.Size = System.Drawing.Size(44, 13)
        self._label6.Text = "Colorist:"
        #
        # Penciler
        #
        self._Penciler.Location = System.Drawing.Point(312, 143)
        self._Penciler.Name = "Penciler"
        self._Penciler.Size = System.Drawing.Size(139, 20)
        self._Penciler.TabIndex = 2
        self._Penciler.Tag = "Penciller"
        #
        # label7
        #
        self._label7.AutoSize = True
        self._label7.Location = System.Drawing.Point(12, 256)
        self._label7.Name = "label7"
        self._label7.Size = System.Drawing.Size(53, 13)
        self._label7.Text = "Summary:"
        #
        # Summary
        #
        self._Summary.Location = System.Drawing.Point(12, 272)
        self._Summary.Multiline = True
        self._Summary.Name = "Summary"
        self._Summary.Size = System.Drawing.Size(506, 82)
        self._Summary.TabIndex = 7
        self._Summary.Tag = "Summary"
        #
        # label8
        #
        self._label8.AutoSize = True
        self._label8.Location = System.Drawing.Point(258, 146)
        self._label8.Name = "label8"
        self._label8.Size = System.Drawing.Size(48, 13)
        self._label8.Text = "Penciller:"
        #
        # label9
        #
        self._label9.AutoSize = True
        self._label9.Location = System.Drawing.Point(12, 175)
        self._label9.Name = "label9"
        self._label9.Size = System.Drawing.Size(34, 13)
        self._label9.Text = "Inker:"
        #
        # Inker
        #
        self._Inker.Location = System.Drawing.Point(57, 171)
        self._Inker.Name = "Inker"
        self._Inker.Size = System.Drawing.Size(139, 20)
        self._Inker.TabIndex = 3
        self._Inker.Tag = "Inker"
        #
        # Colorist
        #
        self._Colorist.Location = System.Drawing.Point(312, 171)
        self._Colorist.Name = "Colorist"
        self._Colorist.Size = System.Drawing.Size(139, 20)
        self._Colorist.TabIndex = 4
        self._Colorist.Tag = "Colorist"
        #
        # label11
        #
        self._label11.AutoSize = True
        self._label11.Location = System.Drawing.Point(12, 219)
        self._label11.Name = "label11"
        self._label11.Size = System.Drawing.Size(43, 13)
        self._label11.Text = "Manga:"
        #
        # Manga
        #
        self._Manga.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        self._Manga.FormattingEnabled = True
        self._Manga.Items.AddRange(System.Array[System.Object](
            ["", "No", "Yes", "Yes (Right to Left)"]))
        self._Manga.Location = System.Drawing.Point(57, 215)
        self._Manga.Name = "Manga"
        self._Manga.Size = System.Drawing.Size(99, 21)
        self._Manga.TabIndex = 5
        self._Manga.Tag = "Manga"
        #
        # label10
        #
        self._label10.AutoSize = True
        self._label10.Location = System.Drawing.Point(180, 219)
        self._label10.Name = "label10"
        self._label10.Size = System.Drawing.Size(77, 13)
        self._label10.Text = "Black & White:"
        self._label10.UseMnemonic = False
        #
        # BlackAndWhite
        #
        self._BlackAndWhite.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        self._BlackAndWhite.FormattingEnabled = True
        self._BlackAndWhite.Items.AddRange(
            System.Array[System.Object](["", "No", "Yes"]))
        self._BlackAndWhite.Location = System.Drawing.Point(263, 215)
        self._BlackAndWhite.Name = "BlackAndWhite"
        self._BlackAndWhite.Size = System.Drawing.Size(80, 21)
        self._BlackAndWhite.TabIndex = 6
        self._BlackAndWhite.Tag = "BlackAndWhite"
        #
        # saveFileDialog
        #
        self._save_file_dialog.Filter = "ComicRack webcomic|*.cbw"
        #
        # wpFinished
        #
        self._wpFinished.Description = "The webcomic file has been created and added into ComicRack"
        self._wpFinished.Controls.Add(self._open_webcomic)
        self._wpFinished.Location = System.Drawing.Point(0, 0)
        self._wpFinished.Name = "wpFinished"
        self._wpFinished.Size = System.Drawing.Size(531, 366)
        self._wpFinished.Style = CristiPotlog.Controls.WizardPageStyle.Finish
        self._wpFinished.TabIndex = 15
        self._wpFinished.Title = "Success"
        #
        # open_webcomic checkbox
        #
        self._open_webcomic.Location = System.Drawing.Point(174, 96)
        self._open_webcomic.Size = System.Drawing.Size(239, 22)
        self._open_webcomic.Text = "Open WebComic in ComicRack"
        self._open_webcomic.TabIndex = 0
        self._open_webcomic.BackColor = System.Drawing.SystemColors.ControlLightLight
        self._open_webcomic.Checked = False
        #
        # label13
        #
        self._label13.Location = System.Drawing.Point(13, 172)
        self._label13.Name = "label13"
        self._label13.Size = System.Drawing.Size(69, 23)
        self._label13.TabIndex = 4
        self._label13.Text = "Image URL:"
        #
        # label18
        #
        self._label18.Location = System.Drawing.Point(13, 265)
        self._label18.Name = "label18"
        self._label18.Size = System.Drawing.Size(116, 23)
        self._label18.TabIndex = 5
        self._label18.Text = "Second Page URL:"
        #
        # imageUrl
        #
        self._imageUrl.Location = System.Drawing.Point(111, 169)
        self._imageUrl.Name = "imageUrl"
        self._imageUrl.Size = System.Drawing.Size(408, 20)
        self._imageUrl.TabIndex = 6
        #
        # linkUrl
        #
        self._linkUrl.Location = System.Drawing.Point(111, 262)
        self._linkUrl.Name = "linkUrl"
        self._linkUrl.Size = System.Drawing.Size(408, 20)
        self._linkUrl.TabIndex = 7
        #
        # wpFailedImage
        #
        self._wpFailedImage.Controls.Add(self._label5)
        self._wpFailedImage.Controls.Add(self._label2)
        self._wpFailedImage.Description = "No available regular expression could match the image on the webcomic page."
        self._wpFailedImage.Location = System.Drawing.Point(0, 0)
        self._wpFailedImage.Name = "wpFailedImage"
        self._wpFailedImage.Size = System.Drawing.Size(531, 366)
        self._wpFailedImage.Style = CristiPotlog.Controls.WizardPageStyle.Finish
        self._wpFailedImage.TabIndex = 16
        self._wpFailedImage.Title = "Failed"
        #
        # wpFaliedLink
        #
        self._wpFaliedLink.Controls.Add(self._label14)
        self._wpFaliedLink.Controls.Add(self._label15)
        self._wpFaliedLink.Description = "No available regular expression could match the next page link on the webcomic page."
        self._wpFaliedLink.Location = System.Drawing.Point(0, 0)
        self._wpFaliedLink.Name = "wpFaliedLink"
        self._wpFaliedLink.Size = System.Drawing.Size(531, 366)
        self._wpFaliedLink.Style = CristiPotlog.Controls.WizardPageStyle.Finish
        self._wpFaliedLink.TabIndex = 17
        self._wpFaliedLink.Title = "Failed"
        #
        # wpProgress
        #
        self._wpProgress.Controls.Add(self._ProgressText)
        self._wpProgress.Controls.Add(self._ProgressBar)
        self._wpProgress.Location = System.Drawing.Point(0, 0)
        self._wpProgress.Name = "wpProgress"
        self._wpProgress.Size = System.Drawing.Size(531, 366)
        self._wpProgress.TabIndex = 18
        self._wpProgress.Title = "Working"
        #
        # ProgressBar
        #
        self._ProgressBar.Location = System.Drawing.Point(12, 172)
        self._ProgressBar.Name = "ProgressBar"
        self._ProgressBar.Size = System.Drawing.Size(507, 23)
        self._ProgressBar.TabIndex = 0
        self._ProgressBar.Maximum = 4
        #
        # ProgressText
        #
        self._ProgressText.Location = System.Drawing.Point(13, 202)
        self._ProgressText.Name = "ProgressText"
        self._ProgressText.Size = System.Drawing.Size(506, 44)
        self._ProgressText.TabIndex = 1
        self._ProgressText.Text = "Action"
        #
        # label2
        #
        self._label2.BackColor = System.Drawing.Color.Transparent
        self._label2.Location = System.Drawing.Point(170, 100)
        self._label2.Name = "label2"
        self._label2.Size = System.Drawing.Size(344, 33)
        self._label2.TabIndex = 0
        self._label2.Text = "Please notify the script authors by posting the name and url of the webcomic into the forum thread."
        #
        # label5
        #
        self._label5.BackColor = System.Drawing.Color.Transparent
        self._label5.Location = System.Drawing.Point(170, 174)
        self._label5.Size = System.Drawing.Size(344, 90)
        self._label5.TabIndex = 1
        self._label5.Text = "Press the restart button to restart with a different webcomic or press Finish to close the script."
        #
        # label14
        #
        self._label14.BackColor = System.Drawing.Color.Transparent
        self._label14.Location = System.Drawing.Point(170, 174)
        self._label14.Size = System.Drawing.Size(344, 90)
        self._label14.TabIndex = 3
        self._label14.Text = "Press the restart button to restart with a different webcomic or press Finish to close the script."
        #
        # label15
        #
        self._label15.BackColor = System.Drawing.Color.Transparent
        self._label15.Location = System.Drawing.Point(170, 100)
        self._label15.Size = System.Drawing.Size(344, 33)
        self._label15.TabIndex = 2
        self._label15.Text = "Please notify the script authors by posting the name and url of the webcomic into the forum thread."
        #
        # label16
        #
        self._label16.Location = System.Drawing.Point(13, 114)
        self._label16.Name = "label16"
        self._label16.Size = System.Drawing.Size(506, 37)
        self._label16.TabIndex = 8
        self._label16.Text = "Enter here the entire url of the very first page of the webcomic. For example:  http://www.giantitp.com/comics/oots0001.html"
        #
        # label17
        #
        self._label17.Location = System.Drawing.Point(13, 199)
        self._label17.Name = "label17"
        self._label17.Size = System.Drawing.Size(506, 36)
        self._label17.TabIndex = 9
        self._label17.Text = "Enter here the entire url of the comic image on the very first page of the webcomic. For example: http://www.giantitp.com/comics/images/oots0001.gif"
        #
        # label19
        #
        self._label19.Location = System.Drawing.Point(13, 292)
        self._label19.Name = "label19"
        self._label19.Size = System.Drawing.Size(506, 51)
        self._label19.TabIndex = 10
        self._label19.Text = "Enter here the  entire url of the second page of the webcomic. For example: http://www.giantitp.com/comics/oots0002.html"
        #
        # background_worker
        #
        self._background_worker.WorkerReportsProgress = True
        self._background_worker.WorkerSupportsCancellation = True
        self._background_worker.DoWork += webcomichelper.webcomic_helper_do_work
        self._background_worker.ProgressChanged += self.worker_progress_changed
        self._background_worker.RunWorkerCompleted += self.worker_completed
        #
        # MainForm
        #
        self.ClientSize = System.Drawing.Size(531, 414)
        self.Controls.Add(self._wizard)
        self.ShowIcon = False
        self.Text = "Webcomic Helper"
        self.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        self.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        self.MinimizeBox = False
        self.MaximizeBox = False
        self._wizard.ResumeLayout(False)
        self._wpURL.ResumeLayout(False)
        self._wpURL.PerformLayout()
        self._wpInfo.ResumeLayout(False)
        self._wpInfo.PerformLayout()
        self._wpFailedImage.ResumeLayout(False)
        self._wpFaliedLink.ResumeLayout(False)
        self._wpProgress.ResumeLayout(False)
        self.ResumeLayout(False)

    def before_switch_page(self, sender, e):

        #Value checking on the URL page
        if self._wizard.Pages[e.OldIndex] == self._wpURL:
            if self._firstPageUrl.Text.strip() == "":
                MessageBox.Show("First Page URL must be entered")
                e.Cancel = True
                return

            if self._imageUrl.Text.strip() == "":
                MessageBox.Show("Image URL must be entered")
                e.Cancel = True
                return

            if self._linkUrl.Text.strip() == "":
                MessageBox.Show("Second Page URL must be entered")
                e.Cancel = True
                return

        #Handling the back button on the various pages
        if self._wizard.Pages[
                e.OldIndex] == self._wpFailedImage or self._wizard.Pages[
                    e.OldIndex] == self._wpFaliedLink:
            e.NewIndex = self._wizard.Pages.IndexOf(self._wpURL)
            self._wizard.BackText = "Back"

        if self._wizard.Pages[
                e.OldIndex] == self._wpInfo and self._wizard.Pages[
                    e.NewIndex] == self._wpProgress:
            e.NewIndex = self._wizard.Pages.IndexOf(self._wpURL)
            return

        #Value checking on the info page
        if self._wizard.Pages[
                e.OldIndex] == self._wpInfo and self._webcomic_name.Text.strip(
                ) == "":
            MessageBox.Show("Webcomic Name cannot be empty")
            e.Cancel = True
            return

        if self._wizard.Pages[
                e.OldIndex] == self._wpInfo and self._wizard.Pages[
                    e.NewIndex] == self._wpFinished:
            r = self.save_webcomic()
            if r:
                return
            else:
                e.Cancel = True
                return

    def after_switch_page(self, sender, e):

        #URL page to progress page
        if self._wizard.Pages[e.NewIndex] == self._wpProgress:
            self._background_worker.RunWorkerAsync({
                "FirstPage":
                self._firstPageUrl.Text,
                "Image":
                self._imageUrl.Text,
                "SecondPage":
                self._linkUrl.Text,
                "Form":
                self
            })

            self._wizard.NextEnabled = False
            self._wizard.BackEnabled = False

        #Change the buttons on the finish page
        if self._wizard.Pages[e.NewIndex] == self._wpFinished:
            self._wizard.NextEnabled = False
            self._wizard.BackEnabled = False
            self._open_webcomic.Checked = True
            self._wizard.CancelText = "Finish"

    def wizard_cancel(self, sender, e):
        if self._background_worker.IsBusy or self._background_worker.CancellationPending:
            print "is busy"
            if not self._background_worker.CancellationPending:
                self._background_worker.CancelAsync()
                print "Canceling"

            e.Cancel = True
            return

        print "not busy, exiting"

    def worker_progress_changed(self, sender, e):
        self._ProgressText.Text = e.UserState
        self._ProgressBar.Value = e.ProgressPercentage

    def worker_completed(self, sender, e):
        #Error
        if e.Error:
            MessageBox.Show(e.Error.Message)
            self._wizard.SelectedPage = self._wpURL

        elif e.Cancelled == True:
            self.Close()

        else:

            self.result = e.Result

            if self.result._result == WebComicHelperResultEnum.NoImages:
                self._wizard.SelectedPage = self._wpFailedImage
                self._wizard.BackEnabled = True
                self._wizard.NextEnabled = False
                self._wizard.BackText = "Restart"
                self._wizard.CancelText = "Finish"

            elif self.result._result == WebComicHelperResultEnum.NoLinks:
                self._wizard.SelectedPage = self._wpFaliedLink
                self._wizard.BackEnabled = True
                self._wizard.NextEnabled = False
                self._wizard.BackText = "Restart"
                self._wizard.CancelText = "Finish"

            else:
                self._wizard.Next()

    def get_second_image_url(self):
        form = SecondImageUrl()

        r = form.ShowDialog()

        if r == System.Windows.Forms.DialogResult.OK:
            return form._second_image_url.Text

        else:
            return ""

    def get_next_page_link(self):
        form = NextPageLink()

        r = form.ShowDialog()

        if r == System.Windows.Forms.DialogResult.Cancel:
            return NextPageLinkFormResult("", None)

        return form.get_result()

    def get_info(self):
        info = {}

        info["Series"] = self._webcomic_name.Text
        info["Format"] = "Web Comic"

        web = System.Uri(self._firstPageUrl.Text)

        info["Web"] = web.Scheme + "://" + web.Host

        for control in self._info_textboxes:
            if control.Text.strip():
                info[control.Tag] = control.Text

        if self._BlackAndWhite.SelectedItem:
            info["BlackAndWhite"] = self._BlackAndWhite.SelectedItem

        if self._Manga.SelectedItem:
            if self._Manga.SelectedItem == "Yes (Right to Left)":
                info["Manga"] = "YesAndRightToLeft"
            else:
                info["Manga"] = self._Manga.SelectedItem

        return info

    def save_webcomic(self):
        webcomic = WebComic(self.get_info(), self._firstPageUrl.Text,
                            self.result)
        filepath = self.get_file_location()
        if not filepath:
            MessageBox.Show("A file path is required.", "Empty file path",
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
            return False

        result = webcomic.SaveToXml(filepath)

        if result:
            #Add to ComicRack
            self.book = ComicRack.App.AddNewBook(False)
            self.book.Series = self._webcomic_name.Text
            self.book.Format = "Web Comic"
            self.book.FilePath = filepath
            print "Added " + filepath + " to ComicRack"

        return result

    def get_file_location(self):
        self._save_file_dialog.FileName = self._webcomic_name.Text
        result = self._save_file_dialog.ShowDialog()
        if result == DialogResult.OK:
            return self._save_file_dialog.FileName
        else:
            return ""
class Controller(object):
    def __init__(self, __revit__, view, model):
        self.app = __revit__.Application
        self.doc = __revit__.ActiveUIDocument.Document
        self._view = view
        self._model = model
        self.excel_parameters = []
        self.exl_file_dir_path = "C:\\"
        self.config_file_dir_path = os.path.dirname(os.path.realpath(__file__))
        self._open_xl_file_Dialog = WinForms.OpenFileDialog()
        self._open_config_file_Dialog = WinForms.OpenFileDialog()
        self._save_config_file_Dialog = WinForms.SaveFileDialog()
        self._worker = BackgroundWorker()

        self._connectSignals()

    def _connectSignals(self):

        self._model.startProgress += self.startProgressBar
        self._model.ReportProgress += self.updateProgressBar
        self._model.endProgress += self.disableProgressBar
        self._worker.DoWork += lambda _, __: self._model.write_to_excel()
        self._worker.RunWorkerCompleted += self.run_worker_completed
        self._worker.WorkerSupportsCancellation = True
        self._view.Shown += self.On_MainForm_StartUp
        self._view.FormClosing += self.On_MainForm_Closing
        self._view._run_button.Click += self.run_button_Click
        self._view._browse_button.Click += self.browse_button_Click
        self._view._write_exl_button.Click += self.write_exl_button_Click
        self._view._del_spaces_button.Click += self.del_spaces_button_Click
        self._view._file_path_textBox.TextChanged += self.file_path_textBox_TextChanged
        self._view._shar_pars_check_all_btn.Click += self.shar_pars_check_all_btn_Click
        self._view._shar_pars_check_none_btn.Click += self.shar_pars_check_none_btn_Click
        self._view._builtin_pars_check_all_btn.Click += self.builtin_pars_check_all_btn_Click
        self._view._builtin_pars_check_none_btn.Click += self.builtin_pars_check_none_btn_Click
        self._view._space_id_comboBox.SelectedValueChanged += self.space_id_comboBox_SelectedValueChanged
        self._view._write_exl_checkBox.CheckedChanged += self.write_exl_checkBox_CheckChng
        self._view._load_stngs_button.Click += lambda _, __: self.load_settings(
            (self._view._space_id_comboBox, self._view._file_path_textBox, self
             ._view._shar_pars_checkedListBox, self._view.
             _builtin_pars_checkedListBox, self._view._write_exl_checkBox))
        self._view._save_stngs_button.Click += lambda _, __: self.save_settings(
        )

    def On_MainForm_StartUp(self, sender, args):
        self.load_project_parameters((self._view._space_id_comboBox,
                                      self._view._shar_pars_checkedListBox))
        self.load_builtin_parameters(self._view._builtin_pars_checkedListBox)

        if self._model.spaces_count > 0:
            self._view._del_spaces_button.Enabled = True

    def On_MainForm_Closing(self, sender, args):
        message = "Are you sure that you would like to close the form?"
        caption = "Form Closing"
        result = WinForms.MessageBox.Show(message, caption,
                                          WinForms.MessageBoxButtons.YesNo,
                                          WinForms.MessageBoxIcon.Question)
        # If the no button was pressed ...
        if result == WinForms.DialogResult.No:
            # cancel the closure of the form.
            args.Cancel = True

        elif result == WinForms.DialogResult.Yes:

            # Close Excel Application in Model class
            if self._model.excel is not None:
                self._model.excel.Quit()
                Marshal.FinalReleaseComObject(self._model.excel)

    def save_settings(self):

        try:
            filename = self._view._config_file_textBox.Text

            if self._view._config_file_textBox.Text == "":

                self._save_config_file_Dialog.InitialDirectory = self.config_file_dir_path
                self._save_config_file_Dialog.Filter = "JSON files (*.json)|*.json|All files (*.*)|*.*"
                self._save_config_file_Dialog.FilterIndex = 1
                self._save_config_file_Dialog.RestoreDirectory = True

                result = self._save_config_file_Dialog.ShowDialog(self._view)
                if result == WinForms.DialogResult.OK:
                    filename = self._save_config_file_Dialog.FileName
                    self._view._config_file_textBox.Text = filename
                else:
                    return

            config = {
                self._view._space_id_comboBox.Name:
                self._view._space_id_comboBox.SelectedItem,
                self._view._file_path_textBox.Name:
                self._view._file_path_textBox.Text,
                self._view._shar_pars_checkedListBox.Name:
                list(self._view._shar_pars_checkedListBox.CheckedItems),
                self._view._builtin_pars_checkedListBox.Name:
                list(self._view._builtin_pars_checkedListBox.CheckedItems),
                self._view._write_exl_checkBox.Name:
                self._view._write_exl_checkBox.Checked.ToString()
            }

            with io.open(filename, 'w', encoding='utf8') as file:
                json.dump(config,
                          file,
                          ensure_ascii=False,
                          indent=4,
                          sort_keys=True)

        except Exception as e:
            logger.error(e, exc_info=True)

    def load_settings(self, controls):

        self._open_config_file_Dialog.InitialDirectory = self.config_file_dir_path
        self._open_config_file_Dialog.Filter = "JSON files (*.json)|*.json"
        self._open_config_file_Dialog.FilterIndex = 2
        self._open_config_file_Dialog.RestoreDirectory = True

        result = self._open_config_file_Dialog.ShowDialog(self._view)
        if result == WinForms.DialogResult.OK:
            self._view._config_file_textBox.Clear()
            filename = self._open_config_file_Dialog.FileName
            self._view._config_file_textBox.Text = filename
        else:
            return

        try:
            with io.open(filename, 'r', encoding='utf8') as file:
                config = json.load(file)

                for c in controls:
                    if c.GetType() == clr.GetClrType(WinForms.ComboBox):
                        c.SelectedItem = config[c.Name]

                    elif c.GetType() == clr.GetClrType(WinForms.TextBox):
                        c.Text = config[c.Name]

                    elif c.GetType() == clr.GetClrType(WinForms.CheckBox):
                        if config[c.Name] == "True":
                            c.Checked = True
                        else:
                            c.Checked = False

                    elif c.GetType() == clr.GetClrType(
                            WinForms.CheckedListBox):
                        for item in config[c.Name]:
                            index = c.FindStringExact(item)
                            if (index != c.NoMatches):
                                c.SetItemChecked(index, True)

        except Exception as e:
            logger.error(e, exc_info=True)

    def get_parameter_bindings(self):
        try:
            prj_defs = set()
            binding_map = self.doc.ParameterBindings
            it = binding_map.ForwardIterator()
            it.Reset()
            while it.MoveNext():
                current_binding = it.Current
                if current_binding.Categories.Contains(
                        Category.GetCategory(self.doc,
                                             BuiltInCategory.OST_MEPSpaces)):
                    prj_defs.add(it.Key.Name)

            return prj_defs

        except Exception as e:
            logger.error(e, exc_info=True)
            pass

    def load_project_parameters(self, controls):
        internal_defs = self.get_parameter_bindings()
        for control in controls:
            control.Items.Clear()
            control.BeginUpdate()
            for par_name in sorted(internal_defs):
                if controls.index(control) == 0:
                    match = re.match(
                        r'(?<!.)(REFERENCED)?_?(ROOM)?_?(UNIQUE)?_?ID',
                        par_name, re.IGNORECASE)
                    if match:
                        control.Items.Add(par_name)
                else:
                    control.Items.Add(par_name)
            control.EndUpdate()
        controls[0].Items.Insert(0, "Please select a parameter...")
        controls[0].SelectedIndex = 0

    def shar_pars_check_all_btn_Click(self, sender, args):
        if self._view._shar_pars_checkedListBox.Items.Count > 0:
            i = 0
            while i < self._view._shar_pars_checkedListBox.Items.Count:
                self._view._shar_pars_checkedListBox.SetItemChecked(i, True)
                i += 1

    def shar_pars_check_none_btn_Click(self, sender, args):
        if self._view._shar_pars_checkedListBox.Items.Count > 0:
            i = 0
            while i < self._view._shar_pars_checkedListBox.Items.Count:
                self._view._shar_pars_checkedListBox.SetItemChecked(i, False)
                i += 1

    def builtin_pars_check_all_btn_Click(self, sender, args):
        if self._view._builtin_pars_checkedListBox.Items.Count > 0:
            i = 0
            while i < self._view._builtin_pars_checkedListBox.Items.Count:
                self._view._builtin_pars_checkedListBox.SetItemChecked(i, True)
                i += 1

    def builtin_pars_check_none_btn_Click(self, sender, args):
        if self._view._builtin_pars_checkedListBox.Items.Count > 0:
            i = 0
            while i < self._view._builtin_pars_checkedListBox.Items.Count:
                self._view._builtin_pars_checkedListBox.SetItemChecked(
                    i, False)
                i += 1

    def get_builtin_parameters(self):
        builtin_pars = set()
        bicId = [ElementId(BuiltInCategory.OST_MEPSpaces)]
        catlist = List[ElementId](bicId)
        paramIds = ParameterFilterUtilities.GetFilterableParametersInCommon(
            self.doc, catlist)
        for bpar in BuiltInParameter.GetValues(
                clr.GetClrType(BuiltInParameter)):

            try:
                bparId = ElementId(bpar)
                if bparId in paramIds:
                    builtin_pars.add(LabelUtils.GetLabelFor(bpar))

            except Exception as e:
                logger.error(e, exc_info=True)
                pass

        return builtin_pars

    def load_builtin_parameters(self, control):
        builtin_pars = self.get_builtin_parameters()

        control.Items.Clear()
        control.BeginUpdate()
        for par_name in sorted(builtin_pars):
            control.Items.Add(par_name)
            control.EndUpdate()

    def space_id_comboBox_SelectedValueChanged(self, sender, args):
        if self._view._space_id_comboBox.SelectedIndex != 0:
            self._view._run_button.Enabled = True
            self._model.search_id = self._view._space_id_comboBox.SelectedItem

            if self._view._file_path_textBox.Text != "" and self._model.spaces_count > 0:
                self._view._write_exl_button.Enabled = True
                self._view._write_exl_checkBox.Enabled = True

        else:
            self._view._run_button.Enabled = False
            self._view._write_exl_button.Enabled = False
            self._view._write_exl_checkBox.Enabled = False

    def file_path_textBox_TextChanged(self, sender, args):
        if sender.Text != "" and self._view._space_id_comboBox.SelectedIndex != 0:
            self._view._write_exl_checkBox.Enabled = True
            if self._model.spaces_count > 0:
                self._view._write_exl_button.Enabled = True

    def write_exl_checkBox_CheckChng(self, sender, args):
        if sender.CheckState == WinForms.CheckState.Checked:
            self._model.xl_write_flag = True
        else:
            self._model.xl_write_flag = False

    def browse_button_Click(self, sender, args):
        self._open_xl_file_Dialog.InitialDirectory = self.exl_file_dir_path
        self._open_xl_file_Dialog.Filter = "CSV files (*.csv)|*.csv|Excel Files|*.xls;*.xlsx"
        self._open_xl_file_Dialog.FilterIndex = 2
        self._open_xl_file_Dialog.RestoreDirectory = True

        result = self._open_xl_file_Dialog.ShowDialog(self._view)
        if result == WinForms.DialogResult.OK:
            self._view._file_path_textBox.Clear()
            filename = self._open_xl_file_Dialog.FileName
            self._view._file_path_textBox.Text = filename

    def run_button_Click(self, sender, args):
        self.excel_parameters = sorted(list(self._view._shar_pars_checkedListBox.CheckedItems) + \
                                list(self._view._builtin_pars_checkedListBox.CheckedItems))
        if len(self.excel_parameters) == 0:
            WinForms.MessageBox.Show("At least one parameter must be chosen!",
                                     "Task cancelled!",
                                     WinForms.MessageBoxButtons.OK,
                                     WinForms.MessageBoxIcon.Information)
            return

        self.excel_parameters.insert(
            0, self._view._space_id_comboBox.SelectedItem)

        self._model.xl_file_path = self._view._file_path_textBox.Text
        self._model.excel_parameters = self.excel_parameters
        self._model.main()

    def write_exl_button_Click(self, sender, args):
        self.excel_parameters = sorted(list(self._view._shar_pars_checkedListBox.CheckedItems) + \
                                list(self._view._builtin_pars_checkedListBox.CheckedItems))
        if len(self.excel_parameters) == 0:
            WinForms.MessageBox.Show("At least one parameter must be chosen!",
                                     "Task cancelled!",
                                     WinForms.MessageBoxButtons.OK,
                                     WinForms.MessageBoxIcon.Information)
            return

        self.excel_parameters.insert(
            0, self._view._space_id_comboBox.SelectedItem)

        self._model.xl_file_path = self._view._file_path_textBox.Text
        self._model.excel_parameters = self.excel_parameters

        if not self._worker.IsBusy:
            self._worker.RunWorkerAsync()

    def del_spaces_button_Click(self, sender, args):
        self._model.delete_spaces()
        self._view._del_spaces_button.Enabled = False
        self._view._write_exl_button.Enabled = False

    def startProgressBar(self, *args):
        self._view._progressBar.Value = 0
        self._view._progressBar.Maximum = args[0]

    def updateProgressBar(self, *args):
        self._view._progressBar.Value = args[0]

    def disableProgressBar(self, *args):
        if self._view._progressBar.Maximum > self._view._progressBar.Value:
            self._view._progressBar.Value = self._view._progressBar.Maximum
            WinForms.MessageBox.Show("Task completed successfully!",
                                     "Success!", WinForms.MessageBoxButtons.OK,
                                     WinForms.MessageBoxIcon.Information)

            self._view._del_spaces_button.Enabled = True

            if self._view._file_path_textBox.Text != "":
                self._view._write_exl_button.Enabled = True

    def run_worker_completed(self, sender, args):

        if args.Cancelled:
            WinForms.MessageBox.Show("Task canceled!", "Canceled!",
                                     WinForms.MessageBoxButtons.OK,
                                     WinForms.MessageBoxIcon.Information)

        elif args.Error:
            WinForms.MessageBox.Show("Error in writing parameters!", "Error!",
                                     WinForms.MessageBoxButtons.OK,
                                     WinForms.MessageBoxIcon.Error)

        else:
            self.disableProgressBar()

    def dispose(self):
        self._view.components.Dispose()
        WinForms.Form.Dispose(self._view)

    def run(self):
        '''
        Start our form object
        '''
        # Run the Application
        WinForms.Application.Run(self._view)
Ejemplo n.º 13
0
from System.Diagnostics import Process

#https://docs.microsoft.com/ru-ru/dotnet/api/system.componentmodel.backgroundworker?view=netcore-3.1

reload(sys)
sys.setdefaultencoding('utf-8')

workstatuspanel = StatusBarPanel()
splashForm = Form()
formConvert = Form()
progressbar1 = ProgressBar()
combobox1 = ComboBox()
textboxBrowse = TextBox()
start = Button()
canceling = Button()
worker = BackgroundWorker()
datetimepicker1 = DateTimePicker()
open = Button()
worker.WorkerReportsProgress = True
worker.WorkerSupportsCancellation = True

path_dir_root = os.path.dirname(os.path.abspath(__file__.decode('cp1251')))
path_dirname_ = path_dir_root + '\\' + 'templates'
textboxBrowse.Text = path_dir_root
mydir = textboxBrowse.Text + '\\' + u'Обработка Анкет'

state_dir = True

mydir0 = mydir + "\\" + u"Ошибки"
mydir1 = mydir + "\\" + u"Результаты Финал"
mydir2 = mydir + "\\" + u"Грамоты"