예제 #1
0
        public void UpdateSession(Session newSession)
        {
            _session = newSession;
            hScrollBar.Enabled = _session != null;
            vScrollBar.Enabled = _session != null;
            trackBarZoom.Visible = _session != null;

            UpdateBars();

            pictureBox.Refresh();
        }
예제 #2
0
		private void toolStripMenuItemImport_Click(object sender, EventArgs e)
		{
			using (var d = new FolderBrowserDialog())
			{
				d.SelectedPath = (string)Common.Instance.Parameters[Consts.s_importDir];
				if (d.ShowDialog() == DialogResult.OK)
				{
					var selectedItem = listBoxSessions.SelectedItem;

					Cursor.Current = Cursors.WaitCursor;
					try
					{
						var session = new Session(Path.GetFileName(d.SelectedPath));
                        if (session.Load(d.SelectedPath, (uint)Common.Instance.Parameters[Consts.s_importMinSize]))
						{
							listBoxSessions.SelectedItems.Clear();
							listBoxSessions.Items.Add(session);
							selectedItem = session;
						}

						foreach (string folder in Directory.GetDirectories(d.SelectedPath, "*", SearchOption.AllDirectories))
						{
							session = new Session(Path.GetFileName(folder));
                            if (session.Load(folder, (uint)Common.Instance.Parameters[Consts.s_importMinSize]))
							{
								listBoxSessions.SelectedItems.Clear();
								listBoxSessions.Items.Add(session);
								selectedItem = session;
							}
						}
					}
					finally
					{
						Cursor.Current = Cursors.Default;
					}

					if (selectedItem != null)
						listBoxSessions.SelectedItem = selectedItem;
				}
			}
		}
예제 #3
0
		private void listBoxSessions_SelectedValueChanged(object sender, EventArgs e)
		{
			selected = listBoxSessions.SelectedItems.Count == 1 ? listBoxSessions.SelectedItem as Session : null;
            pictureBox.UpdateSession(selected);

		}
예제 #4
0
		private void toolStripMenuItemCut_Click(object sender, EventArgs e)
		{
			Cursor.Current = Cursors.WaitCursor;
			try
			{
				var name = string.Format("Cut {0:yyyy-MM-dd HH.mm.ss}", DateTime.Now);
				if (!NameQuery(ref name))
					return;

				var session = new Session(name);
				if (session.Load(selected, Session.Inheritance.Cut))
				{
					listBoxSessions.SelectedItems.Clear();
					listBoxSessions.Items.Add(session);
					listBoxSessions.SelectedItem = session;
				}
			}
			finally
			{
				Cursor.Current = Cursors.Default;
			}
		}
예제 #5
0
        private void toolStripMenuItemMergeWizard_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                var matches = new List<Session>();

                var originalTilesHash = selected.GenerateHash();
                foreach (var sessionObject in listBoxSessions.Items)
                {
                    var session = sessionObject as Session;
                    if (session == null || session == selected)
                        continue;

                    var currentTilesHash = session.GenerateHash();
                    if (currentTilesHash.Keys.Any(originalTilesHash.ContainsKey))
                        matches.Add(session);
                }

                if (matches.Count == 0)
                {
                    MessageBox.Show(@"No matches found", @"Merge Finished", MessageBoxButtons.OK);
                    return;
                }

                var mergeWizard = new MergeWizard.MergeWizard(selected, matches);
                if (mergeWizard.StartWizard() == DialogResult.OK)
                {
                    if (MessageBox.Show(@"The merge process was sucessfull.
Should the merged sessions be removed?",
                                        @"Merge Finished", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        listBoxSessions.Items.Remove(selected);
                        foreach (var mergeSession in mergeWizard.MatchingSessions)
                            if (!mergeSession.Skipped) listBoxSessions.Items.Remove(mergeSession.Session);
                    }

                    selected = mergeWizard.FinalSession;
                    listBoxSessions.Items.Add(selected);
                    listBoxSessions.SelectedItem = selected;
                }
            }
            finally 
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #6
0
		public bool Load(Session session, Inheritance inheritance)
		{
			int left = int.MaxValue;
			int right = int.MinValue;
			int top = int.MaxValue;
			int bottom = int.MinValue;
			foreach (Tile tile in session.tiles)
			{
				if (session.selection.Contains(tile.X, tile.Y) ^ inheritance == Inheritance.Crop)
					continue;

				Tile clone = new Tile(tile);

				tiles.Add(clone);

				left = Math.Min(left, clone.X);
				right = Math.Max(right, clone.X + tile.Width);
				top = Math.Min(top, clone.Y);
				bottom = Math.Max(bottom, clone.Y + tile.Height);

				if (tile == session.chosen)
					chosen = clone;
			}

			foreach (Tile tile in tiles)
			{ 
				tile.X -= left;
				tile.Y -= top;
			}

			Init(right - left, bottom - top);

			return tiles.Count > 0;
		}